| 1 |
- import{i as e}from"./chunk-aKtaBQYM.js";import{C as t,D as n,w as r}from"./client-BdOyoZJz.js";import{a as i,i as a}from"./info-DcT0QU8O.js";import{n as o}from"./ToastContext-VFOrCCoA.js";import{t as s}from"./cloud-off-DmnG-KIw.js";import{t as c}from"./loader-circle-CB4leTZa.js";import{t as l}from"./scale-lRomj4j_.js";import{t as u}from"./search-BpAJdxRw.js";import{t as d}from"./sparkles-AUof3WTI.js";import{t as f}from"./x-Dctff5l9.js";import{n as p,t as m}from"./filamentSwatchHelpers-D3oXQSGk.js";import{Dn as h,N as g,On as _,lt as v,w as y}from"./index-DCvCEjg1.js";import{_ as b,h as x,u as S,y as C}from"./utils-nDQe1q2X.js";var w={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,spoolman_filament_id:null},T=new Set([`material`,`subtype`,`brand`,`rgba`,`color_name`,`label_weight`]);function E(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 D=e(n(),1),O=t(),k={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 A({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,O.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded whitespace-nowrap ${k[e]}`,children:n})}function j({value:e,options:t,inheritLabel:n,onChange:a,disabled:o=!1,ariaLabel:s}){let{t:c}=r(),[l,d]=(0,D.useState)(!1),[p,m]=(0,D.useState)(``),h=(0,D.useRef)(null),g=t.find(t=>t.code===e);(0,D.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,O.jsxs)(`div`,{className:`relative`,ref:h,children:[(0,O.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,O.jsx)(`span`,{className:`flex-1 min-w-0 truncate ${g?`text-white`:`text-bambu-gray italic`}`,children:g?g.displayName:n}),g&&(0,O.jsx)(A,{source:g.source}),(0,O.jsx)(i,{className:`w-3.5 h-3.5 text-bambu-gray shrink-0`})]}),l&&(0,O.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,O.jsx)(`div`,{className:`p-2 border-b border-bambu-dark-tertiary`,children:(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(u,{className:`w-3.5 h-3.5 text-bambu-gray absolute left-2 top-1/2 -translate-y-1/2`}),(0,O.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,O.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,O.jsx)(f,{className:`w-3.5 h-3.5`})})]})}),(0,O.jsxs)(`div`,{className:`max-h-56 overflow-y-auto p-1`,role:`listbox`,"aria-label":s,children:[(0,O.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,O.jsx)(`p`,{className:`px-2 py-2 text-sm text-bambu-gray`,children:c(`inventory.noResults`)}):v.map(t=>(0,O.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,O.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,title:t.displayName,children:t.displayName}),(0,O.jsx)(A,{source:t.source})]},t.code))]})]})]})}function M(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 N({label:e}){return(0,O.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 P({formData:e,updateField:t,cloudAuthenticated:n,loadingCloudPresets:a,presetInputValue:o,setPresetInputValue:l,selectedPresetOption:d,filamentOptions:f,availableBrands:p,availableMaterials:m,suggestedBrands:_,suggestedMaterials:v,quickAdd:y,detailsRequired:x,quantity:C,onQuantityChange:w,errors:T}){let{t:E}=r(),[k,j]=(0,D.useState)(!1),[P,F]=(0,D.useState)(!1),[I,L]=(0,D.useState)(!1),[R,z]=(0,D.useState)(!1),[B,V]=(0,D.useState)(``),[H,U]=(0,D.useState)(``),[W,G]=(0,D.useState)(``),[ee,K]=(0,D.useState)(String(e.label_weight)),[te,ne]=(0,D.useState)(!1),[re,ie]=(0,D.useState)(new Set),q=(0,D.useRef)(null),J=(0,D.useRef)(null),ae=(0,D.useRef)(null),oe=(0,D.useRef)(null);(0,D.useEffect)(()=>{let e=e=>{q.current&&!q.current.contains(e.target)&&j(!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,D.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,D.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,D.useMemo)(()=>{if(!H)return b;let e=H.toLowerCase();return b.filter(t=>t.toLowerCase().includes(e))},[H]),X=(0,D.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,D.useMemo)(()=>M(Y,_),[Y,_]),Q=(0,D.useMemo)(()=>M(X,v),[X,v]);(0,D.useEffect)(()=>{te||K(String(e.label_weight))},[e.label_weight,te]);let le=n=>{t(`slicer_filament`,n.code),l(n.displayName),j(!1);let r=S(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,O.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,O.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,O.jsxs)(`div`,{className:`space-y-4`,children:[!y&&(0,O.jsx)(`div`,{className:`flex items-center gap-2 text-xs text-bambu-gray`,children:a?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(c,{className:`w-3 h-3 animate-spin`}),` `,E(`inventory.loadingPresets`)]}):n?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(h,{className:`w-3 h-3 text-bambu-green`}),` `,E(`inventory.cloudConnected`)]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(s,{className:`w-3 h-3`}),` `,E(`inventory.cloudNotConnected`)]})}),!y&&(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[E(`inventory.slicerPreset`),x&&` *`]}),(0,O.jsxs)(`div`,{className:`relative`,ref:q,children:[(0,O.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,O.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),j(!0)},onFocus:()=>{j(!0),l(``)}}),k&&(0,O.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,O.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:E(`inventory.noPresetsFound`)}):se.map(e=>(0,O.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,O.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,title:e.displayName,children:e.displayName}),(0,O.jsx)(A,{source:e.source})]},`${e.code}::${e.name}`))})]}),d&&(0,O.jsxs)(`div`,{className:`mt-1 text-xs text-bambu-gray`,children:[E(`inventory.selectedPreset`),`: `,(0,O.jsx)(`span`,{className:`font-mono text-bambu-green`,children:d.code})]}),T?.slicer_filament&&(0,O.jsx)(`p`,{className:`mt-1 text-xs text-red-700 dark:text-red-400`,children:T.slicer_filament})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[E(`inventory.material`),` *`]}),(0,O.jsxs)(`div`,{className:`relative`,ref:oe,children:[(0,O.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,O.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,O.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,O.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:E(`inventory.noResults`)}):(0,O.jsxs)(O.Fragment,{children:[Q.top.length>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(N,{label:E(`inventory.suggestedOptions`)}),Q.top.map(de)]}),Q.rest.length>0&&(0,O.jsxs)(O.Fragment,{children:[Q.top.length>0&&(0,O.jsx)(N,{label:E(`inventory.allOptions`)}),Q.rest.map(de)]})]}),W&&!X.includes(W)&&(0,O.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,O.jsx)(`p`,{className:`mt-1 text-xs text-red-700 dark:text-red-400`,children:T.material})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[E(`inventory.brand`),x&&` *`]}),(0,O.jsxs)(`div`,{className:`relative`,ref:J,children:[(0,O.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:P?B:e.brand,onChange:e=>{V(e.target.value),F(!0)},onFocus:()=>{F(!0),V(``)}}),(0,O.jsx)(i,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),P&&(0,O.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,O.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:E(`inventory.noResults`)}):(0,O.jsxs)(O.Fragment,{children:[Z.top.length>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(N,{label:E(`inventory.suggestedOptions`)}),Z.top.map(ue)]}),Z.rest.length>0&&(0,O.jsxs)(O.Fragment,{children:[Z.top.length>0&&(0,O.jsx)(N,{label:E(`inventory.allOptions`)}),Z.rest.map(ue)]})]}),B&&!Y.includes(B)&&(0,O.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,O.jsx)(`p`,{className:`mt-1 text-xs text-red-700 dark:text-red-400`,children:T.brand})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[E(`inventory.subtype`),x&&` *`]}),(0,O.jsxs)(`div`,{className:`relative`,ref:ae,children:[(0,O.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,O.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,O.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,O.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:E(`inventory.noResults`)}):ce.map(t=>(0,O.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&&!b.some(e=>e.toLowerCase()===H.toLowerCase().trim())&&(0,O.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,O.jsx)(`p`,{className:`mt-1 text-xs text-red-700 dark:text-red-400`,children:T.subtype})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:E(`inventory.labelWeight`)}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.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,O.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray`,children:`g`})]})]}),y&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:E(`inventory.quantity`)}),(0,O.jsx)(g,{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:C,min:1,max:100,onChange:w,fallback:1})]})]})}function F(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:t,recentColors:n,onColorUsed:o,catalogColors:s}){let{t:c}=r(),[l,f]=(0,D.useState)(!1),[h,g]=(0,D.useState)(``),b=(e.rgba.replace(`#`,``)+`FF`).substring(0,8).toUpperCase(),S=b.substring(0,6),w=b.substring(6,8)===`00`,[T,E]=(0,D.useState)(w?b:S);(0,D.useEffect)(()=>{E(w?b:S)},[S,b,w]);let k=e=>b===(e.replace(`#`,``)+`FF`).substring(0,8).toUpperCase(),A=e=>v(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,D.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,D.useMemo)(()=>{if(!h)return M;if(M.length===0)return[];let e=h.toLowerCase();return M.filter(t=>t.name.toLowerCase().includes(e)||(t.manufacturer?.toLowerCase().includes(e)??!1)||(t.material?.toLowerCase().includes(e)??!1))},[h,M]),P=M.length>0,I=(0,D.useMemo)(()=>h?x.filter(e=>e.name.toLowerCase().includes(h.toLowerCase())):l?x:C,[h,l]),[L,R]=(0,D.useState)(e.extra_colors),[z,B]=(0,D.useState)([]),V=(0,D.useRef)(e.extra_colors);(0,D.useEffect)(()=>{e.extra_colors!==V.current&&(R(e.extra_colors),B([]),V.current=e.extra_colors)},[e.extra_colors]);let H=(0,D.useMemo)(()=>p({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}=F(e);B(r),V.current=n,t(`extra_colors`,n)};return(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsx)(`div`,{className:`h-10 rounded-lg border border-bambu-dark-tertiary`,style:H,"data-testid":`color-preview-banner`}),n.length>0&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-bambu-gray shrink-0`,children:[(0,O.jsx)(_,{className:`w-3 h-3`}),(0,O.jsx)(`span`,{children:c(`inventory.recentColors`)})]}),(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:n.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>j(e.hex,e.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 ${k(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,O.jsxs)(`div`,{className:`relative`,children:[(0,O.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,O.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:h,onChange:e=>g(e.target.value)})]}),P?(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:h?c(`inventory.searchResults`):`${e.brand}${e.material?` ${e.material}`:``}`}),(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[N.map(e=>(0,O.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 ${k(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,O.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,O.jsx)(`p`,{className:`text-sm text-bambu-gray py-1`,children:c(`inventory.noColorsFound`)})]})]}):(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-bambu-gray`,children:[(0,O.jsx)(`span`,{children:c(h?`inventory.searchResults`:l?`inventory.allColors`:`inventory.commonColors`)}),!h&&(0,O.jsx)(`button`,{type:`button`,onClick:()=>f(!l),className:`flex items-center gap-1 hover:text-white transition-colors`,children:l?(0,O.jsxs)(O.Fragment,{children:[c(`inventory.showLess`),` `,(0,O.jsx)(a,{className:`w-3 h-3`})]}):(0,O.jsxs)(O.Fragment,{children:[c(`inventory.showAll`),` `,(0,O.jsx)(i,{className:`w-3 h-3`})]})})]}),(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[I.map(e=>(0,O.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 ${k(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,O.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)),I.length===0&&(0,O.jsx)(`p`,{className:`text-sm text-bambu-gray py-1`,children:c(`inventory.noColorsFound`)})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:c(`inventory.colorName`)}),(0,O.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,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:c(`inventory.hexColor`)}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray`,children:`#`}),(0,O.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,O.jsx)(`input`,{type:`color`,className:`w-11 h-[38px] rounded-lg cursor-pointer border border-bambu-dark-tertiary shrink-0 bg-transparent`,value:`#${S}`,onChange:e=>{t(`rgba`,e.target.value.replace(`#`,``).toUpperCase()+`FF`)},title:c(`inventory.pickColor`)})]})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 pt-2 border-t border-bambu-dark-tertiary/50`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:c(`inventory.extraColorsLabel`)}),(0,O.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,O.jsx)(`p`,{className:`text-xs text-red-700 dark:text-red-400 mt-1`,children:c(`inventory.extraColorsInvalid`,{tokens:z.join(`, `)})}),!z.length&&(0,O.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-1`,children:c(`inventory.extraColorsHint`)})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1 flex items-center gap-1.5`,children:[(0,O.jsx)(d,{className:`w-3.5 h-3.5`}),c(`inventory.colorEffectLabel`)]}),(0,O.jsxs)(`div`,{className:`flex gap-2 items-stretch`,children:[(0,O.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:m.map(e=>(0,O.jsx)(`option`,{value:e.value,children:c(e.labelKey)},e.value||`none`))}),(0,O.jsx)(y,{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:t,onChange:n,catalogId:i,onCatalogIdChange:a}){let{t:o}=r(),[s,c]=(0,D.useState)(!1),[u,d]=(0,D.useState)(``),f=(0,D.useRef)(null),p=(0,D.useRef)(null);(0,D.useEffect)(()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&c(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,D.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,D.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,D.useMemo)(()=>e.filter(e=>e.weight===t),[e,t]),g=(0,D.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,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:(0,O.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(l,{className:`w-3.5 h-3.5 text-bambu-gray`}),o(`inventory.coreWeight`)]})}),(0,O.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,O.jsxs)(`div`,{className:`flex-1 min-w-0 relative`,ref:f,children:[(0,O.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,O.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,O.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:o(`inventory.noResults`)}):m.map(e=>(0,O.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,O.jsx)(`span`,{className:`truncate`,children:e.name}),(0,O.jsxs)(`span`,{className:`font-mono text-xs text-bambu-gray ml-2 shrink-0`,children:[e.weight,`g`]})]},e.id))})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,O.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,O.jsx)(`span`,{className:`text-bambu-gray text-sm`,children:`g`})]})]})]})}function R({formData:e,updateField:t,spoolCatalog:n,currencySymbol:i,availableCategories:a,availableMaterialNumbers:s,availableLocations:c=[],onCreateLocation:l,globalLowStockThreshold:u,spoolmanMode:d=!1}){let{t:f}=r(),{showToast:p}=o(),[m,h]=(0,D.useState)(``),[g,_]=(0,D.useState)(!1),[v,y]=(0,D.useState)(``),[b,x]=(0,D.useState)(!1),[S,C]=(0,D.useState)(``),[w,T]=(0,D.useState)(!1),E=Math.max(0,e.label_weight-e.weight_used),k=e.core_weight+E;return(0,D.useEffect)(()=>{g||h(String(k))},[g,k]),(0,D.useEffect)(()=>{b||y(String(E))},[b,E]),(0,O.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-4`,children:[(0,O.jsx)(`div`,{className:`sm:col-span-2`,children:(0,O.jsx)(L,{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,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:f(`inventory.currentWeight`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.jsx)(`input`,{type:`number`,value:v,min:0,max:e.label_weight,onFocus:()=>x(!0),onChange:e=>{y(e.target.value)},onBlur:()=>{x(!1);let n=v.trim(),r=Number(n);if(!n||!Number.isFinite(r)||r<0||r>e.label_weight){y(String(E));return}let i=Math.round(r);t(`weight_used`,Math.max(0,e.label_weight-i)),y(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,O.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray`,children:`g`})]}),(0,O.jsxs)(`span`,{className:`text-xs text-bambu-gray shrink-0`,children:[`/ `,e.label_weight,`g`]})]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:f(`inventory.measuredWeight`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.jsx)(`input`,{type:`number`,value:m,min:0,onFocus:()=>_(!0),onChange:e=>{h(e.target.value)},onBlur:()=>{_(!1);let n=m.trim(),r=Number(n),i=e.core_weight,a=e.core_weight+e.label_weight;if(!n||!Number.isFinite(r)||r<i||r>a){p(f(`inventory.measuredWeightError`,{min:i,max:a}),`error`),h(String(k));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)),h(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,O.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray`,children:`g`})]}),(0,O.jsxs)(`span`,{className:`text-xs text-bambu-gray shrink-0`,children:[`/ `,e.core_weight+e.label_weight,`g`]})]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:f(`inventory.costPerKg`,`Cost per kg`)}),(0,O.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none`,children:i}),(0,O.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,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-material-number`,children:f(`inventory.materialNumber`)}),(0,O.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:f(`inventory.materialNumberPlaceholder`),value:e.material_number,maxLength:64,onChange:e=>t(`material_number`,e.target.value)}),s.length>0&&(0,O.jsx)(`datalist`,{id:`spool-material-number-options`,children:s.map(e=>(0,O.jsx)(`option`,{value:e},e))}),(0,O.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:f(`inventory.materialNumberHelp`)})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-category`,children:f(`inventory.category`)}),(0,O.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:f(`inventory.categoryPlaceholder`),value:e.category,maxLength:50,onChange:e=>t(`category`,e.target.value)}),a.length>0&&(0,O.jsx)(`datalist`,{id:`spool-category-options`,children:a.map(e=>(0,O.jsx)(`option`,{value:e},e))})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-low-stock-threshold`,children:f(`inventory.lowStockThresholdOverride`)}),(0,O.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.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,O.jsx)(`span`,{className:`absolute right-3 top-1/2 -translate-y-1/2 text-xs text-bambu-gray pointer-events-none`,children:`%`})]})}),(0,O.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:f(`inventory.lowStockThresholdOverrideHelp`,{global:u})})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-storage-location`,children:f(`inventory.storageLocation`)}),(0,O.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,O.jsx)(`option`,{value:``,children:f(`inventory.storageLocationNone`)}),c.map(e=>(0,O.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),l&&(0,O.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,O.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:f(`locations.createPlaceholder`),value:S,onChange:e=>C(e.target.value)}),(0,O.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:!S.trim()||w,onClick:async()=>{let e=S.trim();if(!(!e||!l)){T(!0);try{let n=await l(e);n&&(t(`location_id`,n.id),C(``))}finally{T(!1)}}},children:f(`locations.addShort`)})]})]}),(0,O.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,O.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:f(`inventory.note`)}),(0,O.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:f(`inventory.notePlaceholder`),value:e.note,onChange:e=>t(`note`,e.target.value)})]})]})}export{T as a,j as i,I as n,w as o,P as r,E as s,R as t};
|