AdditionalSection-CzDJF-2x.js 38 KB

1
  1. import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{T as t,k as n,w as r}from"./client-DWQBE01c.js";import{a as i,i as a}from"./info-CPhSLaIW.js";import{n as o}from"./ToastContext-Bg6SLDR7.js";import{t as s}from"./clock-B_D089Yk.js";import{t as c}from"./cloud-off-YV3jBhGQ.js";import{t as l}from"./cloud-Z2CCvbpR.js";import{t as u}from"./loader-circle-QIogdiwG.js";import{t as d}from"./scale-DmTkDo1n.js";import{t as f}from"./search-DLu9V8cG.js";import{t as p}from"./sparkles-DviWgAPD.js";import{t as m}from"./x-Ros7hs1-.js";import{a as h}from"./colors-je4aRt_-.js";import{y as g}from"./date-G9KUauqz.js";import{t as _}from"./NumberInput-Cf4OPY5C.js";import{n as v,t as y}from"./filamentSwatchHelpers-C3r5m07g.js";import{t as b}from"./FilamentSwatch-Dbs43U-F.js";import{_ as x,h as S,u as C,y as w}from"./utils-BGRMUZaT.js";var T={material:``,subtype:``,brand:``,color_name:``,rgba:`808080FF`,extra_colors:``,effect_type:``,label_weight:1e3,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:``,note:``,cost_per_kg:null,category:``,low_stock_threshold_pct:null,material_number:``,location_id:null,last_dried_at:``,spoolman_filament_id:null},E=new Set([`material`,`subtype`,`brand`,`rgba`,`color_name`,`label_weight`]);function D(e,t=!1,n=!1,r=`create`){let i={};return t||n||r!==`create`?(!e.material&&!e.spoolman_filament_id&&(i.material=`Material is required`),{isValid:Object.keys(i).length===0,errors:i}):(e.slicer_filament||(i.slicer_filament=`Slicer preset is required`),e.material||(i.material=`Material is required`),e.brand||(i.brand=`Brand is required`),e.subtype||(i.subtype=`Subtype is required`),{isValid:Object.keys(i).length===0,errors:i})}var O=e(n(),1),k=r(),A={local:`bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-400`,orca_cloud:`bg-purple-100 dark:bg-purple-500/20 text-purple-700 dark:text-purple-400`,cloud:`bg-bambu-blue/20 text-bambu-blue`,builtin:`bg-amber-100 dark:bg-amber-500/20 text-amber-700 dark:text-amber-400`};function j({source:e}){let{t:n}=t(),r={local:n(`profiles.localProfiles.badge`),orca_cloud:n(`configureAmsSlot.orcaCloud`),cloud:n(`configureAmsSlot.bambuCloud`),builtin:n(`configureAmsSlot.builtin`)}[e];return(0,k.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded whitespace-nowrap ${A[e]}`,children:r})}function M({value:e,options:n,inheritLabel:r,onChange:a,disabled:o=!1,ariaLabel:s}){let{t:c}=t(),[l,u]=(0,O.useState)(!1),[d,p]=(0,O.useState)(``),h=(0,O.useRef)(null),g=n.find(t=>t.code===e);(0,O.useEffect)(()=>{if(!l)return;let e=e=>{h.current&&!h.current.contains(e.target)&&u(!1)},t=e=>{e.key===`Escape`&&(e.stopPropagation(),u(!1))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t,!0)}},[l]);let _=d.trim().toLowerCase(),v=_?n.filter(e=>e.displayName.toLowerCase().includes(_)):n,y=e=>{a(e),u(!1),p(``)};return(0,k.jsxs)(`div`,{className:`relative`,ref:h,children:[(0,k.jsxs)(`button`,{type:`button`,"aria-label":s,"aria-haspopup":`listbox`,"aria-expanded":l,disabled:o,onClick:()=>u(e=>!e),className:`w-full flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-left focus:outline-none focus:border-bambu-green disabled:opacity-50`,children:[(0,k.jsx)(`span`,{className:`flex-1 min-w-0 truncate ${g?`text-white`:`text-bambu-gray italic`}`,children:g?g.displayName:r}),g&&(0,k.jsx)(j,{source:g.source}),(0,k.jsx)(i,{className:`w-3.5 h-3.5 text-bambu-gray shrink-0`})]}),l&&(0,k.jsxs)(`div`,{className:`absolute z-50 mt-1 w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl`,children:[(0,k.jsx)(`div`,{className:`p-2 border-b border-bambu-dark-tertiary`,children:(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(f,{className:`w-3.5 h-3.5 text-bambu-gray absolute left-2 top-1/2 -translate-y-1/2`}),(0,k.jsx)(`input`,{autoFocus:!0,type:`text`,value:d,onChange:e=>p(e.target.value),placeholder:c(`inventory.searchPresets`),className:`w-full pl-7 pr-7 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-md text-sm text-white placeholder:text-bambu-gray/60 focus:outline-none focus:border-bambu-green`}),d&&(0,k.jsx)(`button`,{type:`button`,"aria-label":c(`common.clear`),onClick:()=>p(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:(0,k.jsx)(m,{className:`w-3.5 h-3.5`})})]})}),(0,k.jsxs)(`div`,{className:`max-h-56 overflow-y-auto p-1`,role:`listbox`,"aria-label":s,children:[(0,k.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":!g,onClick:()=>y(null),className:`w-full text-left px-2 py-1.5 rounded-md text-sm italic ${g?`text-bambu-gray hover:bg-bambu-dark`:`bg-bambu-green/15 text-bambu-green`}`,children:r}),v.length===0?(0,k.jsx)(`p`,{className:`px-2 py-2 text-sm text-bambu-gray`,children:c(`inventory.noResults`)}):v.map(t=>(0,k.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t.code===e,onClick:()=>y(t),className:`w-full flex items-center gap-2 text-left px-2 py-1.5 rounded-md text-sm ${t.code===e?`bg-bambu-green/15 text-bambu-green`:`text-white hover:bg-bambu-dark`}`,children:[(0,k.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,title:t.displayName,children:t.displayName}),(0,k.jsx)(j,{source:t.source})]},t.code))]})]})]})}function N(e,t){if(t.length===0)return{top:[],rest:e};let n=new Set(t.map(e=>e.toLowerCase()));return{top:e.filter(e=>n.has(e.toLowerCase())),rest:e.filter(e=>!n.has(e.toLowerCase()))}}function P({label:e}){return(0,k.jsx)(`div`,{className:`px-3 py-1 text-[11px] font-semibold uppercase tracking-wide text-bambu-gray/70 bg-bambu-dark-tertiary/40`,children:e})}function F({formData:e,updateField:n,cloudAuthenticated:r,loadingCloudPresets:a,presetInputValue:o,setPresetInputValue:s,selectedPresetOption:d,filamentOptions:p,availableBrands:m,availableMaterials:h,suggestedBrands:g,suggestedMaterials:v,quickAdd:y,detailsRequired:b,quantity:S,onQuantityChange:w,errors:T}){let{t:E}=t(),[D,A]=(0,O.useState)(!1),[M,F]=(0,O.useState)(!1),[ee,I]=(0,O.useState)(!1),[L,R]=(0,O.useState)(!1),[z,B]=(0,O.useState)(``),[V,H]=(0,O.useState)(``),[U,W]=(0,O.useState)(``),[te,G]=(0,O.useState)(String(e.label_weight)),[ne,re]=(0,O.useState)(!1),[ie,ae]=(0,O.useState)(new Set),K=(0,O.useRef)(null),q=(0,O.useRef)(null),J=(0,O.useRef)(null),oe=(0,O.useRef)(null);(0,O.useEffect)(()=>{let e=e=>{K.current&&!K.current.contains(e.target)&&A(!1),oe.current&&!oe.current.contains(e.target)&&R(!1),q.current&&!q.current.contains(e.target)&&F(!1),J.current&&!J.current.contains(e.target)&&I(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let se=(0,O.useMemo)(()=>{if(!o)return p;let e=o.toLowerCase();return p.filter(t=>t.displayName.toLowerCase().includes(e)||t.code.toLowerCase().includes(e))},[p,o]),Y=(0,O.useMemo)(()=>{if(!z)return m;let e=z.toLowerCase();return m.filter(t=>t.toLowerCase().includes(e)).sort((t,n)=>{let r=t.toLowerCase()===e,i=n.toLowerCase()===e;return r&&!i?-1:!r&&i?1:t.localeCompare(n)})},[m,z]),ce=(0,O.useMemo)(()=>{if(!V)return x;let e=V.toLowerCase();return x.filter(t=>t.toLowerCase().includes(e))},[V]),X=(0,O.useMemo)(()=>{if(!U)return h;let e=U.toLowerCase();return h.filter(t=>t.toLowerCase().includes(e)).sort((t,n)=>{let r=t.toLowerCase()===e,i=n.toLowerCase()===e;return r&&!i?-1:!r&&i?1:t.localeCompare(n)})},[U,h]),Z=(0,O.useMemo)(()=>N(Y,g),[Y,g]),Q=(0,O.useMemo)(()=>N(X,v),[X,v]);(0,O.useEffect)(()=>{ne||G(String(e.label_weight))},[e.label_weight,ne]);let le=t=>{n(`slicer_filament`,t.code),s(t.displayName),A(!1);let r=C(t.name),i=new Set,a=[[`material`,r.material],[`brand`,r.brand],[`subtype`,r.variant]];for(let[t,r]of a)r&&(e[t]&&!ie.has(t)||(n(t,r),i.add(t)));ae(i)},$=(e,t)=>{ie.has(e)&&ae(t=>{let n=new Set(t);return n.delete(e),n}),n(e,t)},ue=t=>(0,k.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.brand===t?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{$(`brand`,t),F(!1),B(``)},children:t},t),de=t=>(0,k.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.material===t?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{$(`material`,t),R(!1),W(``)},children:t},t);return(0,k.jsxs)(`div`,{className:`space-y-4`,children:[!y&&(0,k.jsx)(`div`,{className:`flex items-center gap-2 text-xs text-bambu-gray`,children:a?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(u,{className:`w-3 h-3 animate-spin`}),` `,E(`inventory.loadingPresets`)]}):r?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(l,{className:`w-3 h-3 text-bambu-green`}),` `,E(`inventory.cloudConnected`)]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(c,{className:`w-3 h-3`}),` `,E(`inventory.cloudNotConnected`)]})}),!y&&(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[E(`inventory.slicerPreset`),b&&` *`]}),(0,k.jsxs)(`div`,{className:`relative`,ref:K,children:[(0,k.jsx)(f,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),(0,k.jsx)(`input`,{type:`text`,className:`w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:E(`inventory.searchPresets`),value:o,onChange:e=>{s(e.target.value),A(!0)},onFocus:()=>{A(!0),s(``)}}),D&&(0,k.jsx)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto`,children:se.length===0?(0,k.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:E(`inventory.noPresetsFound`)}):se.map(e=>(0,k.jsxs)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2 ${d?.code===e.code?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>le(e),children:[(0,k.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,title:e.displayName,children:e.displayName}),(0,k.jsx)(j,{source:e.source})]},`${e.code}::${e.name}`))})]}),d&&(0,k.jsxs)(`div`,{className:`mt-1 text-xs text-bambu-gray`,children:[E(`inventory.selectedPreset`),`: `,(0,k.jsx)(`span`,{className:`font-mono text-bambu-green`,children:d.code})]}),T?.slicer_filament&&(0,k.jsx)(`p`,{className:`mt-1 text-xs text-red-700 dark:text-red-400`,children:T.slicer_filament})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[E(`inventory.material`),` *`]}),(0,k.jsxs)(`div`,{className:`relative`,ref:oe,children:[(0,k.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:E(`inventory.selectMaterial`),value:L?U:e.material,onChange:e=>{W(e.target.value),R(!0)},onFocus:()=>{R(!0),W(``)}}),(0,k.jsx)(i,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),L&&(0,k.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[X.length===0?(0,k.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:E(`inventory.noResults`)}):(0,k.jsxs)(k.Fragment,{children:[Q.top.length>0&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(P,{label:E(`inventory.suggestedOptions`)}),Q.top.map(de)]}),Q.rest.length>0&&(0,k.jsxs)(k.Fragment,{children:[Q.top.length>0&&(0,k.jsx)(P,{label:E(`inventory.allOptions`)}),Q.rest.map(de)]})]}),U&&!X.includes(U)&&(0,k.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary`,onClick:()=>{$(`material`,U),R(!1),W(``)},children:E(`inventory.useCustomMaterial`,{material:U})})]})]}),T?.material&&(0,k.jsx)(`p`,{className:`mt-1 text-xs text-red-700 dark:text-red-400`,children:T.material})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[E(`inventory.brand`),b&&` *`]}),(0,k.jsxs)(`div`,{className:`relative`,ref:q,children:[(0,k.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:E(`inventory.searchBrand`),value:M?z:e.brand,onChange:e=>{B(e.target.value),F(!0)},onFocus:()=>{F(!0),B(``)}}),(0,k.jsx)(i,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),M&&(0,k.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[Y.length===0?(0,k.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:E(`inventory.noResults`)}):(0,k.jsxs)(k.Fragment,{children:[Z.top.length>0&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(P,{label:E(`inventory.suggestedOptions`)}),Z.top.map(ue)]}),Z.rest.length>0&&(0,k.jsxs)(k.Fragment,{children:[Z.top.length>0&&(0,k.jsx)(P,{label:E(`inventory.allOptions`)}),Z.rest.map(ue)]})]}),z&&!Y.includes(z)&&(0,k.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary`,onClick:()=>{$(`brand`,z),F(!1),B(``)},children:E(`inventory.useCustomBrand`,{brand:z})})]})]}),T?.brand&&(0,k.jsx)(`p`,{className:`mt-1 text-xs text-red-700 dark:text-red-400`,children:T.brand})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[E(`inventory.subtype`),b&&` *`]}),(0,k.jsxs)(`div`,{className:`relative`,ref:J,children:[(0,k.jsx)(`input`,{type:`text`,value:ee?V:e.subtype,onChange:e=>{H(e.target.value),I(!0)},onFocus:()=>{I(!0),H(``)},placeholder:`Basic, Matte, Silk...`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`}),(0,k.jsx)(i,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),ee&&(0,k.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[ce.length===0?(0,k.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:E(`inventory.noResults`)}):ce.map(t=>(0,k.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.subtype===t?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{$(`subtype`,t),I(!1),H(``)},children:t},t)),V&&!x.some(e=>e.toLowerCase()===V.toLowerCase().trim())&&(0,k.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary`,onClick:()=>{$(`subtype`,V),I(!1),H(``)},children:E(`inventory.useCustomBrand`,{brand:V})})]})]}),T?.subtype&&(0,k.jsx)(`p`,{className:`mt-1 text-xs text-red-700 dark:text-red-400`,children:T.subtype})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:E(`inventory.labelWeight`)}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(`input`,{type:`number`,className:`w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:te,min:0,onFocus:()=>re(!0),onChange:e=>G(e.target.value),onBlur:()=>{re(!1);let t=te.trim(),r=Number(t);if(!t||!Number.isFinite(r)||r<0){G(String(e.label_weight));return}let i=Math.round(r);n(`label_weight`,i),G(String(i))}}),(0,k.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray`,children:`g`})]})]}),y&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:E(`inventory.quantity`)}),(0,k.jsx)(_,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:S,min:1,max:100,onChange:w,fallback:1})]})]})}function ee(e){let t=e.split(/[\s,]+/).map(e=>e.trim().replace(/^#/,``)).filter(Boolean),n=[],r=[];for(let e of t)(e.length===6||e.length===8)&&/^[0-9a-fA-F]+$/.test(e)?n.push(e.toLowerCase()):r.push(e);return{value:n.join(`,`),invalid:r}}function I({formData:e,updateField:n,recentColors:r,onColorUsed:o,catalogColors:c}){let{t:l}=t(),[u,d]=(0,O.useState)(!1),[m,g]=(0,O.useState)(``),_=(e.rgba.replace(`#`,``)+`FF`).substring(0,8).toUpperCase(),x=_.substring(0,6),C=_.substring(6,8)===`00`,[T,E]=(0,O.useState)(C?_:x);(0,O.useEffect)(()=>{E(C?_:x)},[x,_,C]);let D=e=>{let t=(e.replace(`#`,``)+`FF`).substring(0,8).toUpperCase();return _===t},A=e=>h(e),j=(e,t,r,i)=>{let a=e.replace(`#`,``).toUpperCase();if(n(`rgba`,a.length===8?a:a+`FF`),n(`color_name`,t),r!==void 0){let e=r??``;L(e),z([]),B.current=e,n(`extra_colors`,e)}i!==void 0&&n(`effect_type`,i??``),o({name:t,hex:e})},M=(0,O.useMemo)(()=>{if(c.length===0)return[];let t=e.brand?.trim(),n=e.material?.toLowerCase().trim(),r=e.subtype?.toLowerCase().trim();if(!t&&!n)return[];let i=t?t.toLowerCase().split(/[\s\-_]+/).filter(e=>e.length>=2):[],a=e=>{if(i.length===0)return!0;let t=e.toLowerCase();return i.some(e=>t.includes(e))};if(t&&!n){let e=c.filter(e=>a(e.manufacturer));if(e.length>0)return e.map(e=>({name:e.color_name,hex:e.hex_color.replace(`#`,``).substring(0,6),manufacturer:e.manufacturer,material:typeof e.material==`string`?e.material:void 0,extra_colors:e.extra_colors??null,effect_type:e.effect_type??null}))}let o=n&&r?`${n} ${r}`:``;if(o){let e=c.filter(e=>a(e.manufacturer)&&e.material?.toLowerCase()===o);if(e.length>0)return e.map(e=>({name:e.color_name,hex:e.hex_color.replace(`#`,``).substring(0,6),manufacturer:e.manufacturer,material:typeof e.material==`string`?e.material:void 0,extra_colors:e.extra_colors??null,effect_type:e.effect_type??null}));let t=o.replace(/\+$/,``);if(t!==o){let e=c.filter(e=>a(e.manufacturer)&&e.material?.toLowerCase()===t);if(e.length>0)return e.map(e=>({name:e.color_name,hex:e.hex_color.replace(`#`,``).substring(0,6),manufacturer:e.manufacturer,material:typeof e.material==`string`?e.material:void 0}))}}if(n){let e=c.filter(e=>a(e.manufacturer)&&(!e.material||e.material.toLowerCase().startsWith(n)));if(e.length>0)return e.map(e=>({name:e.color_name,hex:e.hex_color.replace(`#`,``).substring(0,6),manufacturer:e.manufacturer,material:typeof e.material==`string`?e.material:void 0,extra_colors:e.extra_colors??null,effect_type:e.effect_type??null}))}return[]},[c,e.brand,e.material,e.subtype]),N=(0,O.useMemo)(()=>{if(!m)return M;if(M.length===0)return[];let e=m.toLowerCase();return M.filter(t=>t.name.toLowerCase().includes(e)||(t.manufacturer?.toLowerCase().includes(e)??!1)||(t.material?.toLowerCase().includes(e)??!1))},[m,M]),P=M.length>0,F=(0,O.useMemo)(()=>m?S.filter(e=>e.name.toLowerCase().includes(m.toLowerCase())):u?S:w,[m,u]),[I,L]=(0,O.useState)(e.extra_colors),[R,z]=(0,O.useState)([]),B=(0,O.useRef)(e.extra_colors);(0,O.useEffect)(()=>{e.extra_colors!==B.current&&(L(e.extra_colors),z([]),B.current=e.extra_colors)},[e.extra_colors]);let V=(0,O.useMemo)(()=>v({rgba:e.rgba,extraColors:e.extra_colors,effectType:e.effect_type,subtype:e.subtype,effectSize:`bar`}),[e.rgba,e.extra_colors,e.effect_type,e.subtype]),H=e=>{if(L(e),!e.trim()){z([]),B.current=``,n(`extra_colors`,``);return}let{value:t,invalid:r}=ee(e);z(r),B.current=t,n(`extra_colors`,t)};return(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsx)(`div`,{className:`h-10 rounded-lg border border-bambu-dark-tertiary`,style:V,"data-testid":`color-preview-banner`}),r.length>0&&(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-bambu-gray shrink-0`,children:[(0,k.jsx)(s,{className:`w-3 h-3`}),(0,k.jsx)(`span`,{children:l(`inventory.recentColors`)})]}),(0,k.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.map(e=>(0,k.jsx)(`button`,{type:`button`,onClick:()=>j(e.hex,e.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 ${D(e.hex)?`border-bambu-green ring-1 ring-bambu-green/30 scale-110`:`border-bambu-dark-tertiary`}`,style:A(e.hex),title:e.name},e.hex))})]}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(f,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),(0,k.jsx)(`input`,{type:`text`,className:`w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:l(`inventory.searchColors`),value:m,onChange:e=>g(e.target.value)})]}),P?(0,k.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,k.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:m?l(`inventory.searchResults`):`${e.brand}${e.material?` ${e.material}`:``}`}),(0,k.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[N.map(e=>(0,k.jsx)(`button`,{type:`button`,onClick:()=>j(e.hex,e.name,e.extra_colors,e.effect_type),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${D(e.hex)?`border-bambu-green ring-1 ring-bambu-green/30 scale-110`:`border-bambu-dark-tertiary`}`,style:A(e.hex),title:e.manufacturer&&e.material?`${e.name} (${e.manufacturer} — ${e.material})`:e.manufacturer?`${e.name} (${e.manufacturer})`:e.name,children:(0,k.jsx)(`span`,{className:`absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white`,children:e.manufacturer&&e.material?`${e.name} (${e.manufacturer} — ${e.material})`:e.manufacturer?`${e.name} (${e.manufacturer})`:e.name})},`${e.hex}-${e.name}-${e.manufacturer??``}`)),N.length===0&&(0,k.jsx)(`p`,{className:`text-sm text-bambu-gray py-1`,children:l(`inventory.noColorsFound`)})]})]}):(0,k.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-bambu-gray`,children:[(0,k.jsx)(`span`,{children:l(m?`inventory.searchResults`:u?`inventory.allColors`:`inventory.commonColors`)}),!m&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>d(!u),className:`flex items-center gap-1 hover:text-white transition-colors`,children:u?(0,k.jsxs)(k.Fragment,{children:[l(`inventory.showLess`),` `,(0,k.jsx)(a,{className:`w-3 h-3`})]}):(0,k.jsxs)(k.Fragment,{children:[l(`inventory.showAll`),` `,(0,k.jsx)(i,{className:`w-3 h-3`})]})})]}),(0,k.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[F.map(e=>(0,k.jsx)(`button`,{type:`button`,onClick:()=>j(e.hex,e.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${D(e.hex)?`border-bambu-green ring-1 ring-bambu-green/30 scale-110`:`border-bambu-dark-tertiary`}`,style:A(e.hex),title:e.name,children:(0,k.jsx)(`span`,{className:`absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white`,children:e.name})},e.hex)),F.length===0&&(0,k.jsx)(`p`,{className:`text-sm text-bambu-gray py-1`,children:l(`inventory.noColorsFound`)})]})]}),(0,k.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:l(`inventory.colorName`)}),(0,k.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:l(`inventory.colorNamePlaceholder`),value:e.color_name,onChange:e=>n(`color_name`,e.target.value)})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:l(`inventory.hexColor`)}),(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsxs)(`div`,{className:`relative flex-1`,children:[(0,k.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray`,children:`#`}),(0,k.jsx)(`input`,{type:`text`,className:`w-full pl-7 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono uppercase focus:outline-none focus:border-bambu-green`,placeholder:`RRGGBB`,value:T.toUpperCase(),onChange:e=>{let t=e.target.value.replace(`#`,``).replace(/[^0-9A-Fa-f]/g,``).toUpperCase(),r=t.length>8?t.substring(0,8):t;E(r),r.length===6?n(`rgba`,r+`FF`):r.length===8&&n(`rgba`,r)},onBlur:()=>{if(T.length===7){let e=T+`0`;E(e),n(`rgba`,e)}else if(T.length>0&&T.length<6){let e=T.padEnd(6,`0`);E(e),n(`rgba`,e+`FF`)}}})]}),(0,k.jsx)(`input`,{type:`color`,className:`w-11 h-[38px] rounded-lg cursor-pointer border border-bambu-dark-tertiary shrink-0 bg-transparent`,value:`#${x}`,onChange:e=>{n(`rgba`,e.target.value.replace(`#`,``).toUpperCase()+`FF`)},title:l(`inventory.pickColor`)})]})]})]}),(0,k.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 pt-2 border-t border-bambu-dark-tertiary/50`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:l(`inventory.extraColorsLabel`)}),(0,k.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:l(`inventory.extraColorsPlaceholder`),value:I,onChange:e=>H(e.target.value),"data-testid":`extra-colors-input`}),R.length>0&&(0,k.jsx)(`p`,{className:`text-xs text-red-700 dark:text-red-400 mt-1`,children:l(`inventory.extraColorsInvalid`,{tokens:R.join(`, `)})}),!R.length&&(0,k.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-1`,children:l(`inventory.extraColorsHint`)})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1 flex items-center gap-1.5`,children:[(0,k.jsx)(p,{className:`w-3.5 h-3.5`}),l(`inventory.colorEffectLabel`)]}),(0,k.jsxs)(`div`,{className:`flex gap-2 items-stretch`,children:[(0,k.jsx)(`select`,{className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:e.effect_type,onChange:e=>n(`effect_type`,e.target.value),"data-testid":`effect-type-select`,children:y.map(e=>(0,k.jsx)(`option`,{value:e.value,children:l(e.labelKey)},e.value||`none`))}),(0,k.jsx)(b,{rgba:e.rgba,extraColors:e.extra_colors,effectType:e.effect_type,subtype:e.subtype,effectSize:`preview`,className:`w-10 h-10`,shape:`square`})]})]})]})]})}function L({catalog:e,value:n,onChange:r,catalogId:i,onCatalogIdChange:a}){let{t:o}=t(),[s,c]=(0,O.useState)(!1),[l,u]=(0,O.useState)(``),f=(0,O.useRef)(null),p=(0,O.useRef)(null);(0,O.useEffect)(()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&c(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,O.useEffect)(()=>{if(e.length===0)return;let t=e.filter(e=>e.weight===n);if(i){let t=e.find(e=>e.id===i);if(t&&t.weight===n)return}t.length===1?a(t[0].id):t.length===0&&i!==null&&a(null)},[n,e,i,a]);let m=(0,O.useMemo)(()=>{if(!l)return e;let t=l.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t)||e.weight.toString().includes(t))},[e,l]),h=(0,O.useMemo)(()=>e.filter(e=>e.weight===n),[e,n]),g=(0,O.useMemo)(()=>{if(s)return l;if(i){let t=e.find(e=>e.id===i);if(t)return t.name}return h.length>0?h[0].name:``},[s,l,i,e,h]);return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:(0,k.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(d,{className:`w-3.5 h-3.5 text-bambu-gray`}),o(`inventory.coreWeight`)]})}),(0,k.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,k.jsxs)(`div`,{className:`flex-1 min-w-0 relative`,ref:f,children:[(0,k.jsx)(`input`,{ref:p,type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:o(`inventory.searchSpoolWeight`),value:g,onFocus:()=>{c(!0),u(``)},onChange:e=>{u(e.target.value),c(!0)}}),s&&(0,k.jsx)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto`,children:m.length===0?(0,k.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:o(`inventory.noResults`)}):m.map(e=>(0,k.jsxs)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex justify-between items-center ${(i?e.id===i:e.weight===n)?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{a(e.id),r(e.weight),c(!1),u(``)},children:[(0,k.jsx)(`span`,{className:`truncate`,children:e.name}),(0,k.jsxs)(`span`,{className:`font-mono text-xs text-bambu-gray ml-2 shrink-0`,children:[e.weight,`g`]})]},e.id))})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,k.jsx)(`input`,{type:`number`,className:`w-16 px-2 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm text-center font-mono focus:outline-none focus:border-bambu-green`,value:n,min:0,max:2e3,onChange:e=>{let t=parseInt(e.target.value);!isNaN(t)&&t>=0&&r(t)}}),(0,k.jsx)(`span`,{className:`text-bambu-gray text-sm`,children:`g`})]})]})]})}function R({formData:e,updateField:n,spoolCatalog:r,currencySymbol:i,availableCategories:a,availableMaterialNumbers:s,availableLocations:c=[],onCreateLocation:l,globalLowStockThreshold:u,spoolmanMode:d=!1,showLastDried:f=!1}){let{t:p}=t(),{showToast:m}=o(),[h,_]=(0,O.useState)(``),[v,y]=(0,O.useState)(!1),[b,x]=(0,O.useState)(``),[S,C]=(0,O.useState)(!1),[w,T]=(0,O.useState)(``),[E,D]=(0,O.useState)(!1),A=Math.max(0,e.label_weight-e.weight_used),j=e.core_weight+A;return(0,O.useEffect)(()=>{v||_(String(j))},[v,j]),(0,O.useEffect)(()=>{S||x(String(A))},[S,A]),(0,k.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-4`,children:[(0,k.jsx)(`div`,{className:`sm:col-span-2`,children:(0,k.jsx)(L,{catalog:r,value:e.core_weight,onChange:e=>n(`core_weight`,e),catalogId:e.core_weight_catalog_id,onCatalogIdChange:e=>n(`core_weight_catalog_id`,e)})}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:p(`inventory.currentWeight`)}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`div`,{className:`relative flex-1`,children:[(0,k.jsx)(`input`,{type:`number`,value:b,min:0,max:e.label_weight,onFocus:()=>C(!0),onChange:e=>{x(e.target.value)},onBlur:()=>{C(!1);let t=b.trim(),r=Number(t);if(!t||!Number.isFinite(r)||r<0||r>e.label_weight){x(String(A));return}let i=Math.round(r);n(`weight_used`,Math.max(0,e.label_weight-i)),x(String(i))},className:`w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`}),(0,k.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray`,children:`g`})]}),(0,k.jsxs)(`span`,{className:`text-xs text-bambu-gray shrink-0`,children:[`/ `,e.label_weight,`g`]})]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:p(`inventory.measuredWeight`)}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`div`,{className:`relative flex-1`,children:[(0,k.jsx)(`input`,{type:`number`,value:h,min:0,onFocus:()=>y(!0),onChange:e=>{_(e.target.value)},onBlur:()=>{y(!1);let t=h.trim(),r=Number(t),i=e.core_weight,a=e.core_weight+e.label_weight;if(!t||!Number.isFinite(r)||r<i||r>a){m(p(`inventory.measuredWeightError`,{min:i,max:a}),`error`),_(String(j));return}let o=Math.round(r),s=Math.max(0,Math.min(e.label_weight,o-e.core_weight));n(`weight_used`,Math.max(0,e.label_weight-s)),_(String(o))},className:`w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`}),(0,k.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray`,children:`g`})]}),(0,k.jsxs)(`span`,{className:`text-xs text-bambu-gray shrink-0`,children:[`/ `,e.core_weight+e.label_weight,`g`]})]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:p(`inventory.costPerKg`,`Cost per kg`)}),(0,k.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,k.jsxs)(`div`,{className:`relative flex-1`,children:[(0,k.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none`,children:i}),(0,k.jsx)(`input`,{type:`number`,value:e.cost_per_kg??``,min:0,step:.01,placeholder:`0.00`,onChange:e=>{n(`cost_per_kg`,e.target.value===``?null:parseFloat(e.target.value))},style:{paddingLeft:`${Math.max(2,i.length*.6+1)}rem`},className:`w-full py-2 pr-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`})]})})]}),!d&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-material-number`,children:p(`inventory.materialNumber`)}),(0,k.jsx)(`input`,{id:`spool-material-number`,type:`text`,list:`spool-material-number-options`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:p(`inventory.materialNumberPlaceholder`),value:e.material_number,maxLength:64,onChange:e=>n(`material_number`,e.target.value)}),s.length>0&&(0,k.jsx)(`datalist`,{id:`spool-material-number-options`,children:s.map(e=>(0,k.jsx)(`option`,{value:e},e))}),(0,k.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:p(`inventory.materialNumberHelp`)})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-category`,children:p(`inventory.category`)}),(0,k.jsx)(`input`,{id:`spool-category`,type:`text`,list:`spool-category-options`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:p(`inventory.categoryPlaceholder`),value:e.category,maxLength:50,onChange:e=>n(`category`,e.target.value)}),a.length>0&&(0,k.jsx)(`datalist`,{id:`spool-category-options`,children:a.map(e=>(0,k.jsx)(`option`,{value:e},e))})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-low-stock-threshold`,children:p(`inventory.lowStockThresholdOverride`)}),(0,k.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,k.jsxs)(`div`,{className:`relative flex-1`,children:[(0,k.jsx)(`input`,{id:`spool-low-stock-threshold`,type:`number`,className:`w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:String(u),value:e.low_stock_threshold_pct??``,min:1,max:99,step:1,onChange:e=>{let t=e.target.value;if(t===``){n(`low_stock_threshold_pct`,null);return}let r=Number(t);Number.isFinite(r)&&n(`low_stock_threshold_pct`,Math.min(99,Math.max(1,Math.round(r))))}}),(0,k.jsx)(`span`,{className:`absolute right-3 top-1/2 -translate-y-1/2 text-xs text-bambu-gray pointer-events-none`,children:`%`})]})}),(0,k.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:p(`inventory.lowStockThresholdOverrideHelp`,{global:u})})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-storage-location`,children:p(`inventory.storageLocation`)}),(0,k.jsxs)(`select`,{id:`spool-storage-location`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:e.location_id??``,onChange:e=>{let t=e.target.value;if(!t){n(`location_id`,null);return}n(`location_id`,Number(t))},children:[(0,k.jsx)(`option`,{value:``,children:p(`inventory.storageLocationNone`)}),c.map(e=>(0,k.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),l&&(0,k.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,k.jsx)(`input`,{type:`text`,maxLength:255,className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:p(`locations.createPlaceholder`),value:w,onChange:e=>T(e.target.value)}),(0,k.jsx)(`button`,{type:`button`,className:`px-3 py-2 text-sm rounded-lg bg-bambu-dark-tertiary text-white hover:bg-bambu-gray-dark disabled:opacity-50`,disabled:!w.trim()||E,onClick:async()=>{let e=w.trim();if(!(!e||!l)){D(!0);try{let t=await l(e);t&&(n(`location_id`,t.id),T(``))}finally{D(!1)}}},children:p(`locations.addShort`)})]})]}),f&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-last-dried`,children:p(`inventory.lastDried`)}),(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(`input`,{id:`spool-last-dried`,type:`datetime-local`,className:`flex-1 min-w-0 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:e.last_dried_at,onChange:e=>n(`last_dried_at`,e.target.value)}),(0,k.jsx)(`button`,{type:`button`,className:`px-3 py-2 text-sm rounded-lg bg-bambu-dark-tertiary text-white hover:bg-bambu-gray-dark`,onClick:()=>n(`last_dried_at`,g(new Date)),children:p(`inventory.lastDriedNow`)})]}),(0,k.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:p(`inventory.lastDriedHelp`)})]}),(0,k.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:p(`inventory.note`)}),(0,k.jsx)(`textarea`,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green resize-none min-h-[80px]`,placeholder:p(`inventory.notePlaceholder`),value:e.note,onChange:e=>n(`note`,e.target.value)})]})]})}export{E as a,M as i,I as n,T as o,F as r,D as s,R as t};