import{r as reactExports,j as jsxRuntimeExports,q,u as useAppContext,v as ve,a as axios,Y as Ye}from"./app-CffHYkHW.js";import{B as Button}from"./button-qhe8lrPU.js";import{I as Input}from"./input-Bw4IOOzt.js";import{D as Dialog,a as DialogContent,b as DialogHeader,c as DialogTitle,e as DialogDescription,f as DialogFooter}from"./dialog-Djfc3pyN.js";import{u as useBluetooth,B as Bluetooth,d as DropdownMenu,e as DropdownMenuTrigger,f as DropdownMenuContent,c as DropdownMenuItem}from"./bluetooth-context-CLrE8g1i.js";import{t as toast}from"./index-Dw4sHwMN.js";import{U as Utensils}from"./utensils-Ds87evzs.js";import{C as Calculator,L as LogOut,S as ShoppingBag}from"./shopping-bag-AryJS2XX.js";import{c as createLucideIcon}from"./createLucideIcon-DAR-hy5d.js";import{U as User}from"./user-CvkWuVKY.js";import"./utils-C8zp8JNC.js";import"./index-C0loMkA3.js";import"./index-Cy5bElus.js";import"./index-DPkgfxsD.js";import"./x-BfabuQJD.js";import"./index-C9NeyPdJ.js";/**
 * @license lucide-react v0.475.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const __iconNode$3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Globe=createLucideIcon("Globe",__iconNode$3);/**
 * @license lucide-react v0.475.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const __iconNode$2=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],LayoutDashboard=createLucideIcon("LayoutDashboard",__iconNode$2);/**
 * @license lucide-react v0.475.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const __iconNode$1=[["path",{d:"m14.5 12.5-5-5",key:"1jahn5"}],["path",{d:"m9.5 12.5 5-5",key:"1k2t7b"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]],MonitorX=createLucideIcon("MonitorX",__iconNode$1);/**
 * @license lucide-react v0.475.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const __iconNode=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],Timer=createLucideIcon("Timer",__iconNode);function CalculatorDialog({open,onOpenChange}){const[display,setDisplay]=reactExports.useState(""),[history,setHistory]=reactExports.useState([]),handleClick=o=>{setDisplay(r=>r+o)},handleAllClear=()=>{setDisplay(""),setHistory([])},handleDelete=()=>{setDisplay(o=>o.slice(0,-1))},handleCalculate=()=>{try{let expr=display;expr=expr.replace(/(\d+(\.\d+)?)(\s*[\+\-]\s*)(\d+(\.\d+)?)%/g,(o,r,t,l,x)=>`${r}${l}(${r} * ${x} / 100)`),expr=expr.replace(/(\d+(\.\d+)?)(\s*[\*\/]\s*)(\d+(\.\d+)?)%/g,(o,r,t,l,x)=>`${r}${l}(${x} / 100)`),expr=expr.replace(/(^|[\+\-\*\/]\s*)\(?(\d+(\.\d+)?)%\)?/g,(o,r,t)=>`${r}(0 * ${t} / 100)`);const result=eval(expr),newEntry=`${display} = ${result}`;setHistory(o=>[newEntry,...o].slice(0,3)),setDisplay(result.toString())}catch{setDisplay("Error")}};return jsxRuntimeExports.jsx(Dialog,{open,onOpenChange,children:jsxRuntimeExports.jsxs(DialogContent,{className:"max-w-sm p-4",children:[jsxRuntimeExports.jsx(DialogHeader,{children:jsxRuntimeExports.jsx(DialogTitle,{className:"text-center text-lg",children:"Kalkulator"})}),jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[jsxRuntimeExports.jsxs("div",{className:"rounded border px-3 py-2 bg-muted min-h-[5rem]",children:[jsxRuntimeExports.jsx("div",{className:"text-right text-xs text-muted-foreground space-y-0.5 mb-1",children:history.map((o,r)=>jsxRuntimeExports.jsx("div",{className:"truncate",children:o},r))}),jsxRuntimeExports.jsx("div",{className:"text-right font-mono text-2xl",children:display||"0"})]}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[jsxRuntimeExports.jsx(Button,{variant:"destructive",className:"py-6",onClick:handleAllClear,children:"C"}),jsxRuntimeExports.jsx(Button,{variant:"outline",className:"py-6 text-xl",onClick:handleDelete,children:"←"}),jsxRuntimeExports.jsx(Button,{variant:"secondary",className:"py-6 text-2xl",onClick:()=>handleClick("%"),children:"%"}),jsxRuntimeExports.jsx(Button,{variant:"secondary",className:"py-6 text-2xl",onClick:()=>handleClick("/"),children:"÷"}),jsxRuntimeExports.jsx(Button,{variant:"outline",className:"py-6",onClick:()=>handleClick("7"),children:"7"}),jsxRuntimeExports.jsx(Button,{variant:"outline",className:"py-6",onClick:()=>handleClick("8"),children:"8"}),jsxRuntimeExports.jsx(Button,{variant:"outline",className:"py-6",onClick:()=>handleClick("9"),children:"9"}),jsxRuntimeExports.jsx(Button,{variant:"secondary",className:"py-6 text-2xl",onClick:()=>handleClick("*"),children:"×"}),jsxRuntimeExports.jsx(Button,{variant:"outline",className:"py-6",onClick:()=>handleClick("4"),children:"4"}),jsxRuntimeExports.jsx(Button,{variant:"outline",className:"py-6",onClick:()=>handleClick("5"),children:"5"}),jsxRuntimeExports.jsx(Button,{variant:"outline",className:"py-6",onClick:()=>handleClick("6"),children:"6"}),jsxRuntimeExports.jsx(Button,{variant:"secondary",className:"py-6 text-2xl",onClick:()=>handleClick("-"),children:"−"}),jsxRuntimeExports.jsx(Button,{variant:"outline",className:"py-6",onClick:()=>handleClick("1"),children:"1"}),jsxRuntimeExports.jsx(Button,{variant:"outline",className:"py-6",onClick:()=>handleClick("2"),children:"2"}),jsxRuntimeExports.jsx(Button,{variant:"outline",className:"py-6",onClick:()=>handleClick("3"),children:"3"}),jsxRuntimeExports.jsx(Button,{variant:"secondary",className:"py-6 text-2xl",onClick:()=>handleClick("+"),children:"+"}),jsxRuntimeExports.jsx(Button,{variant:"outline",className:"col-span-2 py-6",onClick:()=>handleClick("0"),children:"0"}),jsxRuntimeExports.jsx(Button,{variant:"outline",className:"py-6",onClick:()=>handleClick("."),children:"."}),jsxRuntimeExports.jsx(Button,{variant:"default",className:"py-6 text-2xl",onClick:handleCalculate,children:"="})]})]})]})})}function Navbar(){var U,K,X,Y,F;const{tables:o,settings:r,shiftCashier:t,pendingTransactionCount:l,bank_accounts:x}=q().props,ne=r.filter(e=>e.code==="NAME"),{isBluetoothConnected:$,connectBluetoothPrinter:re}=useBluetooth(),{isOrderTypeOpen:oe,setIsOrderTypeOpen:_,selectedOrderType:h,setSelectedOrderType:d,selectedTable:f,setSelectedTable:w,selectedPlatform:b,setSelectedPlatform:C,setTransaction:ie}=useAppContext(),le=()=>{d(""),C(""),w("")},D=e=>{le(),e==="dine_in"&&f&&w(f),e==="platform"&&b&&C(b),d(e),_(!1)},[T,xe]=reactExports.useState(""),[de,c]=reactExports.useState(!1),[L,ce]=reactExports.useState([]),[B,E]=reactExports.useState(!1),[me,O]=reactExports.useState(!1),[j,y]=reactExports.useState(!1),[S,ue]=reactExports.useState(!1),[R,pe]=reactExports.useState(""),[P,he]=reactExports.useState([]),[M,N]=reactExports.useState(1),[i,je]=reactExports.useState({current_page:1,last_page:1}),{data:m,setData:I,post:ge,processing:fe,reset:be}=ve({cashier_shift_id:(t==null?void 0:t.id)??"",cashier_transactions:{total_transaction:0,by_payment_method:{cash:{total:0},transfer:{}},total_return:0},end_cash:0}),z=t==null?void 0:t.opened_at,A=z?z.split(" ")[0]:"",Ee=(e,a)=>{var s;return e==="dine_in"?(s=a.table)!=null&&s.number?`Meja ${a.table.number}`:"":e==="platform"?a.platform??"":e??""},ye=e=>{ie(e),E(!1)};reactExports.useEffect(()=>{if(!B)return;const e=async()=>{c(!0);try{const s=await axios.get(route("apps.pos.pending-transactions"),{params:{search:T}});console.log(s),ce(s.data)}finally{c(!1)}},a=setTimeout(()=>{e()},400);return()=>clearTimeout(a)},[T,B]),reactExports.useEffect(()=>{if(!S)return;const a=setTimeout(async()=>{c(!0);try{const s=await axios.get(route("apps.pos.history-transactions"),{params:{search:R,page:M}});he(s.data.data),je({current_page:s.data.current_page,last_page:s.data.last_page})}finally{c(!1)}},400);return()=>clearTimeout(a)},[R,M,S]),reactExports.useEffect(()=>{N(1)},[R]);const H="pos:tx.changed",v=reactExports.useCallback(async()=>{if(t!=null&&t.id){c(!0);try{const e=await axios.get(route("apps.pos.cashier-transactions"),{params:{cashier_shift_id:t.id,_ts:Date.now()},headers:{"Cache-Control":"no-cache"}});I(a=>({...a,cashier_transactions:{...a.cashier_transactions,total_transaction:e.data.totalTransaction,by_payment_method:e.data.byPaymentMethod,total_return:e.data.totalReturn},end_cash:e.data.total}))}finally{c(!1)}}},[t==null?void 0:t.id,I]);reactExports.useEffect(()=>{j&&v()},[j,v]),reactExports.useEffect(()=>{const e=a=>{var n;const s=a;(n=s.detail)!=null&&n.cashier_shift_id&&(t!=null&&t.id)&&String(s.detail.cashier_shift_id)!==String(t.id)||j&&v()};return window.addEventListener(H,e),()=>window.removeEventListener(H,e)},[j,t==null?void 0:t.id,v]);const Re=e=>{e.preventDefault(),ge(route("apps.pos.close-cashier-shift"),{onSuccess:()=>{be(),toast("Data berhasil disimpan"),y(!1)}})},u=e=>`Rp ${(e??0).toLocaleString("id-ID")}`;function Ne(e){var G,J,V,W,Q,Z,ee;const{companyName:a=((G=r.find(k=>k.code==="NAME"))==null?void 0:G.value)??"-",dateOnly:s,shiftCashier:n,bank_accounts:p,data:g}=e,_e=((J=n==null?void 0:n.user)==null?void 0:J.name)??"-",we=n?`${((V=n.shift)==null?void 0:V.name)??"-"} (${((W=n.shift)==null?void 0:W.start_time)??"-"} - ${((Q=n.shift)==null?void 0:Q.end_time)??"-"})`:"-",Ce=(n==null?void 0:n.starting_cash)??0,De=((ee=(Z=g.cashier_transactions.by_payment_method)==null?void 0:Z.cash)==null?void 0:ee.total)??0,Te=p.map(k=>{var te,se,ae;const Be=((ae=(se=(te=g.cashier_transactions.by_payment_method)==null?void 0:te.transfer)==null?void 0:se[k.id])==null?void 0:ae.total)??0;return`<tr><td>Transfer ${String(k.bank_name).toUpperCase()}</td><td style="text-align:right">${u(Be)}</td></tr>`}).join("");return`
            <!doctype html>
            <html>
            <head>
            <meta charset="utf-8" />
            <title>Laporan Tutup Kasir - ${s}</title>
            <style>
            * { box-sizing: border-box; }
            body { font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji"; margin: 0; padding: 24px; }
            .paper { max-width: 720px; margin: 0 auto; }
            .header { text-align: center; margin-bottom: 16px; }
            .header h1 { font-size: 18px; margin: 0 0 4px; }
            .header div { font-size: 12px; color: #555; }
            hr { border: 0; border-top: 1px solid #e5e7eb; margin: 16px 0; }
            .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; font-size: 12px; }
            .label { color: #6b7280; }
            .value { color: #111827; font-weight: 600; text-align: right; }
            table { width: 100%; border-collapse: collapse; font-size: 12px; }
            td { padding: 6px 0; }
            .muted { color: #6b7280; }
            .total { font-weight: 700; font-size: 14px; }
            .sign { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 32px; }
            .sign .box { height: 80px; border-top: 1px solid #e5e7eb; padding-top: 8px; text-align: center; font-size: 12px; color: #374151; }
            @media print {
                body { padding: 0; }
                .paper { max-width: none; margin: 0; padding: 16px 24px; }
            }
            </style>
            </head>
            <body>
            <div class="paper">
                <div class="header">
                <h1>Laporan Tutup Kasir</h1>
                <div>${a}</div>
                <div>${s}</div>
                </div>

                <table>
                <tr><td class="muted">Nama Kasir</td><td style="text-align:right"><strong>${_e}</strong></td></tr>
                <tr><td class="muted">Shift</td><td style="text-align:right"><strong>${we}</strong></td></tr>
                <tr><td class="muted">Saldo Awal</td><td style="text-align:right"><strong>${u(Ce)}</strong></td></tr>
                </table>

                <hr />

                <table>
                <tr><td class="muted">Total Penjualan</td><td style="text-align:right; color:#059669"><strong>${u(g.cashier_transactions.total_transaction)}</strong></td></tr>
                </table>

                <table style="margin-top:8px">
                <tr><td class="muted">Rincian Pembayaran</td><td></td></tr>
                <tr><td>Tunai</td><td style="text-align:right">${u(De)}</td></tr>
                ${Te}
                </table>

                <table style="margin-top:8px">
                <tr><td class="muted">Total Return Penjualan</td><td style="text-align:right; color:#dc2626"><strong>${u(g.cashier_transactions.total_return)}</strong></td></tr>
                </table>

                <hr />

                <table>
                <tr><td class="total">Perkiraan Saldo Akhir</td><td class="total" style="text-align:right">${u(g.end_cash)}</td></tr>
                </table>

                <div class="muted" style="margin-top:16px; font-size:11px">
                Dicetak: ${new Date().toLocaleString("id-ID")}
                </div>
            </div>
            <script>
                window.addEventListener('load', function() {
                window.print();
                setTimeout(() => window.close(), 200);
                });
            <\/script>
            </body>
            </html>
    `.trim()}function ke(e){const a=Ne(e),s=window.open("","_blank","width=840,height=960");if(!s){alert("Popup diblokir. Izinkan popup untuk mencetak laporan.");return}s.document.open(),s.document.write(a),s.document.close()}return jsxRuntimeExports.jsxs("nav",{className:"bg-sidebar px-4 py-3 shadow shrink-0 border-b border-border",children:[jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntimeExports.jsx("h1",{className:"text-lg font-semibold",children:ne[0].value}),jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntimeExports.jsx(Button,{variant:"ghost",size:"icon",className:"hover:bg-primary/80 bg-muted border border-border rounded-md",onClick:()=>_(!0),title:"Jenis Pesanan",children:jsxRuntimeExports.jsx(Utensils,{className:"w-5 h-5"})}),jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:jsxRuntimeExports.jsx(Button,{variant:"ghost",size:"icon",className:`border rounded-md ${$?"bg-green-500 hover:bg-green-600 text-white":"bg-red-500 hover:bg-red-600 text-white"}`,onClick:re,title:$?"Bluetooth Terhubung":"Hubungkan Printer",children:jsxRuntimeExports.jsx(Bluetooth,{className:"w-5 h-5"})})}),jsxRuntimeExports.jsx(Button,{variant:"ghost",size:"icon",className:"hover:bg-primary/80 bg-muted border border-border rounded-md",onClick:()=>O(!0),children:jsxRuntimeExports.jsx(Calculator,{className:"w-5 h-5"})}),jsxRuntimeExports.jsx(Button,{variant:"destructive",size:"icon",className:"border border-border rounded-md",onClick:()=>y(!0),title:"Tutup Kasir",children:jsxRuntimeExports.jsx(MonitorX,{className:"w-5 h-5"})}),jsxRuntimeExports.jsx("div",{className:"relative",children:jsxRuntimeExports.jsxs(Button,{variant:"ghost",size:"icon",className:"relative hover:bg-primary bg-warning border border-border rounded-md",onClick:()=>E(!0),children:[jsxRuntimeExports.jsx(Timer,{className:"w-5 h-5"}),l>0&&jsxRuntimeExports.jsx("span",{className:"absolute top-0 right-0 transform translate-x-1/2 -translate-y-1/2 bg-red-500 text-white text-[10px] font-semibold min-w-[18px] h-5 px-1.5 rounded-full flex items-center justify-center leading-none",children:l})]})}),jsxRuntimeExports.jsxs(DropdownMenu,{children:[jsxRuntimeExports.jsx(DropdownMenuTrigger,{asChild:!0,children:jsxRuntimeExports.jsx(Button,{variant:"ghost",size:"icon",className:"hover:bg-primary/80 bg-muted border border-border rounded-md",children:jsxRuntimeExports.jsx(User,{className:"w-5 h-5"})})}),jsxRuntimeExports.jsxs(DropdownMenuContent,{align:"end",children:[jsxRuntimeExports.jsxs(DropdownMenuItem,{onClick:()=>window.location.href="/dashboard",children:[jsxRuntimeExports.jsx(LayoutDashboard,{className:"w-4 h-4 mr-2"}),"Dashboard"]}),jsxRuntimeExports.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntimeExports.jsxs(Ye,{className:"block w-full",method:"post",href:route("logout"),as:"button",children:[jsxRuntimeExports.jsx(LogOut,{className:"w-4 h-4 mr-2"}),"Logout"]})})]})]})]})]}),jsxRuntimeExports.jsx(Dialog,{open:oe,onOpenChange:e=>{_(e),e||d("")},children:jsxRuntimeExports.jsxs(DialogContent,{className:"max-w-md",children:[jsxRuntimeExports.jsxs(DialogHeader,{children:[jsxRuntimeExports.jsx(DialogTitle,{className:"text-lg font-semibold",children:"Pilih Jenis Pesanan"}),jsxRuntimeExports.jsx(DialogDescription,{className:"text-sm text-muted-foreground",children:"Silakan pilih tipe pesanan dari pelanggan."})]}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 gap-4 mt-4",children:[jsxRuntimeExports.jsxs(Button,{variant:h==="dinein"?"default":"outline",className:"flex flex-col items-center justify-center h-24 rounded-xl text-sm",onClick:()=>{d("dine_in")},children:[jsxRuntimeExports.jsx(Utensils,{className:"w-6 h-6 mb-2"}),"Dine In"]}),jsxRuntimeExports.jsxs(Button,{variant:h==="takeaway"?"default":"outline",className:"flex flex-col items-center justify-center h-24 rounded-xl text-sm",onClick:()=>{d("takeaway"),D("takeaway")},children:[jsxRuntimeExports.jsx(ShoppingBag,{className:"w-6 h-6 mb-2"}),"Take Away"]}),jsxRuntimeExports.jsxs(Button,{variant:h==="platform"?"default":"outline",className:"flex flex-col items-center justify-center h-24 rounded-xl text-sm",onClick:()=>{d("platform")},children:[jsxRuntimeExports.jsx(Globe,{className:"w-6 h-6 mb-2"}),"Online"]})]}),h==="dine_in"&&jsxRuntimeExports.jsxs("div",{className:"mt-6",children:[jsxRuntimeExports.jsx("p",{className:"text-sm font-medium mb-3 text-muted-foreground",children:"Pilih Meja"}),jsxRuntimeExports.jsx("div",{className:"grid grid-cols-2 gap-3 overflow-y-auto h-60",children:o.map(e=>{const a=f===e.id,s=e.status!=="available",n={available:"Tersedia",unavailable:"Tidak Tersedia",booked:"Di-booking",occupied:"Tidak Tersedia",reserved:"Di-booking"}[e.status]||"Tidak Diketahui",p={available:"text-green-600",unavailable:"text-red-600",booked:"text-amber-600",occupied:"text-red-600",reserved:"text-amber-600"}[e.status]||"text-muted-foreground";return jsxRuntimeExports.jsxs(Button,{variant:a?"default":"secondary",className:`h-auto py-3 text-left text-sm flex flex-col items-start rounded-lg ${s?"opacity-50 cursor-not-allowed":""}`,onClick:()=>{s||w(e.id)},disabled:s,children:[jsxRuntimeExports.jsxs("span",{className:"font-medium",children:["Meja ",e.number]}),jsxRuntimeExports.jsxs("span",{className:"text-xs text-muted-foreground",children:["Kapasitas: ",e.capacity," org"]}),jsxRuntimeExports.jsx("span",{className:`text-xs mt-1 font-medium ${p}`,children:n})]},e.id)})}),f&&jsxRuntimeExports.jsx("div",{className:"mt-4 flex justify-end",children:jsxRuntimeExports.jsx(Button,{onClick:()=>D("dine_in"),children:"Lanjut"})})]}),h==="platform"&&jsxRuntimeExports.jsxs("div",{className:"mt-6",children:[jsxRuntimeExports.jsx("p",{className:"text-sm font-medium mb-3 text-muted-foreground",children:"Pilih Platform"}),jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3 gap-3",children:r.filter(e=>e.code==="OLS").map(e=>{const a=b===e.name;return jsxRuntimeExports.jsxs(Button,{variant:a?"default":"secondary",className:"h-auto py-3 text-sm flex flex-col items-center rounded-lg",onClick:()=>C(e.name),children:[jsxRuntimeExports.jsx("span",{className:"capitalize",children:e.name}),e.value&&jsxRuntimeExports.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:e.value})]},e.name)})}),b&&jsxRuntimeExports.jsx("div",{className:"mt-4 flex justify-end",children:jsxRuntimeExports.jsx(Button,{onClick:()=>D("platform"),children:"Lanjut"})})]})]})}),jsxRuntimeExports.jsx(CalculatorDialog,{open:me,onOpenChange:O}),jsxRuntimeExports.jsx(Dialog,{open:j,onOpenChange:y,children:jsxRuntimeExports.jsxs(DialogContent,{className:"w-full max-w-2xl",children:[jsxRuntimeExports.jsxs(DialogHeader,{children:[jsxRuntimeExports.jsx(DialogTitle,{children:"Konfirmasi Tutup Kasir"}),jsxRuntimeExports.jsx(DialogDescription,{children:"Apakah Anda yakin ingin menutup kasir? Semua transaksi akan diselesaikan dan sesi akan ditutup."})]}),jsxRuntimeExports.jsxs("div",{className:"mt-2 border border-border rounded-lg p-4 text-sm bg-muted/30 space-y-2",children:[jsxRuntimeExports.jsxs("div",{className:"flex justify-between",children:[jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"Nama Kasir"}),jsxRuntimeExports.jsx("span",{className:"font-medium text-foreground",children:((U=t==null?void 0:t.user)==null?void 0:U.name)??"-"})]}),jsxRuntimeExports.jsxs("div",{className:"flex justify-between",children:[jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"Shift"}),t?jsxRuntimeExports.jsxs("span",{className:"font-medium text-foreground",children:[t.shift.name," (",t.shift.start_time," - ",t.shift.end_time,")"]}):jsxRuntimeExports.jsx("span",{})]}),jsxRuntimeExports.jsxs("div",{className:"flex justify-between",children:[jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"Tanggal"}),jsxRuntimeExports.jsx("span",{className:"font-medium text-foreground",children:A})]}),jsxRuntimeExports.jsx("div",{className:"border-t border-border"}),jsxRuntimeExports.jsxs("div",{className:"flex justify-between",children:[jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"Saldo Awal"}),jsxRuntimeExports.jsxs("span",{className:"font-medium text-foreground",children:["Rp ",((K=t==null?void 0:t.starting_cash)==null?void 0:K.toLocaleString())??0]})]}),jsxRuntimeExports.jsxs("div",{className:"flex justify-between",children:[jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"Total Penjualan"}),jsxRuntimeExports.jsxs("span",{className:"font-medium text-green-600",children:["Rp ",m.cashier_transactions.total_transaction.toLocaleString()]})]}),jsxRuntimeExports.jsxs("div",{className:"pl-4 space-y-1 text-muted-foreground",children:[jsxRuntimeExports.jsxs("div",{className:"flex justify-between",children:[jsxRuntimeExports.jsx("span",{children:"Tunai"}),jsxRuntimeExports.jsxs("span",{className:"text-foreground",children:["Rp ",((F=(Y=(X=m.cashier_transactions.by_payment_method)==null?void 0:X.cash)==null?void 0:Y.total)==null?void 0:F.toLocaleString())??0]})]}),x.map((e,a)=>{var s,n,p;return jsxRuntimeExports.jsxs("div",{className:"flex justify-between",children:[jsxRuntimeExports.jsxs("span",{children:["Transfer ",jsxRuntimeExports.jsx("span",{className:"uppercase",children:e.bank_name})]}),jsxRuntimeExports.jsxs("span",{className:"text-foreground",children:["Rp ",((p=(n=(s=m.cashier_transactions.by_payment_method.transfer)==null?void 0:s[e.id])==null?void 0:n.total)==null?void 0:p.toLocaleString())??0]})]},a)})]}),jsxRuntimeExports.jsxs("div",{className:"flex justify-between pt-2",children:[jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"Total Return Penjualan"}),jsxRuntimeExports.jsxs("span",{className:"font-medium text-red-600",children:["Rp ",m.cashier_transactions.total_return.toLocaleString()]})]}),jsxRuntimeExports.jsx("div",{className:"border-t border-border"}),jsxRuntimeExports.jsxs("div",{className:"flex justify-between font-semibold text-base",children:[jsxRuntimeExports.jsx("span",{className:"text-foreground",children:"Perkiraan Saldo Akhir"}),jsxRuntimeExports.jsxs("span",{className:"text-foreground",children:["Rp ",m.end_cash.toLocaleString()]})]})]}),jsxRuntimeExports.jsx("div",{className:"text-xs text-muted-foreground mt-2",children:"Pastikan semua transaksi dan pengeluaran sudah dicatat sebelum menutup kasir."}),jsxRuntimeExports.jsxs(DialogFooter,{className:"mt-4 flex justify-between items-center",children:[jsxRuntimeExports.jsx(Button,{variant:"secondary",onClick:()=>ke({dateOnly:A,shiftCashier:t,bank_accounts:x,data:m}),children:"Cetak"}),jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[jsxRuntimeExports.jsx(Button,{variant:"outline",onClick:()=>y(!1),children:"Batal"}),jsxRuntimeExports.jsx("form",{onSubmit:Re,children:jsxRuntimeExports.jsx(Button,{variant:"destructive",type:"submit",disabled:fe,children:"Ya, Tutup Kasir"})})]})]})]})}),jsxRuntimeExports.jsx(Dialog,{open:S,onOpenChange:ue,children:jsxRuntimeExports.jsxs(DialogContent,{className:"max-w-3xl",children:[jsxRuntimeExports.jsx(DialogHeader,{children:jsxRuntimeExports.jsx(DialogTitle,{children:"Riwayat Transaksi"})}),jsxRuntimeExports.jsx(Input,{type:"text",placeholder:"Cari meja, order, atau customer...",className:"mb-2 px-3 py-2 border border-border rounded-md focus:outline-none focus:ring-2 focus:ring-primary",value:R,onChange:e=>pe(e.target.value)}),jsxRuntimeExports.jsx("div",{className:"overflow-auto max-h-[400px]",children:jsxRuntimeExports.jsxs("table",{className:"w-full text-sm border border-border rounded-md",children:[jsxRuntimeExports.jsx("thead",{className:"bg-muted text-foreground sticky top-0 z-10",children:jsxRuntimeExports.jsxs("tr",{className:"text-left",children:[jsxRuntimeExports.jsx("th",{className:"px-4 py-2 border-b border-border",children:"No"}),jsxRuntimeExports.jsx("th",{className:"px-4 py-2 border-b border-border",children:"No. Pesanan"}),jsxRuntimeExports.jsx("th",{className:"px-4 py-2 border-b border-border",children:"Customer"}),jsxRuntimeExports.jsx("th",{className:"px-4 py-2 border-b border-border",children:"Total"}),jsxRuntimeExports.jsx("th",{className:"px-4 py-2 border-b border-border",children:"Tanggal"})]})}),jsxRuntimeExports.jsx("tbody",{children:P.length===0?jsxRuntimeExports.jsx("tr",{children:jsxRuntimeExports.jsx("td",{colSpan:5,className:"text-center py-4 text-muted-foreground",children:"Tidak ada riwayat transaksi."})}):P.map((e,a)=>{var s;return jsxRuntimeExports.jsxs("tr",{className:"hover:bg-accent",children:[jsxRuntimeExports.jsxs("td",{className:"px-4 py-2 border-b border-border whitespace-nowrap",children:[" ",++a]}),jsxRuntimeExports.jsx("td",{className:"px-4 py-2 border-b border-border whitespace-nowrap",children:e.invoice}),jsxRuntimeExports.jsx("td",{className:"px-4 py-2 border-b border-border whitespace-nowrap",children:((s=e.customer)==null?void 0:s.name)??"Umum"}),jsxRuntimeExports.jsxs("td",{className:"px-4 py-2 border-b border-border whitespace-nowrap",children:["Rp ",e.grand_total.toLocaleString()]}),jsxRuntimeExports.jsx("td",{className:"px-4 py-2 border-b border-border whitespace-nowrap",children:e.transaction_date})]},a)})})]})}),i.last_page>1&&jsxRuntimeExports.jsx("div",{className:"pt-4 border-t mt-4",children:jsxRuntimeExports.jsxs("div",{className:"flex justify-center gap-2",children:[jsxRuntimeExports.jsx(Button,{size:"sm",variant:"outline",title:"Halaman Sebelumnya",disabled:i.current_page===1,onClick:()=>N(e=>Math.max(e-1,1)),children:"«"}),Array.from({length:i.last_page},(e,a)=>a+1).map(e=>jsxRuntimeExports.jsx(Button,{size:"sm",variant:e===i.current_page?"default":"outline",onClick:()=>N(e),children:e},e)),jsxRuntimeExports.jsx(Button,{size:"sm",variant:"outline",title:"Halaman Berikutnya",disabled:i.current_page===i.last_page,onClick:()=>N(e=>Math.min(e+1,i.last_page)),children:"»"})]})})]})}),jsxRuntimeExports.jsx(Dialog,{open:B,onOpenChange:E,children:jsxRuntimeExports.jsxs(DialogContent,{children:[jsxRuntimeExports.jsxs(DialogHeader,{children:[jsxRuntimeExports.jsx(DialogTitle,{children:"Pending Order"}),jsxRuntimeExports.jsx(DialogDescription,{children:"Daftar pesanan yang sedang menunggu penyelesaian."})]}),jsxRuntimeExports.jsx(Input,{type:"text",placeholder:"Cari meja, order, atau customer...",className:"mb-2 px-3 py-2 border border-border rounded-md focus:outline-none focus:ring-2 focus:ring-primary",value:T,onChange:e=>xe(e.target.value)}),jsxRuntimeExports.jsx("div",{className:"space-y-2 max-h-[400px] overflow-y-auto",children:de?jsxRuntimeExports.jsx("p",{className:"text-muted-foreground text-sm text-center",children:"Memuat data..."}):L.length===0?jsxRuntimeExports.jsx("p",{className:"text-muted-foreground text-sm text-center",children:"Tidak ada pesanan pending."}):L.map((e,a)=>{var s;return jsxRuntimeExports.jsxs("button",{className:"border border-border rounded-lg p-3 hover:bg-accent cursor-pointer transition w-full",onClick:()=>ye(e),children:[jsxRuntimeExports.jsxs("div",{className:"flex justify-between items-center mb-1",children:[jsxRuntimeExports.jsxs("p",{className:"font-medium text-foreground capitalize",children:[Ee(e.transaction_type,e)," - Order #",e.invoice]}),jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:e.transaction_date})]}),jsxRuntimeExports.jsxs("p",{className:"text-sm text-muted-foreground text-start",children:[((s=e.customer)==null?void 0:s.name)??"Umum","  |  ",e.transaction_details.length," item",e.transaction_details.length>1?"s":""," • Rp ",e.grand_total.toLocaleString()]})]},a)})}),jsxRuntimeExports.jsx(DialogFooter,{className:"mt-4",children:jsxRuntimeExports.jsx(Button,{variant:"outline",onClick:()=>E(!1),children:"Tutup"})})]})})]})}export{Navbar as default};
