AdditionalSection-ZKpgGfxh.js 38 KB

1
  1. import{i as e}from"./chunk-aKtaBQYM.js";import{C as t,D as n,w as r}from"./client-DnySrlFv.js";import{a as i,i as a}from"./info-ROUoQhJR.js";import{n as o}from"./ToastContext-BRX0SW3C.js";import{t as s}from"./cloud-off-DfYbNG2N.js";import{t as c}from"./loader-circle-BEmFtawu.js";import{t as l}from"./scale-CD6XdXUk.js";import{t as u}from"./search-0n0CBc74.js";import{t as d}from"./sparkles-DRqKNlhr.js";import{t as f}from"./x-DR-Trv6U.js";import{y as p}from"./date-G9KUauqz.js";import{n as m,t as h}from"./filamentSwatchHelpers-D3oXQSGk.js";import{Dn as g,N as _,On as v,lt as y,w as b}from"./index-CovRLYqQ.js";import{_ as x,h as S,u as C,y as w}from"./utils-dMg0ogiz.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=t(),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}=r(),n={local:t(`profiles.localProfiles.badge`),orca_cloud:t(`configureAmsSlot.orcaCloud`),cloud:t(`configureAmsSlot.bambuCloud`),builtin:t(`configureAmsSlot.builtin`)}[e];return(0,k.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded whitespace-nowrap ${A[e]}`,children:n})}function M({value:e,options:t,inheritLabel:n,onChange:a,disabled:o=!1,ariaLabel:s}){let{t:c}=r(),[l,d]=(0,O.useState)(!1),[p,m]=(0,O.useState)(``),h=(0,O.useRef)(null),g=t.find(t=>t.code===e);(0,O.useEffect)(()=>{if(!l)return;let e=e=>{h.current&&!h.current.contains(e.target)&&d(!1)},t=e=>{e.key===`Escape`&&(e.stopPropagation(),d(!1))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t,!0)}},[l]);let _=p.trim().toLowerCase(),v=_?t.filter(e=>e.displayName.toLowerCase().includes(_)):t,y=e=>{a(e),d(!1),m(``)};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:()=>d(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:n}),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)(u,{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:p,onChange:e=>m(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`}),p&&(0,k.jsx)(`button`,{type:`button`,"aria-label":c(`common.clear`),onClick:()=>m(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:(0,k.jsx)(f,{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:n}),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:t,cloudAuthenticated:n,loadingCloudPresets:a,presetInputValue:o,setPresetInputValue:l,selectedPresetOption:d,filamentOptions:f,availableBrands:p,availableMaterials:m,suggestedBrands:h,suggestedMaterials:v,quickAdd:y,detailsRequired:b,quantity:S,onQuantityChange:w,errors:T}){let{t:E}=r(),[D,A]=(0,O.useState)(!1),[M,F]=(0,O.useState)(!1),[I,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)(!1),[B,V]=(0,O.useState)(``),[H,U]=(0,O.useState)(``),[W,G]=(0,O.useState)(``),[ee,K]=(0,O.useState)(String(e.label_weight)),[te,ne]=(0,O.useState)(!1),[re,ie]=(0,O.useState)(new Set),q=(0,O.useRef)(null),J=(0,O.useRef)(null),ae=(0,O.useRef)(null),oe=(0,O.useRef)(null);(0,O.useEffect)(()=>{let e=e=>{q.current&&!q.current.contains(e.target)&&A(!1),oe.current&&!oe.current.contains(e.target)&&z(!1),J.current&&!J.current.contains(e.target)&&F(!1),ae.current&&!ae.current.contains(e.target)&&L(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let se=(0,O.useMemo)(()=>{if(!o)return f;let e=o.toLowerCase();return f.filter(t=>t.displayName.toLowerCase().includes(e)||t.code.toLowerCase().includes(e))},[f,o]),Y=(0,O.useMemo)(()=>{if(!B)return p;let e=B.toLowerCase();return p.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)})},[p,B]),ce=(0,O.useMemo)(()=>{if(!H)return x;let e=H.toLowerCase();return x.filter(t=>t.toLowerCase().includes(e))},[H]),X=(0,O.useMemo)(()=>{if(!W)return m;let e=W.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)})},[W,m]),Z=(0,O.useMemo)(()=>N(Y,h),[Y,h]),Q=(0,O.useMemo)(()=>N(X,v),[X,v]);(0,O.useEffect)(()=>{te||K(String(e.label_weight))},[e.label_weight,te]);let le=n=>{t(`slicer_filament`,n.code),l(n.displayName),A(!1);let r=C(n.name),i=new Set,a=[[`material`,r.material],[`brand`,r.brand],[`subtype`,r.variant]];for(let[n,r]of a)r&&(e[n]&&!re.has(n)||(t(n,r),i.add(n)));ie(i)},$=(e,n)=>{re.has(e)&&ie(t=>{let n=new Set(t);return n.delete(e),n}),t(e,n)},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),V(``)},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),z(!1),G(``)},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)(c,{className:`w-3 h-3 animate-spin`}),` `,E(`inventory.loadingPresets`)]}):n?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(g,{className:`w-3 h-3 text-bambu-green`}),` `,E(`inventory.cloudConnected`)]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(s,{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:q,children:[(0,k.jsx)(u,{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=>{l(e.target.value),A(!0)},onFocus:()=>{A(!0),l(``)}}),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:R?W:e.material,onChange:e=>{G(e.target.value),z(!0)},onFocus:()=>{z(!0),G(``)}}),(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`}),R&&(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)]})]}),W&&!X.includes(W)&&(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`,W),z(!1),G(``)},children:E(`inventory.useCustomMaterial`,{material:W})})]})]}),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:J,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?B:e.brand,onChange:e=>{V(e.target.value),F(!0)},onFocus:()=>{F(!0),V(``)}}),(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)]})]}),B&&!Y.includes(B)&&(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`,B),F(!1),V(``)},children:E(`inventory.useCustomBrand`,{brand:B})})]})]}),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:ae,children:[(0,k.jsx)(`input`,{type:`text`,value:I?H:e.subtype,onChange:e=>{U(e.target.value),L(!0)},onFocus:()=>{L(!0),U(``)},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`}),I&&(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),L(!1),U(``)},children:t},t)),H&&!x.some(e=>e.toLowerCase()===H.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`,H),L(!1),U(``)},children:E(`inventory.useCustomBrand`,{brand:H})})]})]}),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:ee,min:0,onFocus:()=>ne(!0),onChange:e=>K(e.target.value),onBlur:()=>{ne(!1);let n=ee.trim(),r=Number(n);if(!n||!Number.isFinite(r)||r<0){K(String(e.label_weight));return}let i=Math.round(r);t(`label_weight`,i),K(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 I(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 L({formData:e,updateField:t,recentColors:n,onColorUsed:o,catalogColors:s}){let{t:c}=r(),[l,f]=(0,O.useState)(!1),[p,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=>_===(e.replace(`#`,``)+`FF`).substring(0,8).toUpperCase(),A=e=>y(e),j=(e,n,r,i)=>{let a=e.replace(`#`,``).toUpperCase();if(t(`rgba`,a.length===8?a:a+`FF`),t(`color_name`,n),r!==void 0){let e=r??``;R(e),B([]),V.current=e,t(`extra_colors`,e)}i!==void 0&&t(`effect_type`,i??``),o({name:n,hex:e})},M=(0,O.useMemo)(()=>{if(s.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=s.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=s.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=s.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=s.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[]},[s,e.brand,e.material,e.subtype]),N=(0,O.useMemo)(()=>{if(!p)return M;if(M.length===0)return[];let e=p.toLowerCase();return M.filter(t=>t.name.toLowerCase().includes(e)||(t.manufacturer?.toLowerCase().includes(e)??!1)||(t.material?.toLowerCase().includes(e)??!1))},[p,M]),P=M.length>0,F=(0,O.useMemo)(()=>p?S.filter(e=>e.name.toLowerCase().includes(p.toLowerCase())):l?S:w,[p,l]),[L,R]=(0,O.useState)(e.extra_colors),[z,B]=(0,O.useState)([]),V=(0,O.useRef)(e.extra_colors);(0,O.useEffect)(()=>{e.extra_colors!==V.current&&(R(e.extra_colors),B([]),V.current=e.extra_colors)},[e.extra_colors]);let H=(0,O.useMemo)(()=>m({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]),U=e=>{if(R(e),!e.trim()){B([]),V.current=``,t(`extra_colors`,``);return}let{value:n,invalid:r}=I(e);B(r),V.current=n,t(`extra_colors`,n)};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:H,"data-testid":`color-preview-banner`}),n.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)(v,{className:`w-3 h-3`}),(0,k.jsx)(`span`,{children:c(`inventory.recentColors`)})]}),(0,k.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:n.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)(u,{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:c(`inventory.searchColors`),value:p,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:p?c(`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:c(`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:c(p?`inventory.searchResults`:l?`inventory.allColors`:`inventory.commonColors`)}),!p&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>f(!l),className:`flex items-center gap-1 hover:text-white transition-colors`,children:l?(0,k.jsxs)(k.Fragment,{children:[c(`inventory.showLess`),` `,(0,k.jsx)(a,{className:`w-3 h-3`})]}):(0,k.jsxs)(k.Fragment,{children:[c(`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:c(`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:c(`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:c(`inventory.colorNamePlaceholder`),value:e.color_name,onChange:e=>t(`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:c(`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 n=e.target.value.replace(`#`,``).replace(/[^0-9A-Fa-f]/g,``).toUpperCase(),r=n.length>8?n.substring(0,8):n;E(r),r.length===6?t(`rgba`,r+`FF`):r.length===8&&t(`rgba`,r)},onBlur:()=>{if(T.length===7){let e=T+`0`;E(e),t(`rgba`,e)}else if(T.length>0&&T.length<6){let e=T.padEnd(6,`0`);E(e),t(`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=>{t(`rgba`,e.target.value.replace(`#`,``).toUpperCase()+`FF`)},title:c(`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:c(`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:c(`inventory.extraColorsPlaceholder`),value:L,onChange:e=>U(e.target.value),"data-testid":`extra-colors-input`}),z.length>0&&(0,k.jsx)(`p`,{className:`text-xs text-red-700 dark:text-red-400 mt-1`,children:c(`inventory.extraColorsInvalid`,{tokens:z.join(`, `)})}),!z.length&&(0,k.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-1`,children:c(`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)(d,{className:`w-3.5 h-3.5`}),c(`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=>t(`effect_type`,e.target.value),"data-testid":`effect-type-select`,children:h.map(e=>(0,k.jsx)(`option`,{value:e.value,children:c(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 R({catalog:e,value:t,onChange:n,catalogId:i,onCatalogIdChange:a}){let{t:o}=r(),[s,c]=(0,O.useState)(!1),[u,d]=(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 n=e.filter(e=>e.weight===t);if(i){let n=e.find(e=>e.id===i);if(n&&n.weight===t)return}n.length===1?a(n[0].id):n.length===0&&i!==null&&a(null)},[t,e,i,a]);let m=(0,O.useMemo)(()=>{if(!u)return e;let t=u.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t)||e.weight.toString().includes(t))},[e,u]),h=(0,O.useMemo)(()=>e.filter(e=>e.weight===t),[e,t]),g=(0,O.useMemo)(()=>{if(s)return u;if(i){let t=e.find(e=>e.id===i);if(t)return t.name}return h.length>0?h[0].name:``},[s,u,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)(l,{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),d(``)},onChange:e=>{d(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===t)?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{a(e.id),n(e.weight),c(!1),d(``)},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:t,min:0,max:2e3,onChange:e=>{let t=parseInt(e.target.value);!isNaN(t)&&t>=0&&n(t)}}),(0,k.jsx)(`span`,{className:`text-bambu-gray text-sm`,children:`g`})]})]})]})}function z({formData:e,updateField:t,spoolCatalog:n,currencySymbol:i,availableCategories:a,availableMaterialNumbers:s,availableLocations:c=[],onCreateLocation:l,globalLowStockThreshold:u,spoolmanMode:d=!1,showLastDried:f=!1}){let{t:m}=r(),{showToast:h}=o(),[g,_]=(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)(R,{catalog:n,value:e.core_weight,onChange:e=>t(`core_weight`,e),catalogId:e.core_weight_catalog_id,onCatalogIdChange:e=>t(`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:m(`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 n=b.trim(),r=Number(n);if(!n||!Number.isFinite(r)||r<0||r>e.label_weight){x(String(A));return}let i=Math.round(r);t(`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:m(`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:g,min:0,onFocus:()=>y(!0),onChange:e=>{_(e.target.value)},onBlur:()=>{y(!1);let n=g.trim(),r=Number(n),i=e.core_weight,a=e.core_weight+e.label_weight;if(!n||!Number.isFinite(r)||r<i||r>a){h(m(`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));t(`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:m(`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=>{t(`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:m(`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:m(`inventory.materialNumberPlaceholder`),value:e.material_number,maxLength:64,onChange:e=>t(`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:m(`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:m(`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:m(`inventory.categoryPlaceholder`),value:e.category,maxLength:50,onChange:e=>t(`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:m(`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 n=e.target.value;if(n===``){t(`low_stock_threshold_pct`,null);return}let r=Number(n);Number.isFinite(r)&&t(`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:m(`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:m(`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 n=e.target.value;if(!n){t(`location_id`,null);return}t(`location_id`,Number(n))},children:[(0,k.jsx)(`option`,{value:``,children:m(`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:m(`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 n=await l(e);n&&(t(`location_id`,n.id),T(``))}finally{D(!1)}}},children:m(`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:m(`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=>t(`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:()=>t(`last_dried_at`,p(new Date)),children:m(`inventory.lastDriedNow`)})]}),(0,k.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:m(`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:m(`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:m(`inventory.notePlaceholder`),value:e.note,onChange:e=>t(`note`,e.target.value)})]})]})}export{E as a,M as i,L as n,T as o,F as r,D as s,z as t};