import{r as f,j as e,v as C,$}from"./app-CffHYkHW.js";import{A as z}from"./app-layout-D-VS7nVU.js";import{C as x,a as h,b,d as _}from"./card-X_CDEGIm.js";import{c as N,B as v}from"./button-qhe8lrPU.js";import{I as n}from"./input-Bw4IOOzt.js";import{L as s}from"./label-iPcRrN_N.js";import{a as k,b as P}from"./index-Cy5bElus.js";import{P as L}from"./index-DPkgfxsD.js";import{a as S}from"./utils-C8zp8JNC.js";import"./sheet-Bisw0FSz.js";import"./index-C0loMkA3.js";import"./x-BfabuQJD.js";import"./createLucideIcon-DAR-hy5d.js";import"./index-C9NeyPdJ.js";import"./index-CjqRk3xD.js";import"./truck-DnoS8QCL.js";import"./package-BHw0cifz.js";import"./shopping-bag-AryJS2XX.js";import"./app-logo-icon-D3Jzt_fn.js";import"./bluetooth-context-CLrE8g1i.js";import"./index-Dw4sHwMN.js";import"./sonner-CPUj7IiR.js";var j="Toggle",y=f.forwardRef((i,r)=>{const{pressed:t,defaultPressed:d,onPressedChange:m,...c}=i,[l,o]=k({prop:t,onChange:m,defaultProp:d??!1,caller:j});return e.jsx(L.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":i.disabled?"":void 0,...c,ref:r,onClick:P(i.onClick,()=>{i.disabled||o(!l)})})});y.displayName=j;var T=y;const A=N("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-1.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}});function g({className:i,variant:r,size:t,...d}){return e.jsx(T,{"data-slot":"toggle",className:S(A({variant:r,size:t,className:i})),...d})}const R=[{title:"Settings",href:"/apps/settings"},{title:"Barcode Label Settings",href:"#"}];function te({settings:i}){const{data:r,setData:t,post:d,processing:m}=C({...i,media_type:i.media_type??"roll",labels_per_row:i.labels_per_row??1,labels_per_sheet:i.labels_per_sheet??30,row_spacing:i.row_spacing??3,column_spacing:i.column_spacing??3,text_size_name:i.text_size_name??10,text_size_variant:i.text_size_variant??9,text_size_price:i.text_size_price??11}),c=a=>{a.preventDefault(),d("/settings/barcode-label")},l=r.media_type==="lembar"?r.labels_per_sheet:5,o=r.media_type==="lembar"?Math.ceil(Math.sqrt(l)):r.labels_per_row,p=f.useRef(null),w=()=>{if(!p.current)return;p.current.innerHTML;const a=window.open("","","width=800,height=600");a&&(a.document.open(),a.document.write(`
        <html>
            <head>
                <title>Cetak Label</title>
                <style>
                    @page { margin: 0; }

                    body {
                        padding: 0;
                        margin: 0;
                        font-family: sans-serif;
                    }

                    /* GRID untuk posisi label */
                    .label-grid {
                        display: grid;
                        grid-template-columns: repeat(${o}, ${r.label_width}mm);
                        gap: ${r.row_spacing}mm ${r.column_spacing}mm;
                        padding-top: ${r.margin_top}mm;
                        padding-left: ${r.margin_left}mm;
                    }

                    /* KOTAK LABEL */
                    .label-item {
                        width: ${r.label_width}mm;
                        height: ${r.label_height}mm;
                        box-sizing: border-box;
                        border: 1px solid #000 !important;
                        padding: 2mm;
                        display: flex;
                        flex-direction: column;
                        justify-content: space-between;
                        font-size: 10px;
                    }

                    .text-center { text-align: center; }
                    .fw-bold { font-weight: bold; }
                </style>
            </head>

            <body>
                <div class="label-grid">
                    ${[...Array(l)].map(()=>`
                                <div class="label-item">
                                    ${r.show_product_name?`<div style="font-size:${r.text_size_name}mm">
                                                Nama Produk
                                            </div>`:""}

                                    ${r.show_variant?`<div style="font-size:${r.text_size_variant}mm">
                                                Varian: Pedas
                                            </div>`:""}

                                    <div class="text-center" style="opacity:0.8">
                                        [ BARCODE ]
                                    </div>

                                    ${r.show_price?`<div class="fw-bold" style="font-size:${r.text_size_price}mm">
                                                Rp 12.000
                                            </div>`:""}
                                </div>
                            `).join("")}
                </div>
            </body>
        </html>
    `),a.document.close(),a.focus(),setTimeout(()=>{a.print(),a.close()},300))};return e.jsxs(z,{breadcrumbs:R,children:[e.jsx($,{title:"Barcode Label Settings"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(x,{children:[e.jsx(h,{children:e.jsx(b,{children:"Pengaturan Label Barcode"})}),e.jsx(_,{children:e.jsxs("form",{className:"space-y-4",onSubmit:c,children:[e.jsxs("div",{children:[e.jsx(s,{children:"Jenis Media"}),e.jsxs("select",{className:"border rounded px-3 py-2 w-full bg-background text-foreground",value:r.media_type,onChange:a=>t("media_type",a.target.value),children:[e.jsx("option",{value:"roll",children:"Roll"}),e.jsx("option",{value:"traktor",children:"Traktor"}),e.jsx("option",{value:"lembar",children:"Lembaran"})]})]}),r.media_type!=="lembar"&&e.jsxs("div",{children:[e.jsx(s,{children:"Stiker per Baris"}),e.jsx(n,{type:"number",value:r.labels_per_row,onChange:a=>t("labels_per_row",a.target.value)})]}),r.media_type==="lembar"&&e.jsxs("div",{children:[e.jsx(s,{children:"Jumlah Stiker per Lembar"}),e.jsx(n,{type:"number",value:r.labels_per_sheet,onChange:a=>t("labels_per_sheet",a.target.value)})]}),e.jsxs("div",{children:[e.jsx(s,{children:"Lebar Label (mm)"}),e.jsx(n,{type:"number",value:r.label_width,onChange:a=>t("label_width",a.target.value)})]}),e.jsxs("div",{children:[e.jsx(s,{children:"Tinggi Label (mm)"}),e.jsx(n,{type:"number",value:r.label_height,onChange:a=>t("label_height",a.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(s,{children:"Jarak Antar Dua Baris (Row Spacing)"}),e.jsx(n,{type:"number",value:r.row_spacing,onChange:a=>t("row_spacing",a.target.value)})]}),e.jsxs("div",{children:[e.jsx(s,{children:"Jarak Antar Dua Kolom (Column Spacing)"}),e.jsx(n,{type:"number",value:r.column_spacing,onChange:a=>t("column_spacing",a.target.value)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(s,{children:"Margin Atas (mm)"}),e.jsx(n,{type:"number",value:r.margin_top,onChange:a=>t("margin_top",a.target.value)})]}),e.jsxs("div",{children:[e.jsx(s,{children:"Margin Kiri (mm)"}),e.jsx(n,{type:"number",value:r.margin_left,onChange:a=>t("margin_left",a.target.value)})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx(s,{className:"text-foreground",children:"Tampilkan Nama Produk"}),e.jsx(g,{pressed:r.show_product_name,onPressedChange:a=>t("show_product_name",a),className:`
            px-4 py-1 rounded-lg border border-border transition-all
            ${r.show_product_name?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}
        `,children:r.show_product_name?"On":"Off"})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx(s,{className:"text-foreground",children:"Tampilkan Variasi"}),e.jsx(g,{pressed:r.show_variant,onPressedChange:a=>t("show_variant",a),className:`
            px-4 py-1 rounded-lg border border-border transition-all
            ${r.show_variant?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}
        `,children:r.show_variant?"On":"Off"})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx(s,{className:"text-foreground",children:"Tampilkan Harga"}),e.jsx(g,{pressed:r.show_price,onPressedChange:a=>t("show_price",a),className:`
            px-4 py-1 rounded-lg border border-border transition-all
            ${r.show_price?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}
        `,children:r.show_price?"On":"Off"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx(s,{children:"Ukuran Nama (px)"}),e.jsx(n,{type:"number",value:r.text_size_name,onChange:a=>t("text_size_name",a.target.value)})]}),e.jsxs("div",{children:[e.jsx(s,{children:"Ukuran Variasi (px)"}),e.jsx(n,{type:"number",value:r.text_size_variant,onChange:a=>t("text_size_variant",a.target.value)})]}),e.jsxs("div",{children:[e.jsx(s,{children:"Ukuran Harga (px)"}),e.jsx(n,{type:"number",value:r.text_size_price,onChange:a=>t("text_size_price",a.target.value)})]})]}),e.jsx(v,{disabled:m,className:"w-full",children:"Simpan Pengaturan"})]})})]}),e.jsxs(x,{children:[e.jsxs(h,{className:"flex items-center justify-between",children:[e.jsx(b,{children:"Preview Label"}),e.jsx(v,{variant:"outline",onClick:w,children:"Cetak Preview"})]}),e.jsx(_,{children:e.jsx("div",{ref:p,className:"p-4 border rounded bg-card text-card-foreground",children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${o}, ${r.label_width}mm)`,gap:`${r.row_spacing}mm ${r.column_spacing}mm`,paddingTop:`${r.margin_top}mm`,paddingLeft:`${r.margin_left}mm`},children:[...Array(l)].map((a,u)=>e.jsxs("div",{style:{width:`${r.label_width}mm`,height:`${r.label_height}mm`,padding:"4px"},className:"text-xs border border-border rounded bg-background text-foreground flex flex-col",children:[r.show_product_name&&e.jsxs("div",{className:"truncate",style:{fontSize:`${r.text_size_name}mm`},children:["Nama Produk ",u]}),r.show_variant&&e.jsxs("div",{style:{fontSize:`${r.text_size_variant}mm`},children:["Varian: Pedas ",u]}),e.jsx("div",{className:"mt-auto mb-1 text-center opacity-80",style:{fontSize:`${r.text_size_variant}mm`},children:"[ BARCODE ]"}),r.show_price&&e.jsx("div",{className:"font-semibold",style:{fontSize:`${r.text_size_price}mm`},children:"Rp 12.000"})]},u))})})})]})]})]})}export{te as default};
