@pisell/private-materials 6.12.363 → 6.12.365

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/meta.js +1 -1
  5. package/build/lowcode/render/default/view.js +1 -1
  6. package/build/lowcode/view.js +1 -1
  7. package/es/components/bigSale/components/BookingFloatingPanel/useBookingPanelController.js +0 -1
  8. package/es/components/bigSale/components/ProductList/index.js +0 -1
  9. package/es/components/bigSale/components/TimeBar/index.js +0 -1
  10. package/es/components/bigSale/dialog.js +0 -1
  11. package/es/components/bigSale/hooks/useBigSaleContext.js +0 -1
  12. package/es/components/bigSale/hooks/useBigSaleProductListConfig.js +1 -0
  13. package/es/components/bigSale/hooks/useSelectFloorMapResourceForBigSale.js +0 -1
  14. package/es/components/bigSale/index.js +0 -1
  15. package/es/components/bigSale/templates/Kiosk/index.js +0 -1
  16. package/es/components/scanOrder/utils/toShoppingCartProducts.identity.test.cjs +79 -0
  17. package/es/components/scanOrder/utils/toShoppingCartProducts.js +7 -3
  18. package/es/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.js +0 -1
  19. package/es/components/ticketBooking/components/ProductDisplayAdapter/index.js +3 -0
  20. package/es/components/ticketBooking/components/addServiceVariant/addService.js +1 -0
  21. package/es/index.js +0 -2
  22. package/es/plus/multiCurrencySettlement/index.js +1 -1
  23. package/es/plus/pisellReservation/data/bookingToReservationTables.js +1 -1
  24. package/es/plus/pisellReservation/floorMap/floorPlanApi.js +1 -1
  25. package/es/plus/pisellReservation/floorMap/reservationMock.js +1 -1
  26. package/es/plus/saasDevice/devicePasscodes/model.js +4 -4
  27. package/es/plus/saleDetail/Base.js +0 -1
  28. package/es/plus/saleDetail/components/Client/hooks/useClientSelectorProps.js +0 -1
  29. package/es/plus/saleDetail/components/DetailActions/PrintAction.js +0 -1
  30. package/es/plus/saleDetail/components/DetailActions/index.js +0 -1
  31. package/es/plus/saleDetail/components/SummaryFinancialSections/index.js +0 -1
  32. package/es/plus/saleDetail/index.js +0 -1
  33. package/es/plus/saleDetail/tmpl/B/components/Dish/index.js +0 -1
  34. package/es/plus/saleDetail/tmpl/B/index.js +0 -1
  35. package/es/plus/salesSdk/utils/addProductWithFlowDebounced.js +1 -1
  36. package/es/plus/salesSdk/utils/bookingDate.js +1 -1
  37. package/es/plus/salesSdk/utils/enrichCartLineHolderDisplay.js +1 -1
  38. package/es/plus/walletPassGallery/components/timelineSection/index.js +4 -4
  39. package/es/private-materials/lowcode/authmodal/meta.d.ts +1 -0
  40. package/es/pro/Login2.0/AuthModal.d.ts +1 -1
  41. package/es/pro/Login2.0/index.d.ts +2 -2
  42. package/es/pro/Login2.0/shared/types.d.ts +1 -1
  43. package/lib/components/scanOrder/utils/toShoppingCartProducts.identity.test.cjs +79 -0
  44. package/lib/components/scanOrder/utils/toShoppingCartProducts.js +7 -3
  45. package/package.json +4 -4
  46. package/es/plus/pisellReservation/index.js +0 -17
  47. package/es/plus/salesSdk/index.js +0 -54
@@ -29,7 +29,7 @@ ${String((null==e?void 0:e.message)??e)}`})}finally{g(!1)}},k=async()=>{let e=h.
29
29
  ${eVt(t)}`})}catch(t){b({status:"error",message:`setBookingStatus(${e}) failed
30
30
  ${String((null==t?void 0:t.message)??t)}`})}finally{y(!1)}},_=async()=>{b({status:"running",message:"openCheckout running..."});try{let e=await l.openCheckout();b({status:"success",message:`openCheckout success
31
31
  ${eVt(e)}`})}catch(e){b({status:"error",message:`openCheckout failed
32
- ${String((null==e?void 0:e.message)??e)}`})}};return(0,eO.jsxs)("section",{className:"sales-sdk-demo__tab",children:[(0,eO.jsxs)("header",{className:"sales-sdk-demo__panel",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"详情展示"}),(0,eO.jsxs)("span",{children:["status: ",l.status," / ready: ",l.isReady?"yes":"no"]})]}),(0,eO.jsxs)("p",{className:"sales-sdk-demo__hint",children:["只读场景:调用 ",(0,eO.jsx)("code",{children:"sales.loadDetail(orderId)"})," 拉取服务端订单详情后展示客户 / 购物车 / 汇总。"]}),(0,eO.jsxs)("div",{className:"sales-sdk-demo__toolbar",children:[(0,eO.jsxs)("button",{type:"button",className:"sales-sdk-demo__primary",disabled:m,onClick:x,children:["一键查看详情(orderId = ",c.orderId,")"]}),(0,eO.jsxs)("button",{type:"button",className:"sales-sdk-demo__primary",disabled:m,onClick:_,children:["结账(orderId = ",c.orderId,")"]})]}),(0,eO.jsxs)("div",{className:"sales-sdk-demo__toolbar",style:{marginTop:8,gap:8,alignItems:"center"},children:[(0,eO.jsx)("span",{style:{fontSize:12,color:"#666"},children:"变更预约状态:"}),(0,eO.jsxs)("select",{value:h,onChange:e=>v(e.target.value),disabled:f||!l.isReady,children:[(0,eO.jsx)("option",{value:"confirmed",children:"confirmed"}),(0,eO.jsx)("option",{value:"pending",children:"pending"}),(0,eO.jsx)("option",{value:"checked_in",children:"checked_in"}),(0,eO.jsx)("option",{value:"completed",children:"completed"}),(0,eO.jsx)("option",{value:"cancelled",children:"cancelled"}),(0,eO.jsx)("option",{value:"no_show",children:"no_show"})]}),(0,eO.jsx)("button",{type:"button",className:"sales-sdk-demo__primary",disabled:f||!l.isReady,onClick:k,title:l.isReady?void 0:"请先点「一键查看详情」加载订单",children:f?"提交中...":`setBookingStatus(${h})`})]})]}),(0,eO.jsx)(eH9,{variant:"detail",value:o,onChange:d}),l.error?(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel sales-sdk-demo__panel--error",children:[(0,eO.jsx)("h3",{children:"SDK Error"}),(0,eO.jsx)("pre",{children:l.error.message})]}):null,(0,eO.jsx)(eH2,{sales:l,cart:a,customer:i,summary:n.summary,products:r.products}),(0,eO.jsx)(eH1,{entries:u})]})};function eVt(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}let eVl=e=>{let{cart:t,readOnly:l,onRemoveError:i,onRemoveSuccess:a,onEditBookingError:n}=e,r=async e=>{try{await t.removeItem(e),null==a||a(e)}catch(e){null==i||i(e)}},s=async e=>{try{await t.editCartLineBooking(e)}catch(e){console.error("[SalesSdk Demo] editCartLineBooking failed",e),null==n||n(e)}};return t.bookings.length,t.items.length,(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"Cart Items"}),(0,eO.jsxs)("span",{children:[t.items.length," item(s)"]})]}),t.items.length>0?(0,eO.jsx)("div",{className:"sales-sdk-demo__items",children:t.items.map((e,t)=>{var i,a;let n=(null==e||null==(i=e._identity)?void 0:i.unique_identification_number)??`${e.product_id}-${e.product_variant_id}-${t}`;return(0,eO.jsxs)("article",{className:"sales-sdk-demo__item",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__item-main",children:[e.cover?(0,eO.jsx)("img",{src:e.cover,alt:e.title}):null,(0,eO.jsxs)("div",{children:[(0,eO.jsx)("h4",{children:e.title||"Untitled product"}),(0,eO.jsxs)("p",{children:["Variant: ",e.variant_title||"-"," / Qty: ",e.num]}),(0,eO.jsxs)("p",{children:["Price: ",e.selling_price||"-"," / Original:"," ",e.original_price||"-"]}),(0,eO.jsxs)("p",{children:["Schedule: ",e.start_at||"-"," - ",e.end_at||"-"]}),e.note?(0,eO.jsxs)("p",{children:["Note: ",e.note]}):null]})]}),l?null:(0,eO.jsxs)("div",{className:"sales-sdk-demo__item-actions",children:[(null==(a=e._extend)?void 0:a.booking)!=null?(0,eO.jsx)("button",{type:"button",className:"sales-sdk-demo__secondary",onClick:()=>s(e),children:"编辑资源"}):null,(0,eO.jsx)("button",{type:"button",className:"sales-sdk-demo__danger",onClick:()=>r(e),children:"remove"})]})]},n)})}):(0,eO.jsx)("div",{className:"sales-sdk-demo__empty",children:"No cart item loaded."})]})},eVi={status:"idle"};function eVa(e){if(!e.startedAt||!e.finishedAt)return"";let t=e.finishedAt-e.startedAt;return t<1e3?`${t}ms`:`${(t/1e3).toFixed(2)}s`}let eVn=e=>{let{title:t,steps:l,oneClickLabel:i="一键测试用例",toolbarExtra:a,onAllDone:n,onReset:r,className:s}=e,[o,d]=(0,ex.useState)({}),[c,u]=(0,ex.useState)(!1),[p,m]=(0,ex.useState)(!1),[g,h]=(0,ex.useState)(null),v=(0,ex.useCallback)(e=>o[e]||eVi,[o]),f=(0,ex.useCallback)((e,t)=>{d(l=>({...l,[e]:{...l[e]||eVi,...t}}))},[]),y=(0,ex.useCallback)(async e=>{let t=Date.now();f(e.id,{status:"running",startedAt:t,finishedAt:void 0,result:void 0,error:void 0});try{let l=await e.run(),i=Date.now(),a={status:"success",result:l,startedAt:t,finishedAt:i};return f(e.id,a),a}catch(a){let l=Date.now(),i={status:"error",error:String((null==a?void 0:a.message)??a),startedAt:t,finishedAt:l};return f(e.id,i),i}},[f]),b=(0,ex.useCallback)(async e=>{if(!c&&!p){if(e.skip)return void f(e.id,{status:"skipped"});u(!0);try{await y(e)}finally{u(!1)}}},[c,p,y,f]),x=(0,ex.useCallback)(async()=>{if(c||p)return;u(!0);let e={};l.forEach(t=>{e[t.id]=t.skip?{status:"skipped"}:eVi}),d(e);try{for(let e of l){if(e.skip)continue;let t=await y(e);if("error"===t.status)break}}finally{u(!1),n&&d(e=>(n(e),e))}},[c,p,y,l,n]),k=(0,ex.useMemo)(()=>{let e={success:0,error:0,skipped:0,idle:0,running:0};return l.forEach(t=>{var l;let i=(null==(l=o[t.id])?void 0:l.status)??"idle";e[i]+=1}),e},[o,l]),_=(0,ex.useCallback)(async()=>{if(!c&&!p){if(h(null),r){m(!0);try{await r()}catch(e){h(String((null==e?void 0:e.message)??e));return}finally{m(!1)}}d({})}},[c,p,r]),w=c||p;return(0,eO.jsxs)("section",{className:["sales-sdk-demo__panel","sales-sdk-demo__steps",s].filter(Boolean).join(" "),children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:t}),(0,eO.jsxs)("span",{children:[k.success," ok / ",k.error," fail / ",k.skipped," skipped /"," ",k.idle+k.running," pending"]})]}),(0,eO.jsxs)("div",{className:"sales-sdk-demo__steps-toolbar",children:[(0,eO.jsx)("button",{type:"button",className:"sales-sdk-demo__primary",disabled:w||0===l.length,onClick:x,children:i}),(0,eO.jsx)("button",{type:"button",disabled:w,onClick:_,children:p?"resetting…":"reset"}),a]}),g?(0,eO.jsxs)("pre",{className:"sales-sdk-demo__step-error",children:["reset 失败: ",g]}):null,(0,eO.jsx)("ol",{className:"sales-sdk-demo__step-list",children:l.map((e,t)=>{let l=v(e.id),i=e.skip?"skipped":l.status;return(0,eO.jsxs)("li",{className:`sales-sdk-demo__step sales-sdk-demo__step--${i}`,children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__step-head",children:[(0,eO.jsx)("span",{className:"sales-sdk-demo__step-index",children:t+1}),(0,eO.jsxs)("div",{className:"sales-sdk-demo__step-meta",children:[(0,eO.jsx)("strong",{children:e.label}),e.description?(0,eO.jsx)("em",{className:"sales-sdk-demo__step-desc",children:e.description}):null]}),(0,eO.jsxs)("div",{className:"sales-sdk-demo__step-status",children:[(0,eO.jsx)("span",{children:i}),eVa(l)?(0,eO.jsx)("em",{children:eVa(l)}):null]}),(0,eO.jsx)("button",{type:"button",disabled:w||!!e.skip,onClick:()=>b(e),children:"单步执行"})]}),l.error?(0,eO.jsx)("pre",{className:"sales-sdk-demo__step-error",children:l.error}):null,"success"===l.status&&void 0!==l.result?(0,eO.jsx)("pre",{className:"sales-sdk-demo__step-result",children:function(e){if(void 0===e)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}(l.result)}):null]},e.id)})})]})};async function eVr(e,t,l){var i,a,n;if(Array.isArray(l)&&l.length>0&&null==t)return l[0]??null;if(null!=t){let l=e.customer.loadById(t);if(l)return l;let i=await e.customer.loadList({search:String(t)});return(null==(a=i.list)?void 0:a.find(e=>String(e.id)===String(t)))??(null==(n=i.list)?void 0:n[0])??null}return(null==(i=(await e.customer.loadList()).list)?void 0:i[0])??null}function eVs(e,t){let l={customer:null,customerList:[],product:null,products:[]},i=t.productPicker.productId??61743;return[{id:"customer.loadList",label:"customer.loadList",description:"从服务端拉默认一页客户列表",run:async()=>{try{let t=await e.customer.loadList();return l.customerList=t.list||[],t}catch(a){var t,i;if((null==(t=e.demoRuntime)?void 0:t.hasAuthToken)===!1&&(null==(i=e.demoRuntime)?void 0:i.fallbackCustomer)){let t=[e.demoRuntime.fallbackCustomer];return l.customerList=t,{list:t,total:t.length,page:1,pageSize:t.length,_fallback:"public-shell-walk-in-customer"}}throw a}}},{id:"customer.select",label:"customer.select",description:t.customerId?`按 customerId=${t.customerId} 选客户`:"默认选 customer.list[0]",run:async()=>{let i=await eVr(e,t.customerId,l.customerList);if(!i)throw Error("未找到可选客户,请检查 customerId 或客户列表");return e.customer.select(i),l.customer=i,i}},{id:"products.load",label:"products.load",description:"loadProducts(fixture.loadProductsParams)",run:async()=>{try{let i=await e.products.load({...t.loadProductsParams,menu_list_ids:[43775]});return l.products=Array.isArray(i)?i:[],i}catch(r){var a,n;if((null==(a=e.demoRuntime)?void 0:a.hasAuthToken)===!1&&"function"==typeof(null==(n=e.demoRuntime)?void 0:n.loadPublicProductDetail)){let a=await e.demoRuntime.loadPublicProductDetail(i,{schedule_date:t.loadProductsParams.schedule_date});if(!a)throw r;let n=null!=t.productPicker.num&&t.productPicker.num>0?t.productPicker.num:1,s={...a,isOpenDetailModal:!1,open_sold_weight:0,cartDetailValue:{key:`demo-public-${a.id}`,quantity:n}};return l.products=[s],[{...s,_fallback:"public-shell-product-detail"}]}throw r}}},{id:"cart.addProductWithFlow",label:"cart.addProductWithFlow",description:"加车编排:OS 决策 → legacy Info2 弹窗 (pisell1.handleOpenProductModal) → confirmDetail → 写入 tempOrder",run:async()=>{var a,n;let r=(a=l.products.length>0?l.products:e.products.products,n={...t.productPicker,productId:i},Array.isArray(a)&&0!==a.length?n.productId?a.find(e=>e.id===n.productId)??null:a[0]??null:null);if(!r)throw Error("未找到可加车商品:请确认 products.load 已成功且 catalog 不为空");l.product=r;let s=t.productPicker.num??1,o=await e.cart.addProductWithFlow(r,{quantity:s});if("cancelled"===o.status)throw Error("加车流程已取消(可能为规格弹窗、跨日日期、Holder 或资源抽屉中取消)");if("requiresDetail"===o.status)throw Error("命中 requiresDetail 但未配置 uiHosts.openProductDetail(请使用 SalesSdkDemoTabShell)");if("requiresBookingEdit"===o.status)throw Error("命中 requiresBookingEdit 但未配置 uiHosts.openBookingEdit(请使用 SalesSdkDemoTabShell)");return o}},{id:"cart.recalcSummary",label:"cart.recalcSummary",description:"触发 summary 重算",run:async()=>e.cart.recalcSummary()},{id:"cart.submit",label:"cart.submit",description:"调真实 OS submit API(执行前会弹确认框)",run:async()=>{var t;if((null==(t=e.demoRuntime)?void 0:t.hasAuthToken)===!1)return{_fallback:"public-shell-submit-skipped",reason:"public shell requires auth before real submit",items:e.cart.items.length,bookings:e.cart.bookings.length,summary:e.cart.summary,tempOrder:e.sales.tempOrder};if(!(!("u"<typeof window)&&window.confirm("一键测试将调用真实 submit API,确认继续?")))throw Error("用户取消 submit");return e.cart.submit()}}]}let eVo=()=>{let e=eI(),t=ehe(),l=ehr(),i=e_M(),a=ekm(),n=e_C(),[r,s]=(0,ex.useState)({}),[o,d]=(0,ex.useState)(null),c=(0,ex.useMemo)(()=>eHX(eHZ,r),[r]),u=(0,ex.useMemo)(()=>!("u"<typeof window)&&!!(window.localStorage.getItem("shop_pc_token")||window.localStorage.getItem("token")),[]),p=n_(async(t,l)=>{var i,a;let n=null==e||null==(a=e.appHelper)||null==(i=a.utils)?void 0:i.request;if("function"!=typeof(null==n?void 0:n.get))return null;let r=await n.get(`/h5/product/show/${t}`,l||{},{customToast:()=>{}});return(null==r?void 0:r.data)??null}),m=(0,ex.useMemo)(()=>{var e;return[{id:"sales.createNew",label:"sales.createNew",description:"创建一个新的 tempOrder",run:async()=>e.sales.createNew()},...eVs(e={sales:t,customer:l,products:i,cart:a,demoRuntime:{hasAuthToken:u,fallbackCustomer:{id:1,name:"Walk In",nickname:"Walk In",phone:"",email:"",country_calling_code:""},loadPublicProductDetail:p}},c)]},[t,l,i,a,c,u,p]),g=n_(async()=>{await t.restore(),await a.recalcSummary()});return eyw(n.summary),(0,eO.jsxs)("section",{className:"sales-sdk-demo__tab",children:[(0,eO.jsxs)("header",{className:"sales-sdk-demo__panel sales-sdk-demo__panel--warn",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"新建订单一键流程"}),(0,eO.jsxs)("span",{children:["status: ",t.status," / ready: ",t.isReady?"yes":"no"]})]}),(0,eO.jsx)("p",{className:"sales-sdk-demo__hint",children:"注意:此 Tab 会调用真实 OS 接口(createNew / addProductWithFlow / submit)。加车若需规格会打开 Info2 弹窗。submit 会弹二次确认,其它步骤直接执行。"})]}),(0,eO.jsx)(eH9,{variant:"create",value:r,onChange:s}),(0,eO.jsx)(eVn,{title:"步骤序列(点一键串行执行 / 也可单步)",steps:m,onReset:g}),t.error?(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel sales-sdk-demo__panel--error",children:[(0,eO.jsx)("h3",{children:"SDK Error"}),(0,eO.jsx)("pre",{children:t.error.message})]}):null,(0,eO.jsx)(eVl,{cart:a,onEditBookingError:e=>d(String((null==e?void 0:e.message)??e))}),o?(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel sales-sdk-demo__panel--error",children:[(0,eO.jsx)("h3",{children:"编辑资源失败"}),(0,eO.jsx)("pre",{children:o})]}):null,(0,eO.jsx)(eH2,{sales:t,cart:a,customer:l,summary:n.summary,products:i.products})]})},eVd=e=>{let{initialOrderId:t}=e,l=ehe(),i=ehr(),a=e_M(),n=ekm(),r=e_C(),s=(0,ex.useMemo)(()=>({...eHJ,...t?{orderId:t}:{}}),[t]),[o,d]=(0,ex.useState)({}),c=(0,ex.useMemo)(()=>({...eHX(s,o),orderId:null!=o.orderId?Number(o.orderId):s.orderId}),[s,o]),u=(0,ex.useMemo)(()=>{var e;return e={sales:l,customer:i,products:a,cart:n},[{id:"sales.loadDetail",label:"sales.loadDetail",description:`加载订单详情 orderId=${c.orderId}`,run:async()=>{if(!Number.isFinite(c.orderId)||c.orderId<=0)throw Error("orderId 必须为正整数");return e.sales.loadDetail(c.orderId)}},{id:"sales.setOrderNote",label:"sales.setOrderNote",description:null!=c.orderNote?`note="${c.orderNote}"`:"未配置 orderNote,跳过",skip:null==c.orderNote,run:async()=>e.sales.setOrderNote(c.orderNote??"")},{id:"sales.setShopDiscount",label:"sales.setShopDiscount",description:null!=c.shopDiscount?`shop_discount=${c.shopDiscount}`:"未配置 shopDiscount,跳过",skip:null==c.shopDiscount,run:async()=>e.sales.setShopDiscount(c.shopDiscount)},{id:"sales.setContactsInfo",label:"sales.setContactsInfo",description:void 0!==c.contactsInfo?`contacts_info=${JSON.stringify(c.contactsInfo)}`:"未配置 contactsInfo,跳过",skip:void 0===c.contactsInfo,run:async()=>e.sales.setContactsInfo(c.contactsInfo??null)},...eVs(e,c)]},[l,i,a,n,c]),p=n_(async()=>{await l.restore(),await n.recalcSummary()});return eyw(r.summary),(0,eO.jsxs)("section",{className:"sales-sdk-demo__tab",children:[(0,eO.jsxs)("header",{className:"sales-sdk-demo__panel sales-sdk-demo__panel--warn",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsxs)("h3",{children:["编辑订单一键流程(orderId = ",c.orderId,")"]}),(0,eO.jsxs)("span",{children:["status: ",l.status," / ready: ",l.isReady?"yes":"no"]})]}),(0,eO.jsx)("p",{className:"sales-sdk-demo__hint",children:"注意:此 Tab 会先 loadDetail 加载既有订单,再写入备注 / 整单优惠 / 联系人,最后追加客户 / 商品 / submit,均为真实 OS 接口。"})]}),(0,eO.jsx)(eH9,{variant:"edit",value:o,onChange:d}),(0,eO.jsx)(eVn,{title:"步骤序列(点一键串行执行 / 也可单步)",steps:u,onReset:p}),l.error?(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel sales-sdk-demo__panel--error",children:[(0,eO.jsx)("h3",{children:"SDK Error"}),(0,eO.jsx)("pre",{children:l.error.message})]}):null,(0,eO.jsx)(eVl,{cart:n}),(0,eO.jsx)(eH2,{sales:l,cart:n,customer:i,summary:r.summary,products:a.products})]})};function eVc(e){let t=qk(),l=evN(),i=(0,ex.useRef)(null),a=(0,ex.useCallback)(a=>{var n,r;return i.current=a,null==(n=a.setPromotionEvaluator)||n.call(a,e??null),null==(r=a.setGiftSelectResolver)||r.call(a,eyU(t.giftSelect,()=>i.current,{getUiHosts:()=>l})),a},[t.giftSelect,e,l]);return(0,ex.useEffect)(()=>()=>{var e,t;let l=i.current;null==l||null==(e=l.setPromotionEvaluator)||e.call(l,null),null==l||null==(t=l.setGiftSelectResolver)||t.call(l,null),i.current=null},[]),a}let eVu="YYYY-MM-DD";function eVp(){return ef()().format(eVu)}function eVm(e){return e.split(",").map(e=>e.trim()).filter(Boolean).map(e=>{let t=Number(e);return Number.isFinite(t)?t:e})}function eVg(e){let t=Number(e);return Number.isFinite(t)?t:void 0}function eVh(){return!("u"<typeof window)&&!!(window.localStorage.getItem("shop_pc_token")||window.localStorage.getItem("token"))}function eVv(){if("u"<typeof window)return null;try{let e=window.localStorage.getItem("customer")||window.localStorage.getItem("shop_pc_customer"),t=e?JSON.parse(e):null,l=Number((null==t?void 0:t.id)??(null==t?void 0:t.customer_id));return Number.isFinite(l)&&l>1?{...t,id:l}:null}catch{return null}}function eVf(e){return(null==e?void 0:e.id)??(null==e?void 0:e.product_id)}function eVy(e){let t=(null==e?void 0:e.title)||(null==e?void 0:e.name)||(null==e?void 0:e.product_title);return"string"==typeof t?t:t&&"object"==typeof t?t.en||t.zh||t.default||String(Object.values(t)[0]||"Untitled product"):`Product #${eVf(e)??"-"}`}function eVb(e){return!!((null==e?void 0:e.duration)||(null==e?void 0:e.durationMinutes)||(null==e?void 0:e.duration_minutes)||(null==e?void 0:e.service_duration))}function eVx(e,t){let l=new Set(t.map(e=>String(e)));return e.filter(e=>l.has(String(eVf(e))))}function eVk(e){return e.map(eVf).filter(e=>null!=e)}let eV_=()=>{var e,t,l,i,a;let n=eI(),r=null==n||null==(e=n.appHelper)?void 0:e.utils,s=null==n||null==(l=n.appHelper)||null==(t=l.utils)?void 0:t.pisellos,o=null==n||null==(a=n.appHelper)||null==(i=a.utils)?void 0:i.pisellosAllModule,d=eVc(null==r?void 0:r.promotionEvaluator),[c,u]=(0,ex.useState)(()=>eVh()),[p,m]=(0,ex.useState)(()=>(function(){var e;let t,l,i,a,n,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0],s=(t=ef()(),l=ef()(`${t.format(eVu)} 09:00:00`),i=ef()(`${t.format(eVu)} 18:00:00`),a=30*Math.ceil(t.minute()/30),(n=t.minute(0).second(0).millisecond(0).add(a,"minute")).isAfter(t)||(n=n.add(30,"minute")),n.isBefore(l)&&(n=l.add(60,"minute")),n.add(30,"minute").isAfter(i)&&(n=l.add(1,"day").add(60,"minute")),{date:n.format(eVu),startTime:n.format("HH:mm")}),o=s.date;return{productIds:"61321",resourceId:"",discountCustomerId:String((null==(e=eVv())?void 0:e.id)||""),preferredDiscountId:"",date:o,startTime:s.startTime,dateRangeStart:o,dateRangeEnd:ef()().add(1,"month").format(eVu),customPageId:"199665",channel:"pc",selectionOrder:"product_first",useResourceDateApi:!0,submitAfterCommit:r,applyBestDiscount:!0,slotDurationMinutes:10,rawResourcesJson:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"41077",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:eVp();return JSON.stringify([{id:e,main_field:`Demo Resource ${e}`,type:"single",capacity:1,times:[{start_at:`${t} 09:00:00`,end_at:`${t} 18:00:00`,event_list:[]}]}],null,2)}("demo-resource-1",o)}})(eVh())),[g,h]=(0,ex.useState)(null),[v,f]=(0,ex.useState)(null),y=eVm(p.resourceId).length?"scan_order":"appointment",b=p.channel||"pc",x="scan_order"===y?"scan_to_order":"online_store",k=`unifiedBookingSales-demo-${y}`;(0,ex.useEffect)(()=>{c&&m(e=>{var t;return{...e,submitAfterCommit:!0,discountCustomerId:e.discountCustomerId||String((null==(t=eVv())?void 0:t.id)||"")}})},[c]);let _=(e,t)=>{m(l=>({...l,[e]:t}))},w=()=>{let e=eVh();u(e),e&&m(e=>{var t;return{...e,submitAfterCommit:!0,discountCustomerId:e.discountCustomerId||String((null==(t=eVv())?void 0:t.id)||"")}})},j=async()=>{var e;if(!(null==s?void 0:s.getModule)||!(null==s?void 0:s.registerModule))throw Error("当前页面没有可用 pisellos runtime");let t=s.getModule(k);if(t)return await (null==(e=t.setOtherParams)?void 0:e.call(t,{platform:"PC",channel:x,businessCode:y})),d(t);let l=(null==o?void 0:o.UnifiedBookingSalesImpl)||(null==o?void 0:o.UnifiedBookingSales);if(!l)throw Error("当前 pisellosAllModule 未导出 UnifiedBookingSalesImpl,请先升级/链接 pisell_os");return t=new l(k),s.registerModule(t,{otherParams:{cacheId:k,platform:"PC",channel:x,businessCode:y,enableTempOrderPersist:!1}}),d(t)},S=(0,ex.useMemo)(()=>{let e,t={},l=async()=>(t.module=t.module||await j(),t.module),i=()=>eVm(p.productIds).map(e=>Number(e)).filter(Number.isFinite),a=()=>{let e=eVg(p.discountCustomerId),t=eVv();return{id:e||(null==t?void 0:t.id),source:e?null:t}},n=async e=>{let t=await l(),i=await t.loadPlannerContext({mode:y,productIds:e.productIds,resourceIds:e.resourceIds||eVm(p.resourceId),date:e.date,dateRange:e.dateRange,startTime:e.startTime,rawProducts:e.rawProducts,rawResources:p.useResourceDateApi?[]:function(e){if(!e.trim())return[];let t=JSON.parse(e);if(!Array.isArray(t))throw Error("rawResourcesJson 必须是数组");return t}(p.rawResourcesJson),useResourceDateApi:p.useResourceDateApi,productLoadParams:e.productIds.length?{product_ids:e.productIds.map(Number).filter(Number.isFinite)}:void 0});return h(i),i},r=async(e,i)=>{var a,n,r;let s=await l(),o=[];for(let t of e){let l=i.filter(e=>String(e.productId)===String(t)),a=!1;for(let t of l){let l=[...o,...t.assignments||[]],i=Array.from(new Map(l.map(e=>e.resourceId).map(e=>[String(e),e])).values());null==(n=s.setPlannerSelection)||n.call(s,{mode:y,productIds:e,date:p.date,startTime:t.startTime||p.startTime,resourceIds:i,assignments:l});let d=null==(r=s.validatePlannerSelection)?void 0:r.call(s);if(!d||!1!==d.ok){o.splice(0,o.length,...l),a=!0;break}}if(!a)throw Error(`商品 ${t} 没有可用的资源/时间组合`)}return t.selectedAssignments=o,h(null==(a=s.getPlannerSnapshot)?void 0:a.call(s)),o},s=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"planner.commit";return{id:e,label:"提交 bookings、应用商品券/折扣卡",description:p.submitAfterCommit?"先写入订单并应用最优优惠,再调用真实 submitSalesOrder":"写入 tempOrder 后应用最优优惠,不真实提交订单",run:async()=>{var e,i,n,r;let s=await l();if(p.submitAfterCommit&&!(!("u"<typeof window)&&window.confirm("将通过 OrderModule 调用真实 submit API,确认继续?")))throw Error("用户取消真实 submit");let o=await s.commitPlannerSelection({assignments:t.selectedAssignments,submitAfterCommit:!1});if(h(null==(e=s.getPlannerSnapshot)?void 0:e.call(s)),(null==o?void 0:o.validation)&&!1===o.validation.ok)throw Error(`commit validation failed:${!Array.isArray(r=o.validation.conflicts)||0===r.length?"unknown":r.map(e=>(null==e?void 0:e.message)||(null==e?void 0:e.type)||JSON.stringify(e)).join("; ")}`);let d=await (null==(i=s.applyPlannerDiscounts)?void 0:i.call(s,{customerId:a().id,preferredDiscountId:eVg(p.preferredDiscountId),applyBestDiscount:p.applyBestDiscount}));if(p.preferredDiscountId&&(null==d?void 0:d.preferredDiscountFound)!==!0)throw Error(`未找到指定券/折扣卡 ${p.preferredDiscountId}`);if(p.preferredDiscountId&&(null==d?void 0:d.preferredDiscountApplied)!==!0)throw Error(`指定券/折扣卡 ${p.preferredDiscountId} 未实际应用到预约商品`);let c=p.submitAfterCommit?await (null==(n=s.submitSalesOrder)?void 0:n.call(s)):void 0;if(p.submitAfterCommit&&!c)throw Error("已请求真实 submit,但没有拿到 submitResult,请检查 OrderModule submit");return{...o,submitResult:c,discount:d,submitRequested:p.submitAfterCommit,...p.submitAfterCommit?{}:{_submitSkipped:!0,reason:"submitAfterCommit=false,仅写入 tempOrder,没有调用 OrderModule submit"}}}}},o={id:"summary.refresh",label:"读取 summary / cart",description:"验证脱离正式 UI 后也能拿到订单数据",run:async()=>{var e,t,i;let a=await l();return{cart:null==(e=a.getCart)?void 0:e.call(a),summary:await (null==(t=a.getSummary)?void 0:t.call(a)),tempOrder:null==(i=a.getTempOrder)?void 0:i.call(a)}}},d=[{id:"module.resolve",label:"注册/获取 UnifiedBookingSales",description:`moduleKey=${k}`,run:async()=>{let e=await l();return{name:null==e?void 0:e.name,hasPlanner:"function"==typeof(null==e?void 0:e.loadPlannerContext),hasFlowSlots:"function"==typeof(null==e?void 0:e.resolveAssignableSlots),selectionOrder:p.selectionOrder}}},{id:"order.restore",label:"创建干净 tempOrder",description:"restoreOrder → addNewOrder,并同步当前优惠客户,避免沿用上一轮购物车",run:async()=>{var e,t,i;let n=await l();await (null==(e=n.restoreOrder)?void 0:e.call(n));let r=await (null==(t=n.addNewOrder)?void 0:t.call(n)),s=a();return s.id&&"function"==typeof n.updateOrderCustomer&&n.updateOrderCustomer({...s.source||{},customer_id:s.id}),{tempOrder:(null==(i=n.getTempOrder)?void 0:i.call(n))||r,discountCustomerId:s.id||null}}}];if("date_first"===p.selectionOrder)return[...d,{id:"date.availability",label:"拉取后端可用日期",description:"/schedule/product/availability/v2,校验场景日期是否可选",run:async()=>{var e;let i=await l();t.availableDates=await (null==(e=i.loadScheduleAvailableDate)?void 0:e.call(i,{startDate:p.dateRangeStart||p.date,endDate:p.dateRangeEnd||p.date,custom_page_id:eVg(p.customPageId),channel:b}))||[];let a=t.availableDates.find(e=>e.date===p.date);if(!a||"available"!==a.status)throw Error(`${p.date} 在后端可用日期接口中不可用`);return{selectedDate:a,total:t.availableDates.length}}},{id:"products.byDate",label:"按日期反推并拉取商品列表",description:"date_list.product_ids + other_product_ids 去重后拉商品",run:async()=>{var e;let i=await l();return t.loadedProducts=await (null==(e=i.loadProductsByScheduleDate)?void 0:e.call(i,{date:p.date,custom_page_id:eVg(p.customPageId),channel:b}))||[],{count:t.loadedProducts.length,products:t.loadedProducts.map(e=>({id:eVf(e),title:eVy(e)}))}}},{id:"products.filterByDayCells",label:"用当天平面图过滤不可预约商品",description:"普通商品保留;session/duration 当天无可用时间则剔除",run:async()=>{var e;let i=t.loadedProducts||[],a=eVk(i);await n({productIds:a,date:p.date,dateRange:{start:p.date,end:p.date},rawProducts:i});let r=await l(),s=await (null==(e=r.queryPlannerAvailability)?void 0:e.call(r,{mode:y,productIds:a,date:p.date,slotDurationMinutes:p.slotDurationMinutes}));t.dayProjection=s;let o=new Map(((null==s?void 0:s.productOptions)||[]).map(e=>[String(e.productId),e]));t.filteredProducts=i.filter(e=>{var t,l;if(!eVb(e)&&!(null==e||null==(l=e.extension_type)||null==(t=l.includes)?void 0:t.call(l,"session")))return!0;let i=o.get(String(eVf(e)));return(null==i?void 0:i.status)==="available"||(null==i?void 0:i.status)==="limited"});let d=eVk(t.filteredProducts),c=eVm(p.productIds).filter(e=>!d.some(t=>String(t)===String(e)));if(c.length)throw Error(`场景商品 ${c.join(",")} 不在 ${p.date} 的可用商品池中`);return{before:i.length,after:t.filteredProducts.length,selectedProductIds:eVm(p.productIds)}}},{id:"products.stage",label:"选中商品加入 tempOrder",description:"只 stage product,不创建 bookings",run:async()=>{var e;let i=await l(),a=eVm(p.productIds);if(!a.length)throw Error("请先填写至少一个商品 ID");t.selectedProductIds=a;let n=await (null==(e=i.stagePlannerProducts)?void 0:e.call(i,{productIds:a,rawProducts:eVx(t.filteredProducts||[],a),productLoadParams:{schedule_date:p.date}}));return{selectedProductIds:a,tempOrder:n}}},{id:"projection.range60",label:"生成选中日期前后 60 天平面图",description:"选中日期 -30 天到 +30 天",run:async()=>{var e,i,a;let r,s=(a=p.date,{start:(r=ef()(a||eVp())).subtract(30,"day").format(eVu),end:r.add(30,"day").format(eVu)}),o=t.selectedProductIds||eVm(p.productIds);await n({productIds:o,date:p.date,dateRange:s,rawProducts:eVx(t.filteredProducts||t.loadedProducts||[],o)});let d=await l(),c=await (null==(e=d.queryPlannerAvailability)?void 0:e.call(d,{mode:y,productIds:o,dateRange:s,slotDurationMinutes:p.slotDurationMinutes}));return t.rangeProjection=c,{range:s,dateSummary:null==c?void 0:c.dateSummary,cellCount:(null==c||null==(i=c.cells)?void 0:i.length)||0}}},{id:"slots.resolve",label:"进入资源分配并自动挑选可用 slot",description:"duration 商品按公共可用区间切片;session 商品按固定时间验证",run:async()=>{var e;let i=await l(),a=t.selectedProductIds||eVm(p.productIds),n=null==(e=i.resolveAssignableSlots)?void 0:e.call(i,{mode:y,productIds:a,date:p.date,slotDurationMinutes:p.slotDurationMinutes});return t.assignableSlots=(null==n?void 0:n.slots)||[],await r(a,t.assignableSlots),{slotCount:t.assignableSlots.length,selectedAssignments:t.selectedAssignments,conflicts:null==n?void 0:n.conflicts}}},s(),o];if("resource_first"===p.selectionOrder)return[...d,{id:"products.lockedResource.load",label:"拉取并过滤指定资源关联商品",description:"必须填写商品 ID、单个资源 ID、日期、开始时间;只保留 duration 商品",run:async()=>{var e;let a=await l(),n=eVm(p.productIds),r=eVm(p.resourceId);if(!n.length)throw Error("先选资源流程必须填写商品 ID");if(1!==r.length)throw Error("先选资源流程必须填写且只能填写一个资源 ID");if(!p.date||!p.startTime)throw Error("先选资源流程必须填写日期和开始时间");if(t.loadedProducts=await (null==(e=a.loadProducts)?void 0:e.call(a,{product_ids:i(),schedule_date:p.date}))||[],t.filteredProducts=t.loadedProducts.filter(e=>{var t,l;let i;return eVb(e)&&(t=r[0],(!Array.isArray(i=null==e||null==(l=e.product_resource)?void 0:l.resources)?[]:i.flatMap(e=>[...Array.isArray(null==e?void 0:e.default_resource)?e.default_resource:[],...Array.isArray(null==e?void 0:e.optional_resource)?e.optional_resource:[]]).map(e=>String(e))).includes(String(t)))}),t.selectedProductIds=eVk(t.filteredProducts),!t.selectedProductIds.length)throw Error(`没有 duration 商品关联资源 ${r[0]}`);return{loaded:t.loadedProducts.length,kept:t.filteredProducts.map(e=>({id:eVf(e),title:eVy(e)}))}}},{id:"projection.lockedResource",label:"生成指定日期/资源平面图",description:"锁定指定 resourceId,只查询这一天",run:async()=>{var e,i;let a=t.selectedProductIds||[];await n({productIds:a,resourceIds:eVm(p.resourceId),date:p.date,dateRange:{start:p.date,end:p.date},rawProducts:t.filteredProducts});let r=await l(),s=await (null==(e=r.queryPlannerAvailability)?void 0:e.call(r,{mode:y,productIds:a,resourceIds:eVm(p.resourceId),date:p.date,slotDurationMinutes:p.slotDurationMinutes}));return t.dayProjection=s,{cellCount:(null==s||null==(i=s.cells)?void 0:i.length)||0,resourceOptions:null==s?void 0:s.resourceOptions}}},{id:"slots.validateLockedTime",label:"用开始时间 + duration 校验资源可用",description:"可用则生成可直接提交的 assignments",run:async()=>{var e;let i=await l(),a=t.selectedProductIds||[],n=null==(e=i.resolveAssignableSlots)?void 0:e.call(i,{mode:y,productIds:a,resourceIds:eVm(p.resourceId),date:p.date,startTime:p.startTime,slotDurationMinutes:p.slotDurationMinutes});return t.assignableSlots=(null==n?void 0:n.slots)||[],await r(a,t.assignableSlots),{slotCount:t.assignableSlots.length,selectedAssignments:t.selectedAssignments,conflicts:null==n?void 0:n.conflicts}}},s(),o];let c={start:e=eVp(),end:ef()(e).add(31,"day").format(eVu)};return[...d,{id:"products.loadByIds",label:"按商品 ID 拉取商品列表",description:"product_first 只按场景参数商品 ID 拉取",run:async()=>{var e;let a=await l(),n=eVm(p.productIds);if(!n.length)throw Error("请先填写至少一个商品 ID");return t.loadedProducts=await (null==(e=a.loadProducts)?void 0:e.call(a,{product_ids:i(),schedule_date:p.date}))||[],t.selectedProductIds=n,{count:t.loadedProducts.length,products:t.loadedProducts.map(e=>({id:eVf(e),title:eVy(e)}))}}},{id:"products.stageAndMonthProjection",label:"stage 商品并生成 31 天平面图",description:"商品加入 tempOrder 后,从今天开始往后 31 天计算 projection",run:async()=>{var e,i,a;let r=await l(),s=t.selectedProductIds||eVm(p.productIds),o=await (null==(e=r.stagePlannerProducts)?void 0:e.call(r,{productIds:s,rawProducts:t.loadedProducts,productLoadParams:{schedule_date:p.date}}));await n({productIds:s,dateRange:c,rawProducts:t.loadedProducts});let d=await (null==(i=r.queryPlannerAvailability)?void 0:i.call(r,{mode:y,productIds:s,dateRange:c,slotDurationMinutes:p.slotDurationMinutes}));return t.rangeProjection=d,{range:c,tempOrder:o,dateSummary:null==d?void 0:d.dateSummary,cellCount:(null==d||null==(a=d.cells)?void 0:a.length)||0}}},{id:"date.pickFromProjection",label:"选择日期并校验是否可用",description:"日期可用性来自步骤 4 的 projection.dateSummary",run:async()=>{var e;let l=((null==(e=t.rangeProjection)?void 0:e.dateSummary)||[]).find(e=>e.date===p.date);if(!l||"available"!==l.status&&"limited"!==l.status)throw Error(`${p.date} 在当前商品平面图中不可选`);return l}},{id:"slots.resolve",label:"进入资源分配并自动挑选可用 slot",description:"duration 商品按公共可用区间切片;session 商品按固定时间验证",run:async()=>{var e;let i=t.selectedProductIds||eVm(p.productIds);await n({productIds:i,date:p.date,dateRange:{start:p.date,end:p.date},rawProducts:t.loadedProducts});let a=await l(),s=null==(e=a.resolveAssignableSlots)?void 0:e.call(a,{mode:y,productIds:i,date:p.date,slotDurationMinutes:p.slotDurationMinutes});return t.assignableSlots=(null==s?void 0:s.slots)||[],await r(i,t.assignableSlots),{slotCount:t.assignableSlots.length,selectedAssignments:t.selectedAssignments,conflicts:null==s?void 0:s.conflicts}}},s(),o]},[p,x,y,k,s,o]);return(0,eO.jsxs)("section",{className:"sales-sdk-demo__tab",children:[(0,eO.jsxs)("header",{className:"sales-sdk-demo__panel sales-sdk-demo__panel--warn",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"用户端预约 Planner Demo"}),(0,eO.jsx)("span",{children:k})]}),(0,eO.jsx)("p",{className:"sales-sdk-demo__hint",children:"这个 Demo 不做正式皮肤,只用步骤驱动 PisellOS UnifiedBookingSales。 商品、资源、日期、选择顺序都可以手动输入,用来验证 planner 和下单闭环。"})]}),(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"场景参数"}),(0,eO.jsx)("span",{children:y})]}),(0,eO.jsxs)("div",{className:"sales-sdk-demo__scenario-grid",children:[(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"商品 ID,逗号分隔"}),(0,eO.jsx)("input",{value:p.productIds,placeholder:"例如 61321",onChange:e=>_("productIds",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"指定资源 ID,填写后等价扫码点餐锁资源入口"}),(0,eO.jsx)("input",{value:p.resourceId,placeholder:"例如 41077",onChange:e=>_("resourceId",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"优惠客户 ID(留空读取当前登录客户)"}),(0,eO.jsx)("input",{value:p.discountCustomerId,placeholder:"登录后自动读取",onChange:e=>_("discountCustomerId",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"优先券/折扣卡 ID(可选)"}),(0,eO.jsx)("input",{value:p.preferredDiscountId,placeholder:"先跑一次可从结果中读取",onChange:e=>_("preferredDiscountId",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"日期"}),(0,eO.jsx)("input",{value:p.date,onChange:e=>_("date",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"开始时间"}),(0,eO.jsx)("input",{value:p.startTime,onChange:e=>_("startTime",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"查询开始日期"}),(0,eO.jsx)("input",{value:p.dateRangeStart,onChange:e=>_("dateRangeStart",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"查询结束日期"}),(0,eO.jsx)("input",{value:p.dateRangeEnd,onChange:e=>_("dateRangeEnd",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"custom_page_id(可用日期接口)"}),(0,eO.jsx)("input",{value:p.customPageId,placeholder:"例如 199665",onChange:e=>_("customPageId",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"availability channel"}),(0,eO.jsx)("input",{value:p.channel,placeholder:"pc",onChange:e=>_("channel",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"选择顺序"}),(0,eO.jsxs)("select",{value:p.selectionOrder,onChange:e=>{var t;return t=e.target.value,void m(e=>{let l;if("resource_first"!==t)return{...e,selectionOrder:t};let i={date:(l=ef()()).format(eVu),startTime:l.format("HH:mm")};return{...e,selectionOrder:t,date:i.date,startTime:i.startTime,dateRangeStart:i.date,dateRangeEnd:i.date}})},children:[(0,eO.jsx)("option",{value:"product_first",children:"先选商品"}),(0,eO.jsx)("option",{value:"date_first",children:"先选日期"}),(0,eO.jsx)("option",{value:"resource_first",children:"先选资源"})]})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"时间切片分钟"}),(0,eO.jsx)("input",{value:p.slotDurationMinutes,onChange:e=>_("slotDurationMinutes",Number(e.target.value)||10)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__checkbox",children:[(0,eO.jsx)("input",{type:"checkbox",checked:p.useResourceDateApi,onChange:e=>_("useResourceDateApi",e.target.checked)}),(0,eO.jsx)("span",{children:"使用资源日期接口"})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__checkbox",children:[(0,eO.jsx)("input",{type:"checkbox",checked:p.submitAfterCommit,onChange:e=>_("submitAfterCommit",e.target.checked)}),(0,eO.jsx)("span",{children:"commit 后真实提交订单"})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__checkbox",children:[(0,eO.jsx)("input",{type:"checkbox",checked:p.applyBestDiscount,onChange:e=>_("applyBestDiscount",e.target.checked)}),(0,eO.jsx)("span",{children:"提交后加载并应用最优商品券/折扣卡"})]})]}),p.useResourceDateApi?null:(0,eO.jsxs)("label",{className:"sales-sdk-demo__field sales-sdk-demo__field--wide",children:[(0,eO.jsx)("span",{children:"rawResources JSON"}),(0,eO.jsx)("textarea",{className:"sales-sdk-demo__textarea",rows:8,value:p.rawResourcesJson,onChange:e=>_("rawResourcesJson",e.target.value)})]})]}),(0,eO.jsx)(eVn,{title:"Planner 场景步骤",steps:S,oneClickLabel:"跑完整 planner case",toolbarExtra:(0,eO.jsx)("button",{type:"button",onClick:()=>{var e,t;let l=null==r?void 0:r.action;"function"!=typeof l?f("[SalesSdk Demo] appHelper.utils.action 不可用,无法拉起登录"):(f(null),null==r||null==(t=r.pubsub)||null==(e=t.once)||e.call(t,"pisell1.login.success",()=>{w()}),l({type:"pisell1.login",data:{notReload:!0,type:"plugin"},callback:()=>{w()}}))},children:c?"已登录":"登录"})}),v?(0,eO.jsx)("pre",{className:"sales-sdk-demo__step-error",children:v}):null,(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"最近 Planner Snapshot"}),(0,eO.jsx)("span",{children:"debug"})]}),(0,eO.jsx)("pre",{children:JSON.stringify(g,null,2)})]})]})},eVw="shop",eVj="online_store",eVS="unifiedBookingSales-demo-retail";function eVN(e){let t=Number(e);return Number.isFinite(t)?t:null}function eVM(e){return(null==e?void 0:e.id)??(null==e?void 0:e.product_id)}let eVC=()=>{var e;let t=eI(),l=null==t||null==(e=t.appHelper)?void 0:e.utils,i=null==l?void 0:l.pisellos,a=null==l?void 0:l.pisellosAllModule,n=eVc(null==l?void 0:l.promotionEvaluator),[r,s]=(0,ex.useState)({productId:"61168",quantity:2,expectedProductAmount:"10"}),[o,d]=(0,ex.useState)(null),c=async()=>{var e;if(!(null==i?void 0:i.getModule)||!(null==i?void 0:i.registerModule))throw Error("当前页面没有可用 pisellos runtime");let t=i.getModule(eVS);if(t)return await (null==(e=t.setOtherParams)?void 0:e.call(t,{platform:eVw,channel:eVj,businessCode:"retail"})),n(t);let l=(null==a?void 0:a.UnifiedBookingSalesImpl)||(null==a?void 0:a.UnifiedBookingSales);if(!l)throw Error("当前 pisellosAllModule 未导出 UnifiedBookingSalesImpl,请先升级/链接 pisell_os");return t=new l(eVS),i.registerModule(t,{otherParams:{cacheId:eVS,platform:eVw,channel:eVj,businessCode:"retail",enableTempOrderPersist:!1}}),n(t)},u=(0,ex.useMemo)(()=>{let e={},t=Number(r.productId),i=async()=>(e.module=e.module||await c(),e.module),a=async e=>{var l,i,a,n,r;let s,o;return{...{productTotal:(o=Array.isArray((s=(null==(a=e.getTempOrder)?void 0:a.call(e))||{}).products)?s.products:[],o.filter(e=>Number((null==e?void 0:e.product_id)??(null==e?void 0:e.id))===t).reduce((e,t)=>{var l;return e+(eVN((null==t||null==(l=t.metadata)?void 0:l.main_product_selling_price)??(null==t?void 0:t.selling_price)??(null==t?void 0:t.price))||0)*(eVN((null==t?void 0:t.num)??(null==t?void 0:t.quantity))||1)},0)),promotionLines:o.filter(e=>Number((null==e?void 0:e.product_id)??(null==e?void 0:e.id))===t).map(e=>{var t;return{productId:(null==e?void 0:e.product_id)??(null==e?void 0:e.id),quantity:null==e?void 0:e.num,sellingPrice:null==e?void 0:e.selling_price,promotion:null==e||null==(t=e.metadata)?void 0:t._promotion}}),giftActions:null==(n=e.getLastGiftActions)?void 0:n.call(e),unfulfilledPromotions:null==(r=e.getUnfulfilledPromotions)?void 0:r.call(e),tempOrder:s},summary:await (null==(l=e.getSummary)?void 0:l.call(e)),cart:null==(i=e.getCart)?void 0:i.call(e)}};return[{id:"retail.module.resolve",label:"注册/获取 UnifiedBookingSales",description:"绑定 promotion evaluator 与赠品 resolver;不初始化 planner",run:async()=>{var e,t;let a=await i();"function"==typeof(null==l?void 0:l.loadPromotionStrategies)&&await l.loadPromotionStrategies(),n(a);let r=(null==l||null==(t=l.promotionEvaluator)||null==(e=t.getStrategyConfigs)?void 0:e.call(t))||[];return{name:null==a?void 0:a.name,hasPlanner:"function"==typeof(null==a?void 0:a.queryPlannerAvailability),evaluatorAvailable:!!(null==l?void 0:l.promotionEvaluator),giftResolverAvailable:"function"==typeof(null==a?void 0:a.setGiftSelectResolver),strategyConfigCount:Array.isArray(r)?r.length:null}}},{id:"retail.order.create",label:"创建干净零售 tempOrder",description:"不创建 booking,不拉取资源或平面图",run:async()=>{var e,t;let l=await i();return await (null==(e=l.restoreOrder)?void 0:e.call(l)),{tempOrder:await (null==(t=l.addNewOrder)?void 0:t.call(l))}}},{id:"retail.product.load",label:"拉取普通商品",description:"商品不需要 session、duration 或资源关联",run:async()=>{var l,a,n,r,s;let o;if(!Number.isFinite(t)||t<=0)throw Error("请填写有效商品 ID");let d=await i();if(e.product=(await (null==(l=d.loadProducts)?void 0:l.call(d,{product_ids:[t]}))||[]).find(e=>Number(eVM(e))===t),!e.product)throw Error(`没有加载到商品 ${t}`);return{id:eVM(e.product),title:"string"==typeof(o=(null==(s=e.product)?void 0:s.title)||(null==s?void 0:s.name)||(null==s?void 0:s.product_title))?o:o&&"object"==typeof o?o.en||o.zh||o.default||String(Object.values(o)[0]||"Untitled product"):`Product #${eVM(s)??"-"}`,price:null==(a=e.product)?void 0:a.price,duration:null==(n=e.product)?void 0:n.duration,resourceRelation:null==(r=e.product)?void 0:r.product_resource}}},{id:"retail.cart.stage",label:"加入零售购物车",description:"仅写普通商品行;不创建 bookings",run:async()=>{var l,a,n;let r=await i();await (null==(l=r.stageRetailProducts)?void 0:l.call(r,{productIds:[t],rawProducts:[e.product]}));let s=(null==(a=r.getTempOrder)?void 0:a.call(r))||{};if(e.line=(s.products||[]).find(e=>Number((null==e?void 0:e.product_id)??(null==e?void 0:e.id))===t),!e.line)throw Error(`商品 ${t} 未写入 tempOrder`);return{line:e.line,bookingCount:(null==(n=s.bookings)?void 0:n.length)||0}}},{id:"retail.promotion.apply",label:"设置数量并验证营销策略",description:"数量写路径会自动计算;这里额外显式 applyPromotion 以便观察结果",run:async()=>{var t,l,n,s;if(!Number.isFinite(r.quantity)||r.quantity<1)throw Error("数量必须大于 0");let o=await i();await (null==(t=o.updateOrderProductQuantity)?void 0:t.call(o,{...{product_id:Number((null==(n=e.line)?void 0:n.product_id)??(null==n?void 0:n.id)),product_variant_id:Number((null==n?void 0:n.product_variant_id)??0),unique_identification_number:(null==n||null==(s=n.metadata)?void 0:s.unique_identification_number)||(null==n?void 0:n.unique_identification_number),product_sku:null==n?void 0:n.product_sku,product_bundle:null==n?void 0:n.product_bundle},num:r.quantity})),await (null==(l=o.applyPromotion)?void 0:l.call(o));let c=await a(o),u=eVN(r.expectedProductAmount);if(null!==u&&Math.abs(c.productTotal-u)>.01)throw Error(`营销策略未达到预期:商品合计 ${c.productTotal.toFixed(2)},期望 ${u.toFixed(2)}`);return d(c),{...c,verified:null===u||.01>=Math.abs(c.productTotal-u)}}},{id:"retail.summary.read",label:"读取零售 cart / summary",description:"确认没有 booking,保留促销行、赠品动作和总价诊断",run:async()=>{let e=await i(),t=await a(e);return d(t),t}}]},[r,n,i,a,null==l?void 0:l.promotionEvaluator]),p=async()=>{var e,t;let l=await c();await (null==(e=l.restoreOrder)?void 0:e.call(l)),await (null==(t=l.addNewOrder)?void 0:t.call(l)),d(null)};return(0,eO.jsxs)("section",{className:"sales-sdk-demo__tab",children:[(0,eO.jsxs)("header",{className:"sales-sdk-demo__panel sales-sdk-demo__panel--warn",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"零售 UnifiedBookingSales Demo"}),(0,eO.jsx)("span",{children:"retail / no planner required"})]}),(0,eO.jsx)("p",{className:"sales-sdk-demo__hint",children:"用 UnifiedBookingSales 的购物车和营销能力测试普通零售商品。不会请求资源、生成平面图或创建 booking。"})]}),(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"测试参数"}),(0,eO.jsx)("span",{children:"默认用 61168 x 2 验证两件价 10"})]}),(0,eO.jsxs)("div",{className:"sales-sdk-demo__field-grid",children:[(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"商品 ID"}),(0,eO.jsx)("input",{value:r.productId,onChange:e=>s(t=>({...t,productId:e.target.value}))})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"数量"}),(0,eO.jsx)("input",{value:r.quantity,onChange:e=>s(t=>({...t,quantity:Number(e.target.value)||1}))})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"期望商品合计"}),(0,eO.jsx)("input",{value:r.expectedProductAmount,onChange:e=>s(t=>({...t,expectedProductAmount:e.target.value}))})]})]})]}),(0,eO.jsx)(eVn,{title:"零售策略步骤",oneClickLabel:"验证零售营销策略",steps:u,onReset:p}),(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"最近零售结果"}),(0,eO.jsx)("span",{children:"debug"})]}),(0,eO.jsx)("pre",{className:"sales-sdk-demo__snapshot",children:JSON.stringify(o,null,2)})]})]})},eVT="sales-sdk-demo",eVP=function(e){var t;let{osKey:l=eVT,orderId:i,businessCode:a,otherParams:n,rulesHooks:r,className:s}=e,o=["sales-sdk-demo",s].filter(Boolean).join(" "),d=l||eVT,c={businessCode:a,otherParams:n,rulesHooks:r,autoBootstrap:!1};return(null==(t=c.otherParams)?void 0:t.platform)||(c.otherParams={platform:"shop"}),(0,eO.jsx)("div",{className:o,children:(0,eO.jsx)(e_.Tabs,{className:"sales-sdk-demo__tabs",defaultActiveKey:"create",destroyInactiveTabPane:!0,items:[{key:"detail",label:"详情展示",children:(0,eO.jsx)(e__,{osKey:`${d}-detail`,...c,children:(0,eO.jsx)(eVe,{initialOrderId:i??eHK.orderId})})},{key:"create",label:"新建",children:(0,eO.jsx)(eHG,{osKey:`${d}-create`,...c,children:(0,eO.jsx)(eVo,{})})},{key:"edit",label:"编辑",children:(0,eO.jsx)(eHG,{osKey:`${d}-edit`,...c,children:(0,eO.jsx)(eVd,{initialOrderId:i??eHJ.orderId})})},{key:"planner-appointment",label:"用户端预约",children:(0,eO.jsx)(eHG,{osKey:`${d}-planner-appointment`,...c,businessCode:c.businessCode||"appointment",autoInitBookingContext:!1,autoRestoreOnInit:!1,children:(0,eO.jsx)(eV_,{})})},{key:"unified-retail",label:"零售模板",children:(0,eO.jsx)(eHG,{osKey:`${d}-unified-retail`,...c,businessCode:c.businessCode||"retail",autoInitBookingContext:!1,autoRestoreOnInit:!1,children:(0,eO.jsx)(eVC,{})})}]})})};function eVA(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,l=Number(e);return Number.isNaN(l)?t:l}function eVI(e){let t=Math.floor(Number(e));return Number.isNaN(t)||t<1?1:t}function eVD(e){if("string"==typeof e)return e.trim();if(!e||"object"!=typeof e||Array.isArray(e))return"";for(let t of["auto","original","en","zh-CN","zh-HK","ja","pt"]){let l=e[t];if("string"==typeof l&&l.trim())return l.trim()}let t=Object.values(e).find(e=>"string"==typeof e&&e.trim());return"string"==typeof t?t.trim():""}function eVE(e){let{orderProducts:t,amountSymbol:l="$"}=e;return Array.isArray(t)?t.map((e,t)=>{var i,a,n,r,s,o,d,c,u,p,m,g,h;let v,f,y,b,x,k,_,w,j,S,N,M,C,T=eVI(null==e?void 0:e.num),P=(f=(null==(v=(null==e||null==(s=e._origin)?void 0:s.callbackData)||{})?void 0:v.origin)||{},y=(null==e||null==(o=e._origin)?void 0:o.sourceItem)||{},eVA(e.selling_price,NaN)||eVA(e.original_price,NaN)||eVA(null==v?void 0:v.price,NaN)||eVA(null==f?void 0:f.price,NaN)||eVA(null==y?void 0:y.price,0)),A=(null==e||null==(i=e._origin)?void 0:i.callbackData)||{},I="string"==typeof(null==e?void 0:e.identity_key)&&e.identity_key.length>0?e.identity_key:void 0,D=I??`${e.product_id??"p"}_${e.product_variant_id}_${t}`,E=("string"==typeof(null==A?void 0:A.product_option_string)?A.product_option_string.trim():"")||function(e){var t,l,i;let a=null==e?void 0:e.product_variant_id;if(null==a||""===a||0>=Number(a))return"";let n=(null==e||null==(t=e.metadata)?void 0:t.origin)||(null==e||null==(i=e._origin)||null==(l=i.callbackData)?void 0:l.origin)||{},r=(Array.isArray(null==n?void 0:n.variant)?n.variant:[]).find(e=>Number(null==e?void 0:e.id)===Number(a));if(!r)return"";let s=null==r?void 0:r.sku_ids;if(null!=s&&""!==String(s).trim()){let e=function(e,t){let l=Array.isArray(null==e?void 0:e.variant_group)?e.variant_group:[],i=[];for(let e of String(t||"").split("_").map(e=>e.trim()).filter(Boolean)){let t=e.indexOf(":");if(t<=0)continue;let a=Number(e.slice(0,t)),n=Number(e.slice(t+1));if(Number.isNaN(a)||Number.isNaN(n))continue;let r=function(e,t){return e.find(e=>Number(null==e?void 0:e.id)===Number(t))}(l,a);if(!r)continue;let s=String((null==r?void 0:r.name)??"").trim(),o=function(e,t){let l=(Array.isArray(null==e?void 0:e.variant_item)?e.variant_item:[]).find(e=>Number(null==e?void 0:e.id)===Number(t));return String((null==l?void 0:l.name)??("string"==typeof(null==l?void 0:l.title)?l.title:null==l?void 0:l.title)??""??"").trim()}(r,n);s&&o?i.push(`${s}: ${o}`):o?i.push(o):s&&i.push(s)}return i.join(", ")}(n,String(s));if(e)return e}return function(e,t){let l=Array.isArray(null==e?void 0:e.variant_group)?e.variant_group:[],i=(null==t?void 0:t.name)||(null==t?void 0:t.title);if(!i||"object"!=typeof i)return"";let a=[];for(let e of l){let t=null==e?void 0:e.position_id;if(null==t)continue;let l=i[String(t)]??i[t];if(null==l||""===l)continue;let n=String((null==e?void 0:e.name)??"").trim(),r=String(l).trim();n&&r?a.push(`${n}: ${r}`):r&&a.push(r)}return a.length?a.join(", "):Object.values(i).filter(e=>null!=e&&""!==String(e).trim()).map(e=>String(e).trim()).join(" / ")}(n,r)}(e)||void 0,z={_id:D,rowKey:D,identity_key:I,id:e.product_id,product_id:e.product_id,product_variant_id:e.product_variant_id,note:(null==e?void 0:e.note)!=null?String(e.note):"",name:(k=(null==(x=(null==(b=(null==e?void 0:e._origin)||{})?void 0:b.callbackData)||{})?void 0:x.origin)||{},_=(null==b?void 0:b.sourceItem)||{},eVD(null==e?void 0:e.product_title)||eVD(null==e||null==(d=e.metadata)?void 0:d.product_title)||eVD(null==x?void 0:x.product_title)||eVD(null==k?void 0:k.product_title)||eVD(null==_?void 0:_.product_title)||eVD(null==b?void 0:b.product_title)||eVD(null==x?void 0:x.name)||eVD(null==x?void 0:x.title)||eVD(null==k?void 0:k.name)||eVD(null==k?void 0:k.title)||eVD(null==_?void 0:_.name)||eVD(null==_?void 0:_.title)||eVD(null==b?void 0:b.name)||eVD(null==b?void 0:b.title)||(null==b||null==(u=b.resources)||null==(c=u[0])?void 0:c.main_field)||(null==e||null==(p=e.metadata)?void 0:p.resource_name)||`Product #${e.product_id??"unknown"}`),image:(S=(null==(j=(null==(w=(null==e?void 0:e._origin)||{})?void 0:w.callbackData)||{})?void 0:j.origin)||{},N=(null==w?void 0:w.sourceItem)||{},(null==j?void 0:j.image)||(null==j?void 0:j.cover)||(null==S?void 0:S.image)||(null==S?void 0:S.cover)||(null==N?void 0:N.image)||(null==N?void 0:N.cover)||(null==w?void 0:w.image)||(null==w?void 0:w.cover)||""),num:T,price:P,total:P,origin_total:eVA(e.original_price,P),symbol:l,options:(M=(null==e||null==(m=e._origin)?void 0:m.callbackData)||{},(Array.isArray(null==e||null==(g=e.product_sku)?void 0:g.option)?e.product_sku.option:Array.isArray(null==e?void 0:e.product_option_item)?e.product_option_item:Array.isArray(null==M?void 0:M.option)?M.option:[]).map(e=>{let t=eVA((null==e?void 0:e.add_price)??(null==e?void 0:e.price),0),l=eVI(null==e?void 0:e.num);return{id:eVA((null==e?void 0:e.product_option_item_id)??(null==e?void 0:e.option_group_item_id)),name:(null==e?void 0:e.name)||(null==e?void 0:e.title)||(null==e?void 0:e.label)||(null==e?void 0:e.option_group_item_name)||"",num:l,price:t,total:t*l,origin_total:t*l}})),bundle:(Array.isArray(null==(C=(null==e||null==(h=e._origin)?void 0:h.callbackData)||{})?void 0:C.bundle)?C.bundle:(null==e?void 0:e.product_bundle)||[]).map((e,t)=>{let l=eVA((null==e?void 0:e.price)??(null==e?void 0:e.product_price)??(null==e?void 0:e.custom_price),0),i=eVI(null==e?void 0:e.num),a=Array.isArray(null==e?void 0:e.option)?e.option:[];return{id:eVA((null==e?void 0:e.id)??(null==e?void 0:e.bundle_product_id),t),name:(null==e?void 0:e.name)||(null==e?void 0:e.title)||"",num:i,price:l,total:l*i,origin_total:l*i,options:a.map(e=>{let t=eVA((null==e?void 0:e.add_price)??(null==e?void 0:e.price),0),l=eVI(null==e?void 0:e.num);return{id:eVA((null==e?void 0:e.product_option_item_id)??(null==e?void 0:e.option_group_item_id)),name:(null==e?void 0:e.name)||(null==e?void 0:e.title)||(null==e?void 0:e.label)||(null==e?void 0:e.option_group_item_name)||"",num:l,price:t,total:t*l,origin_total:t*l}})}}),_origin:null==e?void 0:e._origin,isNormalProduct:!0,...E?{product_option_string:E}:{}};if(e.product_sku?z.product_sku=e.product_sku:Array.isArray(e.product_option_item)&&e.product_option_item.length&&(z.product_option_item=e.product_option_item),Array.isArray(e.product_bundle)&&e.product_bundle.length&&(z.product_bundle=e.product_bundle),null==e||null==(a=e.metadata)?void 0:a.venue_booking){let t=e._origin||{},l=e.metadata||{},i=t.start_date,a=t.start_time,s=t.end_date,o=t.end_time;z.start_date=i&&a?`${i} ${a}`:l.start_time||"",z.end_date=s&&o?`${s} ${o}`:l.end_time||"",z.start_time=a||"",z.end_time=o||"",z.duration_type=t.sub_type||"minutes",z.resource_id=l.resource_id,z.relation_form_name=l.resource_name||(null==(r=t.resources)||null==(n=r[0])?void 0:n.main_field)||"",Array.isArray(t.resources)&&(z.resources=t.resources)}return z}):[]}let eVz=["init","product","check","error"],eVO=()=>{var e;let t=eI();return(null==t||null==(e=t.appHelper)?void 0:e.utils)||{}};function eVL(e,t,l){if("function"!=typeof(null==e?void 0:e[t]))return l;let i=e[t]();return i&&"function"==typeof(null==i?void 0:i.then)?l:i??l}async function eV$(e,t){for(var l=arguments.length,i=Array(l>2?l-2:0),a=2;a<l;a++)i[a-2]=arguments[a];if(!e)throw Error("scanOrder module not found");if("function"!=typeof(null==e?void 0:e[t]))throw Error(`scanOrder action "${t}" not found`);return e[t](...i)}let eVR=()=>{var e,t;let l=eVO();return{isLogin:!!(null==l||null==(t=l.token)||null==(e=t.get)?void 0:e.call(t)),openLoginModal:e=>{let{callback:t}=e||{},{pubsub:i}=l;i.once("pisell1.login.success",e=>{"success"===e&&t(e),t("close")}),l.action({type:"pisell1.login",data:{notReload:!0,type:"plugin"},callback:t})}}},eVF=(0,ex.createContext)(void 0),eVB={menuItems:[],cartItems:[],summary:{},note:""};function eVq(e){var t;let l,{entryContext:i,children:a}=e,n=eD(),r=null==(l=eD())||null==(t=l.getModule)?void 0:t.call(l,"scanOrder"),[s,o]=(0,ex.useState)(!0),[d,c]=(0,ex.useState)(""),[u,p]=(0,ex.useState)("init"),[m,g]=(0,ex.useState)(eVB),[h,v]=(0,ex.useState)({passed:null,failures:[]}),[f,y]=(0,ex.useState)(String(eP.getText("pisell2.scan.order.action.select.required")||"")),[b,x]=(0,ex.useState)(""),[k,_]=(0,ex.useState)("default"),[w,j]=(0,ex.useState)(""),[S,N]=(0,ex.useState)([]),[M,C]=(0,ex.useState)(!1),[T,P]=(0,ex.useState)(null),A=(0,ex.useRef)(!1),I=[...eVz],D=(0,ex.useCallback)(e=>{var t;let l=null==r||null==(t=r.getUIState)?void 0:t.call(r,"gate");return!!(null==l?void 0:l[e])},[r]),E=(0,ex.useCallback)(e=>{var t;if(!(null==r?void 0:r.setUIState))return;let l=(null==(t=r.getUIState)?void 0:t.call(r,"gate"))||{};r.setUIState("gate",{...l,[e]:!0})},[r]),z=(0,ex.useCallback)(()=>{var e;null==r||null==(e=r.clearUIState)||e.call(r),P(null)},[r]),O=(0,ex.useCallback)(()=>{P(null)},[]),L=async()=>{var e;let t,l,i,a,n,s,o,d=null;if(r&&"function"==typeof r.getSummary)try{d=await r.getSummary()}catch(e){console.warn("[scanOrder] getSummary failed during refreshViewModel",e)}g((e=d,t=eVL(r,"getMenu",[]),l=eVL(r,"getOrderProducts",[]),i=void 0===e?eVL(r,"getSummary",null):e,n=(null==(a=eVL(r,"getTempOrder",null))?void 0:a.currency_symbol)||"$",s=eVE({orderProducts:Array.isArray(l)?l:[],amountSymbol:n}),o=(i&&"object"==typeof i?i:null)||(null==a?void 0:a.summary)||{},{menuItems:Array.isArray(t)?t:[],cartItems:Array.isArray(s)?s:[],summary:o&&"object"==typeof o?o:{},note:String((null==a?void 0:a.note)||"")})),r&&"function"==typeof r.getDiscountList&&N(r.getDiscountList()||[])},$=async e=>{await eV$(r,"updateTempOrderNote",e),await L()},R=e=>{I.includes(e)&&p(e)},F=()=>{let e=I.findIndex(e=>e===u);e<0||e>=I.length-1||p(I[e+1])},B=()=>{let e=I.findIndex(e=>e===u);e<=0||p(I[e-1])},q=async function(e){for(var t=arguments.length,l=Array(t>1?t-1:0),i=1;i<t;i++)l[i-1]=arguments[i];return eV$(r,e,...l)};(0,ex.useEffect)(()=>{var e,t,l,a,n,s;if(A.current||!r)return;A.current=!0;let o=String((null==i?void 0:i.resource_id)??""),d=String((null==i?void 0:i.biz)??""),c=!!(null==i?void 0:i.order_id),u=null==(e=r.getUIState)?void 0:e.call(r,"entryContext");if(!(u&&String((null==u?void 0:u.resourceId)??"")===o&&String((null==u?void 0:u.biz)??"")===d)){null==(a=r.clearUIState)||a.call(r),null==(n=r.setUIState)||n.call(r,"entryContext",{resourceId:o,hasOrderId:c,biz:d}),C(!0);return}let p=e=>"product"===e||"check"===e,m=null==(t=r.getUIState)?void 0:t.call(r,"pendingStep");if(p(m)){null==(s=r.deleteUIState)||s.call(r,"pendingStep"),P(m),C(!0);return}let g=null==(l=r.getUIState)?void 0:l.call(r,"step");p(g)&&P(g),C(!0)},[r,null==i?void 0:i.resource_id,null==i?void 0:i.order_id,null==i?void 0:i.biz]),(0,ex.useEffect)(()=>{var e;A.current&&M&&r&&"init"!==u&&(null==(e=r.setUIState)||e.call(r,"step",u))},[u,M,r]),(0,ex.useEffect)(()=>{var e,t;if(!r)return;let l=!1,i=e=>{let t=null==e?void 0:e.cartValidation;v({passed:"boolean"==typeof(null==t?void 0:t.passed)||(null==t?void 0:t.passed)===null?t.passed:"boolean"==typeof(null==e?void 0:e.cartValidationPassed)?e.cartValidationPassed:null,failures:Array.isArray(null==t?void 0:t.failures)?t.failures:[]})};return(async()=>{try{let e=await eV$(r,"getCartValidation");l||v({passed:"boolean"==typeof(null==e?void 0:e.passed)||(null==e?void 0:e.passed)===null?e.passed:null,failures:Array.isArray(null==e?void 0:e.failures)?e.failures:[]})}catch(e){l||v({passed:null,failures:[]})}})(),null==n||null==(t=n.effects)||null==(e=t.on)||e.call(t,"scanOrder:onCartValidationChanged",i),()=>{var e,t;l=!0,null==n||null==(t=n.effects)||null==(e=t.off)||e.call(t,"scanOrder:onCartValidationChanged",i)}},[n,r]),(0,ex.useEffect)(()=>{let e=!1;return(async()=>{try{if(!r){c("scanOrder module not ready"),o(!1);return}if(!("function"!=typeof r.checkAccess||await r.checkAccess(i)))throw Error("scanOrder access denied");"function"==typeof r.getPageConfig&&await r.getPageConfig(i),await L(),e||(c(""),o(!1))}catch(t){e||(c((null==t?void 0:t.message)||"scanOrder load failed"),o(!1))}})(),()=>{e=!0}},[r,null==i?void 0:i.biz,null==i?void 0:i.resource_id]);let H=(0,ex.useMemo)(()=>({entryContext:i,scanOrderModule:r,cartValidation:h,isLoading:s,errorMessage:d,currentStep:u,stepList:I,viewModel:m,footerActionText:f,tableName:b,entryMode:k,submitDisabledTips:w,discountList:S,isReady:!s&&!d,setCurrentStep:p,goToStep:R,nextStep:F,prevStep:B,refreshViewModel:L,runModuleAction:q,setFooterActionText:y,setTableName:x,setEntryMode:_,setSubmitDisabledTips:j,updateOrderNote:$,isCacheHydrated:M,markGate:E,isGatePassed:D,clearStepCache:z,resumeStep:T,consumeResumeStep:O}),[i,r,h,s,d,u,I,m,f,b,k,w,S,M,E,D,z,T,O]);return(0,eO.jsx)(eVF.Provider,{value:H,children:a})}function eVH(){let e=(0,ex.useContext)(eVF);if(e)return e;throw Error("useScanOrderContext must be used within ScanOrderProvider")}let eVV={init:{index:1,localeKey:"pisell2.scan.order.step.init",fallback:"Initialize"},product:{index:2,localeKey:"pisell2.scan.order.step.product",fallback:"Select product"},check:{index:3,localeKey:"pisell2.scan.order.step.check",fallback:"Check order"},error:{index:4,localeKey:"pisell2.scan.order.step.error",fallback:"Unavailable"}};function eVY(e){let{currentStep:t,onBack:l}=e,i=(0,ex.useMemo)(()=>{let e=eP.getText("pisell2.appointment.step");return"function"==typeof e?e(eVV[t].index):`Step ${eVV[t].index}`},[t]),a=(0,ex.useMemo)(()=>{let e=eP.getText(eVV[t].localeKey);return"string"==typeof e&&e?e:eVV[t].fallback},[t]);return(0,eO.jsx)(id.PisellHeaderProgressBar,{className:"pisell-scan-order-progress-bar",stepText:i,title:a,showClose:!1,showBack:"init"!==t,onBack:l,enableBorder:!0,borderColor:"#EAECF0"})}function eVU(){let{discountList:e,runModuleAction:t,refreshViewModel:l,scanOrderModule:i}=eVH(),{isLogin:a,openLoginModal:n}=eVR(),[r,s]=(0,ex.useState)(!0),[o,d]=(0,ex.useState)(""),c=(0,ex.useMemo)(()=>(e||[]).filter(e=>!!e.isAvailable).map(e=>({...e,isDisabled:e.isDisabled||e.isDisabledForProductUsed})),[e]),u=(0,ex.useCallback)(async()=>{await l()},[l]),p=(0,ex.useCallback)(async()=>{if(o.trim())try{var e;let l=null==i||null==(e=i.getTempOrder)?void 0:e.call(i),a=(null==l?void 0:l.customer_id)||void 0,n=await t("scanCode",o,a);if(null==n?void 0:n.isAvailable)d(""),await u();else{let e={time_limit:eP.getText("pisell2.text.goodpass.code-invalid-expired")};e_.message.error({content:String((null==n?void 0:n.type)==="server"?eP.getText("pisell2.text.goodpass.code-invalid"):e[null==n?void 0:n.unavailableReason]||eP.getText("pisell2.text.goodpass.code-invalid-cart"))})}}catch(e){console.warn("[scanOrder] scanCode failed",e),e_.message.error({content:String(eP.getText("pisell2.text.goodpass.code-invalid")||"兑换码无效")})}},[o,i,t,u]),m=(0,ex.useCallback)(async e=>{try{await t("setDiscountSelected",{discountId:e.id,isSelected:e.isSelected}),await u()}catch(e){console.warn("[scanOrder] setDiscountSelected failed",e)}},[t,u]),g=(0,ex.useCallback)(e=>[...e].sort((e,t)=>Number(null==t?void 0:t.isSelected)-Number(null==e?void 0:e.isSelected)),[]);return(0,eO.jsxs)("div",{className:"pisell-lowcode__appointment-booking-voucher-container",style:{marginTop:"10px"},children:[(0,eO.jsxs)("div",{className:"voucher-title",children:[(0,eO.jsx)("span",{className:"voucher-title-left",children:eP.getText("pisell2.text.goodpass")}),(0,eO.jsxs)("span",{className:"voucher-title-right",onClick:()=>s(!r),children:[eP.getText("pisell2.text.details")," ",(0,eO.jsx)(H9,{className:t8()("voucher-right-icon",{show:r})})]})]}),(0,eO.jsxs)("div",{className:t8()("voucher-detail",{show:r}),children:[c.length>0?(0,eO.jsx)(id.PisellGoodPassCard,{style:{width:"100%"},dataSource:c,mixedSort:g,onChange:m}):null,a?null:(0,eO.jsxs)("div",{className:"login-card",children:[(0,eO.jsx)(emR,{style:{fontSize:28}}),(0,eO.jsxs)("div",{className:"text-wrapper",style:{maxWidth:"none"},children:[(0,eO.jsx)(id.PisellText,{className:"login-btn",onClick:()=>{n({callback:()=>{}})},children:eP.getText("pisell2.text.goodpass.login")})," ",(0,eO.jsx)("span",{children:eP.getText("pisell2.text.goodpass.login-tip")})]})]}),(0,eO.jsxs)("div",{className:"voucher-code-input-wrapper",children:[(0,eO.jsxs)("div",{className:"voucher-code-input",children:[(0,eO.jsxs)("div",{style:{whiteSpace:"nowrap"},children:[eP.getText("pisell2.text.goodpass.code"),":"]}),(0,eO.jsx)(id.PisellInput,{value:o,allowClear:!0,onChange:e=>{var t;return d((null==(t=e.target)?void 0:t.value)||"")},size:"small",placeholder:eP.getText("pisell2.text.goodpass.enter-code")})]}),(0,eO.jsx)(e_.Button,{size:"small",onClick:p,disabled:!o.trim(),children:eP.getText("pisell2.text.apply")})]})]})]})}function eVW(e){var t,l,i,a,n,r;let{open:s,onCancel:o,onNext:d,items:c,summary:u,embedded:p=!1,confirmLoading:m=!1,extraContent:g,disabled:h=!1}=e,{runModuleAction:v,refreshViewModel:f,scanOrderModule:y}=eVH(),b=eI(),x=null==b||null==(l=b.appHelper)||null==(t=l.utils)?void 0:t.businessUtils,k=(null==b||null==(a=b.engine)||null==(i=a.props)?void 0:i.locale)||"en",_=!!(null==x||null==(n=x.getAppByModal)?void 0:n.call(x,"goodpass")),w=!!(null==x||null==(r=x.getAppByModal)?void 0:r.call(x,"discountcard")),j=p||s;if(!j)return null;let[S,N]=(0,ex.useState)(null),M=(0,ex.useCallback)(async()=>{let e=await v("getOtherParams");N((null==e?void 0:e.dineInConfig)??{})},[v]);(0,ex.useEffect)(()=>{M()},[]);let C=(0,ex.useMemo)(()=>null==S?void 0:S["sale.allow_item_notes"],[S]),T=(0,ex.useMemo)(()=>{let e=Number((null==u?void 0:u.total_amount)??(null==u?void 0:u.expect_amount)??(null==u?void 0:u.amount)??(null==u?void 0:u.total)??(null==u?void 0:u.totalAmount)??(null==u?void 0:u.payable_amount)??0);return Number.isNaN(e)?"0.00":e.toFixed(2)},[u]),P=String(eP.getText("pisell2.scan.order.action.confirm.order")||eP.getText("pisell2.event.confirm")||"Confirm"),A=(0,ex.useMemo)(()=>{var e;let t=Number((null==u?void 0:u.product_amount)??0),l=Number((null==u?void 0:u.tax_fee)??0),i=Number((null==u?void 0:u.total_amount)??(null==u?void 0:u.expect_amount)??0),a=null==y||null==(e=y.getTempOrder)?void 0:e.call(y),n=(null==a?void 0:a.summary)||{},r=String((null==n?void 0:n.tax_title)||(null==u?void 0:u.tax_title)||"GST/Tax"),s=Number((null==n?void 0:n.tax_rate)??(null==u?void 0:u.tax_rate)),o=Number.isNaN(s)?0:s>1?s/100:s,d=!!((null==n?void 0:n.is_price_include_tax)??(null==n?void 0:n.isPriceIncludeTax)??(null==u?void 0:u.is_price_include_tax)),c=((null==u?void 0:u.surcharges)||[]).filter(e=>Number(null==e?void 0:e.amount)>0).map(e=>{let t=(null==e?void 0:e.label)||(null==e?void 0:e.name)||{},l=t[k]||t.en||t.original||(null==e?void 0:e.key)||"";return{key:(null==e?void 0:e.key)||`surcharge_${null==e?void 0:e.surcharge_id}`,label:l,value:Number(null==e?void 0:e.amount)}});return[{key:"sub_total",value:Number.isNaN(t)?0:t},...c,{key:"tax",value:Number.isNaN(l)?0:l,hidden:!!Number.isNaN(l)||l<=0,tax:{title:r,rate:o,is_price_include_tax:d}},{key:"custom_total",value:Number.isNaN(i)?0:i,label:eP.getText("pisell2.event.total"),bold:!0}]},[u,y,k]),I=async(e,t)=>{if("note"===t){let t=(null==e?void 0:e.product_id)??(null==e?void 0:e.id)??null,l=Number((null==e?void 0:e.product_variant_id)??0),i=null==e?void 0:e.identity_key;if(null===t&&Number.isNaN(l))return;let a={product_id:t,product_variant_id:Number.isNaN(l)?0:l};"string"==typeof i&&i.length>0&&(a.identity_key=i);try{await v("setOrderProductLineNote",a,String((null==e?void 0:e.note)??"")),await f()}catch(t){console.error("[scanOrder] setOrderProductLineNote failed",{error:t,item:e})}return}if("delete"===t){let t=(null==e?void 0:e.product_id)??(null==e?void 0:e.id)??null,l=Number((null==e?void 0:e.product_variant_id)??0),i=null==e?void 0:e.identity_key;if(null===t&&Number.isNaN(l))return;if("string"!=typeof i||0===i.length)return void console.error("[scanOrder] removeProductFromOrder skipped: missing identity_key",{item:e});try{await v("removeProductFromOrder",{product_id:t,product_variant_id:Number.isNaN(l)?0:l,identity_key:i}),await f()}catch(t){console.error("[scanOrder] removeProductFromOrder failed",{error:t,item:e})}}};(0,ex.useEffect)(()=>{j&&f()},[j]);let D=(0,eO.jsx)(LU,{productParams:{products:c||[],hideAddBtn:!0,disabledEdit:!1,isShowNote:C,isShowDelete:!0,isShowPackageNote:!1,isShowChangeHolder:!1,isShowHolder:!1,isShowAddHolderButton:!1},platform:"h5",emptyText:eP.getText("pisell2.scan.order.empty.product"),isOpenGroup:!1,isHideClearCart:!0,onChange:I}),E=(0,eO.jsxs)(eO.Fragment,{children:[_||w?(0,eO.jsx)(eVU,{}):null,(0,eO.jsx)(YI,{list:A,style:{padding:0}}),g?(0,eO.jsx)("div",{className:"pisell-scan-order-cart-extra-content",children:g}):null]}),z=(0,eO.jsxs)("div",{className:p?"pisell-scan-order-cart-body pisell-scan-order-cart-body-embedded":"pisell-scan-order-cart-body",children:[D,E]});return p?(0,eO.jsxs)(eO.Fragment,{children:[z,(0,eO.jsx)("div",{className:"pisell-scan-order-cart-embedded-footer",children:(0,eO.jsx)(id.Button,{type:"primary",block:!0,onClick:d,loading:m,className:h?"pisell-scan-order-cart-embedded-confirm-disabled":void 0,children:P})})]}):(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsx)("div",{className:"pisell-scan-order-cart-mask",onClick:o}),(0,eO.jsxs)("div",{className:"pisell-scan-order-cart-drawer",children:[(0,eO.jsx)("div",{className:"pisell-scan-order-cart-header",children:(0,eO.jsx)("div",{className:"pisell-scan-order-cart-sheet-handle-wrap","aria-hidden":!0,children:(0,eO.jsx)("div",{className:"pisell-scan-order-cart-sheet-handle"})})}),(0,eO.jsx)("div",{className:"pisell-scan-order-cart-list-scroll",children:D}),(0,eO.jsxs)("div",{className:"pisell-scan-order-cart-bottom-panel",children:[E,(0,eO.jsxs)("div",{className:"pisell-scan-order-cart-footer",children:[(0,eO.jsxs)("div",{className:"pisell-scan-order-cart-footer-total-col",children:[(0,eO.jsx)("div",{className:"pisell-scan-order-cart-footer-total-label",children:eP.getText("pisell2.event.total")}),(0,eO.jsxs)("div",{className:"pisell-scan-order-cart-footer-total-amount",children:["$",T]})]}),(0,eO.jsx)(id.Button,{type:"primary",onClick:d,loading:m,children:eP.getText("pisell2.event.continue")})]})]})]})]})}function eVG(e){let{cartItems:t,summary:l,actionText:i,onAction:a,disabled:n=!1}=e,[r,s]=(0,ex.useState)(!1),o=(0,ex.useMemo)(()=>{let e=Number((null==l?void 0:l.total_amount)??(null==l?void 0:l.expect_amount)??(null==l?void 0:l.amount)??(null==l?void 0:l.total)??(null==l?void 0:l.totalAmount)??(null==l?void 0:l.payable_amount)??0);return Number.isNaN(e)?"0.00":e.toFixed(2)},[l]);return(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsxs)("div",{className:"pisell-scan-order-footer",children:[(0,eO.jsxs)("div",{className:"pisell-scan-order-footer-left",children:[(0,eO.jsx)("div",{className:"pisell-scan-order-footer-total-label",children:eP.getText("pisell2.event.total")}),(0,eO.jsxs)("div",{className:"pisell-scan-order-footer-total-amount",children:["$",o]})]}),(0,eO.jsxs)("div",{className:"pisell-scan-order-footer-right",children:[(0,eO.jsx)(id.Badge,{count:(null==t?void 0:t.length)||0,id:"scan-order-v2-cart-btn",children:(0,eO.jsx)(id.Button,{size:"large",className:"pisell-scan-order-footer-cart-btn",onClick:()=>s(!0),children:(0,eO.jsx)(id.Image,{src:egO,preview:!1})})}),(0,eO.jsx)(id.Button,{type:"primary",size:"large",className:`pisell-scan-order-footer-btn${n?" pisell-scan-order-footer-btn-disabled":""}`,onClick:a,children:i})]})]}),(0,eO.jsx)(eVW,{open:r,items:t||[],summary:l||{},onCancel:()=>{s(!1)},onNext:()=>{s(!1),a()}})]})}function eVQ(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,l=Number(e);return Number.isNaN(l)?t:l}function eVK(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,l=Math.floor(Number(e));return Number.isNaN(l)||l<1?t:l}function eVZ(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0.00",l=Number(e);return Number.isNaN(l)?t:l.toFixed(2)}function eVJ(e){return Array.isArray(e)?e.map(e=>{let{price:t,...l}=e||{},i=eVQ((null==e?void 0:e.product_option_item_id)??(null==e?void 0:e.option_group_item_id));return{...l,product_option_item_id:i,option_group_id:eVQ(null==e?void 0:e.option_group_id),num:eVK(null==e?void 0:e.num,1),add_price:eVQ((null==e?void 0:e.add_price)??t,0)}}):[]}function eVX(e,t){return e&&t&&!(t<=0)&&(Array.isArray(null==e?void 0:e.variant)?e.variant:[]).find(e=>Number(null==e?void 0:e.id)===t)||null}function eV0(e){var t,l,i;let{payload:a,fallbackProductId:n=null,sourceItem:r={}}=e;if(!a||"object"!=typeof a)return null;let s=function(e){if(null==e||""===e)return null;let t=Number(e);return Number.isNaN(t)?null:t}(a.product_id??a.id??(null==r?void 0:r.product_id)??n);if(null===s)return null;let o=eVQ(a.product_variant_id??a.variant_id??(null==r?void 0:r.product_variant_id),0),d=(null==a?void 0:a.origin)||(null==a||null==(t=a._origin)?void 0:t.sourceItem)||(null==a?void 0:a._origin)||{},c=eVX(d,o)??eVX(r,o),u=eVZ((null==a?void 0:a.price)??(null==a?void 0:a.selling_price)??(null==c?void 0:c.price)??(null==c?void 0:c.base_price)??(null==d?void 0:d.price)??(null==r?void 0:r.price)??(null==r?void 0:r.selling_price)??(null==r?void 0:r.base_price),"0.00"),p=eVZ((null==a?void 0:a.tax_fee)??(null==c?void 0:c.tax_fee)??(null==d?void 0:d.tax_fee)??(null==r?void 0:r.tax_fee),"0.00"),m=eVQ((null==a?void 0:a.is_charge_tax)??(null==c?void 0:c.is_charge_tax)??(null==d?void 0:d.is_charge_tax)??(null==r?void 0:r.is_charge_tax),0),g=function(e){let{payload:t,callbackOrigin:l,sourceItem:i}=e;for(let e of[null==t?void 0:t.product_title,null==i?void 0:i.product_title,null==l?void 0:l.product_title,null==t?void 0:t.title,null==i?void 0:i.title,null==l?void 0:l.title,null==t?void 0:t.name,null==i?void 0:i.name,null==l?void 0:l.name]){let t=function(e){if("string"==typeof e){let t=e.trim();return t?{auto:t}:void 0}if(!e||"object"!=typeof e||Array.isArray(e))return;let t={};Object.entries(e).forEach(e=>{let[l,i]=e;"string"==typeof i?t[l]=i:null==i&&(t[l]=i)});let l=function(e){if("string"==typeof e)return e.trim();if(!e||"object"!=typeof e||Array.isArray(e))return"";for(let t of["auto","original","en","zh-CN","zh-HK","ja","pt"]){let l=e[t];if("string"==typeof l&&l.trim())return l.trim()}let t=Object.values(e).find(e=>"string"==typeof e&&e.trim());return"string"==typeof t?t.trim():""}(t);return l&&!t.auto&&(t.auto=l),Object.values(t).some(e=>"string"==typeof e&&e.trim())?t:void 0}(e);if(t)return t}}({payload:a,callbackOrigin:d,sourceItem:r});return{product_id:s,product_variant_id:o,num:eVK(a.quantity??a.num,1),product_sku:{...a.product_sku,option:eVJ((null==(l=a.product_sku)?void 0:l.option)??a.option??a.product_option_item)},product_bundle:Array.isArray(i=a.bundle??a.product_bundle)?i.map(e=>({...e,option:eVJ(null==e?void 0:e.option)})):[],selling_price:u,original_price:u,tax_fee:p,is_charge_tax:m,...g?{product_title:g}:{},metadata:{unique:a.unique,session:a.session,form:a.form,service_times:a.service_times,machine_code:a.machine_code,schedule_id:a.schedule_id,duration:a.duration,policy_id:a.policy_id,source_shop_id:a.source_shop_id,origin:a.origin,...g?{product_title:g}:{}},_origin:{...r||{},callbackData:a}}}function eV2(e){var t;let{onCheckout:l,productList:i,isProductListLoading:a,onEnsureProductList:n}=e,{utils:r}=eI().appHelper||{},{runModuleAction:s,refreshViewModel:o,viewModel:d}=eVH(),[c,u]=(0,ex.useState)(null),p=(0,ex.useCallback)(async()=>{let e=await s("getOtherParams");u((null==e?void 0:e.dineInConfig)??{})},[s]);(0,ex.useEffect)(()=>{p()},[]),(0,ex.useEffect)(()=>{n()},[n]);let m=(0,ex.useRef)(null);rp();let g=window.innerHeight-100,h=async e=>{let{orderProduct:t,sourceData:l}=e;try{await s("addProductToOrder",t),await o()}catch(e){console.error("[scanOrder] addProductToOrder failed",{error:e,sourceData:l,mappedData:t})}},v=async e=>{let{product_id:t,product_variant_id:l,identity_key:i,sourceData:a}=e;try{await s("removeProductFromOrder",{product_id:t,product_variant_id:l,...i?{identity_key:i}:{}}),await o()}catch(e){console.error("[scanOrder] removeProductFromOrder failed",{error:e,sourceData:a,product_id:t,product_variant_id:l,identity_key:i})}},f=async e=>{let{product_id:t,product_variant_id:l,identity_key:i,updates:a,sourceData:n}=e;try{await s("updateOrderProduct",{product_id:t,product_variant_id:l,...i?{identity_key:i}:{},updates:a}),await o()}catch(e){console.error("[scanOrder] updateOrderProduct failed",{error:e,sourceData:n,product_id:t,product_variant_id:l,identity_key:i,updates:a})}},y=async(e,t,l)=>{let i=(null==l?void 0:l.product)||e;if((null==l?void 0:l.intent)==="quantity"){let t={...e,quantity:null==e?void 0:e.num,option:(null==e?void 0:e.option)??(null==e?void 0:e.product_option_item),bundle:(null==e?void 0:e.bundle)??(null==e?void 0:e.product_bundle),origin:i,price:(null==e?void 0:e.price)??(null==e?void 0:e.selling_price)},a=eV0({payload:t,fallbackProductId:(null==e?void 0:e.product_id)??(null==e?void 0:e.id),sourceItem:i});if(!a)return void console.warn("[scanOrder] quantity add missing product_id",t);let n=Number((null==l?void 0:l.quantity)??(null==t?void 0:t.quantity)??0),r=Number((null==a?void 0:a.product_variant_id)??0);if(Number.isNaN(r))return void console.warn("[scanOrder] quantity action missing product_variant_id",{quantityData:t,orderProduct:a});let s=Number.isNaN(n)?0:Math.max(0,Math.floor(n)),o=(Array.isArray(null==d?void 0:d.cartItems)?d.cartItems:[]).find(e=>String((null==e?void 0:e.product_id)??null)===String((null==a?void 0:a.product_id)??null)&&Number((null==e?void 0:e.product_variant_id)??0)===r),c="string"==typeof(null==o?void 0:o.identity_key)&&o.identity_key.length>0?o.identity_key:void 0;if(s<=0)return void await v({product_id:(null==a?void 0:a.product_id)??null,product_variant_id:r,identity_key:c,sourceData:t});if(!o)return void await h({orderProduct:{...a,num:s},sourceData:t});await f({product_id:(null==a?void 0:a.product_id)??null,product_variant_id:r,identity_key:c,updates:{num:s,_origin:null==a?void 0:a._origin},sourceData:t})}else null==r||r.action({type:"pisell1.productDetail",data:{detail:{...i,open_deposit:1},setting:{can_input:!0,item_max_length:1,is_detail_open:!1}},callback:async t=>{var l,a,n;if((null==t?void 0:t.isCancel)||(null==t||null==(l=t.origin)?void 0:l.is_track)&&!(null==t||null==(a=t.origin)?void 0:a.over_sold)&&(null==t||null==(n=t.origin)?void 0:n.stock_quantity)<=0)return;let r=eV0({payload:t,fallbackProductId:(null==e?void 0:e.product_id)??(null==e?void 0:e.id),sourceItem:i});r?await h({orderProduct:r,sourceData:t}):console.warn("[scanOrder] productDetail callback missing product_id",t)}})},b=(0,eO.jsx)(z9,{dataSource:i,onChange:y,loading:a,emptyDescription:eP.getText("pisell2.scan.order.empty.product"),token:{colorPrimary:"var(--theme-color)",containerBg:"#FFFFFF",tabItemBg:"#F2F4F7",tabItemHoverBg:"#F2F4F7",tabItemActiveBg:"var(--theme-color)",categoryTextColor:"#1B1B1B",cardSelectedBg:"var(--theme-color)"},customScrollParent:(null==(t=m.current)?void 0:t.getScrollContainer())||"",hideCategoryWhenOne:!0,version:"v2",value:(null==d?void 0:d.cartItems)||[],productListSetting:{imgWidth:80,imgHeight:80},cartElementId:"#scan-order-v2-cart-btn"});return(0,eO.jsx)("div",{className:"pisell-scan-menu",children:(0,eO.jsx)(id.PisellScrollView,{height:g,overflow:"y",ref:m,children:b})})}function eV1(e){let{title:t="Error",message:l,onRetry:i}=e;return(0,eO.jsxs)("div",{className:"pisell-scan-order-error-state",children:[(0,eO.jsx)("h3",{children:t}),(0,eO.jsx)("p",{children:l}),i?(0,eO.jsx)("button",{type:"button",onClick:i,children:"Retry"}):null]})}function eV4(){let e=String(eP.getText("pisell2.scan.order.step.init")||"Initialize"),t=String(eP.getText("pisell2.scan.order.loading.initializing")||"Preparing your order, please wait...");return(0,eO.jsxs)("div",{className:"pisell-scan-order-initializing",children:[(0,eO.jsx)("div",{className:"pisell-scan-order-initializing-spinner",children:(0,eO.jsx)(id.PisellLoading,{loading:!0})}),(0,eO.jsx)("div",{className:"pisell-scan-order-initializing-title",children:e}),(0,eO.jsx)("div",{className:"pisell-scan-order-initializing-description",children:t})]})}function eV3(){let{scanOrderModule:e}=eVH(),[t,l]=(0,ex.useState)({}),[i,a]=(0,ex.useState)("table_service");(0,ex.useEffect)(()=>{if(!e)return;let t=("function"==typeof e.getFulfillmentModes?e.getFulfillmentModes():void 0)||{};l(t),t.enableTableService&&t.enablePickup;let i=!t.enableTableService&&t.enablePickup?"counter_pickup":"table_service";a(i),(t.enableTableService||t.enablePickup)&&"function"==typeof e.setPickupReferenceMode&&e.setPickupReferenceMode(i)},[e]);let{enableTableService:n,enablePickup:r}=t,s=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.fulfillment.title")),[]),o=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.fulfillment.table_service")),[]),d=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.fulfillment.pickup")),[]);if(!n&&!r)return null;if(!n||!r){let e=r?d:o;return(0,eO.jsxs)("div",{className:"pisell-scan-order-fulfillment pisell-scan-order-fulfillment-single",children:[(0,eO.jsx)("span",{className:"pisell-scan-order-fulfillment-title",children:s}),(0,eO.jsx)("span",{className:"pisell-scan-order-fulfillment-value",children:e})]})}return(0,eO.jsxs)("div",{className:"pisell-scan-order-fulfillment",children:[(0,eO.jsx)("div",{className:"pisell-scan-order-fulfillment-title",children:s}),(0,eO.jsxs)(e_.Radio.Group,{className:"pisell-scan-order-fulfillment-group",optionType:"button",buttonStyle:"solid",value:i,onChange:t=>{var l,n;(n=null==t||null==(l=t.target)?void 0:l.value)!==i&&(a(n),"function"==typeof(null==e?void 0:e.setPickupReferenceMode)&&e.setPickupReferenceMode(n))},children:[(0,eO.jsx)(e_.Radio.Button,{value:"table_service",children:o}),(0,eO.jsx)(e_.Radio.Button,{value:"counter_pickup",children:d})]})]})}function eV8(e){let{open:t,confirmLoading:l=!1,onCancel:i,onConfirm:a}=e,[n,r]=(0,ex.useState)("");(0,ex.useEffect)(()=>{t&&r("")},[t]);let s=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.pickup.ref.title")),[]),o=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.pickup.ref.heading")),[]),d=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.pickup.ref.description")),[]),c=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.pickup.ref.placeholder")),[]),u=(0,ex.useMemo)(()=>String(eP.getText("pisell2.event.confirm")||"Confirm"),[]),p=n.trim(),m=!!p&&!l,g=()=>{m&&a(p)};return(0,eO.jsx)(e_.Modal,{open:t,title:s,footer:null,onCancel:i,maskClosable:!1,destroyOnClose:!0,centered:!0,className:"pisell-scan-order-pickup-ref-modal",children:(0,eO.jsxs)("div",{className:"pisell-scan-order-pickup-ref-body",children:[(0,eO.jsx)("div",{className:"pisell-scan-order-pickup-ref-heading",children:o}),(0,eO.jsx)("div",{className:"pisell-scan-order-pickup-ref-desc",children:d}),(0,eO.jsx)(e_.Input,{size:"large",placeholder:c,value:n,onChange:e=>{var t;return r((null==e||null==(t=e.target)?void 0:t.value)||"")},onPressEnter:g,className:"pisell-scan-order-pickup-ref-input",maxLength:32,allowClear:!0}),(0,eO.jsx)(id.Button,{type:"primary",block:!0,size:"large",disabled:!m,loading:l,onClick:g,children:u})]})})}function eV6(){let{viewModel:e,runModuleAction:t,refreshViewModel:l,tableName:i,entryMode:a,clearStepCache:n,entryContext:r}=eVH(),s="additional_order"===a,[o,d]=(0,ex.useState)(!1),c=(0,ex.useRef)(!1),u=(0,ex.useRef)(!1),[p,m]=(0,ex.useState)((null==e?void 0:e.note)||""),[g,h]=(0,ex.useState)(!1),[v,f]=(0,ex.useState)(!1),y=eVO(),[b,x]=(0,ex.useState)(null),[k,_]=(0,ex.useState)(""),w=(0,ex.useCallback)(async()=>{let e=await t("getOtherParams");x((null==e?void 0:e.dineInConfig)??{}),_((null==e?void 0:e.channel)??"")},[t]);(0,ex.useEffect)(()=>{w()},[]);let j=(0,ex.useMemo)(()=>null==b?void 0:b["sale.allow_order_notes"],[b]),S=(0,ex.useMemo)(()=>String(eP.getText("pisell2.text.order-notes")||eP.getText("pisell2.scan.order.note.title")||"备注"),[]),N=(0,ex.useMemo)(()=>String(eP.getText("pisell2.text.add-order-notes")||eP.getText("pisell2.scan.order.note.placeholder")||"请输入备注"),[]),M=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.current.table")||"Current table"),[]),C=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.products.title")||"Products"),[]),T=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.add.on.confirm.title")||"This table has already started ordering"),[]),P=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.add.on.confirm.description")||"Someone at your table has placed the order. This will be submitted as an add-on order."),[]),A=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.add.on.confirm.button")||"Confirm Add-on Order"),[]),I=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.add.on.return.button")||"Return to Cart"),[]),D=()=>{e_.message.error(eP.getText("pisell2.scan.order.check.cart.empty.tip")||"Please go back to add products")},E=(0,ex.useCallback)(e=>{let t=String(e||eP.getText("pisell2.scan.order.submit.failed")||"Submit order failed");(0,id.PisellToast)({content:t})},[]),z=e=>(null==e?void 0:e.code)==="SCAN_ORDER_MENU_UNAVAILABLE"?!!u.current||(u.current=!0,e_.Modal.info({title:String(eP.getText("pisell2.scan.order.menu.unavailable.title")||"Ordering time has ended"),content:String(eP.getText("pisell2.scan.order.menu.unavailable.description")||"Some items in your cart are no longer available to order at this time. Select Confirm to refresh the page and choose your items again."),okText:String(eP.getText("pisell2.event.confirm")||"OK"),maskClosable:!1,keyboard:!1,closable:!1,onOk:()=>{let e=new URL(window.location.href);e.searchParams.delete("cacheId"),window.location.replace(e.toString())}}),!0):(null==e?void 0:e.code)==="SCAN_ORDER_MENU_VALIDATION_FAILED"&&(E(String(eP.getText("pisell2.scan.order.menu.validation.failed")||"Unable to check the ordering time. Please try again. Your cart has been kept.")),!0),O=async e=>{if(!c.current&&!u.current){c.current=!0,d(!0);try{await e()}catch(e){console.error("[scanOrder] submit action failed",e),z(e)||E(null==e?void 0:e.message)}finally{c.current=!1,d(!1)}}},L=(0,ex.useCallback)(e=>{var t;let l=(Array.isArray(null==e||null==(t=e.data)?void 0:t.unavailable_products)?e.data.unavailable_products:[]).map(e=>String((null==e?void 0:e.title)||(null==e?void 0:e.product_id)||"").trim()).filter(Boolean),i=String(eP.getText("pisell2.scan.order.inventory.insufficient.title")||"Insufficient inventory"),a=String(eP.getText("pisell2.scan.order.inventory.insufficient.description")||"The following items are out of stock or do not have enough inventory. Please adjust your cart and try again."),n=String(eP.getText("pisell2.scan.order.inventory.insufficient.products.label")||"Unavailable products:"),r=String((null==e?void 0:e.message)||a);e_.Modal.info({title:i,content:(0,eO.jsxs)("div",{children:[(0,eO.jsx)("div",{children:a}),(0,eO.jsx)("div",{children:n}),l.length>0?(0,eO.jsx)("ul",{children:l.map((e,t)=>(0,eO.jsx)("li",{children:e},`${e}-${t}`))}):(0,eO.jsx)("div",{children:r})]}),okText:String(eP.getText("pisell2.event.confirm")||"OK"),maskClosable:!1})},[]),$=async()=>{if(0===((null==e?void 0:e.cartItems)||[]).length)return void D();try{var i,a,o,d,c;await t("updateTempOrderNote",p);let r=await t("submitScanOrder");if((null==r?void 0:r.status)===!1){if(z(r))return;if((null==r?void 0:r.code)===6008)return void L(r);E(null==r?void 0:r.message);return}let u=null==r||null==(i=r.data)?void 0:i.order_id,m=(null==b?void 0:b["sale.require_payment_on_submit"])&&!s;if(!u)return void E(null==r?void 0:r.message);if(n(),m)y.action({type:"pisell1.payment",data:{order_id:u,total_amount:(null==r||null==(a=r.data)?void 0:a.order_wait_pay_amount)||(null==e||null==(o=e.summary)?void 0:o.total_amount),sale_channel:{scan_to_order:"table-order",scan_to_order_2:"mobile_order",scan_to_order_3:"scantoorder3"}[k]||k},callback:async e=>{try{await t("restoreOrder")}catch(e){console.warn("[scanOrder] restoreOrder after payment failed",e)}}});else{try{await t("restoreOrder")}catch(e){console.warn("[scanOrder] restoreOrder before redirect failed",e)}let e=`/order/details?id=${u}`;(null==y||null==(d=y.history)?void 0:d.replace)?y.history.replace(e):(null==y||null==(c=y.history)?void 0:c.push)?y.history.push(e):location.replace(e);try{await t("restoreOrder")}catch(e){console.warn("[scanOrder] restoreOrder after payment failed",e)}}await l()}catch(e){if(console.error("[scanOrder] submitScanOrder failed",e),z(e))return;if((null==e?void 0:e.code)===670005)E(String(eP.getText("pisell2.scan.order.settled.cannot.add.tip")||""));else if((null==e?void 0:e.code)===670007&&(null==r?void 0:r.resource_id)){let l=await t("getReservationResourceSelectType"),i=await t("checkAllowAddItems"),a=await t("syncAdditionalOrderFromResource",null==r?void 0:r.resource_id);"single"===l.resourceSelectType&&(null==i?void 0:i.enabled)&&(null==a?void 0:a.matched)?f(!0):E(null==e?void 0:e.message)}else(null==e?void 0:e.code)===6008?L(e):E(null==e?void 0:e.message)}},R=()=>{c.current||f(!1)},F=(0,eO.jsxs)("div",{className:"pisell-scan-order-check-note",children:[(0,eO.jsx)("div",{className:"pisell-scan-order-check-note-title",children:S}),(0,eO.jsx)(e_.Input.TextArea,{value:p,placeholder:N,autoSize:{minRows:4},allowClear:!0,onChange:e=>{var t;return m((null==e||null==(t=e.target)?void 0:t.value)||"")}})]});return(0,eO.jsxs)("div",{className:"pisell-scan-order-check",children:[i?(0,eO.jsxs)("div",{className:"pisell-scan-order-check-current-table",children:[(0,eO.jsx)("span",{className:"pisell-scan-order-check-current-table-label",children:M}),(0,eO.jsx)("span",{className:"pisell-scan-order-check-current-table-value",children:i})]}):null,s?null:(0,eO.jsx)(eV3,{}),(0,eO.jsx)("div",{className:"pisell-scan-order-check-products-title",children:C}),(0,eO.jsx)(eVW,{embedded:!0,open:!0,onCancel:()=>{},onNext:()=>O(async()=>{if(0===((null==e?void 0:e.cartItems)||[]).length)return void D();if(s)return void await $();try{let e=await t("checkManualPickupRef");if(null==e?void 0:e.enabled)return void h(!0)}catch(e){console.error("[scanOrder] checkManualPickupRef failed",e),e_.message.error((null==e?void 0:e.message)||"Submit order failed");return}await $()}),items:(null==e?void 0:e.cartItems)||[],summary:(null==e?void 0:e.summary)||{},confirmLoading:o,extraContent:!s&&j?F:void 0}),(0,eO.jsx)(eV8,{open:g,confirmLoading:o,onCancel:()=>{c.current||h(!1)},onConfirm:e=>O(async()=>{try{await t("setPickupRef",e)}catch(e){console.error("[scanOrder] setPickupRef failed",e),e_.message.error((null==e?void 0:e.message)||"Submit order failed");return}h(!1),await $()})}),(0,eO.jsx)(e_.Modal,{open:v,footer:null,onCancel:R,maskClosable:!1,destroyOnClose:!0,centered:!0,className:"pisell-scan-order-add-on-confirm-modal",children:(0,eO.jsxs)("div",{className:"pisell-scan-order-add-on-confirm-body",children:[(0,eO.jsx)("div",{className:"pisell-scan-order-add-on-confirm-title",children:T}),(0,eO.jsx)("div",{className:"pisell-scan-order-add-on-confirm-desc",children:P}),(0,eO.jsx)(id.Button,{type:"primary",block:!0,size:"large",loading:o,onClick:()=>O(async()=>{f(!1),await $()}),children:A}),(0,eO.jsx)(id.Button,{block:!0,size:"large",disabled:o,onClick:R,children:I})]})}),o?(0,eO.jsx)("div",{className:"pisell-scan-order-check-loading-mask",children:(0,eO.jsx)("div",{className:"pisell-scan-order-check-loading-panel",children:(0,eO.jsx)(id.PisellLoading,{loading:!0,mask:{backgroundColor:"transparent",width:64,height:64},children:(0,eO.jsx)("div",{className:"pisell-scan-order-check-loading-placeholder"})})})}):null]})}function eV5(){var e,t,l,i,a;let{currentStep:n,prevStep:r,goToStep:s,runModuleAction:o,entryContext:d,viewModel:c,refreshViewModel:u,footerActionText:p,setFooterActionText:m,cartValidation:g,setTableName:h,entryMode:v,setEntryMode:f,submitDisabledTips:y,setSubmitDisabledTips:b,scanOrderModule:x,isCacheHydrated:k,markGate:_,isGatePassed:w,resumeStep:j,consumeResumeStep:S}=eVH(),{openLoginModal:N}=eVR(),M=eVO(),[C]=HX({components:["FormCard"]}),T=(0,ex.useRef)(null),[P,A]=(0,ex.useState)(!1),[I,D]=(0,ex.useState)({open:!1,content:null}),[E,z]=(0,ex.useState)({open:!1,content:null}),[O,L]=(0,ex.useState)(null),[$,R]=(0,ex.useState)([]),[F,B]=(0,ex.useState)(!1),q=(0,ex.useRef)(!1),H=(0,ex.useRef)(null),V=(0,ex.useCallback)(async()=>{if(q.current)return;if(H.current)return void await H.current.catch(()=>{});let e=(async()=>{B(!0);try{let e=await o("getProductList");if(Array.isArray(e)){q.current=!0,R(e);return}e_.Modal.confirm({title:null==e?void 0:e.message,okText:String(eP.getText("pisell2.event.confirm")||"OK"),cancelButtonProps:{style:{display:"none"}},maskClosable:!1,onOk:()=>{location.replace("/")}})}catch(e){console.warn("[scanOrder] getProductList failed",e)}finally{B(!1),H.current=null}})();H.current=e,await e},[o]),Y=(0,ex.useRef)(0),U=(0,ex.useRef)(1),W=(0,ex.useRef)(1),G=(0,ex.useRef)(null);(0,ex.useRef)(!1);let Q=(0,ex.useRef)(!1),K=e=>{if(!e)return"";let t=e[eP.getLocale()];if("string"==typeof t&&t)return t;let l=e.original;return"string"==typeof l&&l?l:""},Z=e=>null==e?"":"string"==typeof e?e:"object"!=typeof e?String(e):K(e),J=null==M||null==(e=M.getApp)?void 0:e.call(M),X=()=>{var e,t;return!!(null==M||null==(t=M.token)||null==(e=t.get)?void 0:e.call(t))},ee=()=>{var e,t;(null==J||null==(e=J.history)?void 0:e.replace)?J.history.replace("/"):(null==J||null==(t=J.history)?void 0:t.push)?J.history.push("/"):location.replace("/")},et=()=>new Promise(e=>{var t;"function"!=typeof(null==M?void 0:M.action)?e(null):M.action({type:"pisell1.handlePaxModal",data:{tableName:K(null==(t=G.current)?void 0:t.name),requestPaxMin:U.current,requestPaxMax:W.current},callback:t=>{e(function(e){if(null==e)return null;if("number"==typeof e&&Number.isFinite(e)&&e>=1)return Math.floor(e);if("string"==typeof e){let t=Number(e);if(Number.isFinite(t)&&t>=1)return Math.floor(t)}if("object"==typeof e)for(let t of["entryPaxNumber","pax","num","count","value"]){let l=e[t];if("number"==typeof l&&Number.isFinite(l)&&l>=1)return Math.floor(l);if("string"==typeof l){let e=Number(l);if(Number.isFinite(e)&&e>=1)return Math.floor(e)}}return null}(t))}})}),el=e=>{var t,l;let i=`/order/details?id=${e}`;(null==J||null==(t=J.history)?void 0:t.replace)?J.history.replace(i):(null==J||null==(l=J.history)?void 0:l.push)?J.history.push(i):location.replace(i)},ei=async()=>{try{await o("applyItemRulePrefill"),await u()}catch(e){console.warn("[scanOrder] applyItemRulePrefill failed",e)}finally{j&&S(),s("check"===j?"check":"product")}},ea=async()=>{if("additional_order"===v||1!==Y.current||w("paxEntered"))return void await ei();Q.current=!0;let e=await et();if(null==e)return void ee();try{await o("setEntryPaxNumber",e),_("paxEntered")}catch(e){console.warn("[scanOrder] setOtherParams failed",e)}await ei()},en=e=>{e&&(A(!1),z({open:!0,content:e}))};(0,ex.useEffect)(()=>{let e=async()=>{let e=!!(null==d?void 0:d.order_id),{mode:t,order_id:l,errorTips:i,policy:a,form:r,partyroom_booking:s,requestEntryPax:c,requestPaxMin:u,requestPaxMax:p,table_form_record:m}=await o("checkResourceAvailable",null==d?void 0:d.resource_id,e);Y.current=+(1===Number(c)),U.current=Number(u)||1,W.current=Number(p)||1,G.current=m||{},h(K(null==m?void 0:m.name));let g=((e,t)=>{let l=e??t;if(!l)return null;let i=Number("number"==typeof l||"string"==typeof l?l:(null==l?void 0:l.id)??(null==l?void 0:l.form_id)??(null==l?void 0:l.resource_form_id)??(null==l?void 0:l.partyroom_booking));if(Number.isNaN(i)||i<=0)return null;let a="object"==typeof l&&null!==l?l:{};return{id:i,title:null==a?void 0:a.title,defaultValues:(null==a?void 0:a.defaultValues)||{},setting:null==a?void 0:a.setting}})(r,s),v="additional_order"===t||"additional_order_with_code"===t;if(f(v?"additional_order":"default"),"idle"===t){let e="object"==typeof a&&null!==a?a:{id:a};if((null==e?void 0:e.id)&&!w("policyAccepted")){L(g),D({open:!0,content:e});return}if(g&&!w("formSubmitted"))return void en(g);await ea()}else if(v){let e=await o("checkAllowAddItems");if(X()){if(!(null==d?void 0:d.order_id)||!e.enabled)return void el(l);await o("restorePreviousOrderData"),await ei()}else{let t=()=>{var i;null==x||null==(i=x.setUIState)||i.call(x,"pendingStep",n),N({callback:async i=>{if("success"===i)return(null==d?void 0:d.order_id)&&e.enabled?(await o("restorePreviousOrderData"),void await ei()):void el(l);let a=e_.Modal.info({title:eP.getText("pisell2.scan.order.add.on.login.required.title"),content:String(eP.getText("pisell2.scan.order.add.on.login.required")||"").trim(),okText:String(eP.getText("pisell2.event.confirm")||"OK"),maskClosable:!1,onOk:()=>{a.destroy(),t()}})}})};t();return}}else if("submit_disabled"===t)b(Z(i)||String(eP.getText("pisell2.scan.order.submit.disabled.default")||"")),await ei();else if("multiple_orders"===t)e_.Modal.info({title:eP.getText("pisell2.scan.order.step.error"),content:String(eP.getText("pisell2.scan.order.multiple.orders.tip")||"").trim(),okText:String(eP.getText("pisell2.scan.order.multiple.orders.confirm")||"I Got It"),maskClosable:!1,onOk:()=>{ee()}});else if("resource_busy"===t)if(0!==Number(l))if(X())el(l);else{let e=()=>{var t;null==x||null==(t=x.setUIState)||t.call(x,"pendingStep",n),N({callback:t=>{if("success"===t){var i;null==x||null==(i=x.deleteUIState)||i.call(x,"pendingStep"),el(l);return}e_.Modal.info({title:eP.getText("pisell2.scan.order.add.on.login.required.title"),content:String(eP.getText("pisell2.scan.order.add.on.login.required")||"").trim(),okText:String(eP.getText("pisell2.event.confirm")||"OK"),maskClosable:!1,onOk:()=>{e()}})}})};e()}else{let e=String(eP.getText("pisell2.scan.order.add.on.unavailable.description")||"");e_.Modal.info({title:eP.getText("pisell2.scan.order.add.on.unavailable.title"),content:(0,eO.jsx)("div",{style:{whiteSpace:"pre-line"},children:e.trim()}),okText:String(eP.getText("pisell2.scan.order.add.on.unavailable.confirm")||"Got it"),maskClosable:!1,onOk:()=>{location.replace("/")}})}else{let e=Z(i);e||(e="resource_block"===t?String(eP.getText("pisell2.scan.order.resource.status.exception")||""):String(eP.getText("pisell2.scan.order.store.status.exception")||"")),e_.Modal.info({title:eP.getText("pisell2.scan.order.step.error"),content:Z(e).trim(),okText:String(eP.getText("pisell2.event.confirm")||"OK"),maskClosable:!1,onOk:()=>{location.replace("/")}})}};k&&e()},[k]),(0,ex.useEffect)(()=>{window.scrollTo({top:0,behavior:"smooth"})},[n]),(0,ex.useEffect)(()=>{"product"===n?m((null==g?void 0:g.passed)===!0?String(eP.getText("pisell2.event.continue")||"下一步"):String(eP.getText("pisell2.scan.order.action.select.required")||"")):"check"===n&&m(String(eP.getText("pisell2.event.checkout")||""))},[n,null==g?void 0:g.passed]);let er={init:(0,eO.jsx)(eV4,{}),product:(0,eO.jsx)(eV2,{onCheckout:()=>s("check"),productList:$,isProductListLoading:F,onEnsureProductList:V}),check:(0,eO.jsx)(eV6,{}),error:(0,eO.jsx)(eV1,{message:eP.getText("pisell2.scan.order.store.status.exception")})},es=async()=>{if(y)return void e_.message.warning(y,2);let e=Array.isArray(null==g?void 0:g.failures)?g.failures[0]:null;if((null==g?void 0:g.passed)===!1){let t=(()=>{let e=Array.isArray(null==g?void 0:g.failures)?g.failures[0]:null,t=Array.isArray(null==e?void 0:e.targets)?e.targets:[],l=[],i=new Set;for(let e of t){let t=Number(null==e?void 0:e.product_id);Number.isFinite(t)&&t>0&&!i.has(t)&&(i.add(t),l.push(t))}return l})();t.length&&(e=>{if(!(null==e?void 0:e.length))return;let t=!1;for(let l of e){let e=document.querySelector(`[data-product-id="${String(l)}"]`);e&&(e.classList.remove("highlight-product-item"),t||(e.scrollIntoView({behavior:"smooth",block:"center"}),t=!0),e.offsetWidth,e.classList.add("highlight-product-item"),setTimeout(()=>{e.classList.remove("highlight-product-item")},3e3))}})(t);let l=String((null==e?void 0:e.validationMessage)||"").trim();e_.message.warning(l,2);return}let t=await o("getOtherParams"),l=(null==t?void 0:t.dineInConfig)??{};if(null==l?void 0:l["availability.paused"])return void e_.Modal.info({title:String(eP.getText("pisell2.scan.order.step.error")||""),content:(null==l?void 0:l["availability.pause_message"])??"",okText:String(eP.getText("pisell2.event.confirm")||"OK"),onOk:()=>{location.replace("/")}});if(!X()){var i;null==x||null==(i=x.setUIState)||i.call(x,"pendingStep","check"),N({callback:e=>{var t;null==x||null==(t=x.deleteUIState)||t.call(x,"pendingStep"),"success"===e&&s("check")}});return}s("check")},eo=rp(),ed=(0,ex.useMemo)(()=>!!eo&&"product"===n,[n,eo]),ec=(0,ex.useMemo)(()=>!eo&&"product"===n,[n,eo]);return(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsx)(eVY,{currentStep:n,onBack:()=>{"product"!==n?r():"additional_order"===v&&(null==d?void 0:d.order_id)?el(d.order_id):Q.current?(async()=>{let e=await et();if(null==e)return ee();try{await o("setEntryPaxNumber",e),await u()}catch(e){console.warn("[scanOrder] setEntryPaxNumber on back pax confirm failed",e)}})():ee()}}),(0,eO.jsxs)("div",{className:`pisell-scan-order-content-wrap ${eo?"pisell-scan-order-content-mobile-wrap":""}`,"data-cart-validation-passed":String(null==g?void 0:g.passed),children:[(0,eO.jsx)("div",{className:"pisell-scan-order-content-left",children:er[n]}),ec?(0,eO.jsx)("div",{className:"pisell-scan-order-content-right",children:(0,eO.jsx)(eVW,{embedded:!0,open:!0,onCancel:()=>{},onNext:es,items:(null==c?void 0:c.cartItems)||[],summary:(null==c?void 0:c.summary)||{},disabled:!!y})}):null]}),ed?(0,eO.jsx)(eVG,{cartItems:(null==c?void 0:c.cartItems)||[],summary:(null==c?void 0:c.summary)||{},actionText:p,onAction:()=>es(),disabled:!!y}):null,I.open?(0,eO.jsx)(Bb,{open:I.open,onCancel:()=>{D({open:!1,content:null}),location.replace("/")},onConfirm:()=>{(D({open:!1,content:null}),_("policyAccepted"),O&&!w("formSubmitted"))?en(O):ea()},item:I.content,isHideCheckout:!1,depositProtocolRequest:e=>{var t,l;return null==M||null==(l=M.request)||null==(t=l.get)?void 0:t.call(l,`/h5/shop-policy/${e}`,{})}}):null,E.open?(0,eO.jsx)(id.PisellModal,{open:E.open,platform:eo?"h5":"pc",onCancel:()=>{A(!1),z({open:!1,content:null}),L(null),location.replace("/")},title:(null==(t=E.content)?void 0:t.title)||eP.getText("pisell2.appointment.fill-form")||"填写信息",mobileModalHeight:"90vh",width:eo?"100%":900,className:"pisell-scan-order-form-modal",footer:(0,eO.jsx)("div",{className:"pisell-scan-order-form-modal-footer",children:(0,eO.jsx)(id.Button,{type:"primary",size:"large",loading:P,onClick:()=>{var e,t;P||(A(!0),null==(t=T.current)||null==(e=t.submit)||e.call(t))},className:"pisell-scan-order-form-modal-confirm-btn",children:String(eP.getText("pisell2.event.confirm")||"Confirm")})}),children:(0,eO.jsx)("div",{className:"pisell-scan-order-form-modal-body",children:C?(0,eO.jsx)(C,{id:(null==(l=E.content)?void 0:l.id)||0,ref:T,isGetLastData:!1,setting:(null==(i=E.content)?void 0:i.setting)||{isHidden:1},formWrapStyle:{padding:"16px"},isV2API:!0,isShowSkeleton:!0,onSubmit:e=>{A(!1),"success"===e&&(z({open:!1,content:null}),L(null),_("formSubmitted"),ea())},onFinishFailed:()=>{A(!1)},onFormValueChange:()=>{},defaultValues:(null==(a=E.content)?void 0:a.defaultValues)||{},isClearData:!1}):null})}):null]})}function eV7(){let{isLoading:e,errorMessage:t}=eVH();return e?(0,eO.jsx)("div",{className:"pisell-scan-order-loading",children:"Loading..."}):t?(0,eO.jsx)(eV1,{message:t,onRetry:()=>{window.location.reload()}}):(0,eO.jsx)(eV5,{})}let eV9={en:{"pisell2.scan.order.action.confirm.order":"Confirm order","pisell2.event.confirm":"Confirm","pisell2.event.cart":"Cart","pisell2.event.close.continue":"Close and continue","pisell2.event.continue":"Continue","pisell2.event.total":"Total","pisell2.scan.order.action.select.required":"Select Required","pisell2.scan.order.step.init":"Initialize","pisell2.scan.order.loading.initializing":"Preparing your order, please wait...","pisell2.scan.order.loading.products":"Loading products...","pisell2.scan.order.step.product":"Select product","pisell2.scan.order.step.check":"Check order","pisell2.scan.order.step.error":"Unavailable","pisell2.scan.order.empty.product":"No products available","pisell2.scan.order.resource.status.exception":"The current table is unavailable or locked.","pisell2.scan.order.store.status.exception":"The store is currently closed or in an abnormal state. Please contact staff.","pisell2.scan.order.note.title":"Order notes","pisell2.scan.order.note.placeholder":"Add order notes","pisell2.scan.order.fulfillment.title":"Fulfillment","pisell2.scan.order.fulfillment.table_service":"Table service","pisell2.scan.order.fulfillment.pickup":"Pickup","pisell2.scan.order.current.table":"Current table","pisell2.scan.order.pickup.ref.title":"Table Service","pisell2.scan.order.pickup.ref.heading":"Use any name you like","pisell2.scan.order.pickup.ref.description":"Enter your nickname, or anything fun!","pisell2.scan.order.pickup.ref.placeholder":"e.g. John","pisell2.scan.order.products.title":"Products","pisell2.scan.order.products.empty.tip":"Please select products","pisell2.scan.order.check.cart.empty.tip":"Please go back to add products","pisell2.scan.order.submit.disabled.default":"Order submission is currently disabled.","pisell2.scan.order.submit.failed":"Failed to submit order","pisell2.scan.order.menu.unavailable.title":"Ordering time has ended","pisell2.scan.order.menu.unavailable.description":"Some items in your cart are no longer available to order at this time. Select Confirm to refresh the page and choose your items again.","pisell2.scan.order.menu.validation.failed":"Unable to check the ordering time. Please try again. Your cart has been kept.","pisell2.scan.order.multiple.orders.tip":"There are multiple active orders for this table. Please contact staff for add-on orders.","pisell2.scan.order.multiple.orders.confirm":"I Got It","pisell2.scan.order.settled.cannot.add.tip":"This order has already been settled and you cannot add more items. Please scan again to create a new order or contact staff.","pisell2.scan.order.inventory.insufficient.title":"Insufficient inventory","pisell2.scan.order.inventory.insufficient.description":"The following items are out of stock or do not have enough inventory. Please adjust your cart and try again.","pisell2.scan.order.inventory.insufficient.products.label":"Unavailable products:","pisell2.scan.order.add.on.confirm.title":"This table has already started ordering","pisell2.scan.order.add.on.confirm.description":"Someone at your table has placed the order. This will be submitted as an add-on order.","pisell2.scan.order.add.on.confirm.button":"Confirm Add-on Order","pisell2.scan.order.add.on.return.button":"Return to Cart","pisell2.scan.order.add.on.unavailable.title":"Add-on ordering is not available","pisell2.scan.order.add.on.unavailable.description":"You can’t add items to this order from your phone right now.\nPlease ask a staff member for help.","pisell2.scan.order.add.on.unavailable.confirm":"Got it","pisell2.scan.order.add.on.login.required.title":"Notice","pisell2.scan.order.add.on.login.required":"Please login before placing an add-on order.","pisell2.text.goodpass":"Promotion","pisell2.text.goodpass.product-vouchers":"Product Vouchers","pisell2.text.goodpass.view-more":"View More","pisell2.text.goodpass.code":"Code","pisell2.text.goodpass.enter-code":"Enter Code","pisell2.text.goodpass.code-invalid":"Current code is invalid","pisell2.text.goodpass.code-invalid-cart":"No eligible items in the cart","pisell2.text.goodpass.code-invalid-expired":"Current coupon is not valid in use","pisell2.text.goodpass.login":"Login","pisell2.text.goodpass.login-tip":"to access your promotions","pisell2.text.apply":"Apply","pisell2.text.details":"Details","pisell2.appointment.booking.empty.data":"No data","pisell2.appointment.deposit.close":"Close","pisell2.appointment.policy":"You have read and agreed to this policy","pisell2.appointment.policy.confirm":"Confirm","pisell2.appointment.fill-form":"Enter your details"},"zh-CN":{"pisell2.scan.order.action.confirm.order":"确认下单","pisell2.event.confirm":"确定","pisell2.event.cart":"购物车","pisell2.event.close.continue":"关闭并继续","pisell2.event.continue":"继续","pisell2.event.total":"合计","pisell2.scan.order.action.select.required":"请选择","pisell2.scan.order.step.init":"初始化","pisell2.scan.order.loading.initializing":"正在为您准备点餐页面,请稍候...","pisell2.scan.order.loading.products":"正在获取商品中...","pisell2.scan.order.step.product":"选择商品","pisell2.scan.order.step.check":"订单确认","pisell2.scan.order.step.error":"不可用","pisell2.scan.order.empty.product":"暂无可选商品","pisell2.scan.order.resource.status.exception":"当前桌台不可用或被锁定","pisell2.scan.order.store.status.exception":"当前店铺不在营业中或者状态异常,请联系工作人员","pisell2.scan.order.note.title":"备注","pisell2.scan.order.note.placeholder":"请输入备注","pisell2.scan.order.fulfillment.title":"取餐方式","pisell2.scan.order.fulfillment.table_service":"送餐到桌","pisell2.scan.order.fulfillment.pickup":"到店自取","pisell2.scan.order.current.table":"当前桌台","pisell2.scan.order.pickup.ref.title":"桌边服务","pisell2.scan.order.pickup.ref.heading":"随便起个名字吧","pisell2.scan.order.pickup.ref.description":"输入你的昵称,或任何有趣的名字!","pisell2.scan.order.pickup.ref.placeholder":"例如:小明","pisell2.scan.order.products.title":"商品","pisell2.scan.order.products.empty.tip":"请选择商品","pisell2.scan.order.check.cart.empty.tip":"请返回添加商品","pisell2.scan.order.submit.disabled.default":"当前暂不可下单","pisell2.scan.order.submit.failed":"订单提交失败","pisell2.scan.order.menu.unavailable.title":"已过可下单时间","pisell2.scan.order.menu.unavailable.description":"购物车中有商品已不在可下单时间内。点击确定后将刷新页面,请重新选择商品。","pisell2.scan.order.menu.validation.failed":"暂时无法校验商品的可下单时间,请重试。购物车已保留。","pisell2.scan.order.multiple.orders.tip":"当前桌台存在多个进行中的订单,请联系店员处理加餐。","pisell2.scan.order.multiple.orders.confirm":"我知道了","pisell2.scan.order.settled.cannot.add.tip":"当前订单已结账,无法继续加餐。请重新扫码创建新订单或联系店员。","pisell2.scan.order.inventory.insufficient.title":"库存不足","pisell2.scan.order.inventory.insufficient.description":"以下商品库存不足或已售罄,请调整购物车后重新提交。","pisell2.scan.order.inventory.insufficient.products.label":"异常商品:","pisell2.scan.order.add.on.confirm.title":"本桌已开始点餐","pisell2.scan.order.add.on.confirm.description":"同行顾客已提交订单。本次将作为加餐提交,请确认后继续。","pisell2.scan.order.add.on.confirm.button":"确认加餐","pisell2.scan.order.add.on.return.button":"返回购物车","pisell2.scan.order.add.on.unavailable.title":"暂不支持加餐","pisell2.scan.order.add.on.unavailable.description":"当前无法通过手机为此订单加餐。\n如需加餐,请联系工作人员。","pisell2.scan.order.add.on.unavailable.confirm":"我知道了","pisell2.scan.order.add.on.login.required.title":"提示","pisell2.scan.order.add.on.login.required":"需要登录后才能加餐","pisell2.text.goodpass":"促销","pisell2.text.goodpass.product-vouchers":"商品兑换券","pisell2.text.goodpass.view-more":"查看更多","pisell2.text.goodpass.code":"券码","pisell2.text.goodpass.enter-code":"请输入券码","pisell2.text.goodpass.code-invalid":"当前券码不可用","pisell2.text.goodpass.code-invalid-cart":"当前购物车中无可用商品","pisell2.text.goodpass.code-invalid-expired":"当前优惠券不在使用期限内","pisell2.text.goodpass.login":"登录","pisell2.text.goodpass.login-tip":"以获取会员福利或使用账户积分","pisell2.text.apply":"应用","pisell2.text.details":"详情","pisell2.appointment.booking.empty.data":"暂无数据","pisell2.appointment.deposit.close":"关闭","pisell2.appointment.policy":"您已仔细阅读并同意此协议","pisell2.appointment.policy.confirm":"确定","pisell2.appointment.fill-form":"填写信息"},"zh-HK":{"pisell2.scan.order.action.confirm.order":"確認下單","pisell2.event.confirm":"確認","pisell2.event.cart":"購物車","pisell2.event.close.continue":"關閉並繼續","pisell2.event.continue":"繼續","pisell2.event.total":"合計","pisell2.scan.order.action.select.required":"請選擇","pisell2.scan.order.step.init":"初始化","pisell2.scan.order.loading.initializing":"正在為您準備點餐頁面,請稍候...","pisell2.scan.order.loading.products":"正在獲取商品中...","pisell2.scan.order.step.product":"選擇商品","pisell2.scan.order.step.check":"訂單確認","pisell2.scan.order.step.error":"不可用","pisell2.scan.order.empty.product":"暫無可選商品","pisell2.scan.order.resource.status.exception":"當前桌台不可用或被鎖定","pisell2.scan.order.store.status.exception":"當前店鋪不在營業中或者狀態異常,請聯繫工作人員","pisell2.scan.order.note.title":"備註","pisell2.scan.order.note.placeholder":"請輸入備註","pisell2.scan.order.fulfillment.title":"取餐方式","pisell2.scan.order.fulfillment.table_service":"送餐到桌","pisell2.scan.order.fulfillment.pickup":"到店自取","pisell2.scan.order.current.table":"當前桌台","pisell2.scan.order.pickup.ref.title":"桌邊服務","pisell2.scan.order.pickup.ref.heading":"隨便起個名字吧","pisell2.scan.order.pickup.ref.description":"輸入你的暱稱,或任何有趣的名字!","pisell2.scan.order.pickup.ref.placeholder":"例如:小明","pisell2.scan.order.products.title":"商品","pisell2.scan.order.products.empty.tip":"請選擇商品","pisell2.scan.order.check.cart.empty.tip":"請返回添加商品","pisell2.scan.order.submit.disabled.default":"當前暫不可下單","pisell2.scan.order.submit.failed":"訂單提交失敗","pisell2.scan.order.menu.unavailable.title":"已過可下單時間","pisell2.scan.order.menu.unavailable.description":"購物車中有商品已不在可下單時間內。點擊確定後將重新整理頁面,請重新選擇商品。","pisell2.scan.order.menu.validation.failed":"暫時無法核實商品的可下單時間,請重試。購物車已保留。","pisell2.scan.order.multiple.orders.tip":"當前桌台存在多個進行中的訂單,請聯繫店員處理加餐。","pisell2.scan.order.multiple.orders.confirm":"我知道了","pisell2.scan.order.settled.cannot.add.tip":"當前訂單已結賬,無法繼續加餐。請重新掃碼創建新訂單或聯繫店員。","pisell2.scan.order.inventory.insufficient.title":"庫存不足","pisell2.scan.order.inventory.insufficient.description":"以下商品庫存不足或已售罄,請調整購物車後重新提交。","pisell2.scan.order.inventory.insufficient.products.label":"異常商品:","pisell2.scan.order.add.on.confirm.title":"本桌已開始點餐","pisell2.scan.order.add.on.confirm.description":"同行顧客已提交訂單。本次將作為加餐提交,請確認後繼續。","pisell2.scan.order.add.on.confirm.button":"確認加餐","pisell2.scan.order.add.on.return.button":"返回購物車","pisell2.scan.order.add.on.unavailable.title":"暫不支援加餐","pisell2.scan.order.add.on.unavailable.description":"目前無法透過手機為此訂單加餐。\n如需加餐,請聯絡工作人員。","pisell2.scan.order.add.on.unavailable.confirm":"我知道了","pisell2.scan.order.add.on.login.required.title":"提示","pisell2.scan.order.add.on.login.required":"需要登錄後才能加餐","pisell2.text.goodpass":"促銷","pisell2.text.goodpass.product-vouchers":"商品兌換券","pisell2.text.goodpass.view-more":"查看更多","pisell2.text.goodpass.code":"券碼","pisell2.text.goodpass.enter-code":"請輸入券碼","pisell2.text.goodpass.code-invalid":"當前券碼不可用","pisell2.text.goodpass.code-invalid-cart":"當前購物車中無可用商品","pisell2.text.goodpass.code-invalid-expired":"當前優惠券不在使用期限內","pisell2.text.goodpass.login":"登錄","pisell2.text.goodpass.login-tip":"以獲取會員福利或使用賬戶積分","pisell2.text.apply":"應用","pisell2.text.details":"詳情","pisell2.appointment.booking.empty.data":"暫無數據","pisell2.appointment.deposit.close":"关闭","pisell2.appointment.policy":"您已仔細閱讀並同意此協議","pisell2.appointment.policy.confirm":"確定","pisell2.appointment.fill-form":"填寫資訊"},ja:{"pisell2.scan.order.action.confirm.order":"注文を確定","pisell2.event.confirm":"確認","pisell2.event.cart":"カート","pisell2.event.close.continue":"閉じて続行","pisell2.event.continue":"続行","pisell2.event.total":"合計","pisell2.scan.order.action.select.required":"選択してください","pisell2.scan.order.step.init":"初期化","pisell2.scan.order.loading.initializing":"ご注文画面を準備しています。しばらくお待ちください。","pisell2.scan.order.loading.products":"商品を取得しています...","pisell2.scan.order.step.product":"商品を選択","pisell2.scan.order.step.check":"注文確認","pisell2.scan.order.step.error":"利用不可","pisell2.scan.order.empty.product":"利用可能な商品がありません","pisell2.scan.order.resource.status.exception":"現在のテーブルは利用できないか、ロックされています。","pisell2.scan.order.store.status.exception":"現在、店舗は営業時間外または状態が異常です。スタッフまでお問い合わせください。","pisell2.scan.order.note.title":"備考","pisell2.scan.order.note.placeholder":"備考を入力してください","pisell2.scan.order.fulfillment.title":"受け取り方法","pisell2.scan.order.fulfillment.table_service":"テーブルサービス","pisell2.scan.order.fulfillment.pickup":"ピックアップ","pisell2.scan.order.current.table":"現在のテーブル","pisell2.scan.order.pickup.ref.title":"テーブルサービス","pisell2.scan.order.pickup.ref.heading":"好きな名前をどうぞ","pisell2.scan.order.pickup.ref.description":"ニックネームや楽しい名前を入力してね!","pisell2.scan.order.pickup.ref.placeholder":"例: ジョン","pisell2.scan.order.products.title":"商品","pisell2.scan.order.products.empty.tip":"商品を選択してください","pisell2.scan.order.check.cart.empty.tip":"商品を追加するには、前の画面に戻ってください","pisell2.scan.order.submit.disabled.default":"現在、注文を送信できません。","pisell2.scan.order.submit.failed":"注文の送信に失敗しました","pisell2.scan.order.menu.unavailable.title":"注文可能な時間を過ぎています","pisell2.scan.order.menu.unavailable.description":"カートに注文可能な時間を過ぎた商品があります。「確認」を押すとページが再読み込みされます。商品を選び直してください。","pisell2.scan.order.menu.validation.failed":"注文可能な時間を確認できませんでした。もう一度お試しください。カートの内容は保持されています。","pisell2.scan.order.multiple.orders.tip":"現在のテーブルには進行中の注文が複数あります。追加注文についてはスタッフにお問い合わせください。","pisell2.scan.order.multiple.orders.confirm":"了解しました","pisell2.scan.order.settled.cannot.add.tip":"現在の注文はすでに会計済みのため、追加注文できません。再度QRコードをスキャンして新しい注文を作成するか、スタッフにお問い合わせください。","pisell2.scan.order.inventory.insufficient.title":"在庫が不足しています","pisell2.scan.order.inventory.insufficient.description":"以下の商品は在庫切れ、または在庫が不足しています。カートを調整してからもう一度送信してください。","pisell2.scan.order.inventory.insufficient.products.label":"対象商品:","pisell2.scan.order.add.on.confirm.title":"このテーブルではすでに注文が開始されています","pisell2.scan.order.add.on.confirm.description":"同席のお客様がすでに注文を送信しました。今回は追加注文として送信されます。確認して続行してください。","pisell2.scan.order.add.on.confirm.button":"追加注文を確認","pisell2.scan.order.add.on.return.button":"カートに戻る","pisell2.scan.order.add.on.unavailable.title":"追加注文は現在ご利用いただけません","pisell2.scan.order.add.on.unavailable.description":"現在、スマートフォンからこの注文に商品を追加することはできません。\n追加注文をご希望の場合は、スタッフにお声がけください。","pisell2.scan.order.add.on.unavailable.confirm":"了解しました","pisell2.scan.order.add.on.login.required.title":"お知らせ","pisell2.scan.order.add.on.login.required":"追加注文を行うにはログインが必要です。","pisell2.text.goodpass":"プロモーション","pisell2.text.goodpass.product-vouchers":"商品バウチャー","pisell2.text.goodpass.view-more":"もっと見る","pisell2.text.goodpass.code":"コード","pisell2.text.goodpass.enter-code":"コードを入力","pisell2.text.goodpass.code-invalid":"現在のコードは無効です","pisell2.text.goodpass.code-invalid-cart":"カートに適格な項目がありません","pisell2.text.goodpass.code-invalid-expired":"現在のクーポンは使用期限外です","pisell2.text.goodpass.login":"ログイン","pisell2.text.goodpass.login-tip":"プロモーションにアクセスするため","pisell2.text.apply":"適用","pisell2.text.details":"詳細","pisell2.appointment.booking.empty.data":"データなし","pisell2.appointment.deposit.close":"閉じる","pisell2.appointment.policy":"このポリシーを読み、同意しました","pisell2.appointment.policy.confirm":"確認","pisell2.appointment.fill-form":"詳細を入力"},pt:{"pisell2.scan.order.action.confirm.order":"Confirmar pedido","pisell2.event.confirm":"Confirmar","pisell2.event.cart":"Carrinho","pisell2.event.close.continue":"Fechar e continuar","pisell2.event.continue":"Continuar","pisell2.event.total":"Total","pisell2.scan.order.action.select.required":"Selecionar obrigat\xf3rio","pisell2.scan.order.step.init":"Inicializar","pisell2.scan.order.loading.initializing":"Estamos preparando sua tela de pedido, aguarde...","pisell2.scan.order.loading.products":"Carregando produtos...","pisell2.scan.order.step.product":"Selecionar produto","pisell2.scan.order.step.check":"Verificar pedido","pisell2.scan.order.step.error":"Indispon\xedvel","pisell2.scan.order.empty.product":"Nenhum produto dispon\xedvel","pisell2.scan.order.resource.status.exception":"A mesa atual est\xe1 indispon\xedvel ou bloqueada.","pisell2.scan.order.store.status.exception":"A loja est\xe1 fechada no momento ou em estado anormal. Entre em contato com a equipe.","pisell2.scan.order.note.title":"Observa\xe7\xf5es do pedido","pisell2.scan.order.note.placeholder":"Adicione observa\xe7\xf5es do pedido","pisell2.scan.order.fulfillment.title":"Forma de retirada","pisell2.scan.order.fulfillment.table_service":"Servi\xe7o \xe0 mesa","pisell2.scan.order.fulfillment.pickup":"Retirada","pisell2.scan.order.current.table":"Mesa atual","pisell2.scan.order.pickup.ref.title":"Servi\xe7o \xe0 mesa","pisell2.scan.order.pickup.ref.heading":"Use o nome que quiser","pisell2.scan.order.pickup.ref.description":"Digite seu apelido ou algo divertido!","pisell2.scan.order.pickup.ref.placeholder":"Ex.: Jo\xe3o","pisell2.scan.order.products.title":"Produtos","pisell2.scan.order.products.empty.tip":"Selecione produtos","pisell2.scan.order.check.cart.empty.tip":"Volte para adicionar produtos","pisell2.scan.order.submit.disabled.default":"No momento, n\xe3o \xe9 poss\xedvel enviar pedidos.","pisell2.scan.order.submit.failed":"Falha ao enviar o pedido","pisell2.scan.order.menu.unavailable.title":"O hor\xe1rio para pedidos terminou","pisell2.scan.order.menu.unavailable.description":"Alguns itens no carrinho n\xe3o est\xe3o mais dispon\xedveis para pedido neste hor\xe1rio. Selecione Confirmar para atualizar a p\xe1gina e escolher os itens novamente.","pisell2.scan.order.menu.validation.failed":"N\xe3o foi poss\xedvel verificar o hor\xe1rio para pedidos. Tente novamente. Seu carrinho foi mantido.","pisell2.scan.order.multiple.orders.tip":"H\xe1 v\xe1rios pedidos ativos nesta mesa. Entre em contato com a equipe para adicionar itens.","pisell2.scan.order.multiple.orders.confirm":"Entendi","pisell2.scan.order.settled.cannot.add.tip":"Este pedido j\xe1 foi finalizado e n\xe3o \xe9 poss\xedvel adicionar mais itens. Escaneie novamente para criar um novo pedido ou entre em contato com a equipe.","pisell2.scan.order.inventory.insufficient.title":"Estoque insuficiente","pisell2.scan.order.inventory.insufficient.description":"Os seguintes itens est\xe3o sem estoque ou n\xe3o t\xeam estoque suficiente. Ajuste o carrinho e tente novamente.","pisell2.scan.order.inventory.insufficient.products.label":"Produtos indispon\xedveis:","pisell2.scan.order.add.on.confirm.title":"Esta mesa j\xe1 come\xe7ou a fazer o pedido","pisell2.scan.order.add.on.confirm.description":"Algu\xe9m na sua mesa j\xe1 enviou o pedido. Este ser\xe1 enviado como um pedido adicional.","pisell2.scan.order.add.on.confirm.button":"Confirmar pedido adicional","pisell2.scan.order.add.on.return.button":"Voltar ao carrinho","pisell2.scan.order.add.on.unavailable.title":"Pedidos adicionais n\xe3o est\xe3o dispon\xedveis","pisell2.scan.order.add.on.unavailable.description":"No momento, voc\xea n\xe3o pode adicionar itens a este pedido pelo celular.\nPe\xe7a ajuda a um membro da equipe.","pisell2.scan.order.add.on.unavailable.confirm":"Entendi","pisell2.scan.order.add.on.login.required.title":"Aviso","pisell2.scan.order.add.on.login.required":"Fa\xe7a login antes de fazer um pedido adicional.","pisell2.text.goodpass":"Promo\xe7\xe3o","pisell2.text.goodpass.product-vouchers":"Vales de Produto","pisell2.text.goodpass.view-more":"Ver Mais","pisell2.text.goodpass.code":"C\xf3digo","pisell2.text.goodpass.enter-code":"Digite o C\xf3digo","pisell2.text.goodpass.code-invalid":"C\xf3digo atual \xe9 inv\xe1lido","pisell2.text.goodpass.code-invalid-cart":"Nenhum item eleg\xedvel no carrinho","pisell2.text.goodpass.code-invalid-expired":"Cupom atual n\xe3o est\xe1 no per\xedodo de uso","pisell2.text.goodpass.login":"Entrar","pisell2.text.goodpass.login-tip":"para acessar suas promo\xe7\xf5es","pisell2.text.apply":"Aplicar","pisell2.text.details":"Detalhes","pisell2.appointment.booking.empty.data":"Sem dados","pisell2.appointment.deposit.close":"Fechar","pisell2.appointment.policy":"Voc\xea leu e concordou com esta pol\xedtica","pisell2.appointment.policy.confirm":"Confirmar","pisell2.appointment.fill-form":"Digite seus detalhes"}},eYe=function(e){var t,l,i,a;let n=eI(),r={biz:(null==(a=null==n||null==(t=n.engine)?void 0:t.props)?void 0:a.biz)||"",resource_id:null==a?void 0:a.resource_id,order_id:null==a?void 0:a.order_id};return eP.init(eV9,(null==n||null==(i=n.engine)||null==(l=i.props)?void 0:l.locale)||"en"),(0,eO.jsx)("div",{className:`pisell-scan-order-wrap ${rp()?"pisell-scan-order-mobile-wrap":""}`,children:(0,eO.jsx)(eVq,{entryContext:r,children:(0,eO.jsx)(eV7,{})})})};function eYt(e){if(!e||"object"!=typeof e)return null;let t=ev7(e);return"string"!=typeof t.unique_identification_number||0===t.unique_identification_number.length?null:t}function eYl(e){var t;return null==(t=eYt(e))?void 0:t.unique_identification_number}let eYi=[61947,61948];function eYa(){var e,t;let l,i=(null==(l=eI())||null==(t=l.appHelper)?void 0:t.utils)||{};return String((null==i||null==(e=i.getSymbolic)?void 0:e.call(i))||"$")}function eYn(e,t,l){if("function"!=typeof(null==e?void 0:e[t]))return l;let i=e[t]();return i&&"function"==typeof(null==i?void 0:i.then)?l:i??l}async function eYr(e,t){for(var l=arguments.length,i=Array(l>2?l-2:0),a=2;a<l;a++)i[a-2]=arguments[a];if(!e)throw Error("venueBooking module not found");if("function"!=typeof(null==e?void 0:e[t]))throw Error(`venueBooking action "${t}" not found`);return e[t](...i)}async function eYs(e,t){return eYr(e,"loadVenueProducts",{productIds:t})}async function eYo(e,t,l){return eYr(e,"fetchResourceAvailability",{startDate:t,endDate:l})}function eYd(e,t,l){return e&&"function"==typeof e.getDateRangeSummary&&e.getDateRangeSummary({startDate:t,endDate:l})||[]}function eYc(e,t){return e&&"function"==typeof e.getTimeSlotGrid&&e.getTimeSlotGrid(t)||null}async function eYu(e,t){return eYr(e,"toggleSlot",t)}function eYp(e,t,l,i){return!!e&&"function"==typeof e.isSlotSelected&&!!e.isSlotSelected(t,l,i)}function eYm(e,t){return!!e&&"function"==typeof e.isSlotDisabledBySelection&&!!e.isSlotDisabledBySelection(t)}function eYg(e,t){for(let l of[null==t?void 0:t.startTime,null==t?void 0:t.start_time,null==t?void 0:t.startDate,null==t?void 0:t.start_date]){let t=function(e){if("string"!=typeof e)return null;let t=e.trim().match(/^(\d{4}-\d{2}-\d{2})/);return t?t[1]:null}(l);if(t)return void e.add(t)}}async function eYh(e){let t="function"==typeof(null==e?void 0:e.getSummary)?await e.getSummary():null,l=eYn(e,"getOrderProducts",[]),i=Array.isArray(l)?l:[],a=eYn(e,"getTempOrder",null),n=(null==a?void 0:a.currency_symbol)||"$",r=i.map(e=>{var t,l,i,n;let r=eYl(e),s=(null==a||null==(i=a._extend)||null==(l=i.productsByUid)||null==(t=l[r])?void 0:t.origin)??e._origin,o=Array.isArray(null==(n=e.product_sku)?void 0:n.option)?e.product_sku.option.map(e=>({...e,price:e.add_price??e.price})):e.product_option_item;return{...e,identity_key:r,product_option_item:o,_origin:Array.isArray(o)?{...s,callbackData:{...null==s?void 0:s.callbackData,option:o}}:s}}),s=eVE({orderProducts:r,amountSymbol:n}).map((e,t)=>{let l=r[t],i=l.identity_key;return{...e,metadata:l.metadata,product_sku:l.product_sku,unique_identification_number:i,_id:i??e._id,rowKey:i??e.rowKey}}),o=(t&&"object"==typeof t?t:null)||(null==a?void 0:a.summary)||{};return{cartItems:s,summary:o&&"object"==typeof o?o:{},note:String((null==a?void 0:a.note)||""),contactsInfo:Array.isArray(null==a?void 0:a.contacts_info)?a.contacts_info:[]}}function eYv(e){return e.format("YYYY-MM-DD")}function eYf(e){let t=e.startOf("week");return Array.from({length:7},(e,l)=>t.add(l,"day"))}function eYy(e){return e.format("MMMM YYYY")}function eYb(e){return e.endsWith(":00")}function eYx(e,t){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"$",i=eYv(e),a=t.find(e=>e.date===i);if(!a)return{topTag:null,startingPrice:null,fewLeft:!1,soldOut:!0,unavailable:!0};let n="sold_out"===a.status||"unavailable"===a.status,r="few_left"===a.status,s="unavailable"===a.status,o=a.startingPrice?`${l}${a.startingPrice}+`:null;return{topTag:null,startingPrice:n||s?null:o,fewLeft:r,soldOut:n,unavailable:s}}function eYk(e,t){let l=e.filter(e=>e.slots[t]&&"available"===e.slots[t].status).length,i=e.length>0?l/e.length:0;return{soldOut:0===l,fewLeft:l>0&&i<.2}}function eY_(e){return{price:e.price?parseFloat(e.price):0,originalPrice:null,label:"",highlight:!1}}function eYw(e){return e.highlight?"text-emerald-600":"Pickleball"===e.courtType?"vb-primary-text":"text-zinc-800"}let eYj=(0,ex.createContext)(void 0),eYS={dateSummary:[],timeSlotGrid:null,cartItems:[],summary:{},note:"",contactsInfo:[],venueProducts:[],addonProductList:[]},eYN={};function eYM(e,t){let l=eYv(ef()());return t<l?null:{startDate:e<l?l:e,endDate:t}}function eYC(e){var t,l,i;let{entryContext:a,children:n}=e,r=eD(),s=function(){let e=eD(),t=(0,ex.useRef)(null);if(!t.current){var l;t.current=(null==e||null==(l=e.getModule)?void 0:l.call(e,"venueBooking"))??null}return t.current}(),[o,d]=(0,ex.useState)("select-venue"),c=(0,ex.useRef)(!1),[u,p]=(0,ex.useState)(!1),[m,g]=(0,ex.useState)(eYS),h=(0,ex.useRef)(m);h.current=m;let v=(0,ex.useMemo)(()=>{var e;return((null==(e=m.addonProductList)?void 0:e.length)||0)>0?["select-venue","addons","checkout"]:["select-venue","checkout"]},[null==(t=m.addonProductList)?void 0:t.length]),[f,y]=(0,ex.useState)(!0),[b,x]=(0,ex.useState)(!0),[k,_]=(0,ex.useState)(!0),w=b||k,[j,S]=(0,ex.useState)(ef()()),[N,M]=(0,ex.useState)("ALL"),[C,T]=(0,ex.useState)(""),[P,A]=(0,ex.useState)(""),[I,D]=(0,ex.useState)(!1),[E,z]=(0,ex.useState)(!1),[O,L]=(0,ex.useState)(ef()().startOf("month")),{isLogin:$,openLoginModal:R}=qS(),F=eI(),B=(null==F||null==(l=F.appHelper)?void 0:l.utils)||eYN,[q,H]=(0,ex.useState)([]),[V,Y]=(0,ex.useState)(!1),[U,W]=(0,ex.useState)({passed:null,failures:[]}),[G,Q]=(0,ex.useState)(String(eP.getText("pisell2.venue.action.next.addons")||"")),[K,Z]=(0,ex.useState)(!1),J=(0,ex.useRef)(j);J.current=j;let X=(0,ex.useRef)(!1),ee=(0,ex.useMemo)(()=>{let e=s&&"function"==typeof s.getAllSelectedSlots&&s.getAllSelectedSlots()||[];return!!Array.isArray(e)&&e.length>0||m.cartItems.length>0},[s,m]);(0,ex.useEffect)(()=>{if(!P)return;let e=window.setTimeout(()=>A(""),3800);return()=>window.clearTimeout(e)},[P]),(0,ex.useEffect)(()=>{var e,t,l;if(c.current||!s)return;c.current=!0;let i=null==(e=s.getUIState)?void 0:e.call(s,"pendingStep");if(i){null==(l=s.deleteUIState)||l.call(s,"pendingStep"),d(i);return}let a=null==(t=s.getUIState)?void 0:t.call(s,"step");a&&d(a)},[s]),(0,ex.useEffect)(()=>{var e;c.current&&s&&(null==(e=s.setUIState)||e.call(s,"step",o))},[o,s]),(0,ex.useEffect)(()=>{c.current&&u&&(v.includes(o)||d(v[0]))},[v,o,u]);let et=(0,ex.useCallback)(async e=>{try{let t=await eYh(s);if(g(l=>({...l,...t,...e||{}})),s&&"function"==typeof s.getDiscountList){let e=s.getDiscountList()||[];H(e)}}catch(e){console.warn("[venueBooking] refreshViewModel failed",e)}},[s]),el=(0,ex.useCallback)(e=>{if(!s)return;let t=eYc(s,e||eYv(J.current));g(e=>({...e,timeSlotGrid:t}))},[s]),ei=(0,ex.useCallback)(async(e,t)=>{if(s){x(!0);try{let l=eYM(e,t),i=[];if(l){await eYo(s,l.startDate,l.endDate);let e=eYd(s,l.startDate,l.endDate);i=Array.isArray(e)?e:[]}let a=eYv(J.current),n=eYc(s,a);g(e=>({...e,dateSummary:i,timeSlotGrid:n}))}finally{x(!1)}}},[s]),ea=(0,ex.useCallback)(async e=>{if(s){x(!0);try{let t=[];for(let l=0;l<=8;l++){let i=e.add(7*l,"day"),{startDate:a,endDate:n}=function(e){let t=eYf(e);return{startDate:eYv(t[0]),endDate:eYv(t[t.length-1])}}(i),r=eYM(a,n);if(!r)continue;await eYo(s,r.startDate,r.endDate);let o=eYd(s,r.startDate,r.endDate);0===l&&(t=Array.isArray(o)?o:[]);let d=function(e){let{summary:t,preferredDate:l}=e;if(!Array.isArray(t)||!t.length)return null;let i=t.filter(e=>(null==e?void 0:e.status)==="available"||(null==e?void 0:e.status)==="few_left").map(e=>ef()(String((null==e?void 0:e.date)||""))).filter(e=>e.isValid());if(!i.length)return null;let a=l.startOf("day"),n=i.filter(e=>!e.isBefore(a,"day")).sort((e,t)=>e.valueOf()-t.valueOf());return n.length?n[0]:i.sort((e,t)=>t.valueOf()-e.valueOf())[0]}({summary:Array.isArray(o)?o:[],preferredDate:0===l?e:i.startOf("week")});if(!d)continue;S(d),L(d.startOf("month"));let c=eYc(s,eYv(d));g(e=>({...e,dateSummary:Array.isArray(o)?o:[],timeSlotGrid:c}));return}let l=eYc(s,eYv(e));S(e),L(e.startOf("month")),g(e=>({...e,dateSummary:t,timeSlotGrid:l}))}finally{x(!1)}}},[s]),en=(0,ex.useCallback)(async(e,t,l)=>{if(s&&l.price)try{await eYu(s,{resourceId:e,productId:t,startTime:l.startTime,endTime:l.endTime,price:l.price}),el(),await et()}catch(e){console.warn("[venueBooking] toggleSlot failed",e)}},[s,el,et]),er=(0,ex.useCallback)(async e=>{await eYr(s,"updateTempOrderNote",e),await et()},[s,et]),es=(0,ex.useCallback)(async function(e){for(var t=arguments.length,l=Array(t>1?t-1:0),i=1;i<t;i++)l[i-1]=arguments[i];return eYr(s,e,...l)},[s]),eo=(0,ex.useCallback)(async()=>{try{var e,t,l,i,a;if("function"!=typeof(null==B||null==(e=B.token)?void 0:e.get))return;if(!(null==B||null==(l=B.token)||null==(t=l.get)?void 0:t.call(l)))return void await es("onCustomerLogout");let n=null==B||null==(a=B.storage)||null==(i=a.get)?void 0:i.call(a,"customer"),r="string"==typeof n?JSON.parse(n||"{}"):n||{},s=null==r?void 0:r.id;if(!s)return;await es("onCustomerLogin",{customerId:s})}catch(e){console.warn("[venueBooking] syncCustomerLoginToModule failed",e)}},[B,es]),ed=(0,ex.useCallback)(e=>{v.includes(e)&&d(e)},[v]),ec=(0,ex.useCallback)(()=>{d(e=>{let t=v.findIndex(t=>t===e);return t<0||t>=v.length-1?e:v[t+1]})},[v]),eu=(0,ex.useCallback)(()=>{d(e=>{let t=v.findIndex(t=>t===e);return t<=0?e:v[t-1]})},[v]),ep=(0,ex.useCallback)(async()=>{try{var e;await eo();let t=(null==s||null==(e=s.getDiscountList)?void 0:e.call(s))||[];H(t),await et()}catch(e){console.warn("[venueBooking] handleLoginSuccess failed",e)}},[eo,s,et]),em=(0,ex.useRef)(eo);em.current=eo;let eg=(0,ex.useRef)(ea);eg.current=ea;let eh=(0,ex.useRef)(ep);eh.current=ep;let ev=(0,ex.useCallback)(async()=>{if(!K)try{var e,t,l;Z(!0);let i=await eYr(s,"submitOrder");await et();let a=(null==i||null==(e=i.data)?void 0:e.order_id)||(null==i?void 0:i.order_id)||"",n=null==m||null==(t=m.summary)?void 0:t.total_amount;if(e_.message.success({content:String(eP.getText("pisell2.venue.order.submit.success")||"订单已提交"),duration:2}),!a)return void console.warn("[venueBooking] submitOrder succeeded but order_id is missing",i);let r=s&&"function"==typeof s.getOtherParams&&s.getOtherParams()||{};if("function"==typeof(null==B?void 0:B.action)&&(null==r?void 0:r.openData["sale.require_payment_on_submit"])){if(0===n||(null==r||null==(l=r.openData["checkout.checkout_options"])?void 0:l.length)===0)return location.replace(`/payment-finish/success?amount=${n}&order_id=${a}`);B.action({type:"pisell1.payment",data:{order_id:a,total_amount:n},callback:e=>{}})}else location.replace(`/order/details?id=${a}`)}catch(e){e_.message.error({content:function(e){let t=Array.isArray(null==e?void 0:e.failures)?e.failures[0]:null,l=String((null==t?void 0:t.validationMessage)||"").trim();if(l)return l;let i=String((null==e?void 0:e.message)||"").trim();return i||String(eP.getText("pisell2.venue.error.submit.order")||"提交订单失败,请稍后重试。")}(e),duration:2}),console.warn("[venueBooking] submitOrder failed",e)}finally{Z(!1)}},[K,s,et,B,null==m||null==(i=m.summary)?void 0:i.total_amount]),ey=(0,ex.useCallback)(async()=>{var e;$?await ev():(null==s||null==(e=s.setUIState)||e.call(s,"pendingStep","checkout"),R({callback:e=>{var t;"success"===e&&(null==s||null==(t=s.deleteUIState)||t.call(s,"pendingStep"),ep().then(()=>{ev()}))}}))},[$,R,ep,ev,s]),eb=(0,ex.useCallback)(()=>{if(!$){var e;null==s||null==(e=s.setUIState)||e.call(s,"pendingStep","checkout"),R({callback:e=>{if("success"===e){var t;null==s||null==(t=s.deleteUIState)||t.call(s,"pendingStep"),ep().then(()=>ed("checkout"))}}});return}if("addons"===o){let{hasError:e}=(e=>{let{items:t=[],getHolderConfig:l=egA}=e,i=t.filter(e=>!!epz(l(e))&&!egN(e));return{hasError:i.length>0,invalidItems:i}})({items:m.cartItems,getHolderConfig:egA});if(e)return}ed("checkout")},[$,R,ep,ed,s,o,m.cartItems,egA]),ek=(0,ex.useCallback)(()=>{var e,t;if("select-venue"===o)return ee?"checkout"===v[1]?void eb():void ed("addons"):void e_.message.warning({content:String(eP.getText("pisell2.venue.cart.choose.first")||"请先选择场地。"),duration:2});if("addons"===o)return void eb();let l=null==(e=m.summary)?void 0:e.deposit;(null==l?void 0:l.hasDeposit)&&(null==l||null==(t=l.deposit_policy_data)?void 0:t.length)>0&&!V?e_.message.warning(String(eP.getText("pisell2.appointment.deposit.agree.policy")||"请先同意定金协议")):ey()},[o,ee,V,m.summary,v,ed,ey,eb]);(0,ex.useEffect)(()=>{var e;let t=null==B?void 0:B.pubsub;if(!t)return;let l=async e=>{("success"===e||(null==e?void 0:e.status)==="success")&&await eh.current()};return null==(e=t.subscribe)||e.call(t,"pisell1.login.success",l),()=>{var e;null==(e=t.unsubscribe)||e.call(t,"pisell1.login.success",l)}},[null==B?void 0:B.pubsub]),(0,ex.useEffect)(()=>{var e,t;if(!s)return;let l=!1,i=async()=>{try{var e,t;let i=await eYh(s),a=await (null==(e=s.getProductList)?void 0:e.call(s));if(l)return;let n=h.current.dateSummary.map(e=>e.date).sort(),r=n.length?eYd(s,n[0],n[n.length-1]):[],o=eYc(s,eYv(J.current));g(e=>{var t;return{...e,...i,timeSlotGrid:o,dateSummary:Array.isArray(r)?r:e.dateSummary,venueProducts:(null==(t=s.getVenueProducts)?void 0:t.call(s))||e.venueProducts,addonProductList:Array.isArray(a)?a:e.addonProductList}}),H((null==(t=s.getDiscountList)?void 0:t.call(s))||[])}catch(e){console.warn("[venueBooking] smart pricing refresh failed",e)}};return null==r||null==(t=r.effects)||null==(e=t.on)||e.call(t,"venueBooking:onSmartPricingUpdated",i),()=>{var e,t;l=!0,null==r||null==(t=r.effects)||null==(e=t.off)||e.call(t,"venueBooking:onSmartPricingUpdated",i)}},[r,s]),(0,ex.useEffect)(()=>{if(!s)return;_(!0),el(eYv(j));let e=window.setTimeout(()=>_(!1),220);return()=>window.clearTimeout(e)},[j,s,el]),(0,ex.useEffect)(()=>{var e,t;if(!s)return;let l=!1,i=e=>{let t=null==e?void 0:e.cartValidation;W({passed:"boolean"==typeof(null==t?void 0:t.passed)||(null==t?void 0:t.passed)===null?t.passed:"boolean"==typeof(null==e?void 0:e.cartValidationPassed)?e.cartValidationPassed:null,failures:Array.isArray(null==t?void 0:t.failures)?t.failures:[]})};return(async()=>{try{let e=await eYr(s,"getCartValidation");l||W({passed:"boolean"==typeof(null==e?void 0:e.passed)||(null==e?void 0:e.passed)===null?e.passed:null,failures:Array.isArray(null==e?void 0:e.failures)?e.failures:[]})}catch{l||W({passed:null,failures:[]})}})(),null==r||null==(t=r.effects)||null==(e=t.on)||e.call(t,"venueBooking:onCartValidationChanged",i),()=>{var e,t;l=!0,null==r||null==(t=r.effects)||null==(e=t.off)||e.call(t,"venueBooking:onCartValidationChanged",i)}},[r,s]),(0,ex.useEffect)(()=>{if(X.current||!s)return;X.current=!0;let e=!1;return(async()=>{try{y(!0),await em.current(),await eYs(s,eYi);let t="function"==typeof(null==s?void 0:s.getVenueProducts)?s.getVenueProducts():[];await eg.current(J.current);let l=await eYh(s);e||(g(e=>({...e,cartItems:Array.isArray(l.cartItems)?l.cartItems:[],summary:l.summary||{},note:l.note||"",contactsInfo:Array.isArray(l.contactsInfo)?l.contactsInfo:[],venueProducts:Array.isArray(t)?t:[]})),y(!1),"function"==typeof(null==s?void 0:s.getProductList)?s.getProductList().then(t=>{!e&&Array.isArray(t)&&g(e=>({...e,addonProductList:t}))}).catch(e=>{console.warn("[venueBooking] prefetch getProductList failed",e)}).finally(()=>{e||p(!0)}):p(!0))}catch(t){console.warn("[venueBooking] bootstrap failed",t),e||y(!1)}})(),()=>{e=!0}},[s]);let ew=(0,ex.useMemo)(()=>({venueBookingModule:s,currentStep:o,stepList:v,viewModel:m,anchorDate:j,filter:N,search:C,isLoading:f,isWeekLoading:b,isGridLoading:w,limitMessage:P,mobileCartOpen:I,monthPickerOpen:E,monthCursor:O,canNext:ee,cartValidation:U,footerActionText:G,isSubmittingOrder:K,isLogin:$,openLoginModal:R,handleLoginSuccess:ep,discountList:q,isAgreeDepositPolicy:V,setIsAgreeDepositPolicy:Y,goToStep:ed,nextStep:ec,prevStep:eu,setAnchorDate:S,setFilter:M,setSearch:T,setLimitMessage:A,setMobileCartOpen:D,setMonthPickerOpen:z,setMonthCursor:L,setFooterActionText:Q,toggleSlot:en,refreshViewModel:et,fetchWeekData:ei,goToNearestAvailableDate:ea,refreshTimeSlotGrid:el,runModuleAction:es,updateOrderNote:er,handlePrimaryAction:ek,handleSubmitOrder:ey}),[s,o,m,j,N,C,f,b,w,P,I,E,O,ee,U,G,K,$,R,ep,q,en,et,ei,ea,el,es,er,ek,ey,ed,ec,eu]);return(0,eO.jsx)(eYj.Provider,{value:ew,children:n})}function eYT(){let e=(0,ex.useContext)(eYj);if(e)return e;throw Error("useVenueBookingContext must be used within VenueBookingProvider")}function eYP(){var e;let{currentStep:t,canNext:l,viewModel:i,goToStep:a,prevStep:n}=eYT(),[r,s]=(0,ex.useState)(!1),[o,d]=(0,ex.useState)(!1),c=(0,ex.useRef)(null),u=(0,ex.useMemo)(()=>{var e;return[{key:"select-venue",titleKey:"pisell2.venue.step.select"},...((null==(e=i.addonProductList)?void 0:e.length)||0)>0?[{key:"addons",titleKey:"pisell2.venue.step.addons"}]:[],{key:"checkout",titleKey:"pisell2.venue.step.checkout"}].map((e,t)=>({...e,n:t+1}))},[null==(e=i.addonProductList)?void 0:e.length]),p=u.findIndex(e=>e.key===t),m=u[p]||u[0],g=p<=0;function h(e){return"select-venue"===e.key||"addons"===e.key&&l}function v(e){let t=u.findIndex(t=>t.key===e.key);return t<p?"done":t===p?"active":"pending"}function f(e){let t=v(e);if("select-venue"===e.key&&l&&"done"===t)return(0,eO.jsx)("span",{className:"ml-1 inline-flex h-5 w-5 items-center justify-center rounded-full text-[11px] font-bold text-white",style:{backgroundColor:"var(--vb-primary)"},children:(0,eO.jsx)(id.Iconfont,{type:"pisell2-check",style:{fontSize:12}})});if("addons"===e.key){let e=(i.cartItems||[]).filter(e=>!(null==e?void 0:e.start_date)||!(null==e?void 0:e.end_date)).length;return e<=0?null:(0,eO.jsxs)("span",{className:"ml-1 inline-flex min-w-[20px] items-center justify-center rounded-full bg-[#111111] px-1.5 text-[11px] font-bold text-white",children:["+",e]})}return null}let y=u.filter(e=>u.findIndex(t=>t.key===e.key)<p&&h(e));return(0,eO.jsxs)("div",{ref:c,className:"relative bg-white p-3 md:rounded-[24px] md:p-4",children:[(0,eO.jsx)(e_.Modal,{open:o,onCancel:()=>d(!1),title:String(eP.getText("pisell2.venue.leave.title")||"Leave booking?"),centered:!0,footer:(0,eO.jsxs)("div",{style:{display:"flex",gap:24},children:[(0,eO.jsx)("button",{type:"button",onClick:()=>d(!1),style:{flex:1,borderRadius:12,border:"none",background:"#f4f4f5",padding:"12px 0",fontSize:16,fontWeight:600,color:"#3f3f46",cursor:"pointer"},children:String(eP.getText("pisell2.venue.leave.stay")||"Stay")}),(0,eO.jsx)("button",{type:"button",onClick:()=>{d(!1),function(){if("u">typeof window){if(window.history.length>1)return window.history.back();window.location.href="/"}}()},style:{flex:1,borderRadius:12,border:"none",background:"var(--vb-primary, #ea1018)",padding:"12px 0",fontSize:16,fontWeight:700,color:"#fff",cursor:"pointer"},children:String(eP.getText("pisell2.venue.leave.confirm")||"Leave")})]}),children:(0,eO.jsx)("p",{className:"text-sm text-zinc-500",children:String(eP.getText("pisell2.venue.leave.desc")||"Your selections will be lost if you leave now.")})}),r&&y.length>0?(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsx)("div",{className:"fixed inset-0 z-40 md:hidden",onClick:()=>s(!1)}),(0,eO.jsx)("div",{className:"absolute left-4 right-4 top-full z-50 mt-2 overflow-hidden rounded-2xl bg-white shadow-[0_8px_30px_rgba(20,20,20,0.12)] ring-1 ring-black/[0.06] md:hidden",children:y.map((e,t)=>(0,eO.jsxs)("button",{type:"button",onClick:()=>{a(e.key),s(!1)},className:`flex w-full items-center gap-3 px-4 py-3 text-left transition hover:bg-zinc-50 active:bg-zinc-100 ${t>0?"border-t border-zinc-100":""}`,children:[(0,eO.jsxs)("div",{className:"flex h-8 min-w-[62px] shrink-0 items-center justify-center rounded-full bg-zinc-100 px-2.5 text-xs font-bold text-zinc-700",children:[e.n,"/",u.length]}),(0,eO.jsxs)("div",{className:"flex items-center text-sm font-semibold text-zinc-800",children:[(0,eO.jsx)("span",{children:eP.getText(e.titleKey)||"-"}),f(e)]})]},e.key))})]}):null,(0,eO.jsxs)("div",{className:"flex items-center gap-3",children:[g?null:(0,eO.jsx)("button",{type:"button","aria-label":"Back",onClick:function(){g?d(!0):n()},className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-zinc-50 text-zinc-700 transition hover:bg-zinc-100",children:(0,eO.jsx)("svg",{viewBox:"0 0 24 24",className:"h-5 w-5",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,eO.jsx)("path",{d:"M15 18l-6-6 6-6"})})}),(0,eO.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eO.jsx)("div",{className:`md:hidden ${y.length>0?"cursor-pointer":""}`,onClick:()=>{y.length>0&&s(e=>!e)},children:(0,eO.jsxs)("div",{className:"flex items-center gap-3",children:[(0,eO.jsxs)("div",{className:"flex h-8 min-w-[62px] items-center justify-center rounded-full px-2.5 text-xs font-bold md:h-10 md:min-w-[74px] md:text-sm",style:{backgroundColor:"var(--vb-primary-light)",color:"var(--vb-primary)"},children:[p+1,"/",u.length]}),(0,eO.jsx)("div",{className:"min-w-0 flex-1 text-lg font-extrabold text-zinc-900 md:text-xl",children:eP.getText(m.titleKey)||"-"}),y.length>0?(0,eO.jsx)("svg",{viewBox:"0 0 24 24",className:`h-5 w-5 shrink-0 text-zinc-400 transition-transform ${r?"rotate-180":""}`,fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,eO.jsx)("path",{d:"M6 9l6 6 6-6",strokeLinecap:"round",strokeLinejoin:"round"})}):null]})}),(0,eO.jsx)("div",{className:"hidden items-center gap-3 md:flex",children:u.map((e,t)=>{let l=v(e),i=h(e);return(0,eO.jsxs)(ek().Fragment,{children:[(0,eO.jsxs)("button",{type:"button",onClick:()=>{i&&a(e.key)},className:`flex items-center gap-3 rounded-full px-3 py-2 transition ${"done"===l?"bg-zinc-50":"active"!==l?"bg-zinc-50/80":""} ${i?"cursor-pointer hover:bg-zinc-100":"cursor-default"}`,style:"active"===l?{backgroundColor:"var(--vb-primary-light)"}:void 0,children:[(0,eO.jsx)("div",{className:`flex h-8 w-8 items-center justify-center rounded-full text-sm font-bold ${"done"===l?"bg-[#111] text-white":"active"===l?"text-white":"bg-white text-zinc-400"}`,style:"active"===l?{backgroundColor:"var(--vb-primary)"}:void 0,children:"done"===l?(0,eO.jsx)(id.Iconfont,{type:"pisell2-check",style:{fontSize:15}}):e.n}),(0,eO.jsxs)("div",{className:`flex items-center text-sm font-semibold ${"active"===l?"text-zinc-900":"done"===l?"text-zinc-700":"text-zinc-400"}`,children:[(0,eO.jsx)("span",{children:eP.getText(e.titleKey)||"-"}),f(e)]})]}),t<u.length-1?(0,eO.jsx)("div",{className:"relative h-px flex-1 overflow-hidden rounded-full bg-zinc-200",children:(0,eO.jsx)("div",{className:`absolute left-0 top-0 h-full ${"done"===l?"w-full bg-[#111]":"active"===l?"w-1/2":"w-0"}`,style:"active"===l?{backgroundColor:"var(--vb-primary)"}:void 0})}):null]},e.n)})})]}),(0,eO.jsx)("button",{type:"button","aria-label":"Close",onClick:d.bind(null,!0),className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-zinc-50 text-zinc-700 transition hover:bg-zinc-100",children:(0,eO.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-5 w-5",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,eO.jsx)("path",{d:"M18 6 6 18"}),(0,eO.jsx)("path",{d:"M6 6l12 12"})]})})]})]})}function eYA(){let{isLogin:e,openLoginModal:t,handleLoginSuccess:l,discountList:i,runModuleAction:a,refreshViewModel:n,venueBookingModule:r}=eYT(),[s,o]=(0,ex.useState)(!0),[d,c]=(0,ex.useState)(""),u=(0,ex.useMemo)(()=>(i||[]).filter(e=>!!e.isAvailable).map(e=>({...e,isDisabled:e.isDisabled||e.isDisabledForProductUsed})),[i]),p=(0,ex.useCallback)(async()=>{await n()},[n]),m=(0,ex.useCallback)(async()=>{if(d.trim())try{var e;let t=null==r||null==(e=r.getTempOrder)?void 0:e.call(r),l=(null==t?void 0:t.customer_id)||void 0,i=await a("scanCode",d,l);if(null==i?void 0:i.isAvailable)c(""),await p();else{let e={time_limit:eP.getText("pisell2.text.goodpass.code-invalid-expired")};e_.message.error({content:String((null==i?void 0:i.type)==="server"?eP.getText("pisell2.text.goodpass.code-invalid"):e[null==i?void 0:i.unavailableReason]||eP.getText("pisell2.text.goodpass.code-invalid-cart"))})}}catch(e){console.warn("[venueBooking] scanCode failed",e),e_.message.error({content:String(eP.getText("pisell2.text.goodpass.code-invalid")||"兑换码无效")})}},[d,r,a,p]),g=(0,ex.useCallback)(async e=>{try{await a("setDiscountSelected",{discountId:e.id,isSelected:e.isSelected}),await p()}catch(e){console.warn("[venueBooking] setDiscountSelected failed",e)}},[a,p]),h=(0,ex.useCallback)(e=>[...e].sort((e,t)=>Number(null==t?void 0:t.isSelected)-Number(null==e?void 0:e.isSelected)),[]);return(0,eO.jsxs)("div",{className:"pisell-lowcode__appointment-booking-voucher-container",children:[(0,eO.jsxs)("div",{className:"voucher-title",children:[(0,eO.jsx)("span",{className:"voucher-title-left",children:eP.getText("pisell2.text.goodpass")}),(0,eO.jsxs)("span",{className:"voucher-title-right",onClick:()=>o(!s),children:[eP.getText("pisell2.text.details")," ",(0,eO.jsx)(H9,{className:t8()("voucher-right-icon",{show:s})})]})]}),(0,eO.jsxs)("div",{className:t8()("voucher-detail",{show:s}),children:[u.length>0?(0,eO.jsx)(id.PisellGoodPassCard,{style:{width:"100%"},dataSource:u,mixedSort:h,onChange:g}):null,e?null:(0,eO.jsxs)("div",{className:"login-card",children:[(0,eO.jsx)(emR,{style:{fontSize:28}}),(0,eO.jsxs)("div",{className:"text-wrapper",style:{maxWidth:"none"},children:[(0,eO.jsx)(id.PisellText,{className:"login-btn",onClick:()=>{t({callback:e=>{"success"===e&&l().then(()=>{p()})}})},children:eP.getText("pisell2.text.goodpass.login")})," ",(0,eO.jsx)("span",{children:eP.getText("pisell2.text.goodpass.login-tip")})]})]}),(0,eO.jsxs)("div",{className:"voucher-code-input-wrapper",children:[(0,eO.jsxs)("div",{className:"voucher-code-input",children:[(0,eO.jsxs)("div",{style:{whiteSpace:"nowrap"},children:[eP.getText("pisell2.text.goodpass.code"),":"]}),(0,eO.jsx)(id.PisellInput,{value:d,allowClear:!0,onChange:e=>{var t;return c((null==(t=e.target)?void 0:t.value)||"")},size:"small",placeholder:eP.getText("pisell2.text.goodpass.enter-code")})]}),(0,eO.jsx)(e_.Button,{size:"small",onClick:m,disabled:!d.trim(),children:eP.getText("pisell2.text.apply")})]})]})]})}function eYI(e){let{deposit:t,isAgreePolicy:l,onChange:i,getProtocol:a}=e;if(!(null==t?void 0:t.hasDeposit))return null;let n=(null==t?void 0:t.deposit_policy_data)||[];return(0,eO.jsx)(em_,{total:null==t?void 0:t.total,protocols:n,isAgreePolicy:l,isShowTitle:!1,onChange:i,depositProtocolRequest:e=>a(e)})}function eYD(e){var t,l,i,a,n,r,s,o,d,c,u;let{open:p,onCancel:m,onNext:g,items:h,summary:v,embedded:f=!1,confirmLoading:y=!1,extraContent:b}=e,{currentStep:x,runModuleAction:k,refreshViewModel:_,refreshTimeSlotGrid:w,venueBookingModule:j,isAgreeDepositPolicy:S,setIsAgreeDepositPolicy:N,isLoading:M,isLogin:C}=eYT(),T=eI(),P=null==T||null==(l=T.appHelper)||null==(t=l.utils)?void 0:t.businessUtils,A=String((null==T||null==(n=T.appHelper)||null==(a=n.utils)||null==(i=a.getSymbolic)?void 0:i.call(a))||"$"),I=(null==T||null==(s=T.engine)||null==(r=s.props)?void 0:r.locale)||"en",[D,E]=(0,ex.useState)({}),{pisellos:z,translation:O}=(null==T||null==(o=T.appHelper)?void 0:o.utils)||{},L=!!(null==P||null==(d=P.getAppByModal)?void 0:d.call(P,"goodpass")),$=!!(null==P||null==(c=P.getAppByModal)?void 0:c.call(P,"discountcard"));(0,ex.useEffect)(()=>{var e;let t=e=>{(null==e?void 0:e.path)==="holderMap"&&E(null==e?void 0:e.value)};return null==z||null==(e=z.effects)||e.on("venueBooking_holder:changed",t),()=>{var e;null==z||null==(e=z.effects)||e.off("venueBooking_holder:changed",t)}},[z]),(0,ex.useEffect)(()=>{if(!M&&j)try{var e;let t=(null==(e=j.getHolderFormMap)?void 0:e.call(j))||{};E(t)}catch(e){console.warn("[venueBooking] Holder data is not ready",e),E({})}},[j,M]);let R=f||p,F=(null==v?void 0:v.total_amount)??(null==v?void 0:v.expect_amount)??(null==v?void 0:v.amount)??(null==v?void 0:v.total)??"0.00",B=(0,ex.useMemo)(()=>(h||[]).map(e=>{var t,l,i;let a=egA(e),n=epE(a)?null==D?void 0:D[null==a?void 0:a.resource_id]:{},r=egT({item:e,holderConfig:a,formData:n,translation:O,enabled:!!(null==e||null==(l=e._origin)||null==(t=l.product)?void 0:t.bookingUuid),utils:null==T||null==(i=T.appHelper)?void 0:i.utils});return{...e,symbol:(null==e?void 0:e.symbol)||A,is_hide_like:!0,allowClearHolder:!0,...r}}),[h,A,D,O]),q="checkout"===x?String(eP.getText("pisell2.venue.action.pay.now")||"立即支付"):String(eP.getText("pisell2.venue.action.next")||"下一步"),H=(0,ex.useMemo)(()=>{var e,t,l;let i=Number((null==v?void 0:v.product_amount)??0),a=Number((null==v?void 0:v.tax_fee)??0),n=Number((null==v?void 0:v.total_amount)??(null==v?void 0:v.expect_amount)??0),r=!!(null==v||null==(e=v.deposit)?void 0:e.hasDeposit),s=null==j||null==(t=j.getTempOrder)?void 0:t.call(j),o=(null==s?void 0:s.summary)||{},d=String((null==o?void 0:o.tax_title)||(null==v?void 0:v.tax_title)||"GST/Tax"),c=Number(null==o?void 0:o.tax_rate),u=Number.isNaN(c)?0:c>1?c/100:c,p=!!((null==o?void 0:o.is_price_include_tax)??(null==o?void 0:o.isPriceIncludeTax)),m=((null==v?void 0:v.surcharges)||[]).filter(e=>Number(null==e?void 0:e.amount)>0).map(e=>{let t=(null==e?void 0:e.label)||(null==e?void 0:e.name)||{},l=t[I]||t.en||t.original||(null==e?void 0:e.key)||"";return{key:(null==e?void 0:e.key)||`surcharge_${null==e?void 0:e.surcharge_id}`,label:l,value:Number(null==e?void 0:e.amount)}});return[{key:"deposit",value:Number((null==v||null==(l=v.deposit)?void 0:l.total)??0),label:eP.getText("pisell2.appointment.deposit")||"Deposit",hidden:!r},{key:"sub_total",value:Number.isNaN(i)?0:i},...m,{key:"tax",value:Number.isNaN(a)?0:a,hidden:!!Number.isNaN(a)||a<=0,tax:{title:d,rate:u,is_price_include_tax:p}},{key:"custom_total",value:Number.isNaN(n)?0:n,label:eP.getText("pisell2.event.total")||"合计",bold:!r}]},[v,I,j]),V=async(e,t,l)=>{var i,a,n,r,s;if("add_holder"===t){let t=egA(e);if(!epE(t))return;let l=null==t?void 0:t.resource_id;if(!l)return;let a=egI(D,l);return epH({form_id:a||l,title:eP.getText("pisell2.venue.create.form"),utils:null==T||null==(i=T.appHelper)?void 0:i.utils,callback:async t=>{if((null==t?void 0:t.status)==="success"){var i,n,r,s;let{formRecordId:o,formId:d}=egD({res:t,formId:l,skuRelationFormId:a,utils:null==T||null==(i=T.appHelper)?void 0:i.utils,module:j}),c=epB(null==T||null==(n=T.appHelper)?void 0:n.utils);j.setBookingHolder(null==e||null==(s=e._origin)||null==(r=s.product)?void 0:r.bookingUuid,{customer_id:null==c?void 0:c.id,form_id:d,form_record:[o]}),await _()}}})}if("change_holder"===t){let t=epB(null==T||null==(a=T.appHelper)?void 0:a.utils),i=(null==l?void 0:l._origin)||l,s=l?{customer_id:null==t?void 0:t.id,form_id:null==i?void 0:i.form_id,form_record:[null==i?void 0:i.form_record_id]}:null;j.setBookingHolder(null==e||null==(r=e._origin)||null==(n=r.product)?void 0:n.bookingUuid,s),await _();return}if("delete"!==t)return;let o=l&&"object"==typeof l?l:e;if("select-venue"!==x&&o&&"object"==typeof o&&(null!=(s=o.metadata)&&s.venue_booking||null!=o&&o.start_date&&null!=o&&o.end_date))return void e_.message.warning({content:String(eP.getText("pisell2.venue.cart.delete.venue.only.step1")||"请返回第一步后再删除场地商品"),duration:2});let d=eYt(o);if(!d)return void console.error("[venueBooking] removeProductFromOrder skipped: missing product UID",{item:o});try{await k("removeProductFromOrder",d),w(),await _()}catch(e){console.error("[venueBooking] removeProductFromOrder failed",{error:e,item:o})}};if((0,ex.useEffect)(()=>{R&&_()},[R]),!R)return null;let Y=(0,eO.jsx)("div",{className:"pisell-venue-booking-cart-body",children:(0,eO.jsx)(LU,{productParams:{products:B,hideAddBtn:!0,disabledEdit:!1,isShowNote:!1,isShowDelete:!0,isShowPackageNote:!1,isShowChangeHolder:"checkout"!==x&&!!C,isShowHolder:!0,isShowAddHolderButton:!0},platform:"h5",emptyText:eP.getText("pisell2.venue.cart.empty"),isOpenGroup:!1,isHideClearCart:!0,onChange:V})}),U=(0,eO.jsxs)(eO.Fragment,{children:[L||$?(0,eO.jsx)(eYA,{}):null,(0,eO.jsx)(YI,{list:H,style:{padding:0},children:(null==v||null==(u=v.deposit)?void 0:u.hasDeposit)?(0,eO.jsx)(eYI,{deposit:v.deposit,isAgreePolicy:S,onChange:N,getProtocol:e=>{var t;return null==j||null==(t=j.getProtocol)?void 0:t.call(j,e)}}):null}),b?(0,eO.jsx)("div",{className:"pisell-venue-booking-cart-extra-content",children:b}):null]});return f?(0,eO.jsxs)(eO.Fragment,{children:[Y,(0,eO.jsxs)("div",{className:"pisell-venue-booking-cart-embedded-footer",children:[U,(0,eO.jsx)(id.Button,{type:"primary",block:!0,onClick:g,loading:y,children:q})]})]}):(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsx)("div",{className:"pisell-venue-booking-cart-mask",onClick:m}),(0,eO.jsxs)("div",{className:"pisell-venue-booking-cart-drawer",children:[(0,eO.jsx)("div",{className:"pisell-venue-booking-cart-header",onClick:m,children:(0,eO.jsx)("span",{className:"pisell-venue-booking-cart-handle","aria-hidden":!0})}),Y,(0,eO.jsx)("div",{className:"pisell-venue-booking-cart-drawer-summary",children:U}),(0,eO.jsxs)("div",{className:"pisell-venue-booking-cart-footer",children:[(0,eO.jsxs)("div",{className:"pisell-venue-booking-cart-total",children:[(0,eO.jsx)("div",{className:"pisell-venue-booking-cart-total-label",children:eP.getText("pisell2.event.total")||"合计"}),(0,eO.jsxs)("div",{className:"pisell-venue-booking-cart-total-amount",children:[A,Number(F||0).toFixed(2)]})]}),(0,eO.jsx)(id.Button,{type:"primary",onClick:g,loading:y,children:"checkout"===x?q:eP.getText("pisell2.event.continue")||"继续"})]})]})]})}function eYE(){var e;let t=eYa(),{currentStep:l,viewModel:i,handlePrimaryAction:a,isSubmittingOrder:n}=eYT(),[r,s]=(0,ex.useState)(!1),o=(0,ex.useMemo)(()=>{var e,t,l,a,n,r;let s=Number((null==(e=i.summary)?void 0:e.total_amount)??(null==(t=i.summary)?void 0:t.expect_amount)??(null==(l=i.summary)?void 0:l.amount)??(null==(a=i.summary)?void 0:a.total)??(null==(n=i.summary)?void 0:n.totalAmount)??(null==(r=i.summary)?void 0:r.payable_amount)??0);return Number.isNaN(s)?"0.00":s.toFixed(2)},[i.summary]),d=(0,ex.useMemo)(()=>"checkout"===l?String(eP.getText("pisell2.venue.action.pay.now")||"立即支付"):String(eP.getText("pisell2.venue.action.next")||"下一步"),[l]);return(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsxs)("div",{className:"pisell-venue-booking-footer",children:[(0,eO.jsxs)("div",{className:"pisell-venue-booking-footer-left",children:[(0,eO.jsx)("div",{className:"pisell-venue-booking-footer-total-label",children:eP.getText("pisell2.event.total")||"合计"}),(0,eO.jsxs)("div",{className:"pisell-venue-booking-footer-total-amount",children:[t,o]})]}),(0,eO.jsxs)("div",{className:"pisell-venue-booking-footer-right",children:[(0,eO.jsx)(id.Badge,{count:(null==(e=i.cartItems)?void 0:e.length)||0,id:"venue-booking-cart-btn",children:(0,eO.jsx)(id.Button,{size:"large",className:"pisell-venue-booking-footer-cart-btn",onClick:()=>s(!0),children:(0,eO.jsx)(id.Image,{src:egO,preview:!1})})}),(0,eO.jsx)(id.Button,{type:"primary",size:"large",className:"pisell-venue-booking-footer-btn",onClick:a,loading:n,children:d})]})]}),(0,eO.jsx)(eYD,{open:r,items:i.cartItems||[],summary:i.summary||{},onCancel:()=>s(!1),onNext:()=>{s(!1),a()},confirmLoading:n})]})}function eYz(){let{monthCursor:e,setMonthCursor:t,anchorDate:l,setAnchorDate:i,setMonthPickerOpen:a,fetchWeekData:n,viewModel:r}=eYT(),s=function(e){let t=e.startOf("month"),l=e.daysInMonth(),i=t.day(),a=0===i?6:i-1,n=[];for(let e=0;e<a;e++)n.push(null);for(let e=1;e<=l;e++)n.push(t.date(e));for(;n.length%7!=0;)n.push(null);return n}(e),o=eYv(l),d=eYv(ef()()),c=ef()().startOf("day"),u=(0,ex.useMemo)(()=>{let e=(r.dateSummary||[]).map(e=>ef()(String((null==e?void 0:e.date)||""))).filter(e=>e.isValid()).sort((e,t)=>e.valueOf()-t.valueOf());return e.length?{minDate:e[0].startOf("day"),maxDate:e[e.length-1].startOf("day")}:null},[r.dateSummary]);async function p(e){i(e),t(e.startOf("month")),a(!1);let l=eYf(e);await n(eYv(l[0]),eYv(l[l.length-1]))}return(0,eO.jsxs)("div",{className:"absolute right-0 top-[calc(100%+12px)] z-30 w-[320px] rounded-[24px] border border-black/[0.06] bg-white p-4 shadow-[0_20px_60px_rgba(20,20,20,0.14)]",children:[(0,eO.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,eO.jsx)("button",{className:"flex h-10 w-10 items-center justify-center rounded-2xl bg-[#fafafa] hover:bg-zinc-50",onClick:()=>t(e.subtract(1,"month")),children:(0,eO.jsx)(id.Iconfont,{type:"pisell2-chevron-left",style:{fontSize:16}})}),(0,eO.jsx)("div",{className:"text-sm font-bold text-zinc-900",children:eYy(e)}),(0,eO.jsx)("button",{className:"flex h-10 w-10 items-center justify-center rounded-2xl bg-[#fafafa] hover:bg-zinc-50",onClick:()=>t(e.add(1,"month")),children:(0,eO.jsx)(id.Iconfont,{type:"pisell2-chevron-right",style:{fontSize:16}})})]}),(0,eO.jsx)("div",{className:"mb-2 grid grid-cols-7 gap-2 px-1 text-center text-[11px] font-bold uppercase tracking-wide text-zinc-400",children:[eP.getText("pisell2.venue.calendar.weekday.short.mon")||"周一",eP.getText("pisell2.venue.calendar.weekday.short.tue")||"周二",eP.getText("pisell2.venue.calendar.weekday.short.wed")||"周三",eP.getText("pisell2.venue.calendar.weekday.short.thu")||"周四",eP.getText("pisell2.venue.calendar.weekday.short.fri")||"周五",eP.getText("pisell2.venue.calendar.weekday.short.sat")||"周六",eP.getText("pisell2.venue.calendar.weekday.short.sun")||"周日"].map(e=>(0,eO.jsx)("div",{children:e},e))}),(0,eO.jsx)("div",{className:"grid grid-cols-7 gap-2",children:s.map((e,t)=>{if(!e)return(0,eO.jsx)("div",{className:"h-11"},`empty-${t}`);let l=eYv(e),i=eYx(e,r.dateSummary),a=l===o,n=l===d,s=e.isBefore(c,"day"),m=!(!u||e.isBefore(u.minDate,"day")||e.isAfter(u.maxDate,"day"))&&i.soldOut,g=s||m,h=g?"bg-zinc-50 text-zinc-400":a?"text-white shadow-sm":n?"":"bg-[#fafafa] text-zinc-700",v=a&&!i.soldOut?{backgroundColor:"var(--vb-primary)"}:n&&!i.soldOut?{backgroundColor:"var(--vb-primary-light)",color:"var(--vb-primary)"}:void 0;return(0,eO.jsx)("button",{onClick:()=>{g||p(e)},disabled:g,className:`h-11 rounded-2xl text-sm font-semibold transition ${h}`,style:v,children:(0,eO.jsx)("span",{className:m?"line-through text-zinc-400":"",children:e.date()})},l)})})]})}function eYO(e){let{onPrevWeek:t,onNextWeek:l}=e,{anchorDate:i,monthPickerOpen:a,setMonthPickerOpen:n,goToNearestAvailableDate:r}=eYT(),s=ef()(),o=eYv(i)===eYv(s);async function d(){o||(n(!1),await r(s))}return(0,eO.jsxs)("div",{className:"relative flex w-full items-center gap-2 xl:w-auto",children:[(0,eO.jsx)("button",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-[#fafafa] md:h-12 md:w-12",onClick:t,children:(0,eO.jsx)(id.Iconfont,{type:"pisell2-chevron-left",style:{fontSize:18}})}),(0,eO.jsx)("button",{className:"min-w-0 flex-1 rounded-2xl bg-[#fafafa] px-4 py-3 text-sm font-bold text-zinc-900 xl:min-w-[200px] xl:flex-none",onClick:()=>n(!a),children:eYy(i)}),(0,eO.jsx)("button",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-[#fafafa] md:h-12 md:w-12",onClick:l,children:(0,eO.jsx)(id.Iconfont,{type:"pisell2-chevron-right",style:{fontSize:18}})}),(0,eO.jsx)("button",{className:`rounded-2xl px-4 py-3 text-sm font-bold shadow-sm ${o?"bg-zinc-200 text-zinc-500 cursor-not-allowed":"text-white"}`,style:o?void 0:{backgroundColor:"var(--vb-primary)"},onClick:d,disabled:o,children:eP.getText("pisell2.venue.action.go.today")||"回到今天"}),a?(0,eO.jsx)(eYz,{}):null]})}function eYL(e){let{onPrevWeek:t,onNextWeek:l}=e,i=eYa(),{anchorDate:a,setAnchorDate:n,setMonthCursor:r,viewModel:s,venueBookingModule:o,isWeekLoading:d}=eYT(),c=eYf(a),u=eYv(a),p=(0,ex.useMemo)(()=>(function(e){let t=new Set;if(!e||"function"!=typeof e.getAllSelectedSlots)return t;let l=e.getAllSelectedSlots();return l&&(l instanceof Map?l.forEach(e=>{Array.isArray(e)&&e.forEach(e=>eYg(t,e))}):Array.isArray(l)&&l.forEach(e=>{Array.isArray(e)?e.forEach(e=>eYg(t,e)):Array.isArray(null==e?void 0:e.slots)?e.slots.forEach(e=>eYg(t,e)):eYg(t,e)})),t})(o),[o,s.cartItems]),m=c.some(e=>{let t=eYx(e,s.dateSummary,i);return!t.soldOut&&t.fewLeft}),g="u">typeof window&&window.innerWidth<920,h=(0,ex.useRef)({startX:0,startY:0,active:!1,moved:!1});return d?(0,eO.jsx)("div",{className:"grid grid-cols-7 gap-1 select-none","aria-busy":"true","aria-live":"polite",children:Array.from({length:7}).map((e,t)=>(0,eO.jsxs)("div",{className:"relative min-h-[56px] overflow-hidden rounded-[12px] bg-zinc-100 px-2 py-2 md:min-h-[60px] md:rounded-[16px] md:px-3 md:py-2",children:[(0,eO.jsx)("div",{className:"h-2 w-8 rounded bg-zinc-200/90 md:h-2.5 md:w-10"}),(0,eO.jsxs)("div",{className:"mt-2 flex items-end justify-between gap-1",children:[(0,eO.jsx)("div",{className:"h-3 w-5 rounded bg-zinc-200/90 md:h-4 md:w-6"}),(0,eO.jsx)("div",{className:"h-2 w-8 rounded bg-zinc-200/90 md:h-2.5 md:w-10"})]}),(0,eO.jsx)("span",{className:"vb-skeleton-shimmer","aria-hidden":"true"})]},`day-skeleton-${t}`))}):(0,eO.jsx)("div",{className:"grid grid-cols-7 gap-1 touch-pan-y select-none",onPointerDown:function(e){("mouse"!==e.pointerType||0===e.button)&&(h.current={startX:e.clientX,startY:e.clientY,active:!0,moved:!1})},onPointerMove:function(e){if(!h.current.active)return;let t=e.clientX-h.current.startX,l=e.clientY-h.current.startY;(Math.abs(t)>8||Math.abs(l)>8)&&(h.current.moved=!0)},onPointerUp:function(e){if(!h.current.active)return;let i=e.clientX-h.current.startX,a=e.clientY-h.current.startY;h.current.active=!1,48>Math.abs(i)||Math.abs(i)<=Math.abs(a)||(i<0?l():t())},onPointerCancel:()=>{h.current.active=!1,h.current.moved=!1},children:c.map(e=>{let t,l=eYv(e),a=l===u,o=eYx(e,s.dateSummary,i),d=p.has(l)&&!a,c=o.soldOut?"bg-zinc-50 text-zinc-400":a?"text-white shadow-sm":"bg-white text-zinc-800 hover:bg-zinc-50",v=!o.soldOut&&a?{backgroundColor:"var(--vb-primary)"}:void 0,f=a?"bg-white/15 text-white ring-white/20":"Promo"===o.topTag?"bg-emerald-50 text-emerald-700 ring-emerald-200":"bg-zinc-100 text-zinc-600 ring-zinc-200";return(0,eO.jsxs)("button",{type:"button",onClick:()=>(function(e){if(h.current.moved){h.current.moved=!1;return}n(e),r(e.startOf("month"))})(e),className:`relative min-w-0 cursor-pointer rounded-[12px] px-2 py-2 text-left transition md:rounded-[16px] md:px-3 md:py-2 ${m?"min-h-[66px] pb-5 md:min-h-[72px] md:pb-6":"min-h-[56px] md:min-h-[60px]"} ${c}`,style:v,children:[o.topTag&&!g?(0,eO.jsx)("div",{className:`pointer-events-none absolute right-1 top-1 inline-flex rounded-full px-1.5 py-0.5 text-[8px] font-semibold ring-1 md:right-2 md:top-2 md:text-[10px] ${f}`,children:o.topTag}):null,(0,eO.jsxs)("div",{className:`pointer-events-none inline-flex max-w-full items-center gap-1 truncate text-[8px] leading-none md:text-xs ${o.soldOut?"text-zinc-400":a?"text-white/85":"text-zinc-500"}`,children:[(0,eO.jsx)("span",{className:"truncate",children:1===(t=e.day())?String(eP.getText("pisell2.venue.calendar.weekday.short.mon")||"周一"):2===t?String(eP.getText("pisell2.venue.calendar.weekday.short.tue")||"周二"):3===t?String(eP.getText("pisell2.venue.calendar.weekday.short.wed")||"周三"):4===t?String(eP.getText("pisell2.venue.calendar.weekday.short.thu")||"周四"):5===t?String(eP.getText("pisell2.venue.calendar.weekday.short.fri")||"周五"):6===t?String(eP.getText("pisell2.venue.calendar.weekday.short.sat")||"周六"):String(eP.getText("pisell2.venue.calendar.weekday.short.sun")||"周日")}),d?(0,eO.jsx)(id.Iconfont,{type:"pisell2-check-circle",style:{fontSize:13,color:"var(--vb-primary, #ea1018)"}}):null]}),(0,eO.jsxs)("div",{className:"pointer-events-none mt-1 flex w-full flex-wrap items-end justify-between gap-x-1",children:[(0,eO.jsx)("div",{className:`text-[13px] font-bold leading-none md:text-base ${o.soldOut?"line-through":""}`,children:e.date()}),(0,eO.jsx)("div",{className:`text-[8px] font-semibold leading-tight md:text-[10px] lg:text-xs ${a?"text-white/70":"text-zinc-400"}`,children:o.soldOut?eP.getText("pisell2.venue.label.sold.out")||"已满":o.startingPrice??""})]}),m?(0,eO.jsx)("div",{className:`pointer-events-none absolute bottom-2 left-2 text-[10px] font-bold leading-none md:bottom-2 md:left-3 md:text-[11px] ${o.fewLeft&&!o.soldOut?a?"text-white":"":"opacity-0"}`,style:!o.fewLeft||o.soldOut||a?void 0:{color:"var(--vb-primary)"},children:eP.getText("pisell2.venue.label.few.left")||"即将满"}):null]},l)})})}function eY$(){let{search:e,setSearch:t,filter:l,setFilter:i,viewModel:a}=eYT(),n=(0,ex.useMemo)(()=>{var e;return Array.from(new Set(((null==(e=a.timeSlotGrid)?void 0:e.resources)||[]).map(e=>e.productTitle)))},[a.timeSlotGrid]),r=[{label:eP.getText("pisell2.venue.filter.all")||"全部",value:"ALL"},...n.map(e=>({label:e,value:e}))];return(0,eO.jsx)("div",{className:"mt-4 grid gap-3 md:mt-5 xl:grid-cols-[1fr_auto] xl:items-center",children:n.length>1?(0,eO.jsx)("div",{className:"flex flex-wrap gap-2",children:r.map(e=>(0,eO.jsx)("button",{onClick:()=>i(e.value),className:`rounded-full px-4 py-2 text-sm font-semibold transition ${l===e.value?"text-white":"bg-[#fafafa] text-zinc-700"}`,style:l===e.value?{backgroundColor:"var(--vb-primary)"}:void 0,children:e.label},e.value))}):null})}function eYR(){let e=eYa(),{viewModel:t,venueBookingModule:l,toggleSlot:i,filter:a,search:n,isGridLoading:r}=eYT(),s=t.timeSlotGrid,o=(null==s?void 0:s.timeLabels)||[],d=(null==s?void 0:s.resources)||[],c=!r&&!!s&&o.length>0,u=(0,ex.useMemo)(()=>o.filter(e=>e.endsWith(":00")),[o]),p=(0,ex.useMemo)(()=>{var e;return e=o.length,{gridTemplateColumns:`120px repeat(${e}, minmax(70px, 1fr))`,minWidth:`${120+70*e}px`,width:"100%"}},[o.length]),m=(0,ex.useMemo)(()=>!("u"<typeof navigator)&&rm(),[]),g=(0,ex.useMemo)(()=>m?{overscrollBehavior:"none"}:{overscrollBehaviorX:"none",overscrollBehaviorY:"auto"},[m]),h=(0,ex.useMemo)(()=>d.filter(e=>{let t="ALL"===a||e.productTitle===a,l=!n||e.resourceName.toLowerCase().includes(n.toLowerCase());return t&&l}),[a,n,d]),v=(0,ex.useRef)(null),f=(0,ex.useRef)(null),y=(0,ex.useRef)(null),b=(0,ex.useRef)({isDragging:!1,pointerId:null,startX:0,startY:0,startScrollLeft:0,moved:!1}),x=(0,ex.useCallback)(e=>{f.current&&(f.current.style.transform=`translateX(${-e}px)`),y.current&&(y.current.style.transform=`translateX(${e}px)`)},[]);(0,ex.useEffect)(()=>{if(r)return;let e=v.current;if(!e||!o.length||!s)return;let t=function(e){if(!e)return 0;for(let t=0;t<e.timeLabels.length;t++)if(e.resources.some(e=>e.slots[t]&&"available"===e.slots[t].status))return t;return 0}(s);if(t<=0)return void x(e.scrollLeft);let l=Math.max(0,e.scrollWidth-120),i=Math.max(0,Math.max(0,t-1)*(o.length?l/o.length:0));e.scrollTo({left:i,behavior:"smooth"}),x(i)},[null==s?void 0:s.date,o.length,r,x]),(0,ex.useEffect)(()=>{if(!c)return;let e=v.current;if(e)return e.addEventListener("pointerdown",t),e.addEventListener("pointermove",l,{passive:!1}),e.addEventListener("pointerup",i),e.addEventListener("pointercancel",i),()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("pointermove",l),e.removeEventListener("pointerup",i),e.removeEventListener("pointercancel",i),b.current.isDragging=!1,b.current.pointerId=null,b.current.moved=!1};function t(t){if("mouse"!==t.pointerType){b.current.isDragging=!1,b.current.pointerId=null,b.current.moved=!1;return}0!==t.button||t.target instanceof Element&&t.target.closest('[data-cart-button="true"], input, textarea')||(b.current={isDragging:!0,pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startScrollLeft:e.scrollLeft,moved:!1})}function l(t){if("mouse"!==t.pointerType)return;let l=b.current;if(!l.isDragging||l.pointerId!==t.pointerId)return;let i=t.clientX-l.startX,a=t.clientY-l.startY;if(Math.abs(i)>6||Math.abs(a)>6){var n,r;l.moved=!0,(null==(n=e.hasPointerCapture)?void 0:n.call(e,t.pointerId))||null==(r=e.setPointerCapture)||r.call(e,t.pointerId)}Math.abs(i)>=Math.abs(a)&&(t.preventDefault(),e.scrollLeft=l.startScrollLeft-i,x(e.scrollLeft))}function i(t){var l;b.current.pointerId===t.pointerId&&(b.current.isDragging=!1,b.current.pointerId=null,null==(l=e.releasePointerCapture)||l.call(e,t.pointerId))}},[x,c]),(0,ex.useEffect)(()=>{let e=v.current;if(e)return e.addEventListener("wheel",t,{passive:!1}),()=>e.removeEventListener("wheel",t);function t(e){Math.abs(e.deltaY)>Math.abs(e.deltaX)&&(e.preventDefault(),window.scrollBy({top:e.deltaY,behavior:"instant"}))}},[]);let[k,_]=(0,ex.useState)({}),w=(0,ex.useCallback)(e=>{_(t=>({...t,[String(e)]:!t[String(e)]}))},[]);function j(e,t,l){if(b.current.moved){b.current.moved=!1;return}"available"===l.status&&i(e,t,l)}return c?(0,eO.jsxs)("div",{className:"relative",children:[(0,eO.jsx)("div",{className:"sticky z-30 overflow-hidden rounded-t-[28px] bg-[#fff7f7]",style:{top:"var(--vb-grid-sticky-top, 0px)"},children:(0,eO.jsxs)("div",{ref:f,className:"grid border-b border-black/[0.06]",style:{...p,willChange:"transform"},children:[(0,eO.jsxs)("div",{ref:y,className:"relative z-20 row-span-2 flex items-center gap-2 border-r border-black/[0.06] bg-[#fff7f7] px-2 py-4 font-bold text-zinc-900 shadow-[10px_0_16px_-14px_rgba(0,0,0,0.2)] md:px-4",style:{willChange:"transform"},children:[(0,eO.jsx)(id.Iconfont,{type:"pisell2-clock",style:{fontSize:16,color:"var(--vb-primary, #ea1018)"}}),(0,eO.jsx)("span",{children:eP.getText("pisell2.venue.label.courts")||"场地"})]}),u.map((e,t)=>{let l=o.indexOf(e),i=l+1,a=eYk(d,l),n=i<o.length?eYk(d,i):a,r=a.soldOut&&n.soldOut;return(0,eO.jsx)("div",{className:`col-span-2 px-1 py-3 text-center text-[12px] font-bold md:text-sm ${r?"bg-zinc-100 text-zinc-400":"text-zinc-700"}`,style:{borderLeft:"1px solid rgba(0,0,0,0.08)"},children:function(e){let[t]=e.split(":").map(Number),l=t>=12?eP.getText("pisell2.venue.time.pm")||"pm":eP.getText("pisell2.venue.time.am")||"am";return(eP.getText("pisell2.venue.time.hour.format")||"{hour}{suffix}").replace("{hour}",String(t%12==0?12:t%12)).replace("{suffix}",l)}(e)},e)}),o.map((e,t)=>{let l=eYk(d,t);return(0,eO.jsxs)("div",{className:`px-1 py-1.5 text-center ${l.soldOut?"bg-zinc-100 text-zinc-400":"bg-white/55"}`,style:{borderTop:"1px solid rgba(0,0,0,0.04)",borderLeft:eYb(e)?"1px solid rgba(0,0,0,0.08)":"1px solid rgba(0,0,0,0.03)"},children:[null,l.soldOut?(0,eO.jsx)("div",{className:"mt-1 text-[10px] font-bold text-zinc-400",children:eP.getText("pisell2.venue.label.sold.out")||"已满"}):null,!l.soldOut&&l.fewLeft?(0,eO.jsx)("div",{className:"mt-1 text-[10px] font-bold",style:{color:"var(--vb-primary)"},children:eP.getText("pisell2.venue.label.few.left")||"即将满"}):null,l.soldOut||l.fewLeft?null:(0,eO.jsx)("div",{className:"mt-1 text-[10px] font-bold text-zinc-500",children:eP.getText("pisell2.venue.label.bookable")||"充足"})]},`${e}-tag`)})]},`${s.date}-header`)}),(0,eO.jsx)("div",{ref:v,onScroll:function(e){x(e.currentTarget.scrollLeft)},className:"max-w-full overflow-x-auto rounded-b-[28px] cursor-grab select-none active:cursor-grabbing",style:{touchAction:"auto",WebkitOverflowScrolling:"touch",...g},children:(0,eO.jsx)("div",{className:"w-full",children:h.map(t=>{let i,a,n=(i=t.slots.length,{soldOut:0===(a=t.slots.filter(e=>"available"===e.status).length),fewLeft:a>0&&(i>0?a/i:0)<.2}),r=!!t.hasMultipleProducts&&Array.isArray(t.products),d=!!k[String(t.resourceId)];return(0,eO.jsxs)(ek().Fragment,{children:[(0,eO.jsxs)("div",{className:"grid border-b border-black/[0.06]",style:p,children:[(0,eO.jsx)("div",{className:`sticky left-0 z-10 border-r border-black/[0.06] px-2 py-2 shadow-[10px_0_16px_-14px_rgba(0,0,0,0.2)] md:px-4 ${n.soldOut?"bg-zinc-50":"bg-white"}`,children:(0,eO.jsx)("div",{className:"flex items-start justify-between gap-2",children:(0,eO.jsxs)("div",{className:"flex items-center gap-1.5",children:[r?(0,eO.jsx)("button",{type:"button","data-cart-button":"true",onClick:e=>{e.stopPropagation(),w(t.resourceId)},className:"flex h-5 w-5 items-center justify-center rounded text-zinc-500 hover:bg-black/5","aria-label":d?"collapse":"expand",children:(0,eO.jsx)(id.Iconfont,{type:d?"pisell2-chevron-down":"pisell2-chevron-right",style:{fontSize:12}})}):null,(0,eO.jsx)("div",{className:`text-[13px] font-extrabold leading-5 md:text-[15px] ${n.soldOut?"text-zinc-400":"text-zinc-900"}`,children:t.resourceName})]})})}),t.slots.map((i,a)=>{let n="available"===i.status,s="occupied"===i.status||"past"===i.status||"unavailable"===i.status,d=o[a]||"",c=eY_(i),u=eYw({...c,courtType:t.productTitle}),p=c.highlight||"Promo"===c.label?{text:"pisell2.venue.label.promo",className:"bg-emerald-50 text-emerald-700 ring-emerald-200"}:"Off-Peak"===c.label?{text:"pisell2.venue.label.off.peak",className:"bg-zinc-100 text-zinc-600 ring-zinc-200"}:null,m=(null==p?void 0:p.text)==="pisell2.venue.label.promo"?eP.getText("pisell2.venue.label.promo")||"促销":(null==p?void 0:p.text)==="pisell2.venue.label.off.peak"?eP.getText("pisell2.venue.label.off.peak")||"非高峰":null,g=t.productId,h=!r&&!s&&eYm(l,{resourceId:t.resourceId,productId:g,startTime:i.startTime}),v=s||h,f=!r&&n&&eYp(l,t.resourceId,i.startTime,g),y=!r&&!v,b=r&&!v;return(0,eO.jsx)("button",{"data-slot-button":"true",onClick:()=>{if(r){if(v)return;w(t.resourceId);return}v||j(t.resourceId,g,i)},disabled:v,className:`px-1 py-2 text-center transition md:px-2 ${v?"cursor-not-allowed bg-zinc-100 text-zinc-400":f?"text-white":"bg-white hover:bg-[#fff6f6]"}`,style:{borderLeft:eYb(d)?"1px solid rgba(0,0,0,0.08)":"1px solid rgba(0,0,0,0.03)",borderBottom:"1px solid rgba(0,0,0,0.04)",...f&&y?{backgroundColor:"var(--vb-primary)"}:null},children:v?(0,eO.jsx)("div",{className:"flex flex-col items-center justify-center gap-1 text-zinc-400",children:(0,eO.jsx)("div",{className:"text-lg font-bold leading-none",children:"\xd7"})}):f?(0,eO.jsx)("div",{className:"space-y-0.5",children:(0,eO.jsx)(id.PisellText.Amount,{value:Number(i.price||0),symbol:e,precision:2,showCurrencySymbol:!0,className:"text-[13px] font-extrabold leading-4 text-white md:text-sm"})}):(0,eO.jsxs)("div",{className:"space-y-0.5",children:[(0,eO.jsxs)("div",{className:"flex items-baseline justify-center gap-0.5",children:[(0,eO.jsx)(id.PisellText.Amount,{value:Number(i.price||0),symbol:e,precision:2,showCurrencySymbol:!0,hideDecimalForWholeNumbers:!0,className:`text-[13px] font-normal leading-4 ${u} md:text-sm`}),b?(0,eO.jsx)("span",{className:`text-[13px] font-semibold leading-4 ${u} md:text-sm`,children:"+"}):null]}),p?(0,eO.jsx)("div",{className:`inline-flex rounded-full px-1.5 py-0 text-[8px] font-semibold leading-4 ring-1 md:text-[9px] ${p.className}`,children:m}):null]})},`${t.resourceId}-outer-${i.startTime}`)})]}),r&&d&&t.products.map(i=>(0,eO.jsxs)("div",{className:"grid border-b border-black/[0.06] bg-zinc-50/60",style:p,children:[(0,eO.jsx)("div",{className:"sticky left-0 z-10 border-r border-black/[0.06] bg-zinc-50/60 px-2 py-2 pl-8 shadow-[10px_0_16px_-14px_rgba(0,0,0,0.2)] md:px-4 md:pl-10",children:(0,eO.jsx)("div",{className:"text-[12px] font-semibold leading-5 text-zinc-700 md:text-[13px]",children:i.productTitle})}),i.slots.map((a,n)=>{let r="available"===a.status,s="occupied"===a.status||"past"===a.status||"unavailable"===a.status,d=o[n]||"",c=!s&&eYm(l,{resourceId:t.resourceId,productId:i.productId,startTime:a.startTime}),u=s||c,p=r&&eYp(l,t.resourceId,a.startTime,i.productId),m=!u,g=eYw({...eY_(a),courtType:i.productTitle});return(0,eO.jsx)("button",{"data-slot-button":"true",onClick:()=>{m&&j(t.resourceId,i.productId,a)},disabled:!m,className:`px-1 py-2 text-center transition md:px-2 ${u?"cursor-not-allowed bg-zinc-100 text-zinc-400":p?"text-white":"bg-white hover:bg-[#fff6f6]"}`,style:{borderLeft:eYb(d)?"1px solid rgba(0,0,0,0.08)":"1px solid rgba(0,0,0,0.03)",borderBottom:"1px solid rgba(0,0,0,0.04)",...p&&m?{backgroundColor:"var(--vb-primary)"}:null},children:u?(0,eO.jsx)("div",{className:"flex flex-col items-center justify-center gap-1 text-zinc-400",children:(0,eO.jsx)("div",{className:"text-lg font-bold leading-none",children:"\xd7"})}):(0,eO.jsx)("div",{className:"space-y-0.5",children:(0,eO.jsx)(id.PisellText.Amount,{value:Number(a.price||0),symbol:e,precision:2,showCurrencySymbol:!0,hideDecimalForWholeNumbers:!0,className:`text-[13px] leading-4 ${p?"font-extrabold text-white":`font-normal ${g}`} md:text-sm`})})},`${t.resourceId}-${i.productId}-${a.startTime}`)})]},`${t.resourceId}-sub-${i.productId}`))]},`${t.resourceId}-${s.date}`)})},s.date)})]}):(0,eO.jsx)(eYF,{})}function eYF(){return(0,eO.jsxs)("div",{className:"relative","aria-busy":"true","aria-live":"polite",children:[(0,eO.jsx)("div",{className:"sticky z-30 overflow-hidden rounded-t-[28px] bg-[#fff7f7]",style:{top:"var(--vb-grid-sticky-top, 0px)"},children:(0,eO.jsxs)("div",{className:"grid border-b border-black/[0.06]",style:{gridTemplateColumns:"120px repeat(8, minmax(90px, 1fr))"},children:[(0,eO.jsxs)("div",{className:"relative z-20 flex items-center gap-2 border-r border-black/[0.06] bg-[#fff7f7] px-2 py-4 font-bold text-zinc-900 shadow-[10px_0_16px_-14px_rgba(0,0,0,0.2)] md:px-4",children:[(0,eO.jsx)(id.Iconfont,{type:"pisell2-clock",style:{fontSize:16,color:"var(--vb-primary, #ea1018)"}}),(0,eO.jsx)("span",{children:eP.getText("pisell2.venue.label.courts")||"场地"})]}),Array.from({length:8}).map((e,t)=>(0,eO.jsxs)("div",{className:"relative flex items-center justify-center overflow-hidden px-1 py-3",style:{borderLeft:"1px solid rgba(0,0,0,0.08)"},children:[(0,eO.jsx)("div",{className:"h-3 w-10 rounded bg-zinc-200/80"}),(0,eO.jsx)("span",{className:"vb-skeleton-shimmer","aria-hidden":"true"})]},`sk-h-${t}`))]})}),(0,eO.jsx)("div",{className:"w-full max-w-full overflow-hidden rounded-b-[28px]",children:Array.from({length:5}).map((e,t)=>(0,eO.jsxs)("div",{className:"grid border-b border-black/[0.06]",style:{gridTemplateColumns:"120px repeat(8, minmax(90px, 1fr))"},children:[(0,eO.jsx)("div",{className:"sticky left-0 z-10 border-r border-black/[0.06] bg-white px-2 py-4 shadow-[10px_0_16px_-14px_rgba(0,0,0,0.2)] md:px-4",children:(0,eO.jsxs)("div",{className:"relative overflow-hidden",children:[(0,eO.jsx)("div",{className:"h-4 w-20 rounded bg-zinc-200/80 md:w-24"}),(0,eO.jsx)("div",{className:"mt-2 h-2.5 w-14 rounded bg-zinc-200/60 md:w-16"}),(0,eO.jsx)("span",{className:"vb-skeleton-shimmer","aria-hidden":"true"})]})}),Array.from({length:8}).map((e,l)=>(0,eO.jsxs)("div",{className:"relative overflow-hidden px-1 py-3",style:{borderLeft:l%2==0?"1px solid rgba(0,0,0,0.08)":"1px solid rgba(0,0,0,0.03)",borderBottom:"1px solid rgba(0,0,0,0.04)",backgroundColor:"#fff"},children:[(0,eO.jsx)("div",{className:"mx-auto h-3 w-10 rounded bg-zinc-200/70 md:h-3.5 md:w-12"}),(0,eO.jsx)("span",{className:"vb-skeleton-shimmer","aria-hidden":"true"})]},`sk-cell-${t}-${l}`))]},`sk-row-${t}`))})]})}function eYB(){let{setAnchorDate:e,anchorDate:t,fetchWeekData:l}=eYT(),i=(0,ex.useRef)(null),a=(0,ex.useCallback)(async i=>{let a=t.add(i,"day");e(a);let n=eYf(a),r=eYv(n[0]),s=eYv(n[n.length-1]);await l(r,s)},[t,e,l]);function n(){a(-7)}function r(){a(7)}return(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsxs)("div",{className:"rounded-b-[24px] bg-white p-3 md:rounded-[28px] md:p-6",children:[(0,eO.jsxs)("div",{className:"flex flex-col gap-2 xl:flex-row xl:items-center xl:justify-between",children:[(0,eO.jsxs)("div",{children:[(0,eO.jsx)("h2",{className:"text-2xl font-extrabold leading-tight text-zinc-900 md:text-[30px]",children:eP.getText("pisell2.venue.step1.title")||"选择场地"}),(0,eO.jsx)("p",{className:"mt-1 text-xs leading-5 text-zinc-500 md:mt-2 md:text-sm md:leading-6",children:eP.getText("pisell2.venue.step1.subtitle")||"仅显示可用时段和价格。"})]}),(0,eO.jsx)(eYO,{onPrevWeek:n,onNextWeek:r})]}),(0,eO.jsx)("div",{className:"mt-3 md:mt-5",children:(0,eO.jsx)(eYL,{onPrevWeek:n,onNextWeek:r})}),(0,eO.jsx)(eY$,{})]}),(0,eO.jsx)("div",{ref:i,className:"w-full max-w-full isolate rounded-[28px] bg-white",children:(0,eO.jsx)(eYR,{})})]})}function eYq(e){if("string"==typeof e)return e.trim();if(!e||"object"!=typeof e||Array.isArray(e))return"";for(let t of["auto","original","en","zh-CN","zh-HK","ja","pt"]){let l=e[t];if("string"==typeof l&&l.trim())return l.trim()}let t=Object.values(e).find(e=>"string"==typeof e&&e.trim());return"string"==typeof t?t.trim():""}function eYH(e){var t;let{payload:l}=e;if(!l||"object"!=typeof l)return null;let i=(null==(t=l.product_sku)?void 0:t.option)??l.option??l.product_option_item,a=Array.isArray(i)?i:[],n=eV0({...e,payload:{...l,option:a.map(e=>({...e,price:(null==e?void 0:e.add_price)??(null==e?void 0:e.price)}))}});if(!n)return null;let r=[l.origin,e.sourceItem].filter(e=>!!(e&&"object"==typeof e)),{product_option_item:s,...o}=n;return{...o,product_sku:{...l.product_sku,option:s.map((e,t)=>{var l;let{price:i,...n}=e,s=function(e,t){let l=eYq((null==e?void 0:e.name)??(null==e?void 0:e.title)??(null==e?void 0:e.label)??(null==e?void 0:e.option_group_item_name));if(l)return l;let i=Number((null==e?void 0:e.product_option_item_id)??(null==e?void 0:e.option_group_item_id)),a=Number(null==e?void 0:e.option_group_id);if(!i||Number.isNaN(i))return"";for(let e of t){let t=Array.isArray(null==e?void 0:e.option_group)?e.option_group:[],l=t.find(e=>!(!a||Number.isNaN(a))&&Number(null==e?void 0:e.id)===a);for(let e of l?[l]:t){let t=(Array.isArray(null==e?void 0:e.option_item)?e.option_item:[]).find(e=>Number(null==e?void 0:e.id)===i),l=eYq((null==t?void 0:t.name)??(null==t?void 0:t.title)??(null==t?void 0:t.label)??(null==t?void 0:t.option_group_item_name));if(l)return l}}return""}(a[t]||n,r),o={...a[t],...n,option_group_item_id:Number((null==(l=a[t])?void 0:l.option_group_item_id)??n.product_option_item_id)||0,add_price:i,...s?{name:s}:{}};return delete o.price,o})}}}function eYV(){var e;let{utils:t}=eI().appHelper||{},{runModuleAction:l,refreshViewModel:i,viewModel:a,goToStep:n}=eYT(),r=a.addonProductList||[],s=(Array.isArray(a.cartItems)?a.cartItems:[]).filter(e=>{var t;return!(null==e||null==(t=e.metadata)?void 0:t.venue_booking)}),o=(0,ex.useRef)(null),d=rp(),c=window.innerHeight-100;(0,ex.useEffect)(()=>{r.length>0||(async()=>{try{let e=await l("getAddonProducts");Array.isArray(e)?i({addonProductList:e}):e_.Modal.confirm({title:(null==e?void 0:e.message)||String(eP.getText("pisell2.venue.error.load.products")||"商品加载失败"),okText:String(eP.getText("pisell2.event.confirm")||"确认"),cancelButtonProps:{style:{display:"none"}},maskClosable:!1,onOk:()=>{location.replace("/")}})}catch(e){console.error("[venueBooking] getProductList failed",e)}})()},[]);let u=async e=>{let{orderProduct:t,sourceData:a}=e;try{await l("addProductToOrder",t),await i()}catch(e){console.error("[venueBooking] addProductToOrder failed",{error:e,sourceData:a,mappedData:t})}},p=async e=>{let{identity:t,sourceData:a}=e;try{await l("removeProductFromOrder",t),await i()}catch(e){console.error("[venueBooking] removeProductFromOrder failed",{error:e,sourceData:a,identity:t})}},m=async e=>{let{identity:t,num:a,sourceData:n}=e;try{await l("updateOrderProduct",{...t,updates:{num:a}}),await i()}catch(e){console.error("[venueBooking] updateOrderProduct failed",{error:e,sourceData:n,identity:t,num:a})}},g=async(e,l,i)=>{let a=(null==i?void 0:i.product)||e;if((null==i?void 0:i.intent)==="quantity"){var n;let t={...e,quantity:null==e?void 0:e.num,option:(null==e||null==(n=e.product_sku)?void 0:n.option)??(null==e?void 0:e.option)??(null==e?void 0:e.product_option_item),bundle:(null==e?void 0:e.bundle)??(null==e?void 0:e.product_bundle),origin:a,price:(null==e?void 0:e.price)??(null==e?void 0:e.selling_price)},l=eYH({payload:t,fallbackProductId:(null==e?void 0:e.product_id)??(null==e?void 0:e.id),sourceItem:a});if(!l)return void console.warn("[venueBooking] quantity add missing product_id",t);let r=Number((null==i?void 0:i.quantity)??(null==t?void 0:t.quantity)??0),o=Number((null==l?void 0:l.product_variant_id)??0);if(Number.isNaN(o))return void console.warn("[venueBooking] quantity action missing product_variant_id",{quantityData:t,orderProduct:l});let d=Number.isNaN(r)?0:Math.max(0,Math.floor(r)),c=s.filter(e=>String((null==e?void 0:e.product_id)??null)===String((null==l?void 0:l.product_id)??null)),g=c.filter(e=>Number((null==e?void 0:e.product_variant_id)??0)===o),h=eYl(e),v=h?g.filter(e=>eYl(e)===h):g;if(c.length>1||h&&1!==v.length)return void console.warn("[venueBooking] quantity action skipped: ambiguous or stale order line",{mode:h?"uid":"sku",eventUid:h,product_id:l.product_id,product_variant_id:o,matchedLineCount:c.length});let f=v[0],y=f?eYt(f):null;if(f&&!y)return void console.warn("[venueBooking] quantity action skipped: missing order line UID",{item:f});if(d<=0){if(!y)return;await p({identity:y,sourceData:t});return}if(!f)return void await u({orderProduct:{...l,num:d},sourceData:t});if(!y)return;await m({identity:y,num:d,sourceData:t})}else null==t||t.action({type:"pisell1.productDetail",data:{detail:{...a,open_deposit:1},setting:{can_input:!0,item_max_length:1,is_detail_open:!0}},callback:async t=>{if(null==t?void 0:t.isCancel)return;let l=eYH({payload:t,fallbackProductId:(null==e?void 0:e.product_id)??(null==e?void 0:e.id),sourceItem:a});l?await u({orderProduct:l,sourceData:t}):console.warn("[venueBooking] productDetail callback missing product_id",t)}})},h=(0,eO.jsx)(z9,{dataSource:r,onChange:g,loading:!1,emptyDescription:eP.getText("pisell2.venue.addons.empty"),token:{colorPrimary:"var(--theme-color)",containerBg:"#FFFFFF",tabItemBg:"#F2F4F7",tabItemHoverBg:"#F2F4F7",tabItemActiveBg:"var(--theme-color)",categoryTextColor:"#1B1B1B",cardSelectedBg:"var(--theme-color)"},customScrollParent:(null==(e=o.current)?void 0:e.getScrollContainer())||"",hideCategoryWhenOne:!0,version:"v2",value:s,productListSetting:{imgWidth:80,imgHeight:80},cartElementId:"#venue-booking-cart-btn"});return d?(0,eO.jsx)("div",{className:"pisell-venue-booking-addons pisell-venue-booking-addons--mobile",children:h}):(0,eO.jsx)("div",{className:"pisell-venue-booking-addons",children:(0,eO.jsx)(id.PisellScrollView,{maxHeight:c,overflow:"y",ref:o,children:h})})}function eYY(){eYa();let{viewModel:e,goToStep:t,updateOrderNote:l,runModuleAction:i}=eYT(),[a]=e_.Form.useForm(),[n,r]=(0,ex.useState)(String(e.note||"")),s=(0,ex.useRef)("[]"),o=(0,ex.useRef)(String(e.note||""));(0,ex.useMemo)(()=>{var t;return Number((null==(t=e.summary)?void 0:t.product_amount)??0)},[e.summary]),(0,ex.useMemo)(()=>{var t,l;return Number((null==(t=e.summary)?void 0:t.total_amount)??(null==(l=e.summary)?void 0:l.expect_amount)??0)},[e.summary]);let d=(0,ex.useMemo)(()=>(e.cartItems||[]).filter(e=>!!((null==e?void 0:e.start_date)&&(null==e?void 0:e.end_date))),[e.cartItems]),c=(0,ex.useMemo)(()=>(e.cartItems||[]).filter(e=>!(null==e?void 0:e.start_date)||!(null==e?void 0:e.end_date)),[e.cartItems]);(0,ex.useMemo)(()=>c.reduce((e,t)=>e+function(e){let t=Number.isNaN(Number(null==e?void 0:e.num))?1:Math.max(1,Math.floor(Number(null==e?void 0:e.num))),l=Number(null==e?void 0:e.price);if(!Number.isNaN(l))return l*t;let i=Number(null==e?void 0:e.total);return Number.isNaN(i)?0:i}(t),0),[c]);let u=(0,ex.useMemo)(()=>d.map((e,t)=>{let l=function(e){var t,l;let i=String((null==e?void 0:e.relation_form_name)||"").trim();if(i)return i;let a=String((null==e||null==(l=e.resources)||null==(t=l[0])?void 0:t.main_field)||"").trim();if(a)return a;let n=String((null==e?void 0:e.title)||(null==e?void 0:e.name)||"").trim();return n||""}(e),i=function(e){var t;let l,i,a=String((null==e?void 0:e.start_date)||""),n=String((null==e?void 0:e.end_date)||""),r=ef()(a),s=ef()(n);if(!r.isValid()||!s.isValid())return String((null==e?void 0:e.description)||(null==e?void 0:e.subtitle)||"-");let o=(l=Math.floor((t=Math.max(0,s.diff(r,"minute")))/60),i=t%60,l>0&&i>0?eYW(String(eP.getText("pisell2.venue.checkout.duration.hours_minutes")||"{hours}h {minutes}min"),{hours:l,minutes:i}):l>0?eYW(String(eP.getText("pisell2.venue.checkout.duration.hours")||"{hours}h"),{hours:l}):eYW(String(eP.getText("pisell2.venue.checkout.duration.minutes")||"{minutes}min"),{minutes:i}));return`${r.format("HH:mm")} ~ ${s.format("HH:mm")} ${r.format("DD/MM/YYYY")} (${o})`}(e),a=String(l||`场地 ${t+1}`);return`${a} ${i}`}),[d]);(0,ex.useMemo)(()=>({first_name:{visible:!0,required:!1},last_name:{visible:!0,required:!1},phone:{visible:!0,required:!1},email:{visible:!1,required:!1}}),[]);let p=(0,ex.useCallback)(async()=>{let e=eYU(a.getFieldsValue()),t=JSON.stringify(e);t!==s.current&&(s.current=t,await i("updateTempOrderContactsInfo",e))},[a,i]);(0,ex.useCallback)(()=>{p()},[p]);let m=(0,ex.useCallback)(async()=>{n!==o.current&&(o.current=n,await l(n))},[n,l]);return(0,ex.useEffect)(()=>{var t,l,i,n;let r,o,d=(o=Array.isArray(t=e.contactsInfo)?t[0]:null)&&"object"==typeof o?{first_name:String((null==o?void 0:o.first_name)||""),last_name:String((null==o?void 0:o.last_name)||""),email:String((null==o?void 0:o.email)||""),phone:{phone:String((null==o||null==(l=o.phone)?void 0:l.phone)||""),countryCallingCode:(r=String((null==o||null==(i=o.phone)?void 0:i.country_calling_code)||"").trim())?r.startsWith("+")?r:`+${r}`:"",countryCode:String((null==o||null==(n=o.phone)?void 0:n.country_code)||"")}}:{first_name:"",last_name:"",email:"",phone:{phone:"",countryCallingCode:"",countryCode:""}};a.setFieldsValue(d),s.current=JSON.stringify(eYU(d))},[a,e.contactsInfo]),(0,ex.useEffect)(()=>{let t=String(e.note||"");r(t),o.current=t},[e.note]),(0,eO.jsx)("div",{className:"space-y-3 md:space-y-5",children:(0,eO.jsxs)("div",{className:"grid gap-3 md:gap-4",children:[(0,eO.jsxs)("div",{className:"rounded-[22px] bg-white p-4 md:rounded-[28px] md:p-6",children:[(0,eO.jsx)("div",{className:"flex items-center justify-between gap-3",children:(0,eO.jsx)("div",{children:(0,eO.jsx)("div",{className:"mt-3 text-[22px] font-extrabold text-zinc-900",children:eP.getText("pisell2.venue.checkout.court.summary")||"场地预订摘要"})})}),(0,eO.jsxs)("div",{className:"mt-5 grid gap-4 md:grid-cols-2",children:[(0,eO.jsxs)("div",{className:"rounded-[22px] bg-[#faf7f4] p-4 md:col-span-2",children:[(0,eO.jsx)("div",{className:"text-sm font-semibold text-[#a69183]",children:eP.getText("pisell2.venue.checkout.selected.courts")||"已选场地"}),(0,eO.jsx)("div",{className:"mt-3 space-y-2 text-[15px] font-semibold text-zinc-900",children:u.length?u.map((e,t)=>(0,eO.jsx)("div",{children:e},`venue-session-line-${t}`)):(0,eO.jsx)("div",{children:eP.getText("pisell2.venue.checkout.sessions.empty")||"-"})})]}),c.length>0?(0,eO.jsxs)("div",{className:"rounded-[22px] bg-[#faf7f4] p-4",children:[(0,eO.jsx)("div",{className:"text-sm font-semibold text-[#a69183]",children:eP.getText("pisell2.venue.checkout.addons")||"附加项"}),(0,eO.jsx)("div",{className:"mt-3 text-[15px] font-semibold text-zinc-900",children:c.map((e,t)=>(0,eO.jsx)("div",{children:e.title||e.name||"-"},`addon-${e.id||t}`))})]}):null]})]}),(0,eO.jsx)("div",{className:"space-y-4",children:(0,eO.jsx)("div",{className:"rounded-[28px] bg-white p-5 md:p-6",children:(0,eO.jsxs)("div",{className:"mt-5 rounded-[22px] bg-[#faf7f4] p-4",children:[(0,eO.jsx)("div",{className:"text-lg font-bold text-zinc-900",children:eP.getText("pisell2.venue.checkout.notice")||"备注"}),(0,eO.jsx)("textarea",{className:"mt-4 min-h-[120px] w-full rounded-[20px] border border-black/10 bg-white px-4 py-4 text-sm outline-none placeholder:text-zinc-400",value:n,onChange:e=>r(e.target.value),placeholder:String(eP.getText("pisell2.venue.note.placeholder")||"特殊要求..."),onBlur:()=>{m()}})]})})})]})})}function eYU(e){var t,l,i;let a=String((null==e?void 0:e.first_name)||"").trim(),n=String((null==e?void 0:e.last_name)||"").trim(),r=String((null==e?void 0:e.email)||"").trim(),s=String((null==e||null==(t=e.phone)?void 0:t.phone)||"").trim(),o=String((null==e||null==(l=e.phone)?void 0:l.countryCallingCode)||"").trim(),d=String((null==e||null==(i=e.phone)?void 0:i.countryCode)||"").trim();if(!(a||n||r||s||o||d))return[];let c=`${a} ${n}`.trim();return[{first_name:a,last_name:n,display_name:c,email:r,phone:{phone:s,country_calling_code:o,country_code:d}}]}function eYW(e,t){let l=e;for(let[e,i]of Object.entries(t))l=l.split(`{${e}}`).join(String(i));return l}function eYG(){let{currentStep:e,viewModel:t,handlePrimaryAction:l,isSubmittingOrder:i}=eYT(),a={"select-venue":(0,eO.jsx)(eYB,{}),addons:(0,eO.jsx)(eYV,{}),checkout:(0,eO.jsx)(eYY,{})},n=(0,ex.useRef)(null);return(0,ex.useEffect)(()=>{let e=n.current;if(!e)return;let t=e.closest(".venue-booking-scope");if(!t)return;function l(){e&&(null==t||t.style.setProperty("--vb-grid-sticky-top",`${e.offsetHeight}px`))}l();let i="u">typeof ResizeObserver?new ResizeObserver(l):null;return null==i||i.observe(e),window.addEventListener("resize",l),()=>{null==i||i.disconnect(),window.removeEventListener("resize",l)}},[]),(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsx)("style",{children:`
32
+ ${String((null==e?void 0:e.message)??e)}`})}};return(0,eO.jsxs)("section",{className:"sales-sdk-demo__tab",children:[(0,eO.jsxs)("header",{className:"sales-sdk-demo__panel",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"详情展示"}),(0,eO.jsxs)("span",{children:["status: ",l.status," / ready: ",l.isReady?"yes":"no"]})]}),(0,eO.jsxs)("p",{className:"sales-sdk-demo__hint",children:["只读场景:调用 ",(0,eO.jsx)("code",{children:"sales.loadDetail(orderId)"})," 拉取服务端订单详情后展示客户 / 购物车 / 汇总。"]}),(0,eO.jsxs)("div",{className:"sales-sdk-demo__toolbar",children:[(0,eO.jsxs)("button",{type:"button",className:"sales-sdk-demo__primary",disabled:m,onClick:x,children:["一键查看详情(orderId = ",c.orderId,")"]}),(0,eO.jsxs)("button",{type:"button",className:"sales-sdk-demo__primary",disabled:m,onClick:_,children:["结账(orderId = ",c.orderId,")"]})]}),(0,eO.jsxs)("div",{className:"sales-sdk-demo__toolbar",style:{marginTop:8,gap:8,alignItems:"center"},children:[(0,eO.jsx)("span",{style:{fontSize:12,color:"#666"},children:"变更预约状态:"}),(0,eO.jsxs)("select",{value:h,onChange:e=>v(e.target.value),disabled:f||!l.isReady,children:[(0,eO.jsx)("option",{value:"confirmed",children:"confirmed"}),(0,eO.jsx)("option",{value:"pending",children:"pending"}),(0,eO.jsx)("option",{value:"checked_in",children:"checked_in"}),(0,eO.jsx)("option",{value:"completed",children:"completed"}),(0,eO.jsx)("option",{value:"cancelled",children:"cancelled"}),(0,eO.jsx)("option",{value:"no_show",children:"no_show"})]}),(0,eO.jsx)("button",{type:"button",className:"sales-sdk-demo__primary",disabled:f||!l.isReady,onClick:k,title:l.isReady?void 0:"请先点「一键查看详情」加载订单",children:f?"提交中...":`setBookingStatus(${h})`})]})]}),(0,eO.jsx)(eH9,{variant:"detail",value:o,onChange:d}),l.error?(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel sales-sdk-demo__panel--error",children:[(0,eO.jsx)("h3",{children:"SDK Error"}),(0,eO.jsx)("pre",{children:l.error.message})]}):null,(0,eO.jsx)(eH2,{sales:l,cart:a,customer:i,summary:n.summary,products:r.products}),(0,eO.jsx)(eH1,{entries:u})]})};function eVt(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}let eVl=e=>{let{cart:t,readOnly:l,onRemoveError:i,onRemoveSuccess:a,onEditBookingError:n}=e,r=async e=>{try{await t.removeItem(e),null==a||a(e)}catch(e){null==i||i(e)}},s=async e=>{try{await t.editCartLineBooking(e)}catch(e){console.error("[SalesSdk Demo] editCartLineBooking failed",e),null==n||n(e)}};return t.bookings.length,t.items.length,(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"Cart Items"}),(0,eO.jsxs)("span",{children:[t.items.length," item(s)"]})]}),t.items.length>0?(0,eO.jsx)("div",{className:"sales-sdk-demo__items",children:t.items.map((e,t)=>{var i,a;let n=(null==e||null==(i=e._identity)?void 0:i.unique_identification_number)??`${e.product_id}-${e.product_variant_id}-${t}`;return(0,eO.jsxs)("article",{className:"sales-sdk-demo__item",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__item-main",children:[e.cover?(0,eO.jsx)("img",{src:e.cover,alt:e.title}):null,(0,eO.jsxs)("div",{children:[(0,eO.jsx)("h4",{children:e.title||"Untitled product"}),(0,eO.jsxs)("p",{children:["Variant: ",e.variant_title||"-"," / Qty: ",e.num]}),(0,eO.jsxs)("p",{children:["Price: ",e.selling_price||"-"," / Original:"," ",e.original_price||"-"]}),(0,eO.jsxs)("p",{children:["Schedule: ",e.start_at||"-"," - ",e.end_at||"-"]}),e.note?(0,eO.jsxs)("p",{children:["Note: ",e.note]}):null]})]}),l?null:(0,eO.jsxs)("div",{className:"sales-sdk-demo__item-actions",children:[(null==(a=e._extend)?void 0:a.booking)!=null?(0,eO.jsx)("button",{type:"button",className:"sales-sdk-demo__secondary",onClick:()=>s(e),children:"编辑资源"}):null,(0,eO.jsx)("button",{type:"button",className:"sales-sdk-demo__danger",onClick:()=>r(e),children:"remove"})]})]},n)})}):(0,eO.jsx)("div",{className:"sales-sdk-demo__empty",children:"No cart item loaded."})]})},eVi={status:"idle"};function eVa(e){if(!e.startedAt||!e.finishedAt)return"";let t=e.finishedAt-e.startedAt;return t<1e3?`${t}ms`:`${(t/1e3).toFixed(2)}s`}let eVn=e=>{let{title:t,steps:l,oneClickLabel:i="一键测试用例",toolbarExtra:a,onAllDone:n,onReset:r,className:s}=e,[o,d]=(0,ex.useState)({}),[c,u]=(0,ex.useState)(!1),[p,m]=(0,ex.useState)(!1),[g,h]=(0,ex.useState)(null),v=(0,ex.useCallback)(e=>o[e]||eVi,[o]),f=(0,ex.useCallback)((e,t)=>{d(l=>({...l,[e]:{...l[e]||eVi,...t}}))},[]),y=(0,ex.useCallback)(async e=>{let t=Date.now();f(e.id,{status:"running",startedAt:t,finishedAt:void 0,result:void 0,error:void 0});try{let l=await e.run(),i=Date.now(),a={status:"success",result:l,startedAt:t,finishedAt:i};return f(e.id,a),a}catch(a){let l=Date.now(),i={status:"error",error:String((null==a?void 0:a.message)??a),startedAt:t,finishedAt:l};return f(e.id,i),i}},[f]),b=(0,ex.useCallback)(async e=>{if(!c&&!p){if(e.skip)return void f(e.id,{status:"skipped"});u(!0);try{await y(e)}finally{u(!1)}}},[c,p,y,f]),x=(0,ex.useCallback)(async()=>{if(c||p)return;u(!0);let e={};l.forEach(t=>{e[t.id]=t.skip?{status:"skipped"}:eVi}),d(e);try{for(let e of l){if(e.skip)continue;let t=await y(e);if("error"===t.status)break}}finally{u(!1),n&&d(e=>(n(e),e))}},[c,p,y,l,n]),k=(0,ex.useMemo)(()=>{let e={success:0,error:0,skipped:0,idle:0,running:0};return l.forEach(t=>{var l;let i=(null==(l=o[t.id])?void 0:l.status)??"idle";e[i]+=1}),e},[o,l]),_=(0,ex.useCallback)(async()=>{if(!c&&!p){if(h(null),r){m(!0);try{await r()}catch(e){h(String((null==e?void 0:e.message)??e));return}finally{m(!1)}}d({})}},[c,p,r]),w=c||p;return(0,eO.jsxs)("section",{className:["sales-sdk-demo__panel","sales-sdk-demo__steps",s].filter(Boolean).join(" "),children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:t}),(0,eO.jsxs)("span",{children:[k.success," ok / ",k.error," fail / ",k.skipped," skipped /"," ",k.idle+k.running," pending"]})]}),(0,eO.jsxs)("div",{className:"sales-sdk-demo__steps-toolbar",children:[(0,eO.jsx)("button",{type:"button",className:"sales-sdk-demo__primary",disabled:w||0===l.length,onClick:x,children:i}),(0,eO.jsx)("button",{type:"button",disabled:w,onClick:_,children:p?"resetting…":"reset"}),a]}),g?(0,eO.jsxs)("pre",{className:"sales-sdk-demo__step-error",children:["reset 失败: ",g]}):null,(0,eO.jsx)("ol",{className:"sales-sdk-demo__step-list",children:l.map((e,t)=>{let l=v(e.id),i=e.skip?"skipped":l.status;return(0,eO.jsxs)("li",{className:`sales-sdk-demo__step sales-sdk-demo__step--${i}`,children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__step-head",children:[(0,eO.jsx)("span",{className:"sales-sdk-demo__step-index",children:t+1}),(0,eO.jsxs)("div",{className:"sales-sdk-demo__step-meta",children:[(0,eO.jsx)("strong",{children:e.label}),e.description?(0,eO.jsx)("em",{className:"sales-sdk-demo__step-desc",children:e.description}):null]}),(0,eO.jsxs)("div",{className:"sales-sdk-demo__step-status",children:[(0,eO.jsx)("span",{children:i}),eVa(l)?(0,eO.jsx)("em",{children:eVa(l)}):null]}),(0,eO.jsx)("button",{type:"button",disabled:w||!!e.skip,onClick:()=>b(e),children:"单步执行"})]}),l.error?(0,eO.jsx)("pre",{className:"sales-sdk-demo__step-error",children:l.error}):null,"success"===l.status&&void 0!==l.result?(0,eO.jsx)("pre",{className:"sales-sdk-demo__step-result",children:function(e){if(void 0===e)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}(l.result)}):null]},e.id)})})]})};async function eVr(e,t,l){var i,a,n;if(Array.isArray(l)&&l.length>0&&null==t)return l[0]??null;if(null!=t){let l=e.customer.loadById(t);if(l)return l;let i=await e.customer.loadList({search:String(t)});return(null==(a=i.list)?void 0:a.find(e=>String(e.id)===String(t)))??(null==(n=i.list)?void 0:n[0])??null}return(null==(i=(await e.customer.loadList()).list)?void 0:i[0])??null}function eVs(e,t){let l={customer:null,customerList:[],product:null,products:[]},i=t.productPicker.productId??61743;return[{id:"customer.loadList",label:"customer.loadList",description:"从服务端拉默认一页客户列表",run:async()=>{try{let t=await e.customer.loadList();return l.customerList=t.list||[],t}catch(a){var t,i;if((null==(t=e.demoRuntime)?void 0:t.hasAuthToken)===!1&&(null==(i=e.demoRuntime)?void 0:i.fallbackCustomer)){let t=[e.demoRuntime.fallbackCustomer];return l.customerList=t,{list:t,total:t.length,page:1,pageSize:t.length,_fallback:"public-shell-walk-in-customer"}}throw a}}},{id:"customer.select",label:"customer.select",description:t.customerId?`按 customerId=${t.customerId} 选客户`:"默认选 customer.list[0]",run:async()=>{let i=await eVr(e,t.customerId,l.customerList);if(!i)throw Error("未找到可选客户,请检查 customerId 或客户列表");return e.customer.select(i),l.customer=i,i}},{id:"products.load",label:"products.load",description:"loadProducts(fixture.loadProductsParams)",run:async()=>{try{let i=await e.products.load({...t.loadProductsParams,menu_list_ids:[43775]});return l.products=Array.isArray(i)?i:[],i}catch(r){var a,n;if((null==(a=e.demoRuntime)?void 0:a.hasAuthToken)===!1&&"function"==typeof(null==(n=e.demoRuntime)?void 0:n.loadPublicProductDetail)){let a=await e.demoRuntime.loadPublicProductDetail(i,{schedule_date:t.loadProductsParams.schedule_date});if(!a)throw r;let n=null!=t.productPicker.num&&t.productPicker.num>0?t.productPicker.num:1,s={...a,isOpenDetailModal:!1,open_sold_weight:0,cartDetailValue:{key:`demo-public-${a.id}`,quantity:n}};return l.products=[s],[{...s,_fallback:"public-shell-product-detail"}]}throw r}}},{id:"cart.addProductWithFlow",label:"cart.addProductWithFlow",description:"加车编排:OS 决策 → legacy Info2 弹窗 (pisell1.handleOpenProductModal) → confirmDetail → 写入 tempOrder",run:async()=>{var a,n;let r=(a=l.products.length>0?l.products:e.products.products,n={...t.productPicker,productId:i},Array.isArray(a)&&0!==a.length?n.productId?a.find(e=>e.id===n.productId)??null:a[0]??null:null);if(!r)throw Error("未找到可加车商品:请确认 products.load 已成功且 catalog 不为空");l.product=r;let s=t.productPicker.num??1,o=await e.cart.addProductWithFlow(r,{quantity:s});if("cancelled"===o.status)throw Error("加车流程已取消(可能为规格弹窗、跨日日期、Holder 或资源抽屉中取消)");if("requiresDetail"===o.status)throw Error("命中 requiresDetail 但未配置 uiHosts.openProductDetail(请使用 SalesSdkDemoTabShell)");if("requiresBookingEdit"===o.status)throw Error("命中 requiresBookingEdit 但未配置 uiHosts.openBookingEdit(请使用 SalesSdkDemoTabShell)");return o}},{id:"cart.recalcSummary",label:"cart.recalcSummary",description:"触发 summary 重算",run:async()=>e.cart.recalcSummary()},{id:"cart.submit",label:"cart.submit",description:"调真实 OS submit API(执行前会弹确认框)",run:async()=>{var t;if((null==(t=e.demoRuntime)?void 0:t.hasAuthToken)===!1)return{_fallback:"public-shell-submit-skipped",reason:"public shell requires auth before real submit",items:e.cart.items.length,bookings:e.cart.bookings.length,summary:e.cart.summary,tempOrder:e.sales.tempOrder};if(!(!("u"<typeof window)&&window.confirm("一键测试将调用真实 submit API,确认继续?")))throw Error("用户取消 submit");return e.cart.submit()}}]}let eVo=()=>{let e=eI(),t=ehe(),l=ehr(),i=e_M(),a=ekm(),n=e_C(),[r,s]=(0,ex.useState)({}),[o,d]=(0,ex.useState)(null),c=(0,ex.useMemo)(()=>eHX(eHZ,r),[r]),u=(0,ex.useMemo)(()=>!("u"<typeof window)&&!!(window.localStorage.getItem("shop_pc_token")||window.localStorage.getItem("token")),[]),p=n_(async(t,l)=>{var i,a;let n=null==e||null==(a=e.appHelper)||null==(i=a.utils)?void 0:i.request;if("function"!=typeof(null==n?void 0:n.get))return null;let r=await n.get(`/h5/product/show/${t}`,l||{},{customToast:()=>{}});return(null==r?void 0:r.data)??null}),m=(0,ex.useMemo)(()=>{var e;return[{id:"sales.createNew",label:"sales.createNew",description:"创建一个新的 tempOrder",run:async()=>e.sales.createNew()},...eVs(e={sales:t,customer:l,products:i,cart:a,demoRuntime:{hasAuthToken:u,fallbackCustomer:{id:1,name:"Walk In",nickname:"Walk In",phone:"",email:"",country_calling_code:""},loadPublicProductDetail:p}},c)]},[t,l,i,a,c,u,p]),g=n_(async()=>{await t.restore(),await a.recalcSummary()});return eyw(n.summary),(0,eO.jsxs)("section",{className:"sales-sdk-demo__tab",children:[(0,eO.jsxs)("header",{className:"sales-sdk-demo__panel sales-sdk-demo__panel--warn",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"新建订单一键流程"}),(0,eO.jsxs)("span",{children:["status: ",t.status," / ready: ",t.isReady?"yes":"no"]})]}),(0,eO.jsx)("p",{className:"sales-sdk-demo__hint",children:"注意:此 Tab 会调用真实 OS 接口(createNew / addProductWithFlow / submit)。加车若需规格会打开 Info2 弹窗。submit 会弹二次确认,其它步骤直接执行。"})]}),(0,eO.jsx)(eH9,{variant:"create",value:r,onChange:s}),(0,eO.jsx)(eVn,{title:"步骤序列(点一键串行执行 / 也可单步)",steps:m,onReset:g}),t.error?(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel sales-sdk-demo__panel--error",children:[(0,eO.jsx)("h3",{children:"SDK Error"}),(0,eO.jsx)("pre",{children:t.error.message})]}):null,(0,eO.jsx)(eVl,{cart:a,onEditBookingError:e=>d(String((null==e?void 0:e.message)??e))}),o?(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel sales-sdk-demo__panel--error",children:[(0,eO.jsx)("h3",{children:"编辑资源失败"}),(0,eO.jsx)("pre",{children:o})]}):null,(0,eO.jsx)(eH2,{sales:t,cart:a,customer:l,summary:n.summary,products:i.products})]})},eVd=e=>{let{initialOrderId:t}=e,l=ehe(),i=ehr(),a=e_M(),n=ekm(),r=e_C(),s=(0,ex.useMemo)(()=>({...eHJ,...t?{orderId:t}:{}}),[t]),[o,d]=(0,ex.useState)({}),c=(0,ex.useMemo)(()=>({...eHX(s,o),orderId:null!=o.orderId?Number(o.orderId):s.orderId}),[s,o]),u=(0,ex.useMemo)(()=>{var e;return e={sales:l,customer:i,products:a,cart:n},[{id:"sales.loadDetail",label:"sales.loadDetail",description:`加载订单详情 orderId=${c.orderId}`,run:async()=>{if(!Number.isFinite(c.orderId)||c.orderId<=0)throw Error("orderId 必须为正整数");return e.sales.loadDetail(c.orderId)}},{id:"sales.setOrderNote",label:"sales.setOrderNote",description:null!=c.orderNote?`note="${c.orderNote}"`:"未配置 orderNote,跳过",skip:null==c.orderNote,run:async()=>e.sales.setOrderNote(c.orderNote??"")},{id:"sales.setShopDiscount",label:"sales.setShopDiscount",description:null!=c.shopDiscount?`shop_discount=${c.shopDiscount}`:"未配置 shopDiscount,跳过",skip:null==c.shopDiscount,run:async()=>e.sales.setShopDiscount(c.shopDiscount)},{id:"sales.setContactsInfo",label:"sales.setContactsInfo",description:void 0!==c.contactsInfo?`contacts_info=${JSON.stringify(c.contactsInfo)}`:"未配置 contactsInfo,跳过",skip:void 0===c.contactsInfo,run:async()=>e.sales.setContactsInfo(c.contactsInfo??null)},...eVs(e,c)]},[l,i,a,n,c]),p=n_(async()=>{await l.restore(),await n.recalcSummary()});return eyw(r.summary),(0,eO.jsxs)("section",{className:"sales-sdk-demo__tab",children:[(0,eO.jsxs)("header",{className:"sales-sdk-demo__panel sales-sdk-demo__panel--warn",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsxs)("h3",{children:["编辑订单一键流程(orderId = ",c.orderId,")"]}),(0,eO.jsxs)("span",{children:["status: ",l.status," / ready: ",l.isReady?"yes":"no"]})]}),(0,eO.jsx)("p",{className:"sales-sdk-demo__hint",children:"注意:此 Tab 会先 loadDetail 加载既有订单,再写入备注 / 整单优惠 / 联系人,最后追加客户 / 商品 / submit,均为真实 OS 接口。"})]}),(0,eO.jsx)(eH9,{variant:"edit",value:o,onChange:d}),(0,eO.jsx)(eVn,{title:"步骤序列(点一键串行执行 / 也可单步)",steps:u,onReset:p}),l.error?(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel sales-sdk-demo__panel--error",children:[(0,eO.jsx)("h3",{children:"SDK Error"}),(0,eO.jsx)("pre",{children:l.error.message})]}):null,(0,eO.jsx)(eVl,{cart:n}),(0,eO.jsx)(eH2,{sales:l,cart:n,customer:i,summary:r.summary,products:a.products})]})};function eVc(e){let t=qk(),l=evN(),i=(0,ex.useRef)(null),a=(0,ex.useCallback)(a=>{var n,r;return i.current=a,null==(n=a.setPromotionEvaluator)||n.call(a,e??null),null==(r=a.setGiftSelectResolver)||r.call(a,eyU(t.giftSelect,()=>i.current,{getUiHosts:()=>l})),a},[t.giftSelect,e,l]);return(0,ex.useEffect)(()=>()=>{var e,t;let l=i.current;null==l||null==(e=l.setPromotionEvaluator)||e.call(l,null),null==l||null==(t=l.setGiftSelectResolver)||t.call(l,null),i.current=null},[]),a}let eVu="YYYY-MM-DD";function eVp(){return ef()().format(eVu)}function eVm(e){return e.split(",").map(e=>e.trim()).filter(Boolean).map(e=>{let t=Number(e);return Number.isFinite(t)?t:e})}function eVg(e){let t=Number(e);return Number.isFinite(t)?t:void 0}function eVh(){return!("u"<typeof window)&&!!(window.localStorage.getItem("shop_pc_token")||window.localStorage.getItem("token"))}function eVv(){if("u"<typeof window)return null;try{let e=window.localStorage.getItem("customer")||window.localStorage.getItem("shop_pc_customer"),t=e?JSON.parse(e):null,l=Number((null==t?void 0:t.id)??(null==t?void 0:t.customer_id));return Number.isFinite(l)&&l>1?{...t,id:l}:null}catch{return null}}function eVf(e){return(null==e?void 0:e.id)??(null==e?void 0:e.product_id)}function eVy(e){let t=(null==e?void 0:e.title)||(null==e?void 0:e.name)||(null==e?void 0:e.product_title);return"string"==typeof t?t:t&&"object"==typeof t?t.en||t.zh||t.default||String(Object.values(t)[0]||"Untitled product"):`Product #${eVf(e)??"-"}`}function eVb(e){return!!((null==e?void 0:e.duration)||(null==e?void 0:e.durationMinutes)||(null==e?void 0:e.duration_minutes)||(null==e?void 0:e.service_duration))}function eVx(e,t){let l=new Set(t.map(e=>String(e)));return e.filter(e=>l.has(String(eVf(e))))}function eVk(e){return e.map(eVf).filter(e=>null!=e)}let eV_=()=>{var e,t,l,i,a;let n=eI(),r=null==n||null==(e=n.appHelper)?void 0:e.utils,s=null==n||null==(l=n.appHelper)||null==(t=l.utils)?void 0:t.pisellos,o=null==n||null==(a=n.appHelper)||null==(i=a.utils)?void 0:i.pisellosAllModule,d=eVc(null==r?void 0:r.promotionEvaluator),[c,u]=(0,ex.useState)(()=>eVh()),[p,m]=(0,ex.useState)(()=>(function(){var e;let t,l,i,a,n,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0],s=(t=ef()(),l=ef()(`${t.format(eVu)} 09:00:00`),i=ef()(`${t.format(eVu)} 18:00:00`),a=30*Math.ceil(t.minute()/30),(n=t.minute(0).second(0).millisecond(0).add(a,"minute")).isAfter(t)||(n=n.add(30,"minute")),n.isBefore(l)&&(n=l.add(60,"minute")),n.add(30,"minute").isAfter(i)&&(n=l.add(1,"day").add(60,"minute")),{date:n.format(eVu),startTime:n.format("HH:mm")}),o=s.date;return{productIds:"61321",resourceId:"",discountCustomerId:String((null==(e=eVv())?void 0:e.id)||""),preferredDiscountId:"",date:o,startTime:s.startTime,dateRangeStart:o,dateRangeEnd:ef()().add(1,"month").format(eVu),customPageId:"199665",channel:"pc",selectionOrder:"product_first",useResourceDateApi:!0,submitAfterCommit:r,applyBestDiscount:!0,slotDurationMinutes:10,rawResourcesJson:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"41077",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:eVp();return JSON.stringify([{id:e,main_field:`Demo Resource ${e}`,type:"single",capacity:1,times:[{start_at:`${t} 09:00:00`,end_at:`${t} 18:00:00`,event_list:[]}]}],null,2)}("demo-resource-1",o)}})(eVh())),[g,h]=(0,ex.useState)(null),[v,f]=(0,ex.useState)(null),y=eVm(p.resourceId).length?"scan_order":"appointment",b=p.channel||"pc",x="scan_order"===y?"scan_to_order":"online_store",k=`unifiedBookingSales-demo-${y}`;(0,ex.useEffect)(()=>{c&&m(e=>{var t;return{...e,submitAfterCommit:!0,discountCustomerId:e.discountCustomerId||String((null==(t=eVv())?void 0:t.id)||"")}})},[c]);let _=(e,t)=>{m(l=>({...l,[e]:t}))},w=()=>{let e=eVh();u(e),e&&m(e=>{var t;return{...e,submitAfterCommit:!0,discountCustomerId:e.discountCustomerId||String((null==(t=eVv())?void 0:t.id)||"")}})},j=async()=>{var e;if(!(null==s?void 0:s.getModule)||!(null==s?void 0:s.registerModule))throw Error("当前页面没有可用 pisellos runtime");let t=s.getModule(k);if(t)return await (null==(e=t.setOtherParams)?void 0:e.call(t,{platform:"PC",channel:x,businessCode:y})),d(t);let l=(null==o?void 0:o.UnifiedBookingSalesImpl)||(null==o?void 0:o.UnifiedBookingSales);if(!l)throw Error("当前 pisellosAllModule 未导出 UnifiedBookingSalesImpl,请先升级/链接 pisell_os");return t=new l(k),s.registerModule(t,{otherParams:{cacheId:k,platform:"PC",channel:x,businessCode:y,enableTempOrderPersist:!1}}),d(t)},S=(0,ex.useMemo)(()=>{let e,t={},l=async()=>(t.module=t.module||await j(),t.module),i=()=>eVm(p.productIds).map(e=>Number(e)).filter(Number.isFinite),a=()=>{let e=eVg(p.discountCustomerId),t=eVv();return{id:e||(null==t?void 0:t.id),source:e?null:t}},n=async e=>{let t=await l(),i=await t.loadPlannerContext({mode:y,productIds:e.productIds,resourceIds:e.resourceIds||eVm(p.resourceId),date:e.date,dateRange:e.dateRange,startTime:e.startTime,rawProducts:e.rawProducts,rawResources:p.useResourceDateApi?[]:function(e){if(!e.trim())return[];let t=JSON.parse(e);if(!Array.isArray(t))throw Error("rawResourcesJson 必须是数组");return t}(p.rawResourcesJson),useResourceDateApi:p.useResourceDateApi,productLoadParams:e.productIds.length?{product_ids:e.productIds.map(Number).filter(Number.isFinite)}:void 0});return h(i),i},r=async(e,i)=>{var a,n,r;let s=await l(),o=[];for(let t of e){let l=i.filter(e=>String(e.productId)===String(t)),a=!1;for(let t of l){let l=[...o,...t.assignments||[]],i=Array.from(new Map(l.map(e=>e.resourceId).map(e=>[String(e),e])).values());null==(n=s.setPlannerSelection)||n.call(s,{mode:y,productIds:e,date:p.date,startTime:t.startTime||p.startTime,resourceIds:i,assignments:l});let d=null==(r=s.validatePlannerSelection)?void 0:r.call(s);if(!d||!1!==d.ok){o.splice(0,o.length,...l),a=!0;break}}if(!a)throw Error(`商品 ${t} 没有可用的资源/时间组合`)}return t.selectedAssignments=o,h(null==(a=s.getPlannerSnapshot)?void 0:a.call(s)),o},s=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"planner.commit";return{id:e,label:"提交 bookings、应用商品券/折扣卡",description:p.submitAfterCommit?"先写入订单并应用最优优惠,再调用真实 submitSalesOrder":"写入 tempOrder 后应用最优优惠,不真实提交订单",run:async()=>{var e,i,n,r;let s=await l();if(p.submitAfterCommit&&!(!("u"<typeof window)&&window.confirm("将通过 OrderModule 调用真实 submit API,确认继续?")))throw Error("用户取消真实 submit");let o=await s.commitPlannerSelection({assignments:t.selectedAssignments,submitAfterCommit:!1});if(h(null==(e=s.getPlannerSnapshot)?void 0:e.call(s)),(null==o?void 0:o.validation)&&!1===o.validation.ok)throw Error(`commit validation failed:${!Array.isArray(r=o.validation.conflicts)||0===r.length?"unknown":r.map(e=>(null==e?void 0:e.message)||(null==e?void 0:e.type)||JSON.stringify(e)).join("; ")}`);let d=await (null==(i=s.applyPlannerDiscounts)?void 0:i.call(s,{customerId:a().id,preferredDiscountId:eVg(p.preferredDiscountId),applyBestDiscount:p.applyBestDiscount}));if(p.preferredDiscountId&&(null==d?void 0:d.preferredDiscountFound)!==!0)throw Error(`未找到指定券/折扣卡 ${p.preferredDiscountId}`);if(p.preferredDiscountId&&(null==d?void 0:d.preferredDiscountApplied)!==!0)throw Error(`指定券/折扣卡 ${p.preferredDiscountId} 未实际应用到预约商品`);let c=p.submitAfterCommit?await (null==(n=s.submitSalesOrder)?void 0:n.call(s)):void 0;if(p.submitAfterCommit&&!c)throw Error("已请求真实 submit,但没有拿到 submitResult,请检查 OrderModule submit");return{...o,submitResult:c,discount:d,submitRequested:p.submitAfterCommit,...p.submitAfterCommit?{}:{_submitSkipped:!0,reason:"submitAfterCommit=false,仅写入 tempOrder,没有调用 OrderModule submit"}}}}},o={id:"summary.refresh",label:"读取 summary / cart",description:"验证脱离正式 UI 后也能拿到订单数据",run:async()=>{var e,t,i;let a=await l();return{cart:null==(e=a.getCart)?void 0:e.call(a),summary:await (null==(t=a.getSummary)?void 0:t.call(a)),tempOrder:null==(i=a.getTempOrder)?void 0:i.call(a)}}},d=[{id:"module.resolve",label:"注册/获取 UnifiedBookingSales",description:`moduleKey=${k}`,run:async()=>{let e=await l();return{name:null==e?void 0:e.name,hasPlanner:"function"==typeof(null==e?void 0:e.loadPlannerContext),hasFlowSlots:"function"==typeof(null==e?void 0:e.resolveAssignableSlots),selectionOrder:p.selectionOrder}}},{id:"order.restore",label:"创建干净 tempOrder",description:"restoreOrder → addNewOrder,并同步当前优惠客户,避免沿用上一轮购物车",run:async()=>{var e,t,i;let n=await l();await (null==(e=n.restoreOrder)?void 0:e.call(n));let r=await (null==(t=n.addNewOrder)?void 0:t.call(n)),s=a();return s.id&&"function"==typeof n.updateOrderCustomer&&n.updateOrderCustomer({...s.source||{},customer_id:s.id}),{tempOrder:(null==(i=n.getTempOrder)?void 0:i.call(n))||r,discountCustomerId:s.id||null}}}];if("date_first"===p.selectionOrder)return[...d,{id:"date.availability",label:"拉取后端可用日期",description:"/schedule/product/availability/v2,校验场景日期是否可选",run:async()=>{var e;let i=await l();t.availableDates=await (null==(e=i.loadScheduleAvailableDate)?void 0:e.call(i,{startDate:p.dateRangeStart||p.date,endDate:p.dateRangeEnd||p.date,custom_page_id:eVg(p.customPageId),channel:b}))||[];let a=t.availableDates.find(e=>e.date===p.date);if(!a||"available"!==a.status)throw Error(`${p.date} 在后端可用日期接口中不可用`);return{selectedDate:a,total:t.availableDates.length}}},{id:"products.byDate",label:"按日期反推并拉取商品列表",description:"date_list.product_ids + other_product_ids 去重后拉商品",run:async()=>{var e;let i=await l();return t.loadedProducts=await (null==(e=i.loadProductsByScheduleDate)?void 0:e.call(i,{date:p.date,custom_page_id:eVg(p.customPageId),channel:b}))||[],{count:t.loadedProducts.length,products:t.loadedProducts.map(e=>({id:eVf(e),title:eVy(e)}))}}},{id:"products.filterByDayCells",label:"用当天平面图过滤不可预约商品",description:"普通商品保留;session/duration 当天无可用时间则剔除",run:async()=>{var e;let i=t.loadedProducts||[],a=eVk(i);await n({productIds:a,date:p.date,dateRange:{start:p.date,end:p.date},rawProducts:i});let r=await l(),s=await (null==(e=r.queryPlannerAvailability)?void 0:e.call(r,{mode:y,productIds:a,date:p.date,slotDurationMinutes:p.slotDurationMinutes}));t.dayProjection=s;let o=new Map(((null==s?void 0:s.productOptions)||[]).map(e=>[String(e.productId),e]));t.filteredProducts=i.filter(e=>{var t,l;if(!eVb(e)&&!(null==e||null==(l=e.extension_type)||null==(t=l.includes)?void 0:t.call(l,"session")))return!0;let i=o.get(String(eVf(e)));return(null==i?void 0:i.status)==="available"||(null==i?void 0:i.status)==="limited"});let d=eVk(t.filteredProducts),c=eVm(p.productIds).filter(e=>!d.some(t=>String(t)===String(e)));if(c.length)throw Error(`场景商品 ${c.join(",")} 不在 ${p.date} 的可用商品池中`);return{before:i.length,after:t.filteredProducts.length,selectedProductIds:eVm(p.productIds)}}},{id:"products.stage",label:"选中商品加入 tempOrder",description:"只 stage product,不创建 bookings",run:async()=>{var e;let i=await l(),a=eVm(p.productIds);if(!a.length)throw Error("请先填写至少一个商品 ID");t.selectedProductIds=a;let n=await (null==(e=i.stagePlannerProducts)?void 0:e.call(i,{productIds:a,rawProducts:eVx(t.filteredProducts||[],a),productLoadParams:{schedule_date:p.date}}));return{selectedProductIds:a,tempOrder:n}}},{id:"projection.range60",label:"生成选中日期前后 60 天平面图",description:"选中日期 -30 天到 +30 天",run:async()=>{var e,i,a;let r,s=(a=p.date,{start:(r=ef()(a||eVp())).subtract(30,"day").format(eVu),end:r.add(30,"day").format(eVu)}),o=t.selectedProductIds||eVm(p.productIds);await n({productIds:o,date:p.date,dateRange:s,rawProducts:eVx(t.filteredProducts||t.loadedProducts||[],o)});let d=await l(),c=await (null==(e=d.queryPlannerAvailability)?void 0:e.call(d,{mode:y,productIds:o,dateRange:s,slotDurationMinutes:p.slotDurationMinutes}));return t.rangeProjection=c,{range:s,dateSummary:null==c?void 0:c.dateSummary,cellCount:(null==c||null==(i=c.cells)?void 0:i.length)||0}}},{id:"slots.resolve",label:"进入资源分配并自动挑选可用 slot",description:"duration 商品按公共可用区间切片;session 商品按固定时间验证",run:async()=>{var e;let i=await l(),a=t.selectedProductIds||eVm(p.productIds),n=null==(e=i.resolveAssignableSlots)?void 0:e.call(i,{mode:y,productIds:a,date:p.date,slotDurationMinutes:p.slotDurationMinutes});return t.assignableSlots=(null==n?void 0:n.slots)||[],await r(a,t.assignableSlots),{slotCount:t.assignableSlots.length,selectedAssignments:t.selectedAssignments,conflicts:null==n?void 0:n.conflicts}}},s(),o];if("resource_first"===p.selectionOrder)return[...d,{id:"products.lockedResource.load",label:"拉取并过滤指定资源关联商品",description:"必须填写商品 ID、单个资源 ID、日期、开始时间;只保留 duration 商品",run:async()=>{var e;let a=await l(),n=eVm(p.productIds),r=eVm(p.resourceId);if(!n.length)throw Error("先选资源流程必须填写商品 ID");if(1!==r.length)throw Error("先选资源流程必须填写且只能填写一个资源 ID");if(!p.date||!p.startTime)throw Error("先选资源流程必须填写日期和开始时间");if(t.loadedProducts=await (null==(e=a.loadProducts)?void 0:e.call(a,{product_ids:i(),schedule_date:p.date}))||[],t.filteredProducts=t.loadedProducts.filter(e=>{var t,l;let i;return eVb(e)&&(t=r[0],(!Array.isArray(i=null==e||null==(l=e.product_resource)?void 0:l.resources)?[]:i.flatMap(e=>[...Array.isArray(null==e?void 0:e.default_resource)?e.default_resource:[],...Array.isArray(null==e?void 0:e.optional_resource)?e.optional_resource:[]]).map(e=>String(e))).includes(String(t)))}),t.selectedProductIds=eVk(t.filteredProducts),!t.selectedProductIds.length)throw Error(`没有 duration 商品关联资源 ${r[0]}`);return{loaded:t.loadedProducts.length,kept:t.filteredProducts.map(e=>({id:eVf(e),title:eVy(e)}))}}},{id:"projection.lockedResource",label:"生成指定日期/资源平面图",description:"锁定指定 resourceId,只查询这一天",run:async()=>{var e,i;let a=t.selectedProductIds||[];await n({productIds:a,resourceIds:eVm(p.resourceId),date:p.date,dateRange:{start:p.date,end:p.date},rawProducts:t.filteredProducts});let r=await l(),s=await (null==(e=r.queryPlannerAvailability)?void 0:e.call(r,{mode:y,productIds:a,resourceIds:eVm(p.resourceId),date:p.date,slotDurationMinutes:p.slotDurationMinutes}));return t.dayProjection=s,{cellCount:(null==s||null==(i=s.cells)?void 0:i.length)||0,resourceOptions:null==s?void 0:s.resourceOptions}}},{id:"slots.validateLockedTime",label:"用开始时间 + duration 校验资源可用",description:"可用则生成可直接提交的 assignments",run:async()=>{var e;let i=await l(),a=t.selectedProductIds||[],n=null==(e=i.resolveAssignableSlots)?void 0:e.call(i,{mode:y,productIds:a,resourceIds:eVm(p.resourceId),date:p.date,startTime:p.startTime,slotDurationMinutes:p.slotDurationMinutes});return t.assignableSlots=(null==n?void 0:n.slots)||[],await r(a,t.assignableSlots),{slotCount:t.assignableSlots.length,selectedAssignments:t.selectedAssignments,conflicts:null==n?void 0:n.conflicts}}},s(),o];let c={start:e=eVp(),end:ef()(e).add(31,"day").format(eVu)};return[...d,{id:"products.loadByIds",label:"按商品 ID 拉取商品列表",description:"product_first 只按场景参数商品 ID 拉取",run:async()=>{var e;let a=await l(),n=eVm(p.productIds);if(!n.length)throw Error("请先填写至少一个商品 ID");return t.loadedProducts=await (null==(e=a.loadProducts)?void 0:e.call(a,{product_ids:i(),schedule_date:p.date}))||[],t.selectedProductIds=n,{count:t.loadedProducts.length,products:t.loadedProducts.map(e=>({id:eVf(e),title:eVy(e)}))}}},{id:"products.stageAndMonthProjection",label:"stage 商品并生成 31 天平面图",description:"商品加入 tempOrder 后,从今天开始往后 31 天计算 projection",run:async()=>{var e,i,a;let r=await l(),s=t.selectedProductIds||eVm(p.productIds),o=await (null==(e=r.stagePlannerProducts)?void 0:e.call(r,{productIds:s,rawProducts:t.loadedProducts,productLoadParams:{schedule_date:p.date}}));await n({productIds:s,dateRange:c,rawProducts:t.loadedProducts});let d=await (null==(i=r.queryPlannerAvailability)?void 0:i.call(r,{mode:y,productIds:s,dateRange:c,slotDurationMinutes:p.slotDurationMinutes}));return t.rangeProjection=d,{range:c,tempOrder:o,dateSummary:null==d?void 0:d.dateSummary,cellCount:(null==d||null==(a=d.cells)?void 0:a.length)||0}}},{id:"date.pickFromProjection",label:"选择日期并校验是否可用",description:"日期可用性来自步骤 4 的 projection.dateSummary",run:async()=>{var e;let l=((null==(e=t.rangeProjection)?void 0:e.dateSummary)||[]).find(e=>e.date===p.date);if(!l||"available"!==l.status&&"limited"!==l.status)throw Error(`${p.date} 在当前商品平面图中不可选`);return l}},{id:"slots.resolve",label:"进入资源分配并自动挑选可用 slot",description:"duration 商品按公共可用区间切片;session 商品按固定时间验证",run:async()=>{var e;let i=t.selectedProductIds||eVm(p.productIds);await n({productIds:i,date:p.date,dateRange:{start:p.date,end:p.date},rawProducts:t.loadedProducts});let a=await l(),s=null==(e=a.resolveAssignableSlots)?void 0:e.call(a,{mode:y,productIds:i,date:p.date,slotDurationMinutes:p.slotDurationMinutes});return t.assignableSlots=(null==s?void 0:s.slots)||[],await r(i,t.assignableSlots),{slotCount:t.assignableSlots.length,selectedAssignments:t.selectedAssignments,conflicts:null==s?void 0:s.conflicts}}},s(),o]},[p,x,y,k,s,o]);return(0,eO.jsxs)("section",{className:"sales-sdk-demo__tab",children:[(0,eO.jsxs)("header",{className:"sales-sdk-demo__panel sales-sdk-demo__panel--warn",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"用户端预约 Planner Demo"}),(0,eO.jsx)("span",{children:k})]}),(0,eO.jsx)("p",{className:"sales-sdk-demo__hint",children:"这个 Demo 不做正式皮肤,只用步骤驱动 PisellOS UnifiedBookingSales。 商品、资源、日期、选择顺序都可以手动输入,用来验证 planner 和下单闭环。"})]}),(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"场景参数"}),(0,eO.jsx)("span",{children:y})]}),(0,eO.jsxs)("div",{className:"sales-sdk-demo__scenario-grid",children:[(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"商品 ID,逗号分隔"}),(0,eO.jsx)("input",{value:p.productIds,placeholder:"例如 61321",onChange:e=>_("productIds",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"指定资源 ID,填写后等价扫码点餐锁资源入口"}),(0,eO.jsx)("input",{value:p.resourceId,placeholder:"例如 41077",onChange:e=>_("resourceId",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"优惠客户 ID(留空读取当前登录客户)"}),(0,eO.jsx)("input",{value:p.discountCustomerId,placeholder:"登录后自动读取",onChange:e=>_("discountCustomerId",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"优先券/折扣卡 ID(可选)"}),(0,eO.jsx)("input",{value:p.preferredDiscountId,placeholder:"先跑一次可从结果中读取",onChange:e=>_("preferredDiscountId",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"日期"}),(0,eO.jsx)("input",{value:p.date,onChange:e=>_("date",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"开始时间"}),(0,eO.jsx)("input",{value:p.startTime,onChange:e=>_("startTime",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"查询开始日期"}),(0,eO.jsx)("input",{value:p.dateRangeStart,onChange:e=>_("dateRangeStart",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"查询结束日期"}),(0,eO.jsx)("input",{value:p.dateRangeEnd,onChange:e=>_("dateRangeEnd",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"custom_page_id(可用日期接口)"}),(0,eO.jsx)("input",{value:p.customPageId,placeholder:"例如 199665",onChange:e=>_("customPageId",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"availability channel"}),(0,eO.jsx)("input",{value:p.channel,placeholder:"pc",onChange:e=>_("channel",e.target.value)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"选择顺序"}),(0,eO.jsxs)("select",{value:p.selectionOrder,onChange:e=>{var t;return t=e.target.value,void m(e=>{let l;if("resource_first"!==t)return{...e,selectionOrder:t};let i={date:(l=ef()()).format(eVu),startTime:l.format("HH:mm")};return{...e,selectionOrder:t,date:i.date,startTime:i.startTime,dateRangeStart:i.date,dateRangeEnd:i.date}})},children:[(0,eO.jsx)("option",{value:"product_first",children:"先选商品"}),(0,eO.jsx)("option",{value:"date_first",children:"先选日期"}),(0,eO.jsx)("option",{value:"resource_first",children:"先选资源"})]})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"时间切片分钟"}),(0,eO.jsx)("input",{value:p.slotDurationMinutes,onChange:e=>_("slotDurationMinutes",Number(e.target.value)||10)})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__checkbox",children:[(0,eO.jsx)("input",{type:"checkbox",checked:p.useResourceDateApi,onChange:e=>_("useResourceDateApi",e.target.checked)}),(0,eO.jsx)("span",{children:"使用资源日期接口"})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__checkbox",children:[(0,eO.jsx)("input",{type:"checkbox",checked:p.submitAfterCommit,onChange:e=>_("submitAfterCommit",e.target.checked)}),(0,eO.jsx)("span",{children:"commit 后真实提交订单"})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__checkbox",children:[(0,eO.jsx)("input",{type:"checkbox",checked:p.applyBestDiscount,onChange:e=>_("applyBestDiscount",e.target.checked)}),(0,eO.jsx)("span",{children:"提交后加载并应用最优商品券/折扣卡"})]})]}),p.useResourceDateApi?null:(0,eO.jsxs)("label",{className:"sales-sdk-demo__field sales-sdk-demo__field--wide",children:[(0,eO.jsx)("span",{children:"rawResources JSON"}),(0,eO.jsx)("textarea",{className:"sales-sdk-demo__textarea",rows:8,value:p.rawResourcesJson,onChange:e=>_("rawResourcesJson",e.target.value)})]})]}),(0,eO.jsx)(eVn,{title:"Planner 场景步骤",steps:S,oneClickLabel:"跑完整 planner case",toolbarExtra:(0,eO.jsx)("button",{type:"button",onClick:()=>{var e,t;let l=null==r?void 0:r.action;"function"!=typeof l?f("[SalesSdk Demo] appHelper.utils.action 不可用,无法拉起登录"):(f(null),null==r||null==(t=r.pubsub)||null==(e=t.once)||e.call(t,"pisell1.login.success",()=>{w()}),l({type:"pisell1.login",data:{notReload:!0,type:"plugin"},callback:()=>{w()}}))},children:c?"已登录":"登录"})}),v?(0,eO.jsx)("pre",{className:"sales-sdk-demo__step-error",children:v}):null,(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"最近 Planner Snapshot"}),(0,eO.jsx)("span",{children:"debug"})]}),(0,eO.jsx)("pre",{children:JSON.stringify(g,null,2)})]})]})},eVw="shop",eVj="online_store",eVS="unifiedBookingSales-demo-retail";function eVN(e){let t=Number(e);return Number.isFinite(t)?t:null}function eVM(e){return(null==e?void 0:e.id)??(null==e?void 0:e.product_id)}let eVC=()=>{var e;let t=eI(),l=null==t||null==(e=t.appHelper)?void 0:e.utils,i=null==l?void 0:l.pisellos,a=null==l?void 0:l.pisellosAllModule,n=eVc(null==l?void 0:l.promotionEvaluator),[r,s]=(0,ex.useState)({productId:"61168",quantity:2,expectedProductAmount:"10"}),[o,d]=(0,ex.useState)(null),c=async()=>{var e;if(!(null==i?void 0:i.getModule)||!(null==i?void 0:i.registerModule))throw Error("当前页面没有可用 pisellos runtime");let t=i.getModule(eVS);if(t)return await (null==(e=t.setOtherParams)?void 0:e.call(t,{platform:eVw,channel:eVj,businessCode:"retail"})),n(t);let l=(null==a?void 0:a.UnifiedBookingSalesImpl)||(null==a?void 0:a.UnifiedBookingSales);if(!l)throw Error("当前 pisellosAllModule 未导出 UnifiedBookingSalesImpl,请先升级/链接 pisell_os");return t=new l(eVS),i.registerModule(t,{otherParams:{cacheId:eVS,platform:eVw,channel:eVj,businessCode:"retail",enableTempOrderPersist:!1}}),n(t)},u=(0,ex.useMemo)(()=>{let e={},t=Number(r.productId),i=async()=>(e.module=e.module||await c(),e.module),a=async e=>{var l,i,a,n,r;let s,o;return{...{productTotal:(o=Array.isArray((s=(null==(a=e.getTempOrder)?void 0:a.call(e))||{}).products)?s.products:[],o.filter(e=>Number((null==e?void 0:e.product_id)??(null==e?void 0:e.id))===t).reduce((e,t)=>{var l;return e+(eVN((null==t||null==(l=t.metadata)?void 0:l.main_product_selling_price)??(null==t?void 0:t.selling_price)??(null==t?void 0:t.price))||0)*(eVN((null==t?void 0:t.num)??(null==t?void 0:t.quantity))||1)},0)),promotionLines:o.filter(e=>Number((null==e?void 0:e.product_id)??(null==e?void 0:e.id))===t).map(e=>{var t;return{productId:(null==e?void 0:e.product_id)??(null==e?void 0:e.id),quantity:null==e?void 0:e.num,sellingPrice:null==e?void 0:e.selling_price,promotion:null==e||null==(t=e.metadata)?void 0:t._promotion}}),giftActions:null==(n=e.getLastGiftActions)?void 0:n.call(e),unfulfilledPromotions:null==(r=e.getUnfulfilledPromotions)?void 0:r.call(e),tempOrder:s},summary:await (null==(l=e.getSummary)?void 0:l.call(e)),cart:null==(i=e.getCart)?void 0:i.call(e)}};return[{id:"retail.module.resolve",label:"注册/获取 UnifiedBookingSales",description:"绑定 promotion evaluator 与赠品 resolver;不初始化 planner",run:async()=>{var e,t;let a=await i();"function"==typeof(null==l?void 0:l.loadPromotionStrategies)&&await l.loadPromotionStrategies(),n(a);let r=(null==l||null==(t=l.promotionEvaluator)||null==(e=t.getStrategyConfigs)?void 0:e.call(t))||[];return{name:null==a?void 0:a.name,hasPlanner:"function"==typeof(null==a?void 0:a.queryPlannerAvailability),evaluatorAvailable:!!(null==l?void 0:l.promotionEvaluator),giftResolverAvailable:"function"==typeof(null==a?void 0:a.setGiftSelectResolver),strategyConfigCount:Array.isArray(r)?r.length:null}}},{id:"retail.order.create",label:"创建干净零售 tempOrder",description:"不创建 booking,不拉取资源或平面图",run:async()=>{var e,t;let l=await i();return await (null==(e=l.restoreOrder)?void 0:e.call(l)),{tempOrder:await (null==(t=l.addNewOrder)?void 0:t.call(l))}}},{id:"retail.product.load",label:"拉取普通商品",description:"商品不需要 session、duration 或资源关联",run:async()=>{var l,a,n,r,s;let o;if(!Number.isFinite(t)||t<=0)throw Error("请填写有效商品 ID");let d=await i();if(e.product=(await (null==(l=d.loadProducts)?void 0:l.call(d,{product_ids:[t]}))||[]).find(e=>Number(eVM(e))===t),!e.product)throw Error(`没有加载到商品 ${t}`);return{id:eVM(e.product),title:"string"==typeof(o=(null==(s=e.product)?void 0:s.title)||(null==s?void 0:s.name)||(null==s?void 0:s.product_title))?o:o&&"object"==typeof o?o.en||o.zh||o.default||String(Object.values(o)[0]||"Untitled product"):`Product #${eVM(s)??"-"}`,price:null==(a=e.product)?void 0:a.price,duration:null==(n=e.product)?void 0:n.duration,resourceRelation:null==(r=e.product)?void 0:r.product_resource}}},{id:"retail.cart.stage",label:"加入零售购物车",description:"仅写普通商品行;不创建 bookings",run:async()=>{var l,a,n;let r=await i();await (null==(l=r.stageRetailProducts)?void 0:l.call(r,{productIds:[t],rawProducts:[e.product]}));let s=(null==(a=r.getTempOrder)?void 0:a.call(r))||{};if(e.line=(s.products||[]).find(e=>Number((null==e?void 0:e.product_id)??(null==e?void 0:e.id))===t),!e.line)throw Error(`商品 ${t} 未写入 tempOrder`);return{line:e.line,bookingCount:(null==(n=s.bookings)?void 0:n.length)||0}}},{id:"retail.promotion.apply",label:"设置数量并验证营销策略",description:"数量写路径会自动计算;这里额外显式 applyPromotion 以便观察结果",run:async()=>{var t,l,n,s;if(!Number.isFinite(r.quantity)||r.quantity<1)throw Error("数量必须大于 0");let o=await i();await (null==(t=o.updateOrderProductQuantity)?void 0:t.call(o,{...{product_id:Number((null==(n=e.line)?void 0:n.product_id)??(null==n?void 0:n.id)),product_variant_id:Number((null==n?void 0:n.product_variant_id)??0),unique_identification_number:(null==n||null==(s=n.metadata)?void 0:s.unique_identification_number)||(null==n?void 0:n.unique_identification_number),product_sku:null==n?void 0:n.product_sku,product_bundle:null==n?void 0:n.product_bundle},num:r.quantity})),await (null==(l=o.applyPromotion)?void 0:l.call(o));let c=await a(o),u=eVN(r.expectedProductAmount);if(null!==u&&Math.abs(c.productTotal-u)>.01)throw Error(`营销策略未达到预期:商品合计 ${c.productTotal.toFixed(2)},期望 ${u.toFixed(2)}`);return d(c),{...c,verified:null===u||.01>=Math.abs(c.productTotal-u)}}},{id:"retail.summary.read",label:"读取零售 cart / summary",description:"确认没有 booking,保留促销行、赠品动作和总价诊断",run:async()=>{let e=await i(),t=await a(e);return d(t),t}}]},[r,n,i,a,null==l?void 0:l.promotionEvaluator]),p=async()=>{var e,t;let l=await c();await (null==(e=l.restoreOrder)?void 0:e.call(l)),await (null==(t=l.addNewOrder)?void 0:t.call(l)),d(null)};return(0,eO.jsxs)("section",{className:"sales-sdk-demo__tab",children:[(0,eO.jsxs)("header",{className:"sales-sdk-demo__panel sales-sdk-demo__panel--warn",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"零售 UnifiedBookingSales Demo"}),(0,eO.jsx)("span",{children:"retail / no planner required"})]}),(0,eO.jsx)("p",{className:"sales-sdk-demo__hint",children:"用 UnifiedBookingSales 的购物车和营销能力测试普通零售商品。不会请求资源、生成平面图或创建 booking。"})]}),(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"测试参数"}),(0,eO.jsx)("span",{children:"默认用 61168 x 2 验证两件价 10"})]}),(0,eO.jsxs)("div",{className:"sales-sdk-demo__field-grid",children:[(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"商品 ID"}),(0,eO.jsx)("input",{value:r.productId,onChange:e=>s(t=>({...t,productId:e.target.value}))})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"数量"}),(0,eO.jsx)("input",{value:r.quantity,onChange:e=>s(t=>({...t,quantity:Number(e.target.value)||1}))})]}),(0,eO.jsxs)("label",{className:"sales-sdk-demo__field",children:[(0,eO.jsx)("span",{children:"期望商品合计"}),(0,eO.jsx)("input",{value:r.expectedProductAmount,onChange:e=>s(t=>({...t,expectedProductAmount:e.target.value}))})]})]})]}),(0,eO.jsx)(eVn,{title:"零售策略步骤",oneClickLabel:"验证零售营销策略",steps:u,onReset:p}),(0,eO.jsxs)("section",{className:"sales-sdk-demo__panel",children:[(0,eO.jsxs)("div",{className:"sales-sdk-demo__section-title",children:[(0,eO.jsx)("h3",{children:"最近零售结果"}),(0,eO.jsx)("span",{children:"debug"})]}),(0,eO.jsx)("pre",{className:"sales-sdk-demo__snapshot",children:JSON.stringify(o,null,2)})]})]})},eVT="sales-sdk-demo",eVP=function(e){var t;let{osKey:l=eVT,orderId:i,businessCode:a,otherParams:n,rulesHooks:r,className:s}=e,o=["sales-sdk-demo",s].filter(Boolean).join(" "),d=l||eVT,c={businessCode:a,otherParams:n,rulesHooks:r,autoBootstrap:!1};return(null==(t=c.otherParams)?void 0:t.platform)||(c.otherParams={platform:"shop"}),(0,eO.jsx)("div",{className:o,children:(0,eO.jsx)(e_.Tabs,{className:"sales-sdk-demo__tabs",defaultActiveKey:"create",destroyInactiveTabPane:!0,items:[{key:"detail",label:"详情展示",children:(0,eO.jsx)(e__,{osKey:`${d}-detail`,...c,children:(0,eO.jsx)(eVe,{initialOrderId:i??eHK.orderId})})},{key:"create",label:"新建",children:(0,eO.jsx)(eHG,{osKey:`${d}-create`,...c,children:(0,eO.jsx)(eVo,{})})},{key:"edit",label:"编辑",children:(0,eO.jsx)(eHG,{osKey:`${d}-edit`,...c,children:(0,eO.jsx)(eVd,{initialOrderId:i??eHJ.orderId})})},{key:"planner-appointment",label:"用户端预约",children:(0,eO.jsx)(eHG,{osKey:`${d}-planner-appointment`,...c,businessCode:c.businessCode||"appointment",autoInitBookingContext:!1,autoRestoreOnInit:!1,children:(0,eO.jsx)(eV_,{})})},{key:"unified-retail",label:"零售模板",children:(0,eO.jsx)(eHG,{osKey:`${d}-unified-retail`,...c,businessCode:c.businessCode||"retail",autoInitBookingContext:!1,autoRestoreOnInit:!1,children:(0,eO.jsx)(eVC,{})})}]})})};function eVA(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,l=Number(e);return Number.isNaN(l)?t:l}function eVI(e){let t=Math.floor(Number(e));return Number.isNaN(t)||t<1?1:t}function eVD(e){if("string"==typeof e)return e.trim();if(!e||"object"!=typeof e||Array.isArray(e))return"";for(let t of["auto","original","en","zh-CN","zh-HK","ja","pt"]){let l=e[t];if("string"==typeof l&&l.trim())return l.trim()}let t=Object.values(e).find(e=>"string"==typeof e&&e.trim());return"string"==typeof t?t.trim():""}function eVE(e){let{orderProducts:t,amountSymbol:l="$"}=e;return Array.isArray(t)?t.map((e,t)=>{var i,a,n,r,s,o,d,c,u,p,m,g,h,v;let f,y,b,x,k,_,w,j,S,N,M,C,T,P=eVI(null==e?void 0:e.num),A=(y=(null==(f=(null==e||null==(o=e._origin)?void 0:o.callbackData)||{})?void 0:f.origin)||{},b=(null==e||null==(d=e._origin)?void 0:d.sourceItem)||{},eVA(e.selling_price,NaN)||eVA(e.original_price,NaN)||eVA(null==f?void 0:f.price,NaN)||eVA(null==y?void 0:y.price,NaN)||eVA(null==b?void 0:b.price,0)),I=(null==e||null==(i=e._origin)?void 0:i.callbackData)||{},D=[null==e||null==(a=e.metadata)?void 0:a.unique_identification_number,null==e?void 0:e.unique_identification_number,null==e?void 0:e.identity_key].find(e=>"string"==typeof e&&e.length>0),E=D??`${e.product_id??"p"}_${e.product_variant_id}_${t}`,z=("string"==typeof(null==I?void 0:I.product_option_string)?I.product_option_string.trim():"")||function(e){var t,l,i;let a=null==e?void 0:e.product_variant_id;if(null==a||""===a||0>=Number(a))return"";let n=(null==e||null==(t=e.metadata)?void 0:t.origin)||(null==e||null==(i=e._origin)||null==(l=i.callbackData)?void 0:l.origin)||{},r=(Array.isArray(null==n?void 0:n.variant)?n.variant:[]).find(e=>Number(null==e?void 0:e.id)===Number(a));if(!r)return"";let s=null==r?void 0:r.sku_ids;if(null!=s&&""!==String(s).trim()){let e=function(e,t){let l=Array.isArray(null==e?void 0:e.variant_group)?e.variant_group:[],i=[];for(let e of String(t||"").split("_").map(e=>e.trim()).filter(Boolean)){let t=e.indexOf(":");if(t<=0)continue;let a=Number(e.slice(0,t)),n=Number(e.slice(t+1));if(Number.isNaN(a)||Number.isNaN(n))continue;let r=function(e,t){return e.find(e=>Number(null==e?void 0:e.id)===Number(t))}(l,a);if(!r)continue;let s=String((null==r?void 0:r.name)??"").trim(),o=function(e,t){let l=(Array.isArray(null==e?void 0:e.variant_item)?e.variant_item:[]).find(e=>Number(null==e?void 0:e.id)===Number(t));return String((null==l?void 0:l.name)??("string"==typeof(null==l?void 0:l.title)?l.title:null==l?void 0:l.title)??""??"").trim()}(r,n);s&&o?i.push(`${s}: ${o}`):o?i.push(o):s&&i.push(s)}return i.join(", ")}(n,String(s));if(e)return e}return function(e,t){let l=Array.isArray(null==e?void 0:e.variant_group)?e.variant_group:[],i=(null==t?void 0:t.name)||(null==t?void 0:t.title);if(!i||"object"!=typeof i)return"";let a=[];for(let e of l){let t=null==e?void 0:e.position_id;if(null==t)continue;let l=i[String(t)]??i[t];if(null==l||""===l)continue;let n=String((null==e?void 0:e.name)??"").trim(),r=String(l).trim();n&&r?a.push(`${n}: ${r}`):r&&a.push(r)}return a.length?a.join(", "):Object.values(i).filter(e=>null!=e&&""!==String(e).trim()).map(e=>String(e).trim()).join(" / ")}(n,r)}(e)||void 0,O={_id:E,rowKey:E,identity_key:D,id:e.product_id,product_id:e.product_id,product_variant_id:e.product_variant_id,note:(null==e?void 0:e.note)!=null?String(e.note):"",name:(_=(null==(k=(null==(x=(null==e?void 0:e._origin)||{})?void 0:x.callbackData)||{})?void 0:k.origin)||{},w=(null==x?void 0:x.sourceItem)||{},eVD(null==e?void 0:e.product_title)||eVD(null==e||null==(c=e.metadata)?void 0:c.product_title)||eVD(null==k?void 0:k.product_title)||eVD(null==_?void 0:_.product_title)||eVD(null==w?void 0:w.product_title)||eVD(null==x?void 0:x.product_title)||eVD(null==k?void 0:k.name)||eVD(null==k?void 0:k.title)||eVD(null==_?void 0:_.name)||eVD(null==_?void 0:_.title)||eVD(null==w?void 0:w.name)||eVD(null==w?void 0:w.title)||eVD(null==x?void 0:x.name)||eVD(null==x?void 0:x.title)||(null==x||null==(p=x.resources)||null==(u=p[0])?void 0:u.main_field)||(null==e||null==(m=e.metadata)?void 0:m.resource_name)||`Product #${e.product_id??"unknown"}`),image:(N=(null==(S=(null==(j=(null==e?void 0:e._origin)||{})?void 0:j.callbackData)||{})?void 0:S.origin)||{},M=(null==j?void 0:j.sourceItem)||{},(null==S?void 0:S.image)||(null==S?void 0:S.cover)||(null==N?void 0:N.image)||(null==N?void 0:N.cover)||(null==M?void 0:M.image)||(null==M?void 0:M.cover)||(null==j?void 0:j.image)||(null==j?void 0:j.cover)||""),num:P,price:A,total:A,origin_total:eVA(e.original_price,A),symbol:l,options:(C=(null==e||null==(g=e._origin)?void 0:g.callbackData)||{},(Array.isArray(null==e||null==(h=e.product_sku)?void 0:h.option)?e.product_sku.option:Array.isArray(null==e?void 0:e.product_option_item)?e.product_option_item:Array.isArray(null==C?void 0:C.option)?C.option:[]).map(e=>{let t=eVA((null==e?void 0:e.add_price)??(null==e?void 0:e.price),0),l=eVI(null==e?void 0:e.num);return{id:eVA((null==e?void 0:e.product_option_item_id)??(null==e?void 0:e.option_group_item_id)),name:(null==e?void 0:e.name)||(null==e?void 0:e.title)||(null==e?void 0:e.label)||(null==e?void 0:e.option_group_item_name)||"",num:l,price:t,total:t*l,origin_total:t*l}})),bundle:(Array.isArray(null==(T=(null==e||null==(v=e._origin)?void 0:v.callbackData)||{})?void 0:T.bundle)?T.bundle:(null==e?void 0:e.product_bundle)||[]).map((e,t)=>{let l=eVA((null==e?void 0:e.price)??(null==e?void 0:e.product_price)??(null==e?void 0:e.custom_price),0),i=eVI(null==e?void 0:e.num),a=Array.isArray(null==e?void 0:e.option)?e.option:[];return{id:eVA((null==e?void 0:e.id)??(null==e?void 0:e.bundle_product_id),t),name:(null==e?void 0:e.name)||(null==e?void 0:e.title)||"",num:i,price:l,total:l*i,origin_total:l*i,options:a.map(e=>{let t=eVA((null==e?void 0:e.add_price)??(null==e?void 0:e.price),0),l=eVI(null==e?void 0:e.num);return{id:eVA((null==e?void 0:e.product_option_item_id)??(null==e?void 0:e.option_group_item_id)),name:(null==e?void 0:e.name)||(null==e?void 0:e.title)||(null==e?void 0:e.label)||(null==e?void 0:e.option_group_item_name)||"",num:l,price:t,total:t*l,origin_total:t*l}})}}),_origin:null==e?void 0:e._origin,isNormalProduct:!0,...z?{product_option_string:z}:{}};if(e.product_sku?O.product_sku=e.product_sku:Array.isArray(e.product_option_item)&&e.product_option_item.length&&(O.product_option_item=e.product_option_item),Array.isArray(e.product_bundle)&&e.product_bundle.length&&(O.product_bundle=e.product_bundle),null==e||null==(n=e.metadata)?void 0:n.venue_booking){let t=e._origin||{},l=e.metadata||{},i=t.start_date,a=t.start_time,n=t.end_date,o=t.end_time;O.start_date=i&&a?`${i} ${a}`:l.start_time||"",O.end_date=n&&o?`${n} ${o}`:l.end_time||"",O.start_time=a||"",O.end_time=o||"",O.duration_type=t.sub_type||"minutes",O.resource_id=l.resource_id,O.relation_form_name=l.resource_name||(null==(s=t.resources)||null==(r=s[0])?void 0:r.main_field)||"",Array.isArray(t.resources)&&(O.resources=t.resources)}return O}):[]}let eVz=["init","product","check","error"],eVO=()=>{var e;let t=eI();return(null==t||null==(e=t.appHelper)?void 0:e.utils)||{}};function eVL(e,t,l){if("function"!=typeof(null==e?void 0:e[t]))return l;let i=e[t]();return i&&"function"==typeof(null==i?void 0:i.then)?l:i??l}async function eV$(e,t){for(var l=arguments.length,i=Array(l>2?l-2:0),a=2;a<l;a++)i[a-2]=arguments[a];if(!e)throw Error("scanOrder module not found");if("function"!=typeof(null==e?void 0:e[t]))throw Error(`scanOrder action "${t}" not found`);return e[t](...i)}let eVR=()=>{var e,t;let l=eVO();return{isLogin:!!(null==l||null==(t=l.token)||null==(e=t.get)?void 0:e.call(t)),openLoginModal:e=>{let{callback:t}=e||{},{pubsub:i}=l;i.once("pisell1.login.success",e=>{"success"===e&&t(e),t("close")}),l.action({type:"pisell1.login",data:{notReload:!0,type:"plugin"},callback:t})}}},eVF=(0,ex.createContext)(void 0),eVB={menuItems:[],cartItems:[],summary:{},note:""};function eVq(e){var t;let l,{entryContext:i,children:a}=e,n=eD(),r=null==(l=eD())||null==(t=l.getModule)?void 0:t.call(l,"scanOrder"),[s,o]=(0,ex.useState)(!0),[d,c]=(0,ex.useState)(""),[u,p]=(0,ex.useState)("init"),[m,g]=(0,ex.useState)(eVB),[h,v]=(0,ex.useState)({passed:null,failures:[]}),[f,y]=(0,ex.useState)(String(eP.getText("pisell2.scan.order.action.select.required")||"")),[b,x]=(0,ex.useState)(""),[k,_]=(0,ex.useState)("default"),[w,j]=(0,ex.useState)(""),[S,N]=(0,ex.useState)([]),[M,C]=(0,ex.useState)(!1),[T,P]=(0,ex.useState)(null),A=(0,ex.useRef)(!1),I=[...eVz],D=(0,ex.useCallback)(e=>{var t;let l=null==r||null==(t=r.getUIState)?void 0:t.call(r,"gate");return!!(null==l?void 0:l[e])},[r]),E=(0,ex.useCallback)(e=>{var t;if(!(null==r?void 0:r.setUIState))return;let l=(null==(t=r.getUIState)?void 0:t.call(r,"gate"))||{};r.setUIState("gate",{...l,[e]:!0})},[r]),z=(0,ex.useCallback)(()=>{var e;null==r||null==(e=r.clearUIState)||e.call(r),P(null)},[r]),O=(0,ex.useCallback)(()=>{P(null)},[]),L=async()=>{var e;let t,l,i,a,n,s,o,d=null;if(r&&"function"==typeof r.getSummary)try{d=await r.getSummary()}catch(e){console.warn("[scanOrder] getSummary failed during refreshViewModel",e)}g((e=d,t=eVL(r,"getMenu",[]),l=eVL(r,"getOrderProducts",[]),i=void 0===e?eVL(r,"getSummary",null):e,n=(null==(a=eVL(r,"getTempOrder",null))?void 0:a.currency_symbol)||"$",s=eVE({orderProducts:Array.isArray(l)?l:[],amountSymbol:n}),o=(i&&"object"==typeof i?i:null)||(null==a?void 0:a.summary)||{},{menuItems:Array.isArray(t)?t:[],cartItems:Array.isArray(s)?s:[],summary:o&&"object"==typeof o?o:{},note:String((null==a?void 0:a.note)||"")})),r&&"function"==typeof r.getDiscountList&&N(r.getDiscountList()||[])},$=async e=>{await eV$(r,"updateTempOrderNote",e),await L()},R=e=>{I.includes(e)&&p(e)},F=()=>{let e=I.findIndex(e=>e===u);e<0||e>=I.length-1||p(I[e+1])},B=()=>{let e=I.findIndex(e=>e===u);e<=0||p(I[e-1])},q=async function(e){for(var t=arguments.length,l=Array(t>1?t-1:0),i=1;i<t;i++)l[i-1]=arguments[i];return eV$(r,e,...l)};(0,ex.useEffect)(()=>{var e,t,l,a,n,s;if(A.current||!r)return;A.current=!0;let o=String((null==i?void 0:i.resource_id)??""),d=String((null==i?void 0:i.biz)??""),c=!!(null==i?void 0:i.order_id),u=null==(e=r.getUIState)?void 0:e.call(r,"entryContext");if(!(u&&String((null==u?void 0:u.resourceId)??"")===o&&String((null==u?void 0:u.biz)??"")===d)){null==(a=r.clearUIState)||a.call(r),null==(n=r.setUIState)||n.call(r,"entryContext",{resourceId:o,hasOrderId:c,biz:d}),C(!0);return}let p=e=>"product"===e||"check"===e,m=null==(t=r.getUIState)?void 0:t.call(r,"pendingStep");if(p(m)){null==(s=r.deleteUIState)||s.call(r,"pendingStep"),P(m),C(!0);return}let g=null==(l=r.getUIState)?void 0:l.call(r,"step");p(g)&&P(g),C(!0)},[r,null==i?void 0:i.resource_id,null==i?void 0:i.order_id,null==i?void 0:i.biz]),(0,ex.useEffect)(()=>{var e;A.current&&M&&r&&"init"!==u&&(null==(e=r.setUIState)||e.call(r,"step",u))},[u,M,r]),(0,ex.useEffect)(()=>{var e,t;if(!r)return;let l=!1,i=e=>{let t=null==e?void 0:e.cartValidation;v({passed:"boolean"==typeof(null==t?void 0:t.passed)||(null==t?void 0:t.passed)===null?t.passed:"boolean"==typeof(null==e?void 0:e.cartValidationPassed)?e.cartValidationPassed:null,failures:Array.isArray(null==t?void 0:t.failures)?t.failures:[]})};return(async()=>{try{let e=await eV$(r,"getCartValidation");l||v({passed:"boolean"==typeof(null==e?void 0:e.passed)||(null==e?void 0:e.passed)===null?e.passed:null,failures:Array.isArray(null==e?void 0:e.failures)?e.failures:[]})}catch(e){l||v({passed:null,failures:[]})}})(),null==n||null==(t=n.effects)||null==(e=t.on)||e.call(t,"scanOrder:onCartValidationChanged",i),()=>{var e,t;l=!0,null==n||null==(t=n.effects)||null==(e=t.off)||e.call(t,"scanOrder:onCartValidationChanged",i)}},[n,r]),(0,ex.useEffect)(()=>{let e=!1;return(async()=>{try{if(!r){c("scanOrder module not ready"),o(!1);return}if(!("function"!=typeof r.checkAccess||await r.checkAccess(i)))throw Error("scanOrder access denied");"function"==typeof r.getPageConfig&&await r.getPageConfig(i),await L(),e||(c(""),o(!1))}catch(t){e||(c((null==t?void 0:t.message)||"scanOrder load failed"),o(!1))}})(),()=>{e=!0}},[r,null==i?void 0:i.biz,null==i?void 0:i.resource_id]);let H=(0,ex.useMemo)(()=>({entryContext:i,scanOrderModule:r,cartValidation:h,isLoading:s,errorMessage:d,currentStep:u,stepList:I,viewModel:m,footerActionText:f,tableName:b,entryMode:k,submitDisabledTips:w,discountList:S,isReady:!s&&!d,setCurrentStep:p,goToStep:R,nextStep:F,prevStep:B,refreshViewModel:L,runModuleAction:q,setFooterActionText:y,setTableName:x,setEntryMode:_,setSubmitDisabledTips:j,updateOrderNote:$,isCacheHydrated:M,markGate:E,isGatePassed:D,clearStepCache:z,resumeStep:T,consumeResumeStep:O}),[i,r,h,s,d,u,I,m,f,b,k,w,S,M,E,D,z,T,O]);return(0,eO.jsx)(eVF.Provider,{value:H,children:a})}function eVH(){let e=(0,ex.useContext)(eVF);if(e)return e;throw Error("useScanOrderContext must be used within ScanOrderProvider")}let eVV={init:{index:1,localeKey:"pisell2.scan.order.step.init",fallback:"Initialize"},product:{index:2,localeKey:"pisell2.scan.order.step.product",fallback:"Select product"},check:{index:3,localeKey:"pisell2.scan.order.step.check",fallback:"Check order"},error:{index:4,localeKey:"pisell2.scan.order.step.error",fallback:"Unavailable"}};function eVY(e){let{currentStep:t,onBack:l}=e,i=(0,ex.useMemo)(()=>{let e=eP.getText("pisell2.appointment.step");return"function"==typeof e?e(eVV[t].index):`Step ${eVV[t].index}`},[t]),a=(0,ex.useMemo)(()=>{let e=eP.getText(eVV[t].localeKey);return"string"==typeof e&&e?e:eVV[t].fallback},[t]);return(0,eO.jsx)(id.PisellHeaderProgressBar,{className:"pisell-scan-order-progress-bar",stepText:i,title:a,showClose:!1,showBack:"init"!==t,onBack:l,enableBorder:!0,borderColor:"#EAECF0"})}function eVU(){let{discountList:e,runModuleAction:t,refreshViewModel:l,scanOrderModule:i}=eVH(),{isLogin:a,openLoginModal:n}=eVR(),[r,s]=(0,ex.useState)(!0),[o,d]=(0,ex.useState)(""),c=(0,ex.useMemo)(()=>(e||[]).filter(e=>!!e.isAvailable).map(e=>({...e,isDisabled:e.isDisabled||e.isDisabledForProductUsed})),[e]),u=(0,ex.useCallback)(async()=>{await l()},[l]),p=(0,ex.useCallback)(async()=>{if(o.trim())try{var e;let l=null==i||null==(e=i.getTempOrder)?void 0:e.call(i),a=(null==l?void 0:l.customer_id)||void 0,n=await t("scanCode",o,a);if(null==n?void 0:n.isAvailable)d(""),await u();else{let e={time_limit:eP.getText("pisell2.text.goodpass.code-invalid-expired")};e_.message.error({content:String((null==n?void 0:n.type)==="server"?eP.getText("pisell2.text.goodpass.code-invalid"):e[null==n?void 0:n.unavailableReason]||eP.getText("pisell2.text.goodpass.code-invalid-cart"))})}}catch(e){console.warn("[scanOrder] scanCode failed",e),e_.message.error({content:String(eP.getText("pisell2.text.goodpass.code-invalid")||"兑换码无效")})}},[o,i,t,u]),m=(0,ex.useCallback)(async e=>{try{await t("setDiscountSelected",{discountId:e.id,isSelected:e.isSelected}),await u()}catch(e){console.warn("[scanOrder] setDiscountSelected failed",e)}},[t,u]),g=(0,ex.useCallback)(e=>[...e].sort((e,t)=>Number(null==t?void 0:t.isSelected)-Number(null==e?void 0:e.isSelected)),[]);return(0,eO.jsxs)("div",{className:"pisell-lowcode__appointment-booking-voucher-container",style:{marginTop:"10px"},children:[(0,eO.jsxs)("div",{className:"voucher-title",children:[(0,eO.jsx)("span",{className:"voucher-title-left",children:eP.getText("pisell2.text.goodpass")}),(0,eO.jsxs)("span",{className:"voucher-title-right",onClick:()=>s(!r),children:[eP.getText("pisell2.text.details")," ",(0,eO.jsx)(H9,{className:t8()("voucher-right-icon",{show:r})})]})]}),(0,eO.jsxs)("div",{className:t8()("voucher-detail",{show:r}),children:[c.length>0?(0,eO.jsx)(id.PisellGoodPassCard,{style:{width:"100%"},dataSource:c,mixedSort:g,onChange:m}):null,a?null:(0,eO.jsxs)("div",{className:"login-card",children:[(0,eO.jsx)(emR,{style:{fontSize:28}}),(0,eO.jsxs)("div",{className:"text-wrapper",style:{maxWidth:"none"},children:[(0,eO.jsx)(id.PisellText,{className:"login-btn",onClick:()=>{n({callback:()=>{}})},children:eP.getText("pisell2.text.goodpass.login")})," ",(0,eO.jsx)("span",{children:eP.getText("pisell2.text.goodpass.login-tip")})]})]}),(0,eO.jsxs)("div",{className:"voucher-code-input-wrapper",children:[(0,eO.jsxs)("div",{className:"voucher-code-input",children:[(0,eO.jsxs)("div",{style:{whiteSpace:"nowrap"},children:[eP.getText("pisell2.text.goodpass.code"),":"]}),(0,eO.jsx)(id.PisellInput,{value:o,allowClear:!0,onChange:e=>{var t;return d((null==(t=e.target)?void 0:t.value)||"")},size:"small",placeholder:eP.getText("pisell2.text.goodpass.enter-code")})]}),(0,eO.jsx)(e_.Button,{size:"small",onClick:p,disabled:!o.trim(),children:eP.getText("pisell2.text.apply")})]})]})]})}function eVW(e){var t,l,i,a,n,r;let{open:s,onCancel:o,onNext:d,items:c,summary:u,embedded:p=!1,confirmLoading:m=!1,extraContent:g,disabled:h=!1}=e,{runModuleAction:v,refreshViewModel:f,scanOrderModule:y}=eVH(),b=eI(),x=null==b||null==(l=b.appHelper)||null==(t=l.utils)?void 0:t.businessUtils,k=(null==b||null==(a=b.engine)||null==(i=a.props)?void 0:i.locale)||"en",_=!!(null==x||null==(n=x.getAppByModal)?void 0:n.call(x,"goodpass")),w=!!(null==x||null==(r=x.getAppByModal)?void 0:r.call(x,"discountcard")),j=p||s;if(!j)return null;let[S,N]=(0,ex.useState)(null),M=(0,ex.useCallback)(async()=>{let e=await v("getOtherParams");N((null==e?void 0:e.dineInConfig)??{})},[v]);(0,ex.useEffect)(()=>{M()},[]);let C=(0,ex.useMemo)(()=>null==S?void 0:S["sale.allow_item_notes"],[S]),T=(0,ex.useMemo)(()=>{let e=Number((null==u?void 0:u.total_amount)??(null==u?void 0:u.expect_amount)??(null==u?void 0:u.amount)??(null==u?void 0:u.total)??(null==u?void 0:u.totalAmount)??(null==u?void 0:u.payable_amount)??0);return Number.isNaN(e)?"0.00":e.toFixed(2)},[u]),P=String(eP.getText("pisell2.scan.order.action.confirm.order")||eP.getText("pisell2.event.confirm")||"Confirm"),A=(0,ex.useMemo)(()=>{var e;let t=Number((null==u?void 0:u.product_amount)??0),l=Number((null==u?void 0:u.tax_fee)??0),i=Number((null==u?void 0:u.total_amount)??(null==u?void 0:u.expect_amount)??0),a=null==y||null==(e=y.getTempOrder)?void 0:e.call(y),n=(null==a?void 0:a.summary)||{},r=String((null==n?void 0:n.tax_title)||(null==u?void 0:u.tax_title)||"GST/Tax"),s=Number((null==n?void 0:n.tax_rate)??(null==u?void 0:u.tax_rate)),o=Number.isNaN(s)?0:s>1?s/100:s,d=!!((null==n?void 0:n.is_price_include_tax)??(null==n?void 0:n.isPriceIncludeTax)??(null==u?void 0:u.is_price_include_tax)),c=((null==u?void 0:u.surcharges)||[]).filter(e=>Number(null==e?void 0:e.amount)>0).map(e=>{let t=(null==e?void 0:e.label)||(null==e?void 0:e.name)||{},l=t[k]||t.en||t.original||(null==e?void 0:e.key)||"";return{key:(null==e?void 0:e.key)||`surcharge_${null==e?void 0:e.surcharge_id}`,label:l,value:Number(null==e?void 0:e.amount)}});return[{key:"sub_total",value:Number.isNaN(t)?0:t},...c,{key:"tax",value:Number.isNaN(l)?0:l,hidden:!!Number.isNaN(l)||l<=0,tax:{title:r,rate:o,is_price_include_tax:d}},{key:"custom_total",value:Number.isNaN(i)?0:i,label:eP.getText("pisell2.event.total"),bold:!0}]},[u,y,k]),I=async(e,t)=>{if("note"===t){let t=(null==e?void 0:e.product_id)??(null==e?void 0:e.id)??null,l=Number((null==e?void 0:e.product_variant_id)??0),i=null==e?void 0:e.identity_key;if(null===t&&Number.isNaN(l))return;let a={product_id:t,product_variant_id:Number.isNaN(l)?0:l};"string"==typeof i&&i.length>0&&(a.identity_key=i);try{await v("setOrderProductLineNote",a,String((null==e?void 0:e.note)??"")),await f()}catch(t){console.error("[scanOrder] setOrderProductLineNote failed",{error:t,item:e})}return}if("delete"===t){let t=(null==e?void 0:e.product_id)??(null==e?void 0:e.id)??null,l=Number((null==e?void 0:e.product_variant_id)??0),i=null==e?void 0:e.identity_key;if(null===t&&Number.isNaN(l))return;if("string"!=typeof i||0===i.length)return void console.error("[scanOrder] removeProductFromOrder skipped: missing identity_key",{item:e});try{await v("removeProductFromOrder",{product_id:t,product_variant_id:Number.isNaN(l)?0:l,identity_key:i}),await f()}catch(t){console.error("[scanOrder] removeProductFromOrder failed",{error:t,item:e})}}};(0,ex.useEffect)(()=>{j&&f()},[j]);let D=(0,eO.jsx)(LU,{productParams:{products:c||[],hideAddBtn:!0,disabledEdit:!1,isShowNote:C,isShowDelete:!0,isShowPackageNote:!1,isShowChangeHolder:!1,isShowHolder:!1,isShowAddHolderButton:!1},platform:"h5",emptyText:eP.getText("pisell2.scan.order.empty.product"),isOpenGroup:!1,isHideClearCart:!0,onChange:I}),E=(0,eO.jsxs)(eO.Fragment,{children:[_||w?(0,eO.jsx)(eVU,{}):null,(0,eO.jsx)(YI,{list:A,style:{padding:0}}),g?(0,eO.jsx)("div",{className:"pisell-scan-order-cart-extra-content",children:g}):null]}),z=(0,eO.jsxs)("div",{className:p?"pisell-scan-order-cart-body pisell-scan-order-cart-body-embedded":"pisell-scan-order-cart-body",children:[D,E]});return p?(0,eO.jsxs)(eO.Fragment,{children:[z,(0,eO.jsx)("div",{className:"pisell-scan-order-cart-embedded-footer",children:(0,eO.jsx)(id.Button,{type:"primary",block:!0,onClick:d,loading:m,className:h?"pisell-scan-order-cart-embedded-confirm-disabled":void 0,children:P})})]}):(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsx)("div",{className:"pisell-scan-order-cart-mask",onClick:o}),(0,eO.jsxs)("div",{className:"pisell-scan-order-cart-drawer",children:[(0,eO.jsx)("div",{className:"pisell-scan-order-cart-header",children:(0,eO.jsx)("div",{className:"pisell-scan-order-cart-sheet-handle-wrap","aria-hidden":!0,children:(0,eO.jsx)("div",{className:"pisell-scan-order-cart-sheet-handle"})})}),(0,eO.jsx)("div",{className:"pisell-scan-order-cart-list-scroll",children:D}),(0,eO.jsxs)("div",{className:"pisell-scan-order-cart-bottom-panel",children:[E,(0,eO.jsxs)("div",{className:"pisell-scan-order-cart-footer",children:[(0,eO.jsxs)("div",{className:"pisell-scan-order-cart-footer-total-col",children:[(0,eO.jsx)("div",{className:"pisell-scan-order-cart-footer-total-label",children:eP.getText("pisell2.event.total")}),(0,eO.jsxs)("div",{className:"pisell-scan-order-cart-footer-total-amount",children:["$",T]})]}),(0,eO.jsx)(id.Button,{type:"primary",onClick:d,loading:m,children:eP.getText("pisell2.event.continue")})]})]})]})]})}function eVG(e){let{cartItems:t,summary:l,actionText:i,onAction:a,disabled:n=!1}=e,[r,s]=(0,ex.useState)(!1),o=(0,ex.useMemo)(()=>{let e=Number((null==l?void 0:l.total_amount)??(null==l?void 0:l.expect_amount)??(null==l?void 0:l.amount)??(null==l?void 0:l.total)??(null==l?void 0:l.totalAmount)??(null==l?void 0:l.payable_amount)??0);return Number.isNaN(e)?"0.00":e.toFixed(2)},[l]);return(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsxs)("div",{className:"pisell-scan-order-footer",children:[(0,eO.jsxs)("div",{className:"pisell-scan-order-footer-left",children:[(0,eO.jsx)("div",{className:"pisell-scan-order-footer-total-label",children:eP.getText("pisell2.event.total")}),(0,eO.jsxs)("div",{className:"pisell-scan-order-footer-total-amount",children:["$",o]})]}),(0,eO.jsxs)("div",{className:"pisell-scan-order-footer-right",children:[(0,eO.jsx)(id.Badge,{count:(null==t?void 0:t.length)||0,id:"scan-order-v2-cart-btn",children:(0,eO.jsx)(id.Button,{size:"large",className:"pisell-scan-order-footer-cart-btn",onClick:()=>s(!0),children:(0,eO.jsx)(id.Image,{src:egO,preview:!1})})}),(0,eO.jsx)(id.Button,{type:"primary",size:"large",className:`pisell-scan-order-footer-btn${n?" pisell-scan-order-footer-btn-disabled":""}`,onClick:a,children:i})]})]}),(0,eO.jsx)(eVW,{open:r,items:t||[],summary:l||{},onCancel:()=>{s(!1)},onNext:()=>{s(!1),a()}})]})}function eVQ(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,l=Number(e);return Number.isNaN(l)?t:l}function eVK(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,l=Math.floor(Number(e));return Number.isNaN(l)||l<1?t:l}function eVZ(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0.00",l=Number(e);return Number.isNaN(l)?t:l.toFixed(2)}function eVJ(e){return Array.isArray(e)?e.map(e=>{let{price:t,...l}=e||{},i=eVQ((null==e?void 0:e.product_option_item_id)??(null==e?void 0:e.option_group_item_id));return{...l,product_option_item_id:i,option_group_id:eVQ(null==e?void 0:e.option_group_id),num:eVK(null==e?void 0:e.num,1),add_price:eVQ((null==e?void 0:e.add_price)??t,0)}}):[]}function eVX(e,t){return e&&t&&!(t<=0)&&(Array.isArray(null==e?void 0:e.variant)?e.variant:[]).find(e=>Number(null==e?void 0:e.id)===t)||null}function eV0(e){var t,l,i;let{payload:a,fallbackProductId:n=null,sourceItem:r={}}=e;if(!a||"object"!=typeof a)return null;let s=function(e){if(null==e||""===e)return null;let t=Number(e);return Number.isNaN(t)?null:t}(a.product_id??a.id??(null==r?void 0:r.product_id)??n);if(null===s)return null;let o=eVQ(a.product_variant_id??a.variant_id??(null==r?void 0:r.product_variant_id),0),d=(null==a?void 0:a.origin)||(null==a||null==(t=a._origin)?void 0:t.sourceItem)||(null==a?void 0:a._origin)||{},c=eVX(d,o)??eVX(r,o),u=eVZ((null==a?void 0:a.price)??(null==a?void 0:a.selling_price)??(null==c?void 0:c.price)??(null==c?void 0:c.base_price)??(null==d?void 0:d.price)??(null==r?void 0:r.price)??(null==r?void 0:r.selling_price)??(null==r?void 0:r.base_price),"0.00"),p=eVZ((null==a?void 0:a.tax_fee)??(null==c?void 0:c.tax_fee)??(null==d?void 0:d.tax_fee)??(null==r?void 0:r.tax_fee),"0.00"),m=eVQ((null==a?void 0:a.is_charge_tax)??(null==c?void 0:c.is_charge_tax)??(null==d?void 0:d.is_charge_tax)??(null==r?void 0:r.is_charge_tax),0),g=function(e){let{payload:t,callbackOrigin:l,sourceItem:i}=e;for(let e of[null==t?void 0:t.product_title,null==i?void 0:i.product_title,null==l?void 0:l.product_title,null==t?void 0:t.title,null==i?void 0:i.title,null==l?void 0:l.title,null==t?void 0:t.name,null==i?void 0:i.name,null==l?void 0:l.name]){let t=function(e){if("string"==typeof e){let t=e.trim();return t?{auto:t}:void 0}if(!e||"object"!=typeof e||Array.isArray(e))return;let t={};Object.entries(e).forEach(e=>{let[l,i]=e;"string"==typeof i?t[l]=i:null==i&&(t[l]=i)});let l=function(e){if("string"==typeof e)return e.trim();if(!e||"object"!=typeof e||Array.isArray(e))return"";for(let t of["auto","original","en","zh-CN","zh-HK","ja","pt"]){let l=e[t];if("string"==typeof l&&l.trim())return l.trim()}let t=Object.values(e).find(e=>"string"==typeof e&&e.trim());return"string"==typeof t?t.trim():""}(t);return l&&!t.auto&&(t.auto=l),Object.values(t).some(e=>"string"==typeof e&&e.trim())?t:void 0}(e);if(t)return t}}({payload:a,callbackOrigin:d,sourceItem:r});return{product_id:s,product_variant_id:o,num:eVK(a.quantity??a.num,1),product_sku:{...a.product_sku,option:eVJ((null==(l=a.product_sku)?void 0:l.option)??a.option??a.product_option_item)},product_bundle:Array.isArray(i=a.bundle??a.product_bundle)?i.map(e=>({...e,option:eVJ(null==e?void 0:e.option)})):[],selling_price:u,original_price:u,tax_fee:p,is_charge_tax:m,...g?{product_title:g}:{},metadata:{unique:a.unique,session:a.session,form:a.form,service_times:a.service_times,machine_code:a.machine_code,schedule_id:a.schedule_id,duration:a.duration,policy_id:a.policy_id,source_shop_id:a.source_shop_id,origin:a.origin,...g?{product_title:g}:{}},_origin:{...r||{},callbackData:a}}}function eV2(e){var t;let{onCheckout:l,productList:i,isProductListLoading:a,onEnsureProductList:n}=e,{utils:r}=eI().appHelper||{},{runModuleAction:s,refreshViewModel:o,viewModel:d}=eVH(),[c,u]=(0,ex.useState)(null),p=(0,ex.useCallback)(async()=>{let e=await s("getOtherParams");u((null==e?void 0:e.dineInConfig)??{})},[s]);(0,ex.useEffect)(()=>{p()},[]),(0,ex.useEffect)(()=>{n()},[n]);let m=(0,ex.useRef)(null);rp();let g=window.innerHeight-100,h=async e=>{let{orderProduct:t,sourceData:l}=e;try{await s("addProductToOrder",t),await o()}catch(e){console.error("[scanOrder] addProductToOrder failed",{error:e,sourceData:l,mappedData:t})}},v=async e=>{let{product_id:t,product_variant_id:l,identity_key:i,sourceData:a}=e;try{await s("removeProductFromOrder",{product_id:t,product_variant_id:l,...i?{identity_key:i}:{}}),await o()}catch(e){console.error("[scanOrder] removeProductFromOrder failed",{error:e,sourceData:a,product_id:t,product_variant_id:l,identity_key:i})}},f=async e=>{let{product_id:t,product_variant_id:l,identity_key:i,updates:a,sourceData:n}=e;try{await s("updateOrderProduct",{product_id:t,product_variant_id:l,...i?{identity_key:i}:{},updates:a}),await o()}catch(e){console.error("[scanOrder] updateOrderProduct failed",{error:e,sourceData:n,product_id:t,product_variant_id:l,identity_key:i,updates:a})}},y=async(e,t,l)=>{let i=(null==l?void 0:l.product)||e;if((null==l?void 0:l.intent)==="quantity"){let t={...e,quantity:null==e?void 0:e.num,option:(null==e?void 0:e.option)??(null==e?void 0:e.product_option_item),bundle:(null==e?void 0:e.bundle)??(null==e?void 0:e.product_bundle),origin:i,price:(null==e?void 0:e.price)??(null==e?void 0:e.selling_price)},a=eV0({payload:t,fallbackProductId:(null==e?void 0:e.product_id)??(null==e?void 0:e.id),sourceItem:i});if(!a)return void console.warn("[scanOrder] quantity add missing product_id",t);let n=Number((null==l?void 0:l.quantity)??(null==t?void 0:t.quantity)??0),r=Number((null==a?void 0:a.product_variant_id)??0);if(Number.isNaN(r))return void console.warn("[scanOrder] quantity action missing product_variant_id",{quantityData:t,orderProduct:a});let s=Number.isNaN(n)?0:Math.max(0,Math.floor(n)),o=(Array.isArray(null==d?void 0:d.cartItems)?d.cartItems:[]).find(e=>String((null==e?void 0:e.product_id)??null)===String((null==a?void 0:a.product_id)??null)&&Number((null==e?void 0:e.product_variant_id)??0)===r),c="string"==typeof(null==o?void 0:o.identity_key)&&o.identity_key.length>0?o.identity_key:void 0;if(s<=0)return void await v({product_id:(null==a?void 0:a.product_id)??null,product_variant_id:r,identity_key:c,sourceData:t});if(!o)return void await h({orderProduct:{...a,num:s},sourceData:t});await f({product_id:(null==a?void 0:a.product_id)??null,product_variant_id:r,identity_key:c,updates:{num:s,_origin:null==a?void 0:a._origin},sourceData:t})}else null==r||r.action({type:"pisell1.productDetail",data:{detail:{...i,open_deposit:1},setting:{can_input:!0,item_max_length:1,is_detail_open:!1}},callback:async t=>{var l,a,n;if((null==t?void 0:t.isCancel)||(null==t||null==(l=t.origin)?void 0:l.is_track)&&!(null==t||null==(a=t.origin)?void 0:a.over_sold)&&(null==t||null==(n=t.origin)?void 0:n.stock_quantity)<=0)return;let r=eV0({payload:t,fallbackProductId:(null==e?void 0:e.product_id)??(null==e?void 0:e.id),sourceItem:i});r?await h({orderProduct:r,sourceData:t}):console.warn("[scanOrder] productDetail callback missing product_id",t)}})},b=(0,eO.jsx)(z9,{dataSource:i,onChange:y,loading:a,emptyDescription:eP.getText("pisell2.scan.order.empty.product"),token:{colorPrimary:"var(--theme-color)",containerBg:"#FFFFFF",tabItemBg:"#F2F4F7",tabItemHoverBg:"#F2F4F7",tabItemActiveBg:"var(--theme-color)",categoryTextColor:"#1B1B1B",cardSelectedBg:"var(--theme-color)"},customScrollParent:(null==(t=m.current)?void 0:t.getScrollContainer())||"",hideCategoryWhenOne:!0,version:"v2",value:(null==d?void 0:d.cartItems)||[],productListSetting:{imgWidth:80,imgHeight:80},cartElementId:"#scan-order-v2-cart-btn"});return(0,eO.jsx)("div",{className:"pisell-scan-menu",children:(0,eO.jsx)(id.PisellScrollView,{height:g,overflow:"y",ref:m,children:b})})}function eV1(e){let{title:t="Error",message:l,onRetry:i}=e;return(0,eO.jsxs)("div",{className:"pisell-scan-order-error-state",children:[(0,eO.jsx)("h3",{children:t}),(0,eO.jsx)("p",{children:l}),i?(0,eO.jsx)("button",{type:"button",onClick:i,children:"Retry"}):null]})}function eV4(){let e=String(eP.getText("pisell2.scan.order.step.init")||"Initialize"),t=String(eP.getText("pisell2.scan.order.loading.initializing")||"Preparing your order, please wait...");return(0,eO.jsxs)("div",{className:"pisell-scan-order-initializing",children:[(0,eO.jsx)("div",{className:"pisell-scan-order-initializing-spinner",children:(0,eO.jsx)(id.PisellLoading,{loading:!0})}),(0,eO.jsx)("div",{className:"pisell-scan-order-initializing-title",children:e}),(0,eO.jsx)("div",{className:"pisell-scan-order-initializing-description",children:t})]})}function eV3(){let{scanOrderModule:e}=eVH(),[t,l]=(0,ex.useState)({}),[i,a]=(0,ex.useState)("table_service");(0,ex.useEffect)(()=>{if(!e)return;let t=("function"==typeof e.getFulfillmentModes?e.getFulfillmentModes():void 0)||{};l(t),t.enableTableService&&t.enablePickup;let i=!t.enableTableService&&t.enablePickup?"counter_pickup":"table_service";a(i),(t.enableTableService||t.enablePickup)&&"function"==typeof e.setPickupReferenceMode&&e.setPickupReferenceMode(i)},[e]);let{enableTableService:n,enablePickup:r}=t,s=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.fulfillment.title")),[]),o=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.fulfillment.table_service")),[]),d=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.fulfillment.pickup")),[]);if(!n&&!r)return null;if(!n||!r){let e=r?d:o;return(0,eO.jsxs)("div",{className:"pisell-scan-order-fulfillment pisell-scan-order-fulfillment-single",children:[(0,eO.jsx)("span",{className:"pisell-scan-order-fulfillment-title",children:s}),(0,eO.jsx)("span",{className:"pisell-scan-order-fulfillment-value",children:e})]})}return(0,eO.jsxs)("div",{className:"pisell-scan-order-fulfillment",children:[(0,eO.jsx)("div",{className:"pisell-scan-order-fulfillment-title",children:s}),(0,eO.jsxs)(e_.Radio.Group,{className:"pisell-scan-order-fulfillment-group",optionType:"button",buttonStyle:"solid",value:i,onChange:t=>{var l,n;(n=null==t||null==(l=t.target)?void 0:l.value)!==i&&(a(n),"function"==typeof(null==e?void 0:e.setPickupReferenceMode)&&e.setPickupReferenceMode(n))},children:[(0,eO.jsx)(e_.Radio.Button,{value:"table_service",children:o}),(0,eO.jsx)(e_.Radio.Button,{value:"counter_pickup",children:d})]})]})}function eV8(e){let{open:t,confirmLoading:l=!1,onCancel:i,onConfirm:a}=e,[n,r]=(0,ex.useState)("");(0,ex.useEffect)(()=>{t&&r("")},[t]);let s=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.pickup.ref.title")),[]),o=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.pickup.ref.heading")),[]),d=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.pickup.ref.description")),[]),c=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.pickup.ref.placeholder")),[]),u=(0,ex.useMemo)(()=>String(eP.getText("pisell2.event.confirm")||"Confirm"),[]),p=n.trim(),m=!!p&&!l,g=()=>{m&&a(p)};return(0,eO.jsx)(e_.Modal,{open:t,title:s,footer:null,onCancel:i,maskClosable:!1,destroyOnClose:!0,centered:!0,className:"pisell-scan-order-pickup-ref-modal",children:(0,eO.jsxs)("div",{className:"pisell-scan-order-pickup-ref-body",children:[(0,eO.jsx)("div",{className:"pisell-scan-order-pickup-ref-heading",children:o}),(0,eO.jsx)("div",{className:"pisell-scan-order-pickup-ref-desc",children:d}),(0,eO.jsx)(e_.Input,{size:"large",placeholder:c,value:n,onChange:e=>{var t;return r((null==e||null==(t=e.target)?void 0:t.value)||"")},onPressEnter:g,className:"pisell-scan-order-pickup-ref-input",maxLength:32,allowClear:!0}),(0,eO.jsx)(id.Button,{type:"primary",block:!0,size:"large",disabled:!m,loading:l,onClick:g,children:u})]})})}function eV6(){let{viewModel:e,runModuleAction:t,refreshViewModel:l,tableName:i,entryMode:a,clearStepCache:n,entryContext:r}=eVH(),s="additional_order"===a,[o,d]=(0,ex.useState)(!1),c=(0,ex.useRef)(!1),u=(0,ex.useRef)(!1),[p,m]=(0,ex.useState)((null==e?void 0:e.note)||""),[g,h]=(0,ex.useState)(!1),[v,f]=(0,ex.useState)(!1),y=eVO(),[b,x]=(0,ex.useState)(null),[k,_]=(0,ex.useState)(""),w=(0,ex.useCallback)(async()=>{let e=await t("getOtherParams");x((null==e?void 0:e.dineInConfig)??{}),_((null==e?void 0:e.channel)??"")},[t]);(0,ex.useEffect)(()=>{w()},[]);let j=(0,ex.useMemo)(()=>null==b?void 0:b["sale.allow_order_notes"],[b]),S=(0,ex.useMemo)(()=>String(eP.getText("pisell2.text.order-notes")||eP.getText("pisell2.scan.order.note.title")||"备注"),[]),N=(0,ex.useMemo)(()=>String(eP.getText("pisell2.text.add-order-notes")||eP.getText("pisell2.scan.order.note.placeholder")||"请输入备注"),[]),M=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.current.table")||"Current table"),[]),C=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.products.title")||"Products"),[]),T=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.add.on.confirm.title")||"This table has already started ordering"),[]),P=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.add.on.confirm.description")||"Someone at your table has placed the order. This will be submitted as an add-on order."),[]),A=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.add.on.confirm.button")||"Confirm Add-on Order"),[]),I=(0,ex.useMemo)(()=>String(eP.getText("pisell2.scan.order.add.on.return.button")||"Return to Cart"),[]),D=()=>{e_.message.error(eP.getText("pisell2.scan.order.check.cart.empty.tip")||"Please go back to add products")},E=(0,ex.useCallback)(e=>{let t=String(e||eP.getText("pisell2.scan.order.submit.failed")||"Submit order failed");(0,id.PisellToast)({content:t})},[]),z=e=>(null==e?void 0:e.code)==="SCAN_ORDER_MENU_UNAVAILABLE"?!!u.current||(u.current=!0,e_.Modal.info({title:String(eP.getText("pisell2.scan.order.menu.unavailable.title")||"Ordering time has ended"),content:String(eP.getText("pisell2.scan.order.menu.unavailable.description")||"Some items in your cart are no longer available to order at this time. Select Confirm to refresh the page and choose your items again."),okText:String(eP.getText("pisell2.event.confirm")||"OK"),maskClosable:!1,keyboard:!1,closable:!1,onOk:()=>{let e=new URL(window.location.href);e.searchParams.delete("cacheId"),window.location.replace(e.toString())}}),!0):(null==e?void 0:e.code)==="SCAN_ORDER_MENU_VALIDATION_FAILED"&&(E(String(eP.getText("pisell2.scan.order.menu.validation.failed")||"Unable to check the ordering time. Please try again. Your cart has been kept.")),!0),O=async e=>{if(!c.current&&!u.current){c.current=!0,d(!0);try{await e()}catch(e){console.error("[scanOrder] submit action failed",e),z(e)||E(null==e?void 0:e.message)}finally{c.current=!1,d(!1)}}},L=(0,ex.useCallback)(e=>{var t;let l=(Array.isArray(null==e||null==(t=e.data)?void 0:t.unavailable_products)?e.data.unavailable_products:[]).map(e=>String((null==e?void 0:e.title)||(null==e?void 0:e.product_id)||"").trim()).filter(Boolean),i=String(eP.getText("pisell2.scan.order.inventory.insufficient.title")||"Insufficient inventory"),a=String(eP.getText("pisell2.scan.order.inventory.insufficient.description")||"The following items are out of stock or do not have enough inventory. Please adjust your cart and try again."),n=String(eP.getText("pisell2.scan.order.inventory.insufficient.products.label")||"Unavailable products:"),r=String((null==e?void 0:e.message)||a);e_.Modal.info({title:i,content:(0,eO.jsxs)("div",{children:[(0,eO.jsx)("div",{children:a}),(0,eO.jsx)("div",{children:n}),l.length>0?(0,eO.jsx)("ul",{children:l.map((e,t)=>(0,eO.jsx)("li",{children:e},`${e}-${t}`))}):(0,eO.jsx)("div",{children:r})]}),okText:String(eP.getText("pisell2.event.confirm")||"OK"),maskClosable:!1})},[]),$=async()=>{if(0===((null==e?void 0:e.cartItems)||[]).length)return void D();try{var i,a,o,d,c;await t("updateTempOrderNote",p);let r=await t("submitScanOrder");if((null==r?void 0:r.status)===!1){if(z(r))return;if((null==r?void 0:r.code)===6008)return void L(r);E(null==r?void 0:r.message);return}let u=null==r||null==(i=r.data)?void 0:i.order_id,m=(null==b?void 0:b["sale.require_payment_on_submit"])&&!s;if(!u)return void E(null==r?void 0:r.message);if(n(),m)y.action({type:"pisell1.payment",data:{order_id:u,total_amount:(null==r||null==(a=r.data)?void 0:a.order_wait_pay_amount)||(null==e||null==(o=e.summary)?void 0:o.total_amount),sale_channel:{scan_to_order:"table-order",scan_to_order_2:"mobile_order",scan_to_order_3:"scantoorder3"}[k]||k},callback:async e=>{try{await t("restoreOrder")}catch(e){console.warn("[scanOrder] restoreOrder after payment failed",e)}}});else{try{await t("restoreOrder")}catch(e){console.warn("[scanOrder] restoreOrder before redirect failed",e)}let e=`/order/details?id=${u}`;(null==y||null==(d=y.history)?void 0:d.replace)?y.history.replace(e):(null==y||null==(c=y.history)?void 0:c.push)?y.history.push(e):location.replace(e);try{await t("restoreOrder")}catch(e){console.warn("[scanOrder] restoreOrder after payment failed",e)}}await l()}catch(e){if(console.error("[scanOrder] submitScanOrder failed",e),z(e))return;if((null==e?void 0:e.code)===670005)E(String(eP.getText("pisell2.scan.order.settled.cannot.add.tip")||""));else if((null==e?void 0:e.code)===670007&&(null==r?void 0:r.resource_id)){let l=await t("getReservationResourceSelectType"),i=await t("checkAllowAddItems"),a=await t("syncAdditionalOrderFromResource",null==r?void 0:r.resource_id);"single"===l.resourceSelectType&&(null==i?void 0:i.enabled)&&(null==a?void 0:a.matched)?f(!0):E(null==e?void 0:e.message)}else(null==e?void 0:e.code)===6008?L(e):E(null==e?void 0:e.message)}},R=()=>{c.current||f(!1)},F=(0,eO.jsxs)("div",{className:"pisell-scan-order-check-note",children:[(0,eO.jsx)("div",{className:"pisell-scan-order-check-note-title",children:S}),(0,eO.jsx)(e_.Input.TextArea,{value:p,placeholder:N,autoSize:{minRows:4},allowClear:!0,onChange:e=>{var t;return m((null==e||null==(t=e.target)?void 0:t.value)||"")}})]});return(0,eO.jsxs)("div",{className:"pisell-scan-order-check",children:[i?(0,eO.jsxs)("div",{className:"pisell-scan-order-check-current-table",children:[(0,eO.jsx)("span",{className:"pisell-scan-order-check-current-table-label",children:M}),(0,eO.jsx)("span",{className:"pisell-scan-order-check-current-table-value",children:i})]}):null,s?null:(0,eO.jsx)(eV3,{}),(0,eO.jsx)("div",{className:"pisell-scan-order-check-products-title",children:C}),(0,eO.jsx)(eVW,{embedded:!0,open:!0,onCancel:()=>{},onNext:()=>O(async()=>{if(0===((null==e?void 0:e.cartItems)||[]).length)return void D();if(s)return void await $();try{let e=await t("checkManualPickupRef");if(null==e?void 0:e.enabled)return void h(!0)}catch(e){console.error("[scanOrder] checkManualPickupRef failed",e),e_.message.error((null==e?void 0:e.message)||"Submit order failed");return}await $()}),items:(null==e?void 0:e.cartItems)||[],summary:(null==e?void 0:e.summary)||{},confirmLoading:o,extraContent:!s&&j?F:void 0}),(0,eO.jsx)(eV8,{open:g,confirmLoading:o,onCancel:()=>{c.current||h(!1)},onConfirm:e=>O(async()=>{try{await t("setPickupRef",e)}catch(e){console.error("[scanOrder] setPickupRef failed",e),e_.message.error((null==e?void 0:e.message)||"Submit order failed");return}h(!1),await $()})}),(0,eO.jsx)(e_.Modal,{open:v,footer:null,onCancel:R,maskClosable:!1,destroyOnClose:!0,centered:!0,className:"pisell-scan-order-add-on-confirm-modal",children:(0,eO.jsxs)("div",{className:"pisell-scan-order-add-on-confirm-body",children:[(0,eO.jsx)("div",{className:"pisell-scan-order-add-on-confirm-title",children:T}),(0,eO.jsx)("div",{className:"pisell-scan-order-add-on-confirm-desc",children:P}),(0,eO.jsx)(id.Button,{type:"primary",block:!0,size:"large",loading:o,onClick:()=>O(async()=>{f(!1),await $()}),children:A}),(0,eO.jsx)(id.Button,{block:!0,size:"large",disabled:o,onClick:R,children:I})]})}),o?(0,eO.jsx)("div",{className:"pisell-scan-order-check-loading-mask",children:(0,eO.jsx)("div",{className:"pisell-scan-order-check-loading-panel",children:(0,eO.jsx)(id.PisellLoading,{loading:!0,mask:{backgroundColor:"transparent",width:64,height:64},children:(0,eO.jsx)("div",{className:"pisell-scan-order-check-loading-placeholder"})})})}):null]})}function eV5(){var e,t,l,i,a;let{currentStep:n,prevStep:r,goToStep:s,runModuleAction:o,entryContext:d,viewModel:c,refreshViewModel:u,footerActionText:p,setFooterActionText:m,cartValidation:g,setTableName:h,entryMode:v,setEntryMode:f,submitDisabledTips:y,setSubmitDisabledTips:b,scanOrderModule:x,isCacheHydrated:k,markGate:_,isGatePassed:w,resumeStep:j,consumeResumeStep:S}=eVH(),{openLoginModal:N}=eVR(),M=eVO(),[C]=HX({components:["FormCard"]}),T=(0,ex.useRef)(null),[P,A]=(0,ex.useState)(!1),[I,D]=(0,ex.useState)({open:!1,content:null}),[E,z]=(0,ex.useState)({open:!1,content:null}),[O,L]=(0,ex.useState)(null),[$,R]=(0,ex.useState)([]),[F,B]=(0,ex.useState)(!1),q=(0,ex.useRef)(!1),H=(0,ex.useRef)(null),V=(0,ex.useCallback)(async()=>{if(q.current)return;if(H.current)return void await H.current.catch(()=>{});let e=(async()=>{B(!0);try{let e=await o("getProductList");if(Array.isArray(e)){q.current=!0,R(e);return}e_.Modal.confirm({title:null==e?void 0:e.message,okText:String(eP.getText("pisell2.event.confirm")||"OK"),cancelButtonProps:{style:{display:"none"}},maskClosable:!1,onOk:()=>{location.replace("/")}})}catch(e){console.warn("[scanOrder] getProductList failed",e)}finally{B(!1),H.current=null}})();H.current=e,await e},[o]),Y=(0,ex.useRef)(0),U=(0,ex.useRef)(1),W=(0,ex.useRef)(1),G=(0,ex.useRef)(null);(0,ex.useRef)(!1);let Q=(0,ex.useRef)(!1),K=e=>{if(!e)return"";let t=e[eP.getLocale()];if("string"==typeof t&&t)return t;let l=e.original;return"string"==typeof l&&l?l:""},Z=e=>null==e?"":"string"==typeof e?e:"object"!=typeof e?String(e):K(e),J=null==M||null==(e=M.getApp)?void 0:e.call(M),X=()=>{var e,t;return!!(null==M||null==(t=M.token)||null==(e=t.get)?void 0:e.call(t))},ee=()=>{var e,t;(null==J||null==(e=J.history)?void 0:e.replace)?J.history.replace("/"):(null==J||null==(t=J.history)?void 0:t.push)?J.history.push("/"):location.replace("/")},et=()=>new Promise(e=>{var t;"function"!=typeof(null==M?void 0:M.action)?e(null):M.action({type:"pisell1.handlePaxModal",data:{tableName:K(null==(t=G.current)?void 0:t.name),requestPaxMin:U.current,requestPaxMax:W.current},callback:t=>{e(function(e){if(null==e)return null;if("number"==typeof e&&Number.isFinite(e)&&e>=1)return Math.floor(e);if("string"==typeof e){let t=Number(e);if(Number.isFinite(t)&&t>=1)return Math.floor(t)}if("object"==typeof e)for(let t of["entryPaxNumber","pax","num","count","value"]){let l=e[t];if("number"==typeof l&&Number.isFinite(l)&&l>=1)return Math.floor(l);if("string"==typeof l){let e=Number(l);if(Number.isFinite(e)&&e>=1)return Math.floor(e)}}return null}(t))}})}),el=e=>{var t,l;let i=`/order/details?id=${e}`;(null==J||null==(t=J.history)?void 0:t.replace)?J.history.replace(i):(null==J||null==(l=J.history)?void 0:l.push)?J.history.push(i):location.replace(i)},ei=async()=>{try{await o("applyItemRulePrefill"),await u()}catch(e){console.warn("[scanOrder] applyItemRulePrefill failed",e)}finally{j&&S(),s("check"===j?"check":"product")}},ea=async()=>{if("additional_order"===v||1!==Y.current||w("paxEntered"))return void await ei();Q.current=!0;let e=await et();if(null==e)return void ee();try{await o("setEntryPaxNumber",e),_("paxEntered")}catch(e){console.warn("[scanOrder] setOtherParams failed",e)}await ei()},en=e=>{e&&(A(!1),z({open:!0,content:e}))};(0,ex.useEffect)(()=>{let e=async()=>{let e=!!(null==d?void 0:d.order_id),{mode:t,order_id:l,errorTips:i,policy:a,form:r,partyroom_booking:s,requestEntryPax:c,requestPaxMin:u,requestPaxMax:p,table_form_record:m}=await o("checkResourceAvailable",null==d?void 0:d.resource_id,e);Y.current=+(1===Number(c)),U.current=Number(u)||1,W.current=Number(p)||1,G.current=m||{},h(K(null==m?void 0:m.name));let g=((e,t)=>{let l=e??t;if(!l)return null;let i=Number("number"==typeof l||"string"==typeof l?l:(null==l?void 0:l.id)??(null==l?void 0:l.form_id)??(null==l?void 0:l.resource_form_id)??(null==l?void 0:l.partyroom_booking));if(Number.isNaN(i)||i<=0)return null;let a="object"==typeof l&&null!==l?l:{};return{id:i,title:null==a?void 0:a.title,defaultValues:(null==a?void 0:a.defaultValues)||{},setting:null==a?void 0:a.setting}})(r,s),v="additional_order"===t||"additional_order_with_code"===t;if(f(v?"additional_order":"default"),"idle"===t){let e="object"==typeof a&&null!==a?a:{id:a};if((null==e?void 0:e.id)&&!w("policyAccepted")){L(g),D({open:!0,content:e});return}if(g&&!w("formSubmitted"))return void en(g);await ea()}else if(v){let e=await o("checkAllowAddItems");if(X()){if(!(null==d?void 0:d.order_id)||!e.enabled)return void el(l);await o("restorePreviousOrderData"),await ei()}else{let t=()=>{var i;null==x||null==(i=x.setUIState)||i.call(x,"pendingStep",n),N({callback:async i=>{if("success"===i)return(null==d?void 0:d.order_id)&&e.enabled?(await o("restorePreviousOrderData"),void await ei()):void el(l);let a=e_.Modal.info({title:eP.getText("pisell2.scan.order.add.on.login.required.title"),content:String(eP.getText("pisell2.scan.order.add.on.login.required")||"").trim(),okText:String(eP.getText("pisell2.event.confirm")||"OK"),maskClosable:!1,onOk:()=>{a.destroy(),t()}})}})};t();return}}else if("submit_disabled"===t)b(Z(i)||String(eP.getText("pisell2.scan.order.submit.disabled.default")||"")),await ei();else if("multiple_orders"===t)e_.Modal.info({title:eP.getText("pisell2.scan.order.step.error"),content:String(eP.getText("pisell2.scan.order.multiple.orders.tip")||"").trim(),okText:String(eP.getText("pisell2.scan.order.multiple.orders.confirm")||"I Got It"),maskClosable:!1,onOk:()=>{ee()}});else if("resource_busy"===t)if(0!==Number(l))if(X())el(l);else{let e=()=>{var t;null==x||null==(t=x.setUIState)||t.call(x,"pendingStep",n),N({callback:t=>{if("success"===t){var i;null==x||null==(i=x.deleteUIState)||i.call(x,"pendingStep"),el(l);return}e_.Modal.info({title:eP.getText("pisell2.scan.order.add.on.login.required.title"),content:String(eP.getText("pisell2.scan.order.add.on.login.required")||"").trim(),okText:String(eP.getText("pisell2.event.confirm")||"OK"),maskClosable:!1,onOk:()=>{e()}})}})};e()}else{let e=String(eP.getText("pisell2.scan.order.add.on.unavailable.description")||"");e_.Modal.info({title:eP.getText("pisell2.scan.order.add.on.unavailable.title"),content:(0,eO.jsx)("div",{style:{whiteSpace:"pre-line"},children:e.trim()}),okText:String(eP.getText("pisell2.scan.order.add.on.unavailable.confirm")||"Got it"),maskClosable:!1,onOk:()=>{location.replace("/")}})}else{let e=Z(i);e||(e="resource_block"===t?String(eP.getText("pisell2.scan.order.resource.status.exception")||""):String(eP.getText("pisell2.scan.order.store.status.exception")||"")),e_.Modal.info({title:eP.getText("pisell2.scan.order.step.error"),content:Z(e).trim(),okText:String(eP.getText("pisell2.event.confirm")||"OK"),maskClosable:!1,onOk:()=>{location.replace("/")}})}};k&&e()},[k]),(0,ex.useEffect)(()=>{window.scrollTo({top:0,behavior:"smooth"})},[n]),(0,ex.useEffect)(()=>{"product"===n?m((null==g?void 0:g.passed)===!0?String(eP.getText("pisell2.event.continue")||"下一步"):String(eP.getText("pisell2.scan.order.action.select.required")||"")):"check"===n&&m(String(eP.getText("pisell2.event.checkout")||""))},[n,null==g?void 0:g.passed]);let er={init:(0,eO.jsx)(eV4,{}),product:(0,eO.jsx)(eV2,{onCheckout:()=>s("check"),productList:$,isProductListLoading:F,onEnsureProductList:V}),check:(0,eO.jsx)(eV6,{}),error:(0,eO.jsx)(eV1,{message:eP.getText("pisell2.scan.order.store.status.exception")})},es=async()=>{if(y)return void e_.message.warning(y,2);let e=Array.isArray(null==g?void 0:g.failures)?g.failures[0]:null;if((null==g?void 0:g.passed)===!1){let t=(()=>{let e=Array.isArray(null==g?void 0:g.failures)?g.failures[0]:null,t=Array.isArray(null==e?void 0:e.targets)?e.targets:[],l=[],i=new Set;for(let e of t){let t=Number(null==e?void 0:e.product_id);Number.isFinite(t)&&t>0&&!i.has(t)&&(i.add(t),l.push(t))}return l})();t.length&&(e=>{if(!(null==e?void 0:e.length))return;let t=!1;for(let l of e){let e=document.querySelector(`[data-product-id="${String(l)}"]`);e&&(e.classList.remove("highlight-product-item"),t||(e.scrollIntoView({behavior:"smooth",block:"center"}),t=!0),e.offsetWidth,e.classList.add("highlight-product-item"),setTimeout(()=>{e.classList.remove("highlight-product-item")},3e3))}})(t);let l=String((null==e?void 0:e.validationMessage)||"").trim();e_.message.warning(l,2);return}let t=await o("getOtherParams"),l=(null==t?void 0:t.dineInConfig)??{};if(null==l?void 0:l["availability.paused"])return void e_.Modal.info({title:String(eP.getText("pisell2.scan.order.step.error")||""),content:(null==l?void 0:l["availability.pause_message"])??"",okText:String(eP.getText("pisell2.event.confirm")||"OK"),onOk:()=>{location.replace("/")}});if(!X()){var i;null==x||null==(i=x.setUIState)||i.call(x,"pendingStep","check"),N({callback:e=>{var t;null==x||null==(t=x.deleteUIState)||t.call(x,"pendingStep"),"success"===e&&s("check")}});return}s("check")},eo=rp(),ed=(0,ex.useMemo)(()=>!!eo&&"product"===n,[n,eo]),ec=(0,ex.useMemo)(()=>!eo&&"product"===n,[n,eo]);return(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsx)(eVY,{currentStep:n,onBack:()=>{"product"!==n?r():"additional_order"===v&&(null==d?void 0:d.order_id)?el(d.order_id):Q.current?(async()=>{let e=await et();if(null==e)return ee();try{await o("setEntryPaxNumber",e),await u()}catch(e){console.warn("[scanOrder] setEntryPaxNumber on back pax confirm failed",e)}})():ee()}}),(0,eO.jsxs)("div",{className:`pisell-scan-order-content-wrap ${eo?"pisell-scan-order-content-mobile-wrap":""}`,"data-cart-validation-passed":String(null==g?void 0:g.passed),children:[(0,eO.jsx)("div",{className:"pisell-scan-order-content-left",children:er[n]}),ec?(0,eO.jsx)("div",{className:"pisell-scan-order-content-right",children:(0,eO.jsx)(eVW,{embedded:!0,open:!0,onCancel:()=>{},onNext:es,items:(null==c?void 0:c.cartItems)||[],summary:(null==c?void 0:c.summary)||{},disabled:!!y})}):null]}),ed?(0,eO.jsx)(eVG,{cartItems:(null==c?void 0:c.cartItems)||[],summary:(null==c?void 0:c.summary)||{},actionText:p,onAction:()=>es(),disabled:!!y}):null,I.open?(0,eO.jsx)(Bb,{open:I.open,onCancel:()=>{D({open:!1,content:null}),location.replace("/")},onConfirm:()=>{(D({open:!1,content:null}),_("policyAccepted"),O&&!w("formSubmitted"))?en(O):ea()},item:I.content,isHideCheckout:!1,depositProtocolRequest:e=>{var t,l;return null==M||null==(l=M.request)||null==(t=l.get)?void 0:t.call(l,`/h5/shop-policy/${e}`,{})}}):null,E.open?(0,eO.jsx)(id.PisellModal,{open:E.open,platform:eo?"h5":"pc",onCancel:()=>{A(!1),z({open:!1,content:null}),L(null),location.replace("/")},title:(null==(t=E.content)?void 0:t.title)||eP.getText("pisell2.appointment.fill-form")||"填写信息",mobileModalHeight:"90vh",width:eo?"100%":900,className:"pisell-scan-order-form-modal",footer:(0,eO.jsx)("div",{className:"pisell-scan-order-form-modal-footer",children:(0,eO.jsx)(id.Button,{type:"primary",size:"large",loading:P,onClick:()=>{var e,t;P||(A(!0),null==(t=T.current)||null==(e=t.submit)||e.call(t))},className:"pisell-scan-order-form-modal-confirm-btn",children:String(eP.getText("pisell2.event.confirm")||"Confirm")})}),children:(0,eO.jsx)("div",{className:"pisell-scan-order-form-modal-body",children:C?(0,eO.jsx)(C,{id:(null==(l=E.content)?void 0:l.id)||0,ref:T,isGetLastData:!1,setting:(null==(i=E.content)?void 0:i.setting)||{isHidden:1},formWrapStyle:{padding:"16px"},isV2API:!0,isShowSkeleton:!0,onSubmit:e=>{A(!1),"success"===e&&(z({open:!1,content:null}),L(null),_("formSubmitted"),ea())},onFinishFailed:()=>{A(!1)},onFormValueChange:()=>{},defaultValues:(null==(a=E.content)?void 0:a.defaultValues)||{},isClearData:!1}):null})}):null]})}function eV7(){let{isLoading:e,errorMessage:t}=eVH();return e?(0,eO.jsx)("div",{className:"pisell-scan-order-loading",children:"Loading..."}):t?(0,eO.jsx)(eV1,{message:t,onRetry:()=>{window.location.reload()}}):(0,eO.jsx)(eV5,{})}let eV9={en:{"pisell2.scan.order.action.confirm.order":"Confirm order","pisell2.event.confirm":"Confirm","pisell2.event.cart":"Cart","pisell2.event.close.continue":"Close and continue","pisell2.event.continue":"Continue","pisell2.event.total":"Total","pisell2.scan.order.action.select.required":"Select Required","pisell2.scan.order.step.init":"Initialize","pisell2.scan.order.loading.initializing":"Preparing your order, please wait...","pisell2.scan.order.loading.products":"Loading products...","pisell2.scan.order.step.product":"Select product","pisell2.scan.order.step.check":"Check order","pisell2.scan.order.step.error":"Unavailable","pisell2.scan.order.empty.product":"No products available","pisell2.scan.order.resource.status.exception":"The current table is unavailable or locked.","pisell2.scan.order.store.status.exception":"The store is currently closed or in an abnormal state. Please contact staff.","pisell2.scan.order.note.title":"Order notes","pisell2.scan.order.note.placeholder":"Add order notes","pisell2.scan.order.fulfillment.title":"Fulfillment","pisell2.scan.order.fulfillment.table_service":"Table service","pisell2.scan.order.fulfillment.pickup":"Pickup","pisell2.scan.order.current.table":"Current table","pisell2.scan.order.pickup.ref.title":"Table Service","pisell2.scan.order.pickup.ref.heading":"Use any name you like","pisell2.scan.order.pickup.ref.description":"Enter your nickname, or anything fun!","pisell2.scan.order.pickup.ref.placeholder":"e.g. John","pisell2.scan.order.products.title":"Products","pisell2.scan.order.products.empty.tip":"Please select products","pisell2.scan.order.check.cart.empty.tip":"Please go back to add products","pisell2.scan.order.submit.disabled.default":"Order submission is currently disabled.","pisell2.scan.order.submit.failed":"Failed to submit order","pisell2.scan.order.menu.unavailable.title":"Ordering time has ended","pisell2.scan.order.menu.unavailable.description":"Some items in your cart are no longer available to order at this time. Select Confirm to refresh the page and choose your items again.","pisell2.scan.order.menu.validation.failed":"Unable to check the ordering time. Please try again. Your cart has been kept.","pisell2.scan.order.multiple.orders.tip":"There are multiple active orders for this table. Please contact staff for add-on orders.","pisell2.scan.order.multiple.orders.confirm":"I Got It","pisell2.scan.order.settled.cannot.add.tip":"This order has already been settled and you cannot add more items. Please scan again to create a new order or contact staff.","pisell2.scan.order.inventory.insufficient.title":"Insufficient inventory","pisell2.scan.order.inventory.insufficient.description":"The following items are out of stock or do not have enough inventory. Please adjust your cart and try again.","pisell2.scan.order.inventory.insufficient.products.label":"Unavailable products:","pisell2.scan.order.add.on.confirm.title":"This table has already started ordering","pisell2.scan.order.add.on.confirm.description":"Someone at your table has placed the order. This will be submitted as an add-on order.","pisell2.scan.order.add.on.confirm.button":"Confirm Add-on Order","pisell2.scan.order.add.on.return.button":"Return to Cart","pisell2.scan.order.add.on.unavailable.title":"Add-on ordering is not available","pisell2.scan.order.add.on.unavailable.description":"You can’t add items to this order from your phone right now.\nPlease ask a staff member for help.","pisell2.scan.order.add.on.unavailable.confirm":"Got it","pisell2.scan.order.add.on.login.required.title":"Notice","pisell2.scan.order.add.on.login.required":"Please login before placing an add-on order.","pisell2.text.goodpass":"Promotion","pisell2.text.goodpass.product-vouchers":"Product Vouchers","pisell2.text.goodpass.view-more":"View More","pisell2.text.goodpass.code":"Code","pisell2.text.goodpass.enter-code":"Enter Code","pisell2.text.goodpass.code-invalid":"Current code is invalid","pisell2.text.goodpass.code-invalid-cart":"No eligible items in the cart","pisell2.text.goodpass.code-invalid-expired":"Current coupon is not valid in use","pisell2.text.goodpass.login":"Login","pisell2.text.goodpass.login-tip":"to access your promotions","pisell2.text.apply":"Apply","pisell2.text.details":"Details","pisell2.appointment.booking.empty.data":"No data","pisell2.appointment.deposit.close":"Close","pisell2.appointment.policy":"You have read and agreed to this policy","pisell2.appointment.policy.confirm":"Confirm","pisell2.appointment.fill-form":"Enter your details"},"zh-CN":{"pisell2.scan.order.action.confirm.order":"确认下单","pisell2.event.confirm":"确定","pisell2.event.cart":"购物车","pisell2.event.close.continue":"关闭并继续","pisell2.event.continue":"继续","pisell2.event.total":"合计","pisell2.scan.order.action.select.required":"请选择","pisell2.scan.order.step.init":"初始化","pisell2.scan.order.loading.initializing":"正在为您准备点餐页面,请稍候...","pisell2.scan.order.loading.products":"正在获取商品中...","pisell2.scan.order.step.product":"选择商品","pisell2.scan.order.step.check":"订单确认","pisell2.scan.order.step.error":"不可用","pisell2.scan.order.empty.product":"暂无可选商品","pisell2.scan.order.resource.status.exception":"当前桌台不可用或被锁定","pisell2.scan.order.store.status.exception":"当前店铺不在营业中或者状态异常,请联系工作人员","pisell2.scan.order.note.title":"备注","pisell2.scan.order.note.placeholder":"请输入备注","pisell2.scan.order.fulfillment.title":"取餐方式","pisell2.scan.order.fulfillment.table_service":"送餐到桌","pisell2.scan.order.fulfillment.pickup":"到店自取","pisell2.scan.order.current.table":"当前桌台","pisell2.scan.order.pickup.ref.title":"桌边服务","pisell2.scan.order.pickup.ref.heading":"随便起个名字吧","pisell2.scan.order.pickup.ref.description":"输入你的昵称,或任何有趣的名字!","pisell2.scan.order.pickup.ref.placeholder":"例如:小明","pisell2.scan.order.products.title":"商品","pisell2.scan.order.products.empty.tip":"请选择商品","pisell2.scan.order.check.cart.empty.tip":"请返回添加商品","pisell2.scan.order.submit.disabled.default":"当前暂不可下单","pisell2.scan.order.submit.failed":"订单提交失败","pisell2.scan.order.menu.unavailable.title":"已过可下单时间","pisell2.scan.order.menu.unavailable.description":"购物车中有商品已不在可下单时间内。点击确定后将刷新页面,请重新选择商品。","pisell2.scan.order.menu.validation.failed":"暂时无法校验商品的可下单时间,请重试。购物车已保留。","pisell2.scan.order.multiple.orders.tip":"当前桌台存在多个进行中的订单,请联系店员处理加餐。","pisell2.scan.order.multiple.orders.confirm":"我知道了","pisell2.scan.order.settled.cannot.add.tip":"当前订单已结账,无法继续加餐。请重新扫码创建新订单或联系店员。","pisell2.scan.order.inventory.insufficient.title":"库存不足","pisell2.scan.order.inventory.insufficient.description":"以下商品库存不足或已售罄,请调整购物车后重新提交。","pisell2.scan.order.inventory.insufficient.products.label":"异常商品:","pisell2.scan.order.add.on.confirm.title":"本桌已开始点餐","pisell2.scan.order.add.on.confirm.description":"同行顾客已提交订单。本次将作为加餐提交,请确认后继续。","pisell2.scan.order.add.on.confirm.button":"确认加餐","pisell2.scan.order.add.on.return.button":"返回购物车","pisell2.scan.order.add.on.unavailable.title":"暂不支持加餐","pisell2.scan.order.add.on.unavailable.description":"当前无法通过手机为此订单加餐。\n如需加餐,请联系工作人员。","pisell2.scan.order.add.on.unavailable.confirm":"我知道了","pisell2.scan.order.add.on.login.required.title":"提示","pisell2.scan.order.add.on.login.required":"需要登录后才能加餐","pisell2.text.goodpass":"促销","pisell2.text.goodpass.product-vouchers":"商品兑换券","pisell2.text.goodpass.view-more":"查看更多","pisell2.text.goodpass.code":"券码","pisell2.text.goodpass.enter-code":"请输入券码","pisell2.text.goodpass.code-invalid":"当前券码不可用","pisell2.text.goodpass.code-invalid-cart":"当前购物车中无可用商品","pisell2.text.goodpass.code-invalid-expired":"当前优惠券不在使用期限内","pisell2.text.goodpass.login":"登录","pisell2.text.goodpass.login-tip":"以获取会员福利或使用账户积分","pisell2.text.apply":"应用","pisell2.text.details":"详情","pisell2.appointment.booking.empty.data":"暂无数据","pisell2.appointment.deposit.close":"关闭","pisell2.appointment.policy":"您已仔细阅读并同意此协议","pisell2.appointment.policy.confirm":"确定","pisell2.appointment.fill-form":"填写信息"},"zh-HK":{"pisell2.scan.order.action.confirm.order":"確認下單","pisell2.event.confirm":"確認","pisell2.event.cart":"購物車","pisell2.event.close.continue":"關閉並繼續","pisell2.event.continue":"繼續","pisell2.event.total":"合計","pisell2.scan.order.action.select.required":"請選擇","pisell2.scan.order.step.init":"初始化","pisell2.scan.order.loading.initializing":"正在為您準備點餐頁面,請稍候...","pisell2.scan.order.loading.products":"正在獲取商品中...","pisell2.scan.order.step.product":"選擇商品","pisell2.scan.order.step.check":"訂單確認","pisell2.scan.order.step.error":"不可用","pisell2.scan.order.empty.product":"暫無可選商品","pisell2.scan.order.resource.status.exception":"當前桌台不可用或被鎖定","pisell2.scan.order.store.status.exception":"當前店鋪不在營業中或者狀態異常,請聯繫工作人員","pisell2.scan.order.note.title":"備註","pisell2.scan.order.note.placeholder":"請輸入備註","pisell2.scan.order.fulfillment.title":"取餐方式","pisell2.scan.order.fulfillment.table_service":"送餐到桌","pisell2.scan.order.fulfillment.pickup":"到店自取","pisell2.scan.order.current.table":"當前桌台","pisell2.scan.order.pickup.ref.title":"桌邊服務","pisell2.scan.order.pickup.ref.heading":"隨便起個名字吧","pisell2.scan.order.pickup.ref.description":"輸入你的暱稱,或任何有趣的名字!","pisell2.scan.order.pickup.ref.placeholder":"例如:小明","pisell2.scan.order.products.title":"商品","pisell2.scan.order.products.empty.tip":"請選擇商品","pisell2.scan.order.check.cart.empty.tip":"請返回添加商品","pisell2.scan.order.submit.disabled.default":"當前暫不可下單","pisell2.scan.order.submit.failed":"訂單提交失敗","pisell2.scan.order.menu.unavailable.title":"已過可下單時間","pisell2.scan.order.menu.unavailable.description":"購物車中有商品已不在可下單時間內。點擊確定後將重新整理頁面,請重新選擇商品。","pisell2.scan.order.menu.validation.failed":"暫時無法核實商品的可下單時間,請重試。購物車已保留。","pisell2.scan.order.multiple.orders.tip":"當前桌台存在多個進行中的訂單,請聯繫店員處理加餐。","pisell2.scan.order.multiple.orders.confirm":"我知道了","pisell2.scan.order.settled.cannot.add.tip":"當前訂單已結賬,無法繼續加餐。請重新掃碼創建新訂單或聯繫店員。","pisell2.scan.order.inventory.insufficient.title":"庫存不足","pisell2.scan.order.inventory.insufficient.description":"以下商品庫存不足或已售罄,請調整購物車後重新提交。","pisell2.scan.order.inventory.insufficient.products.label":"異常商品:","pisell2.scan.order.add.on.confirm.title":"本桌已開始點餐","pisell2.scan.order.add.on.confirm.description":"同行顧客已提交訂單。本次將作為加餐提交,請確認後繼續。","pisell2.scan.order.add.on.confirm.button":"確認加餐","pisell2.scan.order.add.on.return.button":"返回購物車","pisell2.scan.order.add.on.unavailable.title":"暫不支援加餐","pisell2.scan.order.add.on.unavailable.description":"目前無法透過手機為此訂單加餐。\n如需加餐,請聯絡工作人員。","pisell2.scan.order.add.on.unavailable.confirm":"我知道了","pisell2.scan.order.add.on.login.required.title":"提示","pisell2.scan.order.add.on.login.required":"需要登錄後才能加餐","pisell2.text.goodpass":"促銷","pisell2.text.goodpass.product-vouchers":"商品兌換券","pisell2.text.goodpass.view-more":"查看更多","pisell2.text.goodpass.code":"券碼","pisell2.text.goodpass.enter-code":"請輸入券碼","pisell2.text.goodpass.code-invalid":"當前券碼不可用","pisell2.text.goodpass.code-invalid-cart":"當前購物車中無可用商品","pisell2.text.goodpass.code-invalid-expired":"當前優惠券不在使用期限內","pisell2.text.goodpass.login":"登錄","pisell2.text.goodpass.login-tip":"以獲取會員福利或使用賬戶積分","pisell2.text.apply":"應用","pisell2.text.details":"詳情","pisell2.appointment.booking.empty.data":"暫無數據","pisell2.appointment.deposit.close":"关闭","pisell2.appointment.policy":"您已仔細閱讀並同意此協議","pisell2.appointment.policy.confirm":"確定","pisell2.appointment.fill-form":"填寫資訊"},ja:{"pisell2.scan.order.action.confirm.order":"注文を確定","pisell2.event.confirm":"確認","pisell2.event.cart":"カート","pisell2.event.close.continue":"閉じて続行","pisell2.event.continue":"続行","pisell2.event.total":"合計","pisell2.scan.order.action.select.required":"選択してください","pisell2.scan.order.step.init":"初期化","pisell2.scan.order.loading.initializing":"ご注文画面を準備しています。しばらくお待ちください。","pisell2.scan.order.loading.products":"商品を取得しています...","pisell2.scan.order.step.product":"商品を選択","pisell2.scan.order.step.check":"注文確認","pisell2.scan.order.step.error":"利用不可","pisell2.scan.order.empty.product":"利用可能な商品がありません","pisell2.scan.order.resource.status.exception":"現在のテーブルは利用できないか、ロックされています。","pisell2.scan.order.store.status.exception":"現在、店舗は営業時間外または状態が異常です。スタッフまでお問い合わせください。","pisell2.scan.order.note.title":"備考","pisell2.scan.order.note.placeholder":"備考を入力してください","pisell2.scan.order.fulfillment.title":"受け取り方法","pisell2.scan.order.fulfillment.table_service":"テーブルサービス","pisell2.scan.order.fulfillment.pickup":"ピックアップ","pisell2.scan.order.current.table":"現在のテーブル","pisell2.scan.order.pickup.ref.title":"テーブルサービス","pisell2.scan.order.pickup.ref.heading":"好きな名前をどうぞ","pisell2.scan.order.pickup.ref.description":"ニックネームや楽しい名前を入力してね!","pisell2.scan.order.pickup.ref.placeholder":"例: ジョン","pisell2.scan.order.products.title":"商品","pisell2.scan.order.products.empty.tip":"商品を選択してください","pisell2.scan.order.check.cart.empty.tip":"商品を追加するには、前の画面に戻ってください","pisell2.scan.order.submit.disabled.default":"現在、注文を送信できません。","pisell2.scan.order.submit.failed":"注文の送信に失敗しました","pisell2.scan.order.menu.unavailable.title":"注文可能な時間を過ぎています","pisell2.scan.order.menu.unavailable.description":"カートに注文可能な時間を過ぎた商品があります。「確認」を押すとページが再読み込みされます。商品を選び直してください。","pisell2.scan.order.menu.validation.failed":"注文可能な時間を確認できませんでした。もう一度お試しください。カートの内容は保持されています。","pisell2.scan.order.multiple.orders.tip":"現在のテーブルには進行中の注文が複数あります。追加注文についてはスタッフにお問い合わせください。","pisell2.scan.order.multiple.orders.confirm":"了解しました","pisell2.scan.order.settled.cannot.add.tip":"現在の注文はすでに会計済みのため、追加注文できません。再度QRコードをスキャンして新しい注文を作成するか、スタッフにお問い合わせください。","pisell2.scan.order.inventory.insufficient.title":"在庫が不足しています","pisell2.scan.order.inventory.insufficient.description":"以下の商品は在庫切れ、または在庫が不足しています。カートを調整してからもう一度送信してください。","pisell2.scan.order.inventory.insufficient.products.label":"対象商品:","pisell2.scan.order.add.on.confirm.title":"このテーブルではすでに注文が開始されています","pisell2.scan.order.add.on.confirm.description":"同席のお客様がすでに注文を送信しました。今回は追加注文として送信されます。確認して続行してください。","pisell2.scan.order.add.on.confirm.button":"追加注文を確認","pisell2.scan.order.add.on.return.button":"カートに戻る","pisell2.scan.order.add.on.unavailable.title":"追加注文は現在ご利用いただけません","pisell2.scan.order.add.on.unavailable.description":"現在、スマートフォンからこの注文に商品を追加することはできません。\n追加注文をご希望の場合は、スタッフにお声がけください。","pisell2.scan.order.add.on.unavailable.confirm":"了解しました","pisell2.scan.order.add.on.login.required.title":"お知らせ","pisell2.scan.order.add.on.login.required":"追加注文を行うにはログインが必要です。","pisell2.text.goodpass":"プロモーション","pisell2.text.goodpass.product-vouchers":"商品バウチャー","pisell2.text.goodpass.view-more":"もっと見る","pisell2.text.goodpass.code":"コード","pisell2.text.goodpass.enter-code":"コードを入力","pisell2.text.goodpass.code-invalid":"現在のコードは無効です","pisell2.text.goodpass.code-invalid-cart":"カートに適格な項目がありません","pisell2.text.goodpass.code-invalid-expired":"現在のクーポンは使用期限外です","pisell2.text.goodpass.login":"ログイン","pisell2.text.goodpass.login-tip":"プロモーションにアクセスするため","pisell2.text.apply":"適用","pisell2.text.details":"詳細","pisell2.appointment.booking.empty.data":"データなし","pisell2.appointment.deposit.close":"閉じる","pisell2.appointment.policy":"このポリシーを読み、同意しました","pisell2.appointment.policy.confirm":"確認","pisell2.appointment.fill-form":"詳細を入力"},pt:{"pisell2.scan.order.action.confirm.order":"Confirmar pedido","pisell2.event.confirm":"Confirmar","pisell2.event.cart":"Carrinho","pisell2.event.close.continue":"Fechar e continuar","pisell2.event.continue":"Continuar","pisell2.event.total":"Total","pisell2.scan.order.action.select.required":"Selecionar obrigat\xf3rio","pisell2.scan.order.step.init":"Inicializar","pisell2.scan.order.loading.initializing":"Estamos preparando sua tela de pedido, aguarde...","pisell2.scan.order.loading.products":"Carregando produtos...","pisell2.scan.order.step.product":"Selecionar produto","pisell2.scan.order.step.check":"Verificar pedido","pisell2.scan.order.step.error":"Indispon\xedvel","pisell2.scan.order.empty.product":"Nenhum produto dispon\xedvel","pisell2.scan.order.resource.status.exception":"A mesa atual est\xe1 indispon\xedvel ou bloqueada.","pisell2.scan.order.store.status.exception":"A loja est\xe1 fechada no momento ou em estado anormal. Entre em contato com a equipe.","pisell2.scan.order.note.title":"Observa\xe7\xf5es do pedido","pisell2.scan.order.note.placeholder":"Adicione observa\xe7\xf5es do pedido","pisell2.scan.order.fulfillment.title":"Forma de retirada","pisell2.scan.order.fulfillment.table_service":"Servi\xe7o \xe0 mesa","pisell2.scan.order.fulfillment.pickup":"Retirada","pisell2.scan.order.current.table":"Mesa atual","pisell2.scan.order.pickup.ref.title":"Servi\xe7o \xe0 mesa","pisell2.scan.order.pickup.ref.heading":"Use o nome que quiser","pisell2.scan.order.pickup.ref.description":"Digite seu apelido ou algo divertido!","pisell2.scan.order.pickup.ref.placeholder":"Ex.: Jo\xe3o","pisell2.scan.order.products.title":"Produtos","pisell2.scan.order.products.empty.tip":"Selecione produtos","pisell2.scan.order.check.cart.empty.tip":"Volte para adicionar produtos","pisell2.scan.order.submit.disabled.default":"No momento, n\xe3o \xe9 poss\xedvel enviar pedidos.","pisell2.scan.order.submit.failed":"Falha ao enviar o pedido","pisell2.scan.order.menu.unavailable.title":"O hor\xe1rio para pedidos terminou","pisell2.scan.order.menu.unavailable.description":"Alguns itens no carrinho n\xe3o est\xe3o mais dispon\xedveis para pedido neste hor\xe1rio. Selecione Confirmar para atualizar a p\xe1gina e escolher os itens novamente.","pisell2.scan.order.menu.validation.failed":"N\xe3o foi poss\xedvel verificar o hor\xe1rio para pedidos. Tente novamente. Seu carrinho foi mantido.","pisell2.scan.order.multiple.orders.tip":"H\xe1 v\xe1rios pedidos ativos nesta mesa. Entre em contato com a equipe para adicionar itens.","pisell2.scan.order.multiple.orders.confirm":"Entendi","pisell2.scan.order.settled.cannot.add.tip":"Este pedido j\xe1 foi finalizado e n\xe3o \xe9 poss\xedvel adicionar mais itens. Escaneie novamente para criar um novo pedido ou entre em contato com a equipe.","pisell2.scan.order.inventory.insufficient.title":"Estoque insuficiente","pisell2.scan.order.inventory.insufficient.description":"Os seguintes itens est\xe3o sem estoque ou n\xe3o t\xeam estoque suficiente. Ajuste o carrinho e tente novamente.","pisell2.scan.order.inventory.insufficient.products.label":"Produtos indispon\xedveis:","pisell2.scan.order.add.on.confirm.title":"Esta mesa j\xe1 come\xe7ou a fazer o pedido","pisell2.scan.order.add.on.confirm.description":"Algu\xe9m na sua mesa j\xe1 enviou o pedido. Este ser\xe1 enviado como um pedido adicional.","pisell2.scan.order.add.on.confirm.button":"Confirmar pedido adicional","pisell2.scan.order.add.on.return.button":"Voltar ao carrinho","pisell2.scan.order.add.on.unavailable.title":"Pedidos adicionais n\xe3o est\xe3o dispon\xedveis","pisell2.scan.order.add.on.unavailable.description":"No momento, voc\xea n\xe3o pode adicionar itens a este pedido pelo celular.\nPe\xe7a ajuda a um membro da equipe.","pisell2.scan.order.add.on.unavailable.confirm":"Entendi","pisell2.scan.order.add.on.login.required.title":"Aviso","pisell2.scan.order.add.on.login.required":"Fa\xe7a login antes de fazer um pedido adicional.","pisell2.text.goodpass":"Promo\xe7\xe3o","pisell2.text.goodpass.product-vouchers":"Vales de Produto","pisell2.text.goodpass.view-more":"Ver Mais","pisell2.text.goodpass.code":"C\xf3digo","pisell2.text.goodpass.enter-code":"Digite o C\xf3digo","pisell2.text.goodpass.code-invalid":"C\xf3digo atual \xe9 inv\xe1lido","pisell2.text.goodpass.code-invalid-cart":"Nenhum item eleg\xedvel no carrinho","pisell2.text.goodpass.code-invalid-expired":"Cupom atual n\xe3o est\xe1 no per\xedodo de uso","pisell2.text.goodpass.login":"Entrar","pisell2.text.goodpass.login-tip":"para acessar suas promo\xe7\xf5es","pisell2.text.apply":"Aplicar","pisell2.text.details":"Detalhes","pisell2.appointment.booking.empty.data":"Sem dados","pisell2.appointment.deposit.close":"Fechar","pisell2.appointment.policy":"Voc\xea leu e concordou com esta pol\xedtica","pisell2.appointment.policy.confirm":"Confirmar","pisell2.appointment.fill-form":"Digite seus detalhes"}},eYe=function(e){var t,l,i,a;let n=eI(),r={biz:(null==(a=null==n||null==(t=n.engine)?void 0:t.props)?void 0:a.biz)||"",resource_id:null==a?void 0:a.resource_id,order_id:null==a?void 0:a.order_id};return eP.init(eV9,(null==n||null==(i=n.engine)||null==(l=i.props)?void 0:l.locale)||"en"),(0,eO.jsx)("div",{className:`pisell-scan-order-wrap ${rp()?"pisell-scan-order-mobile-wrap":""}`,children:(0,eO.jsx)(eVq,{entryContext:r,children:(0,eO.jsx)(eV7,{})})})};function eYt(e){if(!e||"object"!=typeof e)return null;let t=ev7(e);return"string"!=typeof t.unique_identification_number||0===t.unique_identification_number.length?null:t}function eYl(e){var t;return null==(t=eYt(e))?void 0:t.unique_identification_number}let eYi=[61947,61948];function eYa(){var e,t;let l,i=(null==(l=eI())||null==(t=l.appHelper)?void 0:t.utils)||{};return String((null==i||null==(e=i.getSymbolic)?void 0:e.call(i))||"$")}function eYn(e,t,l){if("function"!=typeof(null==e?void 0:e[t]))return l;let i=e[t]();return i&&"function"==typeof(null==i?void 0:i.then)?l:i??l}async function eYr(e,t){for(var l=arguments.length,i=Array(l>2?l-2:0),a=2;a<l;a++)i[a-2]=arguments[a];if(!e)throw Error("venueBooking module not found");if("function"!=typeof(null==e?void 0:e[t]))throw Error(`venueBooking action "${t}" not found`);return e[t](...i)}async function eYs(e,t){return eYr(e,"loadVenueProducts",{productIds:t})}async function eYo(e,t,l){return eYr(e,"fetchResourceAvailability",{startDate:t,endDate:l})}function eYd(e,t,l){return e&&"function"==typeof e.getDateRangeSummary&&e.getDateRangeSummary({startDate:t,endDate:l})||[]}function eYc(e,t){return e&&"function"==typeof e.getTimeSlotGrid&&e.getTimeSlotGrid(t)||null}async function eYu(e,t){return eYr(e,"toggleSlot",t)}function eYp(e,t,l,i){return!!e&&"function"==typeof e.isSlotSelected&&!!e.isSlotSelected(t,l,i)}function eYm(e,t){return!!e&&"function"==typeof e.isSlotDisabledBySelection&&!!e.isSlotDisabledBySelection(t)}function eYg(e,t){for(let l of[null==t?void 0:t.startTime,null==t?void 0:t.start_time,null==t?void 0:t.startDate,null==t?void 0:t.start_date]){let t=function(e){if("string"!=typeof e)return null;let t=e.trim().match(/^(\d{4}-\d{2}-\d{2})/);return t?t[1]:null}(l);if(t)return void e.add(t)}}async function eYh(e){let t="function"==typeof(null==e?void 0:e.getSummary)?await e.getSummary():null,l=eYn(e,"getOrderProducts",[]),i=Array.isArray(l)?l:[],a=eYn(e,"getTempOrder",null),n=(null==a?void 0:a.currency_symbol)||"$",r=i.map(e=>{var t,l,i,n;let r=eYl(e),s=(null==a||null==(i=a._extend)||null==(l=i.productsByUid)||null==(t=l[r])?void 0:t.origin)??e._origin,o=Array.isArray(null==(n=e.product_sku)?void 0:n.option)?e.product_sku.option.map(e=>({...e,price:e.add_price??e.price})):e.product_option_item;return{...e,identity_key:r,product_option_item:o,_origin:Array.isArray(o)?{...s,callbackData:{...null==s?void 0:s.callbackData,option:o}}:s}}),s=eVE({orderProducts:r,amountSymbol:n}).map((e,t)=>{let l=r[t],i=l.identity_key;return{...e,metadata:l.metadata,product_sku:l.product_sku,unique_identification_number:i,_id:i??e._id,rowKey:i??e.rowKey}}),o=(t&&"object"==typeof t?t:null)||(null==a?void 0:a.summary)||{};return{cartItems:s,summary:o&&"object"==typeof o?o:{},note:String((null==a?void 0:a.note)||""),contactsInfo:Array.isArray(null==a?void 0:a.contacts_info)?a.contacts_info:[]}}function eYv(e){return e.format("YYYY-MM-DD")}function eYf(e){let t=e.startOf("week");return Array.from({length:7},(e,l)=>t.add(l,"day"))}function eYy(e){return e.format("MMMM YYYY")}function eYb(e){return e.endsWith(":00")}function eYx(e,t){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"$",i=eYv(e),a=t.find(e=>e.date===i);if(!a)return{topTag:null,startingPrice:null,fewLeft:!1,soldOut:!0,unavailable:!0};let n="sold_out"===a.status||"unavailable"===a.status,r="few_left"===a.status,s="unavailable"===a.status,o=a.startingPrice?`${l}${a.startingPrice}+`:null;return{topTag:null,startingPrice:n||s?null:o,fewLeft:r,soldOut:n,unavailable:s}}function eYk(e,t){let l=e.filter(e=>e.slots[t]&&"available"===e.slots[t].status).length,i=e.length>0?l/e.length:0;return{soldOut:0===l,fewLeft:l>0&&i<.2}}function eY_(e){return{price:e.price?parseFloat(e.price):0,originalPrice:null,label:"",highlight:!1}}function eYw(e){return e.highlight?"text-emerald-600":"Pickleball"===e.courtType?"vb-primary-text":"text-zinc-800"}let eYj=(0,ex.createContext)(void 0),eYS={dateSummary:[],timeSlotGrid:null,cartItems:[],summary:{},note:"",contactsInfo:[],venueProducts:[],addonProductList:[]},eYN={};function eYM(e,t){let l=eYv(ef()());return t<l?null:{startDate:e<l?l:e,endDate:t}}function eYC(e){var t,l,i;let{entryContext:a,children:n}=e,r=eD(),s=function(){let e=eD(),t=(0,ex.useRef)(null);if(!t.current){var l;t.current=(null==e||null==(l=e.getModule)?void 0:l.call(e,"venueBooking"))??null}return t.current}(),[o,d]=(0,ex.useState)("select-venue"),c=(0,ex.useRef)(!1),[u,p]=(0,ex.useState)(!1),[m,g]=(0,ex.useState)(eYS),h=(0,ex.useRef)(m);h.current=m;let v=(0,ex.useMemo)(()=>{var e;return((null==(e=m.addonProductList)?void 0:e.length)||0)>0?["select-venue","addons","checkout"]:["select-venue","checkout"]},[null==(t=m.addonProductList)?void 0:t.length]),[f,y]=(0,ex.useState)(!0),[b,x]=(0,ex.useState)(!0),[k,_]=(0,ex.useState)(!0),w=b||k,[j,S]=(0,ex.useState)(ef()()),[N,M]=(0,ex.useState)("ALL"),[C,T]=(0,ex.useState)(""),[P,A]=(0,ex.useState)(""),[I,D]=(0,ex.useState)(!1),[E,z]=(0,ex.useState)(!1),[O,L]=(0,ex.useState)(ef()().startOf("month")),{isLogin:$,openLoginModal:R}=qS(),F=eI(),B=(null==F||null==(l=F.appHelper)?void 0:l.utils)||eYN,[q,H]=(0,ex.useState)([]),[V,Y]=(0,ex.useState)(!1),[U,W]=(0,ex.useState)({passed:null,failures:[]}),[G,Q]=(0,ex.useState)(String(eP.getText("pisell2.venue.action.next.addons")||"")),[K,Z]=(0,ex.useState)(!1),J=(0,ex.useRef)(j);J.current=j;let X=(0,ex.useRef)(!1),ee=(0,ex.useMemo)(()=>{let e=s&&"function"==typeof s.getAllSelectedSlots&&s.getAllSelectedSlots()||[];return!!Array.isArray(e)&&e.length>0||m.cartItems.length>0},[s,m]);(0,ex.useEffect)(()=>{if(!P)return;let e=window.setTimeout(()=>A(""),3800);return()=>window.clearTimeout(e)},[P]),(0,ex.useEffect)(()=>{var e,t,l;if(c.current||!s)return;c.current=!0;let i=null==(e=s.getUIState)?void 0:e.call(s,"pendingStep");if(i){null==(l=s.deleteUIState)||l.call(s,"pendingStep"),d(i);return}let a=null==(t=s.getUIState)?void 0:t.call(s,"step");a&&d(a)},[s]),(0,ex.useEffect)(()=>{var e;c.current&&s&&(null==(e=s.setUIState)||e.call(s,"step",o))},[o,s]),(0,ex.useEffect)(()=>{c.current&&u&&(v.includes(o)||d(v[0]))},[v,o,u]);let et=(0,ex.useCallback)(async e=>{try{let t=await eYh(s);if(g(l=>({...l,...t,...e||{}})),s&&"function"==typeof s.getDiscountList){let e=s.getDiscountList()||[];H(e)}}catch(e){console.warn("[venueBooking] refreshViewModel failed",e)}},[s]),el=(0,ex.useCallback)(e=>{if(!s)return;let t=eYc(s,e||eYv(J.current));g(e=>({...e,timeSlotGrid:t}))},[s]),ei=(0,ex.useCallback)(async(e,t)=>{if(s){x(!0);try{let l=eYM(e,t),i=[];if(l){await eYo(s,l.startDate,l.endDate);let e=eYd(s,l.startDate,l.endDate);i=Array.isArray(e)?e:[]}let a=eYv(J.current),n=eYc(s,a);g(e=>({...e,dateSummary:i,timeSlotGrid:n}))}finally{x(!1)}}},[s]),ea=(0,ex.useCallback)(async e=>{if(s){x(!0);try{let t=[];for(let l=0;l<=8;l++){let i=e.add(7*l,"day"),{startDate:a,endDate:n}=function(e){let t=eYf(e);return{startDate:eYv(t[0]),endDate:eYv(t[t.length-1])}}(i),r=eYM(a,n);if(!r)continue;await eYo(s,r.startDate,r.endDate);let o=eYd(s,r.startDate,r.endDate);0===l&&(t=Array.isArray(o)?o:[]);let d=function(e){let{summary:t,preferredDate:l}=e;if(!Array.isArray(t)||!t.length)return null;let i=t.filter(e=>(null==e?void 0:e.status)==="available"||(null==e?void 0:e.status)==="few_left").map(e=>ef()(String((null==e?void 0:e.date)||""))).filter(e=>e.isValid());if(!i.length)return null;let a=l.startOf("day"),n=i.filter(e=>!e.isBefore(a,"day")).sort((e,t)=>e.valueOf()-t.valueOf());return n.length?n[0]:i.sort((e,t)=>t.valueOf()-e.valueOf())[0]}({summary:Array.isArray(o)?o:[],preferredDate:0===l?e:i.startOf("week")});if(!d)continue;S(d),L(d.startOf("month"));let c=eYc(s,eYv(d));g(e=>({...e,dateSummary:Array.isArray(o)?o:[],timeSlotGrid:c}));return}let l=eYc(s,eYv(e));S(e),L(e.startOf("month")),g(e=>({...e,dateSummary:t,timeSlotGrid:l}))}finally{x(!1)}}},[s]),en=(0,ex.useCallback)(async(e,t,l)=>{if(s&&l.price)try{await eYu(s,{resourceId:e,productId:t,startTime:l.startTime,endTime:l.endTime,price:l.price}),el(),await et()}catch(e){console.warn("[venueBooking] toggleSlot failed",e)}},[s,el,et]),er=(0,ex.useCallback)(async e=>{await eYr(s,"updateTempOrderNote",e),await et()},[s,et]),es=(0,ex.useCallback)(async function(e){for(var t=arguments.length,l=Array(t>1?t-1:0),i=1;i<t;i++)l[i-1]=arguments[i];return eYr(s,e,...l)},[s]),eo=(0,ex.useCallback)(async()=>{try{var e,t,l,i,a;if("function"!=typeof(null==B||null==(e=B.token)?void 0:e.get))return;if(!(null==B||null==(l=B.token)||null==(t=l.get)?void 0:t.call(l)))return void await es("onCustomerLogout");let n=null==B||null==(a=B.storage)||null==(i=a.get)?void 0:i.call(a,"customer"),r="string"==typeof n?JSON.parse(n||"{}"):n||{},s=null==r?void 0:r.id;if(!s)return;await es("onCustomerLogin",{customerId:s})}catch(e){console.warn("[venueBooking] syncCustomerLoginToModule failed",e)}},[B,es]),ed=(0,ex.useCallback)(e=>{v.includes(e)&&d(e)},[v]),ec=(0,ex.useCallback)(()=>{d(e=>{let t=v.findIndex(t=>t===e);return t<0||t>=v.length-1?e:v[t+1]})},[v]),eu=(0,ex.useCallback)(()=>{d(e=>{let t=v.findIndex(t=>t===e);return t<=0?e:v[t-1]})},[v]),ep=(0,ex.useCallback)(async()=>{try{var e;await eo();let t=(null==s||null==(e=s.getDiscountList)?void 0:e.call(s))||[];H(t),await et()}catch(e){console.warn("[venueBooking] handleLoginSuccess failed",e)}},[eo,s,et]),em=(0,ex.useRef)(eo);em.current=eo;let eg=(0,ex.useRef)(ea);eg.current=ea;let eh=(0,ex.useRef)(ep);eh.current=ep;let ev=(0,ex.useCallback)(async()=>{if(!K)try{var e,t,l;Z(!0);let i=await eYr(s,"submitOrder");await et();let a=(null==i||null==(e=i.data)?void 0:e.order_id)||(null==i?void 0:i.order_id)||"",n=null==m||null==(t=m.summary)?void 0:t.total_amount;if(e_.message.success({content:String(eP.getText("pisell2.venue.order.submit.success")||"订单已提交"),duration:2}),!a)return void console.warn("[venueBooking] submitOrder succeeded but order_id is missing",i);let r=s&&"function"==typeof s.getOtherParams&&s.getOtherParams()||{};if("function"==typeof(null==B?void 0:B.action)&&(null==r?void 0:r.openData["sale.require_payment_on_submit"])){if(0===n||(null==r||null==(l=r.openData["checkout.checkout_options"])?void 0:l.length)===0)return location.replace(`/payment-finish/success?amount=${n}&order_id=${a}`);B.action({type:"pisell1.payment",data:{order_id:a,total_amount:n},callback:e=>{}})}else location.replace(`/order/details?id=${a}`)}catch(e){e_.message.error({content:function(e){let t=Array.isArray(null==e?void 0:e.failures)?e.failures[0]:null,l=String((null==t?void 0:t.validationMessage)||"").trim();if(l)return l;let i=String((null==e?void 0:e.message)||"").trim();return i||String(eP.getText("pisell2.venue.error.submit.order")||"提交订单失败,请稍后重试。")}(e),duration:2}),console.warn("[venueBooking] submitOrder failed",e)}finally{Z(!1)}},[K,s,et,B,null==m||null==(i=m.summary)?void 0:i.total_amount]),ey=(0,ex.useCallback)(async()=>{var e;$?await ev():(null==s||null==(e=s.setUIState)||e.call(s,"pendingStep","checkout"),R({callback:e=>{var t;"success"===e&&(null==s||null==(t=s.deleteUIState)||t.call(s,"pendingStep"),ep().then(()=>{ev()}))}}))},[$,R,ep,ev,s]),eb=(0,ex.useCallback)(()=>{if(!$){var e;null==s||null==(e=s.setUIState)||e.call(s,"pendingStep","checkout"),R({callback:e=>{if("success"===e){var t;null==s||null==(t=s.deleteUIState)||t.call(s,"pendingStep"),ep().then(()=>ed("checkout"))}}});return}if("addons"===o){let{hasError:e}=(e=>{let{items:t=[],getHolderConfig:l=egA}=e,i=t.filter(e=>!!epz(l(e))&&!egN(e));return{hasError:i.length>0,invalidItems:i}})({items:m.cartItems,getHolderConfig:egA});if(e)return}ed("checkout")},[$,R,ep,ed,s,o,m.cartItems,egA]),ek=(0,ex.useCallback)(()=>{var e,t;if("select-venue"===o)return ee?"checkout"===v[1]?void eb():void ed("addons"):void e_.message.warning({content:String(eP.getText("pisell2.venue.cart.choose.first")||"请先选择场地。"),duration:2});if("addons"===o)return void eb();let l=null==(e=m.summary)?void 0:e.deposit;(null==l?void 0:l.hasDeposit)&&(null==l||null==(t=l.deposit_policy_data)?void 0:t.length)>0&&!V?e_.message.warning(String(eP.getText("pisell2.appointment.deposit.agree.policy")||"请先同意定金协议")):ey()},[o,ee,V,m.summary,v,ed,ey,eb]);(0,ex.useEffect)(()=>{var e;let t=null==B?void 0:B.pubsub;if(!t)return;let l=async e=>{("success"===e||(null==e?void 0:e.status)==="success")&&await eh.current()};return null==(e=t.subscribe)||e.call(t,"pisell1.login.success",l),()=>{var e;null==(e=t.unsubscribe)||e.call(t,"pisell1.login.success",l)}},[null==B?void 0:B.pubsub]),(0,ex.useEffect)(()=>{var e,t;if(!s)return;let l=!1,i=async()=>{try{var e,t;let i=await eYh(s),a=await (null==(e=s.getProductList)?void 0:e.call(s));if(l)return;let n=h.current.dateSummary.map(e=>e.date).sort(),r=n.length?eYd(s,n[0],n[n.length-1]):[],o=eYc(s,eYv(J.current));g(e=>{var t;return{...e,...i,timeSlotGrid:o,dateSummary:Array.isArray(r)?r:e.dateSummary,venueProducts:(null==(t=s.getVenueProducts)?void 0:t.call(s))||e.venueProducts,addonProductList:Array.isArray(a)?a:e.addonProductList}}),H((null==(t=s.getDiscountList)?void 0:t.call(s))||[])}catch(e){console.warn("[venueBooking] smart pricing refresh failed",e)}};return null==r||null==(t=r.effects)||null==(e=t.on)||e.call(t,"venueBooking:onSmartPricingUpdated",i),()=>{var e,t;l=!0,null==r||null==(t=r.effects)||null==(e=t.off)||e.call(t,"venueBooking:onSmartPricingUpdated",i)}},[r,s]),(0,ex.useEffect)(()=>{if(!s)return;_(!0),el(eYv(j));let e=window.setTimeout(()=>_(!1),220);return()=>window.clearTimeout(e)},[j,s,el]),(0,ex.useEffect)(()=>{var e,t;if(!s)return;let l=!1,i=e=>{let t=null==e?void 0:e.cartValidation;W({passed:"boolean"==typeof(null==t?void 0:t.passed)||(null==t?void 0:t.passed)===null?t.passed:"boolean"==typeof(null==e?void 0:e.cartValidationPassed)?e.cartValidationPassed:null,failures:Array.isArray(null==t?void 0:t.failures)?t.failures:[]})};return(async()=>{try{let e=await eYr(s,"getCartValidation");l||W({passed:"boolean"==typeof(null==e?void 0:e.passed)||(null==e?void 0:e.passed)===null?e.passed:null,failures:Array.isArray(null==e?void 0:e.failures)?e.failures:[]})}catch{l||W({passed:null,failures:[]})}})(),null==r||null==(t=r.effects)||null==(e=t.on)||e.call(t,"venueBooking:onCartValidationChanged",i),()=>{var e,t;l=!0,null==r||null==(t=r.effects)||null==(e=t.off)||e.call(t,"venueBooking:onCartValidationChanged",i)}},[r,s]),(0,ex.useEffect)(()=>{if(X.current||!s)return;X.current=!0;let e=!1;return(async()=>{try{y(!0),await em.current(),await eYs(s,eYi);let t="function"==typeof(null==s?void 0:s.getVenueProducts)?s.getVenueProducts():[];await eg.current(J.current);let l=await eYh(s);e||(g(e=>({...e,cartItems:Array.isArray(l.cartItems)?l.cartItems:[],summary:l.summary||{},note:l.note||"",contactsInfo:Array.isArray(l.contactsInfo)?l.contactsInfo:[],venueProducts:Array.isArray(t)?t:[]})),y(!1),"function"==typeof(null==s?void 0:s.getProductList)?s.getProductList().then(t=>{!e&&Array.isArray(t)&&g(e=>({...e,addonProductList:t}))}).catch(e=>{console.warn("[venueBooking] prefetch getProductList failed",e)}).finally(()=>{e||p(!0)}):p(!0))}catch(t){console.warn("[venueBooking] bootstrap failed",t),e||y(!1)}})(),()=>{e=!0}},[s]);let ew=(0,ex.useMemo)(()=>({venueBookingModule:s,currentStep:o,stepList:v,viewModel:m,anchorDate:j,filter:N,search:C,isLoading:f,isWeekLoading:b,isGridLoading:w,limitMessage:P,mobileCartOpen:I,monthPickerOpen:E,monthCursor:O,canNext:ee,cartValidation:U,footerActionText:G,isSubmittingOrder:K,isLogin:$,openLoginModal:R,handleLoginSuccess:ep,discountList:q,isAgreeDepositPolicy:V,setIsAgreeDepositPolicy:Y,goToStep:ed,nextStep:ec,prevStep:eu,setAnchorDate:S,setFilter:M,setSearch:T,setLimitMessage:A,setMobileCartOpen:D,setMonthPickerOpen:z,setMonthCursor:L,setFooterActionText:Q,toggleSlot:en,refreshViewModel:et,fetchWeekData:ei,goToNearestAvailableDate:ea,refreshTimeSlotGrid:el,runModuleAction:es,updateOrderNote:er,handlePrimaryAction:ek,handleSubmitOrder:ey}),[s,o,m,j,N,C,f,b,w,P,I,E,O,ee,U,G,K,$,R,ep,q,en,et,ei,ea,el,es,er,ek,ey,ed,ec,eu]);return(0,eO.jsx)(eYj.Provider,{value:ew,children:n})}function eYT(){let e=(0,ex.useContext)(eYj);if(e)return e;throw Error("useVenueBookingContext must be used within VenueBookingProvider")}function eYP(){var e;let{currentStep:t,canNext:l,viewModel:i,goToStep:a,prevStep:n}=eYT(),[r,s]=(0,ex.useState)(!1),[o,d]=(0,ex.useState)(!1),c=(0,ex.useRef)(null),u=(0,ex.useMemo)(()=>{var e;return[{key:"select-venue",titleKey:"pisell2.venue.step.select"},...((null==(e=i.addonProductList)?void 0:e.length)||0)>0?[{key:"addons",titleKey:"pisell2.venue.step.addons"}]:[],{key:"checkout",titleKey:"pisell2.venue.step.checkout"}].map((e,t)=>({...e,n:t+1}))},[null==(e=i.addonProductList)?void 0:e.length]),p=u.findIndex(e=>e.key===t),m=u[p]||u[0],g=p<=0;function h(e){return"select-venue"===e.key||"addons"===e.key&&l}function v(e){let t=u.findIndex(t=>t.key===e.key);return t<p?"done":t===p?"active":"pending"}function f(e){let t=v(e);if("select-venue"===e.key&&l&&"done"===t)return(0,eO.jsx)("span",{className:"ml-1 inline-flex h-5 w-5 items-center justify-center rounded-full text-[11px] font-bold text-white",style:{backgroundColor:"var(--vb-primary)"},children:(0,eO.jsx)(id.Iconfont,{type:"pisell2-check",style:{fontSize:12}})});if("addons"===e.key){let e=(i.cartItems||[]).filter(e=>!(null==e?void 0:e.start_date)||!(null==e?void 0:e.end_date)).length;return e<=0?null:(0,eO.jsxs)("span",{className:"ml-1 inline-flex min-w-[20px] items-center justify-center rounded-full bg-[#111111] px-1.5 text-[11px] font-bold text-white",children:["+",e]})}return null}let y=u.filter(e=>u.findIndex(t=>t.key===e.key)<p&&h(e));return(0,eO.jsxs)("div",{ref:c,className:"relative bg-white p-3 md:rounded-[24px] md:p-4",children:[(0,eO.jsx)(e_.Modal,{open:o,onCancel:()=>d(!1),title:String(eP.getText("pisell2.venue.leave.title")||"Leave booking?"),centered:!0,footer:(0,eO.jsxs)("div",{style:{display:"flex",gap:24},children:[(0,eO.jsx)("button",{type:"button",onClick:()=>d(!1),style:{flex:1,borderRadius:12,border:"none",background:"#f4f4f5",padding:"12px 0",fontSize:16,fontWeight:600,color:"#3f3f46",cursor:"pointer"},children:String(eP.getText("pisell2.venue.leave.stay")||"Stay")}),(0,eO.jsx)("button",{type:"button",onClick:()=>{d(!1),function(){if("u">typeof window){if(window.history.length>1)return window.history.back();window.location.href="/"}}()},style:{flex:1,borderRadius:12,border:"none",background:"var(--vb-primary, #ea1018)",padding:"12px 0",fontSize:16,fontWeight:700,color:"#fff",cursor:"pointer"},children:String(eP.getText("pisell2.venue.leave.confirm")||"Leave")})]}),children:(0,eO.jsx)("p",{className:"text-sm text-zinc-500",children:String(eP.getText("pisell2.venue.leave.desc")||"Your selections will be lost if you leave now.")})}),r&&y.length>0?(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsx)("div",{className:"fixed inset-0 z-40 md:hidden",onClick:()=>s(!1)}),(0,eO.jsx)("div",{className:"absolute left-4 right-4 top-full z-50 mt-2 overflow-hidden rounded-2xl bg-white shadow-[0_8px_30px_rgba(20,20,20,0.12)] ring-1 ring-black/[0.06] md:hidden",children:y.map((e,t)=>(0,eO.jsxs)("button",{type:"button",onClick:()=>{a(e.key),s(!1)},className:`flex w-full items-center gap-3 px-4 py-3 text-left transition hover:bg-zinc-50 active:bg-zinc-100 ${t>0?"border-t border-zinc-100":""}`,children:[(0,eO.jsxs)("div",{className:"flex h-8 min-w-[62px] shrink-0 items-center justify-center rounded-full bg-zinc-100 px-2.5 text-xs font-bold text-zinc-700",children:[e.n,"/",u.length]}),(0,eO.jsxs)("div",{className:"flex items-center text-sm font-semibold text-zinc-800",children:[(0,eO.jsx)("span",{children:eP.getText(e.titleKey)||"-"}),f(e)]})]},e.key))})]}):null,(0,eO.jsxs)("div",{className:"flex items-center gap-3",children:[g?null:(0,eO.jsx)("button",{type:"button","aria-label":"Back",onClick:function(){g?d(!0):n()},className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-zinc-50 text-zinc-700 transition hover:bg-zinc-100",children:(0,eO.jsx)("svg",{viewBox:"0 0 24 24",className:"h-5 w-5",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,eO.jsx)("path",{d:"M15 18l-6-6 6-6"})})}),(0,eO.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eO.jsx)("div",{className:`md:hidden ${y.length>0?"cursor-pointer":""}`,onClick:()=>{y.length>0&&s(e=>!e)},children:(0,eO.jsxs)("div",{className:"flex items-center gap-3",children:[(0,eO.jsxs)("div",{className:"flex h-8 min-w-[62px] items-center justify-center rounded-full px-2.5 text-xs font-bold md:h-10 md:min-w-[74px] md:text-sm",style:{backgroundColor:"var(--vb-primary-light)",color:"var(--vb-primary)"},children:[p+1,"/",u.length]}),(0,eO.jsx)("div",{className:"min-w-0 flex-1 text-lg font-extrabold text-zinc-900 md:text-xl",children:eP.getText(m.titleKey)||"-"}),y.length>0?(0,eO.jsx)("svg",{viewBox:"0 0 24 24",className:`h-5 w-5 shrink-0 text-zinc-400 transition-transform ${r?"rotate-180":""}`,fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,eO.jsx)("path",{d:"M6 9l6 6 6-6",strokeLinecap:"round",strokeLinejoin:"round"})}):null]})}),(0,eO.jsx)("div",{className:"hidden items-center gap-3 md:flex",children:u.map((e,t)=>{let l=v(e),i=h(e);return(0,eO.jsxs)(ek().Fragment,{children:[(0,eO.jsxs)("button",{type:"button",onClick:()=>{i&&a(e.key)},className:`flex items-center gap-3 rounded-full px-3 py-2 transition ${"done"===l?"bg-zinc-50":"active"!==l?"bg-zinc-50/80":""} ${i?"cursor-pointer hover:bg-zinc-100":"cursor-default"}`,style:"active"===l?{backgroundColor:"var(--vb-primary-light)"}:void 0,children:[(0,eO.jsx)("div",{className:`flex h-8 w-8 items-center justify-center rounded-full text-sm font-bold ${"done"===l?"bg-[#111] text-white":"active"===l?"text-white":"bg-white text-zinc-400"}`,style:"active"===l?{backgroundColor:"var(--vb-primary)"}:void 0,children:"done"===l?(0,eO.jsx)(id.Iconfont,{type:"pisell2-check",style:{fontSize:15}}):e.n}),(0,eO.jsxs)("div",{className:`flex items-center text-sm font-semibold ${"active"===l?"text-zinc-900":"done"===l?"text-zinc-700":"text-zinc-400"}`,children:[(0,eO.jsx)("span",{children:eP.getText(e.titleKey)||"-"}),f(e)]})]}),t<u.length-1?(0,eO.jsx)("div",{className:"relative h-px flex-1 overflow-hidden rounded-full bg-zinc-200",children:(0,eO.jsx)("div",{className:`absolute left-0 top-0 h-full ${"done"===l?"w-full bg-[#111]":"active"===l?"w-1/2":"w-0"}`,style:"active"===l?{backgroundColor:"var(--vb-primary)"}:void 0})}):null]},e.n)})})]}),(0,eO.jsx)("button",{type:"button","aria-label":"Close",onClick:d.bind(null,!0),className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-zinc-50 text-zinc-700 transition hover:bg-zinc-100",children:(0,eO.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-5 w-5",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,eO.jsx)("path",{d:"M18 6 6 18"}),(0,eO.jsx)("path",{d:"M6 6l12 12"})]})})]})]})}function eYA(){let{isLogin:e,openLoginModal:t,handleLoginSuccess:l,discountList:i,runModuleAction:a,refreshViewModel:n,venueBookingModule:r}=eYT(),[s,o]=(0,ex.useState)(!0),[d,c]=(0,ex.useState)(""),u=(0,ex.useMemo)(()=>(i||[]).filter(e=>!!e.isAvailable).map(e=>({...e,isDisabled:e.isDisabled||e.isDisabledForProductUsed})),[i]),p=(0,ex.useCallback)(async()=>{await n()},[n]),m=(0,ex.useCallback)(async()=>{if(d.trim())try{var e;let t=null==r||null==(e=r.getTempOrder)?void 0:e.call(r),l=(null==t?void 0:t.customer_id)||void 0,i=await a("scanCode",d,l);if(null==i?void 0:i.isAvailable)c(""),await p();else{let e={time_limit:eP.getText("pisell2.text.goodpass.code-invalid-expired")};e_.message.error({content:String((null==i?void 0:i.type)==="server"?eP.getText("pisell2.text.goodpass.code-invalid"):e[null==i?void 0:i.unavailableReason]||eP.getText("pisell2.text.goodpass.code-invalid-cart"))})}}catch(e){console.warn("[venueBooking] scanCode failed",e),e_.message.error({content:String(eP.getText("pisell2.text.goodpass.code-invalid")||"兑换码无效")})}},[d,r,a,p]),g=(0,ex.useCallback)(async e=>{try{await a("setDiscountSelected",{discountId:e.id,isSelected:e.isSelected}),await p()}catch(e){console.warn("[venueBooking] setDiscountSelected failed",e)}},[a,p]),h=(0,ex.useCallback)(e=>[...e].sort((e,t)=>Number(null==t?void 0:t.isSelected)-Number(null==e?void 0:e.isSelected)),[]);return(0,eO.jsxs)("div",{className:"pisell-lowcode__appointment-booking-voucher-container",children:[(0,eO.jsxs)("div",{className:"voucher-title",children:[(0,eO.jsx)("span",{className:"voucher-title-left",children:eP.getText("pisell2.text.goodpass")}),(0,eO.jsxs)("span",{className:"voucher-title-right",onClick:()=>o(!s),children:[eP.getText("pisell2.text.details")," ",(0,eO.jsx)(H9,{className:t8()("voucher-right-icon",{show:s})})]})]}),(0,eO.jsxs)("div",{className:t8()("voucher-detail",{show:s}),children:[u.length>0?(0,eO.jsx)(id.PisellGoodPassCard,{style:{width:"100%"},dataSource:u,mixedSort:h,onChange:g}):null,e?null:(0,eO.jsxs)("div",{className:"login-card",children:[(0,eO.jsx)(emR,{style:{fontSize:28}}),(0,eO.jsxs)("div",{className:"text-wrapper",style:{maxWidth:"none"},children:[(0,eO.jsx)(id.PisellText,{className:"login-btn",onClick:()=>{t({callback:e=>{"success"===e&&l().then(()=>{p()})}})},children:eP.getText("pisell2.text.goodpass.login")})," ",(0,eO.jsx)("span",{children:eP.getText("pisell2.text.goodpass.login-tip")})]})]}),(0,eO.jsxs)("div",{className:"voucher-code-input-wrapper",children:[(0,eO.jsxs)("div",{className:"voucher-code-input",children:[(0,eO.jsxs)("div",{style:{whiteSpace:"nowrap"},children:[eP.getText("pisell2.text.goodpass.code"),":"]}),(0,eO.jsx)(id.PisellInput,{value:d,allowClear:!0,onChange:e=>{var t;return c((null==(t=e.target)?void 0:t.value)||"")},size:"small",placeholder:eP.getText("pisell2.text.goodpass.enter-code")})]}),(0,eO.jsx)(e_.Button,{size:"small",onClick:m,disabled:!d.trim(),children:eP.getText("pisell2.text.apply")})]})]})]})}function eYI(e){let{deposit:t,isAgreePolicy:l,onChange:i,getProtocol:a}=e;if(!(null==t?void 0:t.hasDeposit))return null;let n=(null==t?void 0:t.deposit_policy_data)||[];return(0,eO.jsx)(em_,{total:null==t?void 0:t.total,protocols:n,isAgreePolicy:l,isShowTitle:!1,onChange:i,depositProtocolRequest:e=>a(e)})}function eYD(e){var t,l,i,a,n,r,s,o,d,c,u;let{open:p,onCancel:m,onNext:g,items:h,summary:v,embedded:f=!1,confirmLoading:y=!1,extraContent:b}=e,{currentStep:x,runModuleAction:k,refreshViewModel:_,refreshTimeSlotGrid:w,venueBookingModule:j,isAgreeDepositPolicy:S,setIsAgreeDepositPolicy:N,isLoading:M,isLogin:C}=eYT(),T=eI(),P=null==T||null==(l=T.appHelper)||null==(t=l.utils)?void 0:t.businessUtils,A=String((null==T||null==(n=T.appHelper)||null==(a=n.utils)||null==(i=a.getSymbolic)?void 0:i.call(a))||"$"),I=(null==T||null==(s=T.engine)||null==(r=s.props)?void 0:r.locale)||"en",[D,E]=(0,ex.useState)({}),{pisellos:z,translation:O}=(null==T||null==(o=T.appHelper)?void 0:o.utils)||{},L=!!(null==P||null==(d=P.getAppByModal)?void 0:d.call(P,"goodpass")),$=!!(null==P||null==(c=P.getAppByModal)?void 0:c.call(P,"discountcard"));(0,ex.useEffect)(()=>{var e;let t=e=>{(null==e?void 0:e.path)==="holderMap"&&E(null==e?void 0:e.value)};return null==z||null==(e=z.effects)||e.on("venueBooking_holder:changed",t),()=>{var e;null==z||null==(e=z.effects)||e.off("venueBooking_holder:changed",t)}},[z]),(0,ex.useEffect)(()=>{if(!M&&j)try{var e;let t=(null==(e=j.getHolderFormMap)?void 0:e.call(j))||{};E(t)}catch(e){console.warn("[venueBooking] Holder data is not ready",e),E({})}},[j,M]);let R=f||p,F=(null==v?void 0:v.total_amount)??(null==v?void 0:v.expect_amount)??(null==v?void 0:v.amount)??(null==v?void 0:v.total)??"0.00",B=(0,ex.useMemo)(()=>(h||[]).map(e=>{var t,l,i;let a=egA(e),n=epE(a)?null==D?void 0:D[null==a?void 0:a.resource_id]:{},r=egT({item:e,holderConfig:a,formData:n,translation:O,enabled:!!(null==e||null==(l=e._origin)||null==(t=l.product)?void 0:t.bookingUuid),utils:null==T||null==(i=T.appHelper)?void 0:i.utils});return{...e,symbol:(null==e?void 0:e.symbol)||A,is_hide_like:!0,allowClearHolder:!0,...r}}),[h,A,D,O]),q="checkout"===x?String(eP.getText("pisell2.venue.action.pay.now")||"立即支付"):String(eP.getText("pisell2.venue.action.next")||"下一步"),H=(0,ex.useMemo)(()=>{var e,t,l;let i=Number((null==v?void 0:v.product_amount)??0),a=Number((null==v?void 0:v.tax_fee)??0),n=Number((null==v?void 0:v.total_amount)??(null==v?void 0:v.expect_amount)??0),r=!!(null==v||null==(e=v.deposit)?void 0:e.hasDeposit),s=null==j||null==(t=j.getTempOrder)?void 0:t.call(j),o=(null==s?void 0:s.summary)||{},d=String((null==o?void 0:o.tax_title)||(null==v?void 0:v.tax_title)||"GST/Tax"),c=Number(null==o?void 0:o.tax_rate),u=Number.isNaN(c)?0:c>1?c/100:c,p=!!((null==o?void 0:o.is_price_include_tax)??(null==o?void 0:o.isPriceIncludeTax)),m=((null==v?void 0:v.surcharges)||[]).filter(e=>Number(null==e?void 0:e.amount)>0).map(e=>{let t=(null==e?void 0:e.label)||(null==e?void 0:e.name)||{},l=t[I]||t.en||t.original||(null==e?void 0:e.key)||"";return{key:(null==e?void 0:e.key)||`surcharge_${null==e?void 0:e.surcharge_id}`,label:l,value:Number(null==e?void 0:e.amount)}});return[{key:"deposit",value:Number((null==v||null==(l=v.deposit)?void 0:l.total)??0),label:eP.getText("pisell2.appointment.deposit")||"Deposit",hidden:!r},{key:"sub_total",value:Number.isNaN(i)?0:i},...m,{key:"tax",value:Number.isNaN(a)?0:a,hidden:!!Number.isNaN(a)||a<=0,tax:{title:d,rate:u,is_price_include_tax:p}},{key:"custom_total",value:Number.isNaN(n)?0:n,label:eP.getText("pisell2.event.total")||"合计",bold:!r}]},[v,I,j]),V=async(e,t,l)=>{var i,a,n,r,s;if("add_holder"===t){let t=egA(e);if(!epE(t))return;let l=null==t?void 0:t.resource_id;if(!l)return;let a=egI(D,l);return epH({form_id:a||l,title:eP.getText("pisell2.venue.create.form"),utils:null==T||null==(i=T.appHelper)?void 0:i.utils,callback:async t=>{if((null==t?void 0:t.status)==="success"){var i,n,r,s;let{formRecordId:o,formId:d}=egD({res:t,formId:l,skuRelationFormId:a,utils:null==T||null==(i=T.appHelper)?void 0:i.utils,module:j}),c=epB(null==T||null==(n=T.appHelper)?void 0:n.utils);j.setBookingHolder(null==e||null==(s=e._origin)||null==(r=s.product)?void 0:r.bookingUuid,{customer_id:null==c?void 0:c.id,form_id:d,form_record:[o]}),await _()}}})}if("change_holder"===t){let t=epB(null==T||null==(a=T.appHelper)?void 0:a.utils),i=(null==l?void 0:l._origin)||l,s=l?{customer_id:null==t?void 0:t.id,form_id:null==i?void 0:i.form_id,form_record:[null==i?void 0:i.form_record_id]}:null;j.setBookingHolder(null==e||null==(r=e._origin)||null==(n=r.product)?void 0:n.bookingUuid,s),await _();return}if("delete"!==t)return;let o=l&&"object"==typeof l?l:e;if("select-venue"!==x&&o&&"object"==typeof o&&(null!=(s=o.metadata)&&s.venue_booking||null!=o&&o.start_date&&null!=o&&o.end_date))return void e_.message.warning({content:String(eP.getText("pisell2.venue.cart.delete.venue.only.step1")||"请返回第一步后再删除场地商品"),duration:2});let d=eYt(o);if(!d)return void console.error("[venueBooking] removeProductFromOrder skipped: missing product UID",{item:o});try{await k("removeProductFromOrder",d),w(),await _()}catch(e){console.error("[venueBooking] removeProductFromOrder failed",{error:e,item:o})}};if((0,ex.useEffect)(()=>{R&&_()},[R]),!R)return null;let Y=(0,eO.jsx)("div",{className:"pisell-venue-booking-cart-body",children:(0,eO.jsx)(LU,{productParams:{products:B,hideAddBtn:!0,disabledEdit:!1,isShowNote:!1,isShowDelete:!0,isShowPackageNote:!1,isShowChangeHolder:"checkout"!==x&&!!C,isShowHolder:!0,isShowAddHolderButton:!0},platform:"h5",emptyText:eP.getText("pisell2.venue.cart.empty"),isOpenGroup:!1,isHideClearCart:!0,onChange:V})}),U=(0,eO.jsxs)(eO.Fragment,{children:[L||$?(0,eO.jsx)(eYA,{}):null,(0,eO.jsx)(YI,{list:H,style:{padding:0},children:(null==v||null==(u=v.deposit)?void 0:u.hasDeposit)?(0,eO.jsx)(eYI,{deposit:v.deposit,isAgreePolicy:S,onChange:N,getProtocol:e=>{var t;return null==j||null==(t=j.getProtocol)?void 0:t.call(j,e)}}):null}),b?(0,eO.jsx)("div",{className:"pisell-venue-booking-cart-extra-content",children:b}):null]});return f?(0,eO.jsxs)(eO.Fragment,{children:[Y,(0,eO.jsxs)("div",{className:"pisell-venue-booking-cart-embedded-footer",children:[U,(0,eO.jsx)(id.Button,{type:"primary",block:!0,onClick:g,loading:y,children:q})]})]}):(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsx)("div",{className:"pisell-venue-booking-cart-mask",onClick:m}),(0,eO.jsxs)("div",{className:"pisell-venue-booking-cart-drawer",children:[(0,eO.jsx)("div",{className:"pisell-venue-booking-cart-header",onClick:m,children:(0,eO.jsx)("span",{className:"pisell-venue-booking-cart-handle","aria-hidden":!0})}),Y,(0,eO.jsx)("div",{className:"pisell-venue-booking-cart-drawer-summary",children:U}),(0,eO.jsxs)("div",{className:"pisell-venue-booking-cart-footer",children:[(0,eO.jsxs)("div",{className:"pisell-venue-booking-cart-total",children:[(0,eO.jsx)("div",{className:"pisell-venue-booking-cart-total-label",children:eP.getText("pisell2.event.total")||"合计"}),(0,eO.jsxs)("div",{className:"pisell-venue-booking-cart-total-amount",children:[A,Number(F||0).toFixed(2)]})]}),(0,eO.jsx)(id.Button,{type:"primary",onClick:g,loading:y,children:"checkout"===x?q:eP.getText("pisell2.event.continue")||"继续"})]})]})]})}function eYE(){var e;let t=eYa(),{currentStep:l,viewModel:i,handlePrimaryAction:a,isSubmittingOrder:n}=eYT(),[r,s]=(0,ex.useState)(!1),o=(0,ex.useMemo)(()=>{var e,t,l,a,n,r;let s=Number((null==(e=i.summary)?void 0:e.total_amount)??(null==(t=i.summary)?void 0:t.expect_amount)??(null==(l=i.summary)?void 0:l.amount)??(null==(a=i.summary)?void 0:a.total)??(null==(n=i.summary)?void 0:n.totalAmount)??(null==(r=i.summary)?void 0:r.payable_amount)??0);return Number.isNaN(s)?"0.00":s.toFixed(2)},[i.summary]),d=(0,ex.useMemo)(()=>"checkout"===l?String(eP.getText("pisell2.venue.action.pay.now")||"立即支付"):String(eP.getText("pisell2.venue.action.next")||"下一步"),[l]);return(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsxs)("div",{className:"pisell-venue-booking-footer",children:[(0,eO.jsxs)("div",{className:"pisell-venue-booking-footer-left",children:[(0,eO.jsx)("div",{className:"pisell-venue-booking-footer-total-label",children:eP.getText("pisell2.event.total")||"合计"}),(0,eO.jsxs)("div",{className:"pisell-venue-booking-footer-total-amount",children:[t,o]})]}),(0,eO.jsxs)("div",{className:"pisell-venue-booking-footer-right",children:[(0,eO.jsx)(id.Badge,{count:(null==(e=i.cartItems)?void 0:e.length)||0,id:"venue-booking-cart-btn",children:(0,eO.jsx)(id.Button,{size:"large",className:"pisell-venue-booking-footer-cart-btn",onClick:()=>s(!0),children:(0,eO.jsx)(id.Image,{src:egO,preview:!1})})}),(0,eO.jsx)(id.Button,{type:"primary",size:"large",className:"pisell-venue-booking-footer-btn",onClick:a,loading:n,children:d})]})]}),(0,eO.jsx)(eYD,{open:r,items:i.cartItems||[],summary:i.summary||{},onCancel:()=>s(!1),onNext:()=>{s(!1),a()},confirmLoading:n})]})}function eYz(){let{monthCursor:e,setMonthCursor:t,anchorDate:l,setAnchorDate:i,setMonthPickerOpen:a,fetchWeekData:n,viewModel:r}=eYT(),s=function(e){let t=e.startOf("month"),l=e.daysInMonth(),i=t.day(),a=0===i?6:i-1,n=[];for(let e=0;e<a;e++)n.push(null);for(let e=1;e<=l;e++)n.push(t.date(e));for(;n.length%7!=0;)n.push(null);return n}(e),o=eYv(l),d=eYv(ef()()),c=ef()().startOf("day"),u=(0,ex.useMemo)(()=>{let e=(r.dateSummary||[]).map(e=>ef()(String((null==e?void 0:e.date)||""))).filter(e=>e.isValid()).sort((e,t)=>e.valueOf()-t.valueOf());return e.length?{minDate:e[0].startOf("day"),maxDate:e[e.length-1].startOf("day")}:null},[r.dateSummary]);async function p(e){i(e),t(e.startOf("month")),a(!1);let l=eYf(e);await n(eYv(l[0]),eYv(l[l.length-1]))}return(0,eO.jsxs)("div",{className:"absolute right-0 top-[calc(100%+12px)] z-30 w-[320px] rounded-[24px] border border-black/[0.06] bg-white p-4 shadow-[0_20px_60px_rgba(20,20,20,0.14)]",children:[(0,eO.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,eO.jsx)("button",{className:"flex h-10 w-10 items-center justify-center rounded-2xl bg-[#fafafa] hover:bg-zinc-50",onClick:()=>t(e.subtract(1,"month")),children:(0,eO.jsx)(id.Iconfont,{type:"pisell2-chevron-left",style:{fontSize:16}})}),(0,eO.jsx)("div",{className:"text-sm font-bold text-zinc-900",children:eYy(e)}),(0,eO.jsx)("button",{className:"flex h-10 w-10 items-center justify-center rounded-2xl bg-[#fafafa] hover:bg-zinc-50",onClick:()=>t(e.add(1,"month")),children:(0,eO.jsx)(id.Iconfont,{type:"pisell2-chevron-right",style:{fontSize:16}})})]}),(0,eO.jsx)("div",{className:"mb-2 grid grid-cols-7 gap-2 px-1 text-center text-[11px] font-bold uppercase tracking-wide text-zinc-400",children:[eP.getText("pisell2.venue.calendar.weekday.short.mon")||"周一",eP.getText("pisell2.venue.calendar.weekday.short.tue")||"周二",eP.getText("pisell2.venue.calendar.weekday.short.wed")||"周三",eP.getText("pisell2.venue.calendar.weekday.short.thu")||"周四",eP.getText("pisell2.venue.calendar.weekday.short.fri")||"周五",eP.getText("pisell2.venue.calendar.weekday.short.sat")||"周六",eP.getText("pisell2.venue.calendar.weekday.short.sun")||"周日"].map(e=>(0,eO.jsx)("div",{children:e},e))}),(0,eO.jsx)("div",{className:"grid grid-cols-7 gap-2",children:s.map((e,t)=>{if(!e)return(0,eO.jsx)("div",{className:"h-11"},`empty-${t}`);let l=eYv(e),i=eYx(e,r.dateSummary),a=l===o,n=l===d,s=e.isBefore(c,"day"),m=!(!u||e.isBefore(u.minDate,"day")||e.isAfter(u.maxDate,"day"))&&i.soldOut,g=s||m,h=g?"bg-zinc-50 text-zinc-400":a?"text-white shadow-sm":n?"":"bg-[#fafafa] text-zinc-700",v=a&&!i.soldOut?{backgroundColor:"var(--vb-primary)"}:n&&!i.soldOut?{backgroundColor:"var(--vb-primary-light)",color:"var(--vb-primary)"}:void 0;return(0,eO.jsx)("button",{onClick:()=>{g||p(e)},disabled:g,className:`h-11 rounded-2xl text-sm font-semibold transition ${h}`,style:v,children:(0,eO.jsx)("span",{className:m?"line-through text-zinc-400":"",children:e.date()})},l)})})]})}function eYO(e){let{onPrevWeek:t,onNextWeek:l}=e,{anchorDate:i,monthPickerOpen:a,setMonthPickerOpen:n,goToNearestAvailableDate:r}=eYT(),s=ef()(),o=eYv(i)===eYv(s);async function d(){o||(n(!1),await r(s))}return(0,eO.jsxs)("div",{className:"relative flex w-full items-center gap-2 xl:w-auto",children:[(0,eO.jsx)("button",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-[#fafafa] md:h-12 md:w-12",onClick:t,children:(0,eO.jsx)(id.Iconfont,{type:"pisell2-chevron-left",style:{fontSize:18}})}),(0,eO.jsx)("button",{className:"min-w-0 flex-1 rounded-2xl bg-[#fafafa] px-4 py-3 text-sm font-bold text-zinc-900 xl:min-w-[200px] xl:flex-none",onClick:()=>n(!a),children:eYy(i)}),(0,eO.jsx)("button",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-[#fafafa] md:h-12 md:w-12",onClick:l,children:(0,eO.jsx)(id.Iconfont,{type:"pisell2-chevron-right",style:{fontSize:18}})}),(0,eO.jsx)("button",{className:`rounded-2xl px-4 py-3 text-sm font-bold shadow-sm ${o?"bg-zinc-200 text-zinc-500 cursor-not-allowed":"text-white"}`,style:o?void 0:{backgroundColor:"var(--vb-primary)"},onClick:d,disabled:o,children:eP.getText("pisell2.venue.action.go.today")||"回到今天"}),a?(0,eO.jsx)(eYz,{}):null]})}function eYL(e){let{onPrevWeek:t,onNextWeek:l}=e,i=eYa(),{anchorDate:a,setAnchorDate:n,setMonthCursor:r,viewModel:s,venueBookingModule:o,isWeekLoading:d}=eYT(),c=eYf(a),u=eYv(a),p=(0,ex.useMemo)(()=>(function(e){let t=new Set;if(!e||"function"!=typeof e.getAllSelectedSlots)return t;let l=e.getAllSelectedSlots();return l&&(l instanceof Map?l.forEach(e=>{Array.isArray(e)&&e.forEach(e=>eYg(t,e))}):Array.isArray(l)&&l.forEach(e=>{Array.isArray(e)?e.forEach(e=>eYg(t,e)):Array.isArray(null==e?void 0:e.slots)?e.slots.forEach(e=>eYg(t,e)):eYg(t,e)})),t})(o),[o,s.cartItems]),m=c.some(e=>{let t=eYx(e,s.dateSummary,i);return!t.soldOut&&t.fewLeft}),g="u">typeof window&&window.innerWidth<920,h=(0,ex.useRef)({startX:0,startY:0,active:!1,moved:!1});return d?(0,eO.jsx)("div",{className:"grid grid-cols-7 gap-1 select-none","aria-busy":"true","aria-live":"polite",children:Array.from({length:7}).map((e,t)=>(0,eO.jsxs)("div",{className:"relative min-h-[56px] overflow-hidden rounded-[12px] bg-zinc-100 px-2 py-2 md:min-h-[60px] md:rounded-[16px] md:px-3 md:py-2",children:[(0,eO.jsx)("div",{className:"h-2 w-8 rounded bg-zinc-200/90 md:h-2.5 md:w-10"}),(0,eO.jsxs)("div",{className:"mt-2 flex items-end justify-between gap-1",children:[(0,eO.jsx)("div",{className:"h-3 w-5 rounded bg-zinc-200/90 md:h-4 md:w-6"}),(0,eO.jsx)("div",{className:"h-2 w-8 rounded bg-zinc-200/90 md:h-2.5 md:w-10"})]}),(0,eO.jsx)("span",{className:"vb-skeleton-shimmer","aria-hidden":"true"})]},`day-skeleton-${t}`))}):(0,eO.jsx)("div",{className:"grid grid-cols-7 gap-1 touch-pan-y select-none",onPointerDown:function(e){("mouse"!==e.pointerType||0===e.button)&&(h.current={startX:e.clientX,startY:e.clientY,active:!0,moved:!1})},onPointerMove:function(e){if(!h.current.active)return;let t=e.clientX-h.current.startX,l=e.clientY-h.current.startY;(Math.abs(t)>8||Math.abs(l)>8)&&(h.current.moved=!0)},onPointerUp:function(e){if(!h.current.active)return;let i=e.clientX-h.current.startX,a=e.clientY-h.current.startY;h.current.active=!1,48>Math.abs(i)||Math.abs(i)<=Math.abs(a)||(i<0?l():t())},onPointerCancel:()=>{h.current.active=!1,h.current.moved=!1},children:c.map(e=>{let t,l=eYv(e),a=l===u,o=eYx(e,s.dateSummary,i),d=p.has(l)&&!a,c=o.soldOut?"bg-zinc-50 text-zinc-400":a?"text-white shadow-sm":"bg-white text-zinc-800 hover:bg-zinc-50",v=!o.soldOut&&a?{backgroundColor:"var(--vb-primary)"}:void 0,f=a?"bg-white/15 text-white ring-white/20":"Promo"===o.topTag?"bg-emerald-50 text-emerald-700 ring-emerald-200":"bg-zinc-100 text-zinc-600 ring-zinc-200";return(0,eO.jsxs)("button",{type:"button",onClick:()=>(function(e){if(h.current.moved){h.current.moved=!1;return}n(e),r(e.startOf("month"))})(e),className:`relative min-w-0 cursor-pointer rounded-[12px] px-2 py-2 text-left transition md:rounded-[16px] md:px-3 md:py-2 ${m?"min-h-[66px] pb-5 md:min-h-[72px] md:pb-6":"min-h-[56px] md:min-h-[60px]"} ${c}`,style:v,children:[o.topTag&&!g?(0,eO.jsx)("div",{className:`pointer-events-none absolute right-1 top-1 inline-flex rounded-full px-1.5 py-0.5 text-[8px] font-semibold ring-1 md:right-2 md:top-2 md:text-[10px] ${f}`,children:o.topTag}):null,(0,eO.jsxs)("div",{className:`pointer-events-none inline-flex max-w-full items-center gap-1 truncate text-[8px] leading-none md:text-xs ${o.soldOut?"text-zinc-400":a?"text-white/85":"text-zinc-500"}`,children:[(0,eO.jsx)("span",{className:"truncate",children:1===(t=e.day())?String(eP.getText("pisell2.venue.calendar.weekday.short.mon")||"周一"):2===t?String(eP.getText("pisell2.venue.calendar.weekday.short.tue")||"周二"):3===t?String(eP.getText("pisell2.venue.calendar.weekday.short.wed")||"周三"):4===t?String(eP.getText("pisell2.venue.calendar.weekday.short.thu")||"周四"):5===t?String(eP.getText("pisell2.venue.calendar.weekday.short.fri")||"周五"):6===t?String(eP.getText("pisell2.venue.calendar.weekday.short.sat")||"周六"):String(eP.getText("pisell2.venue.calendar.weekday.short.sun")||"周日")}),d?(0,eO.jsx)(id.Iconfont,{type:"pisell2-check-circle",style:{fontSize:13,color:"var(--vb-primary, #ea1018)"}}):null]}),(0,eO.jsxs)("div",{className:"pointer-events-none mt-1 flex w-full flex-wrap items-end justify-between gap-x-1",children:[(0,eO.jsx)("div",{className:`text-[13px] font-bold leading-none md:text-base ${o.soldOut?"line-through":""}`,children:e.date()}),(0,eO.jsx)("div",{className:`text-[8px] font-semibold leading-tight md:text-[10px] lg:text-xs ${a?"text-white/70":"text-zinc-400"}`,children:o.soldOut?eP.getText("pisell2.venue.label.sold.out")||"已满":o.startingPrice??""})]}),m?(0,eO.jsx)("div",{className:`pointer-events-none absolute bottom-2 left-2 text-[10px] font-bold leading-none md:bottom-2 md:left-3 md:text-[11px] ${o.fewLeft&&!o.soldOut?a?"text-white":"":"opacity-0"}`,style:!o.fewLeft||o.soldOut||a?void 0:{color:"var(--vb-primary)"},children:eP.getText("pisell2.venue.label.few.left")||"即将满"}):null]},l)})})}function eY$(){let{search:e,setSearch:t,filter:l,setFilter:i,viewModel:a}=eYT(),n=(0,ex.useMemo)(()=>{var e;return Array.from(new Set(((null==(e=a.timeSlotGrid)?void 0:e.resources)||[]).map(e=>e.productTitle)))},[a.timeSlotGrid]),r=[{label:eP.getText("pisell2.venue.filter.all")||"全部",value:"ALL"},...n.map(e=>({label:e,value:e}))];return(0,eO.jsx)("div",{className:"mt-4 grid gap-3 md:mt-5 xl:grid-cols-[1fr_auto] xl:items-center",children:n.length>1?(0,eO.jsx)("div",{className:"flex flex-wrap gap-2",children:r.map(e=>(0,eO.jsx)("button",{onClick:()=>i(e.value),className:`rounded-full px-4 py-2 text-sm font-semibold transition ${l===e.value?"text-white":"bg-[#fafafa] text-zinc-700"}`,style:l===e.value?{backgroundColor:"var(--vb-primary)"}:void 0,children:e.label},e.value))}):null})}function eYR(){let e=eYa(),{viewModel:t,venueBookingModule:l,toggleSlot:i,filter:a,search:n,isGridLoading:r}=eYT(),s=t.timeSlotGrid,o=(null==s?void 0:s.timeLabels)||[],d=(null==s?void 0:s.resources)||[],c=!r&&!!s&&o.length>0,u=(0,ex.useMemo)(()=>o.filter(e=>e.endsWith(":00")),[o]),p=(0,ex.useMemo)(()=>{var e;return e=o.length,{gridTemplateColumns:`120px repeat(${e}, minmax(70px, 1fr))`,minWidth:`${120+70*e}px`,width:"100%"}},[o.length]),m=(0,ex.useMemo)(()=>!("u"<typeof navigator)&&rm(),[]),g=(0,ex.useMemo)(()=>m?{overscrollBehavior:"none"}:{overscrollBehaviorX:"none",overscrollBehaviorY:"auto"},[m]),h=(0,ex.useMemo)(()=>d.filter(e=>{let t="ALL"===a||e.productTitle===a,l=!n||e.resourceName.toLowerCase().includes(n.toLowerCase());return t&&l}),[a,n,d]),v=(0,ex.useRef)(null),f=(0,ex.useRef)(null),y=(0,ex.useRef)(null),b=(0,ex.useRef)({isDragging:!1,pointerId:null,startX:0,startY:0,startScrollLeft:0,moved:!1}),x=(0,ex.useCallback)(e=>{f.current&&(f.current.style.transform=`translateX(${-e}px)`),y.current&&(y.current.style.transform=`translateX(${e}px)`)},[]);(0,ex.useEffect)(()=>{if(r)return;let e=v.current;if(!e||!o.length||!s)return;let t=function(e){if(!e)return 0;for(let t=0;t<e.timeLabels.length;t++)if(e.resources.some(e=>e.slots[t]&&"available"===e.slots[t].status))return t;return 0}(s);if(t<=0)return void x(e.scrollLeft);let l=Math.max(0,e.scrollWidth-120),i=Math.max(0,Math.max(0,t-1)*(o.length?l/o.length:0));e.scrollTo({left:i,behavior:"smooth"}),x(i)},[null==s?void 0:s.date,o.length,r,x]),(0,ex.useEffect)(()=>{if(!c)return;let e=v.current;if(e)return e.addEventListener("pointerdown",t),e.addEventListener("pointermove",l,{passive:!1}),e.addEventListener("pointerup",i),e.addEventListener("pointercancel",i),()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("pointermove",l),e.removeEventListener("pointerup",i),e.removeEventListener("pointercancel",i),b.current.isDragging=!1,b.current.pointerId=null,b.current.moved=!1};function t(t){if("mouse"!==t.pointerType){b.current.isDragging=!1,b.current.pointerId=null,b.current.moved=!1;return}0!==t.button||t.target instanceof Element&&t.target.closest('[data-cart-button="true"], input, textarea')||(b.current={isDragging:!0,pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startScrollLeft:e.scrollLeft,moved:!1})}function l(t){if("mouse"!==t.pointerType)return;let l=b.current;if(!l.isDragging||l.pointerId!==t.pointerId)return;let i=t.clientX-l.startX,a=t.clientY-l.startY;if(Math.abs(i)>6||Math.abs(a)>6){var n,r;l.moved=!0,(null==(n=e.hasPointerCapture)?void 0:n.call(e,t.pointerId))||null==(r=e.setPointerCapture)||r.call(e,t.pointerId)}Math.abs(i)>=Math.abs(a)&&(t.preventDefault(),e.scrollLeft=l.startScrollLeft-i,x(e.scrollLeft))}function i(t){var l;b.current.pointerId===t.pointerId&&(b.current.isDragging=!1,b.current.pointerId=null,null==(l=e.releasePointerCapture)||l.call(e,t.pointerId))}},[x,c]),(0,ex.useEffect)(()=>{let e=v.current;if(e)return e.addEventListener("wheel",t,{passive:!1}),()=>e.removeEventListener("wheel",t);function t(e){Math.abs(e.deltaY)>Math.abs(e.deltaX)&&(e.preventDefault(),window.scrollBy({top:e.deltaY,behavior:"instant"}))}},[]);let[k,_]=(0,ex.useState)({}),w=(0,ex.useCallback)(e=>{_(t=>({...t,[String(e)]:!t[String(e)]}))},[]);function j(e,t,l){if(b.current.moved){b.current.moved=!1;return}"available"===l.status&&i(e,t,l)}return c?(0,eO.jsxs)("div",{className:"relative",children:[(0,eO.jsx)("div",{className:"sticky z-30 overflow-hidden rounded-t-[28px] bg-[#fff7f7]",style:{top:"var(--vb-grid-sticky-top, 0px)"},children:(0,eO.jsxs)("div",{ref:f,className:"grid border-b border-black/[0.06]",style:{...p,willChange:"transform"},children:[(0,eO.jsxs)("div",{ref:y,className:"relative z-20 row-span-2 flex items-center gap-2 border-r border-black/[0.06] bg-[#fff7f7] px-2 py-4 font-bold text-zinc-900 shadow-[10px_0_16px_-14px_rgba(0,0,0,0.2)] md:px-4",style:{willChange:"transform"},children:[(0,eO.jsx)(id.Iconfont,{type:"pisell2-clock",style:{fontSize:16,color:"var(--vb-primary, #ea1018)"}}),(0,eO.jsx)("span",{children:eP.getText("pisell2.venue.label.courts")||"场地"})]}),u.map((e,t)=>{let l=o.indexOf(e),i=l+1,a=eYk(d,l),n=i<o.length?eYk(d,i):a,r=a.soldOut&&n.soldOut;return(0,eO.jsx)("div",{className:`col-span-2 px-1 py-3 text-center text-[12px] font-bold md:text-sm ${r?"bg-zinc-100 text-zinc-400":"text-zinc-700"}`,style:{borderLeft:"1px solid rgba(0,0,0,0.08)"},children:function(e){let[t]=e.split(":").map(Number),l=t>=12?eP.getText("pisell2.venue.time.pm")||"pm":eP.getText("pisell2.venue.time.am")||"am";return(eP.getText("pisell2.venue.time.hour.format")||"{hour}{suffix}").replace("{hour}",String(t%12==0?12:t%12)).replace("{suffix}",l)}(e)},e)}),o.map((e,t)=>{let l=eYk(d,t);return(0,eO.jsxs)("div",{className:`px-1 py-1.5 text-center ${l.soldOut?"bg-zinc-100 text-zinc-400":"bg-white/55"}`,style:{borderTop:"1px solid rgba(0,0,0,0.04)",borderLeft:eYb(e)?"1px solid rgba(0,0,0,0.08)":"1px solid rgba(0,0,0,0.03)"},children:[null,l.soldOut?(0,eO.jsx)("div",{className:"mt-1 text-[10px] font-bold text-zinc-400",children:eP.getText("pisell2.venue.label.sold.out")||"已满"}):null,!l.soldOut&&l.fewLeft?(0,eO.jsx)("div",{className:"mt-1 text-[10px] font-bold",style:{color:"var(--vb-primary)"},children:eP.getText("pisell2.venue.label.few.left")||"即将满"}):null,l.soldOut||l.fewLeft?null:(0,eO.jsx)("div",{className:"mt-1 text-[10px] font-bold text-zinc-500",children:eP.getText("pisell2.venue.label.bookable")||"充足"})]},`${e}-tag`)})]},`${s.date}-header`)}),(0,eO.jsx)("div",{ref:v,onScroll:function(e){x(e.currentTarget.scrollLeft)},className:"max-w-full overflow-x-auto rounded-b-[28px] cursor-grab select-none active:cursor-grabbing",style:{touchAction:"auto",WebkitOverflowScrolling:"touch",...g},children:(0,eO.jsx)("div",{className:"w-full",children:h.map(t=>{let i,a,n=(i=t.slots.length,{soldOut:0===(a=t.slots.filter(e=>"available"===e.status).length),fewLeft:a>0&&(i>0?a/i:0)<.2}),r=!!t.hasMultipleProducts&&Array.isArray(t.products),d=!!k[String(t.resourceId)];return(0,eO.jsxs)(ek().Fragment,{children:[(0,eO.jsxs)("div",{className:"grid border-b border-black/[0.06]",style:p,children:[(0,eO.jsx)("div",{className:`sticky left-0 z-10 border-r border-black/[0.06] px-2 py-2 shadow-[10px_0_16px_-14px_rgba(0,0,0,0.2)] md:px-4 ${n.soldOut?"bg-zinc-50":"bg-white"}`,children:(0,eO.jsx)("div",{className:"flex items-start justify-between gap-2",children:(0,eO.jsxs)("div",{className:"flex items-center gap-1.5",children:[r?(0,eO.jsx)("button",{type:"button","data-cart-button":"true",onClick:e=>{e.stopPropagation(),w(t.resourceId)},className:"flex h-5 w-5 items-center justify-center rounded text-zinc-500 hover:bg-black/5","aria-label":d?"collapse":"expand",children:(0,eO.jsx)(id.Iconfont,{type:d?"pisell2-chevron-down":"pisell2-chevron-right",style:{fontSize:12}})}):null,(0,eO.jsx)("div",{className:`text-[13px] font-extrabold leading-5 md:text-[15px] ${n.soldOut?"text-zinc-400":"text-zinc-900"}`,children:t.resourceName})]})})}),t.slots.map((i,a)=>{let n="available"===i.status,s="occupied"===i.status||"past"===i.status||"unavailable"===i.status,d=o[a]||"",c=eY_(i),u=eYw({...c,courtType:t.productTitle}),p=c.highlight||"Promo"===c.label?{text:"pisell2.venue.label.promo",className:"bg-emerald-50 text-emerald-700 ring-emerald-200"}:"Off-Peak"===c.label?{text:"pisell2.venue.label.off.peak",className:"bg-zinc-100 text-zinc-600 ring-zinc-200"}:null,m=(null==p?void 0:p.text)==="pisell2.venue.label.promo"?eP.getText("pisell2.venue.label.promo")||"促销":(null==p?void 0:p.text)==="pisell2.venue.label.off.peak"?eP.getText("pisell2.venue.label.off.peak")||"非高峰":null,g=t.productId,h=!r&&!s&&eYm(l,{resourceId:t.resourceId,productId:g,startTime:i.startTime}),v=s||h,f=!r&&n&&eYp(l,t.resourceId,i.startTime,g),y=!r&&!v,b=r&&!v;return(0,eO.jsx)("button",{"data-slot-button":"true",onClick:()=>{if(r){if(v)return;w(t.resourceId);return}v||j(t.resourceId,g,i)},disabled:v,className:`px-1 py-2 text-center transition md:px-2 ${v?"cursor-not-allowed bg-zinc-100 text-zinc-400":f?"text-white":"bg-white hover:bg-[#fff6f6]"}`,style:{borderLeft:eYb(d)?"1px solid rgba(0,0,0,0.08)":"1px solid rgba(0,0,0,0.03)",borderBottom:"1px solid rgba(0,0,0,0.04)",...f&&y?{backgroundColor:"var(--vb-primary)"}:null},children:v?(0,eO.jsx)("div",{className:"flex flex-col items-center justify-center gap-1 text-zinc-400",children:(0,eO.jsx)("div",{className:"text-lg font-bold leading-none",children:"\xd7"})}):f?(0,eO.jsx)("div",{className:"space-y-0.5",children:(0,eO.jsx)(id.PisellText.Amount,{value:Number(i.price||0),symbol:e,precision:2,showCurrencySymbol:!0,className:"text-[13px] font-extrabold leading-4 text-white md:text-sm"})}):(0,eO.jsxs)("div",{className:"space-y-0.5",children:[(0,eO.jsxs)("div",{className:"flex items-baseline justify-center gap-0.5",children:[(0,eO.jsx)(id.PisellText.Amount,{value:Number(i.price||0),symbol:e,precision:2,showCurrencySymbol:!0,hideDecimalForWholeNumbers:!0,className:`text-[13px] font-normal leading-4 ${u} md:text-sm`}),b?(0,eO.jsx)("span",{className:`text-[13px] font-semibold leading-4 ${u} md:text-sm`,children:"+"}):null]}),p?(0,eO.jsx)("div",{className:`inline-flex rounded-full px-1.5 py-0 text-[8px] font-semibold leading-4 ring-1 md:text-[9px] ${p.className}`,children:m}):null]})},`${t.resourceId}-outer-${i.startTime}`)})]}),r&&d&&t.products.map(i=>(0,eO.jsxs)("div",{className:"grid border-b border-black/[0.06] bg-zinc-50/60",style:p,children:[(0,eO.jsx)("div",{className:"sticky left-0 z-10 border-r border-black/[0.06] bg-zinc-50/60 px-2 py-2 pl-8 shadow-[10px_0_16px_-14px_rgba(0,0,0,0.2)] md:px-4 md:pl-10",children:(0,eO.jsx)("div",{className:"text-[12px] font-semibold leading-5 text-zinc-700 md:text-[13px]",children:i.productTitle})}),i.slots.map((a,n)=>{let r="available"===a.status,s="occupied"===a.status||"past"===a.status||"unavailable"===a.status,d=o[n]||"",c=!s&&eYm(l,{resourceId:t.resourceId,productId:i.productId,startTime:a.startTime}),u=s||c,p=r&&eYp(l,t.resourceId,a.startTime,i.productId),m=!u,g=eYw({...eY_(a),courtType:i.productTitle});return(0,eO.jsx)("button",{"data-slot-button":"true",onClick:()=>{m&&j(t.resourceId,i.productId,a)},disabled:!m,className:`px-1 py-2 text-center transition md:px-2 ${u?"cursor-not-allowed bg-zinc-100 text-zinc-400":p?"text-white":"bg-white hover:bg-[#fff6f6]"}`,style:{borderLeft:eYb(d)?"1px solid rgba(0,0,0,0.08)":"1px solid rgba(0,0,0,0.03)",borderBottom:"1px solid rgba(0,0,0,0.04)",...p&&m?{backgroundColor:"var(--vb-primary)"}:null},children:u?(0,eO.jsx)("div",{className:"flex flex-col items-center justify-center gap-1 text-zinc-400",children:(0,eO.jsx)("div",{className:"text-lg font-bold leading-none",children:"\xd7"})}):(0,eO.jsx)("div",{className:"space-y-0.5",children:(0,eO.jsx)(id.PisellText.Amount,{value:Number(a.price||0),symbol:e,precision:2,showCurrencySymbol:!0,hideDecimalForWholeNumbers:!0,className:`text-[13px] leading-4 ${p?"font-extrabold text-white":`font-normal ${g}`} md:text-sm`})})},`${t.resourceId}-${i.productId}-${a.startTime}`)})]},`${t.resourceId}-sub-${i.productId}`))]},`${t.resourceId}-${s.date}`)})},s.date)})]}):(0,eO.jsx)(eYF,{})}function eYF(){return(0,eO.jsxs)("div",{className:"relative","aria-busy":"true","aria-live":"polite",children:[(0,eO.jsx)("div",{className:"sticky z-30 overflow-hidden rounded-t-[28px] bg-[#fff7f7]",style:{top:"var(--vb-grid-sticky-top, 0px)"},children:(0,eO.jsxs)("div",{className:"grid border-b border-black/[0.06]",style:{gridTemplateColumns:"120px repeat(8, minmax(90px, 1fr))"},children:[(0,eO.jsxs)("div",{className:"relative z-20 flex items-center gap-2 border-r border-black/[0.06] bg-[#fff7f7] px-2 py-4 font-bold text-zinc-900 shadow-[10px_0_16px_-14px_rgba(0,0,0,0.2)] md:px-4",children:[(0,eO.jsx)(id.Iconfont,{type:"pisell2-clock",style:{fontSize:16,color:"var(--vb-primary, #ea1018)"}}),(0,eO.jsx)("span",{children:eP.getText("pisell2.venue.label.courts")||"场地"})]}),Array.from({length:8}).map((e,t)=>(0,eO.jsxs)("div",{className:"relative flex items-center justify-center overflow-hidden px-1 py-3",style:{borderLeft:"1px solid rgba(0,0,0,0.08)"},children:[(0,eO.jsx)("div",{className:"h-3 w-10 rounded bg-zinc-200/80"}),(0,eO.jsx)("span",{className:"vb-skeleton-shimmer","aria-hidden":"true"})]},`sk-h-${t}`))]})}),(0,eO.jsx)("div",{className:"w-full max-w-full overflow-hidden rounded-b-[28px]",children:Array.from({length:5}).map((e,t)=>(0,eO.jsxs)("div",{className:"grid border-b border-black/[0.06]",style:{gridTemplateColumns:"120px repeat(8, minmax(90px, 1fr))"},children:[(0,eO.jsx)("div",{className:"sticky left-0 z-10 border-r border-black/[0.06] bg-white px-2 py-4 shadow-[10px_0_16px_-14px_rgba(0,0,0,0.2)] md:px-4",children:(0,eO.jsxs)("div",{className:"relative overflow-hidden",children:[(0,eO.jsx)("div",{className:"h-4 w-20 rounded bg-zinc-200/80 md:w-24"}),(0,eO.jsx)("div",{className:"mt-2 h-2.5 w-14 rounded bg-zinc-200/60 md:w-16"}),(0,eO.jsx)("span",{className:"vb-skeleton-shimmer","aria-hidden":"true"})]})}),Array.from({length:8}).map((e,l)=>(0,eO.jsxs)("div",{className:"relative overflow-hidden px-1 py-3",style:{borderLeft:l%2==0?"1px solid rgba(0,0,0,0.08)":"1px solid rgba(0,0,0,0.03)",borderBottom:"1px solid rgba(0,0,0,0.04)",backgroundColor:"#fff"},children:[(0,eO.jsx)("div",{className:"mx-auto h-3 w-10 rounded bg-zinc-200/70 md:h-3.5 md:w-12"}),(0,eO.jsx)("span",{className:"vb-skeleton-shimmer","aria-hidden":"true"})]},`sk-cell-${t}-${l}`))]},`sk-row-${t}`))})]})}function eYB(){let{setAnchorDate:e,anchorDate:t,fetchWeekData:l}=eYT(),i=(0,ex.useRef)(null),a=(0,ex.useCallback)(async i=>{let a=t.add(i,"day");e(a);let n=eYf(a),r=eYv(n[0]),s=eYv(n[n.length-1]);await l(r,s)},[t,e,l]);function n(){a(-7)}function r(){a(7)}return(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsxs)("div",{className:"rounded-b-[24px] bg-white p-3 md:rounded-[28px] md:p-6",children:[(0,eO.jsxs)("div",{className:"flex flex-col gap-2 xl:flex-row xl:items-center xl:justify-between",children:[(0,eO.jsxs)("div",{children:[(0,eO.jsx)("h2",{className:"text-2xl font-extrabold leading-tight text-zinc-900 md:text-[30px]",children:eP.getText("pisell2.venue.step1.title")||"选择场地"}),(0,eO.jsx)("p",{className:"mt-1 text-xs leading-5 text-zinc-500 md:mt-2 md:text-sm md:leading-6",children:eP.getText("pisell2.venue.step1.subtitle")||"仅显示可用时段和价格。"})]}),(0,eO.jsx)(eYO,{onPrevWeek:n,onNextWeek:r})]}),(0,eO.jsx)("div",{className:"mt-3 md:mt-5",children:(0,eO.jsx)(eYL,{onPrevWeek:n,onNextWeek:r})}),(0,eO.jsx)(eY$,{})]}),(0,eO.jsx)("div",{ref:i,className:"w-full max-w-full isolate rounded-[28px] bg-white",children:(0,eO.jsx)(eYR,{})})]})}function eYq(e){if("string"==typeof e)return e.trim();if(!e||"object"!=typeof e||Array.isArray(e))return"";for(let t of["auto","original","en","zh-CN","zh-HK","ja","pt"]){let l=e[t];if("string"==typeof l&&l.trim())return l.trim()}let t=Object.values(e).find(e=>"string"==typeof e&&e.trim());return"string"==typeof t?t.trim():""}function eYH(e){var t;let{payload:l}=e;if(!l||"object"!=typeof l)return null;let i=(null==(t=l.product_sku)?void 0:t.option)??l.option??l.product_option_item,a=Array.isArray(i)?i:[],n=eV0({...e,payload:{...l,option:a.map(e=>({...e,price:(null==e?void 0:e.add_price)??(null==e?void 0:e.price)}))}});if(!n)return null;let r=[l.origin,e.sourceItem].filter(e=>!!(e&&"object"==typeof e)),{product_option_item:s,...o}=n;return{...o,product_sku:{...l.product_sku,option:s.map((e,t)=>{var l;let{price:i,...n}=e,s=function(e,t){let l=eYq((null==e?void 0:e.name)??(null==e?void 0:e.title)??(null==e?void 0:e.label)??(null==e?void 0:e.option_group_item_name));if(l)return l;let i=Number((null==e?void 0:e.product_option_item_id)??(null==e?void 0:e.option_group_item_id)),a=Number(null==e?void 0:e.option_group_id);if(!i||Number.isNaN(i))return"";for(let e of t){let t=Array.isArray(null==e?void 0:e.option_group)?e.option_group:[],l=t.find(e=>!(!a||Number.isNaN(a))&&Number(null==e?void 0:e.id)===a);for(let e of l?[l]:t){let t=(Array.isArray(null==e?void 0:e.option_item)?e.option_item:[]).find(e=>Number(null==e?void 0:e.id)===i),l=eYq((null==t?void 0:t.name)??(null==t?void 0:t.title)??(null==t?void 0:t.label)??(null==t?void 0:t.option_group_item_name));if(l)return l}}return""}(a[t]||n,r),o={...a[t],...n,option_group_item_id:Number((null==(l=a[t])?void 0:l.option_group_item_id)??n.product_option_item_id)||0,add_price:i,...s?{name:s}:{}};return delete o.price,o})}}}function eYV(){var e;let{utils:t}=eI().appHelper||{},{runModuleAction:l,refreshViewModel:i,viewModel:a,goToStep:n}=eYT(),r=a.addonProductList||[],s=(Array.isArray(a.cartItems)?a.cartItems:[]).filter(e=>{var t;return!(null==e||null==(t=e.metadata)?void 0:t.venue_booking)}),o=(0,ex.useRef)(null),d=rp(),c=window.innerHeight-100;(0,ex.useEffect)(()=>{r.length>0||(async()=>{try{let e=await l("getAddonProducts");Array.isArray(e)?i({addonProductList:e}):e_.Modal.confirm({title:(null==e?void 0:e.message)||String(eP.getText("pisell2.venue.error.load.products")||"商品加载失败"),okText:String(eP.getText("pisell2.event.confirm")||"确认"),cancelButtonProps:{style:{display:"none"}},maskClosable:!1,onOk:()=>{location.replace("/")}})}catch(e){console.error("[venueBooking] getProductList failed",e)}})()},[]);let u=async e=>{let{orderProduct:t,sourceData:a}=e;try{await l("addProductToOrder",t),await i()}catch(e){console.error("[venueBooking] addProductToOrder failed",{error:e,sourceData:a,mappedData:t})}},p=async e=>{let{identity:t,sourceData:a}=e;try{await l("removeProductFromOrder",t),await i()}catch(e){console.error("[venueBooking] removeProductFromOrder failed",{error:e,sourceData:a,identity:t})}},m=async e=>{let{identity:t,num:a,sourceData:n}=e;try{await l("updateOrderProduct",{...t,updates:{num:a}}),await i()}catch(e){console.error("[venueBooking] updateOrderProduct failed",{error:e,sourceData:n,identity:t,num:a})}},g=async(e,l,i)=>{let a=(null==i?void 0:i.product)||e;if((null==i?void 0:i.intent)==="quantity"){var n;let t={...e,quantity:null==e?void 0:e.num,option:(null==e||null==(n=e.product_sku)?void 0:n.option)??(null==e?void 0:e.option)??(null==e?void 0:e.product_option_item),bundle:(null==e?void 0:e.bundle)??(null==e?void 0:e.product_bundle),origin:a,price:(null==e?void 0:e.price)??(null==e?void 0:e.selling_price)},l=eYH({payload:t,fallbackProductId:(null==e?void 0:e.product_id)??(null==e?void 0:e.id),sourceItem:a});if(!l)return void console.warn("[venueBooking] quantity add missing product_id",t);let r=Number((null==i?void 0:i.quantity)??(null==t?void 0:t.quantity)??0),o=Number((null==l?void 0:l.product_variant_id)??0);if(Number.isNaN(o))return void console.warn("[venueBooking] quantity action missing product_variant_id",{quantityData:t,orderProduct:l});let d=Number.isNaN(r)?0:Math.max(0,Math.floor(r)),c=s.filter(e=>String((null==e?void 0:e.product_id)??null)===String((null==l?void 0:l.product_id)??null)),g=c.filter(e=>Number((null==e?void 0:e.product_variant_id)??0)===o),h=eYl(e),v=h?g.filter(e=>eYl(e)===h):g;if(c.length>1||h&&1!==v.length)return void console.warn("[venueBooking] quantity action skipped: ambiguous or stale order line",{mode:h?"uid":"sku",eventUid:h,product_id:l.product_id,product_variant_id:o,matchedLineCount:c.length});let f=v[0],y=f?eYt(f):null;if(f&&!y)return void console.warn("[venueBooking] quantity action skipped: missing order line UID",{item:f});if(d<=0){if(!y)return;await p({identity:y,sourceData:t});return}if(!f)return void await u({orderProduct:{...l,num:d},sourceData:t});if(!y)return;await m({identity:y,num:d,sourceData:t})}else null==t||t.action({type:"pisell1.productDetail",data:{detail:{...a,open_deposit:1},setting:{can_input:!0,item_max_length:1,is_detail_open:!0}},callback:async t=>{if(null==t?void 0:t.isCancel)return;let l=eYH({payload:t,fallbackProductId:(null==e?void 0:e.product_id)??(null==e?void 0:e.id),sourceItem:a});l?await u({orderProduct:l,sourceData:t}):console.warn("[venueBooking] productDetail callback missing product_id",t)}})},h=(0,eO.jsx)(z9,{dataSource:r,onChange:g,loading:!1,emptyDescription:eP.getText("pisell2.venue.addons.empty"),token:{colorPrimary:"var(--theme-color)",containerBg:"#FFFFFF",tabItemBg:"#F2F4F7",tabItemHoverBg:"#F2F4F7",tabItemActiveBg:"var(--theme-color)",categoryTextColor:"#1B1B1B",cardSelectedBg:"var(--theme-color)"},customScrollParent:(null==(e=o.current)?void 0:e.getScrollContainer())||"",hideCategoryWhenOne:!0,version:"v2",value:s,productListSetting:{imgWidth:80,imgHeight:80},cartElementId:"#venue-booking-cart-btn"});return d?(0,eO.jsx)("div",{className:"pisell-venue-booking-addons pisell-venue-booking-addons--mobile",children:h}):(0,eO.jsx)("div",{className:"pisell-venue-booking-addons",children:(0,eO.jsx)(id.PisellScrollView,{maxHeight:c,overflow:"y",ref:o,children:h})})}function eYY(){eYa();let{viewModel:e,goToStep:t,updateOrderNote:l,runModuleAction:i}=eYT(),[a]=e_.Form.useForm(),[n,r]=(0,ex.useState)(String(e.note||"")),s=(0,ex.useRef)("[]"),o=(0,ex.useRef)(String(e.note||""));(0,ex.useMemo)(()=>{var t;return Number((null==(t=e.summary)?void 0:t.product_amount)??0)},[e.summary]),(0,ex.useMemo)(()=>{var t,l;return Number((null==(t=e.summary)?void 0:t.total_amount)??(null==(l=e.summary)?void 0:l.expect_amount)??0)},[e.summary]);let d=(0,ex.useMemo)(()=>(e.cartItems||[]).filter(e=>!!((null==e?void 0:e.start_date)&&(null==e?void 0:e.end_date))),[e.cartItems]),c=(0,ex.useMemo)(()=>(e.cartItems||[]).filter(e=>!(null==e?void 0:e.start_date)||!(null==e?void 0:e.end_date)),[e.cartItems]);(0,ex.useMemo)(()=>c.reduce((e,t)=>e+function(e){let t=Number.isNaN(Number(null==e?void 0:e.num))?1:Math.max(1,Math.floor(Number(null==e?void 0:e.num))),l=Number(null==e?void 0:e.price);if(!Number.isNaN(l))return l*t;let i=Number(null==e?void 0:e.total);return Number.isNaN(i)?0:i}(t),0),[c]);let u=(0,ex.useMemo)(()=>d.map((e,t)=>{let l=function(e){var t,l;let i=String((null==e?void 0:e.relation_form_name)||"").trim();if(i)return i;let a=String((null==e||null==(l=e.resources)||null==(t=l[0])?void 0:t.main_field)||"").trim();if(a)return a;let n=String((null==e?void 0:e.title)||(null==e?void 0:e.name)||"").trim();return n||""}(e),i=function(e){var t;let l,i,a=String((null==e?void 0:e.start_date)||""),n=String((null==e?void 0:e.end_date)||""),r=ef()(a),s=ef()(n);if(!r.isValid()||!s.isValid())return String((null==e?void 0:e.description)||(null==e?void 0:e.subtitle)||"-");let o=(l=Math.floor((t=Math.max(0,s.diff(r,"minute")))/60),i=t%60,l>0&&i>0?eYW(String(eP.getText("pisell2.venue.checkout.duration.hours_minutes")||"{hours}h {minutes}min"),{hours:l,minutes:i}):l>0?eYW(String(eP.getText("pisell2.venue.checkout.duration.hours")||"{hours}h"),{hours:l}):eYW(String(eP.getText("pisell2.venue.checkout.duration.minutes")||"{minutes}min"),{minutes:i}));return`${r.format("HH:mm")} ~ ${s.format("HH:mm")} ${r.format("DD/MM/YYYY")} (${o})`}(e),a=String(l||`场地 ${t+1}`);return`${a} ${i}`}),[d]);(0,ex.useMemo)(()=>({first_name:{visible:!0,required:!1},last_name:{visible:!0,required:!1},phone:{visible:!0,required:!1},email:{visible:!1,required:!1}}),[]);let p=(0,ex.useCallback)(async()=>{let e=eYU(a.getFieldsValue()),t=JSON.stringify(e);t!==s.current&&(s.current=t,await i("updateTempOrderContactsInfo",e))},[a,i]);(0,ex.useCallback)(()=>{p()},[p]);let m=(0,ex.useCallback)(async()=>{n!==o.current&&(o.current=n,await l(n))},[n,l]);return(0,ex.useEffect)(()=>{var t,l,i,n;let r,o,d=(o=Array.isArray(t=e.contactsInfo)?t[0]:null)&&"object"==typeof o?{first_name:String((null==o?void 0:o.first_name)||""),last_name:String((null==o?void 0:o.last_name)||""),email:String((null==o?void 0:o.email)||""),phone:{phone:String((null==o||null==(l=o.phone)?void 0:l.phone)||""),countryCallingCode:(r=String((null==o||null==(i=o.phone)?void 0:i.country_calling_code)||"").trim())?r.startsWith("+")?r:`+${r}`:"",countryCode:String((null==o||null==(n=o.phone)?void 0:n.country_code)||"")}}:{first_name:"",last_name:"",email:"",phone:{phone:"",countryCallingCode:"",countryCode:""}};a.setFieldsValue(d),s.current=JSON.stringify(eYU(d))},[a,e.contactsInfo]),(0,ex.useEffect)(()=>{let t=String(e.note||"");r(t),o.current=t},[e.note]),(0,eO.jsx)("div",{className:"space-y-3 md:space-y-5",children:(0,eO.jsxs)("div",{className:"grid gap-3 md:gap-4",children:[(0,eO.jsxs)("div",{className:"rounded-[22px] bg-white p-4 md:rounded-[28px] md:p-6",children:[(0,eO.jsx)("div",{className:"flex items-center justify-between gap-3",children:(0,eO.jsx)("div",{children:(0,eO.jsx)("div",{className:"mt-3 text-[22px] font-extrabold text-zinc-900",children:eP.getText("pisell2.venue.checkout.court.summary")||"场地预订摘要"})})}),(0,eO.jsxs)("div",{className:"mt-5 grid gap-4 md:grid-cols-2",children:[(0,eO.jsxs)("div",{className:"rounded-[22px] bg-[#faf7f4] p-4 md:col-span-2",children:[(0,eO.jsx)("div",{className:"text-sm font-semibold text-[#a69183]",children:eP.getText("pisell2.venue.checkout.selected.courts")||"已选场地"}),(0,eO.jsx)("div",{className:"mt-3 space-y-2 text-[15px] font-semibold text-zinc-900",children:u.length?u.map((e,t)=>(0,eO.jsx)("div",{children:e},`venue-session-line-${t}`)):(0,eO.jsx)("div",{children:eP.getText("pisell2.venue.checkout.sessions.empty")||"-"})})]}),c.length>0?(0,eO.jsxs)("div",{className:"rounded-[22px] bg-[#faf7f4] p-4",children:[(0,eO.jsx)("div",{className:"text-sm font-semibold text-[#a69183]",children:eP.getText("pisell2.venue.checkout.addons")||"附加项"}),(0,eO.jsx)("div",{className:"mt-3 text-[15px] font-semibold text-zinc-900",children:c.map((e,t)=>(0,eO.jsx)("div",{children:e.title||e.name||"-"},`addon-${e.id||t}`))})]}):null]})]}),(0,eO.jsx)("div",{className:"space-y-4",children:(0,eO.jsx)("div",{className:"rounded-[28px] bg-white p-5 md:p-6",children:(0,eO.jsxs)("div",{className:"mt-5 rounded-[22px] bg-[#faf7f4] p-4",children:[(0,eO.jsx)("div",{className:"text-lg font-bold text-zinc-900",children:eP.getText("pisell2.venue.checkout.notice")||"备注"}),(0,eO.jsx)("textarea",{className:"mt-4 min-h-[120px] w-full rounded-[20px] border border-black/10 bg-white px-4 py-4 text-sm outline-none placeholder:text-zinc-400",value:n,onChange:e=>r(e.target.value),placeholder:String(eP.getText("pisell2.venue.note.placeholder")||"特殊要求..."),onBlur:()=>{m()}})]})})})]})})}function eYU(e){var t,l,i;let a=String((null==e?void 0:e.first_name)||"").trim(),n=String((null==e?void 0:e.last_name)||"").trim(),r=String((null==e?void 0:e.email)||"").trim(),s=String((null==e||null==(t=e.phone)?void 0:t.phone)||"").trim(),o=String((null==e||null==(l=e.phone)?void 0:l.countryCallingCode)||"").trim(),d=String((null==e||null==(i=e.phone)?void 0:i.countryCode)||"").trim();if(!(a||n||r||s||o||d))return[];let c=`${a} ${n}`.trim();return[{first_name:a,last_name:n,display_name:c,email:r,phone:{phone:s,country_calling_code:o,country_code:d}}]}function eYW(e,t){let l=e;for(let[e,i]of Object.entries(t))l=l.split(`{${e}}`).join(String(i));return l}function eYG(){let{currentStep:e,viewModel:t,handlePrimaryAction:l,isSubmittingOrder:i}=eYT(),a={"select-venue":(0,eO.jsx)(eYB,{}),addons:(0,eO.jsx)(eYV,{}),checkout:(0,eO.jsx)(eYY,{})},n=(0,ex.useRef)(null);return(0,ex.useEffect)(()=>{let e=n.current;if(!e)return;let t=e.closest(".venue-booking-scope");if(!t)return;function l(){e&&(null==t||t.style.setProperty("--vb-grid-sticky-top",`${e.offsetHeight}px`))}l();let i="u">typeof ResizeObserver?new ResizeObserver(l):null;return null==i||i.observe(e),window.addEventListener("resize",l),()=>{null==i||i.disconnect(),window.removeEventListener("resize",l)}},[]),(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsx)("style",{children:`
33
33
  @keyframes slideLeft { from { opacity: 0; transform: translateX(34px); } to { opacity: 1; transform: translateX(0); } }
34
34
  @keyframes slideRight { from { opacity: 0; transform: translateX(-34px); } to { opacity: 1; transform: translateX(0); } }
35
35
  @keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }