'use strict'; function modeOf(batch){return batch?.notificationMode||'normal';} function delivery(order,mode='normal'){ if(!order)return null; return mode==='normal'?{status:order.status,batchId:order.batchId||null,error:order.error||null}:order.notifications?.huizhou||null; } function updateDelivery(order,mode,patch){ if(mode==='normal')Object.assign(order,patch); else {if(!order.notifications?.huizhou)throw Error('惠州通知没有独立预留记录。');Object.assign(order.notifications.huizhou,patch);} return order; } function notifications(order){ if(!order)return undefined; const h=delivery(order,'huizhou'); return {normal:delivery(order),huizhou:h?{status:h.status,batchId:h.batchId||null,error:h.error||null,orderNos:[...(h.orderNos||[])],issues:[...(h.issues||[])]}:{status:'not_applicable',batchId:null,error:null,orderNos:[],issues:[]}}; } function needsRuntimeCheck(order){return !!order?.archive&&(['pending','batched'].includes(order.status)||['pending','batched','blocked'].includes(delivery(order,'huizhou')?.status));} function reserved(order){return !!order?.batchId||!!delivery(order,'huizhou')?.batchId;} module.exports={modeOf,delivery,updateDelivery,notifications,needsRuntimeCheck,reserved};