import{n as e}from"./chunk-qMK8H_w0.js";import{$t as t,An as n,Nn as r,Qt as i,Rt as a,Ut as o,_n as s,an as c,bn as l,en as u,et as d,it as f,mn as p,nn as m,nt as h,on as g,ot as _,rn as v,vn as y}from"./app-4kCgdoJR.js";var b=e({default:()=>W}),x={class:`border-b border-gray-200 p-4 sm:px-6 dark:border-gray-700 print:hidden`},S={class:`absolute end-8 top-0 flex items-center gap-3 pe-4 pt-4`},C={class:`sr-only`},w={class:`text-base leading-6 font-semibold text-gray-900 dark:text-gray-100`},T={key:0,class:`m-6 flex flex-col gap-4`},E=[`src`],D={key:1,class:`text-center text-lg font-bold`},O={class:`text-center text-lg font-bold`},k={key:0},A={key:1},j={key:2},M={class:`-mx-2`},N={class:`w-full divide-y divide-gray-200 dark:divide-gray-700 print:divide-gray-400 dark:print:divide-gray-400`},P={class:`px-2 py-0.5 text-start`},F={class:`w-10 px-2 py-0.5 text-center`},I={class:`px-2 py-0.5 text-start`},L={key:0,class:`pb-1 text-xs`},R={class:`px-2 py-0.5 text-start`},z={class:`w-10 px-2 py-0.5 text-center`},B={class:`px-2 py-0.5 text-start`},V={key:0,class:`pb-1 text-xs`},H={class:`w-10 px-2 py-0.5 text-center`},U={key:1,class:`m-6 flex flex-col gap-4 text-yellow-600`},W={__name:`PrintOrder`,props:[`form`,`show`,`sendPrint`,`halls`],setup(e){let b=o(),{t:W}=a({}),G=e,K=t(()=>G.halls.find(e=>e.id===G.form.selectedHallId)?.tables||[]);p(()=>{b.props.settings?.print_dialog==1&&setTimeout(q,250)});function q(){if(b.props.settings?.pos_server==1){let e={type:`print-json-order`,data:{}};e.data.logo=b.props.opened_register.store.logo||b.props.settings?.logo||``,e.data.heading=b.props.settings?.name,e.data.store_heading=b.props.opened_register.store?.name||``,e.data.store_details={},e.data.store_details.state=b.props.opened_register.store?.state?.name||``,e.data.store_details.country=b.props.opened_register.store?.country?.name||``,e.data.type=W(`Order`),e.data.headers=null,e.data.info=[[W(`Ref`),G.form.reference],[W(`Order No.`),G.form.number],[W(`Created by`),G.form.user?.name||b.props.auth?.user?.name||``],[W(`Printed at`),d(new Date().toISOString(),null,null,!0)]],e.data.table_headers=[{label:W(`Description`)},{label:W(`Qty`)}];let t=G.form.items.map(e=>{if(e.variations&&e.variations.length){let t=e.variations.map(e=>({type:`item`,name:f(e.meta),qty:_(e.quantity)}));return{variations:[{type:`text`,text:e.name+(e.comment?`
`+e.comment:``)},...t]}}else return{type:`item`,name:e.name+(e.comment?`
`+e.comment:``),qty:h(e.quantity)}}),n=t.filter(e=>e.variations).map(e=>e.variations),r=t.filter(e=>!e.variations);t=[...n.flat(),...r],e.data.items=[t],e.data.totals=[{label:W(`Total Items`),value:Number(G.form.items.length)+` (`+G.form.items.reduce((e,t)=>e+Number(t.quantity),0)+`)`}],e.data.footers=null,e.data.notice=null,console.log(e),G.sendPrint(e)}else window.print()}return(t,a)=>{let o=l(`Icon`);return s(),v(`div`,null,[u(`div`,x,[u(`div`,S,[u(`button`,{type:`button`,onClick:a[0]||=e=>q(),class:`focus relative rounded-md text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200`},[a[1]||=u(`span`,{class:`absolute -inset-2.5`},null,-1),u(`span`,C,r(t.$t(`Print`)),1),g(o,{name:`print-o`,className:`size-6`})])]),u(`div`,null,[u(`h3`,w,r(t.$t(`Print Order`)),1)])]),e.form.items&&e.form.items.filter(e=>e.quantity).length?(s(),v(`div`,T,[n(b).props.opened_register.store.logo?(s(),v(`img`,{key:0,class:`h-8 max-w-[200pc]`,src:n(b).props.opened_register.store.logo,alt:`Logo`},null,8,E)):(s(),v(`h2`,D,r(n(b).props.opened_register.store.name||t.settings.name),1)),u(`h2`,O,r(t.$t(`Order`)),1),u(`div`,null,[e.form.id?(s(),v(`div`,k,r(t.$t(`Id`))+`: `+r(e.form.id),1)):m(``,!0),e.form.customer?(s(),v(`div`,A,r(t.$t(`Customer`))+`: `+r(e.form.customer?.company||e.form.customer?.name||``),1)):m(``,!0),u(`div`,null,r(t.$t(`Order Ref`))+`: `+r(e.form.reference),1),u(`div`,null,r(t.$t(`Order Number`))+`: `+r(e.form.number),1),e.form.table?(s(),v(`div`,j,r(t.$t(`Table`))+`: `+r(e.form.table?.name||K.value.find(t=>t.id===e.form.selectedTableId)?.name||``)+` (`+r(e.form.table?.hall?.name||e.halls.find(t=>t.id===e.form.selectedHallId)?.name||`Main`)+`) `,1)):m(``,!0),u(`div`,null,r(t.$t(`Created at`))+`: `+r(e.form.created_at?n(d)(e.form.created_at):n(d)(new Date().toISOString(),null,null,!0)),1),u(`div`,null,r(t.$t(`Created  by`))+`: `+r(e.form.user?.name||n(b).props.auth?.user?.name||``),1)]),u(`div`,M,[u(`table`,N,[u(`thead`,null,[u(`tr`,null,[u(`th`,P,r(t.$t(`Description`)),1),u(`th`,F,r(t.$t(`Qty`)),1)])]),(s(!0),v(i,null,y(e.form.items,e=>(s(),v(i,null,[e.variations&&e.variations.length?(s(),v(`tbody`,{key:e.id},[u(`tr`,null,[u(`td`,I,[c(r(e.name)+` `,1),e.comment?(s(),v(`div`,L,r(e.comment),1)):m(``,!0)]),a[2]||=u(`td`,{class:`w-10 px-2 py-0.5 text-center`},null,-1)]),(s(!0),v(i,null,y(e.variations,e=>(s(),v(`tr`,{key:e.id},[u(`td`,R,r(n(f)(e.meta)),1),u(`td`,z,r(n(_)(e.quantity)),1)]))),128))])):(s(),v(i,{key:1},[e.quantity>0?(s(),v(`tbody`,{key:e.id+`_`},[u(`tr`,null,[u(`td`,B,[c(r(e.name)+` `,1),e.comment?(s(),v(`div`,V,r(e.comment),1)):m(``,!0)]),u(`td`,H,r(n(h)(e.quantity)),1)])])):m(``,!0)],64))],64))),256))])]),u(`div`,null,[u(`div`,null,r(t.$t(`Sent at`))+`: `+r(n(d)(new Date().toISOString(),null,null,!0)),1),u(`div`,null,r(t.$t(`Sent by`))+`: `+r(n(b).props.auth?.user?.name||``),1)])])):(s(),v(`div`,U,r(t.$t(`Please add at least one item to form.`)),1))])}}};export{W as n,b as t};