From 664fc86e3f2c68ef6d7ff3532e69460aa0f99927 Mon Sep 17 00:00:00 2001 From: maziggy Date: Fri, 20 Mar 2026 11:18:28 +0100 Subject: [PATCH] [Fix] File rename preserves extension in File Manager (#751) Renaming a file in the File Manager included the extension in the editable text, letting users accidentally strip it and break the file. The rename modal now separates the base name from the extension (.3mf, .gcode, .gcode.3mf), showing the extension as a non-editable gray suffix and re-appending it on save. --- CHANGELOG.md | 1 + frontend/src/pages/FileManagerPage.tsx | 34 ++++++++++++------- .../{index-HM8c6qA1.js => index-Ceor3BCc.js} | 4 +-- ...{index-DS0IE7o1.css => index-hPK_4Ftq.css} | 2 +- static/index.html | 4 +-- 5 files changed, 28 insertions(+), 17 deletions(-) rename static/assets/{index-HM8c6qA1.js => index-Ceor3BCc.js} (98%) rename static/assets/{index-DS0IE7o1.css => index-hPK_4Ftq.css} (67%) diff --git a/CHANGELOG.md b/CHANGELOG.md index ced90b599..66808802b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ All notable changes to Bambuddy will be documented in this file. - **UserEmailPreference Model Not Registered** — The `UserEmailPreference` SQLAlchemy model was not imported in `models/__init__.py`, causing mapper initialization failures when the `User` model's relationship resolved the string reference before the model class was registered with Base metadata. - **Native Install Missing CAP_NET_BIND_SERVICE** — The `install.sh` systemd service template was missing `AmbientCapabilities=CAP_NET_BIND_SERVICE`, causing Virtual Printer proxy mode to silently fail to bind privileged ports (322, 990) on native installations. - **Virtual Printer Proxy A1 Diagnostics** ([#757](https://github.com/maziggy/bambuddy/issues/757)) — Added diagnostic port probing (ports 21, 80, 443) on proxy VP bind IPs to detect if BambuStudio tries to connect on ports the proxy doesn't handle. Logs a warning when an unexpected connection is detected. Helps diagnose A1/A1 Mini proxy issues where the slicer may use a different connection flow. +- **File Rename Removes Extension** ([#751](https://github.com/maziggy/bambuddy/issues/751)) — Renaming a file in the File Manager included the file extension in the editable text, so users could accidentally remove it (e.g. renaming `bracket.gcode.3mf` to `bracket`), making the file unprintable. The rename modal now only lets users edit the base name, with the extension shown as a non-editable suffix. Reported by @fleishmaab, confirmed by @cadtoolbox. ### Added - **Quick Print Speed Control** ([#256](https://github.com/maziggy/bambuddy/issues/256)) — Added a print speed control badge to the printer card controls row, next to the fan status badges. Click to choose between Silent (50%), Standard (100%), Sport (124%), and Ludicrous (166%) speed presets. The badge shows the current speed percentage with a gauge icon, always visible but disabled when no print is active. Includes optimistic UI updates for instant feedback. Requested by @Sllepper. diff --git a/frontend/src/pages/FileManagerPage.tsx b/frontend/src/pages/FileManagerPage.tsx index 91677642a..50df0abc2 100644 --- a/frontend/src/pages/FileManagerPage.tsx +++ b/frontend/src/pages/FileManagerPage.tsx @@ -126,12 +126,17 @@ interface RenameModalProps { } function RenameModal({ type, currentName, onClose, onSave, isLoading, t }: RenameModalProps) { - const [name, setName] = useState(currentName); + // For files, separate the extension so users can only edit the base name + // Handle compound extensions like .gcode.3mf + const fileExtension = type === 'file' ? (currentName.match(/(\.gcode\.3mf|\.3mf|\.gcode)$/i)?.[1] ?? '') : ''; + const baseName = type === 'file' && fileExtension ? currentName.slice(0, -fileExtension.length) : currentName; + const [name, setName] = useState(baseName); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); - if (name.trim() && name.trim() !== currentName) { - onSave(name.trim()); + const fullName = type === 'file' ? name.trim() + fileExtension : name.trim(); + if (name.trim() && fullName !== currentName) { + onSave(fullName); } }; @@ -146,20 +151,25 @@ function RenameModal({ type, currentName, onClose, onSave, isLoading, t }: Renam - setName(e.target.value)} - className="w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green" - autoFocus - required - /> +
+ setName(e.target.value)} + className="flex-1 bg-transparent px-3 py-2 text-white placeholder-bambu-gray focus:outline-none min-w-0" + autoFocus + required + /> + {fileExtension && ( + {fileExtension} + )} +
-
diff --git a/static/assets/index-HM8c6qA1.js b/static/assets/index-Ceor3BCc.js similarity index 98% rename from static/assets/index-HM8c6qA1.js rename to static/assets/index-Ceor3BCc.js index 6286778c9..1fe2291bf 100644 --- a/static/assets/index-HM8c6qA1.js +++ b/static/assets/index-Ceor3BCc.js @@ -8699,7 +8699,7 @@ Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Is(t. ${u&&ie?"sm:border-bambu-dark-tertiary border-bambu-green/40":""} ${!u&&!W?"border-bambu-dark-tertiary hover:border-bambu-dark-tertiary/80":""} ${ie?"sm:cursor-default":""} - `,onClick:ie?()=>{window.innerWidth<640&&d()}:void 0,children:[ie&&u&&i.jsx("div",{className:"sm:hidden absolute left-0 top-3 bottom-3 w-1 rounded-full bg-bambu-green"}),i.jsxs("div",{className:"flex items-start sm:items-center gap-2 sm:gap-4 p-3 sm:p-4",children:[I&&d&&i.jsx("button",{onClick:Q=>{Q.stopPropagation(),d()},className:`hidden sm:flex items-center justify-center w-6 h-6 rounded border transition-colors shrink-0 ${u?"bg-bambu-green border-bambu-green text-white":"border-white/30 bg-black/30 hover:border-bambu-green/50"}`,children:u&&i.jsx(Qr,{className:"w-4 h-4"})}),I?i.jsx("div",{...P,...k,className:"hidden sm:flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation shrink-0",children:i.jsx(Sh,{className:"w-4 h-4 text-bambu-gray"})}):e!==void 0?i.jsxs("div",{className:"hidden sm:flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium shrink-0",children:["#",e]}):i.jsx("div",{className:"hidden sm:block w-8 shrink-0"}),i.jsx("div",{className:"w-10 h-10 sm:w-14 sm:h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?i.jsx("img",{src:t.plate_id!=null?fe.getArchivePlateThumbnail(t.archive_id,t.plate_id):fe.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?i.jsx("img",{src:t.plate_id!=null?fe.getLibraryFilePlateThumbnail(t.library_file_id,t.plate_id):fe.getLibraryFileThumbnailUrl(t.library_file_id),alt:"",className:"w-full h-full object-cover"}):i.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:i.jsx(Vi,{className:"w-5 h-5 sm:w-6 sm:h-6"})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsxs("p",{className:"text-sm sm:text-base text-white font-medium truncate",children:[t.archive_name||t.library_file_name||`File #${t.archive_id||t.library_file_id}`,(N?.is_multi_plate??!1)&&t.plate_id!==void 0&&t.plate_id!==null&&` • ${T.find(Q=>Q.index===t.plate_id)?.name||y("queue.plateNumber",{index:t.plate_id})}`]}),t.archive_id?i.jsx(co,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:y("queue.viewArchive"),children:i.jsx(ti,{className:"w-3.5 h-3.5"})}):t.library_file_id?i.jsx(co,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:y("queue.viewInFileManager"),children:i.jsx(ti,{className:"w-3.5 h-3.5"})}):null]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs sm:text-sm text-bambu-gray",children:[i.jsxs("span",{className:`flex items-center gap-1 sm:gap-1.5 ${t.printer_id===null&&!t.target_model?"text-orange-400":""} ${t.target_model?"text-blue-400":""}`,children:[i.jsx(_r,{className:"w-3 h-3 sm:w-3.5 sm:h-3.5"}),i.jsx("span",{className:"truncate max-w-[120px] sm:max-w-none",children:t.target_model?`${y("queue.filter.any")} ${t.target_model}${t.target_location?` @ ${t.target_location}`:""}${t.required_filament_types?.length?` (${t.required_filament_types.join(", ")})`:""}`:t.printer_id===null?y("queue.filter.unassigned"):t.printer_name||`${y("common.printer")} #${t.printer_id}`})]}),t.print_time_seconds&&i.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[i.jsx(yd,{className:"w-3 h-3 sm:w-3.5 sm:h-3.5"}),Is(t.print_time_seconds)]}),t.filament_used_grams&&i.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[i.jsx(tQ,{className:"w-3 h-3 sm:w-3.5 sm:h-3.5"}),Foe(t.filament_used_grams)]}),t.created_by_username&&i.jsxs("span",{className:"hidden sm:flex items-center gap-1.5",title:y("queue.addedBy",{name:t.created_by_username}),children:[i.jsx(zd,{className:"w-3.5 h-3.5"}),t.created_by_username]}),I&&!t.manual_start&&i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx(Jn,{className:"w-3.5 h-3.5"}),t.scheduled_time?(Zn(t.scheduled_time)?.getTime()??0)-Date.now()<-6e4?y?.("queue.time.overdue")??"Overdue":w0(t.scheduled_time,c,y):y?.("queue.time.asap")??"ASAP"]})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 sm:gap-2 mt-1.5 sm:mt-2",children:[t.manual_start&&i.jsxs("span",{className:"text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded-full border border-purple-500/20 flex items-center gap-1",children:[i.jsx(GX,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3"}),y("queue.badges.staged")]}),t.require_previous_success&&i.jsx("span",{className:"text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20",children:y("queue.badges.requiresPrevious")}),t.auto_off_after&&i.jsxs("span",{className:"text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1",children:[i.jsx(Xd,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3"}),y("queue.badges.autoPowerOff")]})]}),W&&v&&i.jsxs("div",{className:"mt-2 sm:mt-3",children:[i.jsxs("div",{className:"flex items-center justify-between text-xs sm:text-sm",children:[i.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5 sm:h-2 mr-3",children:i.jsx("div",{className:"bg-bambu-green h-1.5 sm:h-2 rounded-full transition-all",style:{width:`${v.progress||0}%`}})}),i.jsxs("span",{className:"text-white",children:[Math.round(v.progress||0),"%"]})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mt-1.5 sm:mt-2 text-[10px] sm:text-xs text-bambu-gray",children:[v.remaining_time!=null&&v.remaining_time>0&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Jn,{className:"w-3 h-3"}),Is(v.remaining_time*60)]}),i.jsxs("span",{className:"text-bambu-green font-medium",title:y("printers.estimatedCompletion"),children:["ETA ",XL(v.remaining_time,c,y)]})]}),v.layer_num!=null&&v.total_layers!=null&&v.total_layers>0&&i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Vi,{className:"w-3 h-3"}),v.layer_num,"/",v.total_layers]})]})]}),t.waiting_reason&&t.status==="pending"&&i.jsxs("p",{className:"text-[10px] sm:text-xs text-purple-400 mt-1.5 sm:mt-2 flex items-start gap-1",children:[i.jsx(Li,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),i.jsx("span",{children:t.waiting_reason})]}),t.error_message&&i.jsxs("p",{className:"text-[10px] sm:text-xs text-red-400 mt-1.5 sm:mt-2 flex items-center gap-1",children:[i.jsx(Li,{className:"w-3 h-3"}),t.error_message]})]}),i.jsxs("div",{className:"flex flex-col sm:flex-row items-end sm:items-center gap-2 sm:gap-1 shrink-0",onClick:Q=>Q.stopPropagation(),children:[i.jsx(HJe,{status:t.status,waitingReason:t.waiting_reason,printerState:f,t:y}),i.jsxs("div",{className:"flex items-center gap-0.5 sm:gap-1",children:[W&&i.jsx(Ie,{variant:"ghost",size:"sm",onClick:s,disabled:!m("printers:control"),title:m("printers:control")?y("queue.actions.stopPrint"):y("queue.permissions.noStopPrint"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 p-1.5 sm:p-2",children:i.jsx(Jhe,{className:"w-4 h-4"})}),I&&i.jsxs(i.Fragment,{children:[t.manual_start&&i.jsx(Ie,{variant:"ghost",size:"sm",onClick:l,disabled:!m("printers:control"),title:m("printers:control")?y("queue.actions.startPrint"):y("queue.permissions.noStartPrint"),className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10 p-1.5 sm:p-2",children:i.jsx(wo,{className:"w-4 h-4"})}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:n,disabled:!p("queue","update",t.created_by_id),title:p("queue","update",t.created_by_id)?y("common.edit"):y("queue.permissions.noEdit"),className:"p-1.5 sm:p-2",children:i.jsx(Ki,{className:"w-4 h-4"})}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:r,disabled:!p("queue","delete",t.created_by_id),title:p("queue","delete",t.created_by_id)?y("common.cancel"):y("queue.permissions.noCancel"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 p-1.5 sm:p-2",children:i.jsx(Ht,{className:"w-4 h-4"})})]}),J&&i.jsxs(i.Fragment,{children:[i.jsx(Ie,{variant:"ghost",size:"sm",onClick:o,disabled:!m("queue:create"),title:m("queue:create")?y("queue.actions.requeue"):y("queue.permissions.noRequeue"),className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10 p-1.5 sm:p-2",children:i.jsx(Sr,{className:"w-4 h-4"})}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:a,disabled:!p("queue","delete",t.created_by_id),title:p("queue","delete",t.created_by_id)?y("common.remove"):y("queue.permissions.noRemove"),className:"p-1.5 sm:p-2",children:i.jsx(en,{className:"w-4 h-4"})})]})]})]})]})]})}function qJe(){const{t}=Rt(),e=sn(),{showToast:n}=fn(),{hasPermission:r,hasAnyPermission:a,canModify:s}=Nr(),[o,l]=w.useState(null),[c,u]=w.useState(""),[d,m]=w.useState(""),[p,f]=w.useState(!1),[y,v]=w.useState(null),[b,g]=w.useState(null),[_,N]=w.useState(null),[T,C]=w.useState([]),[P,k]=w.useState(!1),[R,A]=w.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[D,B]=w.useState(()=>{const L=localStorage.getItem("queue.historySortAsc");return L!==null?L==="true":!1}),[z,W]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[I,J]=w.useState(()=>{const L=localStorage.getItem("queue.pendingSortAsc");return L!==null?L==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",R)},[R]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(D))},[D]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",z)},[z]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(I))},[I]);const ie=uoe(qC(EA,{activationConstraint:{distance:8}}),qC(MA,{coordinateGetter:Doe})),{data:Q}=tt({queryKey:["settings"],queryFn:fe.getSettings}),ue=Q?.time_format||"system",{data:me,isLoading:pe}=tt({queryKey:["queue",o,c],queryFn:()=>fe.getQueue(o||void 0,c||void 0),refetchInterval:5e3}),{data:Y}=tt({queryKey:["printers"],queryFn:()=>fe.getPrinters()}),se=ft({mutationFn:L=>fe.cancelQueueItem(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.cancelled"))},onError:()=>n(t("queue.toast.cancelFailed"),"error")}),oe=ft({mutationFn:L=>fe.removeFromQueue(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.removed"))},onError:()=>n(t("queue.toast.removeFailed"),"error")}),be=ft({mutationFn:L=>fe.stopQueueItem(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.stopped"))},onError:()=>n(t("queue.toast.stopFailed"),"error")}),Me=ft({mutationFn:L=>fe.startQueueItem(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.released"))},onError:()=>n(t("queue.toast.startFailed"),"error")}),q=ft({mutationFn:L=>fe.reorderQueue(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]})},onError:()=>n(t("queue.toast.reorderFailed"),"error")}),Z=ft({mutationFn:async()=>{const L=me?.filter(F=>["completed","failed","skipped","cancelled"].includes(F.status))||[];for(const F of L)await fe.removeFromQueue(F.id);return L.length},onSuccess:L=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.historyCleared",{count:L}))},onError:()=>n(t("queue.toast.clearHistoryFailed"),"error")}),j=ft({mutationFn:L=>fe.bulkUpdateQueue(L),onSuccess:L=>{e.invalidateQueries({queryKey:["queue"]}),C([]),k(!1),n(L.message)},onError:()=>n(t("queue.toast.updateFailed"),"error")}),E=ft({mutationFn:async L=>{for(const F of L)await fe.cancelQueueItem(F);return L.length},onSuccess:L=>{e.invalidateQueries({queryKey:["queue"]}),C([]),n(t("queue.toast.bulkCancelled",{count:L}))},onError:()=>n(t("queue.toast.bulkCancelFailed"),"error")}),U=L=>{C(F=>F.includes(L)?F.filter(te=>te!==L):[...F,L])},K=w.useMemo(()=>{const L=new Set;return Y?.forEach(F=>{F.location&&L.add(F.location)}),me?.forEach(F=>{F.target_location&&L.add(F.target_location)}),Array.from(L).sort()},[Y,me]),$=w.useCallback(L=>d?L.target_location?L.target_location===d:L.printer_id?Y?.find(te=>te.id===L.printer_id)?.location===d:!1:!0,[d,Y]),ne=w.useMemo(()=>{let L=me?.filter(te=>te.status==="pending")||[];d&&(L=L.filter($));const F=te=>{if(!te.scheduled_time)return 0;const ve=Zn(te.scheduled_time)?.getTime()??0,he=Date.now()+4320*60*60*1e3;return ve>he?0:ve};return[...L].sort((te,ve)=>{let he;if(z==="name"){const de=te.archive_name||te.library_file_name||"",ke=ve.archive_name||ve.library_file_name||"";he=de.localeCompare(ke)}else z==="printer"?he=(te.printer_name||"").localeCompare(ve.printer_name||""):z==="time"?he=F(te)-F(ve):he=te.position-ve.position;return I?he:-he})},[me,z,I,$,d]),O=()=>{const L=ne.map(F=>F.id);T.length===L.length?C([]):C(L)},V=w.useMemo(()=>{let L=me?.filter(F=>F.status==="printing")||[];return d&&(L=L.filter($)),L},[me,d,$]),ee=w.useMemo(()=>{const L=new Set;return V.forEach(F=>{F.printer_id&&L.add(F.printer_id)}),Array.from(L)},[V]),G=Yf({queries:ee.map(L=>({queryKey:["printerStatus",L],queryFn:()=>fe.getPrinterStatus(L),refetchInterval:5e3}))}),re=w.useMemo(()=>{const L={};return ee.forEach((F,te)=>{const ve=G[te];ve?.data?.state&&(L[F]=ve.data.state)}),L},[ee,G]),ce=w.useMemo(()=>{let L=me?.filter(F=>["completed","failed","skipped","cancelled"].includes(F.status))||[];return d&&(L=L.filter($)),[...L].sort((F,te)=>{let ve;if(R==="name"){const he=F.archive_name||F.library_file_name||"",de=te.archive_name||te.library_file_name||"";ve=he.localeCompare(de)}else R==="printer"?ve=(F.printer_name||"").localeCompare(te.printer_name||""):ve=(Zn(te.completed_at||te.created_at)?.getTime()??0)-(Zn(F.completed_at||F.created_at)?.getTime()??0);return D?-ve:ve})},[me,R,D,$,d]),ge=w.useMemo(()=>ne.reduce((L,F)=>L+(F.print_time_seconds||0),0),[ne]),xe=w.useMemo(()=>ne.reduce((L,F)=>L+(F.filament_used_grams||0),0),[ne]),ae=L=>{const{active:F,over:te}=L;if(!te||F.id===te.id)return;const ve=ne.findIndex(de=>de.id===F.id),he=ne.findIndex(de=>de.id===te.id);if(ve!==-1&&he!==-1){const ke=RA(ne,ve,he).map((_e,Le)=>({id:_e.id,position:Le+1}));q.mutate(ke)}};return i.jsxs("div",{className:"p-4 md:p-8",children:[i.jsx("div",{className:"flex items-center justify-between mb-8",children:i.jsxs("div",{children:[i.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[i.jsx(WX,{className:"w-7 h-7 text-bambu-green"}),t("queue.title")]}),i.jsx("p",{className:"text-bambu-gray mt-1",children:t("queue.subtitle")})]})}),i.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-2 sm:gap-3 lg:gap-4 mb-8",children:[i.jsx(Pt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:i.jsx(Et,{className:"p-3 sm:p-4",children:i.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[i.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-blue-500/20 flex items-center justify-center shrink-0",children:i.jsx(wo,{className:"w-4 h-4 sm:w-5 sm:h-5 text-blue-400"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:V.length}),i.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.printing")})]})]})})}),i.jsx(Pt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:i.jsx(Et,{className:"p-3 sm:p-4",children:i.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[i.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center shrink-0",children:i.jsx(Jn,{className:"w-4 h-4 sm:w-5 sm:h-5 text-yellow-400"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:ne.length}),i.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.queued")})]})]})})}),i.jsx(Pt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:i.jsx(Et,{className:"p-3 sm:p-4",children:i.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[i.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center shrink-0",children:i.jsx(yd,{className:"w-4 h-4 sm:w-5 sm:h-5 text-bambu-green"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:Is(ge)}),i.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.totalTime")})]})]})})}),i.jsx(Pt,{className:"bg-gradient-to-br from-purple-500/10 to-transparent border-purple-500/20",children:i.jsx(Et,{className:"p-3 sm:p-4",children:i.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[i.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-purple-500/20 flex items-center justify-center shrink-0",children:i.jsx(tQ,{className:"w-4 h-4 sm:w-5 sm:h-5 text-purple-500"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:Foe(xe)}),i.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.totalWeight")})]})]})})}),i.jsx(Pt,{className:"col-span-2 sm:col-span-1 bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:i.jsx(Et,{className:"p-3 sm:p-4",children:i.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[i.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-gray-500/20 flex items-center justify-center shrink-0",children:i.jsx(fr,{className:"w-4 h-4 sm:w-5 sm:h-5 text-gray-400"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:ce.length}),i.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.history")})]})]})})})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-4 mb-6",children:[i.jsxs("select",{className:"px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none",value:o===-1?"unassigned":o||"",onChange:L=>{const F=L.target.value;l(F==="unassigned"?-1:F===""?null:Number(F))},children:[i.jsx("option",{value:"",children:t("queue.filter.allPrinters")}),i.jsx("option",{value:"unassigned",children:t("queue.filter.unassigned")}),Y?.map(L=>i.jsx("option",{value:L.id,children:L.name},L.id))]}),i.jsxs("select",{className:"px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none",value:c,onChange:L=>u(L.target.value),children:[i.jsx("option",{value:"",children:t("queue.filter.allStatus")}),i.jsx("option",{value:"pending",children:t("queue.status.pending")}),i.jsx("option",{value:"printing",children:t("queue.status.printing")}),i.jsx("option",{value:"completed",children:t("queue.status.completed")}),i.jsx("option",{value:"failed",children:t("queue.status.failed")}),i.jsx("option",{value:"skipped",children:t("queue.status.skipped")}),i.jsx("option",{value:"cancelled",children:t("queue.status.cancelled")})]}),K.length>0&&i.jsxs("select",{className:"px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none",value:d,onChange:L=>m(L.target.value),children:[i.jsx("option",{value:"",children:t("queue.filter.allLocations")}),K.map(L=>i.jsx("option",{value:L,children:L},L))]}),i.jsx("div",{className:"hidden sm:block flex-1"}),ce.length>0&&i.jsxs(Ie,{className:"w-full sm:w-auto",variant:"secondary",size:"sm",onClick:()=>f(!0),disabled:!r("queue:delete_all"),title:r("queue:delete_all")?void 0:t("queue.permissions.noClearHistory"),children:[i.jsx(en,{className:"w-4 h-4"}),t("queue.clearHistory")]})]}),pe?i.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):me?.length===0?i.jsxs(Pt,{className:"p-12 text-center border-dashed",children:[i.jsx(Yr,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),i.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:t("queue.empty.title")}),i.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:t("queue.empty.description")})]}):i.jsxs("div",{className:"space-y-6 sm:space-y-8",children:[V.length>0&&i.jsxs("div",{children:[i.jsxs("h2",{className:"text-base sm:text-lg font-semibold text-white mb-3 sm:mb-4 flex items-center gap-2",children:[i.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),t("queue.sections.currentlyPrinting")]}),i.jsx("div",{className:"space-y-2 sm:space-y-3",children:V.map(L=>i.jsx(ID,{item:L,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>N({type:"stop",item:L}),onRequeue:()=>{},onStart:()=>{},timeFormat:ue,hasPermission:r,canModify:s,printerState:L.printer_id?re[L.printer_id]:null,t},L.id))})]}),ne.length>0&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3 sm:mb-4",children:[i.jsxs("h2",{className:"text-base sm:text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(Jn,{className:"w-4 h-4 sm:w-5 sm:h-5 text-yellow-400"}),t("queue.sections.queued"),i.jsxs("span",{className:"text-xs sm:text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:ne.length}),")"]}),i.jsx("span",{className:"hidden sm:inline text-xs text-bambu-gray ml-2",title:t("queue.reorderHint"),children:t("queue.dragToReorder")})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("select",{className:"px-2 sm:px-3 py-1.5 text-xs sm:text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:z,onChange:L=>W(L.target.value),children:[i.jsx("option",{value:"position",children:t("queue.sort.byPosition")}),i.jsx("option",{value:"name",children:t("queue.sort.byName")}),i.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")}),i.jsx("option",{value:"time",children:t("queue.sort.bySchedule")})]}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>J(!I),title:t(I?"common.ascending":"common.descending"),className:"px-2",children:I?i.jsx(Sf,{className:"w-4 h-4"}):i.jsx(rx,{className:"w-4 h-4"})})]})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mb-3 sm:mb-4 p-2 sm:p-3 bg-bambu-dark rounded-lg",children:[i.jsxs(Ie,{variant:"ghost",size:"sm",onClick:O,className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm",children:[T.length===ne.length&&ne.length>0?i.jsx(_o,{className:"w-4 h-4 text-bambu-green"}):i.jsx(ql,{className:"w-4 h-4"}),T.length===ne.length&&ne.length>0?t("queue.bulkEdit.deselectAll"):t("queue.bulkEdit.selectAll")]}),T.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-xs sm:text-sm text-bambu-gray",children:t("queue.bulkEdit.selected",{count:T.length})}),i.jsx("div",{className:"hidden sm:block h-4 w-px bg-bambu-dark-tertiary"}),i.jsxs(Ie,{variant:"ghost",size:"sm",onClick:()=>k(!0),className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm text-bambu-green hover:text-bambu-green-light",disabled:!a("queue:update_own","queue:update_all"),title:a("queue:update_own","queue:update_all")?t("queue.bulkEdit.editSelected"):t("queue.permissions.noEditItems"),children:[i.jsx(Ki,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("queue.bulkEdit.editSelected")})]}),i.jsxs(Ie,{variant:"ghost",size:"sm",onClick:()=>E.mutate(T),className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm text-red-400 hover:text-red-300",disabled:E.isPending||!a("queue:delete_own","queue:delete_all"),title:a("queue:delete_own","queue:delete_all")?t("queue.bulkEdit.cancelSelected"):t("queue.permissions.noCancelItems"),children:[i.jsx(Ht,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("queue.bulkEdit.cancelSelected")})]})]})]}),i.jsx(Toe,{sensors:ie,collisionDetection:poe,onDragEnd:ae,children:i.jsx(Moe,{items:ne.map(L=>L.id),strategy:EJe,children:i.jsx("div",{className:"space-y-2 sm:space-y-3",children:ne.map((L,F)=>i.jsx(ID,{item:L,position:F+1,onEdit:()=>v(L),onCancel:()=>N({type:"cancel",item:L}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>Me.mutate(L.id),timeFormat:ue,isSelected:T.includes(L.id),onToggleSelect:()=>U(L.id),hasPermission:r,canModify:s,t},L.id))})})})]}),ce.length>0&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3 sm:mb-4",children:[i.jsxs("h2",{className:"text-base sm:text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(fr,{className:"w-4 h-4 sm:w-5 sm:h-5 text-bambu-gray"}),t("queue.sections.history"),i.jsxs("span",{className:"text-xs sm:text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:ce.length}),")"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("select",{className:"px-2 sm:px-3 py-1.5 text-xs sm:text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:R,onChange:L=>A(L.target.value),children:[i.jsx("option",{value:"date",children:t("queue.sort.byDate")}),i.jsx("option",{value:"name",children:t("queue.sort.byName")}),i.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")})]}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>B(!D),title:t(D?"queue.sort.ascendingOldest":"queue.sort.descendingNewest"),className:"px-2",children:D?i.jsx(Sf,{className:"w-4 h-4"}):i.jsx(rx,{className:"w-4 h-4"})})]})]}),i.jsx("div",{className:"space-y-2 sm:space-y-3",children:ce.slice(0,20).map((L,F)=>i.jsx(ID,{item:L,position:F+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>N({type:"remove",item:L}),onStop:()=>{},onRequeue:()=>g(L),onStart:()=>{},timeFormat:ue,hasPermission:r,canModify:s,t},L.id))})]})]}),y&&i.jsx(bu,{mode:"edit-queue-item",archiveId:y.archive_id??void 0,libraryFileId:y.library_file_id??void 0,archiveName:y.archive_name||y.library_file_name||`File #${y.archive_id||y.library_file_id}`,queueItem:y,onClose:()=>v(null)}),b&&i.jsx(bu,{mode:"add-to-queue",archiveId:b.archive_id??void 0,libraryFileId:b.library_file_id??void 0,archiveName:b.archive_name||b.library_file_name||`File #${b.archive_id||b.library_file_id}`,onClose:()=>g(null)}),_&&i.jsx(_n,{title:_.type==="cancel"?t("queue.confirm.cancelTitle"):_.type==="stop"?t("queue.confirm.stopTitle"):t("queue.confirm.removeTitle"),message:_.type==="cancel"?t("queue.confirm.cancelMessage",{name:_.item.archive_name||_.item.library_file_name||t("queue.confirm.thisPrint")}):_.type==="stop"?t("queue.confirm.stopMessage",{name:_.item.archive_name||_.item.library_file_name||t("queue.confirm.thisPrint")}):t("queue.confirm.removeMessage",{name:_.item.archive_name||_.item.library_file_name||t("queue.confirm.thisItem")}),confirmText:_.type==="cancel"?t("queue.confirm.cancelButton"):_.type==="stop"?t("queue.confirm.stopButton"):t("common.remove"),variant:"danger",onConfirm:()=>{_.type==="cancel"?se.mutate(_.item.id):_.type==="stop"?be.mutate(_.item.id):oe.mutate(_.item.id),N(null)},onCancel:()=>N(null)}),p&&i.jsx(_n,{title:t("queue.confirm.clearHistoryTitle"),message:t("queue.confirm.clearHistoryMessage",{count:ce.length}),confirmText:t("queue.clearHistory"),variant:"danger",onConfirm:()=>{Z.mutate(),f(!1)},onCancel:()=>f(!1)}),P&&i.jsx($Je,{selectedCount:T.length,printers:Y?.map(L=>({id:L.id,name:L.name}))||[],onSave:L=>{Object.keys(L).length>0&&j.mutate({item_ids:T,...L})},onClose:()=>k(!1),isSaving:j.isPending,canControlPrinter:r("printers:control"),t})]})}function VJe({printDates:t,months:e=3}){const n=w.useRef(null),[r,a]=w.useState(0);w.useEffect(()=>{const _=n.current;if(!_)return;const N=new ResizeObserver(T=>{const C=T[0]?.contentRect.width||0;a(C)});return N.observe(_),()=>N.disconnect()},[]);const{weeks:s,monthLabels:o,printCounts:l}=w.useMemo(()=>{const _={};t.forEach(B=>{const z=B.split("T")[0];_[z]=(_[z]||0)+1});const N=new Date,T=new Date(N);T.setMonth(T.getMonth()-e),T.setDate(T.getDate()-T.getDay());const C=[],P=[];let k=[],R=-1;const A=new Date(T);let D=0;for(;A<=N;)A.getDay()===0&&k.length>0&&(C.push(k),k=[],D++),A.getMonth()!==R&&(P.push({month:A.toLocaleDateString("en-US",{month:"short"}),weekIndex:D}),R=A.getMonth()),k.push(new Date(A)),A.setDate(A.getDate()+1);return k.length>0&&C.push(k),{weeks:C,monthLabels:P,printCounts:_}},[t,e]),c=Math.max(1,...Object.values(l)),u=_=>{if(_===0)return"bg-bambu-dark";const N=_/c;return N<=.25?"bg-bambu-green/30":N<=.5?"bg-bambu-green/50":N<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],m=s.length,p=32,f=2,y=r-p-16,v=m>0?Math.floor((y-(m-1)*f)/m):12,b=Math.max(8,Math.min(20,v)),g=b<=10?10:12;return i.jsx("div",{ref:n,className:"w-full flex justify-center",children:r>0&&i.jsxs("div",{children:[i.jsx("div",{className:"flex mb-1",style:{marginLeft:p+4},children:o.map(({month:_,weekIndex:N},T)=>i.jsx("div",{className:"text-bambu-gray",style:{fontSize:g,marginLeft:T===0?0:`${(N-(o[T-1]?.weekIndex||0))*(b+f)-24}px`},children:_},T))}),i.jsxs("div",{className:"flex",style:{gap:f},children:[i.jsx("div",{className:"flex flex-col",style:{gap:f,marginRight:4,width:p},children:d.map((_,N)=>i.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:p,height:b,fontSize:g,visibility:N%2===1?"visible":"hidden"},children:_},_))}),s.map((_,N)=>i.jsx("div",{className:"flex flex-col",style:{gap:f},children:[0,1,2,3,4,5,6].map(T=>{const C=_.find(A=>A.getDay()===T);if(!C)return i.jsx("div",{style:{width:b,height:b}},T);const P=C.toISOString().split("T")[0],k=l[P]||0,R=P===new Date().toISOString().split("T")[0];return i.jsx("div",{className:`rounded-sm ${u(k)} ${R?"ring-1 ring-white":""}`,style:{width:b,height:b},title:`${C.toLocaleDateString()}: ${k} print${k!==1?"s":""}`},T)})},N))]}),i.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:g},children:[i.jsx("span",{children:"Less"}),i.jsxs("div",{className:"flex",style:{gap:f},children:[i.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:b,height:b}}),i.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:b,height:b}}),i.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:b,height:b}}),i.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:b,height:b}}),i.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:b,height:b}})]}),i.jsx("span",{children:"More"})]})]})})}const _Y=["weight","prints","time"];function WC({value:t,onChange:e,exclude:n}){const{t:r}=Rt(),a={weight:r("stats.filamentByWeight"),prints:r("stats.filamentByPrints"),time:r("stats.filamentByTime")},s=n?_Y.filter(o=>!n.includes(o)):_Y;return i.jsx("div",{className:"flex gap-0.5 bg-bambu-dark rounded-lg p-0.5",children:s.map(o=>i.jsx("button",{onClick:()=>e(o),className:`px-2 py-0.5 text-xs rounded-md transition-colors ${t===o?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:a[o]},o))})}function sh(t){if(t>=1e6){const e=t/1e6;return`${e%1===0?e.toFixed(0):e.toFixed(1)}t`}if(t>=1e3){const e=t/1e3;return`${e%1===0?e.toFixed(0):e.toFixed(1)}kg`}return`${Math.round(t)}g`}const V1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"],GJe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],NY=["12am","1am","2am","3am","4am","5am","6am","7am","8am","9am","10am","11am","12pm","1pm","2pm","3pm","4pm","5pm","6pm","7pm","8pm","9pm","10pm","11pm"];function WJe({archives:t,currency:e="$",dateFrom:n,dateTo:r}){const{t:a}=Rt(),[s,o]=w.useState("weight"),[l,c]=w.useState("weight"),u=w.useMemo(()=>{const R=new Map;return t.forEach(A=>{const D=Zn(A.completed_at||A.created_at)||new Date,B=`${D.getFullYear()}-${String(D.getMonth()+1).padStart(2,"0")}-${String(D.getDate()).padStart(2,"0")}`,z=R.get(B)||{date:B,filament:0,cost:0,prints:0};z.filament+=A.filament_used_grams||0,z.cost+=A.cost||0,z.prints+=A.quantity||1,R.set(B,z)}),Array.from(R.values()).sort((A,D)=>A.date.localeCompare(D.date)).map(A=>({...A,dateLabel:new Date(A.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[t]),d=w.useMemo(()=>{if(n&&r)return Math.max((new Date(r).getTime()-new Date(n).getTime())/864e5,0)+1;if(n)return Math.max((Date.now()-new Date(n).getTime())/864e5,0)+1;if(t.length<2)return 0;const R=t.map(A=>new Date(A.completed_at||A.created_at).getTime());return(Math.max(...R)-Math.min(...R))/864e5},[t,n,r]),m=w.useMemo(()=>{if(d>7)return[];const R=new Map,A=d>1;return t.forEach(D=>{const B=Zn(D.completed_at||D.created_at)||new Date,z=B.getHours(),W=`${B.getFullYear()}-${String(B.getMonth()+1).padStart(2,"0")}-${String(B.getDate()).padStart(2,"0")}T${String(z).padStart(2,"0")}`,I=R.get(W)||{date:W,filament:0,cost:0,prints:0};I.filament+=D.filament_used_grams||0,I.cost+=D.cost||0,I.prints+=D.quantity||1,R.set(W,I)}),Array.from(R.values()).sort((D,B)=>D.date.localeCompare(B.date)).map(D=>{const[B,z]=D.date.split("T"),W=new Date(B),I=parseInt(z,10),J=A?`${GJe[W.getDay()]} ${NY[I]}`:NY[I];return{...D,dateLabel:J}})},[t,d]),p=w.useMemo(()=>{if(u.length<=60)return u;const R=new Map;return u.forEach(A=>{const D=new Date(A.date),B=new Date(D);B.setDate(D.getDate()-D.getDay());const z=`${B.getFullYear()}-${String(B.getMonth()+1).padStart(2,"0")}-${String(B.getDate()).padStart(2,"0")}`,W=R.get(z)||{week:z,filament:0,cost:0,prints:0};W.filament+=A.filament,W.cost+=A.cost,W.prints+=A.prints,R.set(z,W)}),Array.from(R.values()).sort((A,D)=>A.week.localeCompare(D.week)).map(A=>({date:A.week,dateLabel:`Week of ${new Date(A.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...A}))},[u]),f=w.useMemo(()=>{const R=new Map;return t.forEach(A=>{const B=(A.filament_type||"Unknown").split(", ");B.forEach(z=>{const W=(A.filament_used_grams||0)/B.length;R.set(z,(R.get(z)||0)+W)})}),Array.from(R.entries()).map(([A,D])=>({name:A,value:Math.round(D)})).sort((A,D)=>D.value-A.value)},[t]),y=w.useMemo(()=>{const R=new Map;return t.forEach(A=>{(A.filament_type||"Unknown").split(", ").forEach(z=>{R.set(z,(R.get(z)||0)+1)})}),Array.from(R.entries()).map(([A,D])=>({name:A,value:D})).sort((A,D)=>D.value-A.value)},[t]),v=w.useMemo(()=>{const R=new Map;return t.forEach(A=>{const B=(A.filament_type||"Unknown").split(", "),z=(A.actual_time_seconds||A.print_time_seconds||0)/B.length;B.forEach(W=>{R.set(W,(R.get(W)||0)+z)})}),Array.from(R.entries()).map(([A,D])=>({name:A,value:Math.round(D/3600*10)/10})).sort((A,D)=>D.value-A.value)},[t]),b=w.useMemo(()=>{const R=new Map;return t.forEach(A=>{if(A.status!=="completed"&&A.status!=="failed")return;(A.filament_type||"Unknown").split(", ").forEach(B=>{const z=R.get(B)||{completed:0,failed:0};A.status==="completed"?z.completed++:z.failed++,R.set(B,z)})}),Array.from(R.entries()).filter(([,A])=>A.completed+A.failed>=2).map(([A,D])=>{const B=D.completed+D.failed,z=Math.round(D.completed/B*100);return{name:A,rate:z,total:B}}).sort((A,D)=>D.rate-A.rate)},[t]),g=w.useMemo(()=>{const R=new Map;return t.forEach(A=>{if(!A.filament_color)return;const D=A.filament_color.split(",").map(z=>z.trim()),B=(A.filament_used_grams||0)/D.length;D.forEach(z=>{const W=R.get(z)||{count:0,weight:0};W.count++,W.weight+=B,R.set(z,W)})}),Array.from(R.entries()).map(([A,D])=>({hex:A,value:l==="prints"?D.count:Math.round(D.weight)})).sort((A,D)=>D.value-A.value)},[t,l]),_=s==="weight"?f:s==="prints"?y:v,N=d<=7&&m.length>0?m:p,T=t.reduce((R,A)=>R+(A.filament_used_grams||0),0),C=t.reduce((R,A)=>R+(A.cost||0),0),P=t.reduce((R,A)=>R+(A.quantity||1),0),k=new Set(t.map(R=>R.printer_id).filter(Boolean)).size;return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-3 gap-2 max-[640px]:grid-cols-1",children:[i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:a("stats.periodFilament")}),i.jsx("p",{className:"text-2xl font-bold text-white leading-none",children:sh(T)})]}),i.jsxs("p",{className:"text-xs text-bambu-gray",children:[k," ",a("nav.printers").toLowerCase()]})]}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:a("stats.periodCost")}),i.jsxs("p",{className:"text-2xl font-bold text-white leading-none",children:[e,C.toFixed(2)]})]}),i.jsxs("p",{className:"text-xs text-bambu-gray",children:[P," ",a("common.prints")]})]}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:a("stats.avgPerPrint")}),i.jsxs("p",{className:"text-2xl font-bold text-white leading-none",children:[P>0?(T/P).toFixed(0):0,"g"]})]}),i.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,P>0?(C/P).toFixed(2):"0.00"," avg"]})]})]}),N.length>0?i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:a("stats.usageOverTime")}),i.jsx(mh,{width:"100%",height:250,children:i.jsxs(Cqe,{data:N,children:[i.jsx("defs",{children:i.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[i.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),i.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),i.jsx(Qp,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),i.jsx(Zp,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),i.jsx(Jp,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:R=>`${R}g`}),i.jsx(hh,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:R=>[`${Number(R??0).toFixed(0)}g`,"Filament"]}),i.jsx(Are,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):i.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:a("stats.noPrintDataInRange")}),i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h4",{className:"text-sm font-medium text-bambu-gray",children:a("stats.byMaterial")}),i.jsx(WC,{value:s,onChange:o})]}),_.length>0?i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(mh,{width:160,height:160,children:i.jsxs(aW,{children:[i.jsx(SF,{data:_,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:_.map((R,A)=>i.jsx(Nx,{fill:V1[A%V1.length]},`cell-${A}`))}),i.jsx(hh,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:R=>[s==="weight"?sh(Number(R??0)):s==="time"?`${Number(R??0)}h`:`${R??0}`,s==="weight"?"Usage":s==="time"?"Time":"Prints"]})]})}),i.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:_.map((R,A)=>{const D=_.reduce((z,W)=>z+W.value,0),B=D>0?(R.value/D*100).toFixed(0):0;return i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:V1[A%V1.length]}}),i.jsx("span",{className:"text-white truncate flex-1",children:R.name}),i.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[s==="weight"?sh(R.value):s==="time"?`${R.value}h`:R.value," · ",B,"%"]})]},R.name)})})]}):i.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:a("stats.noFilamentData")})]}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:a("stats.filamentSuccess")}),b.length>0?i.jsx("div",{className:"space-y-1.5",children:b.map(R=>i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx("span",{className:"text-white truncate w-20 flex-shrink-0",children:R.name}),i.jsx("div",{className:"flex-1 h-1.5 bg-bambu-dark-secondary rounded-full",children:i.jsx("div",{className:`h-full rounded-full transition-all ${R.rate>=90?"bg-status-ok":R.rate>=70?"bg-status-warning":"bg-status-error"}`,style:{width:`${R.rate}%`}})}),i.jsxs("span",{className:`font-medium flex-shrink-0 tabular-nums ${R.rate>=90?"text-status-ok":R.rate>=70?"text-status-warning":"text-status-error"}`,children:[R.rate,"%"]}),i.jsxs("span",{className:"text-bambu-gray flex-shrink-0 text-xs",children:["(",R.total,")"]})]},R.name))}):i.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:a("stats.noArchiveData")})]}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h4",{className:"text-sm font-medium text-bambu-gray",children:a("stats.colorDistribution")}),i.jsx(WC,{value:l,onChange:c,exclude:["time"]})]}),g.length>0?(()=>{const R=g.reduce((A,D)=>A+D.value,0);return i.jsxs("div",{children:[i.jsxs("div",{className:"relative mx-auto",style:{width:160,height:160},children:[i.jsx(mh,{width:"100%",height:"100%",children:i.jsxs(aW,{children:[i.jsx(SF,{data:g,cx:"50%",cy:"50%",innerRadius:45,outerRadius:70,paddingAngle:2,dataKey:"value",children:g.map((A,D)=>i.jsx(Nx,{fill:A.hex,stroke:"#1a1a1a",strokeWidth:1},`color-${D}`))}),i.jsx(hh,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:A=>[l==="weight"?sh(Number(A??0)):`${A??0}`,a(l==="weight"?"stats.filamentByWeight":"stats.filamentByPrints")]})]})}),i.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[i.jsx("span",{className:"text-lg font-bold text-white",children:l==="weight"?sh(R):R}),i.jsxs("span",{className:"text-[10px] text-bambu-gray",children:[g.length," ",g.length===1?"color":"colors"]})]})]}),i.jsx("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1 mt-2",children:g.slice(0,8).map(A=>{const D=R>0?(A.value/R*100).toFixed(0):0;return i.jsxs("div",{className:"flex items-center gap-1.5 text-xs min-w-0",children:[i.jsx("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0 border border-black/20",style:{backgroundColor:A.hex}}),i.jsxs("span",{className:"text-bambu-gray truncate",children:[D,"%"]})]},A.hex)})}),g.length>8&&i.jsxs("p",{className:"text-[10px] text-bambu-gray mt-1 text-center",children:["+",g.length-8," more"]})]})})():i.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:a("stats.noColorData")})]})]})]})}function KJe({id:t,title:e,component:n,isHidden:r,size:a,columnSpan:s,onToggleVisibility:o,onToggleSize:l}){const{attributes:c,listeners:u,setNodeRef:d,transform:m,transition:p,isDragging:f}=joe({id:t}),y={transform:jx.Transform.toString(m),transition:p,opacity:f?.5:1};return r?null:i.jsxs("div",{ref:d,style:{...y,gridColumn:`span ${s}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${f?"ring-2 ring-bambu-green shadow-lg":""}`,children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{...c,...u,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:i.jsx(Sh,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),i.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{onClick:l,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${a===1?"1/4":a===2?"1/2":"Full"} - Click to cycle`,children:a===4?i.jsx($L,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):i.jsx(tT,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),i.jsx("button",{onClick:o,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:i.jsx(fw,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),i.jsx("div",{className:"p-4",children:typeof n=="function"?n(a):n})]})}function YJe({widgets:t,storageKey:e,columns:n=4,stackBelow:r,hideControls:a=!1,onResetLayout:s,renderControls:o}){const l=()=>{const R={};return t.forEach(A=>{R[A.id]=A.defaultSize||4}),R},[c,u]=w.useState(()=>{const R=localStorage.getItem(e);if(R)try{const A=JSON.parse(R);if(!A.sizes)A.sizes=l();else{const D=l();for(const B in D)B in A.sizes||(A.sizes[B]=D[B])}return A}catch{}return{order:t.map(A=>A.id),hidden:t.filter(A=>A.defaultVisible===!1).map(A=>A.id),sizes:l()}}),[d,m]=w.useState(!1),[p,f]=w.useState(!1);w.useEffect(()=>{if(!r)return;const R=window.matchMedia(`(max-width: ${r}px)`),A=B=>{f(B.matches)};A(R);const D=B=>A(B);return R.addEventListener?R.addEventListener("change",D):R.addListener(D),()=>{R.removeEventListener?R.removeEventListener("change",D):R.removeListener(D)}},[r]);const y=r&&p?1:n;w.useEffect(()=>{const R=()=>m(A=>!A);return window.addEventListener("toggle-hidden-panel",R),()=>window.removeEventListener("toggle-hidden-panel",R)},[]),w.useEffect(()=>{localStorage.setItem(e,JSON.stringify(c))},[c,e]),w.useEffect(()=>{const A=t.map(D=>D.id).filter(D=>!c.order.includes(D));A.length>0&&u(D=>({...D,order:[...D.order,...A]}))},[t,c.order]);const v=uoe(qC(EA,{activationConstraint:{distance:8}}),qC(MA,{coordinateGetter:Doe})),b=R=>{const{active:A,over:D}=R;D&&A.id!==D.id&&u(B=>{const z=B.order.indexOf(A.id),W=B.order.indexOf(D.id);return{...B,order:RA(B.order,z,W)}})},g=R=>{u(A=>({...A,hidden:A.hidden.includes(R)?A.hidden.filter(D=>D!==R):[...A.hidden,R]}))},_=R=>{u(A=>{const D=A.sizes[R]||4,B=D===1?2:D===2?4:1;return{...A,sizes:{...A.sizes,[R]:B}}})},N=()=>{const R={order:t.map(A=>A.id),hidden:t.filter(A=>A.defaultVisible===!1).map(A=>A.id),sizes:l()};u(R),s?.()},T=c.order.map(R=>t.find(A=>A.id===R)).filter(Boolean),C=T.filter(R=>!c.hidden.includes(R.id)),P=T.filter(R=>c.hidden.includes(R.id)),k=o?.({hiddenCount:P.length,showHiddenPanel:d,setShowHiddenPanel:m,resetLayout:N});return i.jsxs("div",{className:"space-y-4",children:[k,!a&&!o&&i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:N,children:[i.jsx(So,{className:"w-4 h-4"}),"Reset Layout"]}),P.length>0&&i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>m(!d),children:[i.jsx(Ac,{className:"w-4 h-4"}),P.length," Hidden"]})]}),d&&P.length>0&&i.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[i.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:P.map(R=>i.jsxs("button",{onClick:()=>g(R.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[i.jsx(Ac,{className:"w-3 h-3"}),R.title]},R.id))})]}),i.jsx(Toe,{sensors:v,collisionDetection:poe,onDragEnd:b,children:i.jsx(Moe,{items:C.map(R=>R.id),strategy:k5,children:i.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${y}, minmax(0, 1fr))`},children:C.map(R=>{const A=c.sizes[R.id]||2,D=Math.min(A,y);return i.jsx(KJe,{id:R.id,title:R.title,component:R.component,isHidden:c.hidden.includes(R.id),size:A,columnSpan:D,onToggleVisibility:()=>g(R.id),onToggleSize:()=>_(R.id)},R.id)})})})}),C.length===0&&i.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[i.jsx("p",{children:"All widgets are hidden."}),i.jsx(Ie,{className:"mt-4",onClick:N,children:"Reset Layout"})]})]})}function XJe(t){const e=new Date,n=e.getUTCFullYear(),r=e.getUTCMonth(),a=e.getUTCDate(),s=l=>l.toISOString().split("T")[0],o=s(e);switch(t){case"today":return{dateFrom:o,dateTo:o};case"this-week":{const l=e.getUTCDay(),c=new Date(Date.UTC(n,r,a-(l===0?6:l-1)));return{dateFrom:s(c),dateTo:o}}case"this-month":return{dateFrom:s(new Date(Date.UTC(n,r,1))),dateTo:o};case"last-7":return{dateFrom:s(new Date(Date.UTC(n,r,a-6))),dateTo:o};case"last-30":return{dateFrom:s(new Date(Date.UTC(n,r,a-29))),dateTo:o};case"last-90":return{dateFrom:s(new Date(Date.UTC(n,r,a-89))),dateTo:o};case"this-year":return{dateFrom:s(new Date(Date.UTC(n,0,1))),dateTo:o};case"all-time":return{dateFrom:void 0,dateTo:void 0};case"custom":return{}}}const QJe=["today","this-week","this-month","last-7","last-30","last-90","this-year","all-time"],ZJe=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],yL=["12am","1am","2am","3am","4am","5am","6am","7am","8am","9am","10am","11am","12pm","1pm","2pm","3pm","4pm","5pm","6pm","7pm","8pm","9pm","10pm","11pm"],zD=[{key:"<30m",max:1800},{key:"30m-1h",max:3600},{key:"1-2h",max:7200},{key:"2-4h",max:14400},{key:"4-8h",max:28800},{key:"8-12h",max:43200},{key:"12-24h",max:86400},{key:"24h+",max:1/0}],G1={backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"};function JJe({stats:t,currency:e}){const{t:n}=Rt(),r=[{icon:Gi,color:"text-bambu-green",label:n("stats.totalPrints"),value:`${t?.total_prints||0}`},{icon:Jn,color:"text-blue-400",label:n("stats.printTime"),value:`${t?.total_print_time_hours?.toFixed(1)??"0"}h`},{icon:Gi,color:"text-orange-400",label:n("stats.filamentUsed"),value:sh(t?.total_filament_grams||0)},{icon:EN,color:"text-green-400",label:n("stats.filamentCost"),value:`${e} ${t?.total_cost?.toFixed(2)??"0.00"}`},{icon:Mc,color:"text-yellow-400",label:n("stats.energyUsed"),value:`${t?.total_energy_kwh?.toFixed(3)??"0.000"} kWh`},{icon:EN,color:"text-yellow-500",label:n("stats.energyCost"),value:`${e} ${t?.total_energy_cost?.toFixed(2)??"0.00"}`}];return i.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:r.map(a=>i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${a.color}`,children:i.jsx(a.icon,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-xs text-bambu-gray",children:a.label}),i.jsx("p",{className:"text-xl font-bold text-white",children:a.value})]})]},a.label))})}function eet({stats:t,printerMap:e,size:n=1}){const{t:r}=Rt(),a=(t?.successful_prints||0)+(t?.failed_prints||0),s=a?Math.round(t.successful_prints/a*100):0,o=n===1?112:n===2?128:144,l=o/2-8,c=l*2*Math.PI;return i.jsxs("div",{className:"flex items-center gap-6",children:[i.jsxs("div",{className:"relative flex-shrink-0",style:{width:o,height:o},children:[i.jsxs("svg",{className:"w-full h-full -rotate-90",children:[i.jsx("circle",{cx:o/2,cy:o/2,r:l,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),i.jsx("circle",{cx:o/2,cy:o/2,r:l,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${s/100*c} ${c}`})]}),i.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:i.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[s,"%"]})})]}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(fr,{className:"w-4 h-4 text-status-ok flex-shrink-0"}),i.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.successful")}),i.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(qi,{className:"w-4 h-4 text-status-error flex-shrink-0"}),i.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.failed")}),i.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]}),n>=2&&t?.prints_by_printer&&Object.keys(t.prints_by_printer).length>0&&i.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[i.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:r("stats.printsByPrinter")}),i.jsx("div",{className:`grid gap-x-6 gap-y-1 ${n===4?"grid-cols-3":"grid-cols-2"}`,style:{width:"fit-content"},children:Object.entries(t.prints_by_printer).map(([u,d])=>i.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[i.jsx("span",{className:"text-bambu-gray truncate max-w-[120px]",children:e.get(u)||`${r("common.printer")} ${u}`}),i.jsx("span",{className:"text-white font-medium",children:d})]},u))})]})]})]})}function tet({stats:t,printerMap:e,size:n=1}){const{t:r}=Rt(),a=t?.average_time_accuracy;if(a==null)return i.jsx("div",{className:"flex items-center justify-center h-full",children:i.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noTimeAccuracyData")})});const o=(Math.min(150,Math.max(50,a))-50)/100*100,c=(v=>v>=95&&v<=105?"#00ae42":v>105?"#3b82f6":"#f97316")(a),u=a-100,d=n===1?112:n===2?128:144,m=d/2-8,p=m*2*Math.PI,f=n===1?3:n===2?6:999,y=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,f):[];return i.jsxs("div",{className:"flex items-center gap-6",children:[i.jsxs("div",{className:"relative flex-shrink-0",style:{width:d,height:d},children:[i.jsxs("svg",{className:"w-full h-full -rotate-90",children:[i.jsx("circle",{cx:d/2,cy:d/2,r:m,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),i.jsx("circle",{cx:d/2,cy:d/2,r:m,fill:"none",stroke:c,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${o/100*p} ${p}`})]}),i.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[i.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[a.toFixed(0),"%"]}),i.jsxs("span",{className:`text-xs ${u>=0?"text-blue-400":"text-orange-400"}`,children:[u>=0?"+":"",u.toFixed(0),"%"]})]})]}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[i.jsx(JX,{className:"w-3 h-3 flex-shrink-0"}),i.jsx("span",{children:r("stats.perfectEstimate")})]}),y.length>0&&i.jsx("div",{className:`mt-2 ${n===4?"grid grid-cols-3 gap-x-6 gap-y-1":n===2?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,style:{width:"fit-content"},children:y.map(([v,b])=>i.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[i.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(v)||`${r("common.printer")} ${v}`}),i.jsxs("span",{className:`font-medium ${b>=95&&b<=105?"text-status-ok":b>105?"text-blue-400":"text-status-warning"}`,children:[b.toFixed(0),"%"]})]},v))})]})]})}function net({printDates:t,dateFrom:e,dateTo:n}){const{days:r,hourlyCounts:a,maxCount:s}=w.useMemo(()=>{const d=new Date(e+"T00:00:00"),m=new Date(n+"T00:00:00"),p=[],f=g=>`${g.getFullYear()}-${String(g.getMonth()+1).padStart(2,"0")}-${String(g.getDate()).padStart(2,"0")}`,y=new Date(d);for(;y<=m;)p.push({key:f(y),label:y.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"})}),y.setDate(y.getDate()+1);const v={};let b=0;return t.forEach(g=>{const _=Zn(g);if(!_)return;const T=`${`${_.getFullYear()}-${String(_.getMonth()+1).padStart(2,"0")}-${String(_.getDate()).padStart(2,"0")}`}-${_.getHours()}`;v[T]=(v[T]||0)+1,v[T]>b&&(b=v[T])}),{days:p,hourlyCounts:v,maxCount:Math.max(1,b)}},[t,e,n]),o=d=>{if(d===0)return"bg-bambu-dark";const m=d/s;return m<=.25?"bg-bambu-green/30":m<=.5?"bg-bambu-green/50":m<=.75?"bg-bambu-green/75":"bg-bambu-green"},l=20,c=2,u=80;return i.jsxs("div",{className:"w-full overflow-x-auto",children:[i.jsxs("div",{className:"inline-flex flex-col",style:{gap:c},children:[i.jsx("div",{className:"flex",style:{gap:c,marginLeft:u+4},children:yL.map((d,m)=>i.jsx("div",{className:"text-bambu-gray text-[10px] text-center",style:{width:l,visibility:m%2===0?"visible":"hidden"},children:d},m))}),r.map(d=>i.jsxs("div",{className:"flex items-center",style:{gap:c},children:[i.jsx("div",{className:"text-bambu-gray text-[10px] flex-shrink-0 truncate",style:{width:u},children:d.label}),Array.from({length:24},(m,p)=>{const f=a[`${d.key}-${p}`]||0;return i.jsx("div",{className:`rounded-sm ${o(f)}`,style:{width:l,height:l},title:`${d.label} ${yL[p]}: ${f} print${f!==1?"s":""}`},p)})]},d.key))]}),i.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray text-xs",children:[i.jsx("span",{children:"Less"}),i.jsxs("div",{className:"flex",style:{gap:c},children:[i.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:l,height:l}}),i.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:l,height:l}}),i.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:l,height:l}}),i.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:l,height:l}}),i.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:l,height:l}})]}),i.jsx("span",{children:"More"})]})]})}function ret({printDates:t,size:e=2,dateFrom:n,dateTo:r}){const a=w.useMemo(()=>n&&r?Math.max((new Date(r).getTime()-new Date(n).getTime())/864e5,0)+1:n?Math.max((Date.now()-new Date(n).getTime())/864e5,0)+1:1/0,[n,r]);if(a<=7&&n&&r)return i.jsx(net,{printDates:t,dateFrom:n,dateTo:r});const o=a===1/0?e===1?3:e===2?6:12:Math.max(1,Math.ceil(a/30));return i.jsx(VJe,{printDates:t,months:o})}function iet({stats:t,archives:e,printerMap:n}){const{t:r}=Rt(),[a,s]=w.useState("weight"),[o,l]=w.useState("weight"),c=w.useMemo(()=>{const g=new Map;return t?.prints_by_printer&&Object.entries(t.prints_by_printer).forEach(([_,N])=>{const T=g.get(_)||{prints:0,weight:0,time:0};T.prints=N,g.set(_,T)}),e.forEach(_=>{if(!_.printer_id)return;const N=String(_.printer_id),T=g.get(N)||{prints:0,weight:0,time:0};T.weight+=_.filament_used_grams||0,T.time+=_.actual_time_seconds||_.print_time_seconds||0,t?.prints_by_printer||T.prints++,g.set(N,T)}),Array.from(g.entries()).map(([_,N])=>({name:n.get(_)||`${r("common.printer")} ${_}`,value:a==="prints"?N.prints:a==="weight"?Math.round(N.weight):Math.round(N.time/3600*10)/10})).sort((_,N)=>N.value-_.value)},[t,e,n,a,r]),u=w.useMemo(()=>{const g=Array.from({length:24},(_,N)=>({hour:N,label:yL[N],total:0,failures:0}));return e.forEach(_=>{if(!_.started_at)return;const N=Zn(_.started_at);if(!N)return;const T=N.getHours();g[T].total++,_.status==="failed"&&g[T].failures++}),g},[e]),d=w.useMemo(()=>{const g=zD.map(_=>({name:_.key,count:0}));return e.forEach(_=>{const N=_.actual_time_seconds||_.print_time_seconds;if(!(!N||N<=0)){for(let T=0;T{const g=[0,0,0,0,0,0,0],_=new Set;e.forEach(T=>{const C=Zn(T.created_at)||new Date(T.created_at);let P=C.getDay()-1;P<0&&(P=6),o==="prints"?g[P]++:o==="weight"?g[P]+=T.filament_used_grams||0:g[P]+=(T.actual_time_seconds||T.print_time_seconds||0)/3600;const k=new Date(C);k.setDate(C.getDate()-(C.getDay()+6)%7),_.add(`${k.getFullYear()}-${String(k.getMonth()+1).padStart(2,"0")}-${String(k.getDate()).padStart(2,"0")}`)});const N=Math.max(_.size,1);return ZJe.map((T,C)=>({name:T,avg:Math.round(g[C]/N*10)/10}))},[e,o]),p=g=>({unit:g==="weight"?"g":g==="time"?"h":"",color:g==="weight"?"#00ae42":g==="time"?"#3b82f6":"#f59e0b"}),f=p(a),y=r(a==="weight"?"stats.filamentByWeight":a==="time"?"stats.hours":"common.prints"),v=p(o),b=r(o==="weight"?"stats.avgWeight":o==="time"?"stats.avgTime":"stats.avgPrints");return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h4",{className:"text-sm font-medium text-bambu-gray",children:r("stats.printsByPrinter")}),i.jsx(WC,{value:a,onChange:s})]}),c.length>0?i.jsx(mh,{width:"100%",height:Math.max(140,c.length*40),children:i.jsxs(C1,{data:c,layout:"vertical",margin:{left:10},children:[i.jsx(Qp,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),i.jsx(Zp,{type:"number",stroke:"#9ca3af",tick:{fontSize:11},unit:f.unit}),i.jsx(Jp,{type:"category",dataKey:"name",stroke:"#9ca3af",tick:{fontSize:11},width:100}),i.jsx(hh,{contentStyle:G1,formatter:g=>[a==="weight"?sh(Number(g??0)):`${g??0}${f.unit}`,y]}),i.jsx(Pb,{dataKey:"value",fill:f.color,radius:[0,4,4,0]})]})}):i.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noPrinterData")})]}),i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-3",children:r("stats.printDuration")}),e.length>0?i.jsx(mh,{width:"100%",height:160,children:i.jsxs(C1,{data:d,children:[i.jsx(Qp,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),i.jsx(Zp,{dataKey:"name",stroke:"#9ca3af",tick:{fontSize:11}}),i.jsx(Jp,{stroke:"#9ca3af",tick:{fontSize:11},allowDecimals:!1}),i.jsx(hh,{contentStyle:G1}),i.jsx(Pb,{dataKey:"count",name:r("common.prints"),fill:"#00ae42",radius:[4,4,0,0]})]})}):i.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noArchiveData")})]}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h4",{className:"text-sm font-medium text-bambu-gray",children:r("stats.printHabits")}),i.jsx(WC,{value:o,onChange:l})]}),e.length>0?i.jsx(mh,{width:"100%",height:160,children:i.jsxs(C1,{data:m,children:[i.jsx(Qp,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),i.jsx(Zp,{dataKey:"name",stroke:"#9ca3af",tick:{fontSize:11}}),i.jsx(Jp,{stroke:"#9ca3af",tick:{fontSize:11},unit:v.unit}),i.jsx(hh,{contentStyle:G1,formatter:g=>[`${g??0}${v.unit}`,b]}),i.jsx(Pb,{dataKey:"avg",fill:v.color,radius:[4,4,0,0]})]})}):i.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noArchiveData")})]}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-3",children:r("stats.printTimeOfDay")}),e.length>0?i.jsx(mh,{width:"100%",height:160,children:i.jsxs(C1,{data:u,children:[i.jsx(Qp,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),i.jsx(Zp,{dataKey:"label",stroke:"#9ca3af",tick:{fontSize:10},interval:5}),i.jsx(Jp,{stroke:"#9ca3af",tick:{fontSize:11},allowDecimals:!1}),i.jsx(hh,{contentStyle:G1}),i.jsx(Pb,{dataKey:"total",name:r("stats.totalPrints"),fill:"#00ae42",radius:[2,2,0,0]}),i.jsx(Pb,{dataKey:"failures",name:r("stats.failed"),fill:"#ef4444",radius:[2,2,0,0]})]})}):i.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noArchiveData")})]})]})]})}function aet({archives:t,currency:e,dateFrom:n,dateTo:r}){const{t:a}=Rt();return!t||t.length===0?i.jsx("p",{className:"text-bambu-gray text-center py-4",children:a("stats.noPrintData")}):i.jsx(WJe,{archives:t,currency:e,dateFrom:n,dateTo:r})}function set({size:t=1,dateFrom:e,dateTo:n}){const{t:r}=Rt(),a=!!(e||n),{data:s,isLoading:o}=tt({queryKey:["failureAnalysis",e,n],queryFn:()=>fe.getFailureAnalysis({...a?{dateFrom:e,dateTo:n}:{days:30}})});if(o)return i.jsx("div",{className:"flex justify-center py-4",children:i.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!s||s.total_prints===0)return i.jsx("p",{className:"text-bambu-gray text-center py-4",children:r(a?"stats.noPrintDataInRange":"stats.noPrintDataLast30Days")});const l=t===1?5:t===2?8:999,c=Object.entries(s.failures_by_reason).sort(([,m],[,p])=>p-m),u=c.slice(0,l),d=c.length>l;return i.jsxs("div",{className:`${t>=2?"flex gap-8":"space-y-4"}`,children:[i.jsxs("div",{className:t>=2?"flex-shrink-0":"",children:[i.jsx("div",{className:"flex items-center gap-4",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Mn,{className:`w-5 h-5 ${s.failure_rate>20?"text-status-error":s.failure_rate>10?"text-status-warning":"text-status-ok"}`}),i.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[s.failure_rate.toFixed(1),"%"]})]})}),i.jsx("div",{className:"text-sm text-bambu-gray mt-1",children:r("stats.failedPrintsCount",{failed:s.failed_prints,total:s.total_prints})}),s.trend&&s.trend.length>=2&&i.jsx("div",{className:`${t>=2?"mt-4":"mt-2 pt-2 border-t border-bambu-dark-tertiary"}`,children:i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx(GL,{className:`w-4 h-4 ${s.trend[s.trend.length-1].failure_rate0&&i.jsxs("div",{className:`flex-1 ${t>=2?"border-l border-bambu-dark-tertiary pl-8":"pt-2"}`,children:[i.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:t>=2?r("stats.failureReasons"):r("stats.topFailureReasons")}),i.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:u.map(([m,p])=>i.jsxs("div",{className:"flex items-center justify-between text-sm",children:[i.jsx("span",{className:`text-white truncate ${t===4?"max-w-[200px]":"max-w-[160px]"}`,children:m||r("common.unknown")}),i.jsx("span",{className:"text-bambu-gray ml-2",children:p})]},m))}),d&&i.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:r("common.more",{count:c.length-l})})]})]})}function oet({archives:t,currency:e}){const{t:n}=Rt(),r=w.useMemo(()=>{const a=[];if(t.length===0)return a;const s=y=>{let v=null,b=0;return t.forEach(g=>{const _=y(g);_&&_>b&&(b=_,v=g)}),{archive:v,value:b}},o=s(y=>y.actual_time_seconds);o.archive&&a.push({icon:Jn,iconColor:"text-blue-400",label:n("stats.longestPrint"),value:Is(o.value),detail:o.archive.print_name||null});const l=s(y=>y.filament_used_grams);l.archive&&a.push({icon:Gi,iconColor:"text-orange-400",label:n("stats.heaviestPrint"),value:sh(l.value),detail:l.archive.print_name||null});const c=s(y=>y.cost);c.archive&&a.push({icon:EN,iconColor:"text-green-400",label:n("stats.mostExpensivePrint"),value:`${e}${c.value.toFixed(2)}`,detail:c.archive.print_name||null});const u=new Map;t.forEach(y=>{const v=Zn(y.created_at)||new Date(y.created_at),b=`${v.getFullYear()}-${String(v.getMonth()+1).padStart(2,"0")}-${String(v.getDate()).padStart(2,"0")}`;u.set(b,(u.get(b)||0)+1)});let d="",m=0;u.forEach((y,v)=>{y>m&&(m=y,d=v)}),m>1&&a.push({icon:Yr,iconColor:"text-purple-400",label:n("stats.busiestDay"),value:`${m} ${n("common.prints")}`,detail:(()=>{const[y,v,b]=d.split("-").map(Number);return new Date(y,v-1,b).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})})()});const p=[...t].filter(y=>y.status==="completed"||y.status==="failed").sort((y,v)=>new Date(v.completed_at||v.created_at).getTime()-new Date(y.completed_at||y.created_at).getTime());let f=0;for(const y of p)if(y.status==="completed")f++;else break;return f>0&&a.push({icon:Mc,iconColor:"text-yellow-400",label:n("stats.successStreak"),value:`${f}`,detail:f===1?n("stats.streakPrint"):n("stats.streakPrints",{count:f})}),a},[t,e,n]);return r.length===0?i.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noArchiveData")}):i.jsx("div",{className:"space-y-3",children:r.map((a,s)=>i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`p-1.5 rounded-lg bg-bambu-dark ${a.iconColor}`,children:i.jsx(a.icon,{className:"w-4 h-4"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-xs text-bambu-gray",children:a.label}),i.jsxs("div",{className:"flex items-baseline gap-2",children:[i.jsx("span",{className:"text-sm font-bold text-white",children:a.value}),a.detail&&i.jsx("span",{className:"text-xs text-bambu-gray truncate",children:a.detail})]})]})]},s))})}function cet(){const{t}=Rt(),{showToast:e}=fn(),{hasPermission:n}=Nr(),[r,a]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(0),[u,d]=w.useState(0),[m,p]=w.useState(!1),[f,y]=w.useState(()=>{try{const J=localStorage.getItem("bambusy-stats-timeframe");if(J){const ie=JSON.parse(J);if(ie.preset)return ie}}catch{}return{preset:"all-time",dateFrom:void 0,dateTo:void 0}}),[v,b]=w.useState(!1);w.useEffect(()=>{localStorage.setItem("bambusy-stats-timeframe",JSON.stringify(f))},[f]);const g=w.useMemo(()=>f.preset==="custom"?{dateFrom:f.dateFrom,dateTo:f.dateTo}:XJe(f.preset),[f]);w.useEffect(()=>{const J=()=>{try{const Q=localStorage.getItem("bambusy-dashboard-layout-v2");if(Q){const ue=JSON.parse(Q);d(ue.hidden?.length||0)}}catch{d(0)}};J(),window.addEventListener("storage",J);const ie=setInterval(J,2e3);return()=>{window.removeEventListener("storage",J),clearInterval(ie)}},[l]);const{data:_,isLoading:N,refetch:T}=tt({queryKey:["archiveStats",g.dateFrom,g.dateTo],queryFn:()=>fe.getArchiveStats({dateFrom:g.dateFrom,dateTo:g.dateTo})}),{data:C}=tt({queryKey:["printers"],queryFn:fe.getPrinters}),{data:P,refetch:k}=tt({queryKey:["archivesSlim",g.dateFrom,g.dateTo],queryFn:()=>fe.getArchivesSlim(g.dateFrom,g.dateTo)}),{data:R}=tt({queryKey:["settings"],queryFn:fe.getSettings}),A=async J=>{o(!1),a(!0);try{const{blob:ie,filename:Q}=await fe.exportStats({format:J,days:90}),ue=URL.createObjectURL(ie),me=document.createElement("a");me.href=ue,me.download=Q,me.click(),URL.revokeObjectURL(ue),e(t("stats.exportDownloaded"))}catch{e(t("stats.exportFailed"),"error")}finally{a(!1)}},D=async()=>{p(!0);try{const J=await fe.recalculateCosts();await Promise.all([T(),k()]),e(t("stats.recalculatedCosts",{count:J.updated}))}catch{e(t("stats.recalculateFailed"),"error")}finally{p(!1)}},B=Go(R?.currency||"USD"),z=new Map(C?.map(J=>[String(J.id),J.name])||[]),W=w.useMemo(()=>P?.map(J=>J.created_at)||[],[P]);if(N)return i.jsx("div",{className:"p-4 md:p-8",children:i.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("stats.loadingStats")})});const I=[{id:"quick-stats",title:t("stats.quickStats"),component:i.jsx(JJe,{stats:_,currency:B}),defaultSize:2},{id:"success-rate",title:t("stats.successRate"),component:J=>i.jsx(eet,{stats:_,printerMap:z,size:J}),defaultSize:1},{id:"time-accuracy",title:t("stats.timeAccuracy"),component:J=>i.jsx(tet,{stats:_,printerMap:z,size:J}),defaultSize:1},{id:"failure-analysis",title:t("stats.failureAnalysis"),component:J=>i.jsx(set,{size:J,dateFrom:g.dateFrom,dateTo:g.dateTo}),defaultSize:1},{id:"print-activity",title:t("stats.printActivity"),component:J=>i.jsx(ret,{printDates:W,size:J,dateFrom:g.dateFrom,dateTo:g.dateTo}),defaultSize:2},{id:"records",title:t("stats.records"),component:i.jsx(oet,{archives:P||[],currency:B}),defaultSize:1},{id:"printer-stats",title:t("stats.printerStats"),component:i.jsx(iet,{stats:_,archives:P||[],printerMap:z}),defaultSize:4},{id:"filament-trends",title:t("stats.filamentTrends"),component:i.jsx(aet,{archives:P||[],currency:B,dateFrom:g.dateFrom,dateTo:g.dateTo}),defaultSize:4}];return i.jsxs("div",{className:"p-4 md:p-8",children:[i.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold text-white",children:t("stats.title")}),i.jsx("p",{className:"text-bambu-gray",children:t("stats.subtitle")})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[u>0&&i.jsxs(Ie,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[i.jsx(Ac,{className:"w-4 h-4"}),t("stats.hiddenCount",{count:u})]}),i.jsxs(Ie,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout-v2"),c(J=>J+1),e(t("stats.layoutReset"))},disabled:!n("settings:update"),title:n("settings:update")?void 0:t("stats.noPermissionResetLayout"),children:[i.jsx(So,{className:"w-4 h-4"}),t("stats.resetLayout")]}),i.jsxs(Ie,{variant:"secondary",onClick:D,disabled:m||!n("archives:update_all"),title:n("archives:update_all")?t("stats.recalculateCostsHint"):t("stats.noPermissionRecalculate"),children:[m?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(jhe,{className:"w-4 h-4"}),t("stats.recalculateCosts")]}),i.jsxs("div",{className:"relative",children:[i.jsxs(Ie,{variant:"secondary",onClick:()=>o(!s),disabled:r,children:[r?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(DN,{className:"w-4 h-4"}),t("stats.exportStats")]}),s&&i.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[i.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>A("csv"),children:[i.jsx(zs,{className:"w-4 h-4"}),t("stats.exportAsCsv")]}),i.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>A("xlsx"),children:[i.jsx(DN,{className:"w-4 h-4"}),t("stats.exportAsExcel")]})]})]}),i.jsxs("div",{className:"relative",children:[i.jsxs(Ie,{variant:"secondary",onClick:()=>b(!v),children:[i.jsx(Yr,{className:"w-4 h-4"}),t(`stats.timeframe.${f.preset}`),i.jsx(On,{className:"w-3 h-3"})]}),v&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>b(!1)}),i.jsxs("div",{className:"absolute right-0 top-full mt-1 w-64 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 p-2",children:[QJe.map(J=>i.jsx("button",{className:`w-full px-3 py-2 text-left text-sm rounded-md transition-colors ${f.preset===J?"bg-bambu-green text-white":"text-white hover:bg-bambu-dark-tertiary"}`,onClick:()=>{y({preset:J,dateFrom:void 0,dateTo:void 0}),b(!1)},children:t(`stats.timeframe.${J}`)},J)),i.jsx("div",{className:"border-t border-bambu-dark-tertiary my-2"}),i.jsx("button",{className:`w-full px-3 py-2 text-left text-sm rounded-md transition-colors ${f.preset==="custom"?"bg-bambu-green text-white":"text-white hover:bg-bambu-dark-tertiary"}`,onClick:()=>y(J=>({...J,preset:"custom"})),children:t("stats.timeframe.custom")}),f.preset==="custom"&&i.jsxs("div",{className:"mt-2 px-1 pb-1 space-y-2",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-bambu-gray block mb-1",children:t("stats.timeframe.from")}),i.jsx("input",{type:"date",value:f.dateFrom||"",max:f.dateTo||new Date().toISOString().split("T")[0],onChange:J=>y(ie=>({...ie,dateFrom:J.target.value||void 0})),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-sm text-white [color-scheme:dark]"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-bambu-gray block mb-1",children:t("stats.timeframe.to")}),i.jsx("input",{type:"date",value:f.dateTo||"",min:f.dateFrom,max:new Date().toISOString().split("T")[0],onChange:J=>y(ie=>({...ie,dateTo:J.target.value||void 0})),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-sm text-white [color-scheme:dark]"})]}),i.jsx(Ie,{variant:"primary",onClick:()=>b(!1),className:"w-full",children:t("common.apply")})]})]})]})]})]})]}),i.jsx(YJe,{widgets:I,storageKey:"bambusy-dashboard-layout-v2",stackBelow:640,hideControls:!0},l)]})}function uet({plug:t,onEdit:e}){const{t:n}=Rt(),r=sn(),{showToast:a}=fn(),[s,o]=w.useState(!1),[l,c]=w.useState(!1),[u,d]=w.useState(!1),[m,p]=w.useState(!1),{data:f,isLoading:y}=tt({queryKey:["smart-plug-status",t.id],queryFn:()=>fe.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:v}=tt({queryKey:["printers"],queryFn:fe.getPrinters}),b=v?.find(D=>D.id===t.printer_id),g=ft({mutationFn:D=>fe.controlSmartPlug(t.id,D),onMutate:async D=>{await r.cancelQueries({queryKey:["smart-plug-status",t.id]});const B=r.getQueryData(["smart-plug-status",t.id]),z=D==="on"?"ON":D==="off"||f?.state==="ON"?"OFF":"ON";return r.setQueryData(["smart-plug-status",t.id],W=>({...W,state:z})),{previousStatus:B}},onError:(D,B,z)=>{z?.previousStatus&&r.setQueryData(["smart-plug-status",t.id],z.previousStatus),a(n("smartPlugs.failedToTurn",{action:B,name:t.name}),"error")},onSettled:()=>{setTimeout(()=>{r.invalidateQueries({queryKey:["smart-plug-status",t.id]}),r.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),_=ft({mutationFn:D=>fe.updateSmartPlug(t.id,D),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&(r.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]}))}}),N=ft({mutationFn:()=>fe.deleteSmartPlug(t.id),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&r.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]})}}),T=f?.state==="ON",C=t.plug_type==="mqtt"&&f?.energy?.power!==null&&f?.energy?.power!==void 0,P=(f?.reachable??!1)||C,k=g.isPending,A=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const D=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${D}/`:`http://${D}/`})();return i.jsxs(i.Fragment,{children:[i.jsx(Pt,{className:"relative",children:i.jsxs(Et,{className:"p-4",children:[i.jsxs("div",{className:"flex items-start justify-between gap-2 mb-3",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[i.jsx("div",{className:`p-2 rounded-lg flex-shrink-0 ${t.plug_type==="mqtt"?P?"bg-teal-500/20":"bg-red-500/20":P?T?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="mqtt"?i.jsx(qL,{className:`w-5 h-5 ${P?"text-teal-400":"text-red-400"}`}):t.plug_type==="homeassistant"?i.jsx(bw,{className:`w-5 h-5 ${P?T?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):i.jsx(Il,{className:`w-5 h-5 ${P?T?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("h3",{className:"font-medium text-white truncate",children:t.name}),i.jsx("p",{className:"text-sm text-bambu-gray truncate",title:t.plug_type==="mqtt"?t.mqtt_topic??void 0:t.plug_type==="homeassistant"?t.ha_entity_id??void 0:t.ip_address??void 0,children:t.plug_type==="mqtt"?t.mqtt_topic:t.plug_type==="homeassistant"?t.ha_entity_id:t.ip_address})]})]}),i.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[y?i.jsx(pt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):t.plug_type==="mqtt"?i.jsxs("div",{className:"flex items-center gap-1.5 text-sm whitespace-nowrap",children:[i.jsx("span",{className:"px-1.5 py-0.5 bg-teal-500/20 text-teal-400 text-[10px] font-medium rounded flex-shrink-0",children:"MQTT"}),P&&i.jsx("span",{className:"text-status-ok",children:"✓"})]}):t.plug_type==="homeassistant"?i.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[i.jsx("span",{className:"px-1 py-0.5 bg-blue-500/20 text-blue-400 text-[10px] font-medium rounded",children:"HA"}),i.jsx("span",{className:P?T?"text-status-ok":"text-bambu-gray":"text-status-error",children:P?f?.state||"?":n("smartPlugs.offline")})]}):P?i.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[i.jsx(Hb,{className:"w-4 h-4 text-status-ok"}),i.jsx("span",{className:T?"text-status-ok":"text-bambu-gray",children:f?.state||n("smartPlugs.unknown")})]}):i.jsxs("div",{className:"flex items-center gap-1 text-sm text-status-error",children:[i.jsx(Rh,{className:"w-4 h-4"}),i.jsx("span",{children:n("smartPlugs.offline")})]}),A&&i.jsxs("a",{href:A,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2 py-0.5 bg-bambu-dark hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white text-xs rounded-full transition-colors",title:n("smartPlugs.openPlugAdminPage"),children:[i.jsx(ti,{className:"w-3 h-3"}),n("smartPlugs.admin")]})]})]}),b&&i.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[i.jsxs("span",{className:"text-xs text-bambu-gray",children:[n("smartPlugs.linkedTo")," "]}),i.jsx("span",{className:"text-sm text-white",children:b.name})]}),(t.power_alert_enabled||t.schedule_enabled||t.plug_type==="mqtt")&&i.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.plug_type==="mqtt"&&i.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded-full",children:[i.jsx(Ac,{className:"w-3 h-3"}),n("smartPlugs.monitorOnly")]}),t.power_alert_enabled&&i.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[i.jsx(xh,{className:"w-3 h-3"}),n("smartPlugs.alerts")]}),t.schedule_enabled&&i.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[i.jsx(Yr,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?n("smartPlugs.scheduleOn",{time:t.schedule_on_time}):n("smartPlugs.scheduleOff",{time:t.schedule_off_time})]})]}),t.plug_type!=="mqtt"&&i.jsxs("div",{className:"flex gap-2 mb-3",children:[i.jsxs(Ie,{size:"sm",variant:T?"primary":"secondary",disabled:!P||k,onClick:()=>c(!0),className:"flex-1",children:[k?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Xd,{className:"w-4 h-4"}),n("smartPlugs.on")]}),i.jsxs(Ie,{size:"sm",variant:T?"secondary":"primary",disabled:!P||k,onClick:()=>d(!0),className:"flex-1",children:[k?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(rT,{className:"w-4 h-4"}),n("smartPlugs.off")]})]}),t.plug_type==="mqtt"&&f?.energy&&i.jsxs("div",{className:"flex gap-2 mb-3 px-3 py-2 bg-bambu-dark rounded-lg",children:[f.energy.power!==null&&f.energy.power!==void 0&&i.jsxs("div",{className:"flex-1 text-center",children:[i.jsxs("p",{className:"text-lg font-semibold text-white",children:[Math.round(f.energy.power),"W"]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.power")})]}),f.energy.today!==null&&f.energy.today!==void 0&&i.jsxs("div",{className:"flex-1 text-center border-l border-bambu-dark-tertiary",children:[i.jsx("p",{className:"text-lg font-semibold text-white",children:f.energy.today.toFixed(3)}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.kwhToday")})]})]}),i.jsxs("button",{onClick:()=>p(!m),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(Od,{className:"w-4 h-4"}),t.plug_type==="mqtt"?n("smartPlugs.settings"):n("smartPlugs.automationSettings")]}),i.jsx("span",{children:m?"-":"+"})]}),m&&i.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(xw,{className:"w-4 h-4 text-bambu-green"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("smartPlugs.showInSwitchbar")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.quickAccessSidebar")})]})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:D=>_.mutate({show_in_switchbar:D.target.checked}),className:"sr-only peer"}),i.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.plug_type!=="mqtt"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("smartPlugs.enabled")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.enableAutomation")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:t.enabled,onChange:D=>_.mutate({enabled:D.target.checked}),className:"sr-only peer"}),i.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("smartPlugs.autoOn")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.autoOnDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:D=>_.mutate({auto_on:D.target.checked}),className:"sr-only peer"}),i.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("smartPlugs.autoOff")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.autoOffDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:D=>_.mutate({auto_off:D.target.checked}),className:"sr-only peer"}),i.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&i.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white mb-2",children:n("smartPlugs.turnOffDelayMode")}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("button",{onClick:()=>_.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[i.jsx(Jn,{className:"w-4 h-4"}),n("smartPlugs.time")]}),i.jsxs("button",{onClick:()=>_.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[i.jsx(sT,{className:"w-4 h-4"}),n("smartPlugs.temp")]})]})]}),t.off_delay_mode==="time"?i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:n("smartPlugs.delayMinutes")}),i.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:D=>_.mutate({off_delay_minutes:parseInt(D.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:n("smartPlugs.tempThreshold")}),i.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:D=>_.mutate({off_temp_threshold:parseInt(D.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("smartPlugs.tempThresholdDescription")})]})]})]}),i.jsxs("div",{className:"flex gap-2 pt-2",children:[i.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[i.jsx(oh,{className:"w-4 h-4"}),n("smartPlugs.edit")]}),i.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>o(!0),className:"text-red-400 hover:text-red-300",children:i.jsx(en,{className:"w-4 h-4"})})]})]})]})}),s&&i.jsx(_n,{title:n("smartPlugs.deleteSmartPlug"),message:n("smartPlugs.deleteConfirm",{name:t.name}),confirmText:n("smartPlugs.delete"),variant:"danger",onConfirm:()=>{N.mutate(),o(!1)},onCancel:()=>o(!1)}),l&&i.jsx(_n,{title:n("smartPlugs.turnOnSmartPlug"),message:n("smartPlugs.turnOnConfirm",{name:t.name}),confirmText:n("smartPlugs.turnOn"),variant:"default",onConfirm:()=>{g.mutate("on"),c(!1)},onCancel:()=>c(!1)}),u&&i.jsx(_n,{title:n("smartPlugs.turnOffSmartPlug"),message:n("smartPlugs.turnOffConfirm",{name:t.name}),confirmText:n("smartPlugs.turnOff"),variant:"danger",onConfirm:()=>{g.mutate("off"),d(!1)},onCancel:()=>d(!1)})]})}function det({plug:t,onClose:e}){const{t:n}=Rt(),r=sn(),a=!!t,[s,o]=w.useState(t?.plug_type||"tasmota"),[l,c]=w.useState(t?.name||""),[u,d]=w.useState(t?.ip_address||""),[m,p]=w.useState(t?.username||""),[f,y]=w.useState(t?.password||""),[v,b]=w.useState(t?.ha_entity_id||""),[g,_]=w.useState(t?.mqtt_power_topic||t?.mqtt_topic||""),[N,T]=w.useState(t?.mqtt_power_path||""),[C,P]=w.useState((t?.mqtt_power_multiplier??t?.mqtt_multiplier??1).toString()),[k,R]=w.useState(t?.mqtt_energy_topic||""),[A,D]=w.useState(t?.mqtt_energy_path||""),[B,z]=w.useState((t?.mqtt_energy_multiplier??1).toString()),[W,I]=w.useState(t?.mqtt_state_topic||""),[J,ie]=w.useState(t?.mqtt_state_path||""),[Q,ue]=w.useState(t?.mqtt_state_on_value||""),[me,pe]=w.useState(t?.ha_power_entity||""),[Y,se]=w.useState(t?.ha_energy_today_entity||""),[oe,be]=w.useState(t?.ha_energy_total_entity||""),[Me,q]=w.useState(""),[Z,j]=w.useState(""),[E,U]=w.useState(!1),K=w.useRef(null),[$,ne]=w.useState(""),[O,V]=w.useState(!1),ee=w.useRef(null),[G,re]=w.useState(""),[ce,ge]=w.useState(!1),xe=w.useRef(null),[ae,L]=w.useState(""),[F,te]=w.useState(!1),ve=w.useRef(null),[he,de]=w.useState(t?.printer_id||null),[ke,_e]=w.useState(null),[Le,$e]=w.useState(null),[Re,Ae]=w.useState(t?.power_alert_enabled||!1),[Pe,Ue]=w.useState(t?.power_alert_high?.toString()||""),[je,Xe]=w.useState(t?.power_alert_low?.toString()||""),[ye,Ge]=w.useState(t?.schedule_enabled||!1),[Ee,Ke]=w.useState(t?.schedule_on_time||""),[Ve,Ne]=w.useState(t?.schedule_off_time||""),[Ce,He]=w.useState(t?.show_in_switchbar||!1),[et,it]=w.useState(t?.show_on_printer_card??!0),[xt,vt]=w.useState(!1),[qe,_t]=w.useState({scanned:0,total:0}),[Nt,mt]=w.useState([]),jt=w.useRef(null),{data:qt}=tt({queryKey:["printers"],queryFn:fe.getPrinters}),{data:Jt}=tt({queryKey:["smart-plugs"],queryFn:fe.getSmartPlugs}),{data:Wt}=tt({queryKey:["settings"],queryFn:fe.getSettings}),un=!!(Wt?.ha_enabled&&Wt?.ha_url&&Wt?.ha_token);w.useEffect(()=>{const De=setTimeout(()=>{j(Me)},300);return()=>clearTimeout(De)},[Me]),w.useEffect(()=>{const De=ht=>{K.current&&!K.current.contains(ht.target)&&U(!1),ee.current&&!ee.current.contains(ht.target)&&V(!1),xe.current&&!xe.current.contains(ht.target)&&ge(!1),ve.current&&!ve.current.contains(ht.target)&&te(!1)};return document.addEventListener("mousedown",De),()=>document.removeEventListener("mousedown",De)},[]);const{data:Je,isLoading:xn,error:Cn}=tt({queryKey:["ha-entities",Z],queryFn:()=>fe.getHAEntities(Z||void 0),enabled:s==="homeassistant"&&un,retry:!1,staleTime:0}),{data:Oe}=tt({queryKey:["ha-sensor-entities"],queryFn:fe.getHASensorEntities,enabled:s==="homeassistant"&&un,retry:!1,staleTime:0});w.useEffect(()=>{const De=ht=>{ht.key==="Escape"&&e()};return window.addEventListener("keydown",De),()=>{window.removeEventListener("keydown",De),jt.current&&clearInterval(jt.current)}},[e]);const nt=async()=>{vt(!0),mt([]),_t({scanned:0,total:0}),$e(null);try{await fe.startTasmotaScan();const De=async()=>{try{const ht=await fe.getTasmotaScanStatus();_t({scanned:ht.scanned,total:ht.total});const ut=await fe.getDiscoveredTasmotaDevices();mt(ut),ht.running||(vt(!1),jt.current&&(clearInterval(jt.current),jt.current=null))}catch(ht){console.error("Polling error:",ht)}};await De(),jt.current=setInterval(De,500)}catch(De){vt(!1);const ht=De instanceof Error?De.message:typeof De=="string"?De:JSON.stringify(De);$e(ht||n("smartPlugs.failedToStartScan"))}},dt=async()=>{try{await fe.stopTasmotaScan()}catch{}vt(!1),jt.current&&(clearInterval(jt.current),jt.current=null)},Qe=De=>{d(De.ip_address),c(De.name),_e(null)},Te=ft({mutationFn:()=>fe.testSmartPlugConnection(u,m||null,f||null),onSuccess:De=>{_e(De),$e(null),!l&&De.device_name&&c(De.device_name)},onError:De=>{_e(null),$e(De.message)}}),st=ft({mutationFn:De=>fe.createSmartPlug(De),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:De=>{$e(De.message)}}),le=ft({mutationFn:De=>fe.updateSmartPlug(t.id,De),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:De=>{$e(De.message)}}),Be=qt?.filter(De=>s==="tasmota"?!Jt?.some(ut=>ut.printer_id===De.id&&ut.id!==t?.id&&ut.plug_type==="tasmota"):!0),We=De=>{if(De.preventDefault(),$e(null),!l.trim()){$e(n("smartPlugs.nameRequired"));return}if(s==="tasmota"&&!u.trim()){$e("IP address is required for Tasmota plugs");return}if(s==="homeassistant"&&!v){$e(n("smartPlugs.entityRequired"));return}if(s==="mqtt"){const ut=g.trim(),rt=k.trim(),wt=W.trim();if(!ut&&!rt&&!wt){$e(n("smartPlugs.mqttTopicRequired"));return}}const ht={name:l.trim(),plug_type:s,ip_address:s==="tasmota"?u.trim():null,ha_entity_id:s==="homeassistant"?v:null,ha_power_entity:s==="homeassistant"&&me||null,ha_energy_today_entity:s==="homeassistant"&&Y||null,ha_energy_total_entity:s==="homeassistant"&&oe||null,mqtt_power_topic:s==="mqtt"&&g.trim()||null,mqtt_power_path:s==="mqtt"&&N.trim()||null,mqtt_power_multiplier:s==="mqtt"&&parseFloat(C)||1,mqtt_energy_topic:s==="mqtt"&&k.trim()||null,mqtt_energy_path:s==="mqtt"&&A.trim()||null,mqtt_energy_multiplier:s==="mqtt"&&parseFloat(B)||1,mqtt_state_topic:s==="mqtt"&&W.trim()||null,mqtt_state_path:s==="mqtt"&&J.trim()||null,mqtt_state_on_value:s==="mqtt"&&Q.trim()||null,username:s==="tasmota"&&m.trim()||null,password:s==="tasmota"&&f.trim()||null,printer_id:he,power_alert_enabled:Re,power_alert_high:Pe?parseFloat(Pe):null,power_alert_low:je?parseFloat(je):null,schedule_enabled:ye,schedule_on_time:Ee||null,schedule_off_time:Ve||null,show_in_switchbar:Ce,show_on_printer_card:et};a?le.mutate(ht):st.mutate(ht)},Ye=st.isPending||le.isPending;return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:De=>De.stopPropagation(),children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[i.jsx("h2",{className:"text-lg font-semibold text-white",children:n(a?"smartPlugs.editTitle":"smartPlugs.addTitle")}),i.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:i.jsx(Ht,{className:"w-5 h-5"})})]}),i.jsxs("form",{onSubmit:We,className:"p-6 space-y-4 overflow-y-auto",children:[Le&&i.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:Le}),!a&&i.jsxs("div",{className:"flex gap-2 mb-2",children:[i.jsxs("button",{type:"button",onClick:()=>{o("tasmota"),_e(null),$e(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="tasmota"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[i.jsx(Il,{className:"w-4 h-4"}),"Tasmota"]}),i.jsxs("button",{type:"button",onClick:()=>{o("homeassistant"),_e(null),$e(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="homeassistant"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[i.jsx(bw,{className:"w-4 h-4"}),"HA"]}),i.jsxs("button",{type:"button",onClick:()=>{o("mqtt"),_e(null),$e(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="mqtt"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[i.jsx(qL,{className:"w-4 h-4"}),"MQTT"]})]}),!a&&s==="tasmota"&&i.jsxs("div",{className:"space-y-3",children:[xt?i.jsxs(Ie,{type:"button",variant:"secondary",onClick:dt,className:"w-full",children:[i.jsx(Ht,{className:"w-4 h-4"}),n("smartPlugs.stopScanning")]}):i.jsxs(Ie,{type:"button",variant:"primary",onClick:nt,className:"w-full",children:[i.jsx(Rr,{className:"w-4 h-4"}),n("smartPlugs.discoverTasmota")]}),xt&&qe.total>0&&i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray",children:[i.jsx("span",{children:n("smartPlugs.addSmartPlug.scanningNetwork")}),i.jsxs("span",{children:[qe.scanned," / ",qe.total]})]}),i.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:i.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${qe.scanned/qe.total*100}%`}})})]}),Nt.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.foundDevices",{count:Nt.length})}),i.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:Nt.map(De=>i.jsxs("button",{type:"button",onClick:()=>Qe(De),className:"w-full flex items-center justify-between p-2 bg-bambu-dark hover:bg-bambu-dark-tertiary rounded-lg transition-colors text-left border border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Il,{className:"w-4 h-4 text-bambu-green"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:De.name}),i.jsx("p",{className:"text-xs text-bambu-gray",children:De.ip_address})]})]}),De.state&&i.jsxs("span",{className:`flex items-center gap-1 text-xs ${De.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[i.jsx(Xd,{className:"w-3 h-3"}),De.state]})]},De.ip_address))})]}),!xt&&Nt.length===0&&qe.total>0&&i.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:n("smartPlugs.noDevicesFound")})]}),s==="homeassistant"&&i.jsxs("div",{className:"space-y-3",children:[!un&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:[n("smartPlugs.haNotConfigured")," ",i.jsx("span",{className:"font-medium",children:n("smartPlugs.haSettingsPath")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1 opacity-50",children:n("smartPlugs.selectEntity")}),i.jsx("select",{disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed opacity-50",children:i.jsx("option",{children:n("smartPlugs.addSmartPlug.chooseEntity")})})]})]}),un&&i.jsxs(i.Fragment,{children:[xn&&i.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[i.jsx(pt,{className:"w-5 h-5 animate-spin mr-2"}),n("smartPlugs.loadingEntities")]}),Cn&&i.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:n("smartPlugs.failedToLoadEntities",{error:Cn.message})}),(()=>{const De=Jt?.filter(rt=>rt.ha_entity_id&&rt.id!==t?.id).map(rt=>rt.ha_entity_id)||[],ht=(Je||[]).filter(rt=>!De.includes(rt.entity_id)),ut=Je?.find(rt=>rt.entity_id===v);return i.jsxs("div",{ref:K,className:"relative",children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.selectEntity")}),i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),i.jsx("input",{type:"text",value:E?Me:ut?`${ut.friendly_name} (${ut.entity_id})`:"",onChange:rt=>{q(rt.target.value),E||U(!0)},onFocus:()=>{U(!0),q("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEntities"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),v&&!E&&i.jsx("button",{type:"button",onClick:()=>{b(""),q("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:i.jsx(Ht,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),xn&&i.jsx(pt,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),E&&i.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[xn&&i.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),n("smartPlugs.loading")]}),!xn&&ht.length===0&&i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:Z?n("smartPlugs.noEntitiesMatching",{search:Z}):n("smartPlugs.noEntitiesAvailable")}),!xn&&ht.map(rt=>i.jsxs("button",{type:"button",onClick:()=>{b(rt.entity_id),U(!1),q(""),l||c(rt.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${rt.entity_id===v?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[i.jsx("div",{className:"font-medium",children:rt.friendly_name}),i.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[i.jsx("span",{children:rt.entity_id}),i.jsx("span",{className:rt.state==="on"?"text-bambu-green":"",children:rt.state})]})]},rt.entity_id))]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:Z?n("smartPlugs.searchingEntities",{count:ht.length}):n("smartPlugs.showingEntities",{count:ht.length})})]})})(),v&&Oe&&Oe.length>0&&i.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4 space-y-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white font-medium mb-1",children:n("smartPlugs.energyMonitoringOptional")}),i.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:n("smartPlugs.energyMonitoringHint")})]}),(()=>{const De=Oe.filter(rt=>rt.unit_of_measurement==="W"||rt.unit_of_measurement==="kW"||rt.unit_of_measurement==="mW"),ht=$?De.filter(rt=>rt.entity_id.toLowerCase().includes($.toLowerCase())||rt.friendly_name.toLowerCase().includes($.toLowerCase())):De,ut=Oe.find(rt=>rt.entity_id===me);return i.jsxs("div",{ref:ee,className:"relative",children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.powerSensorW")}),i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),i.jsx("input",{type:"text",value:O?$:ut?`${ut.friendly_name} (${ut.state} ${ut.unit_of_measurement})`:"",onChange:rt=>{ne(rt.target.value),O||V(!0)},onFocus:()=>{V(!0),ne("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchPowerSensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),me&&!O&&i.jsx("button",{type:"button",onClick:()=>{pe(""),ne("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:i.jsx(Ht,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),O&&i.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[i.jsx("button",{type:"button",onClick:()=>{pe(""),V(!1),ne("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:n("smartPlugs.none")}),ht.map(rt=>i.jsxs("button",{type:"button",onClick:()=>{pe(rt.entity_id),V(!1),ne("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${rt.entity_id===me?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[i.jsx("div",{className:"font-medium",children:rt.friendly_name}),i.jsxs("div",{className:"text-xs text-bambu-gray",children:[rt.entity_id," • ",rt.state," ",rt.unit_of_measurement]})]},rt.entity_id)),ht.length===0&&i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:n("smartPlugs.noMatchingSensors")})]})]})})(),(()=>{const De=Oe.filter(rt=>rt.unit_of_measurement==="kWh"||rt.unit_of_measurement==="Wh"||rt.unit_of_measurement==="MWh"),ht=G?De.filter(rt=>rt.entity_id.toLowerCase().includes(G.toLowerCase())||rt.friendly_name.toLowerCase().includes(G.toLowerCase())):De,ut=Oe.find(rt=>rt.entity_id===Y);return i.jsxs("div",{ref:xe,className:"relative",children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.energyTodayKwh")}),i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),i.jsx("input",{type:"text",value:ce?G:ut?`${ut.friendly_name} (${ut.state} ${ut.unit_of_measurement})`:"",onChange:rt=>{re(rt.target.value),ce||ge(!0)},onFocus:()=>{ge(!0),re("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEnergySensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),Y&&!ce&&i.jsx("button",{type:"button",onClick:()=>{se(""),re("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:i.jsx(Ht,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),ce&&i.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[i.jsx("button",{type:"button",onClick:()=>{se(""),ge(!1),re("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:n("smartPlugs.none")}),ht.map(rt=>i.jsxs("button",{type:"button",onClick:()=>{se(rt.entity_id),ge(!1),re("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${rt.entity_id===Y?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[i.jsx("div",{className:"font-medium",children:rt.friendly_name}),i.jsxs("div",{className:"text-xs text-bambu-gray",children:[rt.entity_id," • ",rt.state," ",rt.unit_of_measurement]})]},rt.entity_id)),ht.length===0&&i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:n("smartPlugs.noMatchingSensors")})]})]})})(),(()=>{const De=Oe.filter(rt=>rt.unit_of_measurement==="kWh"||rt.unit_of_measurement==="Wh"||rt.unit_of_measurement==="MWh"),ht=ae?De.filter(rt=>rt.entity_id.toLowerCase().includes(ae.toLowerCase())||rt.friendly_name.toLowerCase().includes(ae.toLowerCase())):De,ut=Oe.find(rt=>rt.entity_id===oe);return i.jsxs("div",{ref:ve,className:"relative",children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.totalEnergyKwh")}),i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),i.jsx("input",{type:"text",value:F?ae:ut?`${ut.friendly_name} (${ut.state} ${ut.unit_of_measurement})`:"",onChange:rt=>{L(rt.target.value),F||te(!0)},onFocus:()=>{te(!0),L("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEnergySensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),oe&&!F&&i.jsx("button",{type:"button",onClick:()=>{be(""),L("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:i.jsx(Ht,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),F&&i.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[i.jsx("button",{type:"button",onClick:()=>{be(""),te(!1),L("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:n("smartPlugs.none")}),ht.map(rt=>i.jsxs("button",{type:"button",onClick:()=>{be(rt.entity_id),te(!1),L("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${rt.entity_id===oe?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[i.jsx("div",{className:"font-medium",children:rt.friendly_name}),i.jsxs("div",{className:"text-xs text-bambu-gray",children:[rt.entity_id," • ",rt.state," ",rt.unit_of_measurement]})]},rt.entity_id)),ht.length===0&&i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:n("smartPlugs.noMatchingSensors")})]})]})})()]})]})]}),s==="mqtt"&&i.jsxs("div",{className:"space-y-3",children:[!Wt?.mqtt_broker&&i.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:[n("smartPlugs.mqttNotConfigured")," ",i.jsx("span",{className:"font-medium",children:n("smartPlugs.mqttSettingsPath")})," ",n("smartPlugs.mqttNotConfiguredSuffix")]}),Wt?.mqtt_broker&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg text-sm text-blue-300",children:[i.jsx("p",{className:"font-medium mb-1",children:n("smartPlugs.monitorOnly")}),i.jsx("p",{className:"text-xs opacity-80",children:n("smartPlugs.mqttMonitorOnlyDescription")})]}),i.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[i.jsx("p",{className:"text-white font-medium text-sm",children:n("smartPlugs.powerMonitoring")}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.topic")}),i.jsx("input",{type:"text",value:g,onChange:De=>_(De.target.value),placeholder:"zigbee2mqtt/shelly-working-room",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.jsonPath")}),i.jsx("input",{type:"text",value:N,onChange:De=>T(De.target.value),placeholder:"power_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.multiplier")}),i.jsx("input",{type:"text",value:C,onChange:De=>P(De.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",style:{whiteSpace:"pre-line"},children:n("smartPlugs.mqttPowerHint")})]}),i.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[i.jsxs("p",{className:"text-white font-medium text-sm",children:[n("smartPlugs.energyMonitoring")," ",i.jsxs("span",{className:"text-bambu-gray font-normal",children:["(",n("smartPlugs.optional"),")"]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.topic")}),i.jsx("input",{type:"text",value:k,onChange:De=>R(De.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.jsonPath")}),i.jsx("input",{type:"text",value:A,onChange:De=>D(De.target.value),placeholder:"energy_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.multiplier")}),i.jsx("input",{type:"text",value:B,onChange:De=>z(De.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",style:{whiteSpace:"pre-line"},children:n("smartPlugs.mqttEnergyHint")})]}),i.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[i.jsxs("p",{className:"text-white font-medium text-sm",children:[n("smartPlugs.stateMonitoring")," ",i.jsxs("span",{className:"text-bambu-gray font-normal",children:["(",n("smartPlugs.optional"),")"]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.topic")}),i.jsx("input",{type:"text",value:W,onChange:De=>I(De.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.jsonPath")}),i.jsx("input",{type:"text",value:J,onChange:De=>ie(De.target.value),placeholder:"state_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.onValue")}),i.jsx("input",{type:"text",value:Q,onChange:De=>ue(De.target.value),placeholder:n("smartPlugs.addSmartPlug.placeholders.mqttStateOnValue"),className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",style:{whiteSpace:"pre-line"},children:n("smartPlugs.mqttStateHint")})]})]})]}),s==="tasmota"&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.ipAddress")}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",value:u,onChange:De=>{d(De.target.value),_e(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),i.jsxs(Ie,{type:"button",variant:"secondary",onClick:()=>Te.mutate(),disabled:!u.trim()||Te.isPending,children:[Te.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Hb,{className:"w-4 h-4"}),n("smartPlugs.test")]})]})]}),s==="tasmota"&&ke&&i.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ke.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:ke.success?i.jsxs(i.Fragment,{children:[i.jsx(fr,{className:"w-5 h-5"}),i.jsxs("div",{children:[i.jsx("p",{className:"font-medium",children:n("smartPlugs.connectedResult")}),i.jsxs("p",{className:"text-sm opacity-80",children:[ke.device_name&&n("smartPlugs.deviceLabel",{name:ke.device_name}),n("smartPlugs.stateLabel",{state:ke.state})]})]})]}):i.jsxs(i.Fragment,{children:[i.jsx(Rh,{className:"w-5 h-5"}),i.jsx("span",{children:n("smartPlugs.addSmartPlug.connectionFailed")})]})}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.nameLabel")}),i.jsx("input",{type:"text",value:l,onChange:De=>c(De.target.value),placeholder:n("smartPlugs.addSmartPlug.placeholders.plugName"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s==="tasmota"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.username")}),i.jsx("input",{type:"text",value:m,onChange:De=>p(De.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.password")}),i.jsx("input",{type:"password",value:f,onChange:De=>y(De.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:n("smartPlugs.authHint")})]}),s!=="mqtt"&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.linkToPrinter")}),i.jsxs("select",{value:he??"",onChange:De=>de(De.target.value?Number(De.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"",children:n("smartPlugs.noPrinter")}),Be?.map(De=>i.jsx("option",{value:De.id,children:De.name},De.id))]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("smartPlugs.linkingDescription")})]}),i.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(xh,{className:"w-4 h-4 text-bambu-green"}),i.jsx("span",{className:"text-white font-medium",children:n("smartPlugs.powerAlerts")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:Re,onChange:De=>Ae(De.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),Re&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.alertAbove")}),i.jsx("input",{type:"number",value:Pe,onChange:De=>Ue(De.target.value),placeholder:"e.g. 200",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.alertBelow")}),i.jsx("input",{type:"number",value:je,onChange:De=>Xe(De.target.value),placeholder:"e.g. 10",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.alertDescription")})]})]}),s!=="mqtt"&&i.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Jn,{className:"w-4 h-4 text-bambu-green"}),i.jsx("span",{className:"text-white font-medium",children:n("smartPlugs.dailySchedule")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:ye,onChange:De=>Ge(De.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),ye&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.turnOnAt")}),i.jsx("input",{type:"time",value:Ee,onChange:De=>Ke(De.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.turnOffAt")}),i.jsx("input",{type:"time",value:Ve,onChange:De=>Ne(De.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.scheduleDescription")})]})]}),i.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(xw,{className:"w-4 h-4 text-bambu-green"}),i.jsxs("div",{children:[i.jsx("span",{className:"text-white font-medium",children:n("smartPlugs.showInSwitchbar")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.quickAccessSidebar")})]})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:Ce,onChange:De=>He(De.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),s==="homeassistant"&&i.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Ac,{className:"w-4 h-4 text-bambu-green"}),i.jsxs("div",{children:[i.jsx("span",{className:"text-white font-medium",children:n("smartPlugs.showOnPrinterCard")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.displayOnPrinterCard")})]})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:et,onChange:De=>it(De.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),i.jsxs("div",{className:"flex gap-3 pt-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:n("smartPlugs.cancel")}),i.jsxs(Ie,{type:"submit",disabled:Ye,className:"flex-1",children:[Ye?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(ss,{className:"w-4 h-4"}),n(a?"smartPlugs.save":"smartPlugs.add")]})]})]})]})})}function Bn({checked:t,onChange:e,disabled:n}){const r=a=>{a.preventDefault(),a.stopPropagation(),n||e(!t)};return i.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-11 h-7 md:w-9 md:h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:i.jsx("span",{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}function met({provider:t,onEdit:e}){const{t:n}=Rt(),r=sn(),[a,s]=w.useState(!1),[o,l]=w.useState(!1),[c,u]=w.useState(null),{data:d}=tt({queryKey:["printers"],queryFn:fe.getPrinters}),m=d?.find(b=>b.id===t.printer_id),p=ft({mutationFn:b=>fe.updateNotificationProvider(t.id,b),onSuccess:()=>{r.invalidateQueries({queryKey:["notification-providers"]})}}),f=ft({mutationFn:()=>fe.deleteNotificationProvider(t.id),onSuccess:()=>{r.invalidateQueries({queryKey:["notification-providers"]})}}),y=ft({mutationFn:()=>fe.testNotificationProvider(t.id),onSuccess:b=>{u(b),r.invalidateQueries({queryKey:["notification-providers"]})},onError:b=>{u({success:!1,message:b.message})}}),v=b=>b||"";return i.jsxs(i.Fragment,{children:[i.jsx(Pt,{className:"relative",children:i.jsxs(Et,{className:"p-4",children:[i.jsxs("div",{className:"flex items-start justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:i.jsx(xh,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium text-white",children:t.name}),i.jsx("p",{className:"text-sm text-bambu-gray",children:n(`notifications.providerTypes.${t.provider_type}`,t.provider_type)})]})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&i.jsx("span",{className:"text-xs text-status-ok hidden sm:inline",children:n("notifications.lastSuccess",{date:Cf(t.last_success)})}),t.last_error&&t.last_error_at&&(!t.last_success||(Zn(t.last_error_at)?.getTime()||0)>(Zn(t.last_success)?.getTime()||0))&&i.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:n("notifications.error")}),i.jsx(Bn,{checked:t.enabled,onChange:b=>p.mutate({enabled:b})})]})]}),m&&i.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[i.jsxs("span",{className:"text-xs text-bambu-gray",children:[n("notifications.printer")," "]}),i.jsx("span",{className:"text-sm text-white",children:m.name})]}),!m&&!t.printer_id&&i.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:i.jsx("span",{className:"text-xs text-bambu-gray",children:n("notifications.allPrinters")})}),i.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&i.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:n("notifications.start")}),t.on_plate_not_empty&&i.jsx("span",{className:"px-2 py-0.5 bg-rose-600/20 text-rose-300 text-xs rounded",children:n("notifications.plateCheck")}),t.on_print_complete&&i.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:n("notifications.complete")}),t.on_print_failed&&i.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:n("notifications.failed")}),t.on_print_stopped&&i.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:n("notifications.stopped")}),t.on_print_progress&&i.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:n("notifications.progress")}),t.on_printer_offline&&i.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:n("notifications.offline")}),t.on_printer_error&&i.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:n("notifications.error")}),t.on_filament_low&&i.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:n("notifications.lowFilament")}),t.on_maintenance_due&&i.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:n("notifications.maintenance")}),t.on_ams_humidity_high&&i.jsx("span",{className:"px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded",children:n("notifications.amsHumidity")}),t.on_ams_temperature_high&&i.jsx("span",{className:"px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded",children:n("notifications.amsTemp")}),t.on_ams_ht_humidity_high&&i.jsx("span",{className:"px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded",children:n("notifications.amsHtHumidity")}),t.on_ams_ht_temperature_high&&i.jsx("span",{className:"px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded",children:n("notifications.amsHtTemp")}),t.on_bed_cooled&&i.jsx("span",{className:"px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded",children:n("notifications.bedCooled")}),t.on_first_layer_complete&&i.jsx("span",{className:"px-2 py-0.5 bg-emerald-600/20 text-emerald-300 text-xs rounded",children:n("notifications.firstLayer")}),t.quiet_hours_enabled&&i.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[i.jsx(FN,{className:"w-3 h-3"}),n("notifications.quiet")]}),t.daily_digest_enabled&&i.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[i.jsx(Yr,{className:"w-3 h-3"}),n("notifications.digest",{time:t.daily_digest_time})]})]}),i.jsx("div",{className:"mb-3",children:i.jsxs(Ie,{size:"sm",variant:"secondary",disabled:y.isPending,onClick:()=>{u(null),y.mutate()},className:"w-full",children:[y.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(iT,{className:"w-4 h-4"}),n("notifications.sendTestNotification")]})}),c&&i.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${c.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[c.success?i.jsx(fr,{className:"w-4 h-4"}):i.jsx(qi,{className:"w-4 h-4"}),i.jsx("span",{children:c.message})]}),i.jsxs("button",{onClick:()=>l(!o),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(Od,{className:"w-4 h-4"}),n("notifications.eventSettings")]}),o?i.jsx($l,{className:"w-4 h-4"}):i.jsx(On,{className:"w-4 h-4"})]}),o&&i.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.enabled")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.sendFromProvider")})]}),i.jsx(Bn,{checked:t.enabled,onChange:b=>p.mutate({enabled:b})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:n("notifications.printEvents")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.printStarted")}),i.jsx(Bn,{checked:t.on_print_start,onChange:b=>p.mutate({on_print_start:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.plateNotEmpty")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.plateNotEmptyDescription")})]}),i.jsx(Bn,{checked:t.on_plate_not_empty??!0,onChange:b=>p.mutate({on_plate_not_empty:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.printCompleted")}),i.jsx(Bn,{checked:t.on_print_complete,onChange:b=>p.mutate({on_print_complete:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.bedCooledLabel")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.bedCooledDescription")})]}),i.jsx(Bn,{checked:t.on_bed_cooled??!1,onChange:b=>p.mutate({on_bed_cooled:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.firstLayerCompleteLabel")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.firstLayerCompleteDescription")})]}),i.jsx(Bn,{checked:t.on_first_layer_complete??!1,onChange:b=>p.mutate({on_first_layer_complete:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.printFailed")}),i.jsx(Bn,{checked:t.on_print_failed,onChange:b=>p.mutate({on_print_failed:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.printStopped")}),i.jsx(Bn,{checked:t.on_print_stopped,onChange:b=>p.mutate({on_print_stopped:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.progressMilestones")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.progressMilestonesDescription")})]}),i.jsx(Bn,{checked:t.on_print_progress,onChange:b=>p.mutate({on_print_progress:b})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:n("notifications.printerStatus")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.printerOffline")}),i.jsx(Bn,{checked:t.on_printer_offline,onChange:b=>p.mutate({on_printer_offline:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.printerError")}),i.jsx(Bn,{checked:t.on_printer_error,onChange:b=>p.mutate({on_printer_error:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.lowFilamentLabel")}),i.jsx(Bn,{checked:t.on_filament_low,onChange:b=>p.mutate({on_filament_low:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.maintenanceDue")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.maintenanceDueDescription")})]}),i.jsx(Bn,{checked:t.on_maintenance_due??!1,onChange:b=>p.mutate({on_maintenance_due:b})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:n("notifications.amsAlarms")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.amsHumidityHigh")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.amsHumidityHighDescription")})]}),i.jsx(Bn,{checked:t.on_ams_humidity_high??!1,onChange:b=>p.mutate({on_ams_humidity_high:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.amsTemperatureHigh")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.amsTemperatureHighDescription")})]}),i.jsx(Bn,{checked:t.on_ams_temperature_high??!1,onChange:b=>p.mutate({on_ams_temperature_high:b})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:n("notifications.amsHtAlarms")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.amsHtHumidityHigh")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.amsHtHumidityHighDescription")})]}),i.jsx(Bn,{checked:t.on_ams_ht_humidity_high??!1,onChange:b=>p.mutate({on_ams_ht_humidity_high:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.amsHtTemperatureHigh")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.amsHtTemperatureHighDescription")})]}),i.jsx(Bn,{checked:t.on_ams_ht_temperature_high??!1,onChange:b=>p.mutate({on_ams_ht_temperature_high:b})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:n("notifications.printQueue")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.jobAdded")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.jobAddedDescription")})]}),i.jsx(Bn,{checked:t.on_queue_job_added??!1,onChange:b=>p.mutate({on_queue_job_added:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.jobAssigned")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.jobAssignedDescription")})]}),i.jsx(Bn,{checked:t.on_queue_job_assigned??!1,onChange:b=>p.mutate({on_queue_job_assigned:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.jobStarted")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.jobStartedDescription")})]}),i.jsx(Bn,{checked:t.on_queue_job_started??!1,onChange:b=>p.mutate({on_queue_job_started:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.jobWaiting")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.jobWaitingDescription")})]}),i.jsx(Bn,{checked:t.on_queue_job_waiting??!0,onChange:b=>p.mutate({on_queue_job_waiting:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.jobSkipped")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.jobSkippedDescription")})]}),i.jsx(Bn,{checked:t.on_queue_job_skipped??!0,onChange:b=>p.mutate({on_queue_job_skipped:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.jobFailed")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.jobFailedDescription")})]}),i.jsx(Bn,{checked:t.on_queue_job_failed??!0,onChange:b=>p.mutate({on_queue_job_failed:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.queueComplete")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.queueCompleteDescription")})]}),i.jsx(Bn,{checked:t.on_queue_completed??!1,onChange:b=>p.mutate({on_queue_completed:b})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(FN,{className:"w-4 h-4 text-purple-400"}),i.jsx("p",{className:"text-sm text-white",children:n("notifications.quietHours")})]}),i.jsx(Bn,{checked:t.quiet_hours_enabled,onChange:b=>p.mutate({quiet_hours_enabled:b})})]}),t.quiet_hours_enabled&&i.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.noNotificationsDuring")}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Jn,{className:"w-4 h-4 text-bambu-gray"}),i.jsxs("span",{className:"text-sm text-white",children:[v(t.quiet_hours_start)||"22:00"," - ",v(t.quiet_hours_end)||"07:00"]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.editProviderToChangeQuietHours")})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Yr,{className:"w-4 h-4 text-emerald-400"}),i.jsx("p",{className:"text-sm text-white",children:n("notifications.dailyDigest")})]}),i.jsx(Bn,{checked:t.daily_digest_enabled,onChange:b=>p.mutate({daily_digest_enabled:b})})]}),t.daily_digest_enabled&&i.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.batchNotifications")}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Jn,{className:"w-4 h-4 text-bambu-gray"}),i.jsx("span",{className:"text-sm text-white",children:n("notifications.sendAt",{time:v(t.daily_digest_time)||"08:00"})})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.editProviderToChangeDigestTime")})]})]}),i.jsxs("div",{className:"flex gap-2 pt-2",children:[i.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[i.jsx(oh,{className:"w-4 h-4"}),n("notifications.edit")]}),i.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>s(!0),className:"text-red-400 hover:text-red-300",children:i.jsx(en,{className:"w-4 h-4"})})]})]})]})}),a&&i.jsx(_n,{title:n("notifications.deleteProvider"),message:n("notifications.deleteConfirm",{name:t.name}),confirmText:n("notifications.delete"),variant:"danger",onConfirm:()=>{f.mutate(),s(!1)},onCancel:()=>s(!1)})]})}const het=["email","telegram","discord","ntfy","pushover","callmebot","webhook","homeassistant"];function pet({provider:t,onClose:e}){const{t:n}=Rt(),r=sn(),a=!!t,[s,o]=w.useState(t?.name||""),[l,c]=w.useState(t?.provider_type||"email"),[u,d]=w.useState(t?.printer_id||null),[m,p]=w.useState(t?.quiet_hours_enabled||!1),[f,y]=w.useState(t?.quiet_hours_start||"22:00"),[v,b]=w.useState(t?.quiet_hours_end||"07:00"),[g,_]=w.useState(t?.daily_digest_enabled||!1),[N,T]=w.useState(t?.daily_digest_time||"08:00"),[C,P]=w.useState(t?.on_print_start??!1),[k,R]=w.useState(t?.on_print_complete??!0),[A,D]=w.useState(t?.on_print_failed??!0),[B,z]=w.useState(t?.on_print_stopped??!0),[W,I]=w.useState(t?.on_print_progress??!1),[J,ie]=w.useState(t?.on_printer_offline??!1),[Q,ue]=w.useState(t?.on_printer_error??!1),[me,pe]=w.useState(t?.on_filament_low??!1),[Y,se]=w.useState(t?.on_maintenance_due??!1),[oe,be]=w.useState(t?.on_bed_cooled??!1),[Me,q]=w.useState(t?.on_first_layer_complete??!1),[Z,j]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([ae,L])=>[ae,String(L)])):{}),[E,U]=w.useState(null),[K,$]=w.useState(null),{data:ne}=tt({queryKey:["printers"],queryFn:fe.getPrinters});w.useEffect(()=>{const ae=L=>{L.key==="Escape"&&e()};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[e]);const O=ft({mutationFn:()=>fe.testNotificationConfig({provider_type:l,config:Z}),onSuccess:ae=>{U(ae),$(null)},onError:ae=>{U({success:!1,message:ae.message})}}),V=ft({mutationFn:ae=>fe.createNotificationProvider(ae),onSuccess:()=>{r.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:ae=>{$(ae.message)}}),ee=ft({mutationFn:ae=>fe.updateNotificationProvider(t.id,ae),onSuccess:()=>{r.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:ae=>{$(ae.message)}}),G=ae=>{if(ae.preventDefault(),$(null),!s.trim()){$(n("notifications.nameRequired"));return}const L=ge(l);for(const te of L)if(!Z[te.key]?.trim()){$(n("notifications.fieldRequired",{field:te.label}));return}const F={name:s.trim(),provider_type:l,config:Z,printer_id:u,quiet_hours_enabled:m,quiet_hours_start:m?f:null,quiet_hours_end:m?v:null,daily_digest_enabled:g,daily_digest_time:g?N:null,on_print_start:C,on_print_complete:k,on_print_failed:A,on_print_stopped:B,on_print_progress:W,on_printer_offline:J,on_printer_error:Q,on_filament_low:me,on_maintenance_due:Y,on_bed_cooled:oe,on_first_layer_complete:Me};a?ee.mutate(F):V.mutate(F)},re=V.isPending||ee.isPending,ce=ae=>{switch(ae){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"payload_format",label:"Payload Format",type:"select",required:!1,options:[{value:"generic",label:"Generic JSON"},{value:"slack",label:"Slack / Mattermost"}]},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1,showIf:L=>L.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:L=>L.payload_format!=="slack"}];case"homeassistant":return[];default:return[]}},ge=ae=>ce(ae).filter(L=>L.required),xe=ce(l);return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:ae=>ae.stopPropagation(),children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[i.jsx("h2",{className:"text-lg font-semibold text-white",children:n(a?"notifications.editTitle":"notifications.addTitle")}),i.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:i.jsx(Ht,{className:"w-5 h-5"})})]}),i.jsxs("form",{onSubmit:G,className:"p-6 space-y-4",children:[K&&i.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:K}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("notifications.nameLabel")}),i.jsx("input",{type:"text",value:s,onChange:ae=>o(ae.target.value),placeholder:n("notifications.namePlaceholder"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("notifications.providerTypeLabel")}),i.jsx("select",{value:l,onChange:ae=>{c(ae.target.value),j({}),U(null)},disabled:a,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:het.map(ae=>i.jsx("option",{value:ae,children:n(`notifications.providerTypes.${ae}`,ae)},ae))}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n(`notifications.providerDescriptions.${l}`,"")})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:n("notifications.configuration")}),xe.filter(ae=>!("showIf"in ae)||ae.showIf?.(Z)!==!1).map(ae=>i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[ae.label," ",ae.required&&"*"]}),ae.type==="select"&&"options"in ae&&ae.options?i.jsx("select",{value:Z[ae.key]||ae.options[0]?.value||"",onChange:L=>{j({...Z,[ae.key]:L.target.value}),U(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:ae.options.map(L=>i.jsx("option",{value:L.value,children:L.label},L.value))}):i.jsx("input",{type:ae.type,value:Z[ae.key]||"",onChange:L=>{j({...Z,[ae.key]:L.target.value}),U(null)},placeholder:ae.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},ae.key))]}),i.jsx("div",{className:"flex gap-2",children:i.jsxs(Ie,{type:"button",variant:"secondary",onClick:()=>{U(null),O.mutate()},disabled:O.isPending||ge(l).length>0&&!Z[ge(l)[0]?.key],className:"flex-1",children:[O.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(iT,{className:"w-4 h-4"}),n("notifications.testConfiguration")]})}),E&&i.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${E.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:E.success?i.jsxs(i.Fragment,{children:[i.jsx(fr,{className:"w-5 h-5"}),i.jsx("span",{children:E.message})]}):i.jsxs(i.Fragment,{children:[i.jsx(qi,{className:"w-5 h-5"}),i.jsx("span",{children:E.message})]})}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("notifications.printerFilter")}),i.jsxs("select",{value:u??"",onChange:ae=>d(ae.target.value?Number(ae.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"",children:n("notifications.allPrinters")}),ne?.map(ae=>i.jsx("option",{value:ae.id,children:ae.name},ae.id))]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("notifications.onlyFromPrinter")})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"text-sm text-white",children:n("notifications.quietHoursDnd")}),i.jsx(Bn,{checked:m,onChange:p})]}),m&&i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:n("notifications.quietStart")}),i.jsx("input",{type:"time",value:f,onChange:ae=>y(ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:n("notifications.quietEnd")}),i.jsx("input",{type:"time",value:v,onChange:ae=>b(ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm text-white",children:n("notifications.dailyDigestLabel")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.batchNotifications")})]}),i.jsx(Bn,{checked:g,onChange:_})]}),g&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:n("notifications.sendDigestAt")}),i.jsx("input",{type:"time",value:N,onChange:ae=>T(ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("notifications.digestCollected")})]})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:n("notifications.notificationEvents")}),i.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:n("notifications.printEvents")}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.start")}),i.jsx(Bn,{checked:C,onChange:P})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.complete")}),i.jsx(Bn,{checked:k,onChange:R})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.failed")}),i.jsx(Bn,{checked:A,onChange:D})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.stopped")}),i.jsx(Bn,{checked:B,onChange:z})]}),i.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.progress")}),i.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:n("notifications.progressPercent")})]}),i.jsx(Bn,{checked:W,onChange:I})]}),i.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.bedCooled")}),i.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:n("notifications.bedCooledAfterPrint")})]}),i.jsx(Bn,{checked:oe,onChange:be})]}),i.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.firstLayerCompleteLabel")}),i.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:n("notifications.firstLayerCompleteDescription")})]}),i.jsx(Bn,{checked:Me,onChange:q})]})]})]}),i.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:n("notifications.printerStatus")}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.offline")}),i.jsx(Bn,{checked:J,onChange:ie})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.error")}),i.jsx(Bn,{checked:Q,onChange:ue})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.lowFilament")}),i.jsx(Bn,{checked:me,onChange:pe})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.maintenance")}),i.jsx(Bn,{checked:Y,onChange:se})]})]})]})]}),i.jsxs("div",{className:"flex gap-3 pt-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:n("notifications.cancel")}),i.jsxs(Ie,{type:"submit",disabled:re,className:"flex-1",children:[re?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(ss,{className:"w-4 h-4"}),n(a?"notifications.save":"notifications.add")]})]})]})]})})}function fet({template:t,onClose:e}){const{t:n}=Rt(),r=sn(),a=w.useRef(null),[s,o]=w.useState(t.title_template),[l,c]=w.useState(t.body_template),[u,d]=w.useState(null),[m,p]=w.useState(!0),{data:f}=tt({queryKey:["template-variables"],queryFn:fe.getTemplateVariables}),y=f?.find(P=>P.event_type===t.event_type),{data:v,isLoading:b}=tt({queryKey:["template-preview",t.event_type,s,l],queryFn:()=>fe.previewTemplate({event_type:t.event_type,title_template:s,body_template:l}),enabled:m&&s.length>0&&l.length>0});w.useEffect(()=>{const P=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[e]);const g=ft({mutationFn:P=>fe.updateNotificationTemplate(t.id,P),onSuccess:()=>{r.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:P=>{d(P.message)}}),_=ft({mutationFn:()=>fe.resetNotificationTemplate(t.id),onSuccess:P=>{o(P.title_template),c(P.body_template),r.invalidateQueries({queryKey:["notification-templates"]})},onError:P=>{d(P.message)}}),N=P=>{if(P.preventDefault(),d(null),!s.trim()){d(n("notifications.titleRequired"));return}if(!l.trim()){d(n("notifications.bodyRequired"));return}g.mutate({title_template:s,body_template:l})},T=P=>{const k=a.current;if(!k)return;const R=k.selectionStart,A=k.selectionEnd,D=l,B=D.substring(0,R),z=D.substring(A),W=B+`{${P}}`+z;c(W),setTimeout(()=>{k.focus();const I=R+P.length+2;k.setSelectionRange(I,I)},0)},C=s!==t.title_template||l!==t.body_template;return i.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[i.jsx("h2",{className:"text-lg font-semibold text-white",children:n("notifications.editTemplate",{name:t.name})}),i.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:i.jsx(Ht,{className:"w-5 h-5 text-bambu-gray"})})]}),i.jsxs("form",{onSubmit:N,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[u&&i.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:u}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:n("notifications.titleLabel")}),i.jsx("input",{type:"text",value:s,onChange:P=>o(P.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:n("notifications.titlePlaceholder")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:n("notifications.bodyLabel")}),i.jsx("textarea",{ref:a,value:l,onChange:P=>c(P.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:n("notifications.bodyPlaceholder")})]}),y&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:n("notifications.availableVariables")}),i.jsx("div",{className:"flex flex-wrap gap-2",children:y.variables.map(P=>i.jsxs("button",{type:"button",onClick:()=>T(P),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[i.jsx(ar,{className:"w-3 h-3"}),P]},P))}),i.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:n("notifications.clickToInsert")})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[i.jsx(Ac,{className:"w-4 h-4"}),n("notifications.livePreview")]}),i.jsx("button",{type:"button",onClick:()=>p(!m),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:n(m?"notifications.hide":"notifications.show")})]}),m&&i.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:b?i.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),n("notifications.loadingPreview")]}):v?i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-xs text-bambu-gray",children:n("notifications.titlePreview")}),i.jsx("div",{className:"text-white font-medium",children:v.title})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-xs text-bambu-gray",children:n("notifications.bodyPreview")}),i.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:v.body})]})]}):i.jsx("div",{className:"text-bambu-gray text-sm",children:n("notifications.enterTemplateContent")})})]})]}),i.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[i.jsxs(Ie,{type:"button",variant:"ghost",onClick:()=>_.mutate(),disabled:_.isPending,className:"text-orange-400 hover:text-orange-300",children:[_.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}):i.jsx(So,{className:"w-4 h-4 mr-2"}),n("notifications.resetToDefault")]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:e,children:n("notifications.cancel")}),i.jsxs(Ie,{onClick:N,disabled:g.isPending||!C,children:[g.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}):i.jsx(ss,{className:"w-4 h-4 mr-2"}),n("notifications.save")]})]})]})]})})}const get={print_start:"text-blue-400",print_complete:"text-bambu-green",print_failed:"text-red-400",print_stopped:"text-orange-400",print_progress:"text-yellow-400",printer_offline:"text-gray-400",printer_error:"text-rose-400",filament_low:"text-cyan-400",maintenance_due:"text-purple-400",test:"text-bambu-gray"};function bet({onClose:t}){const{t:e}=Rt(),n=sn(),{showToast:r}=fn(),[a,s]=w.useState(7),[o,l]=w.useState(null),[c,u]=w.useState(!1),{data:d}=tt({queryKey:["settings"],queryFn:fe.getSettings}),m=d?.time_format||"system",{data:p,isLoading:f,refetch:y,isRefetching:v}=tt({queryKey:["notification-logs",a,c],queryFn:()=>fe.getNotificationLogs({days:a,limit:100,success:c?!1:void 0})}),{data:b}=tt({queryKey:["notification-log-stats",a],queryFn:()=>fe.getNotificationLogStats(a)}),g=ft({mutationFn:()=>fe.clearNotificationLogs(30),onSuccess:N=>{r(N.message,"success"),n.invalidateQueries({queryKey:["notification-logs"]}),n.invalidateQueries({queryKey:["notification-log-stats"]})},onError:N=>{r(`Failed to clear logs: ${N.message}`,"error")}}),_=N=>{const T=Zn(N);if(!T)return"";const P=new Date().getTime()-T.getTime();return P<6e4?e("notifications.justNow"):P<36e5?`${Math.floor(P/6e4)}m ago`:P<864e5?`${Math.floor(P/36e5)}h ago`:T.toLocaleDateString()+" "+lQ(T,m)};return i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[i.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(x0,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:e("notifications.notificationLog")})]}),i.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),b&&i.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:i.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[i.jsxs("span",{className:"text-bambu-gray",children:[e("notifications.statsSummary",{days:a})," ",i.jsx("span",{className:"text-white font-medium",children:b.total})," ",e("notifications.statsNotifications")]}),i.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[i.jsx(fr,{className:"w-4 h-4"}),e("notifications.statsSent",{count:b.success_count})]}),b.failure_count>0&&i.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[i.jsx(qi,{className:"w-4 h-4"}),e("notifications.statsFailed",{count:b.failure_count})]})]})}),i.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[i.jsxs("select",{value:a,onChange:N=>s(Number(N.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[i.jsx("option",{value:1,children:e("notifications.last24Hours")}),i.jsx("option",{value:7,children:e("notifications.last7Days")}),i.jsx("option",{value:30,children:e("notifications.last30Days")}),i.jsx("option",{value:90,children:e("notifications.last90Days")})]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:c,onChange:N=>u(N.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),e("notifications.showFailedOnly")]}),i.jsx("div",{className:"flex-1"}),i.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:v,children:[v?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Sr,{className:"w-4 h-4"}),e("notifications.refresh")]}),i.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>g.mutate(),disabled:g.isPending,className:"text-red-400 hover:text-red-300",children:[g.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(en,{className:"w-4 h-4"}),e("notifications.clearOld")]})]}),i.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:f?i.jsx("div",{className:"flex justify-center py-12",children:i.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):p&&p.length>0?i.jsx("div",{className:"space-y-2",children:p.map(N=>i.jsx(xet,{log:N,isExpanded:o===N.id,onToggle:()=>l(o===N.id?null:N.id),formatDate:_,formatFullDate:T=>Tf(T,m)},N.id))}):i.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[i.jsx(x0,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),i.jsx("p",{className:"text-sm",children:e(c?"notifications.noFailedNotifications":"notifications.noNotificationsLogged")})]})})]})})}function xet({log:t,isExpanded:e,onToggle:n,formatDate:r,formatFullDate:a}){const{t:s}=Rt();return i.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[i.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?i.jsx(fr,{className:"w-4 h-4 text-bambu-green shrink-0"}):i.jsx(qi,{className:"w-4 h-4 text-red-400 shrink-0"}),i.jsx("span",{className:`text-xs font-medium ${get[t.event_type]||"text-bambu-gray"}`,children:s(`notifications.eventTypes.${t.event_type}`,t.event_type)}),i.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||s("notifications.unknownProvider")}),t.printer_name&&i.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),i.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?i.jsx($l,{className:"w-4 h-4 text-bambu-gray shrink-0"}):i.jsx(On,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&i.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:s("notifications.logTitle")}),i.jsx("p",{className:"text-sm text-white",children:t.title})]}),i.jsxs("div",{children:[i.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:s("notifications.logMessage")}),i.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&i.jsxs("div",{children:[i.jsx("p",{className:"text-xs text-red-400 mb-1",children:s("notifications.logError")}),i.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),i.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[i.jsx("span",{children:s("notifications.logProvider",{type:t.provider_type})}),i.jsx("span",{children:s("notifications.logTime",{time:a(t.created_at)})})]})]})]})}function yet({formData:t,setFormData:e,groups:n,onClose:r,onCreate:a,isCreating:s,isCreateButtonDisabled:o}){const{t:l}=Rt();w.useEffect(()=>{const u=d=>{d.key==="Escape"&&r()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[r]);const c=u=>{e({...t,group_ids:t.group_ids.includes(u)?t.group_ids.filter(d=>d!==u):[...t.group_ids,u]})};return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:r,children:i.jsxs(Pt,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Jm,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:l("users.modal.createUser")})]}),i.jsx("p",{className:"text-sm text-bambu-gray ml-7",children:l("users.modal.advancedAuthSubtitle")||"with Advanced Authentication"})]}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:r,children:i.jsx(Ht,{className:"w-5 h-5"})})]})}),i.jsxs(Et,{children:[i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[l("users.form.username")," ",i.jsx("span",{className:"text-red-400",children:"*"})]}),i.jsx("input",{type:"text",value:t.username,onChange:u=>e({...t,username:u.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:l("users.form.usernamePlaceholder"),autoComplete:"username",required:!0})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[l("users.form.email")||"Email"," ",i.jsx("span",{className:"text-red-400",children:"*"})]}),i.jsx("input",{type:"email",value:t.email,onChange:u=>e({...t,email:u.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:l("users.form.emailPlaceholder")||"user@example.com",required:!0})]}),i.jsx("div",{className:"bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3",children:i.jsx("p",{className:"text-sm text-bambu-gray",children:l("users.form.autoGeneratedPassword")||"A secure password will be automatically generated and emailed to the user."})}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:l("users.form.groups")}),i.jsxs("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:[n.map(u=>i.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:t.group_ids.includes(u.id),onChange:()=>c(u.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),i.jsx("span",{className:"text-sm text-white",children:u.name}),u.is_system&&i.jsxs("span",{className:"text-xs text-yellow-400",children:["(",l("users.system"),")"]})]},u.id)),n.length===0&&i.jsx("p",{className:"text-sm text-bambu-gray",children:l("users.noGroupsAvailable")})]})]})]}),i.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[i.jsx(Ie,{variant:"secondary",onClick:r,children:l("users.modal.cancel")}),i.jsx(Ie,{onClick:a,disabled:o,children:s?i.jsxs(i.Fragment,{children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),l("users.modal.creating")]}):i.jsxs(i.Fragment,{children:[i.jsx(ar,{className:"w-4 h-4"}),l("users.modal.createUser")]})})]})]})]})})}function vet(){const{t}=Rt(),e=sn(),{showToast:n}=fn(),[r,a]=w.useState(!1),[s,o]=w.useState(""),[l,c]=w.useState("auto"),[u,d]=w.useState(!1),[m,p]=w.useState(!0),[f,y]=w.useState("all"),[v,b]=w.useState(!1),[g,_]=w.useState(!1),[N,T]=w.useState(!1),{data:C,isLoading:P}=tt({queryKey:["spoolman-settings"],queryFn:fe.getSpoolmanSettings}),{data:k,isLoading:R,refetch:A}=tt({queryKey:["spoolman-status"],queryFn:fe.getSpoolmanStatus,refetchInterval:3e4}),{data:D}=tt({queryKey:["printers"],queryFn:fe.getPrinters});w.useEffect(()=>{C&&(a(C.spoolman_enabled==="true"),o(C.spoolman_url||""),c(C.spoolman_sync_mode||"auto"),d(C.spoolman_disable_weight_sync==="true"),p(C.spoolman_report_partial_usage!=="false"),b(!0))},[C]),w.useEffect(()=>{if(!v||!C)return;if(C.spoolman_enabled==="true"!==r||(C.spoolman_url||"")!==s||(C.spoolman_sync_mode||"auto")!==l||C.spoolman_disable_weight_sync==="true"!==u||C.spoolman_report_partial_usage!=="false"!==m){const se=setTimeout(()=>{B.mutate()},500);return()=>clearTimeout(se)}},[r,s,l,u,m,v]);const B=ft({mutationFn:()=>fe.updateSpoolmanSettings({spoolman_enabled:r?"true":"false",spoolman_url:s,spoolman_sync_mode:l,spoolman_disable_weight_sync:u?"true":"false",spoolman_report_partial_usage:m?"true":"false"}),onSuccess:()=>{e.invalidateQueries({queryKey:["spoolman-settings"]}),e.invalidateQueries({queryKey:["spoolman-status"]}),e.invalidateQueries({queryKey:["spool-assignments"]}),e.invalidateQueries({queryKey:["settings"]}),n(t("settings.toast.settingsSaved"))}}),z=ft({mutationFn:fe.connectSpoolman,onSuccess:()=>{A()}}),W=ft({mutationFn:fe.disconnectSpoolman,onSuccess:()=>{A()}}),I=ft({mutationFn:fe.syncAllPrintersAms,onSuccess:Y=>{Y.success}}),J=ft({mutationFn:Y=>fe.syncPrinterAms(Y),onSuccess:Y=>{Y.success}}),ie=()=>{f==="all"?I.mutate():J.mutate(f)},Q=ft({mutationFn:fe.syncWeightsFromAms,onSuccess:Y=>{e.invalidateQueries({queryKey:["spools"]}),e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("settings.amsSyncSuccess",{synced:Y.synced,skipped:Y.skipped}),"success"),T(!1)},onError:()=>{n(t("settings.amsSyncError"),"error"),T(!1)}}),ue=I.isPending||J.isPending,me=f==="all"?I.data:J.data,pe=f==="all"?I.isSuccess:J.isSuccess;return P?i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(mu,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.filamentTracking")})]})}),i.jsx(Et,{children:i.jsx("div",{className:"flex justify-center py-8",children:i.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(mu,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.filamentTracking")})]}),B.isPending&&i.jsx(pt,{className:"w-4 h-4 text-bambu-green animate-spin"})]})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:t("settings.filamentTrackingDesc")}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("button",{type:"button",onClick:()=>a(!1),className:`p-3 rounded-lg border-2 text-left transition-colors ${r?"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray/50":"border-bambu-green bg-bambu-green/10"}`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[i.jsx(Gi,{className:`w-4 h-4 ${r?"text-bambu-gray":"text-bambu-green"}`}),i.jsx("span",{className:`text-sm font-medium ${r?"text-bambu-gray":"text-white"}`,children:t("settings.trackingModeBuiltIn")})]}),i.jsx("p",{className:`text-xs ${r?"text-bambu-gray/60":"text-bambu-gray"}`,children:t("settings.trackingModeBuiltInDesc")}),!r&&i.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[i.jsx(Qr,{className:"w-3 h-3 text-bambu-green"}),i.jsx("span",{className:"text-xs text-bambu-green",children:t("common.enabled")})]})]}),i.jsxs("button",{type:"button",onClick:()=>a(!0),className:`p-3 rounded-lg border-2 text-left transition-colors ${r?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray/50"}`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[i.jsx(ti,{className:`w-4 h-4 ${r?"text-bambu-green":"text-bambu-gray"}`}),i.jsx("span",{className:`text-sm font-medium ${r?"text-white":"text-bambu-gray"}`,children:"Spoolman"})]}),i.jsx("p",{className:`text-xs ${r?"text-bambu-gray":"text-bambu-gray/60"}`,children:t("settings.trackingModeSpoolmanDesc")}),r&&i.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[i.jsx(Qr,{className:"w-3 h-3 text-bambu-green"}),i.jsx("span",{className:"text-xs text-bambu-green",children:t("common.enabled")})]})]})]}),!r&&i.jsxs("div",{className:"space-y-3",children:[i.jsx("div",{className:"p-3 bg-bambu-green/5 border border-bambu-green/20 rounded-lg",children:i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Us,{className:"w-4 h-4 text-bambu-green flex-shrink-0 mt-0.5"}),i.jsx("div",{className:"text-xs text-bambu-gray",children:i.jsxs("ul",{className:"list-disc list-inside space-y-0.5",children:[i.jsx("li",{children:t("settings.builtInFeatureRfid")}),i.jsx("li",{children:t("settings.builtInFeatureUsage")}),i.jsx("li",{children:t("settings.builtInFeatureCatalog")}),i.jsx("li",{children:t("settings.builtInFeatureThirdParty")})]})})]})}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>T(!0),disabled:Q.isPending,children:[Q.isPending?i.jsx(pt,{className:"w-4 h-4 mr-2 animate-spin"}):i.jsx(Sr,{className:"w-4 h-4 mr-2"}),t("settings.amsSyncButton")]})]}),r&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Us,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"text-xs text-blue-300",children:[i.jsx("p",{className:"font-medium mb-1",children:t("settings.howSyncWorks")}),i.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[i.jsx("li",{children:t("settings.syncInfoRfidOnly")}),i.jsx("li",{children:t("settings.syncInfoAutoCreate")}),i.jsx("li",{children:t("settings.syncInfoThirdPartySkipped")})]}),i.jsx("p",{className:"font-medium mt-2 mb-1",children:t("settings.linkingExistingSpools")}),i.jsx("p",{className:"text-blue-300/80",children:t("settings.linkingExistingSpoolsDesc")})]})]})}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("settings.spoolmanUrl")}),i.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:s,onChange:Y=>o(Y.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none"}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:t("settings.spoolmanUrlHint")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("settings.syncMode")}),i.jsxs("select",{value:l,onChange:Y=>c(Y.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"auto",children:t("settings.syncModeAuto")}),i.jsx("option",{value:"manual",children:t("settings.syncModeManual")})]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:t(l==="auto"?"settings.syncModeAutoDesc":"settings.syncModeManualDesc")})]}),l==="auto"&&i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:t("spoolman.disableWeightSync")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("spoolman.disableWeightSyncDesc")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:u,onChange:Y=>d(Y.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),u&&i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:t("spoolman.reportPartialUsage")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("spoolman.reportPartialUsageDesc")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:m,onChange:Y=>p(Y.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("settings.status"),":"]}),R?i.jsx(pt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):k?.connected?i.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[i.jsx(Qr,{className:"w-4 h-4"}),t("settings.spoolmanConnected")]}):i.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[i.jsx(Ht,{className:"w-4 h-4"}),t("settings.spoolmanDisconnected")]})]}),i.jsx("div",{className:"flex gap-2",children:k?.connected?i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>W.mutate(),disabled:W.isPending,children:[W.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(jfe,{className:"w-4 h-4"}),t("settings.disconnect")]}):i.jsxs(Ie,{size:"sm",onClick:()=>z.mutate(),disabled:z.isPending||!s,children:[z.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(_h,{className:"w-4 h-4"}),t("settings.connect")]})})]}),z.isError&&i.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:z.error.message}),k?.connected&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:t("settings.syncAmsData")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:t("settings.syncAmsDataDesc")})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsxs("select",{value:f,onChange:Y=>y(Y.target.value==="all"?"all":Number(Y.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[i.jsx("option",{value:"all",children:t("settings.allPrinters")}),D?.map(Y=>i.jsx("option",{value:Y.id,children:Y.name},Y.id))]}),i.jsx(On,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:ie,disabled:ue,children:[ue?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Sr,{className:"w-4 h-4"}),t("spoolman.sync")]})]})]}),pe&&me&&i.jsxs("div",{className:"mt-3 space-y-2",children:[i.jsx("div",{className:`p-2 rounded text-sm ${me.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:me.success?`Synced ${me.synced_count} spool${me.synced_count!==1?"s":""} successfully`:`Synced ${me.synced_count} spool${me.synced_count!==1?"s":""} with ${me.errors.length} error${me.errors.length!==1?"s":""}`}),me.skipped_count>0&&i.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[i.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Mn,{className:"w-3.5 h-3.5"}),i.jsxs("span",{className:"font-medium",children:[me.skipped_count," spool",me.skipped_count!==1?"s":""," skipped"]})]}),me.skipped_count>5&&i.jsx("button",{onClick:()=>_(!g),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:g?"Show less":"Show all"})]}),i.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(g?me.skipped:me.skipped.slice(0,5)).map((Y,se)=>i.jsxs("li",{className:"flex items-center gap-2",children:[Y.color&&i.jsx("span",{className:"w-3 h-3 rounded-full border border-black/20",style:{backgroundColor:`#${Y.color}`}}),i.jsx("span",{children:Y.location}),i.jsxs("span",{className:"text-amber-300/60",children:["- ",Y.reason]})]},se)),!g&&me.skipped_count>5&&i.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",me.skipped_count-5," more"]})]})]}),me.errors.length>0&&i.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[i.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),i.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:me.errors.map((Y,se)=>i.jsx("li",{children:Y},se))})]})]})]})]})]}),N&&i.jsx(_n,{title:t("settings.amsSyncTitle"),message:t("settings.amsSyncMessage"),confirmText:t("settings.amsSyncButton"),variant:"warning",isLoading:Q.isPending,loadingText:t("settings.amsSyncing"),onConfirm:()=>Q.mutate(),onCancel:()=>T(!1)})]})}function wet(){const{t}=Rt(),{showToast:e}=fn(),[n,r]=w.useState([]),[a,s]=w.useState(!0),[o,l]=w.useState(""),c=w.useRef(null),[u,d]=w.useState(!1),[m,p]=w.useState(null),[f,y]=w.useState(""),[v,b]=w.useState(""),[g,_]=w.useState(!1),[N,T]=w.useState(new Set),[C,P]=w.useState(!1),[k,R]=w.useState(null),[A,D]=w.useState(!1),B=w.useCallback(async()=>{try{const be=await fe.getSpoolCatalog();r(be)}catch{e(t("settings.catalog.loadFailed"),"error")}finally{s(!1)}},[e,t]);w.useEffect(()=>{B()},[B]);const z=n.filter(be=>be.name.toLowerCase().includes(o.toLowerCase())),W=async()=>{if(!f.trim()||!v){e(t("settings.catalog.nameWeightRequired"),"error");return}_(!0);try{const be=await fe.addCatalogEntry({name:f.trim(),weight:parseInt(v)});r(Me=>[...Me,be].sort((q,Z)=>q.name.localeCompare(Z.name))),d(!1),y(""),b(""),e(t("settings.catalog.entryAdded"),"success")}catch{e(t("settings.catalog.addFailed"),"error")}finally{_(!1)}},I=be=>{p(be.id),y(be.name),b(be.weight.toString())},J=()=>{p(null),y(""),b("")},ie=async be=>{if(!f.trim()||!v){e(t("settings.catalog.nameWeightRequired"),"error");return}_(!0);try{const Me=await fe.updateCatalogEntry(be,{name:f.trim(),weight:parseInt(v)});r(q=>q.map(Z=>Z.id===be?Me:Z).sort((Z,j)=>Z.name.localeCompare(j.name))),p(null),y(""),b(""),e(t("settings.catalog.entryUpdated"),"success")}catch{e(t("settings.catalog.updateFailed"),"error")}finally{_(!1)}},Q=async()=>{if(k)try{await fe.deleteCatalogEntry(k.id),r(be=>be.filter(Me=>Me.id!==k.id)),e(t("settings.catalog.entryDeleted"),"success")}catch{e(t("settings.catalog.deleteFailed"),"error")}finally{R(null)}},ue=async()=>{D(!1),s(!0);try{await fe.resetSpoolCatalog(),await B(),e(t("settings.catalog.resetSuccess"),"success")}catch{e(t("settings.catalog.resetFailed"),"error"),s(!1)}},me=be=>{T(Me=>{const q=new Set(Me);return q.has(be)?q.delete(be):q.add(be),q})},pe=()=>{N.size===z.length?T(new Set):T(new Set(z.map(be=>be.id)))},Y=async()=>{if(P(!1),N.size!==0)try{const be=await fe.bulkDeleteCatalogEntries([...N]);r(Me=>Me.filter(q=>!N.has(q.id))),T(new Set),e(t("settings.catalog.bulkDeleted",{count:be.deleted}),"success")}catch{e(t("settings.catalog.bulkDeleteFailed"),"error")}},se=()=>{const be=n.map(({name:j,weight:E})=>({name:j,weight:E})),Me=new Blob([JSON.stringify(be,null,2)],{type:"application/json"}),q=URL.createObjectURL(Me),Z=document.createElement("a");Z.href=q,Z.download="spool-catalog.json",document.body.appendChild(Z),Z.click(),document.body.removeChild(Z),URL.revokeObjectURL(q),e(t("settings.catalog.exported",{count:n.length}),"success")},oe=async be=>{const Me=be.target.files?.[0];if(Me){try{const q=await Me.text(),Z=JSON.parse(q);if(!Array.isArray(Z))throw new Error("Invalid format");let j=0,E=0;for(const U of Z){if(!U.name||typeof U.weight!="number"){E++;continue}if(n.some($=>$.name.toLowerCase()===U.name.toLowerCase())){E++;continue}try{const $=await fe.addCatalogEntry({name:U.name,weight:U.weight});r(ne=>[...ne,$].sort((O,V)=>O.name.localeCompare(V.name))),j++}catch{E++}}e(t("settings.catalog.imported",{added:j,skipped:E}),"success")}catch{e(t("settings.catalog.importFailed"),"error")}c.current&&(c.current.value="")}};return i.jsxs(Pt,{children:[i.jsxs(Hn,{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(mu,{className:"w-5 h-5 text-bambu-gray"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.catalog.spoolCatalog")}),i.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",n.length,")"]})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsxs("button",{onClick:se,className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.exportTooltip"),children:[i.jsx(bi,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.export")})]}),i.jsxs("button",{onClick:()=>c.current?.click(),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.importTooltip"),children:[i.jsx(vi,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.import")})]}),i.jsx("input",{ref:c,type:"file",accept:".json",className:"hidden",onChange:oe}),i.jsxs("button",{onClick:()=>D(!0),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.resetTooltip"),children:[i.jsx(So,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.reset")})]}),i.jsxs("button",{onClick:()=>d(!0),className:"px-3 py-1.5 text-sm bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 transition-colors flex items-center gap-1.5",children:[i.jsx(ar,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.add")})]})]}),N.size>0&&i.jsxs("div",{className:"flex items-center gap-2 mt-2 px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg",children:[i.jsx("span",{className:"text-sm text-red-400",children:t("settings.catalog.selectedCount",{count:N.size})}),i.jsxs("button",{onClick:()=>P(!0),className:"ml-auto px-3 py-1.5 text-sm bg-red-500 text-white rounded-lg hover:bg-red-600 transition-colors flex items-center gap-1.5",children:[i.jsx(en,{className:"w-4 h-4"}),t("settings.catalog.deleteSelected")]}),i.jsx("button",{onClick:()=>T(new Set),className:"px-3 py-1.5 text-sm text-bambu-gray hover:text-white transition-colors",children:t("common.cancel")})]})]}),i.jsxs(Et,{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:t("settings.catalog.spoolCatalogDescription")}),i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),i.jsx("input",{type:"text",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.catalog.searchCatalog"),value:o,onChange:be=>l(be.target.value)})]}),u&&i.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[i.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:t("settings.catalog.addNewEntry")}),i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsx("div",{className:"flex-1 min-w-0",children:i.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.catalog.namePlaceholder"),value:f,onChange:be=>y(be.target.value)})}),i.jsx("input",{type:"number",className:"w-20 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-center focus:border-bambu-green focus:outline-none",placeholder:"g",value:v,onChange:be=>b(be.target.value)}),i.jsx("span",{className:"text-bambu-gray shrink-0",children:"g"}),i.jsxs("button",{onClick:W,disabled:g,className:"px-3 py-2 bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 flex items-center gap-1 shrink-0",children:[g?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Qr,{className:"w-4 h-4"}),t("common.add")]}),i.jsx("button",{onClick:()=>{d(!1),y(""),b("")},className:"p-2 rounded-lg text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary",children:i.jsx(Ht,{className:"w-4 h-4"})})]})]}),a?i.jsxs("div",{className:"flex items-center justify-center py-8 text-bambu-gray",children:[i.jsx(pt,{className:"w-5 h-5 animate-spin mr-2"}),t("common.loading")]}):i.jsx("div",{className:"max-h-[600px] overflow-y-auto border border-bambu-dark-tertiary rounded-lg",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{className:"bg-bambu-dark sticky top-0",children:i.jsxs("tr",{children:[i.jsx("th",{className:"px-2 py-2 w-10",children:i.jsx("input",{type:"checkbox",checked:z.length>0&&N.size===z.length,onChange:pe,className:"w-4 h-4 accent-bambu-green cursor-pointer"})}),i.jsx("th",{className:"px-4 py-2 text-left text-bambu-gray font-medium",children:t("common.name")}),i.jsx("th",{className:"px-4 py-2 text-right text-bambu-gray font-medium w-24",children:t("settings.catalog.weight")}),i.jsx("th",{className:"px-4 py-2 text-center text-bambu-gray font-medium w-20",children:t("settings.catalog.type")}),i.jsx("th",{className:"px-4 py-2 w-24"})]})}),i.jsx("tbody",{children:z.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:5,className:"px-4 py-8 text-center text-bambu-gray",children:t(o?"settings.catalog.noMatch":"settings.catalog.empty")})}):z.map(be=>i.jsx("tr",{className:`border-t border-bambu-dark-tertiary hover:bg-bambu-dark ${N.has(be.id)?"bg-bambu-dark":""}`,children:m===be.id?i.jsxs(i.Fragment,{children:[i.jsx("td",{className:"px-2 py-2",children:i.jsx("input",{type:"checkbox",checked:N.has(be.id),onChange:()=>me(be.id),className:"w-4 h-4 accent-bambu-green cursor-pointer"})}),i.jsx("td",{className:"px-4 py-2",children:i.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white focus:border-bambu-green focus:outline-none",value:f,onChange:Me=>y(Me.target.value)})}),i.jsx("td",{className:"px-4 py-2",children:i.jsx("input",{type:"number",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-right focus:border-bambu-green focus:outline-none",value:v,onChange:Me=>b(Me.target.value)})}),i.jsx("td",{className:"px-4 py-2 text-center",children:i.jsx("span",{className:"text-xs text-bambu-gray",children:"-"})}),i.jsx("td",{className:"px-4 py-2",children:i.jsxs("div",{className:"flex justify-end gap-1",children:[i.jsx("button",{onClick:()=>ie(be.id),disabled:g,className:"p-1.5 rounded hover:bg-green-500/20 text-green-500",children:g?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Qr,{className:"w-4 h-4"})}),i.jsx("button",{onClick:J,className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray",children:i.jsx(Ht,{className:"w-4 h-4"})})]})})]}):i.jsxs(i.Fragment,{children:[i.jsx("td",{className:"px-2 py-2",children:i.jsx("input",{type:"checkbox",checked:N.has(be.id),onChange:()=>me(be.id),className:"w-4 h-4 accent-bambu-green cursor-pointer"})}),i.jsx("td",{className:"px-4 py-2 text-white",children:be.name}),i.jsxs("td",{className:"px-4 py-2 text-right font-mono text-white",children:[be.weight,"g"]}),i.jsx("td",{className:"px-4 py-2 text-center",children:be.is_default?i.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-bambu-dark-tertiary text-bambu-gray",children:t("settings.catalog.default")}):i.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-bambu-green/20 text-bambu-green",children:t("settings.catalog.custom")})}),i.jsx("td",{className:"px-4 py-2",children:i.jsxs("div",{className:"flex justify-end gap-1",children:[i.jsx("button",{onClick:()=>I(be),className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:i.jsx(Ki,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>R(be),className:"p-1.5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-500",children:i.jsx(en,{className:"w-4 h-4"})})]})})]})},be.id))})]})})]}),k&&i.jsx(_n,{title:t("settings.catalog.deleteEntry"),message:t("settings.catalog.deleteConfirm",{name:k.name}),confirmText:t("common.delete"),variant:"danger",onConfirm:Q,onCancel:()=>R(null)}),C&&i.jsx(_n,{title:t("settings.catalog.deleteSelected"),message:t("settings.catalog.bulkDeleteConfirm",{count:N.size}),confirmText:t("common.delete"),variant:"danger",onConfirm:Y,onCancel:()=>P(!1)}),A&&i.jsx(_n,{title:t("settings.catalog.resetCatalog"),message:t("settings.catalog.resetConfirm"),confirmText:t("common.reset"),variant:"danger",onConfirm:ue,onCancel:()=>D(!1)})]})}function _et(){const{t}=Rt(),{showToast:e}=fn(),[n,r]=w.useState([]),[a,s]=w.useState(!0),[o,l]=w.useState(""),[c,u]=w.useState("Bambu Lab"),d=w.useRef(null),[m,p]=w.useState(!1),[f,y]=w.useState(null),[v,b]=w.useState(""),[g,_]=w.useState(""),[N,T]=w.useState("#FFFFFF"),[C,P]=w.useState(""),[k,R]=w.useState(!1),[A,D]=w.useState(new Set),[B,z]=w.useState(!1),[W,I]=w.useState(!1),[J,ie]=w.useState(null),[Q,ue]=w.useState(null),[me,pe]=w.useState(!1),Y=w.useCallback(async()=>{try{const G=await fe.getColorCatalog();r(G)}catch{e(t("settings.colorCatalog.loadFailed"),"error")}finally{s(!1)}},[e,t]);w.useEffect(()=>{Y()},[Y]);const se=[...new Set(n.map(G=>G.manufacturer))].sort(),oe=n.filter(G=>{const re=o===""||G.manufacturer.toLowerCase().includes(o.toLowerCase())||G.color_name.toLowerCase().includes(o.toLowerCase())||(G.material?.toLowerCase().includes(o.toLowerCase())??!1),ce=c===""||G.manufacturer===c;return re&&ce}),be=()=>{b(""),_(""),T("#FFFFFF"),P("")},Me=async()=>{if(!v.trim()||!g.trim()||!N){e(t("settings.colorCatalog.fieldsRequired"),"error");return}R(!0);try{const G=await fe.addColorEntry({manufacturer:v.trim(),color_name:g.trim(),hex_color:N,material:C.trim()||null});r(re=>[...re,G].sort((ce,ge)=>ce.manufacturer.localeCompare(ge.manufacturer)||(ce.material||"").localeCompare(ge.material||"")||ce.color_name.localeCompare(ge.color_name))),p(!1),be(),e(t("settings.colorCatalog.colorAdded"),"success")}catch{e(t("settings.colorCatalog.addFailed"),"error")}finally{R(!1)}},q=G=>{y(G.id),b(G.manufacturer),_(G.color_name),T(G.hex_color),P(G.material||"")},Z=()=>{y(null),be()},j=async G=>{if(!v.trim()||!g.trim()||!N){e(t("settings.colorCatalog.fieldsRequired"),"error");return}R(!0);try{const re=await fe.updateColorEntry(G,{manufacturer:v.trim(),color_name:g.trim(),hex_color:N,material:C.trim()||null});r(ce=>ce.map(ge=>ge.id===G?re:ge).sort((ge,xe)=>ge.manufacturer.localeCompare(xe.manufacturer)||(ge.material||"").localeCompare(xe.material||"")||ge.color_name.localeCompare(xe.color_name))),y(null),be(),e(t("settings.colorCatalog.colorUpdated"),"success")}catch{e(t("settings.colorCatalog.updateFailed"),"error")}finally{R(!1)}},E=async()=>{if(Q)try{await fe.deleteColorEntry(Q.id),r(G=>G.filter(re=>re.id!==Q.id)),e(t("settings.colorCatalog.colorDeleted"),"success")}catch{e(t("settings.colorCatalog.deleteFailed"),"error")}finally{ue(null)}},U=async()=>{pe(!1),s(!0);try{await fe.resetColorCatalog(),await Y(),e(t("settings.colorCatalog.resetSuccess"),"success")}catch{e(t("settings.colorCatalog.resetFailed"),"error"),s(!1)}},K=async()=>{I(!0),ie(null);try{const G={},re=Ud();re&&(G.Authorization=`Bearer ${re}`);const ce=await fetch("/api/v1/inventory/colors/sync",{method:"POST",headers:G});if(!ce.ok)throw new Error("Failed to start sync");const ge=ce.body?.getReader();if(!ge)throw new Error("No response body");const xe=new TextDecoder;let ae="";for(;;){const{done:L,value:F}=await ge.read();if(L)break;ae+=xe.decode(F,{stream:!0});const te=ae.split(` + `,onClick:ie?()=>{window.innerWidth<640&&d()}:void 0,children:[ie&&u&&i.jsx("div",{className:"sm:hidden absolute left-0 top-3 bottom-3 w-1 rounded-full bg-bambu-green"}),i.jsxs("div",{className:"flex items-start sm:items-center gap-2 sm:gap-4 p-3 sm:p-4",children:[I&&d&&i.jsx("button",{onClick:Q=>{Q.stopPropagation(),d()},className:`hidden sm:flex items-center justify-center w-6 h-6 rounded border transition-colors shrink-0 ${u?"bg-bambu-green border-bambu-green text-white":"border-white/30 bg-black/30 hover:border-bambu-green/50"}`,children:u&&i.jsx(Qr,{className:"w-4 h-4"})}),I?i.jsx("div",{...P,...k,className:"hidden sm:flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation shrink-0",children:i.jsx(Sh,{className:"w-4 h-4 text-bambu-gray"})}):e!==void 0?i.jsxs("div",{className:"hidden sm:flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium shrink-0",children:["#",e]}):i.jsx("div",{className:"hidden sm:block w-8 shrink-0"}),i.jsx("div",{className:"w-10 h-10 sm:w-14 sm:h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?i.jsx("img",{src:t.plate_id!=null?fe.getArchivePlateThumbnail(t.archive_id,t.plate_id):fe.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?i.jsx("img",{src:t.plate_id!=null?fe.getLibraryFilePlateThumbnail(t.library_file_id,t.plate_id):fe.getLibraryFileThumbnailUrl(t.library_file_id),alt:"",className:"w-full h-full object-cover"}):i.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:i.jsx(Vi,{className:"w-5 h-5 sm:w-6 sm:h-6"})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsxs("p",{className:"text-sm sm:text-base text-white font-medium truncate",children:[t.archive_name||t.library_file_name||`File #${t.archive_id||t.library_file_id}`,(N?.is_multi_plate??!1)&&t.plate_id!==void 0&&t.plate_id!==null&&` • ${T.find(Q=>Q.index===t.plate_id)?.name||y("queue.plateNumber",{index:t.plate_id})}`]}),t.archive_id?i.jsx(co,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:y("queue.viewArchive"),children:i.jsx(ti,{className:"w-3.5 h-3.5"})}):t.library_file_id?i.jsx(co,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:y("queue.viewInFileManager"),children:i.jsx(ti,{className:"w-3.5 h-3.5"})}):null]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs sm:text-sm text-bambu-gray",children:[i.jsxs("span",{className:`flex items-center gap-1 sm:gap-1.5 ${t.printer_id===null&&!t.target_model?"text-orange-400":""} ${t.target_model?"text-blue-400":""}`,children:[i.jsx(_r,{className:"w-3 h-3 sm:w-3.5 sm:h-3.5"}),i.jsx("span",{className:"truncate max-w-[120px] sm:max-w-none",children:t.target_model?`${y("queue.filter.any")} ${t.target_model}${t.target_location?` @ ${t.target_location}`:""}${t.required_filament_types?.length?` (${t.required_filament_types.join(", ")})`:""}`:t.printer_id===null?y("queue.filter.unassigned"):t.printer_name||`${y("common.printer")} #${t.printer_id}`})]}),t.print_time_seconds&&i.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[i.jsx(yd,{className:"w-3 h-3 sm:w-3.5 sm:h-3.5"}),Is(t.print_time_seconds)]}),t.filament_used_grams&&i.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[i.jsx(tQ,{className:"w-3 h-3 sm:w-3.5 sm:h-3.5"}),Foe(t.filament_used_grams)]}),t.created_by_username&&i.jsxs("span",{className:"hidden sm:flex items-center gap-1.5",title:y("queue.addedBy",{name:t.created_by_username}),children:[i.jsx(zd,{className:"w-3.5 h-3.5"}),t.created_by_username]}),I&&!t.manual_start&&i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx(Jn,{className:"w-3.5 h-3.5"}),t.scheduled_time?(Zn(t.scheduled_time)?.getTime()??0)-Date.now()<-6e4?y?.("queue.time.overdue")??"Overdue":w0(t.scheduled_time,c,y):y?.("queue.time.asap")??"ASAP"]})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 sm:gap-2 mt-1.5 sm:mt-2",children:[t.manual_start&&i.jsxs("span",{className:"text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded-full border border-purple-500/20 flex items-center gap-1",children:[i.jsx(GX,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3"}),y("queue.badges.staged")]}),t.require_previous_success&&i.jsx("span",{className:"text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20",children:y("queue.badges.requiresPrevious")}),t.auto_off_after&&i.jsxs("span",{className:"text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1",children:[i.jsx(Xd,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3"}),y("queue.badges.autoPowerOff")]})]}),W&&v&&i.jsxs("div",{className:"mt-2 sm:mt-3",children:[i.jsxs("div",{className:"flex items-center justify-between text-xs sm:text-sm",children:[i.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5 sm:h-2 mr-3",children:i.jsx("div",{className:"bg-bambu-green h-1.5 sm:h-2 rounded-full transition-all",style:{width:`${v.progress||0}%`}})}),i.jsxs("span",{className:"text-white",children:[Math.round(v.progress||0),"%"]})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mt-1.5 sm:mt-2 text-[10px] sm:text-xs text-bambu-gray",children:[v.remaining_time!=null&&v.remaining_time>0&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Jn,{className:"w-3 h-3"}),Is(v.remaining_time*60)]}),i.jsxs("span",{className:"text-bambu-green font-medium",title:y("printers.estimatedCompletion"),children:["ETA ",XL(v.remaining_time,c,y)]})]}),v.layer_num!=null&&v.total_layers!=null&&v.total_layers>0&&i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Vi,{className:"w-3 h-3"}),v.layer_num,"/",v.total_layers]})]})]}),t.waiting_reason&&t.status==="pending"&&i.jsxs("p",{className:"text-[10px] sm:text-xs text-purple-400 mt-1.5 sm:mt-2 flex items-start gap-1",children:[i.jsx(Li,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),i.jsx("span",{children:t.waiting_reason})]}),t.error_message&&i.jsxs("p",{className:"text-[10px] sm:text-xs text-red-400 mt-1.5 sm:mt-2 flex items-center gap-1",children:[i.jsx(Li,{className:"w-3 h-3"}),t.error_message]})]}),i.jsxs("div",{className:"flex flex-col sm:flex-row items-end sm:items-center gap-2 sm:gap-1 shrink-0",onClick:Q=>Q.stopPropagation(),children:[i.jsx(HJe,{status:t.status,waitingReason:t.waiting_reason,printerState:f,t:y}),i.jsxs("div",{className:"flex items-center gap-0.5 sm:gap-1",children:[W&&i.jsx(Ie,{variant:"ghost",size:"sm",onClick:s,disabled:!m("printers:control"),title:m("printers:control")?y("queue.actions.stopPrint"):y("queue.permissions.noStopPrint"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 p-1.5 sm:p-2",children:i.jsx(Jhe,{className:"w-4 h-4"})}),I&&i.jsxs(i.Fragment,{children:[t.manual_start&&i.jsx(Ie,{variant:"ghost",size:"sm",onClick:l,disabled:!m("printers:control"),title:m("printers:control")?y("queue.actions.startPrint"):y("queue.permissions.noStartPrint"),className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10 p-1.5 sm:p-2",children:i.jsx(wo,{className:"w-4 h-4"})}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:n,disabled:!p("queue","update",t.created_by_id),title:p("queue","update",t.created_by_id)?y("common.edit"):y("queue.permissions.noEdit"),className:"p-1.5 sm:p-2",children:i.jsx(Ki,{className:"w-4 h-4"})}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:r,disabled:!p("queue","delete",t.created_by_id),title:p("queue","delete",t.created_by_id)?y("common.cancel"):y("queue.permissions.noCancel"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 p-1.5 sm:p-2",children:i.jsx(Ht,{className:"w-4 h-4"})})]}),J&&i.jsxs(i.Fragment,{children:[i.jsx(Ie,{variant:"ghost",size:"sm",onClick:o,disabled:!m("queue:create"),title:m("queue:create")?y("queue.actions.requeue"):y("queue.permissions.noRequeue"),className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10 p-1.5 sm:p-2",children:i.jsx(Sr,{className:"w-4 h-4"})}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:a,disabled:!p("queue","delete",t.created_by_id),title:p("queue","delete",t.created_by_id)?y("common.remove"):y("queue.permissions.noRemove"),className:"p-1.5 sm:p-2",children:i.jsx(en,{className:"w-4 h-4"})})]})]})]})]})]})}function qJe(){const{t}=Rt(),e=sn(),{showToast:n}=fn(),{hasPermission:r,hasAnyPermission:a,canModify:s}=Nr(),[o,l]=w.useState(null),[c,u]=w.useState(""),[d,m]=w.useState(""),[p,f]=w.useState(!1),[y,v]=w.useState(null),[b,g]=w.useState(null),[_,N]=w.useState(null),[T,C]=w.useState([]),[P,k]=w.useState(!1),[R,A]=w.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[D,B]=w.useState(()=>{const L=localStorage.getItem("queue.historySortAsc");return L!==null?L==="true":!1}),[z,W]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[I,J]=w.useState(()=>{const L=localStorage.getItem("queue.pendingSortAsc");return L!==null?L==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",R)},[R]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(D))},[D]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",z)},[z]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(I))},[I]);const ie=uoe(qC(EA,{activationConstraint:{distance:8}}),qC(MA,{coordinateGetter:Doe})),{data:Q}=tt({queryKey:["settings"],queryFn:fe.getSettings}),ue=Q?.time_format||"system",{data:me,isLoading:pe}=tt({queryKey:["queue",o,c],queryFn:()=>fe.getQueue(o||void 0,c||void 0),refetchInterval:5e3}),{data:Y}=tt({queryKey:["printers"],queryFn:()=>fe.getPrinters()}),se=ft({mutationFn:L=>fe.cancelQueueItem(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.cancelled"))},onError:()=>n(t("queue.toast.cancelFailed"),"error")}),oe=ft({mutationFn:L=>fe.removeFromQueue(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.removed"))},onError:()=>n(t("queue.toast.removeFailed"),"error")}),be=ft({mutationFn:L=>fe.stopQueueItem(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.stopped"))},onError:()=>n(t("queue.toast.stopFailed"),"error")}),Me=ft({mutationFn:L=>fe.startQueueItem(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.released"))},onError:()=>n(t("queue.toast.startFailed"),"error")}),q=ft({mutationFn:L=>fe.reorderQueue(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]})},onError:()=>n(t("queue.toast.reorderFailed"),"error")}),Z=ft({mutationFn:async()=>{const L=me?.filter(F=>["completed","failed","skipped","cancelled"].includes(F.status))||[];for(const F of L)await fe.removeFromQueue(F.id);return L.length},onSuccess:L=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.historyCleared",{count:L}))},onError:()=>n(t("queue.toast.clearHistoryFailed"),"error")}),j=ft({mutationFn:L=>fe.bulkUpdateQueue(L),onSuccess:L=>{e.invalidateQueries({queryKey:["queue"]}),C([]),k(!1),n(L.message)},onError:()=>n(t("queue.toast.updateFailed"),"error")}),E=ft({mutationFn:async L=>{for(const F of L)await fe.cancelQueueItem(F);return L.length},onSuccess:L=>{e.invalidateQueries({queryKey:["queue"]}),C([]),n(t("queue.toast.bulkCancelled",{count:L}))},onError:()=>n(t("queue.toast.bulkCancelFailed"),"error")}),U=L=>{C(F=>F.includes(L)?F.filter(te=>te!==L):[...F,L])},K=w.useMemo(()=>{const L=new Set;return Y?.forEach(F=>{F.location&&L.add(F.location)}),me?.forEach(F=>{F.target_location&&L.add(F.target_location)}),Array.from(L).sort()},[Y,me]),$=w.useCallback(L=>d?L.target_location?L.target_location===d:L.printer_id?Y?.find(te=>te.id===L.printer_id)?.location===d:!1:!0,[d,Y]),ne=w.useMemo(()=>{let L=me?.filter(te=>te.status==="pending")||[];d&&(L=L.filter($));const F=te=>{if(!te.scheduled_time)return 0;const ve=Zn(te.scheduled_time)?.getTime()??0,he=Date.now()+4320*60*60*1e3;return ve>he?0:ve};return[...L].sort((te,ve)=>{let he;if(z==="name"){const de=te.archive_name||te.library_file_name||"",ke=ve.archive_name||ve.library_file_name||"";he=de.localeCompare(ke)}else z==="printer"?he=(te.printer_name||"").localeCompare(ve.printer_name||""):z==="time"?he=F(te)-F(ve):he=te.position-ve.position;return I?he:-he})},[me,z,I,$,d]),O=()=>{const L=ne.map(F=>F.id);T.length===L.length?C([]):C(L)},V=w.useMemo(()=>{let L=me?.filter(F=>F.status==="printing")||[];return d&&(L=L.filter($)),L},[me,d,$]),ee=w.useMemo(()=>{const L=new Set;return V.forEach(F=>{F.printer_id&&L.add(F.printer_id)}),Array.from(L)},[V]),G=Yf({queries:ee.map(L=>({queryKey:["printerStatus",L],queryFn:()=>fe.getPrinterStatus(L),refetchInterval:5e3}))}),re=w.useMemo(()=>{const L={};return ee.forEach((F,te)=>{const ve=G[te];ve?.data?.state&&(L[F]=ve.data.state)}),L},[ee,G]),ce=w.useMemo(()=>{let L=me?.filter(F=>["completed","failed","skipped","cancelled"].includes(F.status))||[];return d&&(L=L.filter($)),[...L].sort((F,te)=>{let ve;if(R==="name"){const he=F.archive_name||F.library_file_name||"",de=te.archive_name||te.library_file_name||"";ve=he.localeCompare(de)}else R==="printer"?ve=(F.printer_name||"").localeCompare(te.printer_name||""):ve=(Zn(te.completed_at||te.created_at)?.getTime()??0)-(Zn(F.completed_at||F.created_at)?.getTime()??0);return D?-ve:ve})},[me,R,D,$,d]),ge=w.useMemo(()=>ne.reduce((L,F)=>L+(F.print_time_seconds||0),0),[ne]),xe=w.useMemo(()=>ne.reduce((L,F)=>L+(F.filament_used_grams||0),0),[ne]),ae=L=>{const{active:F,over:te}=L;if(!te||F.id===te.id)return;const ve=ne.findIndex(de=>de.id===F.id),he=ne.findIndex(de=>de.id===te.id);if(ve!==-1&&he!==-1){const ke=RA(ne,ve,he).map((_e,Le)=>({id:_e.id,position:Le+1}));q.mutate(ke)}};return i.jsxs("div",{className:"p-4 md:p-8",children:[i.jsx("div",{className:"flex items-center justify-between mb-8",children:i.jsxs("div",{children:[i.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[i.jsx(WX,{className:"w-7 h-7 text-bambu-green"}),t("queue.title")]}),i.jsx("p",{className:"text-bambu-gray mt-1",children:t("queue.subtitle")})]})}),i.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-2 sm:gap-3 lg:gap-4 mb-8",children:[i.jsx(Pt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:i.jsx(Et,{className:"p-3 sm:p-4",children:i.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[i.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-blue-500/20 flex items-center justify-center shrink-0",children:i.jsx(wo,{className:"w-4 h-4 sm:w-5 sm:h-5 text-blue-400"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:V.length}),i.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.printing")})]})]})})}),i.jsx(Pt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:i.jsx(Et,{className:"p-3 sm:p-4",children:i.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[i.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center shrink-0",children:i.jsx(Jn,{className:"w-4 h-4 sm:w-5 sm:h-5 text-yellow-400"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:ne.length}),i.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.queued")})]})]})})}),i.jsx(Pt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:i.jsx(Et,{className:"p-3 sm:p-4",children:i.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[i.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center shrink-0",children:i.jsx(yd,{className:"w-4 h-4 sm:w-5 sm:h-5 text-bambu-green"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:Is(ge)}),i.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.totalTime")})]})]})})}),i.jsx(Pt,{className:"bg-gradient-to-br from-purple-500/10 to-transparent border-purple-500/20",children:i.jsx(Et,{className:"p-3 sm:p-4",children:i.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[i.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-purple-500/20 flex items-center justify-center shrink-0",children:i.jsx(tQ,{className:"w-4 h-4 sm:w-5 sm:h-5 text-purple-500"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:Foe(xe)}),i.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.totalWeight")})]})]})})}),i.jsx(Pt,{className:"col-span-2 sm:col-span-1 bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:i.jsx(Et,{className:"p-3 sm:p-4",children:i.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[i.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-gray-500/20 flex items-center justify-center shrink-0",children:i.jsx(fr,{className:"w-4 h-4 sm:w-5 sm:h-5 text-gray-400"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:ce.length}),i.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.history")})]})]})})})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-4 mb-6",children:[i.jsxs("select",{className:"px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none",value:o===-1?"unassigned":o||"",onChange:L=>{const F=L.target.value;l(F==="unassigned"?-1:F===""?null:Number(F))},children:[i.jsx("option",{value:"",children:t("queue.filter.allPrinters")}),i.jsx("option",{value:"unassigned",children:t("queue.filter.unassigned")}),Y?.map(L=>i.jsx("option",{value:L.id,children:L.name},L.id))]}),i.jsxs("select",{className:"px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none",value:c,onChange:L=>u(L.target.value),children:[i.jsx("option",{value:"",children:t("queue.filter.allStatus")}),i.jsx("option",{value:"pending",children:t("queue.status.pending")}),i.jsx("option",{value:"printing",children:t("queue.status.printing")}),i.jsx("option",{value:"completed",children:t("queue.status.completed")}),i.jsx("option",{value:"failed",children:t("queue.status.failed")}),i.jsx("option",{value:"skipped",children:t("queue.status.skipped")}),i.jsx("option",{value:"cancelled",children:t("queue.status.cancelled")})]}),K.length>0&&i.jsxs("select",{className:"px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none",value:d,onChange:L=>m(L.target.value),children:[i.jsx("option",{value:"",children:t("queue.filter.allLocations")}),K.map(L=>i.jsx("option",{value:L,children:L},L))]}),i.jsx("div",{className:"hidden sm:block flex-1"}),ce.length>0&&i.jsxs(Ie,{className:"w-full sm:w-auto",variant:"secondary",size:"sm",onClick:()=>f(!0),disabled:!r("queue:delete_all"),title:r("queue:delete_all")?void 0:t("queue.permissions.noClearHistory"),children:[i.jsx(en,{className:"w-4 h-4"}),t("queue.clearHistory")]})]}),pe?i.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):me?.length===0?i.jsxs(Pt,{className:"p-12 text-center border-dashed",children:[i.jsx(Yr,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),i.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:t("queue.empty.title")}),i.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:t("queue.empty.description")})]}):i.jsxs("div",{className:"space-y-6 sm:space-y-8",children:[V.length>0&&i.jsxs("div",{children:[i.jsxs("h2",{className:"text-base sm:text-lg font-semibold text-white mb-3 sm:mb-4 flex items-center gap-2",children:[i.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),t("queue.sections.currentlyPrinting")]}),i.jsx("div",{className:"space-y-2 sm:space-y-3",children:V.map(L=>i.jsx(ID,{item:L,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>N({type:"stop",item:L}),onRequeue:()=>{},onStart:()=>{},timeFormat:ue,hasPermission:r,canModify:s,printerState:L.printer_id?re[L.printer_id]:null,t},L.id))})]}),ne.length>0&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3 sm:mb-4",children:[i.jsxs("h2",{className:"text-base sm:text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(Jn,{className:"w-4 h-4 sm:w-5 sm:h-5 text-yellow-400"}),t("queue.sections.queued"),i.jsxs("span",{className:"text-xs sm:text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:ne.length}),")"]}),i.jsx("span",{className:"hidden sm:inline text-xs text-bambu-gray ml-2",title:t("queue.reorderHint"),children:t("queue.dragToReorder")})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("select",{className:"px-2 sm:px-3 py-1.5 text-xs sm:text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:z,onChange:L=>W(L.target.value),children:[i.jsx("option",{value:"position",children:t("queue.sort.byPosition")}),i.jsx("option",{value:"name",children:t("queue.sort.byName")}),i.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")}),i.jsx("option",{value:"time",children:t("queue.sort.bySchedule")})]}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>J(!I),title:t(I?"common.ascending":"common.descending"),className:"px-2",children:I?i.jsx(Sf,{className:"w-4 h-4"}):i.jsx(rx,{className:"w-4 h-4"})})]})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mb-3 sm:mb-4 p-2 sm:p-3 bg-bambu-dark rounded-lg",children:[i.jsxs(Ie,{variant:"ghost",size:"sm",onClick:O,className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm",children:[T.length===ne.length&&ne.length>0?i.jsx(_o,{className:"w-4 h-4 text-bambu-green"}):i.jsx(ql,{className:"w-4 h-4"}),T.length===ne.length&&ne.length>0?t("queue.bulkEdit.deselectAll"):t("queue.bulkEdit.selectAll")]}),T.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-xs sm:text-sm text-bambu-gray",children:t("queue.bulkEdit.selected",{count:T.length})}),i.jsx("div",{className:"hidden sm:block h-4 w-px bg-bambu-dark-tertiary"}),i.jsxs(Ie,{variant:"ghost",size:"sm",onClick:()=>k(!0),className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm text-bambu-green hover:text-bambu-green-light",disabled:!a("queue:update_own","queue:update_all"),title:a("queue:update_own","queue:update_all")?t("queue.bulkEdit.editSelected"):t("queue.permissions.noEditItems"),children:[i.jsx(Ki,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("queue.bulkEdit.editSelected")})]}),i.jsxs(Ie,{variant:"ghost",size:"sm",onClick:()=>E.mutate(T),className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm text-red-400 hover:text-red-300",disabled:E.isPending||!a("queue:delete_own","queue:delete_all"),title:a("queue:delete_own","queue:delete_all")?t("queue.bulkEdit.cancelSelected"):t("queue.permissions.noCancelItems"),children:[i.jsx(Ht,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("queue.bulkEdit.cancelSelected")})]})]})]}),i.jsx(Toe,{sensors:ie,collisionDetection:poe,onDragEnd:ae,children:i.jsx(Moe,{items:ne.map(L=>L.id),strategy:EJe,children:i.jsx("div",{className:"space-y-2 sm:space-y-3",children:ne.map((L,F)=>i.jsx(ID,{item:L,position:F+1,onEdit:()=>v(L),onCancel:()=>N({type:"cancel",item:L}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>Me.mutate(L.id),timeFormat:ue,isSelected:T.includes(L.id),onToggleSelect:()=>U(L.id),hasPermission:r,canModify:s,t},L.id))})})})]}),ce.length>0&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3 sm:mb-4",children:[i.jsxs("h2",{className:"text-base sm:text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(fr,{className:"w-4 h-4 sm:w-5 sm:h-5 text-bambu-gray"}),t("queue.sections.history"),i.jsxs("span",{className:"text-xs sm:text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:ce.length}),")"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("select",{className:"px-2 sm:px-3 py-1.5 text-xs sm:text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:R,onChange:L=>A(L.target.value),children:[i.jsx("option",{value:"date",children:t("queue.sort.byDate")}),i.jsx("option",{value:"name",children:t("queue.sort.byName")}),i.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")})]}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>B(!D),title:t(D?"queue.sort.ascendingOldest":"queue.sort.descendingNewest"),className:"px-2",children:D?i.jsx(Sf,{className:"w-4 h-4"}):i.jsx(rx,{className:"w-4 h-4"})})]})]}),i.jsx("div",{className:"space-y-2 sm:space-y-3",children:ce.slice(0,20).map((L,F)=>i.jsx(ID,{item:L,position:F+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>N({type:"remove",item:L}),onStop:()=>{},onRequeue:()=>g(L),onStart:()=>{},timeFormat:ue,hasPermission:r,canModify:s,t},L.id))})]})]}),y&&i.jsx(bu,{mode:"edit-queue-item",archiveId:y.archive_id??void 0,libraryFileId:y.library_file_id??void 0,archiveName:y.archive_name||y.library_file_name||`File #${y.archive_id||y.library_file_id}`,queueItem:y,onClose:()=>v(null)}),b&&i.jsx(bu,{mode:"add-to-queue",archiveId:b.archive_id??void 0,libraryFileId:b.library_file_id??void 0,archiveName:b.archive_name||b.library_file_name||`File #${b.archive_id||b.library_file_id}`,onClose:()=>g(null)}),_&&i.jsx(_n,{title:_.type==="cancel"?t("queue.confirm.cancelTitle"):_.type==="stop"?t("queue.confirm.stopTitle"):t("queue.confirm.removeTitle"),message:_.type==="cancel"?t("queue.confirm.cancelMessage",{name:_.item.archive_name||_.item.library_file_name||t("queue.confirm.thisPrint")}):_.type==="stop"?t("queue.confirm.stopMessage",{name:_.item.archive_name||_.item.library_file_name||t("queue.confirm.thisPrint")}):t("queue.confirm.removeMessage",{name:_.item.archive_name||_.item.library_file_name||t("queue.confirm.thisItem")}),confirmText:_.type==="cancel"?t("queue.confirm.cancelButton"):_.type==="stop"?t("queue.confirm.stopButton"):t("common.remove"),variant:"danger",onConfirm:()=>{_.type==="cancel"?se.mutate(_.item.id):_.type==="stop"?be.mutate(_.item.id):oe.mutate(_.item.id),N(null)},onCancel:()=>N(null)}),p&&i.jsx(_n,{title:t("queue.confirm.clearHistoryTitle"),message:t("queue.confirm.clearHistoryMessage",{count:ce.length}),confirmText:t("queue.clearHistory"),variant:"danger",onConfirm:()=>{Z.mutate(),f(!1)},onCancel:()=>f(!1)}),P&&i.jsx($Je,{selectedCount:T.length,printers:Y?.map(L=>({id:L.id,name:L.name}))||[],onSave:L=>{Object.keys(L).length>0&&j.mutate({item_ids:T,...L})},onClose:()=>k(!1),isSaving:j.isPending,canControlPrinter:r("printers:control"),t})]})}function VJe({printDates:t,months:e=3}){const n=w.useRef(null),[r,a]=w.useState(0);w.useEffect(()=>{const _=n.current;if(!_)return;const N=new ResizeObserver(T=>{const C=T[0]?.contentRect.width||0;a(C)});return N.observe(_),()=>N.disconnect()},[]);const{weeks:s,monthLabels:o,printCounts:l}=w.useMemo(()=>{const _={};t.forEach(B=>{const z=B.split("T")[0];_[z]=(_[z]||0)+1});const N=new Date,T=new Date(N);T.setMonth(T.getMonth()-e),T.setDate(T.getDate()-T.getDay());const C=[],P=[];let k=[],R=-1;const A=new Date(T);let D=0;for(;A<=N;)A.getDay()===0&&k.length>0&&(C.push(k),k=[],D++),A.getMonth()!==R&&(P.push({month:A.toLocaleDateString("en-US",{month:"short"}),weekIndex:D}),R=A.getMonth()),k.push(new Date(A)),A.setDate(A.getDate()+1);return k.length>0&&C.push(k),{weeks:C,monthLabels:P,printCounts:_}},[t,e]),c=Math.max(1,...Object.values(l)),u=_=>{if(_===0)return"bg-bambu-dark";const N=_/c;return N<=.25?"bg-bambu-green/30":N<=.5?"bg-bambu-green/50":N<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],m=s.length,p=32,f=2,y=r-p-16,v=m>0?Math.floor((y-(m-1)*f)/m):12,b=Math.max(8,Math.min(20,v)),g=b<=10?10:12;return i.jsx("div",{ref:n,className:"w-full flex justify-center",children:r>0&&i.jsxs("div",{children:[i.jsx("div",{className:"flex mb-1",style:{marginLeft:p+4},children:o.map(({month:_,weekIndex:N},T)=>i.jsx("div",{className:"text-bambu-gray",style:{fontSize:g,marginLeft:T===0?0:`${(N-(o[T-1]?.weekIndex||0))*(b+f)-24}px`},children:_},T))}),i.jsxs("div",{className:"flex",style:{gap:f},children:[i.jsx("div",{className:"flex flex-col",style:{gap:f,marginRight:4,width:p},children:d.map((_,N)=>i.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:p,height:b,fontSize:g,visibility:N%2===1?"visible":"hidden"},children:_},_))}),s.map((_,N)=>i.jsx("div",{className:"flex flex-col",style:{gap:f},children:[0,1,2,3,4,5,6].map(T=>{const C=_.find(A=>A.getDay()===T);if(!C)return i.jsx("div",{style:{width:b,height:b}},T);const P=C.toISOString().split("T")[0],k=l[P]||0,R=P===new Date().toISOString().split("T")[0];return i.jsx("div",{className:`rounded-sm ${u(k)} ${R?"ring-1 ring-white":""}`,style:{width:b,height:b},title:`${C.toLocaleDateString()}: ${k} print${k!==1?"s":""}`},T)})},N))]}),i.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:g},children:[i.jsx("span",{children:"Less"}),i.jsxs("div",{className:"flex",style:{gap:f},children:[i.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:b,height:b}}),i.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:b,height:b}}),i.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:b,height:b}}),i.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:b,height:b}}),i.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:b,height:b}})]}),i.jsx("span",{children:"More"})]})]})})}const _Y=["weight","prints","time"];function WC({value:t,onChange:e,exclude:n}){const{t:r}=Rt(),a={weight:r("stats.filamentByWeight"),prints:r("stats.filamentByPrints"),time:r("stats.filamentByTime")},s=n?_Y.filter(o=>!n.includes(o)):_Y;return i.jsx("div",{className:"flex gap-0.5 bg-bambu-dark rounded-lg p-0.5",children:s.map(o=>i.jsx("button",{onClick:()=>e(o),className:`px-2 py-0.5 text-xs rounded-md transition-colors ${t===o?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:a[o]},o))})}function sh(t){if(t>=1e6){const e=t/1e6;return`${e%1===0?e.toFixed(0):e.toFixed(1)}t`}if(t>=1e3){const e=t/1e3;return`${e%1===0?e.toFixed(0):e.toFixed(1)}kg`}return`${Math.round(t)}g`}const V1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"],GJe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],NY=["12am","1am","2am","3am","4am","5am","6am","7am","8am","9am","10am","11am","12pm","1pm","2pm","3pm","4pm","5pm","6pm","7pm","8pm","9pm","10pm","11pm"];function WJe({archives:t,currency:e="$",dateFrom:n,dateTo:r}){const{t:a}=Rt(),[s,o]=w.useState("weight"),[l,c]=w.useState("weight"),u=w.useMemo(()=>{const R=new Map;return t.forEach(A=>{const D=Zn(A.completed_at||A.created_at)||new Date,B=`${D.getFullYear()}-${String(D.getMonth()+1).padStart(2,"0")}-${String(D.getDate()).padStart(2,"0")}`,z=R.get(B)||{date:B,filament:0,cost:0,prints:0};z.filament+=A.filament_used_grams||0,z.cost+=A.cost||0,z.prints+=A.quantity||1,R.set(B,z)}),Array.from(R.values()).sort((A,D)=>A.date.localeCompare(D.date)).map(A=>({...A,dateLabel:new Date(A.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[t]),d=w.useMemo(()=>{if(n&&r)return Math.max((new Date(r).getTime()-new Date(n).getTime())/864e5,0)+1;if(n)return Math.max((Date.now()-new Date(n).getTime())/864e5,0)+1;if(t.length<2)return 0;const R=t.map(A=>new Date(A.completed_at||A.created_at).getTime());return(Math.max(...R)-Math.min(...R))/864e5},[t,n,r]),m=w.useMemo(()=>{if(d>7)return[];const R=new Map,A=d>1;return t.forEach(D=>{const B=Zn(D.completed_at||D.created_at)||new Date,z=B.getHours(),W=`${B.getFullYear()}-${String(B.getMonth()+1).padStart(2,"0")}-${String(B.getDate()).padStart(2,"0")}T${String(z).padStart(2,"0")}`,I=R.get(W)||{date:W,filament:0,cost:0,prints:0};I.filament+=D.filament_used_grams||0,I.cost+=D.cost||0,I.prints+=D.quantity||1,R.set(W,I)}),Array.from(R.values()).sort((D,B)=>D.date.localeCompare(B.date)).map(D=>{const[B,z]=D.date.split("T"),W=new Date(B),I=parseInt(z,10),J=A?`${GJe[W.getDay()]} ${NY[I]}`:NY[I];return{...D,dateLabel:J}})},[t,d]),p=w.useMemo(()=>{if(u.length<=60)return u;const R=new Map;return u.forEach(A=>{const D=new Date(A.date),B=new Date(D);B.setDate(D.getDate()-D.getDay());const z=`${B.getFullYear()}-${String(B.getMonth()+1).padStart(2,"0")}-${String(B.getDate()).padStart(2,"0")}`,W=R.get(z)||{week:z,filament:0,cost:0,prints:0};W.filament+=A.filament,W.cost+=A.cost,W.prints+=A.prints,R.set(z,W)}),Array.from(R.values()).sort((A,D)=>A.week.localeCompare(D.week)).map(A=>({date:A.week,dateLabel:`Week of ${new Date(A.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...A}))},[u]),f=w.useMemo(()=>{const R=new Map;return t.forEach(A=>{const B=(A.filament_type||"Unknown").split(", ");B.forEach(z=>{const W=(A.filament_used_grams||0)/B.length;R.set(z,(R.get(z)||0)+W)})}),Array.from(R.entries()).map(([A,D])=>({name:A,value:Math.round(D)})).sort((A,D)=>D.value-A.value)},[t]),y=w.useMemo(()=>{const R=new Map;return t.forEach(A=>{(A.filament_type||"Unknown").split(", ").forEach(z=>{R.set(z,(R.get(z)||0)+1)})}),Array.from(R.entries()).map(([A,D])=>({name:A,value:D})).sort((A,D)=>D.value-A.value)},[t]),v=w.useMemo(()=>{const R=new Map;return t.forEach(A=>{const B=(A.filament_type||"Unknown").split(", "),z=(A.actual_time_seconds||A.print_time_seconds||0)/B.length;B.forEach(W=>{R.set(W,(R.get(W)||0)+z)})}),Array.from(R.entries()).map(([A,D])=>({name:A,value:Math.round(D/3600*10)/10})).sort((A,D)=>D.value-A.value)},[t]),b=w.useMemo(()=>{const R=new Map;return t.forEach(A=>{if(A.status!=="completed"&&A.status!=="failed")return;(A.filament_type||"Unknown").split(", ").forEach(B=>{const z=R.get(B)||{completed:0,failed:0};A.status==="completed"?z.completed++:z.failed++,R.set(B,z)})}),Array.from(R.entries()).filter(([,A])=>A.completed+A.failed>=2).map(([A,D])=>{const B=D.completed+D.failed,z=Math.round(D.completed/B*100);return{name:A,rate:z,total:B}}).sort((A,D)=>D.rate-A.rate)},[t]),g=w.useMemo(()=>{const R=new Map;return t.forEach(A=>{if(!A.filament_color)return;const D=A.filament_color.split(",").map(z=>z.trim()),B=(A.filament_used_grams||0)/D.length;D.forEach(z=>{const W=R.get(z)||{count:0,weight:0};W.count++,W.weight+=B,R.set(z,W)})}),Array.from(R.entries()).map(([A,D])=>({hex:A,value:l==="prints"?D.count:Math.round(D.weight)})).sort((A,D)=>D.value-A.value)},[t,l]),_=s==="weight"?f:s==="prints"?y:v,N=d<=7&&m.length>0?m:p,T=t.reduce((R,A)=>R+(A.filament_used_grams||0),0),C=t.reduce((R,A)=>R+(A.cost||0),0),P=t.reduce((R,A)=>R+(A.quantity||1),0),k=new Set(t.map(R=>R.printer_id).filter(Boolean)).size;return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-3 gap-2 max-[640px]:grid-cols-1",children:[i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:a("stats.periodFilament")}),i.jsx("p",{className:"text-2xl font-bold text-white leading-none",children:sh(T)})]}),i.jsxs("p",{className:"text-xs text-bambu-gray",children:[k," ",a("nav.printers").toLowerCase()]})]}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:a("stats.periodCost")}),i.jsxs("p",{className:"text-2xl font-bold text-white leading-none",children:[e,C.toFixed(2)]})]}),i.jsxs("p",{className:"text-xs text-bambu-gray",children:[P," ",a("common.prints")]})]}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:a("stats.avgPerPrint")}),i.jsxs("p",{className:"text-2xl font-bold text-white leading-none",children:[P>0?(T/P).toFixed(0):0,"g"]})]}),i.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,P>0?(C/P).toFixed(2):"0.00"," avg"]})]})]}),N.length>0?i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:a("stats.usageOverTime")}),i.jsx(mh,{width:"100%",height:250,children:i.jsxs(Cqe,{data:N,children:[i.jsx("defs",{children:i.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[i.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),i.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),i.jsx(Qp,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),i.jsx(Zp,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),i.jsx(Jp,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:R=>`${R}g`}),i.jsx(hh,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:R=>[`${Number(R??0).toFixed(0)}g`,"Filament"]}),i.jsx(Are,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):i.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:a("stats.noPrintDataInRange")}),i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h4",{className:"text-sm font-medium text-bambu-gray",children:a("stats.byMaterial")}),i.jsx(WC,{value:s,onChange:o})]}),_.length>0?i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(mh,{width:160,height:160,children:i.jsxs(aW,{children:[i.jsx(SF,{data:_,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:_.map((R,A)=>i.jsx(Nx,{fill:V1[A%V1.length]},`cell-${A}`))}),i.jsx(hh,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:R=>[s==="weight"?sh(Number(R??0)):s==="time"?`${Number(R??0)}h`:`${R??0}`,s==="weight"?"Usage":s==="time"?"Time":"Prints"]})]})}),i.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:_.map((R,A)=>{const D=_.reduce((z,W)=>z+W.value,0),B=D>0?(R.value/D*100).toFixed(0):0;return i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:V1[A%V1.length]}}),i.jsx("span",{className:"text-white truncate flex-1",children:R.name}),i.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[s==="weight"?sh(R.value):s==="time"?`${R.value}h`:R.value," · ",B,"%"]})]},R.name)})})]}):i.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:a("stats.noFilamentData")})]}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:a("stats.filamentSuccess")}),b.length>0?i.jsx("div",{className:"space-y-1.5",children:b.map(R=>i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx("span",{className:"text-white truncate w-20 flex-shrink-0",children:R.name}),i.jsx("div",{className:"flex-1 h-1.5 bg-bambu-dark-secondary rounded-full",children:i.jsx("div",{className:`h-full rounded-full transition-all ${R.rate>=90?"bg-status-ok":R.rate>=70?"bg-status-warning":"bg-status-error"}`,style:{width:`${R.rate}%`}})}),i.jsxs("span",{className:`font-medium flex-shrink-0 tabular-nums ${R.rate>=90?"text-status-ok":R.rate>=70?"text-status-warning":"text-status-error"}`,children:[R.rate,"%"]}),i.jsxs("span",{className:"text-bambu-gray flex-shrink-0 text-xs",children:["(",R.total,")"]})]},R.name))}):i.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:a("stats.noArchiveData")})]}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h4",{className:"text-sm font-medium text-bambu-gray",children:a("stats.colorDistribution")}),i.jsx(WC,{value:l,onChange:c,exclude:["time"]})]}),g.length>0?(()=>{const R=g.reduce((A,D)=>A+D.value,0);return i.jsxs("div",{children:[i.jsxs("div",{className:"relative mx-auto",style:{width:160,height:160},children:[i.jsx(mh,{width:"100%",height:"100%",children:i.jsxs(aW,{children:[i.jsx(SF,{data:g,cx:"50%",cy:"50%",innerRadius:45,outerRadius:70,paddingAngle:2,dataKey:"value",children:g.map((A,D)=>i.jsx(Nx,{fill:A.hex,stroke:"#1a1a1a",strokeWidth:1},`color-${D}`))}),i.jsx(hh,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:A=>[l==="weight"?sh(Number(A??0)):`${A??0}`,a(l==="weight"?"stats.filamentByWeight":"stats.filamentByPrints")]})]})}),i.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[i.jsx("span",{className:"text-lg font-bold text-white",children:l==="weight"?sh(R):R}),i.jsxs("span",{className:"text-[10px] text-bambu-gray",children:[g.length," ",g.length===1?"color":"colors"]})]})]}),i.jsx("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1 mt-2",children:g.slice(0,8).map(A=>{const D=R>0?(A.value/R*100).toFixed(0):0;return i.jsxs("div",{className:"flex items-center gap-1.5 text-xs min-w-0",children:[i.jsx("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0 border border-black/20",style:{backgroundColor:A.hex}}),i.jsxs("span",{className:"text-bambu-gray truncate",children:[D,"%"]})]},A.hex)})}),g.length>8&&i.jsxs("p",{className:"text-[10px] text-bambu-gray mt-1 text-center",children:["+",g.length-8," more"]})]})})():i.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:a("stats.noColorData")})]})]})]})}function KJe({id:t,title:e,component:n,isHidden:r,size:a,columnSpan:s,onToggleVisibility:o,onToggleSize:l}){const{attributes:c,listeners:u,setNodeRef:d,transform:m,transition:p,isDragging:f}=joe({id:t}),y={transform:jx.Transform.toString(m),transition:p,opacity:f?.5:1};return r?null:i.jsxs("div",{ref:d,style:{...y,gridColumn:`span ${s}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${f?"ring-2 ring-bambu-green shadow-lg":""}`,children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{...c,...u,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:i.jsx(Sh,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),i.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{onClick:l,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${a===1?"1/4":a===2?"1/2":"Full"} - Click to cycle`,children:a===4?i.jsx($L,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):i.jsx(tT,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),i.jsx("button",{onClick:o,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:i.jsx(fw,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),i.jsx("div",{className:"p-4",children:typeof n=="function"?n(a):n})]})}function YJe({widgets:t,storageKey:e,columns:n=4,stackBelow:r,hideControls:a=!1,onResetLayout:s,renderControls:o}){const l=()=>{const R={};return t.forEach(A=>{R[A.id]=A.defaultSize||4}),R},[c,u]=w.useState(()=>{const R=localStorage.getItem(e);if(R)try{const A=JSON.parse(R);if(!A.sizes)A.sizes=l();else{const D=l();for(const B in D)B in A.sizes||(A.sizes[B]=D[B])}return A}catch{}return{order:t.map(A=>A.id),hidden:t.filter(A=>A.defaultVisible===!1).map(A=>A.id),sizes:l()}}),[d,m]=w.useState(!1),[p,f]=w.useState(!1);w.useEffect(()=>{if(!r)return;const R=window.matchMedia(`(max-width: ${r}px)`),A=B=>{f(B.matches)};A(R);const D=B=>A(B);return R.addEventListener?R.addEventListener("change",D):R.addListener(D),()=>{R.removeEventListener?R.removeEventListener("change",D):R.removeListener(D)}},[r]);const y=r&&p?1:n;w.useEffect(()=>{const R=()=>m(A=>!A);return window.addEventListener("toggle-hidden-panel",R),()=>window.removeEventListener("toggle-hidden-panel",R)},[]),w.useEffect(()=>{localStorage.setItem(e,JSON.stringify(c))},[c,e]),w.useEffect(()=>{const A=t.map(D=>D.id).filter(D=>!c.order.includes(D));A.length>0&&u(D=>({...D,order:[...D.order,...A]}))},[t,c.order]);const v=uoe(qC(EA,{activationConstraint:{distance:8}}),qC(MA,{coordinateGetter:Doe})),b=R=>{const{active:A,over:D}=R;D&&A.id!==D.id&&u(B=>{const z=B.order.indexOf(A.id),W=B.order.indexOf(D.id);return{...B,order:RA(B.order,z,W)}})},g=R=>{u(A=>({...A,hidden:A.hidden.includes(R)?A.hidden.filter(D=>D!==R):[...A.hidden,R]}))},_=R=>{u(A=>{const D=A.sizes[R]||4,B=D===1?2:D===2?4:1;return{...A,sizes:{...A.sizes,[R]:B}}})},N=()=>{const R={order:t.map(A=>A.id),hidden:t.filter(A=>A.defaultVisible===!1).map(A=>A.id),sizes:l()};u(R),s?.()},T=c.order.map(R=>t.find(A=>A.id===R)).filter(Boolean),C=T.filter(R=>!c.hidden.includes(R.id)),P=T.filter(R=>c.hidden.includes(R.id)),k=o?.({hiddenCount:P.length,showHiddenPanel:d,setShowHiddenPanel:m,resetLayout:N});return i.jsxs("div",{className:"space-y-4",children:[k,!a&&!o&&i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:N,children:[i.jsx(So,{className:"w-4 h-4"}),"Reset Layout"]}),P.length>0&&i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>m(!d),children:[i.jsx(Ac,{className:"w-4 h-4"}),P.length," Hidden"]})]}),d&&P.length>0&&i.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[i.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:P.map(R=>i.jsxs("button",{onClick:()=>g(R.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[i.jsx(Ac,{className:"w-3 h-3"}),R.title]},R.id))})]}),i.jsx(Toe,{sensors:v,collisionDetection:poe,onDragEnd:b,children:i.jsx(Moe,{items:C.map(R=>R.id),strategy:k5,children:i.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${y}, minmax(0, 1fr))`},children:C.map(R=>{const A=c.sizes[R.id]||2,D=Math.min(A,y);return i.jsx(KJe,{id:R.id,title:R.title,component:R.component,isHidden:c.hidden.includes(R.id),size:A,columnSpan:D,onToggleVisibility:()=>g(R.id),onToggleSize:()=>_(R.id)},R.id)})})})}),C.length===0&&i.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[i.jsx("p",{children:"All widgets are hidden."}),i.jsx(Ie,{className:"mt-4",onClick:N,children:"Reset Layout"})]})]})}function XJe(t){const e=new Date,n=e.getUTCFullYear(),r=e.getUTCMonth(),a=e.getUTCDate(),s=l=>l.toISOString().split("T")[0],o=s(e);switch(t){case"today":return{dateFrom:o,dateTo:o};case"this-week":{const l=e.getUTCDay(),c=new Date(Date.UTC(n,r,a-(l===0?6:l-1)));return{dateFrom:s(c),dateTo:o}}case"this-month":return{dateFrom:s(new Date(Date.UTC(n,r,1))),dateTo:o};case"last-7":return{dateFrom:s(new Date(Date.UTC(n,r,a-6))),dateTo:o};case"last-30":return{dateFrom:s(new Date(Date.UTC(n,r,a-29))),dateTo:o};case"last-90":return{dateFrom:s(new Date(Date.UTC(n,r,a-89))),dateTo:o};case"this-year":return{dateFrom:s(new Date(Date.UTC(n,0,1))),dateTo:o};case"all-time":return{dateFrom:void 0,dateTo:void 0};case"custom":return{}}}const QJe=["today","this-week","this-month","last-7","last-30","last-90","this-year","all-time"],ZJe=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],yL=["12am","1am","2am","3am","4am","5am","6am","7am","8am","9am","10am","11am","12pm","1pm","2pm","3pm","4pm","5pm","6pm","7pm","8pm","9pm","10pm","11pm"],zD=[{key:"<30m",max:1800},{key:"30m-1h",max:3600},{key:"1-2h",max:7200},{key:"2-4h",max:14400},{key:"4-8h",max:28800},{key:"8-12h",max:43200},{key:"12-24h",max:86400},{key:"24h+",max:1/0}],G1={backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"};function JJe({stats:t,currency:e}){const{t:n}=Rt(),r=[{icon:Gi,color:"text-bambu-green",label:n("stats.totalPrints"),value:`${t?.total_prints||0}`},{icon:Jn,color:"text-blue-400",label:n("stats.printTime"),value:`${t?.total_print_time_hours?.toFixed(1)??"0"}h`},{icon:Gi,color:"text-orange-400",label:n("stats.filamentUsed"),value:sh(t?.total_filament_grams||0)},{icon:EN,color:"text-green-400",label:n("stats.filamentCost"),value:`${e} ${t?.total_cost?.toFixed(2)??"0.00"}`},{icon:Mc,color:"text-yellow-400",label:n("stats.energyUsed"),value:`${t?.total_energy_kwh?.toFixed(3)??"0.000"} kWh`},{icon:EN,color:"text-yellow-500",label:n("stats.energyCost"),value:`${e} ${t?.total_energy_cost?.toFixed(2)??"0.00"}`}];return i.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:r.map(a=>i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${a.color}`,children:i.jsx(a.icon,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-xs text-bambu-gray",children:a.label}),i.jsx("p",{className:"text-xl font-bold text-white",children:a.value})]})]},a.label))})}function eet({stats:t,printerMap:e,size:n=1}){const{t:r}=Rt(),a=(t?.successful_prints||0)+(t?.failed_prints||0),s=a?Math.round(t.successful_prints/a*100):0,o=n===1?112:n===2?128:144,l=o/2-8,c=l*2*Math.PI;return i.jsxs("div",{className:"flex items-center gap-6",children:[i.jsxs("div",{className:"relative flex-shrink-0",style:{width:o,height:o},children:[i.jsxs("svg",{className:"w-full h-full -rotate-90",children:[i.jsx("circle",{cx:o/2,cy:o/2,r:l,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),i.jsx("circle",{cx:o/2,cy:o/2,r:l,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${s/100*c} ${c}`})]}),i.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:i.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[s,"%"]})})]}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(fr,{className:"w-4 h-4 text-status-ok flex-shrink-0"}),i.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.successful")}),i.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(qi,{className:"w-4 h-4 text-status-error flex-shrink-0"}),i.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.failed")}),i.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]}),n>=2&&t?.prints_by_printer&&Object.keys(t.prints_by_printer).length>0&&i.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[i.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:r("stats.printsByPrinter")}),i.jsx("div",{className:`grid gap-x-6 gap-y-1 ${n===4?"grid-cols-3":"grid-cols-2"}`,style:{width:"fit-content"},children:Object.entries(t.prints_by_printer).map(([u,d])=>i.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[i.jsx("span",{className:"text-bambu-gray truncate max-w-[120px]",children:e.get(u)||`${r("common.printer")} ${u}`}),i.jsx("span",{className:"text-white font-medium",children:d})]},u))})]})]})]})}function tet({stats:t,printerMap:e,size:n=1}){const{t:r}=Rt(),a=t?.average_time_accuracy;if(a==null)return i.jsx("div",{className:"flex items-center justify-center h-full",children:i.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noTimeAccuracyData")})});const o=(Math.min(150,Math.max(50,a))-50)/100*100,c=(v=>v>=95&&v<=105?"#00ae42":v>105?"#3b82f6":"#f97316")(a),u=a-100,d=n===1?112:n===2?128:144,m=d/2-8,p=m*2*Math.PI,f=n===1?3:n===2?6:999,y=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,f):[];return i.jsxs("div",{className:"flex items-center gap-6",children:[i.jsxs("div",{className:"relative flex-shrink-0",style:{width:d,height:d},children:[i.jsxs("svg",{className:"w-full h-full -rotate-90",children:[i.jsx("circle",{cx:d/2,cy:d/2,r:m,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),i.jsx("circle",{cx:d/2,cy:d/2,r:m,fill:"none",stroke:c,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${o/100*p} ${p}`})]}),i.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[i.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[a.toFixed(0),"%"]}),i.jsxs("span",{className:`text-xs ${u>=0?"text-blue-400":"text-orange-400"}`,children:[u>=0?"+":"",u.toFixed(0),"%"]})]})]}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[i.jsx(JX,{className:"w-3 h-3 flex-shrink-0"}),i.jsx("span",{children:r("stats.perfectEstimate")})]}),y.length>0&&i.jsx("div",{className:`mt-2 ${n===4?"grid grid-cols-3 gap-x-6 gap-y-1":n===2?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,style:{width:"fit-content"},children:y.map(([v,b])=>i.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[i.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(v)||`${r("common.printer")} ${v}`}),i.jsxs("span",{className:`font-medium ${b>=95&&b<=105?"text-status-ok":b>105?"text-blue-400":"text-status-warning"}`,children:[b.toFixed(0),"%"]})]},v))})]})]})}function net({printDates:t,dateFrom:e,dateTo:n}){const{days:r,hourlyCounts:a,maxCount:s}=w.useMemo(()=>{const d=new Date(e+"T00:00:00"),m=new Date(n+"T00:00:00"),p=[],f=g=>`${g.getFullYear()}-${String(g.getMonth()+1).padStart(2,"0")}-${String(g.getDate()).padStart(2,"0")}`,y=new Date(d);for(;y<=m;)p.push({key:f(y),label:y.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"})}),y.setDate(y.getDate()+1);const v={};let b=0;return t.forEach(g=>{const _=Zn(g);if(!_)return;const T=`${`${_.getFullYear()}-${String(_.getMonth()+1).padStart(2,"0")}-${String(_.getDate()).padStart(2,"0")}`}-${_.getHours()}`;v[T]=(v[T]||0)+1,v[T]>b&&(b=v[T])}),{days:p,hourlyCounts:v,maxCount:Math.max(1,b)}},[t,e,n]),o=d=>{if(d===0)return"bg-bambu-dark";const m=d/s;return m<=.25?"bg-bambu-green/30":m<=.5?"bg-bambu-green/50":m<=.75?"bg-bambu-green/75":"bg-bambu-green"},l=20,c=2,u=80;return i.jsxs("div",{className:"w-full overflow-x-auto",children:[i.jsxs("div",{className:"inline-flex flex-col",style:{gap:c},children:[i.jsx("div",{className:"flex",style:{gap:c,marginLeft:u+4},children:yL.map((d,m)=>i.jsx("div",{className:"text-bambu-gray text-[10px] text-center",style:{width:l,visibility:m%2===0?"visible":"hidden"},children:d},m))}),r.map(d=>i.jsxs("div",{className:"flex items-center",style:{gap:c},children:[i.jsx("div",{className:"text-bambu-gray text-[10px] flex-shrink-0 truncate",style:{width:u},children:d.label}),Array.from({length:24},(m,p)=>{const f=a[`${d.key}-${p}`]||0;return i.jsx("div",{className:`rounded-sm ${o(f)}`,style:{width:l,height:l},title:`${d.label} ${yL[p]}: ${f} print${f!==1?"s":""}`},p)})]},d.key))]}),i.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray text-xs",children:[i.jsx("span",{children:"Less"}),i.jsxs("div",{className:"flex",style:{gap:c},children:[i.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:l,height:l}}),i.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:l,height:l}}),i.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:l,height:l}}),i.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:l,height:l}}),i.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:l,height:l}})]}),i.jsx("span",{children:"More"})]})]})}function ret({printDates:t,size:e=2,dateFrom:n,dateTo:r}){const a=w.useMemo(()=>n&&r?Math.max((new Date(r).getTime()-new Date(n).getTime())/864e5,0)+1:n?Math.max((Date.now()-new Date(n).getTime())/864e5,0)+1:1/0,[n,r]);if(a<=7&&n&&r)return i.jsx(net,{printDates:t,dateFrom:n,dateTo:r});const o=a===1/0?e===1?3:e===2?6:12:Math.max(1,Math.ceil(a/30));return i.jsx(VJe,{printDates:t,months:o})}function iet({stats:t,archives:e,printerMap:n}){const{t:r}=Rt(),[a,s]=w.useState("weight"),[o,l]=w.useState("weight"),c=w.useMemo(()=>{const g=new Map;return t?.prints_by_printer&&Object.entries(t.prints_by_printer).forEach(([_,N])=>{const T=g.get(_)||{prints:0,weight:0,time:0};T.prints=N,g.set(_,T)}),e.forEach(_=>{if(!_.printer_id)return;const N=String(_.printer_id),T=g.get(N)||{prints:0,weight:0,time:0};T.weight+=_.filament_used_grams||0,T.time+=_.actual_time_seconds||_.print_time_seconds||0,t?.prints_by_printer||T.prints++,g.set(N,T)}),Array.from(g.entries()).map(([_,N])=>({name:n.get(_)||`${r("common.printer")} ${_}`,value:a==="prints"?N.prints:a==="weight"?Math.round(N.weight):Math.round(N.time/3600*10)/10})).sort((_,N)=>N.value-_.value)},[t,e,n,a,r]),u=w.useMemo(()=>{const g=Array.from({length:24},(_,N)=>({hour:N,label:yL[N],total:0,failures:0}));return e.forEach(_=>{if(!_.started_at)return;const N=Zn(_.started_at);if(!N)return;const T=N.getHours();g[T].total++,_.status==="failed"&&g[T].failures++}),g},[e]),d=w.useMemo(()=>{const g=zD.map(_=>({name:_.key,count:0}));return e.forEach(_=>{const N=_.actual_time_seconds||_.print_time_seconds;if(!(!N||N<=0)){for(let T=0;T{const g=[0,0,0,0,0,0,0],_=new Set;e.forEach(T=>{const C=Zn(T.created_at)||new Date(T.created_at);let P=C.getDay()-1;P<0&&(P=6),o==="prints"?g[P]++:o==="weight"?g[P]+=T.filament_used_grams||0:g[P]+=(T.actual_time_seconds||T.print_time_seconds||0)/3600;const k=new Date(C);k.setDate(C.getDate()-(C.getDay()+6)%7),_.add(`${k.getFullYear()}-${String(k.getMonth()+1).padStart(2,"0")}-${String(k.getDate()).padStart(2,"0")}`)});const N=Math.max(_.size,1);return ZJe.map((T,C)=>({name:T,avg:Math.round(g[C]/N*10)/10}))},[e,o]),p=g=>({unit:g==="weight"?"g":g==="time"?"h":"",color:g==="weight"?"#00ae42":g==="time"?"#3b82f6":"#f59e0b"}),f=p(a),y=r(a==="weight"?"stats.filamentByWeight":a==="time"?"stats.hours":"common.prints"),v=p(o),b=r(o==="weight"?"stats.avgWeight":o==="time"?"stats.avgTime":"stats.avgPrints");return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h4",{className:"text-sm font-medium text-bambu-gray",children:r("stats.printsByPrinter")}),i.jsx(WC,{value:a,onChange:s})]}),c.length>0?i.jsx(mh,{width:"100%",height:Math.max(140,c.length*40),children:i.jsxs(C1,{data:c,layout:"vertical",margin:{left:10},children:[i.jsx(Qp,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),i.jsx(Zp,{type:"number",stroke:"#9ca3af",tick:{fontSize:11},unit:f.unit}),i.jsx(Jp,{type:"category",dataKey:"name",stroke:"#9ca3af",tick:{fontSize:11},width:100}),i.jsx(hh,{contentStyle:G1,formatter:g=>[a==="weight"?sh(Number(g??0)):`${g??0}${f.unit}`,y]}),i.jsx(Pb,{dataKey:"value",fill:f.color,radius:[0,4,4,0]})]})}):i.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noPrinterData")})]}),i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-3",children:r("stats.printDuration")}),e.length>0?i.jsx(mh,{width:"100%",height:160,children:i.jsxs(C1,{data:d,children:[i.jsx(Qp,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),i.jsx(Zp,{dataKey:"name",stroke:"#9ca3af",tick:{fontSize:11}}),i.jsx(Jp,{stroke:"#9ca3af",tick:{fontSize:11},allowDecimals:!1}),i.jsx(hh,{contentStyle:G1}),i.jsx(Pb,{dataKey:"count",name:r("common.prints"),fill:"#00ae42",radius:[4,4,0,0]})]})}):i.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noArchiveData")})]}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h4",{className:"text-sm font-medium text-bambu-gray",children:r("stats.printHabits")}),i.jsx(WC,{value:o,onChange:l})]}),e.length>0?i.jsx(mh,{width:"100%",height:160,children:i.jsxs(C1,{data:m,children:[i.jsx(Qp,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),i.jsx(Zp,{dataKey:"name",stroke:"#9ca3af",tick:{fontSize:11}}),i.jsx(Jp,{stroke:"#9ca3af",tick:{fontSize:11},unit:v.unit}),i.jsx(hh,{contentStyle:G1,formatter:g=>[`${g??0}${v.unit}`,b]}),i.jsx(Pb,{dataKey:"avg",fill:v.color,radius:[4,4,0,0]})]})}):i.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noArchiveData")})]}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[i.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-3",children:r("stats.printTimeOfDay")}),e.length>0?i.jsx(mh,{width:"100%",height:160,children:i.jsxs(C1,{data:u,children:[i.jsx(Qp,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),i.jsx(Zp,{dataKey:"label",stroke:"#9ca3af",tick:{fontSize:10},interval:5}),i.jsx(Jp,{stroke:"#9ca3af",tick:{fontSize:11},allowDecimals:!1}),i.jsx(hh,{contentStyle:G1}),i.jsx(Pb,{dataKey:"total",name:r("stats.totalPrints"),fill:"#00ae42",radius:[2,2,0,0]}),i.jsx(Pb,{dataKey:"failures",name:r("stats.failed"),fill:"#ef4444",radius:[2,2,0,0]})]})}):i.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noArchiveData")})]})]})]})}function aet({archives:t,currency:e,dateFrom:n,dateTo:r}){const{t:a}=Rt();return!t||t.length===0?i.jsx("p",{className:"text-bambu-gray text-center py-4",children:a("stats.noPrintData")}):i.jsx(WJe,{archives:t,currency:e,dateFrom:n,dateTo:r})}function set({size:t=1,dateFrom:e,dateTo:n}){const{t:r}=Rt(),a=!!(e||n),{data:s,isLoading:o}=tt({queryKey:["failureAnalysis",e,n],queryFn:()=>fe.getFailureAnalysis({...a?{dateFrom:e,dateTo:n}:{days:30}})});if(o)return i.jsx("div",{className:"flex justify-center py-4",children:i.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!s||s.total_prints===0)return i.jsx("p",{className:"text-bambu-gray text-center py-4",children:r(a?"stats.noPrintDataInRange":"stats.noPrintDataLast30Days")});const l=t===1?5:t===2?8:999,c=Object.entries(s.failures_by_reason).sort(([,m],[,p])=>p-m),u=c.slice(0,l),d=c.length>l;return i.jsxs("div",{className:`${t>=2?"flex gap-8":"space-y-4"}`,children:[i.jsxs("div",{className:t>=2?"flex-shrink-0":"",children:[i.jsx("div",{className:"flex items-center gap-4",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Mn,{className:`w-5 h-5 ${s.failure_rate>20?"text-status-error":s.failure_rate>10?"text-status-warning":"text-status-ok"}`}),i.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[s.failure_rate.toFixed(1),"%"]})]})}),i.jsx("div",{className:"text-sm text-bambu-gray mt-1",children:r("stats.failedPrintsCount",{failed:s.failed_prints,total:s.total_prints})}),s.trend&&s.trend.length>=2&&i.jsx("div",{className:`${t>=2?"mt-4":"mt-2 pt-2 border-t border-bambu-dark-tertiary"}`,children:i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx(GL,{className:`w-4 h-4 ${s.trend[s.trend.length-1].failure_rate0&&i.jsxs("div",{className:`flex-1 ${t>=2?"border-l border-bambu-dark-tertiary pl-8":"pt-2"}`,children:[i.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:t>=2?r("stats.failureReasons"):r("stats.topFailureReasons")}),i.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:u.map(([m,p])=>i.jsxs("div",{className:"flex items-center justify-between text-sm",children:[i.jsx("span",{className:`text-white truncate ${t===4?"max-w-[200px]":"max-w-[160px]"}`,children:m||r("common.unknown")}),i.jsx("span",{className:"text-bambu-gray ml-2",children:p})]},m))}),d&&i.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:r("common.more",{count:c.length-l})})]})]})}function oet({archives:t,currency:e}){const{t:n}=Rt(),r=w.useMemo(()=>{const a=[];if(t.length===0)return a;const s=y=>{let v=null,b=0;return t.forEach(g=>{const _=y(g);_&&_>b&&(b=_,v=g)}),{archive:v,value:b}},o=s(y=>y.actual_time_seconds);o.archive&&a.push({icon:Jn,iconColor:"text-blue-400",label:n("stats.longestPrint"),value:Is(o.value),detail:o.archive.print_name||null});const l=s(y=>y.filament_used_grams);l.archive&&a.push({icon:Gi,iconColor:"text-orange-400",label:n("stats.heaviestPrint"),value:sh(l.value),detail:l.archive.print_name||null});const c=s(y=>y.cost);c.archive&&a.push({icon:EN,iconColor:"text-green-400",label:n("stats.mostExpensivePrint"),value:`${e}${c.value.toFixed(2)}`,detail:c.archive.print_name||null});const u=new Map;t.forEach(y=>{const v=Zn(y.created_at)||new Date(y.created_at),b=`${v.getFullYear()}-${String(v.getMonth()+1).padStart(2,"0")}-${String(v.getDate()).padStart(2,"0")}`;u.set(b,(u.get(b)||0)+1)});let d="",m=0;u.forEach((y,v)=>{y>m&&(m=y,d=v)}),m>1&&a.push({icon:Yr,iconColor:"text-purple-400",label:n("stats.busiestDay"),value:`${m} ${n("common.prints")}`,detail:(()=>{const[y,v,b]=d.split("-").map(Number);return new Date(y,v-1,b).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})})()});const p=[...t].filter(y=>y.status==="completed"||y.status==="failed").sort((y,v)=>new Date(v.completed_at||v.created_at).getTime()-new Date(y.completed_at||y.created_at).getTime());let f=0;for(const y of p)if(y.status==="completed")f++;else break;return f>0&&a.push({icon:Mc,iconColor:"text-yellow-400",label:n("stats.successStreak"),value:`${f}`,detail:f===1?n("stats.streakPrint"):n("stats.streakPrints",{count:f})}),a},[t,e,n]);return r.length===0?i.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noArchiveData")}):i.jsx("div",{className:"space-y-3",children:r.map((a,s)=>i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`p-1.5 rounded-lg bg-bambu-dark ${a.iconColor}`,children:i.jsx(a.icon,{className:"w-4 h-4"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-xs text-bambu-gray",children:a.label}),i.jsxs("div",{className:"flex items-baseline gap-2",children:[i.jsx("span",{className:"text-sm font-bold text-white",children:a.value}),a.detail&&i.jsx("span",{className:"text-xs text-bambu-gray truncate",children:a.detail})]})]})]},s))})}function cet(){const{t}=Rt(),{showToast:e}=fn(),{hasPermission:n}=Nr(),[r,a]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(0),[u,d]=w.useState(0),[m,p]=w.useState(!1),[f,y]=w.useState(()=>{try{const J=localStorage.getItem("bambusy-stats-timeframe");if(J){const ie=JSON.parse(J);if(ie.preset)return ie}}catch{}return{preset:"all-time",dateFrom:void 0,dateTo:void 0}}),[v,b]=w.useState(!1);w.useEffect(()=>{localStorage.setItem("bambusy-stats-timeframe",JSON.stringify(f))},[f]);const g=w.useMemo(()=>f.preset==="custom"?{dateFrom:f.dateFrom,dateTo:f.dateTo}:XJe(f.preset),[f]);w.useEffect(()=>{const J=()=>{try{const Q=localStorage.getItem("bambusy-dashboard-layout-v2");if(Q){const ue=JSON.parse(Q);d(ue.hidden?.length||0)}}catch{d(0)}};J(),window.addEventListener("storage",J);const ie=setInterval(J,2e3);return()=>{window.removeEventListener("storage",J),clearInterval(ie)}},[l]);const{data:_,isLoading:N,refetch:T}=tt({queryKey:["archiveStats",g.dateFrom,g.dateTo],queryFn:()=>fe.getArchiveStats({dateFrom:g.dateFrom,dateTo:g.dateTo})}),{data:C}=tt({queryKey:["printers"],queryFn:fe.getPrinters}),{data:P,refetch:k}=tt({queryKey:["archivesSlim",g.dateFrom,g.dateTo],queryFn:()=>fe.getArchivesSlim(g.dateFrom,g.dateTo)}),{data:R}=tt({queryKey:["settings"],queryFn:fe.getSettings}),A=async J=>{o(!1),a(!0);try{const{blob:ie,filename:Q}=await fe.exportStats({format:J,days:90}),ue=URL.createObjectURL(ie),me=document.createElement("a");me.href=ue,me.download=Q,me.click(),URL.revokeObjectURL(ue),e(t("stats.exportDownloaded"))}catch{e(t("stats.exportFailed"),"error")}finally{a(!1)}},D=async()=>{p(!0);try{const J=await fe.recalculateCosts();await Promise.all([T(),k()]),e(t("stats.recalculatedCosts",{count:J.updated}))}catch{e(t("stats.recalculateFailed"),"error")}finally{p(!1)}},B=Go(R?.currency||"USD"),z=new Map(C?.map(J=>[String(J.id),J.name])||[]),W=w.useMemo(()=>P?.map(J=>J.created_at)||[],[P]);if(N)return i.jsx("div",{className:"p-4 md:p-8",children:i.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("stats.loadingStats")})});const I=[{id:"quick-stats",title:t("stats.quickStats"),component:i.jsx(JJe,{stats:_,currency:B}),defaultSize:2},{id:"success-rate",title:t("stats.successRate"),component:J=>i.jsx(eet,{stats:_,printerMap:z,size:J}),defaultSize:1},{id:"time-accuracy",title:t("stats.timeAccuracy"),component:J=>i.jsx(tet,{stats:_,printerMap:z,size:J}),defaultSize:1},{id:"failure-analysis",title:t("stats.failureAnalysis"),component:J=>i.jsx(set,{size:J,dateFrom:g.dateFrom,dateTo:g.dateTo}),defaultSize:1},{id:"print-activity",title:t("stats.printActivity"),component:J=>i.jsx(ret,{printDates:W,size:J,dateFrom:g.dateFrom,dateTo:g.dateTo}),defaultSize:2},{id:"records",title:t("stats.records"),component:i.jsx(oet,{archives:P||[],currency:B}),defaultSize:1},{id:"printer-stats",title:t("stats.printerStats"),component:i.jsx(iet,{stats:_,archives:P||[],printerMap:z}),defaultSize:4},{id:"filament-trends",title:t("stats.filamentTrends"),component:i.jsx(aet,{archives:P||[],currency:B,dateFrom:g.dateFrom,dateTo:g.dateTo}),defaultSize:4}];return i.jsxs("div",{className:"p-4 md:p-8",children:[i.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold text-white",children:t("stats.title")}),i.jsx("p",{className:"text-bambu-gray",children:t("stats.subtitle")})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[u>0&&i.jsxs(Ie,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[i.jsx(Ac,{className:"w-4 h-4"}),t("stats.hiddenCount",{count:u})]}),i.jsxs(Ie,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout-v2"),c(J=>J+1),e(t("stats.layoutReset"))},disabled:!n("settings:update"),title:n("settings:update")?void 0:t("stats.noPermissionResetLayout"),children:[i.jsx(So,{className:"w-4 h-4"}),t("stats.resetLayout")]}),i.jsxs(Ie,{variant:"secondary",onClick:D,disabled:m||!n("archives:update_all"),title:n("archives:update_all")?t("stats.recalculateCostsHint"):t("stats.noPermissionRecalculate"),children:[m?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(jhe,{className:"w-4 h-4"}),t("stats.recalculateCosts")]}),i.jsxs("div",{className:"relative",children:[i.jsxs(Ie,{variant:"secondary",onClick:()=>o(!s),disabled:r,children:[r?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(DN,{className:"w-4 h-4"}),t("stats.exportStats")]}),s&&i.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[i.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>A("csv"),children:[i.jsx(zs,{className:"w-4 h-4"}),t("stats.exportAsCsv")]}),i.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>A("xlsx"),children:[i.jsx(DN,{className:"w-4 h-4"}),t("stats.exportAsExcel")]})]})]}),i.jsxs("div",{className:"relative",children:[i.jsxs(Ie,{variant:"secondary",onClick:()=>b(!v),children:[i.jsx(Yr,{className:"w-4 h-4"}),t(`stats.timeframe.${f.preset}`),i.jsx(On,{className:"w-3 h-3"})]}),v&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>b(!1)}),i.jsxs("div",{className:"absolute right-0 top-full mt-1 w-64 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 p-2",children:[QJe.map(J=>i.jsx("button",{className:`w-full px-3 py-2 text-left text-sm rounded-md transition-colors ${f.preset===J?"bg-bambu-green text-white":"text-white hover:bg-bambu-dark-tertiary"}`,onClick:()=>{y({preset:J,dateFrom:void 0,dateTo:void 0}),b(!1)},children:t(`stats.timeframe.${J}`)},J)),i.jsx("div",{className:"border-t border-bambu-dark-tertiary my-2"}),i.jsx("button",{className:`w-full px-3 py-2 text-left text-sm rounded-md transition-colors ${f.preset==="custom"?"bg-bambu-green text-white":"text-white hover:bg-bambu-dark-tertiary"}`,onClick:()=>y(J=>({...J,preset:"custom"})),children:t("stats.timeframe.custom")}),f.preset==="custom"&&i.jsxs("div",{className:"mt-2 px-1 pb-1 space-y-2",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-bambu-gray block mb-1",children:t("stats.timeframe.from")}),i.jsx("input",{type:"date",value:f.dateFrom||"",max:f.dateTo||new Date().toISOString().split("T")[0],onChange:J=>y(ie=>({...ie,dateFrom:J.target.value||void 0})),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-sm text-white [color-scheme:dark]"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-bambu-gray block mb-1",children:t("stats.timeframe.to")}),i.jsx("input",{type:"date",value:f.dateTo||"",min:f.dateFrom,max:new Date().toISOString().split("T")[0],onChange:J=>y(ie=>({...ie,dateTo:J.target.value||void 0})),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-sm text-white [color-scheme:dark]"})]}),i.jsx(Ie,{variant:"primary",onClick:()=>b(!1),className:"w-full",children:t("common.apply")})]})]})]})]})]})]}),i.jsx(YJe,{widgets:I,storageKey:"bambusy-dashboard-layout-v2",stackBelow:640,hideControls:!0},l)]})}function uet({plug:t,onEdit:e}){const{t:n}=Rt(),r=sn(),{showToast:a}=fn(),[s,o]=w.useState(!1),[l,c]=w.useState(!1),[u,d]=w.useState(!1),[m,p]=w.useState(!1),{data:f,isLoading:y}=tt({queryKey:["smart-plug-status",t.id],queryFn:()=>fe.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:v}=tt({queryKey:["printers"],queryFn:fe.getPrinters}),b=v?.find(D=>D.id===t.printer_id),g=ft({mutationFn:D=>fe.controlSmartPlug(t.id,D),onMutate:async D=>{await r.cancelQueries({queryKey:["smart-plug-status",t.id]});const B=r.getQueryData(["smart-plug-status",t.id]),z=D==="on"?"ON":D==="off"||f?.state==="ON"?"OFF":"ON";return r.setQueryData(["smart-plug-status",t.id],W=>({...W,state:z})),{previousStatus:B}},onError:(D,B,z)=>{z?.previousStatus&&r.setQueryData(["smart-plug-status",t.id],z.previousStatus),a(n("smartPlugs.failedToTurn",{action:B,name:t.name}),"error")},onSettled:()=>{setTimeout(()=>{r.invalidateQueries({queryKey:["smart-plug-status",t.id]}),r.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),_=ft({mutationFn:D=>fe.updateSmartPlug(t.id,D),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&(r.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]}))}}),N=ft({mutationFn:()=>fe.deleteSmartPlug(t.id),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&r.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]})}}),T=f?.state==="ON",C=t.plug_type==="mqtt"&&f?.energy?.power!==null&&f?.energy?.power!==void 0,P=(f?.reachable??!1)||C,k=g.isPending,A=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const D=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${D}/`:`http://${D}/`})();return i.jsxs(i.Fragment,{children:[i.jsx(Pt,{className:"relative",children:i.jsxs(Et,{className:"p-4",children:[i.jsxs("div",{className:"flex items-start justify-between gap-2 mb-3",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[i.jsx("div",{className:`p-2 rounded-lg flex-shrink-0 ${t.plug_type==="mqtt"?P?"bg-teal-500/20":"bg-red-500/20":P?T?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="mqtt"?i.jsx(qL,{className:`w-5 h-5 ${P?"text-teal-400":"text-red-400"}`}):t.plug_type==="homeassistant"?i.jsx(bw,{className:`w-5 h-5 ${P?T?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):i.jsx(Il,{className:`w-5 h-5 ${P?T?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("h3",{className:"font-medium text-white truncate",children:t.name}),i.jsx("p",{className:"text-sm text-bambu-gray truncate",title:t.plug_type==="mqtt"?t.mqtt_topic??void 0:t.plug_type==="homeassistant"?t.ha_entity_id??void 0:t.ip_address??void 0,children:t.plug_type==="mqtt"?t.mqtt_topic:t.plug_type==="homeassistant"?t.ha_entity_id:t.ip_address})]})]}),i.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[y?i.jsx(pt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):t.plug_type==="mqtt"?i.jsxs("div",{className:"flex items-center gap-1.5 text-sm whitespace-nowrap",children:[i.jsx("span",{className:"px-1.5 py-0.5 bg-teal-500/20 text-teal-400 text-[10px] font-medium rounded flex-shrink-0",children:"MQTT"}),P&&i.jsx("span",{className:"text-status-ok",children:"✓"})]}):t.plug_type==="homeassistant"?i.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[i.jsx("span",{className:"px-1 py-0.5 bg-blue-500/20 text-blue-400 text-[10px] font-medium rounded",children:"HA"}),i.jsx("span",{className:P?T?"text-status-ok":"text-bambu-gray":"text-status-error",children:P?f?.state||"?":n("smartPlugs.offline")})]}):P?i.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[i.jsx(Hb,{className:"w-4 h-4 text-status-ok"}),i.jsx("span",{className:T?"text-status-ok":"text-bambu-gray",children:f?.state||n("smartPlugs.unknown")})]}):i.jsxs("div",{className:"flex items-center gap-1 text-sm text-status-error",children:[i.jsx(Rh,{className:"w-4 h-4"}),i.jsx("span",{children:n("smartPlugs.offline")})]}),A&&i.jsxs("a",{href:A,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2 py-0.5 bg-bambu-dark hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white text-xs rounded-full transition-colors",title:n("smartPlugs.openPlugAdminPage"),children:[i.jsx(ti,{className:"w-3 h-3"}),n("smartPlugs.admin")]})]})]}),b&&i.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[i.jsxs("span",{className:"text-xs text-bambu-gray",children:[n("smartPlugs.linkedTo")," "]}),i.jsx("span",{className:"text-sm text-white",children:b.name})]}),(t.power_alert_enabled||t.schedule_enabled||t.plug_type==="mqtt")&&i.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.plug_type==="mqtt"&&i.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded-full",children:[i.jsx(Ac,{className:"w-3 h-3"}),n("smartPlugs.monitorOnly")]}),t.power_alert_enabled&&i.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[i.jsx(xh,{className:"w-3 h-3"}),n("smartPlugs.alerts")]}),t.schedule_enabled&&i.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[i.jsx(Yr,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?n("smartPlugs.scheduleOn",{time:t.schedule_on_time}):n("smartPlugs.scheduleOff",{time:t.schedule_off_time})]})]}),t.plug_type!=="mqtt"&&i.jsxs("div",{className:"flex gap-2 mb-3",children:[i.jsxs(Ie,{size:"sm",variant:T?"primary":"secondary",disabled:!P||k,onClick:()=>c(!0),className:"flex-1",children:[k?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Xd,{className:"w-4 h-4"}),n("smartPlugs.on")]}),i.jsxs(Ie,{size:"sm",variant:T?"secondary":"primary",disabled:!P||k,onClick:()=>d(!0),className:"flex-1",children:[k?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(rT,{className:"w-4 h-4"}),n("smartPlugs.off")]})]}),t.plug_type==="mqtt"&&f?.energy&&i.jsxs("div",{className:"flex gap-2 mb-3 px-3 py-2 bg-bambu-dark rounded-lg",children:[f.energy.power!==null&&f.energy.power!==void 0&&i.jsxs("div",{className:"flex-1 text-center",children:[i.jsxs("p",{className:"text-lg font-semibold text-white",children:[Math.round(f.energy.power),"W"]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.power")})]}),f.energy.today!==null&&f.energy.today!==void 0&&i.jsxs("div",{className:"flex-1 text-center border-l border-bambu-dark-tertiary",children:[i.jsx("p",{className:"text-lg font-semibold text-white",children:f.energy.today.toFixed(3)}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.kwhToday")})]})]}),i.jsxs("button",{onClick:()=>p(!m),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(Od,{className:"w-4 h-4"}),t.plug_type==="mqtt"?n("smartPlugs.settings"):n("smartPlugs.automationSettings")]}),i.jsx("span",{children:m?"-":"+"})]}),m&&i.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(xw,{className:"w-4 h-4 text-bambu-green"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("smartPlugs.showInSwitchbar")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.quickAccessSidebar")})]})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:D=>_.mutate({show_in_switchbar:D.target.checked}),className:"sr-only peer"}),i.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.plug_type!=="mqtt"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("smartPlugs.enabled")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.enableAutomation")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:t.enabled,onChange:D=>_.mutate({enabled:D.target.checked}),className:"sr-only peer"}),i.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("smartPlugs.autoOn")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.autoOnDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:D=>_.mutate({auto_on:D.target.checked}),className:"sr-only peer"}),i.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("smartPlugs.autoOff")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.autoOffDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:D=>_.mutate({auto_off:D.target.checked}),className:"sr-only peer"}),i.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&i.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white mb-2",children:n("smartPlugs.turnOffDelayMode")}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("button",{onClick:()=>_.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[i.jsx(Jn,{className:"w-4 h-4"}),n("smartPlugs.time")]}),i.jsxs("button",{onClick:()=>_.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[i.jsx(sT,{className:"w-4 h-4"}),n("smartPlugs.temp")]})]})]}),t.off_delay_mode==="time"?i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:n("smartPlugs.delayMinutes")}),i.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:D=>_.mutate({off_delay_minutes:parseInt(D.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:n("smartPlugs.tempThreshold")}),i.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:D=>_.mutate({off_temp_threshold:parseInt(D.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("smartPlugs.tempThresholdDescription")})]})]})]}),i.jsxs("div",{className:"flex gap-2 pt-2",children:[i.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[i.jsx(oh,{className:"w-4 h-4"}),n("smartPlugs.edit")]}),i.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>o(!0),className:"text-red-400 hover:text-red-300",children:i.jsx(en,{className:"w-4 h-4"})})]})]})]})}),s&&i.jsx(_n,{title:n("smartPlugs.deleteSmartPlug"),message:n("smartPlugs.deleteConfirm",{name:t.name}),confirmText:n("smartPlugs.delete"),variant:"danger",onConfirm:()=>{N.mutate(),o(!1)},onCancel:()=>o(!1)}),l&&i.jsx(_n,{title:n("smartPlugs.turnOnSmartPlug"),message:n("smartPlugs.turnOnConfirm",{name:t.name}),confirmText:n("smartPlugs.turnOn"),variant:"default",onConfirm:()=>{g.mutate("on"),c(!1)},onCancel:()=>c(!1)}),u&&i.jsx(_n,{title:n("smartPlugs.turnOffSmartPlug"),message:n("smartPlugs.turnOffConfirm",{name:t.name}),confirmText:n("smartPlugs.turnOff"),variant:"danger",onConfirm:()=>{g.mutate("off"),d(!1)},onCancel:()=>d(!1)})]})}function det({plug:t,onClose:e}){const{t:n}=Rt(),r=sn(),a=!!t,[s,o]=w.useState(t?.plug_type||"tasmota"),[l,c]=w.useState(t?.name||""),[u,d]=w.useState(t?.ip_address||""),[m,p]=w.useState(t?.username||""),[f,y]=w.useState(t?.password||""),[v,b]=w.useState(t?.ha_entity_id||""),[g,_]=w.useState(t?.mqtt_power_topic||t?.mqtt_topic||""),[N,T]=w.useState(t?.mqtt_power_path||""),[C,P]=w.useState((t?.mqtt_power_multiplier??t?.mqtt_multiplier??1).toString()),[k,R]=w.useState(t?.mqtt_energy_topic||""),[A,D]=w.useState(t?.mqtt_energy_path||""),[B,z]=w.useState((t?.mqtt_energy_multiplier??1).toString()),[W,I]=w.useState(t?.mqtt_state_topic||""),[J,ie]=w.useState(t?.mqtt_state_path||""),[Q,ue]=w.useState(t?.mqtt_state_on_value||""),[me,pe]=w.useState(t?.ha_power_entity||""),[Y,se]=w.useState(t?.ha_energy_today_entity||""),[oe,be]=w.useState(t?.ha_energy_total_entity||""),[Me,q]=w.useState(""),[Z,j]=w.useState(""),[E,U]=w.useState(!1),K=w.useRef(null),[$,ne]=w.useState(""),[O,V]=w.useState(!1),ee=w.useRef(null),[G,re]=w.useState(""),[ce,ge]=w.useState(!1),xe=w.useRef(null),[ae,L]=w.useState(""),[F,te]=w.useState(!1),ve=w.useRef(null),[he,de]=w.useState(t?.printer_id||null),[ke,_e]=w.useState(null),[Le,$e]=w.useState(null),[Re,Ae]=w.useState(t?.power_alert_enabled||!1),[Pe,Ue]=w.useState(t?.power_alert_high?.toString()||""),[je,Xe]=w.useState(t?.power_alert_low?.toString()||""),[ye,Ge]=w.useState(t?.schedule_enabled||!1),[Ee,Ke]=w.useState(t?.schedule_on_time||""),[Ve,Ne]=w.useState(t?.schedule_off_time||""),[Ce,He]=w.useState(t?.show_in_switchbar||!1),[et,it]=w.useState(t?.show_on_printer_card??!0),[xt,vt]=w.useState(!1),[qe,_t]=w.useState({scanned:0,total:0}),[Nt,mt]=w.useState([]),jt=w.useRef(null),{data:qt}=tt({queryKey:["printers"],queryFn:fe.getPrinters}),{data:Jt}=tt({queryKey:["smart-plugs"],queryFn:fe.getSmartPlugs}),{data:Wt}=tt({queryKey:["settings"],queryFn:fe.getSettings}),un=!!(Wt?.ha_enabled&&Wt?.ha_url&&Wt?.ha_token);w.useEffect(()=>{const De=setTimeout(()=>{j(Me)},300);return()=>clearTimeout(De)},[Me]),w.useEffect(()=>{const De=ht=>{K.current&&!K.current.contains(ht.target)&&U(!1),ee.current&&!ee.current.contains(ht.target)&&V(!1),xe.current&&!xe.current.contains(ht.target)&&ge(!1),ve.current&&!ve.current.contains(ht.target)&&te(!1)};return document.addEventListener("mousedown",De),()=>document.removeEventListener("mousedown",De)},[]);const{data:Je,isLoading:xn,error:Cn}=tt({queryKey:["ha-entities",Z],queryFn:()=>fe.getHAEntities(Z||void 0),enabled:s==="homeassistant"&&un,retry:!1,staleTime:0}),{data:Oe}=tt({queryKey:["ha-sensor-entities"],queryFn:fe.getHASensorEntities,enabled:s==="homeassistant"&&un,retry:!1,staleTime:0});w.useEffect(()=>{const De=ht=>{ht.key==="Escape"&&e()};return window.addEventListener("keydown",De),()=>{window.removeEventListener("keydown",De),jt.current&&clearInterval(jt.current)}},[e]);const nt=async()=>{vt(!0),mt([]),_t({scanned:0,total:0}),$e(null);try{await fe.startTasmotaScan();const De=async()=>{try{const ht=await fe.getTasmotaScanStatus();_t({scanned:ht.scanned,total:ht.total});const ut=await fe.getDiscoveredTasmotaDevices();mt(ut),ht.running||(vt(!1),jt.current&&(clearInterval(jt.current),jt.current=null))}catch(ht){console.error("Polling error:",ht)}};await De(),jt.current=setInterval(De,500)}catch(De){vt(!1);const ht=De instanceof Error?De.message:typeof De=="string"?De:JSON.stringify(De);$e(ht||n("smartPlugs.failedToStartScan"))}},dt=async()=>{try{await fe.stopTasmotaScan()}catch{}vt(!1),jt.current&&(clearInterval(jt.current),jt.current=null)},Qe=De=>{d(De.ip_address),c(De.name),_e(null)},Te=ft({mutationFn:()=>fe.testSmartPlugConnection(u,m||null,f||null),onSuccess:De=>{_e(De),$e(null),!l&&De.device_name&&c(De.device_name)},onError:De=>{_e(null),$e(De.message)}}),st=ft({mutationFn:De=>fe.createSmartPlug(De),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:De=>{$e(De.message)}}),le=ft({mutationFn:De=>fe.updateSmartPlug(t.id,De),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:De=>{$e(De.message)}}),Be=qt?.filter(De=>s==="tasmota"?!Jt?.some(ut=>ut.printer_id===De.id&&ut.id!==t?.id&&ut.plug_type==="tasmota"):!0),We=De=>{if(De.preventDefault(),$e(null),!l.trim()){$e(n("smartPlugs.nameRequired"));return}if(s==="tasmota"&&!u.trim()){$e("IP address is required for Tasmota plugs");return}if(s==="homeassistant"&&!v){$e(n("smartPlugs.entityRequired"));return}if(s==="mqtt"){const ut=g.trim(),rt=k.trim(),wt=W.trim();if(!ut&&!rt&&!wt){$e(n("smartPlugs.mqttTopicRequired"));return}}const ht={name:l.trim(),plug_type:s,ip_address:s==="tasmota"?u.trim():null,ha_entity_id:s==="homeassistant"?v:null,ha_power_entity:s==="homeassistant"&&me||null,ha_energy_today_entity:s==="homeassistant"&&Y||null,ha_energy_total_entity:s==="homeassistant"&&oe||null,mqtt_power_topic:s==="mqtt"&&g.trim()||null,mqtt_power_path:s==="mqtt"&&N.trim()||null,mqtt_power_multiplier:s==="mqtt"&&parseFloat(C)||1,mqtt_energy_topic:s==="mqtt"&&k.trim()||null,mqtt_energy_path:s==="mqtt"&&A.trim()||null,mqtt_energy_multiplier:s==="mqtt"&&parseFloat(B)||1,mqtt_state_topic:s==="mqtt"&&W.trim()||null,mqtt_state_path:s==="mqtt"&&J.trim()||null,mqtt_state_on_value:s==="mqtt"&&Q.trim()||null,username:s==="tasmota"&&m.trim()||null,password:s==="tasmota"&&f.trim()||null,printer_id:he,power_alert_enabled:Re,power_alert_high:Pe?parseFloat(Pe):null,power_alert_low:je?parseFloat(je):null,schedule_enabled:ye,schedule_on_time:Ee||null,schedule_off_time:Ve||null,show_in_switchbar:Ce,show_on_printer_card:et};a?le.mutate(ht):st.mutate(ht)},Ye=st.isPending||le.isPending;return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:De=>De.stopPropagation(),children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[i.jsx("h2",{className:"text-lg font-semibold text-white",children:n(a?"smartPlugs.editTitle":"smartPlugs.addTitle")}),i.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:i.jsx(Ht,{className:"w-5 h-5"})})]}),i.jsxs("form",{onSubmit:We,className:"p-6 space-y-4 overflow-y-auto",children:[Le&&i.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:Le}),!a&&i.jsxs("div",{className:"flex gap-2 mb-2",children:[i.jsxs("button",{type:"button",onClick:()=>{o("tasmota"),_e(null),$e(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="tasmota"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[i.jsx(Il,{className:"w-4 h-4"}),"Tasmota"]}),i.jsxs("button",{type:"button",onClick:()=>{o("homeassistant"),_e(null),$e(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="homeassistant"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[i.jsx(bw,{className:"w-4 h-4"}),"HA"]}),i.jsxs("button",{type:"button",onClick:()=>{o("mqtt"),_e(null),$e(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="mqtt"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[i.jsx(qL,{className:"w-4 h-4"}),"MQTT"]})]}),!a&&s==="tasmota"&&i.jsxs("div",{className:"space-y-3",children:[xt?i.jsxs(Ie,{type:"button",variant:"secondary",onClick:dt,className:"w-full",children:[i.jsx(Ht,{className:"w-4 h-4"}),n("smartPlugs.stopScanning")]}):i.jsxs(Ie,{type:"button",variant:"primary",onClick:nt,className:"w-full",children:[i.jsx(Rr,{className:"w-4 h-4"}),n("smartPlugs.discoverTasmota")]}),xt&&qe.total>0&&i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray",children:[i.jsx("span",{children:n("smartPlugs.addSmartPlug.scanningNetwork")}),i.jsxs("span",{children:[qe.scanned," / ",qe.total]})]}),i.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:i.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${qe.scanned/qe.total*100}%`}})})]}),Nt.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.foundDevices",{count:Nt.length})}),i.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:Nt.map(De=>i.jsxs("button",{type:"button",onClick:()=>Qe(De),className:"w-full flex items-center justify-between p-2 bg-bambu-dark hover:bg-bambu-dark-tertiary rounded-lg transition-colors text-left border border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Il,{className:"w-4 h-4 text-bambu-green"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:De.name}),i.jsx("p",{className:"text-xs text-bambu-gray",children:De.ip_address})]})]}),De.state&&i.jsxs("span",{className:`flex items-center gap-1 text-xs ${De.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[i.jsx(Xd,{className:"w-3 h-3"}),De.state]})]},De.ip_address))})]}),!xt&&Nt.length===0&&qe.total>0&&i.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:n("smartPlugs.noDevicesFound")})]}),s==="homeassistant"&&i.jsxs("div",{className:"space-y-3",children:[!un&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:[n("smartPlugs.haNotConfigured")," ",i.jsx("span",{className:"font-medium",children:n("smartPlugs.haSettingsPath")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1 opacity-50",children:n("smartPlugs.selectEntity")}),i.jsx("select",{disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed opacity-50",children:i.jsx("option",{children:n("smartPlugs.addSmartPlug.chooseEntity")})})]})]}),un&&i.jsxs(i.Fragment,{children:[xn&&i.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[i.jsx(pt,{className:"w-5 h-5 animate-spin mr-2"}),n("smartPlugs.loadingEntities")]}),Cn&&i.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:n("smartPlugs.failedToLoadEntities",{error:Cn.message})}),(()=>{const De=Jt?.filter(rt=>rt.ha_entity_id&&rt.id!==t?.id).map(rt=>rt.ha_entity_id)||[],ht=(Je||[]).filter(rt=>!De.includes(rt.entity_id)),ut=Je?.find(rt=>rt.entity_id===v);return i.jsxs("div",{ref:K,className:"relative",children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.selectEntity")}),i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),i.jsx("input",{type:"text",value:E?Me:ut?`${ut.friendly_name} (${ut.entity_id})`:"",onChange:rt=>{q(rt.target.value),E||U(!0)},onFocus:()=>{U(!0),q("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEntities"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),v&&!E&&i.jsx("button",{type:"button",onClick:()=>{b(""),q("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:i.jsx(Ht,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),xn&&i.jsx(pt,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),E&&i.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[xn&&i.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),n("smartPlugs.loading")]}),!xn&&ht.length===0&&i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:Z?n("smartPlugs.noEntitiesMatching",{search:Z}):n("smartPlugs.noEntitiesAvailable")}),!xn&&ht.map(rt=>i.jsxs("button",{type:"button",onClick:()=>{b(rt.entity_id),U(!1),q(""),l||c(rt.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${rt.entity_id===v?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[i.jsx("div",{className:"font-medium",children:rt.friendly_name}),i.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[i.jsx("span",{children:rt.entity_id}),i.jsx("span",{className:rt.state==="on"?"text-bambu-green":"",children:rt.state})]})]},rt.entity_id))]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:Z?n("smartPlugs.searchingEntities",{count:ht.length}):n("smartPlugs.showingEntities",{count:ht.length})})]})})(),v&&Oe&&Oe.length>0&&i.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4 space-y-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white font-medium mb-1",children:n("smartPlugs.energyMonitoringOptional")}),i.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:n("smartPlugs.energyMonitoringHint")})]}),(()=>{const De=Oe.filter(rt=>rt.unit_of_measurement==="W"||rt.unit_of_measurement==="kW"||rt.unit_of_measurement==="mW"),ht=$?De.filter(rt=>rt.entity_id.toLowerCase().includes($.toLowerCase())||rt.friendly_name.toLowerCase().includes($.toLowerCase())):De,ut=Oe.find(rt=>rt.entity_id===me);return i.jsxs("div",{ref:ee,className:"relative",children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.powerSensorW")}),i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),i.jsx("input",{type:"text",value:O?$:ut?`${ut.friendly_name} (${ut.state} ${ut.unit_of_measurement})`:"",onChange:rt=>{ne(rt.target.value),O||V(!0)},onFocus:()=>{V(!0),ne("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchPowerSensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),me&&!O&&i.jsx("button",{type:"button",onClick:()=>{pe(""),ne("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:i.jsx(Ht,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),O&&i.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[i.jsx("button",{type:"button",onClick:()=>{pe(""),V(!1),ne("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:n("smartPlugs.none")}),ht.map(rt=>i.jsxs("button",{type:"button",onClick:()=>{pe(rt.entity_id),V(!1),ne("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${rt.entity_id===me?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[i.jsx("div",{className:"font-medium",children:rt.friendly_name}),i.jsxs("div",{className:"text-xs text-bambu-gray",children:[rt.entity_id," • ",rt.state," ",rt.unit_of_measurement]})]},rt.entity_id)),ht.length===0&&i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:n("smartPlugs.noMatchingSensors")})]})]})})(),(()=>{const De=Oe.filter(rt=>rt.unit_of_measurement==="kWh"||rt.unit_of_measurement==="Wh"||rt.unit_of_measurement==="MWh"),ht=G?De.filter(rt=>rt.entity_id.toLowerCase().includes(G.toLowerCase())||rt.friendly_name.toLowerCase().includes(G.toLowerCase())):De,ut=Oe.find(rt=>rt.entity_id===Y);return i.jsxs("div",{ref:xe,className:"relative",children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.energyTodayKwh")}),i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),i.jsx("input",{type:"text",value:ce?G:ut?`${ut.friendly_name} (${ut.state} ${ut.unit_of_measurement})`:"",onChange:rt=>{re(rt.target.value),ce||ge(!0)},onFocus:()=>{ge(!0),re("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEnergySensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),Y&&!ce&&i.jsx("button",{type:"button",onClick:()=>{se(""),re("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:i.jsx(Ht,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),ce&&i.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[i.jsx("button",{type:"button",onClick:()=>{se(""),ge(!1),re("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:n("smartPlugs.none")}),ht.map(rt=>i.jsxs("button",{type:"button",onClick:()=>{se(rt.entity_id),ge(!1),re("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${rt.entity_id===Y?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[i.jsx("div",{className:"font-medium",children:rt.friendly_name}),i.jsxs("div",{className:"text-xs text-bambu-gray",children:[rt.entity_id," • ",rt.state," ",rt.unit_of_measurement]})]},rt.entity_id)),ht.length===0&&i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:n("smartPlugs.noMatchingSensors")})]})]})})(),(()=>{const De=Oe.filter(rt=>rt.unit_of_measurement==="kWh"||rt.unit_of_measurement==="Wh"||rt.unit_of_measurement==="MWh"),ht=ae?De.filter(rt=>rt.entity_id.toLowerCase().includes(ae.toLowerCase())||rt.friendly_name.toLowerCase().includes(ae.toLowerCase())):De,ut=Oe.find(rt=>rt.entity_id===oe);return i.jsxs("div",{ref:ve,className:"relative",children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.totalEnergyKwh")}),i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),i.jsx("input",{type:"text",value:F?ae:ut?`${ut.friendly_name} (${ut.state} ${ut.unit_of_measurement})`:"",onChange:rt=>{L(rt.target.value),F||te(!0)},onFocus:()=>{te(!0),L("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEnergySensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),oe&&!F&&i.jsx("button",{type:"button",onClick:()=>{be(""),L("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:i.jsx(Ht,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),F&&i.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[i.jsx("button",{type:"button",onClick:()=>{be(""),te(!1),L("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:n("smartPlugs.none")}),ht.map(rt=>i.jsxs("button",{type:"button",onClick:()=>{be(rt.entity_id),te(!1),L("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${rt.entity_id===oe?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[i.jsx("div",{className:"font-medium",children:rt.friendly_name}),i.jsxs("div",{className:"text-xs text-bambu-gray",children:[rt.entity_id," • ",rt.state," ",rt.unit_of_measurement]})]},rt.entity_id)),ht.length===0&&i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:n("smartPlugs.noMatchingSensors")})]})]})})()]})]})]}),s==="mqtt"&&i.jsxs("div",{className:"space-y-3",children:[!Wt?.mqtt_broker&&i.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:[n("smartPlugs.mqttNotConfigured")," ",i.jsx("span",{className:"font-medium",children:n("smartPlugs.mqttSettingsPath")})," ",n("smartPlugs.mqttNotConfiguredSuffix")]}),Wt?.mqtt_broker&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg text-sm text-blue-300",children:[i.jsx("p",{className:"font-medium mb-1",children:n("smartPlugs.monitorOnly")}),i.jsx("p",{className:"text-xs opacity-80",children:n("smartPlugs.mqttMonitorOnlyDescription")})]}),i.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[i.jsx("p",{className:"text-white font-medium text-sm",children:n("smartPlugs.powerMonitoring")}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.topic")}),i.jsx("input",{type:"text",value:g,onChange:De=>_(De.target.value),placeholder:"zigbee2mqtt/shelly-working-room",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.jsonPath")}),i.jsx("input",{type:"text",value:N,onChange:De=>T(De.target.value),placeholder:"power_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.multiplier")}),i.jsx("input",{type:"text",value:C,onChange:De=>P(De.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",style:{whiteSpace:"pre-line"},children:n("smartPlugs.mqttPowerHint")})]}),i.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[i.jsxs("p",{className:"text-white font-medium text-sm",children:[n("smartPlugs.energyMonitoring")," ",i.jsxs("span",{className:"text-bambu-gray font-normal",children:["(",n("smartPlugs.optional"),")"]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.topic")}),i.jsx("input",{type:"text",value:k,onChange:De=>R(De.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.jsonPath")}),i.jsx("input",{type:"text",value:A,onChange:De=>D(De.target.value),placeholder:"energy_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.multiplier")}),i.jsx("input",{type:"text",value:B,onChange:De=>z(De.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",style:{whiteSpace:"pre-line"},children:n("smartPlugs.mqttEnergyHint")})]}),i.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[i.jsxs("p",{className:"text-white font-medium text-sm",children:[n("smartPlugs.stateMonitoring")," ",i.jsxs("span",{className:"text-bambu-gray font-normal",children:["(",n("smartPlugs.optional"),")"]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.topic")}),i.jsx("input",{type:"text",value:W,onChange:De=>I(De.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.jsonPath")}),i.jsx("input",{type:"text",value:J,onChange:De=>ie(De.target.value),placeholder:"state_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.onValue")}),i.jsx("input",{type:"text",value:Q,onChange:De=>ue(De.target.value),placeholder:n("smartPlugs.addSmartPlug.placeholders.mqttStateOnValue"),className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",style:{whiteSpace:"pre-line"},children:n("smartPlugs.mqttStateHint")})]})]})]}),s==="tasmota"&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.ipAddress")}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",value:u,onChange:De=>{d(De.target.value),_e(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),i.jsxs(Ie,{type:"button",variant:"secondary",onClick:()=>Te.mutate(),disabled:!u.trim()||Te.isPending,children:[Te.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Hb,{className:"w-4 h-4"}),n("smartPlugs.test")]})]})]}),s==="tasmota"&&ke&&i.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ke.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:ke.success?i.jsxs(i.Fragment,{children:[i.jsx(fr,{className:"w-5 h-5"}),i.jsxs("div",{children:[i.jsx("p",{className:"font-medium",children:n("smartPlugs.connectedResult")}),i.jsxs("p",{className:"text-sm opacity-80",children:[ke.device_name&&n("smartPlugs.deviceLabel",{name:ke.device_name}),n("smartPlugs.stateLabel",{state:ke.state})]})]})]}):i.jsxs(i.Fragment,{children:[i.jsx(Rh,{className:"w-5 h-5"}),i.jsx("span",{children:n("smartPlugs.addSmartPlug.connectionFailed")})]})}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.nameLabel")}),i.jsx("input",{type:"text",value:l,onChange:De=>c(De.target.value),placeholder:n("smartPlugs.addSmartPlug.placeholders.plugName"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s==="tasmota"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.username")}),i.jsx("input",{type:"text",value:m,onChange:De=>p(De.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.password")}),i.jsx("input",{type:"password",value:f,onChange:De=>y(De.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:n("smartPlugs.authHint")})]}),s!=="mqtt"&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.linkToPrinter")}),i.jsxs("select",{value:he??"",onChange:De=>de(De.target.value?Number(De.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"",children:n("smartPlugs.noPrinter")}),Be?.map(De=>i.jsx("option",{value:De.id,children:De.name},De.id))]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("smartPlugs.linkingDescription")})]}),i.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(xh,{className:"w-4 h-4 text-bambu-green"}),i.jsx("span",{className:"text-white font-medium",children:n("smartPlugs.powerAlerts")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:Re,onChange:De=>Ae(De.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),Re&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.alertAbove")}),i.jsx("input",{type:"number",value:Pe,onChange:De=>Ue(De.target.value),placeholder:"e.g. 200",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.alertBelow")}),i.jsx("input",{type:"number",value:je,onChange:De=>Xe(De.target.value),placeholder:"e.g. 10",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.alertDescription")})]})]}),s!=="mqtt"&&i.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Jn,{className:"w-4 h-4 text-bambu-green"}),i.jsx("span",{className:"text-white font-medium",children:n("smartPlugs.dailySchedule")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:ye,onChange:De=>Ge(De.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),ye&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.turnOnAt")}),i.jsx("input",{type:"time",value:Ee,onChange:De=>Ke(De.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("smartPlugs.turnOffAt")}),i.jsx("input",{type:"time",value:Ve,onChange:De=>Ne(De.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.scheduleDescription")})]})]}),i.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(xw,{className:"w-4 h-4 text-bambu-green"}),i.jsxs("div",{children:[i.jsx("span",{className:"text-white font-medium",children:n("smartPlugs.showInSwitchbar")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.quickAccessSidebar")})]})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:Ce,onChange:De=>He(De.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),s==="homeassistant"&&i.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Ac,{className:"w-4 h-4 text-bambu-green"}),i.jsxs("div",{children:[i.jsx("span",{className:"text-white font-medium",children:n("smartPlugs.showOnPrinterCard")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("smartPlugs.displayOnPrinterCard")})]})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:et,onChange:De=>it(De.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),i.jsxs("div",{className:"flex gap-3 pt-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:n("smartPlugs.cancel")}),i.jsxs(Ie,{type:"submit",disabled:Ye,className:"flex-1",children:[Ye?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(ss,{className:"w-4 h-4"}),n(a?"smartPlugs.save":"smartPlugs.add")]})]})]})]})})}function Bn({checked:t,onChange:e,disabled:n}){const r=a=>{a.preventDefault(),a.stopPropagation(),n||e(!t)};return i.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-11 h-7 md:w-9 md:h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:i.jsx("span",{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}function met({provider:t,onEdit:e}){const{t:n}=Rt(),r=sn(),[a,s]=w.useState(!1),[o,l]=w.useState(!1),[c,u]=w.useState(null),{data:d}=tt({queryKey:["printers"],queryFn:fe.getPrinters}),m=d?.find(b=>b.id===t.printer_id),p=ft({mutationFn:b=>fe.updateNotificationProvider(t.id,b),onSuccess:()=>{r.invalidateQueries({queryKey:["notification-providers"]})}}),f=ft({mutationFn:()=>fe.deleteNotificationProvider(t.id),onSuccess:()=>{r.invalidateQueries({queryKey:["notification-providers"]})}}),y=ft({mutationFn:()=>fe.testNotificationProvider(t.id),onSuccess:b=>{u(b),r.invalidateQueries({queryKey:["notification-providers"]})},onError:b=>{u({success:!1,message:b.message})}}),v=b=>b||"";return i.jsxs(i.Fragment,{children:[i.jsx(Pt,{className:"relative",children:i.jsxs(Et,{className:"p-4",children:[i.jsxs("div",{className:"flex items-start justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:i.jsx(xh,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium text-white",children:t.name}),i.jsx("p",{className:"text-sm text-bambu-gray",children:n(`notifications.providerTypes.${t.provider_type}`,t.provider_type)})]})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&i.jsx("span",{className:"text-xs text-status-ok hidden sm:inline",children:n("notifications.lastSuccess",{date:Cf(t.last_success)})}),t.last_error&&t.last_error_at&&(!t.last_success||(Zn(t.last_error_at)?.getTime()||0)>(Zn(t.last_success)?.getTime()||0))&&i.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:n("notifications.error")}),i.jsx(Bn,{checked:t.enabled,onChange:b=>p.mutate({enabled:b})})]})]}),m&&i.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[i.jsxs("span",{className:"text-xs text-bambu-gray",children:[n("notifications.printer")," "]}),i.jsx("span",{className:"text-sm text-white",children:m.name})]}),!m&&!t.printer_id&&i.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:i.jsx("span",{className:"text-xs text-bambu-gray",children:n("notifications.allPrinters")})}),i.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&i.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:n("notifications.start")}),t.on_plate_not_empty&&i.jsx("span",{className:"px-2 py-0.5 bg-rose-600/20 text-rose-300 text-xs rounded",children:n("notifications.plateCheck")}),t.on_print_complete&&i.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:n("notifications.complete")}),t.on_print_failed&&i.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:n("notifications.failed")}),t.on_print_stopped&&i.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:n("notifications.stopped")}),t.on_print_progress&&i.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:n("notifications.progress")}),t.on_printer_offline&&i.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:n("notifications.offline")}),t.on_printer_error&&i.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:n("notifications.error")}),t.on_filament_low&&i.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:n("notifications.lowFilament")}),t.on_maintenance_due&&i.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:n("notifications.maintenance")}),t.on_ams_humidity_high&&i.jsx("span",{className:"px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded",children:n("notifications.amsHumidity")}),t.on_ams_temperature_high&&i.jsx("span",{className:"px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded",children:n("notifications.amsTemp")}),t.on_ams_ht_humidity_high&&i.jsx("span",{className:"px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded",children:n("notifications.amsHtHumidity")}),t.on_ams_ht_temperature_high&&i.jsx("span",{className:"px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded",children:n("notifications.amsHtTemp")}),t.on_bed_cooled&&i.jsx("span",{className:"px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded",children:n("notifications.bedCooled")}),t.on_first_layer_complete&&i.jsx("span",{className:"px-2 py-0.5 bg-emerald-600/20 text-emerald-300 text-xs rounded",children:n("notifications.firstLayer")}),t.quiet_hours_enabled&&i.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[i.jsx(FN,{className:"w-3 h-3"}),n("notifications.quiet")]}),t.daily_digest_enabled&&i.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[i.jsx(Yr,{className:"w-3 h-3"}),n("notifications.digest",{time:t.daily_digest_time})]})]}),i.jsx("div",{className:"mb-3",children:i.jsxs(Ie,{size:"sm",variant:"secondary",disabled:y.isPending,onClick:()=>{u(null),y.mutate()},className:"w-full",children:[y.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(iT,{className:"w-4 h-4"}),n("notifications.sendTestNotification")]})}),c&&i.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${c.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[c.success?i.jsx(fr,{className:"w-4 h-4"}):i.jsx(qi,{className:"w-4 h-4"}),i.jsx("span",{children:c.message})]}),i.jsxs("button",{onClick:()=>l(!o),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(Od,{className:"w-4 h-4"}),n("notifications.eventSettings")]}),o?i.jsx($l,{className:"w-4 h-4"}):i.jsx(On,{className:"w-4 h-4"})]}),o&&i.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.enabled")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.sendFromProvider")})]}),i.jsx(Bn,{checked:t.enabled,onChange:b=>p.mutate({enabled:b})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:n("notifications.printEvents")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.printStarted")}),i.jsx(Bn,{checked:t.on_print_start,onChange:b=>p.mutate({on_print_start:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.plateNotEmpty")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.plateNotEmptyDescription")})]}),i.jsx(Bn,{checked:t.on_plate_not_empty??!0,onChange:b=>p.mutate({on_plate_not_empty:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.printCompleted")}),i.jsx(Bn,{checked:t.on_print_complete,onChange:b=>p.mutate({on_print_complete:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.bedCooledLabel")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.bedCooledDescription")})]}),i.jsx(Bn,{checked:t.on_bed_cooled??!1,onChange:b=>p.mutate({on_bed_cooled:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.firstLayerCompleteLabel")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.firstLayerCompleteDescription")})]}),i.jsx(Bn,{checked:t.on_first_layer_complete??!1,onChange:b=>p.mutate({on_first_layer_complete:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.printFailed")}),i.jsx(Bn,{checked:t.on_print_failed,onChange:b=>p.mutate({on_print_failed:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.printStopped")}),i.jsx(Bn,{checked:t.on_print_stopped,onChange:b=>p.mutate({on_print_stopped:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.progressMilestones")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.progressMilestonesDescription")})]}),i.jsx(Bn,{checked:t.on_print_progress,onChange:b=>p.mutate({on_print_progress:b})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:n("notifications.printerStatus")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.printerOffline")}),i.jsx(Bn,{checked:t.on_printer_offline,onChange:b=>p.mutate({on_printer_offline:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.printerError")}),i.jsx(Bn,{checked:t.on_printer_error,onChange:b=>p.mutate({on_printer_error:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.lowFilamentLabel")}),i.jsx(Bn,{checked:t.on_filament_low,onChange:b=>p.mutate({on_filament_low:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.maintenanceDue")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.maintenanceDueDescription")})]}),i.jsx(Bn,{checked:t.on_maintenance_due??!1,onChange:b=>p.mutate({on_maintenance_due:b})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:n("notifications.amsAlarms")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.amsHumidityHigh")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.amsHumidityHighDescription")})]}),i.jsx(Bn,{checked:t.on_ams_humidity_high??!1,onChange:b=>p.mutate({on_ams_humidity_high:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.amsTemperatureHigh")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.amsTemperatureHighDescription")})]}),i.jsx(Bn,{checked:t.on_ams_temperature_high??!1,onChange:b=>p.mutate({on_ams_temperature_high:b})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:n("notifications.amsHtAlarms")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.amsHtHumidityHigh")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.amsHtHumidityHighDescription")})]}),i.jsx(Bn,{checked:t.on_ams_ht_humidity_high??!1,onChange:b=>p.mutate({on_ams_ht_humidity_high:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.amsHtTemperatureHigh")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.amsHtTemperatureHighDescription")})]}),i.jsx(Bn,{checked:t.on_ams_ht_temperature_high??!1,onChange:b=>p.mutate({on_ams_ht_temperature_high:b})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:n("notifications.printQueue")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.jobAdded")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.jobAddedDescription")})]}),i.jsx(Bn,{checked:t.on_queue_job_added??!1,onChange:b=>p.mutate({on_queue_job_added:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.jobAssigned")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.jobAssignedDescription")})]}),i.jsx(Bn,{checked:t.on_queue_job_assigned??!1,onChange:b=>p.mutate({on_queue_job_assigned:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.jobStarted")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.jobStartedDescription")})]}),i.jsx(Bn,{checked:t.on_queue_job_started??!1,onChange:b=>p.mutate({on_queue_job_started:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.jobWaiting")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.jobWaitingDescription")})]}),i.jsx(Bn,{checked:t.on_queue_job_waiting??!0,onChange:b=>p.mutate({on_queue_job_waiting:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.jobSkipped")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.jobSkippedDescription")})]}),i.jsx(Bn,{checked:t.on_queue_job_skipped??!0,onChange:b=>p.mutate({on_queue_job_skipped:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.jobFailed")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.jobFailedDescription")})]}),i.jsx(Bn,{checked:t.on_queue_job_failed??!0,onChange:b=>p.mutate({on_queue_job_failed:b})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:n("notifications.queueComplete")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.queueCompleteDescription")})]}),i.jsx(Bn,{checked:t.on_queue_completed??!1,onChange:b=>p.mutate({on_queue_completed:b})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(FN,{className:"w-4 h-4 text-purple-400"}),i.jsx("p",{className:"text-sm text-white",children:n("notifications.quietHours")})]}),i.jsx(Bn,{checked:t.quiet_hours_enabled,onChange:b=>p.mutate({quiet_hours_enabled:b})})]}),t.quiet_hours_enabled&&i.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.noNotificationsDuring")}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Jn,{className:"w-4 h-4 text-bambu-gray"}),i.jsxs("span",{className:"text-sm text-white",children:[v(t.quiet_hours_start)||"22:00"," - ",v(t.quiet_hours_end)||"07:00"]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.editProviderToChangeQuietHours")})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Yr,{className:"w-4 h-4 text-emerald-400"}),i.jsx("p",{className:"text-sm text-white",children:n("notifications.dailyDigest")})]}),i.jsx(Bn,{checked:t.daily_digest_enabled,onChange:b=>p.mutate({daily_digest_enabled:b})})]}),t.daily_digest_enabled&&i.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.batchNotifications")}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Jn,{className:"w-4 h-4 text-bambu-gray"}),i.jsx("span",{className:"text-sm text-white",children:n("notifications.sendAt",{time:v(t.daily_digest_time)||"08:00"})})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.editProviderToChangeDigestTime")})]})]}),i.jsxs("div",{className:"flex gap-2 pt-2",children:[i.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[i.jsx(oh,{className:"w-4 h-4"}),n("notifications.edit")]}),i.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>s(!0),className:"text-red-400 hover:text-red-300",children:i.jsx(en,{className:"w-4 h-4"})})]})]})]})}),a&&i.jsx(_n,{title:n("notifications.deleteProvider"),message:n("notifications.deleteConfirm",{name:t.name}),confirmText:n("notifications.delete"),variant:"danger",onConfirm:()=>{f.mutate(),s(!1)},onCancel:()=>s(!1)})]})}const het=["email","telegram","discord","ntfy","pushover","callmebot","webhook","homeassistant"];function pet({provider:t,onClose:e}){const{t:n}=Rt(),r=sn(),a=!!t,[s,o]=w.useState(t?.name||""),[l,c]=w.useState(t?.provider_type||"email"),[u,d]=w.useState(t?.printer_id||null),[m,p]=w.useState(t?.quiet_hours_enabled||!1),[f,y]=w.useState(t?.quiet_hours_start||"22:00"),[v,b]=w.useState(t?.quiet_hours_end||"07:00"),[g,_]=w.useState(t?.daily_digest_enabled||!1),[N,T]=w.useState(t?.daily_digest_time||"08:00"),[C,P]=w.useState(t?.on_print_start??!1),[k,R]=w.useState(t?.on_print_complete??!0),[A,D]=w.useState(t?.on_print_failed??!0),[B,z]=w.useState(t?.on_print_stopped??!0),[W,I]=w.useState(t?.on_print_progress??!1),[J,ie]=w.useState(t?.on_printer_offline??!1),[Q,ue]=w.useState(t?.on_printer_error??!1),[me,pe]=w.useState(t?.on_filament_low??!1),[Y,se]=w.useState(t?.on_maintenance_due??!1),[oe,be]=w.useState(t?.on_bed_cooled??!1),[Me,q]=w.useState(t?.on_first_layer_complete??!1),[Z,j]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([ae,L])=>[ae,String(L)])):{}),[E,U]=w.useState(null),[K,$]=w.useState(null),{data:ne}=tt({queryKey:["printers"],queryFn:fe.getPrinters});w.useEffect(()=>{const ae=L=>{L.key==="Escape"&&e()};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[e]);const O=ft({mutationFn:()=>fe.testNotificationConfig({provider_type:l,config:Z}),onSuccess:ae=>{U(ae),$(null)},onError:ae=>{U({success:!1,message:ae.message})}}),V=ft({mutationFn:ae=>fe.createNotificationProvider(ae),onSuccess:()=>{r.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:ae=>{$(ae.message)}}),ee=ft({mutationFn:ae=>fe.updateNotificationProvider(t.id,ae),onSuccess:()=>{r.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:ae=>{$(ae.message)}}),G=ae=>{if(ae.preventDefault(),$(null),!s.trim()){$(n("notifications.nameRequired"));return}const L=ge(l);for(const te of L)if(!Z[te.key]?.trim()){$(n("notifications.fieldRequired",{field:te.label}));return}const F={name:s.trim(),provider_type:l,config:Z,printer_id:u,quiet_hours_enabled:m,quiet_hours_start:m?f:null,quiet_hours_end:m?v:null,daily_digest_enabled:g,daily_digest_time:g?N:null,on_print_start:C,on_print_complete:k,on_print_failed:A,on_print_stopped:B,on_print_progress:W,on_printer_offline:J,on_printer_error:Q,on_filament_low:me,on_maintenance_due:Y,on_bed_cooled:oe,on_first_layer_complete:Me};a?ee.mutate(F):V.mutate(F)},re=V.isPending||ee.isPending,ce=ae=>{switch(ae){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"payload_format",label:"Payload Format",type:"select",required:!1,options:[{value:"generic",label:"Generic JSON"},{value:"slack",label:"Slack / Mattermost"}]},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1,showIf:L=>L.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:L=>L.payload_format!=="slack"}];case"homeassistant":return[{key:"service",label:"Home Assistant Service",placeholder:"notify.mobile_app_myphone",type:"text",required:!1}];default:return[]}},ge=ae=>ce(ae).filter(L=>L.required),xe=ce(l);return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:ae=>ae.stopPropagation(),children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[i.jsx("h2",{className:"text-lg font-semibold text-white",children:n(a?"notifications.editTitle":"notifications.addTitle")}),i.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:i.jsx(Ht,{className:"w-5 h-5"})})]}),i.jsxs("form",{onSubmit:G,className:"p-6 space-y-4",children:[K&&i.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:K}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("notifications.nameLabel")}),i.jsx("input",{type:"text",value:s,onChange:ae=>o(ae.target.value),placeholder:n("notifications.namePlaceholder"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("notifications.providerTypeLabel")}),i.jsx("select",{value:l,onChange:ae=>{c(ae.target.value),j({}),U(null)},disabled:a,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:het.map(ae=>i.jsx("option",{value:ae,children:n(`notifications.providerTypes.${ae}`,ae)},ae))}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n(`notifications.providerDescriptions.${l}`,"")})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:n("notifications.configuration")}),xe.filter(ae=>!("showIf"in ae)||ae.showIf?.(Z)!==!1).map(ae=>i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[ae.label," ",ae.required&&"*"]}),ae.type==="select"&&"options"in ae&&ae.options?i.jsx("select",{value:Z[ae.key]||ae.options[0]?.value||"",onChange:L=>{j({...Z,[ae.key]:L.target.value}),U(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:ae.options.map(L=>i.jsx("option",{value:L.value,children:L.label},L.value))}):i.jsx("input",{type:ae.type,value:Z[ae.key]||"",onChange:L=>{j({...Z,[ae.key]:L.target.value}),U(null)},placeholder:ae.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},ae.key))]}),i.jsx("div",{className:"flex gap-2",children:i.jsxs(Ie,{type:"button",variant:"secondary",onClick:()=>{U(null),O.mutate()},disabled:O.isPending||ge(l).length>0&&!Z[ge(l)[0]?.key],className:"flex-1",children:[O.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(iT,{className:"w-4 h-4"}),n("notifications.testConfiguration")]})}),E&&i.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${E.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:E.success?i.jsxs(i.Fragment,{children:[i.jsx(fr,{className:"w-5 h-5"}),i.jsx("span",{children:E.message})]}):i.jsxs(i.Fragment,{children:[i.jsx(qi,{className:"w-5 h-5"}),i.jsx("span",{children:E.message})]})}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("notifications.printerFilter")}),i.jsxs("select",{value:u??"",onChange:ae=>d(ae.target.value?Number(ae.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"",children:n("notifications.allPrinters")}),ne?.map(ae=>i.jsx("option",{value:ae.id,children:ae.name},ae.id))]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("notifications.onlyFromPrinter")})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"text-sm text-white",children:n("notifications.quietHoursDnd")}),i.jsx(Bn,{checked:m,onChange:p})]}),m&&i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:n("notifications.quietStart")}),i.jsx("input",{type:"time",value:f,onChange:ae=>y(ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:n("notifications.quietEnd")}),i.jsx("input",{type:"time",value:v,onChange:ae=>b(ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm text-white",children:n("notifications.dailyDigestLabel")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("notifications.batchNotifications")})]}),i.jsx(Bn,{checked:g,onChange:_})]}),g&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:n("notifications.sendDigestAt")}),i.jsx("input",{type:"time",value:N,onChange:ae=>T(ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("notifications.digestCollected")})]})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:n("notifications.notificationEvents")}),i.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:n("notifications.printEvents")}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.start")}),i.jsx(Bn,{checked:C,onChange:P})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.complete")}),i.jsx(Bn,{checked:k,onChange:R})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.failed")}),i.jsx(Bn,{checked:A,onChange:D})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.stopped")}),i.jsx(Bn,{checked:B,onChange:z})]}),i.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.progress")}),i.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:n("notifications.progressPercent")})]}),i.jsx(Bn,{checked:W,onChange:I})]}),i.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.bedCooled")}),i.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:n("notifications.bedCooledAfterPrint")})]}),i.jsx(Bn,{checked:oe,onChange:be})]}),i.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.firstLayerCompleteLabel")}),i.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:n("notifications.firstLayerCompleteDescription")})]}),i.jsx(Bn,{checked:Me,onChange:q})]})]})]}),i.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:n("notifications.printerStatus")}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.offline")}),i.jsx(Bn,{checked:J,onChange:ie})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.error")}),i.jsx(Bn,{checked:Q,onChange:ue})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.lowFilament")}),i.jsx(Bn,{checked:me,onChange:pe})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-white",children:n("notifications.maintenance")}),i.jsx(Bn,{checked:Y,onChange:se})]})]})]})]}),i.jsxs("div",{className:"flex gap-3 pt-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:n("notifications.cancel")}),i.jsxs(Ie,{type:"submit",disabled:re,className:"flex-1",children:[re?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(ss,{className:"w-4 h-4"}),n(a?"notifications.save":"notifications.add")]})]})]})]})})}function fet({template:t,onClose:e}){const{t:n}=Rt(),r=sn(),a=w.useRef(null),[s,o]=w.useState(t.title_template),[l,c]=w.useState(t.body_template),[u,d]=w.useState(null),[m,p]=w.useState(!0),{data:f}=tt({queryKey:["template-variables"],queryFn:fe.getTemplateVariables}),y=f?.find(P=>P.event_type===t.event_type),{data:v,isLoading:b}=tt({queryKey:["template-preview",t.event_type,s,l],queryFn:()=>fe.previewTemplate({event_type:t.event_type,title_template:s,body_template:l}),enabled:m&&s.length>0&&l.length>0});w.useEffect(()=>{const P=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[e]);const g=ft({mutationFn:P=>fe.updateNotificationTemplate(t.id,P),onSuccess:()=>{r.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:P=>{d(P.message)}}),_=ft({mutationFn:()=>fe.resetNotificationTemplate(t.id),onSuccess:P=>{o(P.title_template),c(P.body_template),r.invalidateQueries({queryKey:["notification-templates"]})},onError:P=>{d(P.message)}}),N=P=>{if(P.preventDefault(),d(null),!s.trim()){d(n("notifications.titleRequired"));return}if(!l.trim()){d(n("notifications.bodyRequired"));return}g.mutate({title_template:s,body_template:l})},T=P=>{const k=a.current;if(!k)return;const R=k.selectionStart,A=k.selectionEnd,D=l,B=D.substring(0,R),z=D.substring(A),W=B+`{${P}}`+z;c(W),setTimeout(()=>{k.focus();const I=R+P.length+2;k.setSelectionRange(I,I)},0)},C=s!==t.title_template||l!==t.body_template;return i.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[i.jsx("h2",{className:"text-lg font-semibold text-white",children:n("notifications.editTemplate",{name:t.name})}),i.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:i.jsx(Ht,{className:"w-5 h-5 text-bambu-gray"})})]}),i.jsxs("form",{onSubmit:N,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[u&&i.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:u}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:n("notifications.titleLabel")}),i.jsx("input",{type:"text",value:s,onChange:P=>o(P.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:n("notifications.titlePlaceholder")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:n("notifications.bodyLabel")}),i.jsx("textarea",{ref:a,value:l,onChange:P=>c(P.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:n("notifications.bodyPlaceholder")})]}),y&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:n("notifications.availableVariables")}),i.jsx("div",{className:"flex flex-wrap gap-2",children:y.variables.map(P=>i.jsxs("button",{type:"button",onClick:()=>T(P),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[i.jsx(ar,{className:"w-3 h-3"}),P]},P))}),i.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:n("notifications.clickToInsert")})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[i.jsx(Ac,{className:"w-4 h-4"}),n("notifications.livePreview")]}),i.jsx("button",{type:"button",onClick:()=>p(!m),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:n(m?"notifications.hide":"notifications.show")})]}),m&&i.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:b?i.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),n("notifications.loadingPreview")]}):v?i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-xs text-bambu-gray",children:n("notifications.titlePreview")}),i.jsx("div",{className:"text-white font-medium",children:v.title})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-xs text-bambu-gray",children:n("notifications.bodyPreview")}),i.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:v.body})]})]}):i.jsx("div",{className:"text-bambu-gray text-sm",children:n("notifications.enterTemplateContent")})})]})]}),i.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[i.jsxs(Ie,{type:"button",variant:"ghost",onClick:()=>_.mutate(),disabled:_.isPending,className:"text-orange-400 hover:text-orange-300",children:[_.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}):i.jsx(So,{className:"w-4 h-4 mr-2"}),n("notifications.resetToDefault")]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:e,children:n("notifications.cancel")}),i.jsxs(Ie,{onClick:N,disabled:g.isPending||!C,children:[g.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}):i.jsx(ss,{className:"w-4 h-4 mr-2"}),n("notifications.save")]})]})]})]})})}const get={print_start:"text-blue-400",print_complete:"text-bambu-green",print_failed:"text-red-400",print_stopped:"text-orange-400",print_progress:"text-yellow-400",printer_offline:"text-gray-400",printer_error:"text-rose-400",filament_low:"text-cyan-400",maintenance_due:"text-purple-400",test:"text-bambu-gray"};function bet({onClose:t}){const{t:e}=Rt(),n=sn(),{showToast:r}=fn(),[a,s]=w.useState(7),[o,l]=w.useState(null),[c,u]=w.useState(!1),{data:d}=tt({queryKey:["settings"],queryFn:fe.getSettings}),m=d?.time_format||"system",{data:p,isLoading:f,refetch:y,isRefetching:v}=tt({queryKey:["notification-logs",a,c],queryFn:()=>fe.getNotificationLogs({days:a,limit:100,success:c?!1:void 0})}),{data:b}=tt({queryKey:["notification-log-stats",a],queryFn:()=>fe.getNotificationLogStats(a)}),g=ft({mutationFn:()=>fe.clearNotificationLogs(30),onSuccess:N=>{r(N.message,"success"),n.invalidateQueries({queryKey:["notification-logs"]}),n.invalidateQueries({queryKey:["notification-log-stats"]})},onError:N=>{r(`Failed to clear logs: ${N.message}`,"error")}}),_=N=>{const T=Zn(N);if(!T)return"";const P=new Date().getTime()-T.getTime();return P<6e4?e("notifications.justNow"):P<36e5?`${Math.floor(P/6e4)}m ago`:P<864e5?`${Math.floor(P/36e5)}h ago`:T.toLocaleDateString()+" "+lQ(T,m)};return i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[i.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(x0,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:e("notifications.notificationLog")})]}),i.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),b&&i.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:i.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[i.jsxs("span",{className:"text-bambu-gray",children:[e("notifications.statsSummary",{days:a})," ",i.jsx("span",{className:"text-white font-medium",children:b.total})," ",e("notifications.statsNotifications")]}),i.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[i.jsx(fr,{className:"w-4 h-4"}),e("notifications.statsSent",{count:b.success_count})]}),b.failure_count>0&&i.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[i.jsx(qi,{className:"w-4 h-4"}),e("notifications.statsFailed",{count:b.failure_count})]})]})}),i.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[i.jsxs("select",{value:a,onChange:N=>s(Number(N.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[i.jsx("option",{value:1,children:e("notifications.last24Hours")}),i.jsx("option",{value:7,children:e("notifications.last7Days")}),i.jsx("option",{value:30,children:e("notifications.last30Days")}),i.jsx("option",{value:90,children:e("notifications.last90Days")})]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:c,onChange:N=>u(N.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),e("notifications.showFailedOnly")]}),i.jsx("div",{className:"flex-1"}),i.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:v,children:[v?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Sr,{className:"w-4 h-4"}),e("notifications.refresh")]}),i.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>g.mutate(),disabled:g.isPending,className:"text-red-400 hover:text-red-300",children:[g.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(en,{className:"w-4 h-4"}),e("notifications.clearOld")]})]}),i.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:f?i.jsx("div",{className:"flex justify-center py-12",children:i.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):p&&p.length>0?i.jsx("div",{className:"space-y-2",children:p.map(N=>i.jsx(xet,{log:N,isExpanded:o===N.id,onToggle:()=>l(o===N.id?null:N.id),formatDate:_,formatFullDate:T=>Tf(T,m)},N.id))}):i.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[i.jsx(x0,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),i.jsx("p",{className:"text-sm",children:e(c?"notifications.noFailedNotifications":"notifications.noNotificationsLogged")})]})})]})})}function xet({log:t,isExpanded:e,onToggle:n,formatDate:r,formatFullDate:a}){const{t:s}=Rt();return i.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[i.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?i.jsx(fr,{className:"w-4 h-4 text-bambu-green shrink-0"}):i.jsx(qi,{className:"w-4 h-4 text-red-400 shrink-0"}),i.jsx("span",{className:`text-xs font-medium ${get[t.event_type]||"text-bambu-gray"}`,children:s(`notifications.eventTypes.${t.event_type}`,t.event_type)}),i.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||s("notifications.unknownProvider")}),t.printer_name&&i.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),i.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?i.jsx($l,{className:"w-4 h-4 text-bambu-gray shrink-0"}):i.jsx(On,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&i.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:s("notifications.logTitle")}),i.jsx("p",{className:"text-sm text-white",children:t.title})]}),i.jsxs("div",{children:[i.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:s("notifications.logMessage")}),i.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&i.jsxs("div",{children:[i.jsx("p",{className:"text-xs text-red-400 mb-1",children:s("notifications.logError")}),i.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),i.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[i.jsx("span",{children:s("notifications.logProvider",{type:t.provider_type})}),i.jsx("span",{children:s("notifications.logTime",{time:a(t.created_at)})})]})]})]})}function yet({formData:t,setFormData:e,groups:n,onClose:r,onCreate:a,isCreating:s,isCreateButtonDisabled:o}){const{t:l}=Rt();w.useEffect(()=>{const u=d=>{d.key==="Escape"&&r()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[r]);const c=u=>{e({...t,group_ids:t.group_ids.includes(u)?t.group_ids.filter(d=>d!==u):[...t.group_ids,u]})};return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:r,children:i.jsxs(Pt,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Jm,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:l("users.modal.createUser")})]}),i.jsx("p",{className:"text-sm text-bambu-gray ml-7",children:l("users.modal.advancedAuthSubtitle")||"with Advanced Authentication"})]}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:r,children:i.jsx(Ht,{className:"w-5 h-5"})})]})}),i.jsxs(Et,{children:[i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[l("users.form.username")," ",i.jsx("span",{className:"text-red-400",children:"*"})]}),i.jsx("input",{type:"text",value:t.username,onChange:u=>e({...t,username:u.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:l("users.form.usernamePlaceholder"),autoComplete:"username",required:!0})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[l("users.form.email")||"Email"," ",i.jsx("span",{className:"text-red-400",children:"*"})]}),i.jsx("input",{type:"email",value:t.email,onChange:u=>e({...t,email:u.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:l("users.form.emailPlaceholder")||"user@example.com",required:!0})]}),i.jsx("div",{className:"bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3",children:i.jsx("p",{className:"text-sm text-bambu-gray",children:l("users.form.autoGeneratedPassword")||"A secure password will be automatically generated and emailed to the user."})}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:l("users.form.groups")}),i.jsxs("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:[n.map(u=>i.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:t.group_ids.includes(u.id),onChange:()=>c(u.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),i.jsx("span",{className:"text-sm text-white",children:u.name}),u.is_system&&i.jsxs("span",{className:"text-xs text-yellow-400",children:["(",l("users.system"),")"]})]},u.id)),n.length===0&&i.jsx("p",{className:"text-sm text-bambu-gray",children:l("users.noGroupsAvailable")})]})]})]}),i.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[i.jsx(Ie,{variant:"secondary",onClick:r,children:l("users.modal.cancel")}),i.jsx(Ie,{onClick:a,disabled:o,children:s?i.jsxs(i.Fragment,{children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),l("users.modal.creating")]}):i.jsxs(i.Fragment,{children:[i.jsx(ar,{className:"w-4 h-4"}),l("users.modal.createUser")]})})]})]})]})})}function vet(){const{t}=Rt(),e=sn(),{showToast:n}=fn(),[r,a]=w.useState(!1),[s,o]=w.useState(""),[l,c]=w.useState("auto"),[u,d]=w.useState(!1),[m,p]=w.useState(!0),[f,y]=w.useState("all"),[v,b]=w.useState(!1),[g,_]=w.useState(!1),[N,T]=w.useState(!1),{data:C,isLoading:P}=tt({queryKey:["spoolman-settings"],queryFn:fe.getSpoolmanSettings}),{data:k,isLoading:R,refetch:A}=tt({queryKey:["spoolman-status"],queryFn:fe.getSpoolmanStatus,refetchInterval:3e4}),{data:D}=tt({queryKey:["printers"],queryFn:fe.getPrinters});w.useEffect(()=>{C&&(a(C.spoolman_enabled==="true"),o(C.spoolman_url||""),c(C.spoolman_sync_mode||"auto"),d(C.spoolman_disable_weight_sync==="true"),p(C.spoolman_report_partial_usage!=="false"),b(!0))},[C]),w.useEffect(()=>{if(!v||!C)return;if(C.spoolman_enabled==="true"!==r||(C.spoolman_url||"")!==s||(C.spoolman_sync_mode||"auto")!==l||C.spoolman_disable_weight_sync==="true"!==u||C.spoolman_report_partial_usage!=="false"!==m){const se=setTimeout(()=>{B.mutate()},500);return()=>clearTimeout(se)}},[r,s,l,u,m,v]);const B=ft({mutationFn:()=>fe.updateSpoolmanSettings({spoolman_enabled:r?"true":"false",spoolman_url:s,spoolman_sync_mode:l,spoolman_disable_weight_sync:u?"true":"false",spoolman_report_partial_usage:m?"true":"false"}),onSuccess:()=>{e.invalidateQueries({queryKey:["spoolman-settings"]}),e.invalidateQueries({queryKey:["spoolman-status"]}),e.invalidateQueries({queryKey:["spool-assignments"]}),e.invalidateQueries({queryKey:["settings"]}),n(t("settings.toast.settingsSaved"))}}),z=ft({mutationFn:fe.connectSpoolman,onSuccess:()=>{A()}}),W=ft({mutationFn:fe.disconnectSpoolman,onSuccess:()=>{A()}}),I=ft({mutationFn:fe.syncAllPrintersAms,onSuccess:Y=>{Y.success}}),J=ft({mutationFn:Y=>fe.syncPrinterAms(Y),onSuccess:Y=>{Y.success}}),ie=()=>{f==="all"?I.mutate():J.mutate(f)},Q=ft({mutationFn:fe.syncWeightsFromAms,onSuccess:Y=>{e.invalidateQueries({queryKey:["spools"]}),e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("settings.amsSyncSuccess",{synced:Y.synced,skipped:Y.skipped}),"success"),T(!1)},onError:()=>{n(t("settings.amsSyncError"),"error"),T(!1)}}),ue=I.isPending||J.isPending,me=f==="all"?I.data:J.data,pe=f==="all"?I.isSuccess:J.isSuccess;return P?i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(mu,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.filamentTracking")})]})}),i.jsx(Et,{children:i.jsx("div",{className:"flex justify-center py-8",children:i.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(mu,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.filamentTracking")})]}),B.isPending&&i.jsx(pt,{className:"w-4 h-4 text-bambu-green animate-spin"})]})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:t("settings.filamentTrackingDesc")}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("button",{type:"button",onClick:()=>a(!1),className:`p-3 rounded-lg border-2 text-left transition-colors ${r?"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray/50":"border-bambu-green bg-bambu-green/10"}`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[i.jsx(Gi,{className:`w-4 h-4 ${r?"text-bambu-gray":"text-bambu-green"}`}),i.jsx("span",{className:`text-sm font-medium ${r?"text-bambu-gray":"text-white"}`,children:t("settings.trackingModeBuiltIn")})]}),i.jsx("p",{className:`text-xs ${r?"text-bambu-gray/60":"text-bambu-gray"}`,children:t("settings.trackingModeBuiltInDesc")}),!r&&i.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[i.jsx(Qr,{className:"w-3 h-3 text-bambu-green"}),i.jsx("span",{className:"text-xs text-bambu-green",children:t("common.enabled")})]})]}),i.jsxs("button",{type:"button",onClick:()=>a(!0),className:`p-3 rounded-lg border-2 text-left transition-colors ${r?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray/50"}`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[i.jsx(ti,{className:`w-4 h-4 ${r?"text-bambu-green":"text-bambu-gray"}`}),i.jsx("span",{className:`text-sm font-medium ${r?"text-white":"text-bambu-gray"}`,children:"Spoolman"})]}),i.jsx("p",{className:`text-xs ${r?"text-bambu-gray":"text-bambu-gray/60"}`,children:t("settings.trackingModeSpoolmanDesc")}),r&&i.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[i.jsx(Qr,{className:"w-3 h-3 text-bambu-green"}),i.jsx("span",{className:"text-xs text-bambu-green",children:t("common.enabled")})]})]})]}),!r&&i.jsxs("div",{className:"space-y-3",children:[i.jsx("div",{className:"p-3 bg-bambu-green/5 border border-bambu-green/20 rounded-lg",children:i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Us,{className:"w-4 h-4 text-bambu-green flex-shrink-0 mt-0.5"}),i.jsx("div",{className:"text-xs text-bambu-gray",children:i.jsxs("ul",{className:"list-disc list-inside space-y-0.5",children:[i.jsx("li",{children:t("settings.builtInFeatureRfid")}),i.jsx("li",{children:t("settings.builtInFeatureUsage")}),i.jsx("li",{children:t("settings.builtInFeatureCatalog")}),i.jsx("li",{children:t("settings.builtInFeatureThirdParty")})]})})]})}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>T(!0),disabled:Q.isPending,children:[Q.isPending?i.jsx(pt,{className:"w-4 h-4 mr-2 animate-spin"}):i.jsx(Sr,{className:"w-4 h-4 mr-2"}),t("settings.amsSyncButton")]})]}),r&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Us,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"text-xs text-blue-300",children:[i.jsx("p",{className:"font-medium mb-1",children:t("settings.howSyncWorks")}),i.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[i.jsx("li",{children:t("settings.syncInfoRfidOnly")}),i.jsx("li",{children:t("settings.syncInfoAutoCreate")}),i.jsx("li",{children:t("settings.syncInfoThirdPartySkipped")})]}),i.jsx("p",{className:"font-medium mt-2 mb-1",children:t("settings.linkingExistingSpools")}),i.jsx("p",{className:"text-blue-300/80",children:t("settings.linkingExistingSpoolsDesc")})]})]})}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("settings.spoolmanUrl")}),i.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:s,onChange:Y=>o(Y.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none"}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:t("settings.spoolmanUrlHint")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("settings.syncMode")}),i.jsxs("select",{value:l,onChange:Y=>c(Y.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"auto",children:t("settings.syncModeAuto")}),i.jsx("option",{value:"manual",children:t("settings.syncModeManual")})]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:t(l==="auto"?"settings.syncModeAutoDesc":"settings.syncModeManualDesc")})]}),l==="auto"&&i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:t("spoolman.disableWeightSync")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("spoolman.disableWeightSyncDesc")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:u,onChange:Y=>d(Y.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),u&&i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:t("spoolman.reportPartialUsage")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("spoolman.reportPartialUsageDesc")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:m,onChange:Y=>p(Y.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("settings.status"),":"]}),R?i.jsx(pt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):k?.connected?i.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[i.jsx(Qr,{className:"w-4 h-4"}),t("settings.spoolmanConnected")]}):i.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[i.jsx(Ht,{className:"w-4 h-4"}),t("settings.spoolmanDisconnected")]})]}),i.jsx("div",{className:"flex gap-2",children:k?.connected?i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>W.mutate(),disabled:W.isPending,children:[W.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(jfe,{className:"w-4 h-4"}),t("settings.disconnect")]}):i.jsxs(Ie,{size:"sm",onClick:()=>z.mutate(),disabled:z.isPending||!s,children:[z.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(_h,{className:"w-4 h-4"}),t("settings.connect")]})})]}),z.isError&&i.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:z.error.message}),k?.connected&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-white",children:t("settings.syncAmsData")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:t("settings.syncAmsDataDesc")})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsxs("select",{value:f,onChange:Y=>y(Y.target.value==="all"?"all":Number(Y.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[i.jsx("option",{value:"all",children:t("settings.allPrinters")}),D?.map(Y=>i.jsx("option",{value:Y.id,children:Y.name},Y.id))]}),i.jsx(On,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:ie,disabled:ue,children:[ue?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Sr,{className:"w-4 h-4"}),t("spoolman.sync")]})]})]}),pe&&me&&i.jsxs("div",{className:"mt-3 space-y-2",children:[i.jsx("div",{className:`p-2 rounded text-sm ${me.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:me.success?`Synced ${me.synced_count} spool${me.synced_count!==1?"s":""} successfully`:`Synced ${me.synced_count} spool${me.synced_count!==1?"s":""} with ${me.errors.length} error${me.errors.length!==1?"s":""}`}),me.skipped_count>0&&i.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[i.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Mn,{className:"w-3.5 h-3.5"}),i.jsxs("span",{className:"font-medium",children:[me.skipped_count," spool",me.skipped_count!==1?"s":""," skipped"]})]}),me.skipped_count>5&&i.jsx("button",{onClick:()=>_(!g),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:g?"Show less":"Show all"})]}),i.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(g?me.skipped:me.skipped.slice(0,5)).map((Y,se)=>i.jsxs("li",{className:"flex items-center gap-2",children:[Y.color&&i.jsx("span",{className:"w-3 h-3 rounded-full border border-black/20",style:{backgroundColor:`#${Y.color}`}}),i.jsx("span",{children:Y.location}),i.jsxs("span",{className:"text-amber-300/60",children:["- ",Y.reason]})]},se)),!g&&me.skipped_count>5&&i.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",me.skipped_count-5," more"]})]})]}),me.errors.length>0&&i.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[i.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),i.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:me.errors.map((Y,se)=>i.jsx("li",{children:Y},se))})]})]})]})]})]}),N&&i.jsx(_n,{title:t("settings.amsSyncTitle"),message:t("settings.amsSyncMessage"),confirmText:t("settings.amsSyncButton"),variant:"warning",isLoading:Q.isPending,loadingText:t("settings.amsSyncing"),onConfirm:()=>Q.mutate(),onCancel:()=>T(!1)})]})}function wet(){const{t}=Rt(),{showToast:e}=fn(),[n,r]=w.useState([]),[a,s]=w.useState(!0),[o,l]=w.useState(""),c=w.useRef(null),[u,d]=w.useState(!1),[m,p]=w.useState(null),[f,y]=w.useState(""),[v,b]=w.useState(""),[g,_]=w.useState(!1),[N,T]=w.useState(new Set),[C,P]=w.useState(!1),[k,R]=w.useState(null),[A,D]=w.useState(!1),B=w.useCallback(async()=>{try{const be=await fe.getSpoolCatalog();r(be)}catch{e(t("settings.catalog.loadFailed"),"error")}finally{s(!1)}},[e,t]);w.useEffect(()=>{B()},[B]);const z=n.filter(be=>be.name.toLowerCase().includes(o.toLowerCase())),W=async()=>{if(!f.trim()||!v){e(t("settings.catalog.nameWeightRequired"),"error");return}_(!0);try{const be=await fe.addCatalogEntry({name:f.trim(),weight:parseInt(v)});r(Me=>[...Me,be].sort((q,Z)=>q.name.localeCompare(Z.name))),d(!1),y(""),b(""),e(t("settings.catalog.entryAdded"),"success")}catch{e(t("settings.catalog.addFailed"),"error")}finally{_(!1)}},I=be=>{p(be.id),y(be.name),b(be.weight.toString())},J=()=>{p(null),y(""),b("")},ie=async be=>{if(!f.trim()||!v){e(t("settings.catalog.nameWeightRequired"),"error");return}_(!0);try{const Me=await fe.updateCatalogEntry(be,{name:f.trim(),weight:parseInt(v)});r(q=>q.map(Z=>Z.id===be?Me:Z).sort((Z,j)=>Z.name.localeCompare(j.name))),p(null),y(""),b(""),e(t("settings.catalog.entryUpdated"),"success")}catch{e(t("settings.catalog.updateFailed"),"error")}finally{_(!1)}},Q=async()=>{if(k)try{await fe.deleteCatalogEntry(k.id),r(be=>be.filter(Me=>Me.id!==k.id)),e(t("settings.catalog.entryDeleted"),"success")}catch{e(t("settings.catalog.deleteFailed"),"error")}finally{R(null)}},ue=async()=>{D(!1),s(!0);try{await fe.resetSpoolCatalog(),await B(),e(t("settings.catalog.resetSuccess"),"success")}catch{e(t("settings.catalog.resetFailed"),"error"),s(!1)}},me=be=>{T(Me=>{const q=new Set(Me);return q.has(be)?q.delete(be):q.add(be),q})},pe=()=>{N.size===z.length?T(new Set):T(new Set(z.map(be=>be.id)))},Y=async()=>{if(P(!1),N.size!==0)try{const be=await fe.bulkDeleteCatalogEntries([...N]);r(Me=>Me.filter(q=>!N.has(q.id))),T(new Set),e(t("settings.catalog.bulkDeleted",{count:be.deleted}),"success")}catch{e(t("settings.catalog.bulkDeleteFailed"),"error")}},se=()=>{const be=n.map(({name:j,weight:E})=>({name:j,weight:E})),Me=new Blob([JSON.stringify(be,null,2)],{type:"application/json"}),q=URL.createObjectURL(Me),Z=document.createElement("a");Z.href=q,Z.download="spool-catalog.json",document.body.appendChild(Z),Z.click(),document.body.removeChild(Z),URL.revokeObjectURL(q),e(t("settings.catalog.exported",{count:n.length}),"success")},oe=async be=>{const Me=be.target.files?.[0];if(Me){try{const q=await Me.text(),Z=JSON.parse(q);if(!Array.isArray(Z))throw new Error("Invalid format");let j=0,E=0;for(const U of Z){if(!U.name||typeof U.weight!="number"){E++;continue}if(n.some($=>$.name.toLowerCase()===U.name.toLowerCase())){E++;continue}try{const $=await fe.addCatalogEntry({name:U.name,weight:U.weight});r(ne=>[...ne,$].sort((O,V)=>O.name.localeCompare(V.name))),j++}catch{E++}}e(t("settings.catalog.imported",{added:j,skipped:E}),"success")}catch{e(t("settings.catalog.importFailed"),"error")}c.current&&(c.current.value="")}};return i.jsxs(Pt,{children:[i.jsxs(Hn,{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(mu,{className:"w-5 h-5 text-bambu-gray"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.catalog.spoolCatalog")}),i.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",n.length,")"]})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsxs("button",{onClick:se,className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.exportTooltip"),children:[i.jsx(bi,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.export")})]}),i.jsxs("button",{onClick:()=>c.current?.click(),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.importTooltip"),children:[i.jsx(vi,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.import")})]}),i.jsx("input",{ref:c,type:"file",accept:".json",className:"hidden",onChange:oe}),i.jsxs("button",{onClick:()=>D(!0),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.resetTooltip"),children:[i.jsx(So,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.reset")})]}),i.jsxs("button",{onClick:()=>d(!0),className:"px-3 py-1.5 text-sm bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 transition-colors flex items-center gap-1.5",children:[i.jsx(ar,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.add")})]})]}),N.size>0&&i.jsxs("div",{className:"flex items-center gap-2 mt-2 px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg",children:[i.jsx("span",{className:"text-sm text-red-400",children:t("settings.catalog.selectedCount",{count:N.size})}),i.jsxs("button",{onClick:()=>P(!0),className:"ml-auto px-3 py-1.5 text-sm bg-red-500 text-white rounded-lg hover:bg-red-600 transition-colors flex items-center gap-1.5",children:[i.jsx(en,{className:"w-4 h-4"}),t("settings.catalog.deleteSelected")]}),i.jsx("button",{onClick:()=>T(new Set),className:"px-3 py-1.5 text-sm text-bambu-gray hover:text-white transition-colors",children:t("common.cancel")})]})]}),i.jsxs(Et,{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:t("settings.catalog.spoolCatalogDescription")}),i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),i.jsx("input",{type:"text",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.catalog.searchCatalog"),value:o,onChange:be=>l(be.target.value)})]}),u&&i.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[i.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:t("settings.catalog.addNewEntry")}),i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsx("div",{className:"flex-1 min-w-0",children:i.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.catalog.namePlaceholder"),value:f,onChange:be=>y(be.target.value)})}),i.jsx("input",{type:"number",className:"w-20 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-center focus:border-bambu-green focus:outline-none",placeholder:"g",value:v,onChange:be=>b(be.target.value)}),i.jsx("span",{className:"text-bambu-gray shrink-0",children:"g"}),i.jsxs("button",{onClick:W,disabled:g,className:"px-3 py-2 bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 flex items-center gap-1 shrink-0",children:[g?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Qr,{className:"w-4 h-4"}),t("common.add")]}),i.jsx("button",{onClick:()=>{d(!1),y(""),b("")},className:"p-2 rounded-lg text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary",children:i.jsx(Ht,{className:"w-4 h-4"})})]})]}),a?i.jsxs("div",{className:"flex items-center justify-center py-8 text-bambu-gray",children:[i.jsx(pt,{className:"w-5 h-5 animate-spin mr-2"}),t("common.loading")]}):i.jsx("div",{className:"max-h-[600px] overflow-y-auto border border-bambu-dark-tertiary rounded-lg",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{className:"bg-bambu-dark sticky top-0",children:i.jsxs("tr",{children:[i.jsx("th",{className:"px-2 py-2 w-10",children:i.jsx("input",{type:"checkbox",checked:z.length>0&&N.size===z.length,onChange:pe,className:"w-4 h-4 accent-bambu-green cursor-pointer"})}),i.jsx("th",{className:"px-4 py-2 text-left text-bambu-gray font-medium",children:t("common.name")}),i.jsx("th",{className:"px-4 py-2 text-right text-bambu-gray font-medium w-24",children:t("settings.catalog.weight")}),i.jsx("th",{className:"px-4 py-2 text-center text-bambu-gray font-medium w-20",children:t("settings.catalog.type")}),i.jsx("th",{className:"px-4 py-2 w-24"})]})}),i.jsx("tbody",{children:z.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:5,className:"px-4 py-8 text-center text-bambu-gray",children:t(o?"settings.catalog.noMatch":"settings.catalog.empty")})}):z.map(be=>i.jsx("tr",{className:`border-t border-bambu-dark-tertiary hover:bg-bambu-dark ${N.has(be.id)?"bg-bambu-dark":""}`,children:m===be.id?i.jsxs(i.Fragment,{children:[i.jsx("td",{className:"px-2 py-2",children:i.jsx("input",{type:"checkbox",checked:N.has(be.id),onChange:()=>me(be.id),className:"w-4 h-4 accent-bambu-green cursor-pointer"})}),i.jsx("td",{className:"px-4 py-2",children:i.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white focus:border-bambu-green focus:outline-none",value:f,onChange:Me=>y(Me.target.value)})}),i.jsx("td",{className:"px-4 py-2",children:i.jsx("input",{type:"number",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-right focus:border-bambu-green focus:outline-none",value:v,onChange:Me=>b(Me.target.value)})}),i.jsx("td",{className:"px-4 py-2 text-center",children:i.jsx("span",{className:"text-xs text-bambu-gray",children:"-"})}),i.jsx("td",{className:"px-4 py-2",children:i.jsxs("div",{className:"flex justify-end gap-1",children:[i.jsx("button",{onClick:()=>ie(be.id),disabled:g,className:"p-1.5 rounded hover:bg-green-500/20 text-green-500",children:g?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Qr,{className:"w-4 h-4"})}),i.jsx("button",{onClick:J,className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray",children:i.jsx(Ht,{className:"w-4 h-4"})})]})})]}):i.jsxs(i.Fragment,{children:[i.jsx("td",{className:"px-2 py-2",children:i.jsx("input",{type:"checkbox",checked:N.has(be.id),onChange:()=>me(be.id),className:"w-4 h-4 accent-bambu-green cursor-pointer"})}),i.jsx("td",{className:"px-4 py-2 text-white",children:be.name}),i.jsxs("td",{className:"px-4 py-2 text-right font-mono text-white",children:[be.weight,"g"]}),i.jsx("td",{className:"px-4 py-2 text-center",children:be.is_default?i.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-bambu-dark-tertiary text-bambu-gray",children:t("settings.catalog.default")}):i.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-bambu-green/20 text-bambu-green",children:t("settings.catalog.custom")})}),i.jsx("td",{className:"px-4 py-2",children:i.jsxs("div",{className:"flex justify-end gap-1",children:[i.jsx("button",{onClick:()=>I(be),className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:i.jsx(Ki,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>R(be),className:"p-1.5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-500",children:i.jsx(en,{className:"w-4 h-4"})})]})})]})},be.id))})]})})]}),k&&i.jsx(_n,{title:t("settings.catalog.deleteEntry"),message:t("settings.catalog.deleteConfirm",{name:k.name}),confirmText:t("common.delete"),variant:"danger",onConfirm:Q,onCancel:()=>R(null)}),C&&i.jsx(_n,{title:t("settings.catalog.deleteSelected"),message:t("settings.catalog.bulkDeleteConfirm",{count:N.size}),confirmText:t("common.delete"),variant:"danger",onConfirm:Y,onCancel:()=>P(!1)}),A&&i.jsx(_n,{title:t("settings.catalog.resetCatalog"),message:t("settings.catalog.resetConfirm"),confirmText:t("common.reset"),variant:"danger",onConfirm:ue,onCancel:()=>D(!1)})]})}function _et(){const{t}=Rt(),{showToast:e}=fn(),[n,r]=w.useState([]),[a,s]=w.useState(!0),[o,l]=w.useState(""),[c,u]=w.useState("Bambu Lab"),d=w.useRef(null),[m,p]=w.useState(!1),[f,y]=w.useState(null),[v,b]=w.useState(""),[g,_]=w.useState(""),[N,T]=w.useState("#FFFFFF"),[C,P]=w.useState(""),[k,R]=w.useState(!1),[A,D]=w.useState(new Set),[B,z]=w.useState(!1),[W,I]=w.useState(!1),[J,ie]=w.useState(null),[Q,ue]=w.useState(null),[me,pe]=w.useState(!1),Y=w.useCallback(async()=>{try{const G=await fe.getColorCatalog();r(G)}catch{e(t("settings.colorCatalog.loadFailed"),"error")}finally{s(!1)}},[e,t]);w.useEffect(()=>{Y()},[Y]);const se=[...new Set(n.map(G=>G.manufacturer))].sort(),oe=n.filter(G=>{const re=o===""||G.manufacturer.toLowerCase().includes(o.toLowerCase())||G.color_name.toLowerCase().includes(o.toLowerCase())||(G.material?.toLowerCase().includes(o.toLowerCase())??!1),ce=c===""||G.manufacturer===c;return re&&ce}),be=()=>{b(""),_(""),T("#FFFFFF"),P("")},Me=async()=>{if(!v.trim()||!g.trim()||!N){e(t("settings.colorCatalog.fieldsRequired"),"error");return}R(!0);try{const G=await fe.addColorEntry({manufacturer:v.trim(),color_name:g.trim(),hex_color:N,material:C.trim()||null});r(re=>[...re,G].sort((ce,ge)=>ce.manufacturer.localeCompare(ge.manufacturer)||(ce.material||"").localeCompare(ge.material||"")||ce.color_name.localeCompare(ge.color_name))),p(!1),be(),e(t("settings.colorCatalog.colorAdded"),"success")}catch{e(t("settings.colorCatalog.addFailed"),"error")}finally{R(!1)}},q=G=>{y(G.id),b(G.manufacturer),_(G.color_name),T(G.hex_color),P(G.material||"")},Z=()=>{y(null),be()},j=async G=>{if(!v.trim()||!g.trim()||!N){e(t("settings.colorCatalog.fieldsRequired"),"error");return}R(!0);try{const re=await fe.updateColorEntry(G,{manufacturer:v.trim(),color_name:g.trim(),hex_color:N,material:C.trim()||null});r(ce=>ce.map(ge=>ge.id===G?re:ge).sort((ge,xe)=>ge.manufacturer.localeCompare(xe.manufacturer)||(ge.material||"").localeCompare(xe.material||"")||ge.color_name.localeCompare(xe.color_name))),y(null),be(),e(t("settings.colorCatalog.colorUpdated"),"success")}catch{e(t("settings.colorCatalog.updateFailed"),"error")}finally{R(!1)}},E=async()=>{if(Q)try{await fe.deleteColorEntry(Q.id),r(G=>G.filter(re=>re.id!==Q.id)),e(t("settings.colorCatalog.colorDeleted"),"success")}catch{e(t("settings.colorCatalog.deleteFailed"),"error")}finally{ue(null)}},U=async()=>{pe(!1),s(!0);try{await fe.resetColorCatalog(),await Y(),e(t("settings.colorCatalog.resetSuccess"),"success")}catch{e(t("settings.colorCatalog.resetFailed"),"error"),s(!1)}},K=async()=>{I(!0),ie(null);try{const G={},re=Ud();re&&(G.Authorization=`Bearer ${re}`);const ce=await fetch("/api/v1/inventory/colors/sync",{method:"POST",headers:G});if(!ce.ok)throw new Error("Failed to start sync");const ge=ce.body?.getReader();if(!ge)throw new Error("No response body");const xe=new TextDecoder;let ae="";for(;;){const{done:L,value:F}=await ge.read();if(L)break;ae+=xe.decode(F,{stream:!0});const te=ae.split(` `);ae=te.pop()||"";for(const ve of te)if(ve.startsWith("data: "))try{const he=JSON.parse(ve.slice(6));he.type==="progress"?ie({fetched:he.total_fetched,total:he.total_available}):he.type==="complete"?he.added===0?e(t("settings.colorCatalog.syncUpToDate",{count:he.total_fetched}),"success"):e(t("settings.colorCatalog.syncComplete",{added:he.added,skipped:he.skipped}),"success"):he.type==="error"&&e(`${t("settings.colorCatalog.syncError")}: ${he.error}`,"error")}catch{}}await Y()}catch{e(t("settings.colorCatalog.syncFailed"),"error")}finally{I(!1),ie(null)}},$=G=>{D(re=>{const ce=new Set(re);return ce.has(G)?ce.delete(G):ce.add(G),ce})},ne=()=>{A.size===oe.length?D(new Set):D(new Set(oe.map(G=>G.id)))},O=async()=>{if(z(!1),A.size!==0)try{const G=await fe.bulkDeleteColorEntries([...A]);r(re=>re.filter(ce=>!A.has(ce.id))),D(new Set),e(t("settings.colorCatalog.bulkDeleted",{count:G.deleted}),"success")}catch{e(t("settings.colorCatalog.bulkDeleteFailed"),"error")}},V=()=>{const G=n.map(({manufacturer:xe,color_name:ae,hex_color:L,material:F})=>({manufacturer:xe,color_name:ae,hex_color:L,material:F})),re=new Blob([JSON.stringify(G,null,2)],{type:"application/json"}),ce=URL.createObjectURL(re),ge=document.createElement("a");ge.href=ce,ge.download="color-catalog.json",document.body.appendChild(ge),ge.click(),document.body.removeChild(ge),URL.revokeObjectURL(ce),e(t("settings.colorCatalog.exported",{count:n.length}),"success")},ee=async G=>{const re=G.target.files?.[0];if(re){try{const ce=await re.text(),ge=JSON.parse(ce);if(!Array.isArray(ge))throw new Error("Invalid format");let xe=0,ae=0;for(const L of ge){if(!L.manufacturer||!L.color_name||!L.hex_color){ae++;continue}if(n.some(te=>te.manufacturer.toLowerCase()===L.manufacturer.toLowerCase()&&te.color_name.toLowerCase()===L.color_name.toLowerCase()&&(te.material||"").toLowerCase()===(L.material||"").toLowerCase())){ae++;continue}try{const te=await fe.addColorEntry({manufacturer:L.manufacturer,color_name:L.color_name,hex_color:L.hex_color,material:L.material||null});r(ve=>[...ve,te].sort((he,de)=>he.manufacturer.localeCompare(de.manufacturer)||(he.material||"").localeCompare(de.material||"")||he.color_name.localeCompare(de.color_name))),xe++}catch{ae++}}e(t("settings.colorCatalog.imported",{added:xe,skipped:ae}),"success")}catch{e(t("settings.colorCatalog.importFailed"),"error")}d.current&&(d.current.value="")}};return i.jsxs(Pt,{children:[i.jsxs(Hn,{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(yw,{className:"w-5 h-5 text-bambu-gray"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.colorCatalog.title")}),i.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",n.length,")"]})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsxs("button",{onClick:V,className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",children:[i.jsx(bi,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.export")})]}),i.jsxs("button",{onClick:()=>d.current?.click(),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",children:[i.jsx(vi,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.import")})]}),i.jsx("input",{ref:d,type:"file",accept:".json",className:"hidden",onChange:ee}),i.jsxs("button",{onClick:K,disabled:W,className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.colorCatalog.syncTooltip"),children:[W?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Ox,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:W?J?`${Math.min(J.fetched,J.total)} / ${J.total}`:t("settings.colorCatalog.starting"):t("settings.colorCatalog.sync")})]}),i.jsxs("button",{onClick:()=>pe(!0),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",children:[i.jsx(So,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.reset")})]}),i.jsxs("button",{onClick:()=>p(!0),className:"px-3 py-1.5 text-sm bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 transition-colors flex items-center gap-1.5",children:[i.jsx(ar,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.add")})]})]}),A.size>0&&i.jsxs("div",{className:"flex items-center gap-2 mt-2 px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg",children:[i.jsx("span",{className:"text-sm text-red-400",children:t("settings.colorCatalog.selectedCount",{count:A.size})}),i.jsxs("button",{onClick:()=>z(!0),className:"ml-auto px-3 py-1.5 text-sm bg-red-500 text-white rounded-lg hover:bg-red-600 transition-colors flex items-center gap-1.5",children:[i.jsx(en,{className:"w-4 h-4"}),t("settings.colorCatalog.deleteSelected")]}),i.jsx("button",{onClick:()=>D(new Set),className:"px-3 py-1.5 text-sm text-bambu-gray hover:text-white transition-colors",children:t("common.cancel")})]})]}),i.jsxs(Et,{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:t("settings.colorCatalog.description")}),i.jsxs("div",{className:"flex gap-2 flex-wrap",children:[i.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),i.jsx("input",{type:"text",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.colorCatalog.searchColors"),value:o,onChange:G=>l(G.target.value)})]}),i.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:c,onChange:G=>u(G.target.value),children:[i.jsx("option",{value:"",children:t("settings.colorCatalog.allManufacturers")}),se.map(G=>i.jsx("option",{value:G,children:G},G))]})]}),m&&i.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[i.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:t("settings.colorCatalog.addNewColor")}),i.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-2 items-end",children:[i.jsx("input",{type:"text",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.colorCatalog.manufacturer"),value:v,onChange:G=>b(G.target.value)}),i.jsx("input",{type:"text",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.colorCatalog.colorName"),value:g,onChange:G=>_(G.target.value)}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"color",className:"w-20 h-10 rounded cursor-pointer border border-bambu-dark-tertiary",value:N,onChange:G=>T(G.target.value)}),i.jsx("input",{type:"text",className:"w-32 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:"#FFFFFF",value:N,onChange:G=>T(G.target.value)})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("input",{type:"text",className:"flex-1 max-w-lg min-w-[200px] px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.colorCatalog.materialOptional"),value:C,onChange:G=>P(G.target.value)}),i.jsxs("button",{onClick:Me,disabled:k,className:"w-24 px-3 py-2 bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 flex items-center justify-center gap-3",children:[k?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Qr,{className:"w-4 h-4"}),t("common.add")]}),i.jsx("button",{onClick:()=>{p(!1),be()},className:"p-2 ml-2 rounded-lg text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary",children:i.jsx(Ht,{className:"w-4 h-4"})})]})]})]}),(o||c)&&i.jsx("div",{className:"text-xs text-bambu-gray",children:t("settings.colorCatalog.showing",{filtered:oe.length,total:n.length})}),a?i.jsxs("div",{className:"flex items-center justify-center py-8 text-bambu-gray",children:[i.jsx(pt,{className:"w-5 h-5 animate-spin mr-2"}),t("common.loading")]}):i.jsx("div",{className:"max-h-[600px] overflow-auto border border-bambu-dark-tertiary rounded-lg",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{className:"bg-bambu-dark sticky top-0",children:i.jsxs("tr",{children:[i.jsx("th",{className:"px-2 py-2 w-10",children:i.jsx("input",{type:"checkbox",checked:oe.length>0&&A.size===oe.length,onChange:ne,className:"w-4 h-4 accent-bambu-green cursor-pointer"})}),i.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium w-12"}),i.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium",children:t("settings.colorCatalog.manufacturer")}),i.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium",children:t("inventory.material")}),i.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium",children:t("settings.colorCatalog.colorName")}),i.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium w-24",children:t("settings.colorCatalog.hex")}),i.jsx("th",{className:"px-3 py-2 w-16"})]})}),i.jsx("tbody",{children:oe.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:7,className:"px-3 py-8 text-center text-bambu-gray",children:t(o||c?"settings.colorCatalog.noMatch":"settings.colorCatalog.empty")})}):oe.map(G=>i.jsx("tr",{className:`border-t border-bambu-dark-tertiary hover:bg-bambu-dark ${A.has(G.id)?"bg-bambu-dark":""}`,children:f===G.id?i.jsxs(i.Fragment,{children:[i.jsx("td",{className:"px-2 py-2",children:i.jsx("input",{type:"checkbox",checked:A.has(G.id),onChange:()=>$(G.id),className:"w-4 h-4 accent-bambu-green cursor-pointer"})}),i.jsx("td",{className:"px-3 py-2",children:i.jsx("input",{type:"color",className:"w-8 h-8 rounded cursor-pointer border border-bambu-dark-tertiary",value:N,onChange:re=>T(re.target.value)})}),i.jsx("td",{className:"px-3 py-2",children:i.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",value:v,onChange:re=>b(re.target.value)})}),i.jsx("td",{className:"px-3 py-2",children:i.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",value:C,onChange:re=>P(re.target.value)})}),i.jsx("td",{className:"px-3 py-2",children:i.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",value:g,onChange:re=>_(re.target.value)})}),i.jsx("td",{className:"px-3 py-2",children:i.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",value:N,onChange:re=>T(re.target.value)})}),i.jsx("td",{className:"px-3 py-2",children:i.jsxs("div",{className:"flex justify-end gap-1",children:[i.jsx("button",{onClick:()=>j(G.id),disabled:k,className:"p-1.5 rounded hover:bg-green-500/20 text-green-500",children:k?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Qr,{className:"w-4 h-4"})}),i.jsx("button",{onClick:Z,className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray",children:i.jsx(Ht,{className:"w-4 h-4"})})]})})]}):i.jsxs(i.Fragment,{children:[i.jsx("td",{className:"px-2 py-2",children:i.jsx("input",{type:"checkbox",checked:A.has(G.id),onChange:()=>$(G.id),className:"w-4 h-4 accent-bambu-green cursor-pointer"})}),i.jsx("td",{className:"px-3 py-2",children:i.jsx("div",{className:"w-8 h-8 rounded border border-bambu-dark-tertiary",style:{backgroundColor:G.hex_color},title:G.hex_color})}),i.jsx("td",{className:"px-3 py-2 text-white",children:G.manufacturer}),i.jsx("td",{className:"px-3 py-2 text-bambu-gray",children:G.material||"-"}),i.jsx("td",{className:"px-3 py-2 text-white",children:G.color_name}),i.jsx("td",{className:"px-3 py-2 font-mono text-xs text-bambu-gray",children:G.hex_color}),i.jsx("td",{className:"px-3 py-2",children:i.jsxs("div",{className:"flex justify-end gap-1",children:[i.jsx("button",{onClick:()=>q(G),className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:i.jsx(Ki,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>ue(G),className:"p-1.5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-500",children:i.jsx(en,{className:"w-4 h-4"})})]})})]})},G.id))})]})})]}),Q&&i.jsx(_n,{title:t("settings.colorCatalog.deleteColor"),message:t("settings.colorCatalog.deleteConfirm",{name:`${Q.manufacturer} - ${Q.color_name}`}),confirmText:t("common.delete"),variant:"danger",onConfirm:E,onCancel:()=>ue(null)}),B&&i.jsx(_n,{title:t("settings.colorCatalog.deleteSelected"),message:t("settings.colorCatalog.bulkDeleteConfirm",{count:A.size}),confirmText:t("common.delete"),variant:"danger",onConfirm:O,onCancel:()=>z(!1)}),me&&i.jsx(_n,{title:t("settings.colorCatalog.resetCatalog"),message:t("settings.colorCatalog.resetConfirm"),confirmText:t("common.reset"),variant:"danger",onConfirm:U,onCancel:()=>pe(!1)})]})}function Net({link:t,onClose:e}){const{t:n}=Rt(),r=sn(),a=!!t,s=w.useRef(null),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.url||""),[d,m]=w.useState(t?.icon||"link"),[p,f]=w.useState(t?.open_in_new_tab||!1),[y,v]=w.useState(!!t?.custom_icon),[b,g]=w.useState(t?.custom_icon?fe.getExternalLinkIconUrl(t.id):null),[_,N]=w.useState(null),[T,C]=w.useState(null);w.useEffect(()=>{const W=I=>{I.key==="Escape"&&e()};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[e]);const P=ft({mutationFn:async W=>{const I=await fe.createExternalLink(W);return _?await fe.uploadExternalLinkIcon(I.id,_):I},onSuccess:()=>{r.invalidateQueries({queryKey:["external-links"]}),e()},onError:W=>{C(W.message)}}),k=ft({mutationFn:async W=>{let I=await fe.updateExternalLink(t.id,W);return _?I=await fe.uploadExternalLinkIcon(t.id,_):!y&&t?.custom_icon&&(I=await fe.deleteExternalLinkIcon(t.id)),I},onSuccess:()=>{r.invalidateQueries({queryKey:["external-links"]}),e()},onError:W=>{C(W.message)}}),R=W=>{const I=W.target.files?.[0];if(I){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(I.type)){C("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(I.size>1024*1024){C("Image file must be less than 1MB");return}N(I),v(!0);const ie=new FileReader;ie.onload=Q=>{g(Q.target?.result)},ie.readAsDataURL(I)}},A=()=>{N(null),g(null),v(!1),s.current&&(s.current.value="")},D=W=>{if(W.preventDefault(),C(null),!o.trim()){C("Name is required");return}if(!c.trim()){C("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){C("URL must start with http:// or https://");return}const I={name:o.trim(),url:c.trim(),icon:d,open_in_new_tab:p};a?k.mutate(I):P.mutate(I)},B=P.isPending||k.isPending,z=oT(d);return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:W=>W.stopPropagation(),children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:y&&b?i.jsx("img",{src:b,alt:"",className:"w-5 h-5 rounded"}):i.jsx(z,{className:"w-5 h-5"})}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:a?"Edit Link":"Add External Link"})]}),i.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:i.jsx(Ht,{className:"w-5 h-5"})})]}),i.jsxs("form",{onSubmit:D,className:"p-6 space-y-4",children:[T&&i.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:T}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),i.jsx("input",{type:"text",value:o,onChange:W=>l(W.target.value),placeholder:"My Link",maxLength:50,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),i.jsx("input",{type:"text",value:c,onChange:W=>u(W.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"text-sm text-bambu-gray",children:n("externalLinks.openInNewTab")}),i.jsx("button",{type:"button",onClick:()=>f(!p),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${p?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${p?"translate-x-6":"translate-x-1"}`})})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),i.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),i.jsx("input",{ref:s,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:R}),y&&b?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("img",{src:b,alt:"Custom icon",className:"w-8 h-8 rounded border border-bambu-dark-tertiary"}),i.jsx("button",{type:"button",onClick:A,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:i.jsx(en,{className:"w-4 h-4"})})]}):i.jsxs(Ie,{type:"button",variant:"secondary",size:"sm",onClick:()=>s.current?.click(),children:[i.jsx(vi,{className:"w-4 h-4"}),"Upload"]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!y&&i.jsxs("div",{children:[i.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),i.jsx(Wbe,{value:d,onChange:m})]})]}),i.jsxs("div",{className:"flex gap-3 pt-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),i.jsxs(Ie,{type:"submit",disabled:B,className:"flex-1",children:[B?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(ss,{className:"w-4 h-4"}),a?"Save":"Add"]})]})]})]})})}function ket(){const{t}=Rt(),e=sn(),[n,r]=w.useState(!1),[a,s]=w.useState(null),[o,l]=w.useState(null),[c,u]=w.useState(null),{data:d,isLoading:m}=tt({queryKey:["external-links"],queryFn:fe.getExternalLinks}),p=ft({mutationFn:N=>fe.deleteExternalLink(N),onSuccess:()=>{e.invalidateQueries({queryKey:["external-links"]})}}),f=ft({mutationFn:N=>fe.reorderExternalLinks(N),onSuccess:()=>{e.invalidateQueries({queryKey:["external-links"]})}}),y=(N,T)=>{u(T),N.dataTransfer.effectAllowed="move"},v=N=>{N.preventDefault(),N.dataTransfer.dropEffect="move"},b=(N,T)=>{if(N.preventDefault(),c===null||c===T||!d)return;const C=d.map(A=>A.id),P=C.indexOf(c),k=C.indexOf(T);if(P===-1||k===-1)return;const R=[...C];R.splice(P,1),R.splice(k,0,c),f.mutate(R),u(null)},g=N=>{l(N)},_=()=>{o&&(p.mutate(o.id),l(null))};return i.jsxs(i.Fragment,{children:[i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(_h,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),i.jsxs(Ie,{size:"sm",onClick:()=>r(!0),children:[i.jsx(ar,{className:"w-4 h-4"}),"Add Link"]})]})}),i.jsxs(Et,{children:[i.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),m?i.jsx("div",{className:"flex justify-center py-8",children:i.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):d&&d.length>0?i.jsx("div",{className:"space-y-2",children:d.map(N=>{const T=oT(N.icon);return i.jsxs("div",{draggable:!0,onDragStart:C=>y(C,N.id),onDragOver:v,onDrop:C=>b(C,N.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${c===N.id?"opacity-50":""}`,children:[i.jsx(Sh,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),i.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:i.jsx(T,{className:"w-4 h-4"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-white font-medium truncate",children:N.name}),i.jsx(ti,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),i.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:N.url})]}),i.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[i.jsx("button",{onClick:()=>s(N),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:t("common.edit"),children:i.jsx(Ki,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>g(N),disabled:p.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:t("externalLinks.deleteLink"),children:i.jsx(en,{className:"w-4 h-4"})})]})]},N.id)})}):i.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[i.jsx(_h,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),i.jsx("p",{children:t("externalLinks.noLinksConfigured")}),i.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(n||a)&&i.jsx(Net,{link:a,onClose:()=>{r(!1),s(null)}}),o&&i.jsx(_n,{title:"Delete Link",message:`Are you sure you want to delete "${o.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:_,onCancel:()=>l(null)})]})}const UD={immediate:"archive",review:"review",print_queue:"queue",proxy:"proxy"};function Cet({printer:t,models:e}){const{t:n}=Rt(),r=sn(),{showToast:a}=fn(),[s,o]=w.useState(!0),[l,c]=w.useState(t.enabled),[u,d]=w.useState(t.name),[m,p]=w.useState(""),[f,y]=w.useState(t.mode==="queue"?"review":t.mode),[v,b]=w.useState(t.target_printer_id),[g,_]=w.useState(t.bind_ip||""),[N,T]=w.useState(t.remote_interface_ip||""),[C,P]=w.useState(t.model||""),[k,R]=w.useState(t.auto_dispatch??!0),[A,D]=w.useState(!1),[B,z]=w.useState(null),[W,I]=w.useState(!1);w.useEffect(()=>{B||(c(t.enabled),y(t.mode==="queue"?"review":t.mode),d(t.name),b(t.target_printer_id),_(t.bind_ip||""),T(t.remote_interface_ip||""),P(t.model||""),R(t.auto_dispatch??!0))},[t,B]);const{data:J}=tt({queryKey:["printers"],queryFn:fe.getPrinters}),{data:ie}=tt({queryKey:["network-interfaces"],queryFn:()=>fe.getNetworkInterfaces().then(E=>E.interfaces)}),Q=ft({mutationFn:E=>ON.update(t.id,E),onSuccess:()=>{r.invalidateQueries({queryKey:["virtual-printers"]}),a(n("virtualPrinter.toast.updated")),z(null)},onError:E=>{a(E.message||n("virtualPrinter.toast.failedToUpdate"),"error"),c(t.enabled),y(t.mode==="queue"?"review":t.mode),b(t.target_printer_id),_(t.bind_ip||""),z(null)}}),ue=ft({mutationFn:()=>ON.remove(t.id),onSuccess:()=>{r.invalidateQueries({queryKey:["virtual-printers"]}),a(n("virtualPrinter.toast.deleted")),I(!1)},onError:E=>{a(E.message||n("virtualPrinter.toast.failedToDelete"),"error"),I(!1)}}),me=E=>{E.stopPropagation();const U=!l;if(U){if(!g){a(n("virtualPrinter.toast.bindIpRequired"),"error");return}if(f==="proxy"){if(!v){a(n("virtualPrinter.toast.targetPrinterRequired"),"error");return}}else if(!m&&!t.access_code_set){a(n("virtualPrinter.toast.accessCodeRequired"),"error");return}}c(U),z("toggle"),Q.mutate({enabled:U})},pe=()=>{u.trim()&&(z("name"),Q.mutate({name:u.trim()}))},Y=()=>{if(!m){a(n("virtualPrinter.toast.accessCodeEmpty"),"error");return}if(m.length!==8){a(n("virtualPrinter.toast.accessCodeLength"),"error");return}z("accessCode"),Q.mutate({access_code:m}),p("")},se=E=>{y(E),z("mode"),Q.mutate({mode:E})},oe=E=>{P(E),z("model"),Q.mutate({model:E})},be=E=>{b(E),z("targetPrinter"),Q.mutate({target_printer_id:E})},Me=E=>{T(E),z("remoteInterface"),Q.mutate({remote_interface_ip:E})},q=t.status?.running||!1,Z=n(`virtualPrinter.mode.${UD[f]||"archive"}`),j=J?.find(E=>E.id===v)?.name;return i.jsxs(i.Fragment,{children:[i.jsxs(Pt,{children:[i.jsxs("div",{className:"px-4 py-3 flex items-center gap-3 cursor-pointer select-none",onClick:()=>o(!s),children:[i.jsx("button",{className:"text-bambu-gray flex-shrink-0",children:s?i.jsx(On,{className:"w-4 h-4"}):i.jsx(fa,{className:"w-4 h-4"})}),i.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${q?"bg-green-400 animate-pulse":"bg-gray-500"}`}),i.jsx("span",{className:"text-white font-medium truncate",children:t.name}),i.jsx("span",{className:"text-xs text-bambu-gray flex-shrink-0",children:Z}),t.model_name&&i.jsx("span",{className:"text-xs text-bambu-gray flex-shrink-0",children:t.model_name}),j&&i.jsxs("span",{className:"text-xs text-bambu-gray flex-shrink-0 truncate",children:[f==="proxy"&&i.jsx(f3,{className:"w-3 h-3 inline mr-1"}),j]}),g&&i.jsx("span",{className:"text-[10px] text-bambu-gray flex-shrink-0 font-mono",children:g}),N&&i.jsx("span",{className:"text-[10px] text-bambu-gray flex-shrink-0 font-mono",children:N}),i.jsx("div",{className:"ml-auto flex items-center gap-2 flex-shrink-0",onClick:E=>E.stopPropagation(),children:i.jsx("button",{onClick:me,disabled:B==="toggle",className:`relative w-10 h-5 rounded-full transition-colors ${l?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${B==="toggle"?"opacity-50":""}`,children:i.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform ${l?"translate-x-5":""}`})})})]}),s&&i.jsxs(Et,{className:"pt-0 space-y-4",children:[i.jsx("div",{className:"border-t border-bambu-dark-tertiary"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"text",value:u,onChange:E=>d(E.target.value),onBlur:pe,onKeyDown:E=>E.key==="Enter"&&pe(),className:"flex-1 text-sm text-white bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 focus:border-bambu-green focus:outline-none"}),i.jsx("span",{className:"text-xs text-bambu-gray font-mono",children:t.serial}),i.jsx("button",{onClick:()=>I(!0),className:"p-1.5 text-bambu-gray hover:text-red-400 transition-colors",title:n("common.delete"),children:i.jsx(en,{className:"w-4 h-4"})})]}),i.jsxs("div",{children:[i.jsx("div",{className:"text-white text-sm font-medium mb-2",children:n("virtualPrinter.mode.title")}),i.jsx("div",{className:"grid grid-cols-2 gap-2",children:["immediate","review","print_queue","proxy"].map(E=>i.jsxs("button",{onClick:()=>se(E),disabled:B==="mode",className:`p-2 rounded-lg border text-left transition-colors ${f===E?E==="proxy"?"border-blue-500 bg-blue-500/10":"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[i.jsxs("div",{className:"flex items-center gap-1.5 text-white text-xs font-medium",children:[E==="proxy"&&i.jsx(f3,{className:"w-3 h-3"}),n(`virtualPrinter.mode.${UD[E]}`)]}),i.jsx("div",{className:"text-[10px] text-bambu-gray",children:n(`virtualPrinter.mode.${UD[E]}Desc`)})]},E))})]}),f==="print_queue"&&i.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-white text-sm font-medium",children:n("virtualPrinter.autoDispatch.title")}),i.jsx("div",{className:"text-[10px] text-bambu-gray",children:n("virtualPrinter.autoDispatch.description")})]}),i.jsx("button",{onClick:()=>{const E=!k;R(E),z("autoDispatch"),Q.mutate({auto_dispatch:E})},disabled:B==="autoDispatch",className:`relative w-10 h-5 rounded-full transition-colors flex-shrink-0 ${k?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${B==="autoDispatch"?"opacity-50":""}`,children:i.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform ${k?"translate-x-5":""}`})})]})}),f!=="proxy"&&i.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[i.jsx("div",{className:"text-white text-sm font-medium mb-1",children:n("virtualPrinter.model.title")}),i.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:n("virtualPrinter.model.description")}),i.jsxs("div",{className:"relative",children:[i.jsx("select",{value:C,onChange:E=>oe(E.target.value),disabled:B==="model",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm appearance-none cursor-pointer disabled:opacity-50 pr-10",children:Object.entries(e).map(([E,U])=>i.jsxs("option",{value:E,children:[U," (",E,")"]},E))}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),f==="proxy"&&i.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:i.jsxs("div",{className:"flex items-start gap-2 p-2 rounded bg-blue-500/10 border border-blue-500/30",children:[i.jsx(Us,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("virtualPrinter.proxy.accessCodeHint")})]})}),f!=="proxy"&&i.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx("div",{className:"text-white text-sm font-medium",children:n("virtualPrinter.accessCode.title")}),t.access_code_set?i.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-400",children:[i.jsx(Qr,{className:"w-3 h-3"}),n("virtualPrinter.accessCode.isSet")]}):i.jsxs("span",{className:"flex items-center gap-1 text-xs text-yellow-400",children:[i.jsx(Mn,{className:"w-3 h-3"}),n("virtualPrinter.accessCode.notSet")]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx("input",{type:A?"text":"password",value:m,onChange:E=>p(E.target.value),placeholder:t.access_code_set?n("virtualPrinter.accessCode.placeholderChange"):n("virtualPrinter.accessCode.placeholder"),maxLength:8,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm placeholder-bambu-gray pr-10 font-mono"}),i.jsx("button",{onClick:()=>D(!A),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:A?i.jsx(fw,{className:"w-4 h-4"}):i.jsx(Ac,{className:"w-4 h-4"})})]}),i.jsx(Ie,{onClick:Y,disabled:!m||B==="accessCode",variant:"primary",children:B==="accessCode"?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):n("common.save")})]}),m&&i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i.jsx("span",{className:m.length===8?"text-green-400":"text-yellow-400",children:n("virtualPrinter.accessCode.charCount",{count:m.length})})})]}),i.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[i.jsx("div",{className:"text-white text-sm font-medium mb-2",children:n("virtualPrinter.targetPrinter.title")}),i.jsxs("div",{className:"relative",children:[i.jsxs("select",{value:v??"",onChange:E=>{const U=parseInt(E.target.value,10);isNaN(U)||be(U)},disabled:B==="targetPrinter",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm appearance-none cursor-pointer disabled:opacity-50 pr-10",children:[i.jsx("option",{value:"",children:n("virtualPrinter.targetPrinter.placeholder")}),J?.map(E=>i.jsxs("option",{value:E.id,children:[E.name," (",E.ip_address,")"]},E.id))]}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),i.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[i.jsx("div",{className:"text-white text-sm font-medium mb-1",children:n("virtualPrinter.bindIp.title")}),i.jsxs("div",{className:"relative",children:[i.jsxs("select",{value:g,onChange:E=>{_(E.target.value),z("bindIp"),Q.mutate({bind_ip:E.target.value})},disabled:B==="bindIp",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm appearance-none cursor-pointer disabled:opacity-50 pr-10",children:[i.jsx("option",{value:"",children:n("virtualPrinter.bindIp.placeholder")}),ie?.map(E=>i.jsxs("option",{value:E.ip,children:[E.name," (",E.ip,")",E.is_alias?" [alias]":""," - ",E.subnet]},E.ip))]}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("virtualPrinter.bindIp.hint")})]}),i.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx("div",{className:"text-white text-sm font-medium",children:n("virtualPrinter.remoteInterface.title")}),N?i.jsx("span",{className:"flex items-center gap-1 text-xs text-green-400",children:i.jsx(Qr,{className:"w-3 h-3"})}):i.jsx("span",{className:"flex items-center gap-1 text-xs text-bambu-gray",title:n("virtualPrinter.remoteInterface.optional"),children:i.jsx(Us,{className:"w-3 h-3"})})]}),i.jsxs("div",{className:"relative",children:[i.jsxs("select",{value:N,onChange:E=>Me(E.target.value),disabled:B==="remoteInterface",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm appearance-none cursor-pointer disabled:opacity-50 pr-10",children:[i.jsx("option",{value:"",children:n("virtualPrinter.remoteInterface.placeholder")}),ie?.map(E=>i.jsxs("option",{value:E.ip,children:[E.name," (",E.ip,") - ",E.subnet]},E.ip))]}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]})]})]}),W&&i.jsx(_n,{title:n("virtualPrinter.deleteConfirm.title"),message:n("virtualPrinter.deleteConfirm.message",{name:t.name}),variant:"danger",confirmText:n("common.delete"),isLoading:ue.isPending,onConfirm:()=>ue.mutate(),onCancel:()=>I(!1)})]})}const kY={immediate:"archive",review:"review",print_queue:"queue",proxy:"proxy"};function Tet({onClose:t}){const{t:e}=Rt(),n=sn(),{showToast:r}=fn(),[a,s]=w.useState(""),[o,l]=w.useState("immediate"),[c,u]=w.useState(null),{data:d}=tt({queryKey:["printers"],queryFn:fe.getPrinters}),m=ft({mutationFn:()=>ON.create({name:a.trim()||"Bambuddy",mode:o,target_printer_id:o==="proxy"?c??void 0:void 0}),onSuccess:()=>{n.invalidateQueries({queryKey:["virtual-printers"]}),r(e("virtualPrinter.toast.created")),t()},onError:p=>{r(p.message||e("virtualPrinter.toast.failedToCreate"),"error")}});return i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:i.jsx(Pt,{className:"w-full max-w-md",onClick:p=>p.stopPropagation(),children:i.jsxs(Et,{className:"p-6 space-y-4",children:[i.jsx("h3",{className:"text-lg font-semibold text-white",children:e("virtualPrinter.addDialog.title")}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm text-white font-medium block mb-1",children:e("virtualPrinter.addDialog.name")}),i.jsx("input",{type:"text",value:a,onChange:p=>s(p.target.value),placeholder:"Bambuddy",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm placeholder-bambu-gray",autoFocus:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm text-white font-medium block mb-1",children:e("virtualPrinter.mode.title")}),i.jsx("div",{className:"grid grid-cols-2 gap-2",children:["immediate","review","print_queue","proxy"].map(p=>i.jsxs("button",{onClick:()=>l(p),className:`p-2 rounded-lg border text-left transition-colors ${o===p?p==="proxy"?"border-blue-500 bg-blue-500/10":"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[i.jsxs("div",{className:"flex items-center gap-1.5 text-white text-xs font-medium",children:[p==="proxy"&&i.jsx(f3,{className:"w-3 h-3"}),e(`virtualPrinter.mode.${kY[p]}`)]}),i.jsx("div",{className:"text-[10px] text-bambu-gray",children:e(`virtualPrinter.mode.${kY[p]}Desc`)})]},p))})]}),o==="proxy"&&i.jsxs("div",{children:[i.jsx("label",{className:"text-sm text-white font-medium block mb-1",children:e("virtualPrinter.targetPrinter.title")}),i.jsxs("div",{className:"relative",children:[i.jsxs("select",{value:c??"",onChange:p=>{const f=parseInt(p.target.value,10);u(isNaN(f)?null:f)},className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm appearance-none cursor-pointer pr-10",children:[i.jsx("option",{value:"",children:e("virtualPrinter.targetPrinter.placeholder")}),d?.map(p=>i.jsxs("option",{value:p.id,children:[p.name," (",p.ip_address,")"]},p.id))]}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:e("virtualPrinter.addDialog.hint")}),i.jsxs("div",{className:"flex gap-3 pt-2",children:[i.jsx(Ie,{variant:"secondary",onClick:t,className:"flex-1",disabled:m.isPending,children:e("common.cancel")}),i.jsx(Ie,{variant:"primary",onClick:()=>m.mutate(),className:"flex-1",disabled:m.isPending,children:m.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):e("virtualPrinter.addDialog.create")})]})]})})})}function Aet(){const{t}=Rt(),[e,n]=w.useState(!1),{data:r,isLoading:a}=tt({queryKey:["virtual-printers"],queryFn:ON.list,refetchInterval:1e4});if(a)return i.jsx(Pt,{children:i.jsx(Et,{className:"py-8 flex justify-center",children:i.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const s=r?.printers||[],o=r?.models||{};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-4 items-stretch",children:[i.jsx(Pt,{className:"border-l-4 border-l-yellow-500",children:i.jsx(Et,{className:"py-3 px-4",children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx(Mn,{className:"w-4 h-4 text-yellow-500 flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"text-xs",children:[i.jsx("p",{className:"text-white font-medium",children:t("virtualPrinter.setupRequired.title")}),i.jsx("p",{className:"text-bambu-gray mt-1",children:t("virtualPrinter.setupRequired.description")}),i.jsxs("a",{href:"https://wiki.bambuddy.cool/features/virtual-printer/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 mt-2 px-3 py-1.5 bg-yellow-500/20 border border-yellow-500/50 rounded text-yellow-400 hover:bg-yellow-500/30 transition-colors text-xs",children:[i.jsx(ti,{className:"w-3 h-3"}),t("virtualPrinter.setupRequired.readGuide")]})]})]})})}),i.jsx(Pt,{className:"lg:col-span-3",children:i.jsx(Et,{className:"py-3 px-4",children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx(Us,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"text-xs text-bambu-gray",children:[i.jsx("p",{className:"text-white font-medium mb-1",children:t("virtualPrinter.howItWorks.title")}),i.jsxs("ul",{className:"space-y-1 list-disc list-inside",children:[i.jsx("li",{children:t("virtualPrinter.howItWorks.step1")}),i.jsx("li",{children:t("virtualPrinter.howItWorks.step2")}),i.jsx("li",{children:t("virtualPrinter.howItWorks.step3")})]})]})]})})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(_r,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:t("virtualPrinter.list.title")}),i.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",s.length,")"]})]}),i.jsxs(Ie,{variant:"primary",onClick:()=>n(!0),children:[i.jsx(ar,{className:"w-4 h-4 mr-1"}),t("virtualPrinter.list.add")]})]}),s.length===0?i.jsx(Pt,{children:i.jsxs(Et,{className:"py-8 text-center",children:[i.jsx(_r,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),i.jsx("p",{className:"text-bambu-gray mb-4",children:t("virtualPrinter.list.empty")}),i.jsxs(Ie,{variant:"primary",onClick:()=>n(!0),children:[i.jsx(ar,{className:"w-4 h-4 mr-1"}),t("virtualPrinter.list.addFirst")]})]})}):i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4 items-start",children:s.map(l=>i.jsx(Cet,{printer:l,models:o},l.id))}),e&&i.jsx(Tet,{onClose:()=>n(!1)})]})}function Pet(t){if(!t)return"-";const e=Zn(t);return e?e.toLocaleString():"-"}function CY({status:t}){if(!t)return null;const e={success:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",skipped:"bg-yellow-500/20 text-yellow-400",running:"bg-blue-500/20 text-blue-400"},n={success:i.jsx(fr,{className:"w-3 h-3"}),failed:i.jsx(qi,{className:"w-3 h-3"}),skipped:i.jsx(VL,{className:"w-3 h-3"}),running:i.jsx(pt,{className:"w-3 h-3 animate-spin"})};return i.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium ${e[t]||"bg-gray-500/20 text-gray-400"}`,children:[n[t],t.charAt(0).toUpperCase()+t.slice(1)]})}function Met(){const t=sn(),{showToast:e}=fn(),{t:n}=Rt(),[r,a]=w.useState(""),[s,o]=w.useState(""),[l,c]=w.useState("main"),[u,d]=w.useState(!1),[m,p]=w.useState("daily"),[f,y]=w.useState(!0),[v,b]=w.useState(!0),[g,_]=w.useState(!1),[N,T]=w.useState(!0),[C,P]=w.useState(!1),[k,R]=w.useState(!1),[A,D]=w.useState(""),[B,z]=w.useState(!1),[W,I]=w.useState(null),[J,ie]=w.useState(null),Q=w.useRef(null);w.useEffect(()=>{if(C||k){const L=F=>(F.preventDefault(),F.returnValue="A backup operation is in progress. Are you sure you want to leave?",F.returnValue);return window.addEventListener("beforeunload",L),()=>window.removeEventListener("beforeunload",L)}},[C,k]);const[ue,me]=w.useState(!1),[pe,Y]=w.useState(null),se=w.useRef(null),oe=w.useRef(!1),{data:be,isLoading:Me}=tt({queryKey:["github-backup-config"],queryFn:fe.getGitHubBackupConfig}),{data:q}=tt({queryKey:["github-backup-status"],queryFn:fe.getGitHubBackupStatus,refetchInterval:ae=>ae.state.data?.is_running?500:1e4}),{data:Z}=tt({queryKey:["github-backup-logs"],queryFn:()=>fe.getGitHubBackupLogs(20)}),{data:j}=tt({queryKey:["cloud-status"],queryFn:fe.getCloudStatus}),{data:E}=tt({queryKey:["printers"],queryFn:fe.getPrinters}),U=Yf({queries:(E??[]).map(ae=>({queryKey:["printerStatus",ae.id],queryFn:()=>fe.getPrinterStatus(ae.id),staleTime:1e4,refetchInterval:3e4}))}),K=(E??[]).map((ae,L)=>({printer:ae,connected:U[L]?.data?.connected??!1})),$=K.length,ne=K.filter(ae=>ae.connected).length,O=$>0&&ne===0,V=ne>0&&ne<$;w.useEffect(()=>{be&&(a(be.repository_url),c(be.branch),d(be.schedule_enabled),p(be.schedule_type),y(be.backup_kprofiles),b(be.backup_cloud_profiles),_(be.backup_settings),T(be.enabled),o(""),setTimeout(()=>{oe.current=!0},100))},[be]);const ee=w.useCallback(async(ae=!1)=>{if(be?.has_token)try{ae&&s?(await fe.saveGitHubBackupConfig({repository_url:r,access_token:s,branch:l,schedule_enabled:u,schedule_type:m,backup_kprofiles:f,backup_cloud_profiles:v,backup_settings:g,enabled:N}),o(""),e(n("backup.tokenUpdated"))):(await fe.updateGitHubBackupConfig({repository_url:r,branch:l,schedule_enabled:u,schedule_type:m,backup_kprofiles:f,backup_cloud_profiles:v,backup_settings:g,enabled:N}),e(n("backup.settingsSaved"))),t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]})}catch(L){e(n("backup.failedToSave",{message:L.message}),"error")}},[be?.has_token,r,s,l,u,m,f,v,g,N,t,e,n]);w.useEffect(()=>{if(!(!oe.current||!be?.has_token))return se.current&&clearTimeout(se.current),se.current=setTimeout(()=>{ee(!1)},500),()=>{se.current&&clearTimeout(se.current)}},[r,l,u,m,f,v,g,N,ee,be?.has_token]),w.useEffect(()=>{if(!(!oe.current||!be?.has_token||!s))return se.current&&clearTimeout(se.current),se.current=setTimeout(()=>{ee(!0)},1e3),()=>{se.current&&clearTimeout(se.current)}},[s,ee,be?.has_token]);const G=ft({mutationFn:ae=>fe.saveGitHubBackupConfig(ae),onSuccess:()=>{t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]}),e(n("backup.githubBackupEnabled")),o(""),oe.current=!0},onError:ae=>{e(n("backup.failedToSave",{message:ae.message}),"error")}}),re=ft({mutationFn:fe.triggerGitHubBackup,onSuccess:ae=>{t.invalidateQueries({queryKey:["github-backup-status"]}),t.invalidateQueries({queryKey:["github-backup-logs"]}),ae.success?ae.files_changed>0?e(n("backup.backupCompleteFiles",{count:ae.files_changed})):e(n("backup.backupSkippedNoChanges")):e(n("backup.backupFailed2",{message:ae.message}),"error")},onError:ae=>{e(n("backup.backupFailed2",{message:ae.message}),"error")}}),ce=ft({mutationFn:()=>fe.clearGitHubBackupLogs(0),onSuccess:ae=>{t.invalidateQueries({queryKey:["github-backup-logs"]}),e(n("backup.clearedLogs",{count:ae.deleted}))},onError:ae=>{e(n("backup.failedToClearLogs",{message:ae.message}),"error")}}),ge=async()=>{me(!0),Y(null);try{let ae;if(s){if(!r){e(n("backup.enterRepoUrl"),"error"),me(!1);return}ae=await fe.testGitHubConnection(r,s)}else if(be?.has_token)ae=await fe.testGitHubStoredConnection();else{e(n("backup.enterRepoAndToken"),"error"),me(!1);return}Y({success:ae.success,message:ae.message})}catch(ae){Y({success:!1,message:ae.message})}finally{me(!1)}},xe=()=>{if(!r){e(n("backup.repoRequired"),"error");return}if(!s){e(n("backup.tokenRequired"),"error");return}G.mutate({repository_url:r,access_token:s,branch:l,schedule_enabled:u,schedule_type:m,backup_kprofiles:f,backup_cloud_profiles:v,backup_settings:g,enabled:N})};return Me?i.jsx("div",{className:"flex items-center justify-center py-12",children:i.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[i.jsxs("div",{className:"space-y-6",children:[i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(b3,{className:"w-5 h-5 text-gray-400"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:n("backup.githubBackup")})]}),be&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.enabled")}),i.jsx(Bn,{checked:N,onChange:T})]})]})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.githubDescription")}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("backup.repositoryUrl")}),i.jsx("input",{type:"text",value:r,onChange:ae=>{a(ae.target.value),Y(null)},placeholder:"https://github.com/username/bambuddy-backup",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[n("backup.personalAccessToken")," ",be?.has_token&&i.jsx("span",{className:"text-green-400",children:n("backup.tokenSaved")})]}),i.jsx("input",{type:"password",value:s,onChange:ae=>{o(ae.target.value),Y(null)},placeholder:be?.has_token?n("backup.enterNewToken"):"ghp_xxxxxxxxxxxx",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("backup.tokenHint")})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("backup.branch")}),i.jsx("input",{type:"text",value:l,onChange:ae=>c(ae.target.value),placeholder:"main",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("backup.autoBackup")}),i.jsxs("select",{value:u?m:"disabled",onChange:ae=>{ae.target.value==="disabled"?d(!1):(d(!0),p(ae.target.value))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"disabled",children:n("backup.manualOnly")}),i.jsx("option",{value:"hourly",children:n("backup.hourly")}),i.jsx("option",{value:"daily",children:n("backup.daily")}),i.jsx("option",{value:"weekly",children:n("backup.weekly")})]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:n("backup.includeInBackup")}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("label",{className:`flex items-start gap-2 ${O?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[i.jsx("input",{type:"checkbox",checked:f,onChange:ae=>y(ae.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green",disabled:O}),i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`text-sm ${O?"text-bambu-gray":"text-white"}`,children:n("backup.kProfiles")}),O&&i.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:[i.jsx(Mn,{className:"w-3 h-3"}),n("backup.noPrintersConnected")]}),V&&i.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:[i.jsx(Mn,{className:"w-3 h-3"}),n("backup.printersConnected",{connected:ne,total:$})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("backup.kProfilesDescription")})]})]}),i.jsxs("label",{className:`flex items-start gap-2 ${j?.is_authenticated?"cursor-pointer":"cursor-not-allowed opacity-60"}`,children:[i.jsx("input",{type:"checkbox",checked:v,onChange:ae=>b(ae.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green",disabled:!j?.is_authenticated}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`text-sm ${j?.is_authenticated?"text-white":"text-bambu-gray"}`,children:n("backup.cloudProfiles")}),!j?.is_authenticated&&i.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:[i.jsx(Mn,{className:"w-3 h-3"}),n("backup.cloudLoginRequiredShort")]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("backup.cloudProfilesDescription")})]})]}),i.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:g,onChange:ae=>_(ae.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),i.jsxs("div",{children:[i.jsx("span",{className:"text-white text-sm",children:n("backup.appSettings")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("backup.appSettingsDescription")})]})]})]})]}),i.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 space-y-3",children:[q?.configured&&i.jsxs("div",{className:"flex items-center justify-between text-sm",children:[i.jsx("div",{className:"flex items-center gap-2 text-bambu-gray",children:q.last_backup_at?i.jsxs(i.Fragment,{children:[i.jsxs("span",{children:[n("backup.lastBackupAt")," ",w0(q.last_backup_at,"system",n)]}),i.jsx(CY,{status:q.last_backup_status})]}):i.jsx("span",{children:n("backup.noBackupsYet")})}),q.next_scheduled_run&&i.jsxs("span",{className:"text-bambu-gray",children:[i.jsx(Jn,{className:"w-3 h-3 inline mr-1"}),n("backup.next")," ",w0(q.next_scheduled_run,"system",n)]})]}),pe&&i.jsxs("div",{className:`text-sm flex items-center gap-1 ${pe.success?"text-green-400":"text-red-400"}`,children:[pe.success?i.jsx(fr,{className:"w-4 h-4"}):i.jsx(qi,{className:"w-4 h-4"}),pe.message]}),i.jsx("div",{className:"flex flex-wrap items-center gap-2",children:q?.configured?i.jsx(i.Fragment,{children:re.isPending||q.is_running?i.jsxs("div",{className:"flex items-center gap-2 text-bambu-green",children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),i.jsx("span",{className:"text-sm",children:q.progress||n("backup.startingBackup")})]}):i.jsxs(i.Fragment,{children:[i.jsxs(Ie,{variant:"primary",size:"sm",onClick:()=>re.mutate(),disabled:!be?.enabled,children:[i.jsx(wo,{className:"w-4 h-4"}),n("backup.backupNow")]}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:ge,disabled:ue,children:[ue?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Sr,{className:"w-4 h-4"}),n("backup.test")]})]})}):i.jsxs(i.Fragment,{children:[i.jsxs(Ie,{variant:"primary",size:"sm",onClick:xe,disabled:G.isPending||!r||!s,children:[G.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(fr,{className:"w-4 h-4"}),n("backup.enableBackup")]}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:ge,disabled:ue||!r||!s,children:[ue?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Sr,{className:"w-4 h-4"}),n("backup.testConnection")]})]})})]})]})]}),Z&&Z.length>0&&i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(x0,{className:"w-5 h-5 text-gray-400"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:n("backup.history")})]}),i.jsxs(Ie,{variant:"ghost",size:"sm",onClick:()=>ce.mutate(),disabled:ce.isPending,children:[i.jsx(en,{className:"w-4 h-4"}),n("backup.clear")]})]})}),i.jsx(Et,{children:i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"text-bambu-gray border-b border-bambu-dark-tertiary",children:[i.jsx("th",{className:"text-left py-2 px-2",children:n("backup.date")}),i.jsx("th",{className:"text-left py-2 px-2",children:n("backup.status")}),i.jsx("th",{className:"text-left py-2 px-2",children:n("backup.commit")})]})}),i.jsx("tbody",{children:Z.slice(0,10).map(ae=>i.jsxs("tr",{className:"border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-secondary",children:[i.jsx("td",{className:"py-2 px-2 text-white",children:Pet(ae.started_at)}),i.jsx("td",{className:"py-2 px-2",children:i.jsx(CY,{status:ae.status})}),i.jsx("td",{className:"py-2 px-2",children:ae.commit_sha?i.jsxs("a",{href:`${be?.repository_url}/commit/${ae.commit_sha}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline inline-flex items-center gap-1",children:[ae.commit_sha.substring(0,7),i.jsx(ti,{className:"w-3 h-3"})]}):i.jsx("span",{className:"text-bambu-gray",children:"-"})})]},ae.id))})]})})})]})]}),i.jsx("div",{className:"space-y-6",children:i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(mu,{className:"w-5 h-5 text-gray-400"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:n("backup.localBackup")})]})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.localBackupDescription")}),i.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:n("backup.downloadBackupLabel")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.completeBackupZip")})]}),i.jsxs(Ie,{variant:"secondary",size:"sm",disabled:C||k,onClick:async()=>{P(!0),D(n("backup.preparingBackup"));try{D(n("backup.creatingArchive"));const{blob:ae,filename:L}=await fe.exportBackup();D(n("backup.downloadingFile"));const F=URL.createObjectURL(ae),te=document.createElement("a");te.href=F,te.download=L,te.click(),URL.revokeObjectURL(F),e(n("backup.backupDownloaded"))}catch(ae){e(n("backup.failedToCreateBackup",{message:ae instanceof Error?ae.message:"Unknown error"}),"error")}finally{P(!1),D("")}},children:[i.jsx(bi,{className:"w-4 h-4"}),n("backup.download")]})]}),i.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:n("backup.restoreBackup")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.restoreDescription")}),i.jsx("p",{className:"text-xs text-bambu-gray-light mt-1",children:n("backup.restoreNote")})]}),i.jsx("input",{ref:Q,type:"file",accept:".zip",className:"hidden",onChange:ae=>{const L=ae.target.files?.[0];L&&(I(L),z(!0)),ae.target.value=""}}),i.jsxs(Ie,{variant:"secondary",size:"sm",disabled:k||C,onClick:()=>Q.current?.click(),children:[i.jsx(vi,{className:"w-4 h-4"}),n("backup.restore")]})]}),J&&i.jsx("div",{className:`p-3 rounded-lg ${J.success?"bg-green-500/10 border border-green-500/30":"bg-red-500/10 border border-red-500/30"}`,children:i.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[J.success?i.jsx(fr,{className:"w-4 h-4 text-green-400 mt-0.5 flex-shrink-0"}):i.jsx(qi,{className:"w-4 h-4 text-red-400 mt-0.5 flex-shrink-0"}),i.jsxs("div",{className:J.success?"text-green-200":"text-red-200",children:[J.message,J.success&&i.jsx("div",{className:"mt-2",children:i.jsxs(Ie,{size:"sm",onClick:()=>window.location.reload(),children:[i.jsx(So,{className:"w-3 h-3"}),n("backup.reloadNow")]})})]})]})}),i.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:i.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[i.jsx(Mn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),i.jsxs("div",{className:"text-yellow-200",children:[i.jsx("span",{className:"font-medium",children:n("backup.restoreReplacesAll")})," ",i.jsx("span",{className:"text-yellow-200/70",children:n("backup.restoreReplacesAllDetail")})]})]})})]})]})}),B&&W&&i.jsx(_n,{title:n("backup.restoreConfirmTitle"),message:n("backup.restoreConfirmMessage",{filename:W.name}),confirmText:n("backup.restoreConfirmButton"),variant:"danger",onConfirm:async()=>{z(!1),R(!0),ie(null);try{D(n("backup.uploadingFile"));const ae=await fe.importBackup(W);ie(ae),ae.success?e(n("backup.backupRestoredRestart"),"success"):e(ae.message,"error")}catch(ae){const L=ae instanceof Error?ae.message:n("backup.failedToRestore");ie({success:!1,message:L}),e(L,"error")}finally{R(!1),D(""),I(null)}},onCancel:()=>{z(!1),I(null)}}),(C||k)&&i.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[100]",children:i.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl p-8 max-w-md w-full mx-4 text-center",children:[i.jsx("div",{className:"flex justify-center mb-4",children:i.jsxs("div",{className:"relative",children:[i.jsx("div",{className:"w-16 h-16 border-4 border-bambu-dark-tertiary rounded-full"}),i.jsx("div",{className:"w-16 h-16 border-4 border-bambu-green border-t-transparent rounded-full absolute inset-0 animate-spin"})]})}),i.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:n(C?"backup.creatingBackup":"backup.restoringBackup")}),i.jsx("p",{className:"text-bambu-gray mb-4",children:A||n(C?"backup.preparing":"backup.processing")}),i.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:i.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[i.jsx(Mn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),i.jsx("p",{className:"text-yellow-200 text-left",children:n("backup.doNotClosePage")})]})})]})})]})}const Eet={starttls:587,ssl:465,none:25},jet={587:"starttls",465:"ssl",25:"none"};function Det(){const{t}=Rt(),{showToast:e}=fn(),n=sn(),[r,a]=w.useState({smtp_host:"",smtp_port:587,smtp_username:"",smtp_password:"",smtp_security:"starttls",smtp_auth_enabled:!0,smtp_from_email:"",smtp_from_name:"BamBuddy"}),[s,o]=w.useState(""),{data:l,isLoading:c}=tt({queryKey:["smtpSettings"],queryFn:()=>fe.getSMTPSettings()}),{authEnabled:u}=Nr(),{data:d}=tt({queryKey:["advancedAuthStatus"],queryFn:()=>fe.getAdvancedAuthStatus()});w.useEffect(()=>{l&&a({...l,smtp_password:""})},[l]);const m=k=>{a({...r,smtp_security:k,smtp_port:Eet[k]})},p=k=>{const R=jet[k];a({...r,smtp_port:k,...R?{smtp_security:R}:{}})},f=k=>{a({...r,smtp_auth_enabled:k,...k?{}:{smtp_username:"",smtp_password:""}})},y=ft({mutationFn:k=>fe.saveSMTPSettings(k),onSuccess:()=>{n.invalidateQueries({queryKey:["smtpSettings"]}),n.invalidateQueries({queryKey:["advancedAuthStatus"]}),e(t("settings.email.success.settingsSaved"),"success")},onError:k=>{e(k.message,"error")}}),v=ft({mutationFn:k=>fe.testSMTP(k),onSuccess:k=>{e(k.message,k.success?"success":"error")},onError:k=>{e(k.message,"error")}}),b=ft({mutationFn:k=>k?fe.enableAdvancedAuth():fe.disableAdvancedAuth(),onSuccess:k=>{n.invalidateQueries({queryKey:["advancedAuthStatus"]}),e(k.message,"success")},onError:k=>{e(k.message,"error")}}),g=()=>{if(!r.smtp_host||!r.smtp_from_email){e(t("settings.email.errors.requiredFields"),"error");return}if(r.smtp_auth_enabled&&!r.smtp_username){e(t("settings.email.errors.usernameRequired"),"error");return}y.mutate(r)},_=()=>{if(!s){e(t("settings.email.errors.enterTestEmail"),"error");return}v.mutate({test_recipient:s})},N=()=>{if(!u){e(t("settings.email.errors.enableAuthFirst"),"error");return}if(!d?.advanced_auth_enabled&&!d?.smtp_configured){e(t("settings.email.errors.configureSmtpFirst"),"error");return}b.mutate(!d?.advanced_auth_enabled)};if(c)return i.jsx("div",{className:"flex items-center justify-center p-12",children:i.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"})});const T=d?.advanced_auth_enabled??!1,C="w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",P="w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white/40 placeholder-bambu-gray/40 cursor-not-allowed";return i.jsxs("div",{className:"space-y-6",children:[i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(sx,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.advancedAuth")||"Advanced Authentication"})]}),i.jsx(Ie,{onClick:N,disabled:b.isPending,variant:T?"danger":"primary",children:T?i.jsxs(i.Fragment,{children:[i.jsx(X1,{className:"w-4 h-4"}),t("settings.email.disable")||"Disable"]}):i.jsxs(i.Fragment,{children:[i.jsx(Ep,{className:"w-4 h-4"}),t("settings.email.enable")||"Enable"]})})]})}),i.jsx(Et,{children:i.jsx("div",{className:"space-y-4",children:T?i.jsx("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx(fr,{className:"w-5 h-5 text-green-400 mt-0.5 flex-shrink-0"}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-white font-medium",children:t("settings.email.advancedAuthEnabled")||"Advanced Authentication is enabled"}),i.jsxs("ul",{className:"text-sm text-green-300 space-y-1 list-disc list-inside",children:[i.jsx("li",{children:t("settings.email.feature1")||"Passwords are auto-generated and emailed to new users"}),i.jsx("li",{children:t("settings.email.feature2")||"Users can login with username or email"}),i.jsx("li",{children:t("settings.email.feature3")||"Forgot password feature is available"}),i.jsx("li",{children:t("settings.email.feature4")||"Admins can reset user passwords via email"})]})]})]})}):i.jsx("div",{className:"bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx(Mn,{className:"w-5 h-5 text-yellow-400 mt-0.5 flex-shrink-0"}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-white font-medium",children:t("settings.email.advancedAuthDisabled")||"Advanced Authentication is disabled"}),i.jsx("p",{className:"text-sm text-yellow-300",children:t("settings.email.advancedAuthDisabledDesc")||"Enable advanced authentication to activate email-based features for user management."})]})]})})})})]}),i.jsx("div",{children:i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.smtpSettings")||"SMTP Configuration"})}),i.jsx(Et,{children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.authentication")||"Authentication"}),i.jsxs("select",{value:r.smtp_auth_enabled?"true":"false",onChange:k=>f(k.target.value==="true"),className:C,children:[i.jsx("option",{value:"true",children:t("settings.email.authOptions.enabled")}),i.jsx("option",{value:"false",children:t("settings.email.authOptions.disabled")})]})]}),i.jsxs("div",{className:`grid grid-cols-1 md:grid-cols-2 gap-4 transition-opacity ${r.smtp_auth_enabled?"":"opacity-40 pointer-events-none"}`,children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.username")||"Username"}),i.jsx("input",{type:"text",value:r.smtp_username||"",onChange:k=>a({...r,smtp_username:k.target.value}),placeholder:"your.email@gmail.com",disabled:!r.smtp_auth_enabled,className:r.smtp_auth_enabled?C:P})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.password")||"Password"}),i.jsx("input",{type:"password",value:r.smtp_password||"",onChange:k=>a({...r,smtp_password:k.target.value}),placeholder:l?"••••••••":"App password",disabled:!r.smtp_auth_enabled,className:r.smtp_auth_enabled?C:P})]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[t("settings.email.smtpHost")||"SMTP Server"," *"]}),i.jsx("input",{type:"text",value:r.smtp_host,onChange:k=>a({...r,smtp_host:k.target.value}),placeholder:"smtp.gmail.com",className:C})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.smtpPort")||"SMTP Port"}),i.jsx("input",{type:"number",value:r.smtp_port,onChange:k=>p(parseInt(k.target.value)||587),placeholder:"587",className:C})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.security")||"Security"}),i.jsxs("select",{value:r.smtp_security,onChange:k=>m(k.target.value),className:C,children:[i.jsx("option",{value:"starttls",children:t("settings.email.securityOptions.starttls")}),i.jsx("option",{value:"ssl",children:t("settings.email.securityOptions.ssl")}),i.jsx("option",{value:"none",children:t("settings.email.securityOptions.none")})]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[t("settings.email.fromEmail")||"From Email"," *"]}),i.jsx("input",{type:"email",value:r.smtp_from_email,onChange:k=>a({...r,smtp_from_email:k.target.value}),placeholder:"your@email.com",className:C})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.fromName")||"From Name"}),i.jsx("input",{type:"text",value:r.smtp_from_name,onChange:k=>a({...r,smtp_from_name:k.target.value}),placeholder:"BamBuddy",className:C})]})]}),i.jsx("div",{className:"flex gap-2",children:i.jsx(Ie,{onClick:g,disabled:y.isPending,className:"flex-1",children:y.isPending?i.jsxs(i.Fragment,{children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),t("settings.email.saving")||"Saving..."]}):t("settings.email.save")||"Save Settings"})})]})})]})}),i.jsx("div",{children:i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.testConnection")||"Test SMTP Connection"})}),i.jsx(Et,{children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.testRecipient")||"Test Recipient Email"}),i.jsx("input",{type:"email",value:s,onChange:k=>o(k.target.value),placeholder:"test@example.com",className:C})]}),i.jsx(Ie,{onClick:_,disabled:v.isPending,variant:"secondary",children:v.isPending?i.jsxs(i.Fragment,{children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),t("settings.email.sending")||"Sending..."]}):i.jsxs(i.Fragment,{children:[i.jsx(iT,{className:"w-4 h-4"}),t("settings.email.sendTest")||"Send Test Email"]})})]})})]})})]})}const Ret={get:"bg-blue-500/20 text-blue-400 border-blue-500/30",post:"bg-green-500/20 text-green-400 border-green-500/30",put:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",patch:"bg-orange-500/20 text-orange-400 border-orange-500/30",delete:"bg-red-500/20 text-red-400 border-red-500/30"};function Fet(t,e){const n=e.replace("#/","").split("/");let r=t;for(const a of n)r=r[a];return r}function Uv(t,e,n=0){if(n>5)return"...";if(e.$ref)return Uv(t,Fet(t,e.$ref),n+1);if(e.allOf){const r={};for(const a of e.allOf){const s=Uv(t,a,n+1);typeof s=="object"&&s!==null&&Object.assign(r,s)}return r}if(e.example!==void 0)return e.example;if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:"string";case"integer":case"number":return 0;case"boolean":return!1;case"array":return e.items?[Uv(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[a,s]of Object.entries(e.properties))r[a]=Uv(t,s,n+1);return r}return{};default:return null}}function Let({path:t,method:e,spec:n,schema:r,apiKey:a}){const[s,o]=w.useState(!1),[l,c]=w.useState({}),[u,d]=w.useState(""),[m,p]=w.useState(null),[f,y]=w.useState(!1),[v,b]=w.useState(!1);w.useEffect(()=>{if(s&&n.parameters){const R={};for(const A of n.parameters)A.schema?.default!==void 0&&(R[A.name]=String(A.schema.default));c(A=>({...R,...A}))}},[s,n.parameters]),w.useEffect(()=>{if(s&&n.requestBody?.content?.["application/json"]?.schema&&!u){const R=n.requestBody.content["application/json"].schema,A=Uv(r,R);d(JSON.stringify(A,null,2))}},[s,n.requestBody,r,u]);const _=(()=>{const R=[];for(const A of n.parameters||[])if(A.in==="path"||A.required){const D=l[A.name];(D===void 0||D==="")&&R.push(A.name)}return R})(),N=async()=>{if(_.length>0){p({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${_.join(", ")}`,duration:0});return}y(!0),p(null);try{let R=t;const A=new URLSearchParams;for(const pe of n.parameters||[]){const Y=l[pe.name];Y!==void 0&&Y!==""&&(pe.in==="path"?R=R.replace(`{${pe.name}}`,encodeURIComponent(Y)):pe.in==="query"&&A.append(pe.name,Y))}const D=A.toString(),B=`${R}${D?`?${D}`:""}`,z={"Content-Type":"application/json"};a&&(z["X-API-Key"]=a);const W={method:e.toUpperCase(),headers:z};["post","put","patch"].includes(e)&&u&&(W.body=u);const I=performance.now(),J=await fetch(B,W),ie=Math.round(performance.now()-I),Q={};J.headers.forEach((pe,Y)=>{Q[Y]=pe});let ue;J.headers.get("content-type")?.includes("application/json")?ue=await J.json():ue=await J.text(),p({status:J.status,statusText:J.statusText,headers:Q,body:ue,duration:ie})}catch(R){p({status:0,statusText:"Network Error",headers:{},body:R instanceof Error?R.message:"Unknown error",duration:0})}finally{y(!1)}},T=async()=>{if(m){const R=typeof m.body=="string"?m.body:JSON.stringify(m.body,null,2);try{await navigator.clipboard.writeText(R),b(!0),setTimeout(()=>b(!1),2e3)}catch{const A=document.createElement("textarea");A.value=R,A.style.position="fixed",A.style.left="-999999px",document.body.appendChild(A),A.select(),document.execCommand("copy"),document.body.removeChild(A),b(!0),setTimeout(()=>b(!1),2e3)}}},C=(n.parameters||[]).filter(R=>R.in==="path"),P=(n.parameters||[]).filter(R=>R.in==="query"),k=["post","put","patch"].includes(e)&&n.requestBody;return i.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[i.jsxs("button",{onClick:()=>o(!s),className:"w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left",children:[s?i.jsx(On,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):i.jsx(fa,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),i.jsx("span",{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${Ret[e]||"bg-gray-500/20 text-gray-400"}`,children:e}),i.jsx("code",{className:"text-sm text-white font-mono flex-1 truncate",children:t}),n.summary&&i.jsx("span",{className:"text-sm text-bambu-gray truncate max-w-[40%]",children:n.summary})]}),s&&i.jsxs("div",{className:"border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50",children:[n.description&&i.jsx("p",{className:"text-sm text-bambu-gray",children:n.description}),C.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("h4",{className:"text-sm font-medium text-white",children:"Path Parameters"}),i.jsx("div",{className:"space-y-2",children:C.map(R=>i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[R.name,R.required&&i.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),i.jsx("input",{type:"text",value:l[R.name]||"",onChange:A=>c(D=>({...D,[R.name]:A.target.value})),placeholder:R.description||R.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},R.name))})]}),P.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("h4",{className:"text-sm font-medium text-white",children:"Query Parameters"}),i.jsx("div",{className:"space-y-2",children:P.map(R=>i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[R.name,R.required&&i.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),R.schema?.enum?i.jsxs("select",{value:l[R.name]||"",onChange:A=>c(D=>({...D,[R.name]:A.target.value})),className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"",children:"-- Select --"}),R.schema.enum.map(A=>i.jsx("option",{value:A,children:A},A))]}):i.jsx("input",{type:"text",value:l[R.name]||"",onChange:A=>c(D=>({...D,[R.name]:A.target.value})),placeholder:R.description||R.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},R.name))})]}),k&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("h4",{className:"text-sm font-medium text-white",children:"Request Body"}),i.jsx("textarea",{value:u,onChange:R=>d(R.target.value),rows:8,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono focus:border-bambu-green focus:outline-none resize-y",placeholder:"JSON request body..."})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs(Ie,{onClick:N,disabled:f,children:[f?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(wo,{className:"w-4 h-4"}),"Execute"]}),_.length>0&&i.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[i.jsx(Li,{className:"w-3 h-3"}),"Fill in: ",_.join(", ")]})]}),m&&i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("h4",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Response",i.jsxs("span",{className:`px-2 py-0.5 text-xs rounded ${m.status>=200&&m.status<300?"bg-green-500/20 text-green-400":m.status>=400?"bg-red-500/20 text-red-400":"bg-yellow-500/20 text-yellow-400"}`,children:[m.status," ",m.statusText]}),i.jsxs("span",{className:"text-xs text-bambu-gray",children:[m.duration,"ms"]})]}),i.jsx(Ie,{variant:"secondary",size:"sm",onClick:T,children:v?i.jsx(fr,{className:"w-3 h-3 text-green-400"}):i.jsx(vo,{className:"w-3 h-3"})})]}),i.jsx("pre",{className:"p-3 bg-bambu-dark rounded-lg text-sm font-mono text-white overflow-auto max-h-96 border border-bambu-dark-tertiary",children:typeof m.body=="string"?m.body:JSON.stringify(m.body,null,2)})]})]})]})}function Oet({apiKey:t=""}){const[e,n]=w.useState(null),[r,a]=w.useState(!0),[s,o]=w.useState(null),[l,c]=w.useState(new Set),[u,d]=w.useState("");if(w.useEffect(()=>{async function b(){try{const g=await fetch("/openapi.json");if(!g.ok)throw new Error("Failed to fetch OpenAPI schema");const _=await g.json();n(_)}catch(g){o(g instanceof Error?g.message:"Unknown error")}finally{a(!1)}}b()},[]),r)return i.jsx("div",{className:"flex justify-center py-12",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(s||!e)return i.jsx(Pt,{children:i.jsx(Et,{className:"py-8",children:i.jsxs("div",{className:"text-center text-red-400",children:[i.jsx(Li,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),i.jsx("p",{children:"Failed to load API schema"}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:s})]})})});const m={};for(const[b,g]of Object.entries(e.paths))for(const[_,N]of Object.entries(g)){if(_==="parameters")continue;const T=N.tags||["Other"];for(const C of T)m[C]||(m[C]=[]),m[C].push({path:b,method:_,spec:N})}const p=Object.entries(m).map(([b,g])=>{if(!u)return{tag:b,endpoints:g};const _=g.filter(({path:N,method:T,spec:C})=>{const P=u.toLowerCase();return N.toLowerCase().includes(P)||T.toLowerCase().includes(P)||(C.summary?.toLowerCase()||"").includes(P)||(C.description?.toLowerCase()||"").includes(P)});return{tag:b,endpoints:_}}).filter(({endpoints:b})=>b.length>0).sort((b,g)=>b.tag.localeCompare(g.tag)),f=b=>{c(g=>{const _=new Set(g);return _.has(b)?_.delete(b):_.add(b),_})},y=()=>{c(new Set(p.map(b=>b.tag)))},v=()=>{c(new Set)};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsx("div",{className:"flex-1",children:i.jsx("input",{type:"text",value:u,onChange:b=>d(b.target.value),placeholder:"Search endpoints...",className:"w-full max-w-md px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Ie,{variant:"secondary",size:"sm",onClick:y,children:"Expand All"}),i.jsx(Ie,{variant:"secondary",size:"sm",onClick:v,children:"Collapse All"}),i.jsxs("a",{href:"/docs",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-bambu-green hover:underline",children:[i.jsx(ti,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),i.jsxs("p",{className:"text-sm text-bambu-gray",children:[p.reduce((b,g)=>b+g.endpoints.length,0)," endpoints in ",p.length," categories"]}),i.jsx("div",{className:"space-y-3",children:p.map(({tag:b,endpoints:g})=>i.jsxs(Pt,{children:[i.jsx("button",{onClick:()=>f(b),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/30 transition-colors text-left",children:i.jsxs("div",{className:"flex items-center gap-2",children:[l.has(b)?i.jsx(On,{className:"w-5 h-5 text-bambu-gray"}):i.jsx(fa,{className:"w-5 h-5 text-bambu-gray"}),i.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:b.replace(/-/g," ")}),i.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:g.length})]})}),l.has(b)&&i.jsx(Et,{className:"pt-0 space-y-2",children:g.map(({path:_,method:N,spec:T})=>i.jsx(Let,{path:_,method:N,spec:T,schema:e,apiKey:t},`${N}-${_}`))})]},b))})]})}const Iet=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users","backup"],zet={database:"bg-blue-600",library_files:"bg-green-500",library_thumbnails:"bg-teal-500",library_other:"bg-emerald-700",archive_timelapses:"bg-red-500",archive_thumbnails:"bg-amber-500",archive_files:"bg-sky-500",virtual_printer_uploads:"bg-purple-500",virtual_printer_upload_cache:"bg-fuchsia-500",virtual_printer_certs:"bg-violet-500",virtual_printer_other:"bg-purple-700",downloads:"bg-cyan-500",plate_calibration:"bg-lime-500",logs:"bg-orange-500",other_data:"bg-yellow-500"},TY=["bg-blue-500","bg-green-500","bg-yellow-500","bg-red-500","bg-orange-500","bg-teal-500","bg-cyan-500","bg-purple-500"],AY=(t,e)=>zet[t]||TY[e%TY.length];function Uet(){const t=sn(),e=al(),[n,r]=jL(),{t:a,i18n:s}=Rt(),{showToast:o}=fn(),{authEnabled:l,user:c,refreshAuth:u}=Nr(),{mode:d,darkStyle:m,darkBackground:p,darkAccent:f,lightStyle:y,lightBackground:v,lightAccent:b,setDarkStyle:g,setDarkBackground:_,setDarkAccent:N,setLightStyle:T,setLightBackground:C,setLightAccent:P}=Xf(),[k,R]=w.useState(null),[A,D]=w.useState(!1),[B,z]=w.useState(null),[W,I]=w.useState(!1),[J,ie]=w.useState(null),[Q,ue]=w.useState(null),[me,pe]=w.useState(!1),[Y,se]=w.useState(cQ()),oe=n.get("tab"),be=oe==="email",Me=be?"users":oe&&Iet.includes(oe)?oe:"general",[q,Z]=w.useState(Me),[j,E]=w.useState(be?"email":"users"),U=Se=>{Z(Se),Se==="users"&&E("users"),Se==="general"?n.delete("tab"):n.set("tab",Se),r(n,{replace:!0})},[K,$]=w.useState(!1),[ne,O]=w.useState(""),[V,ee]=w.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[G,re]=w.useState(null),[ce,ge]=w.useState(null),[xe,ae]=w.useState(""),[L,F]=w.useState(!1),[te,ve]=w.useState(!1),[he,de]=w.useState(null),[ke,_e]=w.useState(!1),[Le,$e]=w.useState(!1),[Re,Ae]=w.useState(!1),[Pe,Ue]=w.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[je,Xe]=w.useState(!1),[ye,Ge]=w.useState(!1),[Ee,Ke]=w.useState(!1),[Ve,Ne]=w.useState(!1),[Ce,He]=w.useState(null),[et,it]=w.useState(null),[xt,vt]=w.useState(null),[qe,_t]=w.useState(!1),[Nt,mt]=w.useState({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),[jt,qt]=w.useState(null),[Jt,Wt]=w.useState(null),[un,Je]=w.useState(!1),[xn,Cn]=w.useState({}),[Oe,nt]=w.useState({}),dt=Se=>{se(Se),uxe(Se),o(a("settings.toast.settingsSaved"),"success")},Qe=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:Te,isLoading:st}=tt({queryKey:["settings"],queryFn:fe.getSettings}),{data:le,isLoading:Be,isFetching:We}=tt({queryKey:["storage-usage"],queryFn:()=>fe.getStorageUsage(),enabled:q==="general",staleTime:1/0,refetchInterval:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),Ye=async()=>{Ge(!0);try{const Se=await fe.getStorageUsage({refresh:!0});t.setQueryData(["storage-usage"],Se)}catch(Se){const It=Se instanceof Error?Se.message:"Failed to refresh storage usage";o(It,"error")}finally{Ge(!1)}},{data:De,isLoading:ht}=tt({queryKey:["smart-plugs"],queryFn:fe.getSmartPlugs}),{data:ut,isLoading:rt}=tt({queryKey:["smart-plugs-energy",De?.map(Se=>Se.id)],queryFn:async()=>{if(!De||De.length===0)return null;const Se=await Promise.all(De.filter(Ot=>Ot.enabled).map(async Ot=>{try{const Kt=await fe.getSmartPlugStatus(Ot.id);return{plug:Ot,status:Kt}}catch{return{plug:Ot,status:null}}}));let It=0,gr=0,zn=0,Ta=0,gt=0;for(const{plug:Ot,status:Kt}of Se){const lt=Ot.plug_type==="mqtt"&&Kt?.energy?.power!=null;(Kt?.reachable||lt)&&Kt?.energy&&(gt++,Kt.energy?.power!=null&&(It+=Kt.energy.power),Kt.energy?.today!=null&&(gr+=Kt.energy.today),Kt.energy?.yesterday!=null&&(zn+=Kt.energy.yesterday),Kt.energy?.total!=null&&(Ta+=Kt.energy.total))}return{totalPower:It,totalToday:gr,totalYesterday:zn,totalLifetime:Ta,reachableCount:gt,totalPlugs:De.filter(Ot=>Ot.enabled).length}},enabled:q==="plugs"&&!!De&&De.length>0,refetchInterval:q==="plugs"?1e4:!1}),{data:wt,isLoading:Ut}=tt({queryKey:["notification-providers"],queryFn:fe.getNotificationProviders}),{data:Lt,isLoading:zt}=tt({queryKey:["api-keys"],queryFn:fe.getAPIKeys}),Gt=ft({mutationFn:Se=>fe.createAPIKey(Se),onSuccess:Se=>{re(Se.key||null),$(!1),O(""),t.invalidateQueries({queryKey:["api-keys"]}),o(a("settings.toast.apiKeyCreated"))},onError:Se=>{o(`Failed to create API key: ${Se.message}`,"error")}}),nn=ft({mutationFn:Se=>fe.deleteAPIKey(Se),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o(a("settings.toast.apiKeyDeleted"))},onError:Se=>{o(`Failed to delete API key: ${Se.message}`,"error")}}),{data:on}=tt({queryKey:["printers"],queryFn:fe.getPrinters}),{data:wn,isLoading:In}=tt({queryKey:["notification-templates"],queryFn:fe.getNotificationTemplates}),{data:ln}=tt({queryKey:["virtual-printer-settings"],queryFn:Bbe.getSettings,refetchInterval:1e4}),Tn=ln?.status?.running??!1,{data:Nn}=tt({queryKey:["ffmpeg-status"],queryFn:fe.checkFfmpeg}),{data:Jr}=tt({queryKey:["version"],queryFn:fe.getVersion}),{data:yn,refetch:mr,isRefetching:us}=tt({queryKey:["updateCheck"],queryFn:fe.checkForUpdates,enabled:Te?.check_updates!==!1,staleTime:300*1e3}),{data:$n,refetch:ui}=tt({queryKey:["updateStatus"],queryFn:fe.getUpdateStatus,refetchInterval:Se=>{const It=Se.state.data;return It?.status==="downloading"||It?.status==="installing"?1e3:!1}}),{data:hr}=tt({queryKey:["mqtt-status"],queryFn:fe.getMQTTStatus,refetchInterval:q==="network"?5e3:!1}),{data:Fr}=tt({queryKey:["github-backup-status"],queryFn:fe.getGitHubBackupStatus}),{data:di}=tt({queryKey:["cloud-status"],queryFn:fe.getCloudStatus}),{data:Ar={advanced_auth_enabled:!1,smtp_configured:!1}}=tt({queryKey:["advancedAuthStatus"],queryFn:()=>fe.getAdvancedAuthStatus()}),{hasPermission:zi}=Nr(),{data:rm=[],isLoading:ep}=tt({queryKey:["users"],queryFn:()=>fe.getUsers(),enabled:l&&zi("users:read")}),{data:To=[],isLoading:rg}=tt({queryKey:["groups"],queryFn:()=>fe.getGroups(),enabled:l&&zi("groups:read")}),Eu=ft({mutationFn:Se=>fe.createUser(Se),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),Ke(!1),mt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),o(a("settings.toast.userCreated"))},onError:Se=>{o(Se.message,"error")}}),Ao=ft({mutationFn:({id:Se,data:It})=>fe.updateUser(Se,It),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),Ne(!1),He(null),mt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),o(a("settings.toast.userUpdated"))},onError:Se=>{o(Se.message,"error")}}),Ui=ft({mutationFn:({id:Se,deleteItems:It})=>fe.deleteUser(Se,It),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),o(a("settings.toast.userDeleted")),it(null),vt(null)},onError:Se=>{o(Se.message,"error")}}),ec=ft({mutationFn:Se=>fe.resetUserPassword({user_id:Se}),onSuccess:Se=>{o(Se.message,"success")},onError:Se=>{o(Se.message,"error")}}),sl=async Se=>{it(Se),_t(!0);try{const It=await fe.getUserItemsCount(Se);vt(It)}catch{vt({archives:0,queue_items:0,library_files:0})}finally{_t(!1)}},Js=ft({mutationFn:Se=>fe.deleteGroup(Se),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),o(a("settings.toast.groupDeleted"))},onError:Se=>{o(Se.message,"error")}}),Po=()=>{const Se=Ar?.advanced_auth_enabled||!1;if(!Nt.username){o(a("settings.toast.fillRequiredFields"),"error");return}if(Se&&!Nt.email){o("Email is required when advanced authentication is enabled","error");return}if(!Se){if(!Nt.password){o(a("settings.toast.fillRequiredFields"),"error");return}if(Nt.password!==Nt.confirmPassword){o(a("settings.toast.passwordsDoNotMatch"),"error");return}if(Nt.password.length<6){o(a("settings.toast.passwordTooShort"),"error");return}}Eu.mutate({username:Nt.username,password:Se?void 0:Nt.password,email:Nt.email||void 0,role:Nt.role,group_ids:Nt.group_ids.length>0?Nt.group_ids:void 0})},eo=Se=>{if(Nt.password){if(Nt.password!==Nt.confirmPassword){o(a("settings.toast.passwordsDoNotMatch"),"error");return}if(Nt.password.length<6){o(a("settings.toast.passwordTooShort"),"error");return}}const It={username:Nt.username||void 0,password:Nt.password||void 0,email:Nt.email||void 0,role:Nt.role,group_ids:Nt.group_ids};It.password||delete It.password,Ao.mutate({id:Se,data:It})},ju=Se=>{He(Se.id),mt({username:Se.username,password:"",email:Se.email||"",confirmPassword:"",role:Se.role,group_ids:Se.groups?.map(It=>It.id)||[]}),Ne(!0)},im=Se=>{mt(It=>({...It,group_ids:It.group_ids.includes(Se)?It.group_ids.filter(gr=>gr!==Se):[...It.group_ids,Se]}))},Ba=ft({mutationFn:fe.applyUpdate,onSuccess:Se=>{Se.is_docker?o(Se.message,"error"):ui()}}),[ka,Mo]=w.useState(null),to=ft({mutationFn:fe.testAllNotificationProviders,onSuccess:Se=>{Mo(Se),t.invalidateQueries({queryKey:["notification-providers"]}),Se.failed===0?o(`All ${Se.tested} providers tested successfully!`,"success"):o(`${Se.success}/${Se.tested} providers succeeded`,Se.failed>0?"error":"success")},onError:Se=>{o(`Failed to test providers: ${Se.message}`,"error")}}),la=ft({mutationFn:async Se=>{if(!De)return{success:0,failed:0};const It=De.filter(zn=>zn.enabled),gr=await Promise.all(It.map(async zn=>{try{return await fe.controlSmartPlug(zn.id,Se),{success:!0}}catch{return{success:!1}}}));return{success:gr.filter(zn=>zn.success).length,failed:gr.filter(zn=>!zn.success).length}},onSuccess:(Se,It)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),Se.failed===0?o(`All ${Se.success} plugs turned ${It}`,"success"):o(`${Se.success} plugs turned ${It}, ${Se.failed} failed`,"error")},onError:Se=>{o(`Failed: ${Se.message}`,"error")}}),tc=w.useRef(null),nc=w.useRef(!1),ol=w.useRef(!0);w.useEffect(()=>{if(Te&&!k){const Se={...Te,external_url:Te.external_url||window.location.origin};R(Se),setTimeout(()=>{ol.current=!1},100)}},[Te,k]);const Oc=ft({mutationFn:fe.updateSettings,onSuccess:Se=>{t.setQueryData(["settings"],Se),t.invalidateQueries({queryKey:["archiveStats"]}),o(a("settings.toast.settingsSaved"),"success")},onError:Se=>{o(`Failed to save: ${Se.message}`,"error")},onSettled:()=>{nc.current=!1}}),Ic=ft({mutationFn:({id:Se,data:It})=>fe.updatePrinter(Se,It),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o(a("settings.toast.cameraSettingsSaved"),"success")},onError:Se=>{o(`Failed to update printer: ${Se.message}`,"error")}});w.useEffect(()=>{if(!(ol.current||!k||!Te||!(Te.auto_archive!==k.auto_archive||Te.save_thumbnails!==k.save_thumbnails||Te.capture_finish_photo!==k.capture_finish_photo||Te.default_filament_cost!==k.default_filament_cost||Te.currency!==k.currency||Te.energy_cost_per_kwh!==k.energy_cost_per_kwh||Te.energy_tracking_mode!==k.energy_tracking_mode||Te.check_updates!==k.check_updates||(Te.check_printer_firmware??!0)!==(k.check_printer_firmware??!0)||(Te.include_beta_updates??!1)!==(k.include_beta_updates??!1)||Te.notification_language!==k.notification_language||(Te.bed_cooled_threshold??35)!==(k.bed_cooled_threshold??35)||Te.ams_humidity_good!==k.ams_humidity_good||Te.ams_humidity_fair!==k.ams_humidity_fair||Te.ams_temp_good!==k.ams_temp_good||Te.ams_temp_fair!==k.ams_temp_fair||Te.ams_history_retention_days!==k.ams_history_retention_days||Te.disable_filament_warnings!==k.disable_filament_warnings||(Te.queue_drying_enabled??!1)!==(k.queue_drying_enabled??!1)||(Te.queue_drying_block??!1)!==(k.queue_drying_block??!1)||(Te.ambient_drying_enabled??!1)!==(k.ambient_drying_enabled??!1)||(Te.drying_presets??"")!==(k.drying_presets??"")||Te.per_printer_mapping_expanded!==k.per_printer_mapping_expanded||Te.date_format!==k.date_format||Te.time_format!==k.time_format||Te.default_printer_id!==k.default_printer_id||Te.ftp_retry_enabled!==k.ftp_retry_enabled||Te.ftp_retry_count!==k.ftp_retry_count||Te.ftp_retry_delay!==k.ftp_retry_delay||Te.ftp_timeout!==k.ftp_timeout||Te.mqtt_enabled!==k.mqtt_enabled||Te.mqtt_broker!==k.mqtt_broker||Te.mqtt_port!==k.mqtt_port||Te.mqtt_username!==k.mqtt_username||Te.mqtt_password!==k.mqtt_password||Te.mqtt_topic_prefix!==k.mqtt_topic_prefix||Te.mqtt_use_tls!==k.mqtt_use_tls||Te.external_url!==k.external_url||Te.ha_enabled!==k.ha_enabled||Te.ha_url!==k.ha_url||Te.ha_token!==k.ha_token||(Te.library_archive_mode??"ask")!==(k.library_archive_mode??"ask")||Number(Te.library_disk_warning_gb??5)!==Number(k.library_disk_warning_gb??5)||(Te.camera_view_mode??"window")!==(k.camera_view_mode??"window")||(Te.preferred_slicer??"bambu_studio")!==(k.preferred_slicer??"bambu_studio")||Te.prometheus_enabled!==k.prometheus_enabled||Te.prometheus_token!==k.prometheus_token||(Te.user_notifications_enabled??!0)!==(k.user_notifications_enabled??!0)))&&!nc.current)return tc.current&&clearTimeout(tc.current),tc.current=setTimeout(()=>{if(nc.current)return;nc.current=!0;const It={auto_archive:k.auto_archive,save_thumbnails:k.save_thumbnails,capture_finish_photo:k.capture_finish_photo,default_filament_cost:k.default_filament_cost,currency:k.currency,energy_cost_per_kwh:k.energy_cost_per_kwh,energy_tracking_mode:k.energy_tracking_mode,check_updates:k.check_updates,check_printer_firmware:k.check_printer_firmware,include_beta_updates:k.include_beta_updates,notification_language:k.notification_language,bed_cooled_threshold:k.bed_cooled_threshold,ams_humidity_good:k.ams_humidity_good,ams_humidity_fair:k.ams_humidity_fair,ams_temp_good:k.ams_temp_good,ams_temp_fair:k.ams_temp_fair,ams_history_retention_days:k.ams_history_retention_days,disable_filament_warnings:k.disable_filament_warnings,queue_drying_enabled:k.queue_drying_enabled,queue_drying_block:k.queue_drying_block,ambient_drying_enabled:k.ambient_drying_enabled,drying_presets:k.drying_presets,per_printer_mapping_expanded:k.per_printer_mapping_expanded,date_format:k.date_format,time_format:k.time_format,default_printer_id:k.default_printer_id,ftp_retry_enabled:k.ftp_retry_enabled,ftp_retry_count:k.ftp_retry_count,ftp_retry_delay:k.ftp_retry_delay,ftp_timeout:k.ftp_timeout,mqtt_enabled:k.mqtt_enabled,mqtt_broker:k.mqtt_broker,mqtt_port:k.mqtt_port,mqtt_username:k.mqtt_username,mqtt_password:k.mqtt_password,mqtt_topic_prefix:k.mqtt_topic_prefix,mqtt_use_tls:k.mqtt_use_tls,external_url:k.external_url,ha_enabled:k.ha_enabled,ha_url:k.ha_url,ha_token:k.ha_token,library_archive_mode:k.library_archive_mode,library_disk_warning_gb:k.library_disk_warning_gb,camera_view_mode:k.camera_view_mode,preferred_slicer:k.preferred_slicer,prometheus_enabled:k.prometheus_enabled,prometheus_token:k.prometheus_token,user_notifications_enabled:k.user_notifications_enabled};Oc.mutate(It)},500),()=>{tc.current&&clearTimeout(tc.current)}},[k,Te,Oc]);const hn=w.useCallback((Se,It)=>{R(gr=>gr?{...gr,[Se]:It}:null)},[]),Ca=async(Se,It,gr)=>{if(!It){o(a("settings.toast.enterCameraUrl"),"error");return}nt(zn=>({...zn,[Se]:!0})),Cn(zn=>({...zn,[Se]:null}));try{const zn=await fe.testExternalCamera(Se,It,gr);Cn(Ta=>({...Ta,[Se]:zn})),zn.success?o(a("settings.toast.cameraConnected",{resolution:zn.resolution||""}),"success"):o(zn.error||a("settings.toast.connectionFailed"),"error")}catch(zn){const Ta=zn instanceof Error?zn.message:a("settings.toast.testFailed");Cn(gt=>({...gt,[Se]:{success:!1,error:Ta}})),o(Ta,"error")}finally{nt(zn=>({...zn,[Se]:!1}))}},[ca,Ha]=w.useState({}),Ps=w.useRef({}),ig=w.useRef(new Set);w.useEffect(()=>{if(on){const Se={};on.forEach(It=>{It.external_camera_url&&!ig.current.has(It.id)&&(Se[It.id]=It.external_camera_url,ig.current.add(It.id))}),Object.keys(Se).length>0&&Ha(It=>({...It,...Se}))}},[on]);const tp=(Se,It)=>{Ha(gr=>({...gr,[Se]:It})),Ps.current[Se]&&clearTimeout(Ps.current[Se]),Ps.current[Se]=setTimeout(()=>{Ic.mutate({id:Se,data:{external_camera_url:It||null}})},800)},Du=(Se,It)=>{const gr={};It.type!==void 0&&(gr.external_camera_type=It.type||null),It.enabled!==void 0&&(gr.external_camera_enabled=It.enabled),It.rotation!==void 0&&(gr.camera_rotation=It.rotation),Ic.mutate({id:Se,data:gr})};return st||!k?i.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i.jsxs("div",{className:"p-4 md:p-8",children:[i.jsxs("div",{className:"mb-8",children:[i.jsx("h1",{className:"text-2xl font-bold text-white",children:a("settings.title")}),i.jsx("p",{className:"text-bambu-gray",children:a("settings.configureBambuddy")})]}),i.jsxs("div",{className:"flex flex-wrap gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[i.jsx("button",{onClick:()=>U("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${q==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:a("settings.tabs.general")}),i.jsxs("button",{onClick:()=>U("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${q==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[i.jsx(Il,{className:"w-4 h-4"}),a("settings.tabs.smartPlugs"),De&&De.length>0&&i.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:De.length})]}),i.jsxs("button",{onClick:()=>U("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${q==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[i.jsx(xh,{className:"w-4 h-4"}),a("settings.tabs.notifications"),wt&&wt.length>0&&i.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:wt.length})]}),i.jsxs("button",{onClick:()=>U("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${q==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[i.jsx(Npe,{className:"w-4 h-4"}),a("settings.tabs.filament")]}),i.jsxs("button",{onClick:()=>U("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${q==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[i.jsx(Hb,{className:"w-4 h-4"}),a("settings.tabs.network"),i.jsx("span",{className:`w-2 h-2 rounded-full ${hr?.enabled?"bg-green-400":"bg-gray-500"}`})]}),i.jsxs("button",{onClick:()=>U("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${q==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[i.jsx(Al,{className:"w-4 h-4"}),a("settings.tabs.apiKeys"),Lt&&Lt.length>0&&i.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Lt.length})]}),i.jsxs("button",{onClick:()=>U("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${q==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[i.jsx(_r,{className:"w-4 h-4"}),a("settings.tabs.virtualPrinter"),i.jsx("span",{className:`w-2 h-2 rounded-full ${Tn?"bg-green-400":"bg-gray-500"}`})]}),i.jsxs("button",{onClick:()=>U("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${q==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[i.jsx(Jm,{className:"w-4 h-4"}),a("settings.tabs.users"),l&&i.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"})]}),i.jsxs("button",{onClick:()=>U("backup"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${q==="backup"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[i.jsx(mu,{className:"w-4 h-4"}),a("settings.tabs.backup"),i.jsx("span",{className:`w-2 h-2 rounded-full ${di?.is_authenticated&&Fr?.configured&&Fr?.enabled?"bg-green-400":"bg-gray-500"}`})]})]}),q==="general"&&i.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[i.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:a("settings.general")})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i.jsx(wh,{className:"w-4 h-4 inline mr-1"}),a("settings.language")]}),i.jsxs("div",{className:"relative",children:[i.jsx("select",{value:s.language,onChange:Se=>{s.changeLanguage(Se.target.value),fe.updateSettings({language:Se.target.value}),o(a("settings.toast.settingsSaved"),"success")},className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:C8.map(Se=>i.jsxs("option",{value:Se.code,children:[Se.nativeName," (",Se.name,")"]},Se.code))}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a("settings.languageDescription")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.defaultView")}),i.jsxs("div",{className:"relative",children:[i.jsx("select",{value:Y,onChange:Se=>dt(Se.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:S0.map(Se=>i.jsx("option",{value:Se.to,children:a(Se.labelKey)},Se.id))}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a("settings.defaultViewDescription")})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.dateFormat")}),i.jsxs("div",{className:"relative",children:[i.jsxs("select",{value:k.date_format||"system",onChange:Se=>hn("date_format",Se.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[i.jsx("option",{value:"system",children:a("settings.systemDefault")}),i.jsx("option",{value:"us",children:a("settings.dateFormatUs")}),i.jsx("option",{value:"eu",children:a("settings.dateFormatEu")}),i.jsx("option",{value:"iso",children:a("settings.dateFormatIso")})]}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.timeFormat")}),i.jsxs("div",{className:"relative",children:[i.jsxs("select",{value:k.time_format||"system",onChange:Se=>hn("time_format",Se.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[i.jsx("option",{value:"system",children:a("settings.systemDefault")}),i.jsx("option",{value:"12h",children:a("settings.timeFormat12")}),i.jsx("option",{value:"24h",children:a("settings.timeFormat24")})]}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.defaultPrinter")}),i.jsxs("div",{className:"relative",children:[i.jsxs("select",{value:k.default_printer_id??"",onChange:Se=>hn("default_printer_id",Se.target.value?Number(Se.target.value):null),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[i.jsx("option",{value:"",children:a("settings.noDefaultPrinter")}),on?.map(Se=>i.jsx("option",{value:Se.id,children:Se.name},Se.id))]}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a("settings.defaultPrinterDescription")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.preferredSlicer")}),i.jsxs("div",{className:"relative",children:[i.jsxs("select",{value:k.preferred_slicer??"bambu_studio",onChange:Se=>hn("preferred_slicer",Se.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[i.jsx("option",{value:"bambu_studio",children:a("settings.slicerBambuStudio")}),i.jsx("option",{value:"orcaslicer",children:a("settings.slicerOrcaSlicer")})]}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a("settings.preferredSlicerDescription")})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:a("settings.sidebarOrder")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.sidebarOrderDescription")})]}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:Qe,children:[i.jsx(So,{className:"w-4 h-4"}),a("settings.reset")]})]})]})]}),i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(yw,{className:"w-5 h-5"}),a("settings.appearance")]})}),i.jsxs(Et,{className:"space-y-6",children:[i.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${d==="dark"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[i.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a("settings.darkMode"),d==="dark"&&i.jsx("span",{className:"text-xs text-bambu-green",children:a("settings.active")})]}),i.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:a("settings.background")}),i.jsxs("select",{value:p,onChange:Se=>{_(Se.target.value),o(a("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"neutral",children:a("settings.bgNeutral")}),i.jsx("option",{value:"warm",children:a("settings.bgWarm")}),i.jsx("option",{value:"cool",children:a("settings.bgCool")}),i.jsx("option",{value:"oled",children:a("settings.bgOled")}),i.jsx("option",{value:"slate",children:a("settings.bgSlate")}),i.jsx("option",{value:"forest",children:a("settings.bgForest")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:a("settings.accent")}),i.jsxs("select",{value:f,onChange:Se=>{N(Se.target.value),o(a("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"green",children:a("settings.accentGreen")}),i.jsx("option",{value:"teal",children:a("settings.accentTeal")}),i.jsx("option",{value:"blue",children:a("settings.accentBlue")}),i.jsx("option",{value:"orange",children:a("settings.accentOrange")}),i.jsx("option",{value:"purple",children:a("settings.accentPurple")}),i.jsx("option",{value:"red",children:a("settings.accentRed")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:a("settings.style")}),i.jsxs("select",{value:m,onChange:Se=>{g(Se.target.value),o(a("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"classic",children:a("settings.styleClassic")}),i.jsx("option",{value:"glow",children:a("settings.styleGlow")}),i.jsx("option",{value:"vibrant",children:a("settings.styleVibrant")})]})]})]})]}),i.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${d==="light"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[i.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a("settings.lightMode"),d==="light"&&i.jsx("span",{className:"text-xs text-bambu-green",children:a("settings.active")})]}),i.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:a("settings.background")}),i.jsxs("select",{value:v,onChange:Se=>{C(Se.target.value),o(a("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"neutral",children:a("settings.bgNeutral")}),i.jsx("option",{value:"warm",children:a("settings.bgWarm")}),i.jsx("option",{value:"cool",children:a("settings.bgCool")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:a("settings.accent")}),i.jsxs("select",{value:b,onChange:Se=>{P(Se.target.value),o(a("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"green",children:a("settings.accentGreen")}),i.jsx("option",{value:"teal",children:a("settings.accentTeal")}),i.jsx("option",{value:"blue",children:a("settings.accentBlue")}),i.jsx("option",{value:"orange",children:a("settings.accentOrange")}),i.jsx("option",{value:"purple",children:a("settings.accentPurple")}),i.jsx("option",{value:"red",children:a("settings.accentRed")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:a("settings.style")}),i.jsxs("select",{value:y,onChange:Se=>{T(Se.target.value),o(a("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"classic",children:a("settings.styleClassic")}),i.jsx("option",{value:"glow",children:a("settings.styleGlow")}),i.jsx("option",{value:"vibrant",children:a("settings.styleVibrant")})]})]})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:a("settings.themeToggleHint")})]})]}),i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:a("settings.archiveSettings")})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:a("settings.autoArchivePrints")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.autoArchiveDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:k.auto_archive,onChange:Se=>hn("auto_archive",Se.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:a("settings.saveThumbnails")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.saveThumbnailsDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:k.save_thumbnails,onChange:Se=>hn("save_thumbnails",Se.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:a("settings.captureFinishPhoto")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.captureFinishPhotoDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:k.capture_finish_photo,onChange:Se=>hn("capture_finish_photo",Se.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),k.capture_finish_photo&&Nn&&!Nn.installed&&i.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[i.jsx(Mn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"text-sm",children:[i.jsx("p",{className:"text-yellow-500 font-medium",children:a("settings.ffmpegNotInstalled")}),i.jsx("p",{className:"text-bambu-gray mt-1",children:a("settings.ffmpegRequired")})]})]})]})]})]}),i.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(WL,{className:"w-5 h-5 text-bambu-green"}),a("settings.camera")]})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.cameraViewMode")}),i.jsxs("select",{value:k.camera_view_mode??"window",onChange:Se=>hn("camera_view_mode",Se.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"window",children:a("settings.newWindow")}),i.jsx("option",{value:"embedded",children:a("settings.embeddedOverlay")})]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:k.camera_view_mode==="embedded"?a("settings.cameraOverlayDescription"):a("settings.cameraWindowDescription")})]}),i.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4",children:[i.jsx("h3",{className:"text-sm font-medium text-white mb-2",children:a("settings.externalCameras")}),i.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:a("settings.externalCamerasDescription")}),on&&on.length>0?i.jsx("div",{className:"space-y-3",children:on.map(Se=>i.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("span",{className:"text-white font-medium text-sm",children:Se.name}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:Se.external_camera_enabled,onChange:It=>Du(Se.id,{enabled:It.target.checked}),className:"sr-only peer"}),i.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),Se.external_camera_enabled&&i.jsxs("div",{className:"space-y-2 mt-2",children:[i.jsx("input",{type:"text",placeholder:Se.external_camera_type==="usb"?a("settings.cameraPlaceholderUsb"):a("settings.cameraPlaceholderUrl"),value:ca[Se.id]??Se.external_camera_url??"",onChange:It=>tp(Se.id,It.target.value),className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("select",{value:Se.external_camera_type||"mjpeg",onChange:It=>Du(Se.id,{type:It.target.value}),className:"flex-1 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"mjpeg",children:a("settings.cameraTypeMjpeg")}),i.jsx("option",{value:"rtsp",children:a("settings.cameraTypeRtsp")}),i.jsx("option",{value:"snapshot",children:a("settings.cameraTypeSnapshot")}),i.jsx("option",{value:"usb",children:a("settings.cameraTypeUsb")})]}),i.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>Ca(Se.id,ca[Se.id]??Se.external_camera_url??"",Se.external_camera_type||"mjpeg"),disabled:Oe[Se.id]||!(ca[Se.id]??Se.external_camera_url),children:Oe[Se.id]?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):a("settings.test")})]}),xn[Se.id]&&i.jsx("div",{className:`text-xs flex items-center gap-1 ${xn[Se.id]?.success?"text-green-500":"text-red-500"}`,children:xn[Se.id]?.success?i.jsxs(i.Fragment,{children:[i.jsx(fr,{className:"w-3 h-3"}),a("settings.connected"),xn[Se.id]?.resolution&&` (${xn[Se.id]?.resolution})`]}):i.jsxs(i.Fragment,{children:[i.jsx(qi,{className:"w-3 h-3"}),xn[Se.id]?.error||a("settings.toast.connectionFailed")]})}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("label",{className:"text-xs text-bambu-gray",children:a("settings.cameraRotation")}),i.jsxs("select",{value:Se.camera_rotation||0,onChange:It=>Du(Se.id,{rotation:parseInt(It.target.value)}),className:"px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:0,children:"0°"}),i.jsx("option",{value:90,children:"90°"}),i.jsx("option",{value:180,children:"180°"}),i.jsx("option",{value:270,children:"270°"})]})]})]})]},Se.id))}):i.jsx("p",{className:"text-xs text-bambu-gray italic",children:a("settings.noPrintersConfigured")})]})]})]}),i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:a("settings.costTracking")})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.currency")}),i.jsx("select",{value:k.currency,onChange:Se=>hn("currency",Se.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:zqe.map(Se=>i.jsx("option",{value:Se.code,children:Se.label},Se.code))})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.defaultFilamentCost")}),i.jsxs("div",{className:"relative",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none",children:Go(k.currency)}),i.jsx("input",{type:"number",step:"0.01",min:"0",value:k.default_filament_cost,onChange:Se=>hn("default_filament_cost",parseFloat(Se.target.value)||0),style:{paddingLeft:`${Math.max(2,Go(k.currency).length*.6+1)}rem`},className:"w-full pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.electricityCost")}),i.jsxs("div",{className:"relative",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none",children:Go(k.currency)}),i.jsx("input",{type:"number",step:"0.001",min:"0",value:k.energy_cost_per_kwh,onChange:Se=>hn("energy_cost_per_kwh",parseFloat(Se.target.value)||0),style:{paddingLeft:`${Math.max(2,Go(k.currency).length*.6+1)}rem`},className:"w-full pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.energyDisplayMode")}),i.jsxs("select",{value:k.energy_tracking_mode||"total",onChange:Se=>hn("energy_tracking_mode",Se.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"print",children:a("settings.printsOnly")}),i.jsx("option",{value:"total",children:a("settings.totalConsumption")})]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:k.energy_tracking_mode==="print"?a("settings.energyModePrintDescription"):a("settings.energyModeTotalDescription")})]})]})]}),i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(zs,{className:"w-5 h-5 text-bambu-green"}),a("settings.fileManager")]})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.createArchiveEntry")}),i.jsxs("select",{value:k.library_archive_mode??"ask",onChange:Se=>hn("library_archive_mode",Se.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"always",children:a("settings.archiveMode.always")}),i.jsx("option",{value:"never",children:a("settings.archiveMode.never")}),i.jsx("option",{value:"ask",children:a("settings.archiveMode.ask")})]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a("settings.createArchiveEntryDescription")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.lowDiskSpaceWarning")}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"number",min:"0.5",max:"100",step:"0.5",value:k.library_disk_warning_gb??5,onChange:Se=>hn("library_disk_warning_gb",parseFloat(Se.target.value)||5),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),i.jsx("span",{className:"text-bambu-gray",children:"GB"})]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a("settings.lowDiskSpaceDescription")})]})]})]})]}),i.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[i.jsx(ket,{}),i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:a("settings.updates")})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wider",children:a("settings.printerFirmware")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:a("settings.checkPrinterFirmware")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.checkFirmwareDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:k.check_printer_firmware??!0,onChange:Se=>hn("check_printer_firmware",Se.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:i.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wider mb-4",children:a("settings.bambuddySoftware")})}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:a("settings.checkForUpdatesLabel")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.autoCheckDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:k.check_updates,onChange:Se=>hn("check_updates",Se.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.jsxs("div",{className:`flex items-center justify-between ${k.check_updates?"":"opacity-50"}`,children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:a("settings.includeBetaUpdates")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.includeBetaUpdatesDesc")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:k.include_beta_updates??!1,onChange:Se=>hn("include_beta_updates",Se.target.checked),disabled:!k.check_updates,className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:a("settings.currentVersion")}),i.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",Jr?.version||"..."]})]}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>mr(),disabled:us,children:[us?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Sr,{className:"w-4 h-4"}),a("settings.checkNow")]})]}),yn?.update_available?i.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{children:[i.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",yn.latest_version]}),yn.release_name&&yn.release_name!==yn.latest_version&&i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:yn.release_name})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[yn.release_notes&&i.jsx("button",{onClick:()=>_e(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:a("settings.releaseNotes")}),yn.release_url&&i.jsx("a",{href:yn.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:a("settings.viewReleaseOnGitHub"),children:i.jsx(ti,{className:"w-4 h-4"})})]})]}),$n?.status==="downloading"||$n?.status==="installing"?i.jsxs("div",{className:"mt-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),i.jsx("span",{children:$n.message})]}),i.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:i.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${$n.progress}%`}})})]}):$n?.status==="complete"?i.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:$n.message}):$n?.status==="error"?i.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:$n.error||$n.message}):yn?.is_docker?i.jsxs("div",{className:"mt-3 p-3 bg-bambu-dark-tertiary rounded-lg",children:[i.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:a("settings.updateViaDocker")}),i.jsx("code",{className:"block text-xs bg-bambu-dark p-2 rounded text-bambu-green font-mono",children:"docker compose pull && docker compose up -d"})]}):i.jsxs(Ie,{className:"mt-3",onClick:()=>Ba.mutate(),disabled:Ba.isPending,children:[Ba.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(bi,{className:"w-4 h-4"}),a("settings.installUpdate")]})]}):yn?.error?i.jsx("div",{className:"mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400",children:a("settings.failedToCheckUpdates",{error:yn.error})}):yn&&!yn.update_available?i.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:a("settings.latestVersionRunning")}):null]})]})]}),i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:a("settings.dataManagement")})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:a("settings.clearNotificationLogs")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.clearNotificationLogsDescription")})]}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>F(!0),children:[i.jsx(en,{className:"w-4 h-4"}),a("common.clear")]})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:a("settings.resetUiPreferences")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.resetUiPreferencesDescription")})]}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>ve(!0),children:[i.jsx(en,{className:"w-4 h-4"}),a("settings.reset")]})]}),i.jsxs("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:a("settings.storageUsage","Storage Usage")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.storageUsageDescription","Breakdown of data usage by category")})]}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:Ye,disabled:We||ye,children:[i.jsx(Sr,{className:`w-4 h-4 ${We||ye?"animate-spin":""}`}),a("common.refresh","Refresh")]})]}),i.jsx("div",{className:"mt-3",children:Be?i.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),a("common.loading","Loading")]}):le?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"w-full h-3 bg-bambu-dark rounded-full overflow-hidden flex",children:le.categories.filter(Se=>Se.bytes>0).map((Se,It)=>i.jsx("div",{className:`${AY(Se.key,It)} h-full`,style:{width:`${Se.percent_of_total}%`},title:`${Se.label}: ${Se.formatted}`},Se.key))}),i.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:le.categories.filter(Se=>Se.bytes>0).map((Se,It)=>i.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[i.jsx("span",{className:`w-3 h-3 rounded-full ${AY(Se.key,It)}`}),i.jsx("span",{className:"text-bambu-gray",children:Se.label}),i.jsx("span",{className:"text-white",children:Se.formatted}),i.jsxs("span",{className:"text-bambu-gray",children:["(",Se.percent_of_total.toFixed(1),"%)"]})]},Se.key))}),i.jsxs("div",{className:"mt-2 text-xs text-bambu-gray",children:[a("settings.storageUsageTotal","Total"),": ",i.jsx("span",{className:"text-white",children:le.total_formatted}),le.scan_errors>0&&i.jsxs("span",{className:"ml-2 text-amber-400",children:[a("settings.storageUsageErrors","Scan errors"),": ",le.scan_errors]})]}),le.other_breakdown?.length>0&&i.jsxs("div",{className:"mt-4",children:[i.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:a("settings.storageUsageOtherBreakdown","Other breakdown")}),i.jsx("div",{className:"space-y-2",children:le.other_breakdown.map(Se=>i.jsxs("div",{className:"flex items-center justify-between text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-white",children:Se.label}),i.jsx("span",{className:`px-2 py-0.5 rounded-full border ${Se.kind==="system"?"border-slate-500 text-slate-300":"border-bambu-green text-bambu-green"}`,children:Se.kind==="system"?a("settings.storageUsageSystem","System"):a("settings.storageUsageData","Data")})]}),i.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[i.jsx("span",{className:"text-white",children:Se.formatted}),i.jsxs("span",{children:["(",Se.percent_of_total.toFixed(1),"%)"]})]})]},`${Se.bucket}-${Se.kind}`))})]})]}):i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.storageUsageUnavailable","Storage usage data is unavailable")})})]}),i.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-bambu-dark-tertiary",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:a("settings.backupRestore")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.backupRestoreDescription")})]}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>U("backup"),children:[i.jsx(mu,{className:"w-4 h-4"}),a("settings.goToBackup")]})]})]})]})]})]}),q==="network"&&k&&i.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[i.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(wh,{className:"w-5 h-5 text-blue-400"}),a("settings.externalUrl")]})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.externalUrlDescription")}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.bambuddyUrl")}),i.jsx("input",{type:"text",value:k.external_url??"",onChange:Se=>hn("external_url",Se.target.value),placeholder:"http://192.168.1.100:8000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a("settings.externalUrlHint")})]})]})]}),i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(Sr,{className:"w-5 h-5 text-blue-400"}),a("settings.ftpRetry")]})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.ftpRetryDescription")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:a("settings.enableRetry")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.autoRetryDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:k.ftp_retry_enabled??!0,onChange:Se=>hn("ftp_retry_enabled",Se.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),k.ftp_retry_enabled&&i.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.retryAttempts")}),i.jsxs("div",{className:"relative w-44",children:[i.jsx("select",{value:k.ftp_retry_count??3,onChange:Se=>hn("ftp_retry_count",parseInt(Se.target.value)),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[1,2,3,4,5,6,7,8,9,10].map(Se=>i.jsx("option",{value:Se,children:a("settings.time",{count:Se})},Se))}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.retryDelay")}),i.jsxs("div",{className:"relative w-44",children:[i.jsx("select",{value:k.ftp_retry_delay??2,onChange:Se=>hn("ftp_retry_delay",parseInt(Se.target.value)),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[1,2,3,5,10,15,20,30].map(Se=>i.jsx("option",{value:Se,children:a("settings.second",{count:Se})},Se))}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.connectionTimeout")}),i.jsxs("div",{className:"relative w-44",children:[i.jsx("select",{value:k.ftp_timeout??30,onChange:Se=>hn("ftp_timeout",parseInt(Se.target.value)),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[10,15,20,30,45,60,90,120,180,300].map(Se=>i.jsx("option",{value:Se,children:a("settings.nSeconds",{count:Se})},Se))}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a("settings.increaseForWeakWifi")})]})]})]})]})]}),i.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(bw,{className:"w-5 h-5 text-bambu-green"}),a("settings.homeAssistant")]}),k.ha_enabled&&Jt&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Jt.success?"bg-green-400":"bg-red-400"}`}),i.jsx("span",{className:`text-sm ${Jt.success?"text-green-400":"text-red-400"}`,children:Jt.success?a("settings.connected"):a("settings.disconnected")})]})]})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.homeAssistantFullDescription")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("p",{className:"text-white",children:a("settings.enableHomeAssistant")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:a("settings.homeAssistantDescription")}),k.ha_env_managed&&i.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[i.jsx(Ep,{className:"w-3 h-3 text-bambu-green"}),i.jsx("span",{className:"text-xs text-bambu-green",children:a("settings.autoEnabledViaEnv")})]})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:k.ha_enabled??!1,onChange:Se=>hn("ha_enabled",Se.target.checked),disabled:k.ha_env_managed,className:"sr-only peer"}),i.jsx("div",{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green ${k.ha_env_managed?"opacity-60 cursor-not-allowed":""}`})]})]}),k.ha_enabled&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a("settings.homeAssistantUrl"),k.ha_url_from_env&&i.jsx("span",{className:"ml-2 text-xs text-bambu-green",children:a("settings.environmentManagedLabel")})]}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:"text",value:k.ha_url??"",onChange:Se=>hn("ha_url",Se.target.value),placeholder:"http://192.168.1.100:8123",disabled:k.ha_url_from_env,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${k.ha_url_from_env?"opacity-60 cursor-not-allowed":""}`}),k.ha_url_from_env&&i.jsx(Ep,{className:"absolute right-3 top-2.5 w-4 h-4 text-bambu-gray"})]}),k.ha_url_from_env&&i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a("settings.urlFromEnvReadOnly")})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a("settings.longLivedAccessToken"),k.ha_token_from_env&&i.jsx("span",{className:"ml-2 text-xs text-bambu-green",children:a("settings.environmentManagedLabel")})]}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:"password",value:k.ha_token??"",onChange:Se=>hn("ha_token",Se.target.value),placeholder:"eyJ0eXAiOiJKV1QiLC...",disabled:k.ha_token_from_env,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${k.ha_token_from_env?"opacity-60 cursor-not-allowed":""}`}),k.ha_token_from_env&&i.jsx(Ep,{className:"absolute right-3 top-2.5 w-4 h-4 text-bambu-gray"})]}),k.ha_token_from_env?i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a("settings.tokenFromEnvReadOnly")}):i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a("settings.haTokenHint")})]}),k.ha_url&&k.ha_token&&i.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:i.jsxs(Ie,{variant:"secondary",size:"sm",disabled:un,onClick:async()=>{Je(!0),Wt(null);try{const Se=await fe.testHAConnection(k.ha_url,k.ha_token);Wt(Se)}catch(Se){Wt({success:!1,message:null,error:Se instanceof Error?Se.message:a("common.unknownError")})}finally{Je(!1)}},children:[un?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Hb,{className:"w-4 h-4"}),a("settings.testConnection")]})})]})]})]}),i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(Hb,{className:"w-5 h-5 text-blue-400"}),a("settings.mqttPublishing")]}),hr?.enabled&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${hr.connected?"bg-green-400":"bg-red-400"}`}),i.jsx("span",{className:`text-sm ${hr.connected?"text-green-400":"text-red-400"}`,children:hr.connected?a("settings.connected"):a("settings.disconnected")})]})]})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.mqttDescription")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:a("settings.enableMqtt")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.mqttEnableDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:k.mqtt_enabled??!1,onChange:Se=>hn("mqtt_enabled",Se.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),k.mqtt_enabled&&i.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.brokerHostname")}),i.jsx("input",{type:"text",value:k.mqtt_broker??"",onChange:Se=>hn("mqtt_broker",Se.target.value),placeholder:"mqtt.example.com or 192.168.1.100",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"flex items-end gap-4",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.port")}),i.jsx("input",{type:"number",min:"1",max:"65535",value:k.mqtt_port??1883,onChange:Se=>hn("mqtt_port",Math.min(65535,Math.max(1,parseInt(Se.target.value)||1883))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"flex items-center gap-3 pb-2",children:[i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:k.mqtt_use_tls??!1,onChange:Se=>{const It=Se.target.checked;hn("mqtt_use_tls",It);const gr=k.mqtt_port??1883;It&&gr===1883?hn("mqtt_port",8883):!It&&gr===8883&&hn("mqtt_port",1883)},className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]}),i.jsx("span",{className:"text-white text-sm",children:a("settings.useTls")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.usernameOptional")}),i.jsx("input",{type:"text",value:k.mqtt_username??"",onChange:Se=>hn("mqtt_username",Se.target.value),placeholder:a("settings.leaveEmptyForAnonymous"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.passwordOptional")}),i.jsx("input",{type:"password",value:k.mqtt_password??"",onChange:Se=>hn("mqtt_password",Se.target.value),placeholder:a("settings.leaveEmptyForAnonymous"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.topicPrefix")}),i.jsx("input",{type:"text",value:k.mqtt_topic_prefix??"bambuddy",onChange:Se=>hn("mqtt_topic_prefix",Se.target.value),placeholder:"bambuddy",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a("settings.topicPrefixHint",{prefix:k.mqtt_topic_prefix||"bambuddy"})})]}),hr&&i.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary",children:i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx("span",{className:`w-2 h-2 rounded-full ${hr.connected?"bg-green-400":"bg-red-400"}`}),i.jsx("span",{className:"text-bambu-gray",children:hr.connected?i.jsxs(i.Fragment,{children:[a("settings.mqttConnectedTo")," ",i.jsxs("span",{className:"text-white",children:[hr.broker,":",hr.port]})]}):a("settings.spoolmanDisconnected")})]})})]})]})]})]}),i.jsx("div",{className:"flex-1 lg:max-w-md space-y-4",children:i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(_3,{className:"w-5 h-5 text-orange-400"}),a("settings.prometheusMetrics")]})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.prometheusEndpointDescription")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:a("settings.enableMetricsEndpoint")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:a("settings.prometheusDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:k.prometheus_enabled??!1,onChange:Se=>hn("prometheus_enabled",Se.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),k.prometheus_enabled&&i.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.bearerTokenOptional")}),i.jsx("input",{type:"password",value:k.prometheus_token??"",onChange:Se=>hn("prometheus_token",Se.target.value),placeholder:a("settings.leaveEmptyForNoAuth"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a("settings.bearerTokenHint")})]}),i.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[i.jsx("p",{className:"text-sm text-white mb-2",children:a("settings.availableMetrics")}),i.jsxs("div",{className:"text-xs text-bambu-gray space-y-1",children:[i.jsxs("p",{children:[i.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_connected"})," - ",a("settings.metricsConnectionStatus")]}),i.jsxs("p",{children:[i.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_state"})," - ",a("settings.metricsPrinterState")]}),i.jsxs("p",{children:[i.jsx("code",{className:"text-orange-400",children:"bambuddy_print_progress"})," - ",a("settings.metricsPrintProgress")]}),i.jsxs("p",{children:[i.jsx("code",{className:"text-orange-400",children:"bambuddy_bed_temp_celsius"})," - ",a("settings.metricsBedTemp")]}),i.jsxs("p",{children:[i.jsx("code",{className:"text-orange-400",children:"bambuddy_nozzle_temp_celsius"})," - ",a("settings.metricsNozzleTemp")]}),i.jsxs("p",{children:[i.jsx("code",{className:"text-orange-400",children:"bambuddy_prints_total"})," - ",a("settings.metricsPrintsTotal")]}),i.jsx("p",{className:"text-bambu-gray/70 italic",children:a("settings.metricsMore")})]})]})]})]})]})})]}),Jt&&i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full mx-4",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[Jt.success?i.jsx(fr,{className:"w-8 h-8 text-green-400"}):i.jsx(qi,{className:"w-8 h-8 text-red-400"}),i.jsx("h3",{className:"text-lg font-medium text-white",children:Jt.success?a("settings.connectionSuccessful"):a("settings.connectionFailed")})]}),i.jsx("p",{className:"text-bambu-gray mb-6",children:Jt.success?Jt.message||a("settings.haConnectionSuccess"):Jt.error||a("settings.haConnectionFailed")}),i.jsx("div",{className:"flex justify-end",children:i.jsx(Ie,{variant:"primary",onClick:()=>Wt(null),children:a("settings.ok")})})]})}),q==="plugs"&&i.jsxs("div",{className:"max-w-4xl",children:[i.jsxs("div",{className:"flex items-start justify-between mb-6",children:[i.jsxs("div",{children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(Il,{className:"w-5 h-5 text-bambu-green"}),a("settings.smartPlugs")]}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a("settings.smartPlugsDescription")})]}),i.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[De&&De.filter(Se=>Se.enabled).length>1&&i.jsxs(i.Fragment,{children:[i.jsxs(Ie,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>de("on"),disabled:la.isPending,title:a("settings.turnAllPlugsOn"),children:[la.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(Xd,{className:"w-4 h-4 text-bambu-green"}),a("settings.allOn")]}),i.jsxs(Ie,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>de("off"),disabled:la.isPending,title:a("settings.turnAllPlugsOff"),children:[la.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(rT,{className:"w-4 h-4 text-red-400"}),a("settings.allOff")]})]}),i.jsxs(Ie,{className:"whitespace-nowrap",onClick:()=>{z(null),D(!0)},children:[i.jsx(ar,{className:"w-4 h-4"}),a("settings.addSmartPlug")]})]})]}),De&&De.length>0&&i.jsxs(Pt,{className:"mb-6",children:[i.jsx(Hn,{children:i.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[i.jsx(Mc,{className:"w-4 h-4 text-yellow-400"}),a("settings.energySummary"),rt&&i.jsx(pt,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),i.jsx(Et,{children:ut?i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[i.jsx(Mc,{className:"w-3 h-3"}),a("settings.currentPower")]}),i.jsxs("div",{className:"text-xl font-bold text-white",children:[ut.totalPower.toFixed(1),i.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),i.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:a("settings.plugsOnline",{reachable:ut.reachableCount,total:ut.totalPlugs})})]}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[i.jsx(Yr,{className:"w-3 h-3"}),a("settings.today")]}),i.jsxs("div",{className:"text-xl font-bold text-white",children:[ut.totalToday.toFixed(3),i.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),(k?.energy_cost_per_kwh??0)>0&&i.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ut.totalToday*(k?.energy_cost_per_kwh??0)).toFixed(2)," ",Go(k?.currency||"USD")]})]}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[i.jsx(_3,{className:"w-3 h-3"}),a("settings.yesterday")]}),i.jsxs("div",{className:"text-xl font-bold text-white",children:[ut.totalYesterday.toFixed(3),i.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),(k?.energy_cost_per_kwh??0)>0&&i.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ut.totalYesterday*(k?.energy_cost_per_kwh??0)).toFixed(2)," ",Go(k?.currency||"USD")]})]}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[i.jsx(EN,{className:"w-3 h-3"}),a("settings.total")]}),i.jsxs("div",{className:"text-xl font-bold text-white",children:[ut.totalLifetime.toFixed(1),i.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),(k?.energy_cost_per_kwh??0)>0&&i.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ut.totalLifetime*(k?.energy_cost_per_kwh??0)).toFixed(2)," ",Go(k?.currency||"USD")]})]})]}):rt?null:i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.enablePlugsForSummary")})})]}),ht?i.jsx("div",{className:"flex justify-center py-12",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):De&&De.length>0?i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:De.map(Se=>i.jsx(uet,{plug:Se,onEdit:It=>{z(It),D(!0)}},Se.id))}):i.jsx(Pt,{children:i.jsx(Et,{className:"py-12",children:i.jsxs("div",{className:"text-center text-bambu-gray",children:[i.jsx(Il,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),i.jsx("p",{className:"text-lg font-medium text-white mb-2",children:a("settings.noSmartPlugsTitle")}),i.jsx("p",{className:"text-sm mb-4",children:a("settings.noSmartPlugsDescription")}),i.jsxs(Ie,{onClick:()=>{z(null),D(!0)},children:[i.jsx(ar,{className:"w-4 h-4"}),a("settings.addFirstSmartPlug")]})]})})})]}),q==="notifications"&&i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(xh,{className:"w-5 h-5 text-bambu-green"}),a("settings.providers")]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>pe(!0),children:[i.jsx(x0,{className:"w-4 h-4"}),a("settings.log")]}),wt&&wt.length>0&&i.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>{Mo(null),to.mutate()},disabled:to.isPending,children:[to.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(iT,{className:"w-4 h-4"}),a("settings.testAll")]}),i.jsxs(Ie,{size:"sm",onClick:()=>{ie(null),I(!0)},children:[i.jsx(ar,{className:"w-4 h-4"}),a("settings.addNotificationProvider")]})]})]}),i.jsx(Pt,{className:"mb-4",children:i.jsx(Et,{className:"py-3",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white text-sm font-medium",children:a("settings.notificationLanguage")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:a("settings.notificationLanguageDescription")})]}),i.jsx("select",{value:k.notification_language||"en",onChange:Se=>hn("notification_language",Se.target.value),className:"px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:C8.map(Se=>i.jsx("option",{value:Se.code,children:Se.nativeName},Se.code))})]})})}),i.jsx(Pt,{className:"mb-4",children:i.jsx(Et,{className:"py-3",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white text-sm font-medium",children:a("settings.bedCooledThreshold")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:a("settings.bedCooledThresholdDescription")})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("input",{type:"number",min:20,max:80,step:1,value:k.bed_cooled_threshold??35,onChange:Se=>hn("bed_cooled_threshold",Number(Se.target.value)),className:"w-16 px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm text-center focus:outline-none focus:ring-1 focus:ring-bambu-green"}),i.jsx("span",{className:"text-sm text-bambu-gray",children:"°C"})]})]})})}),i.jsx(Pt,{className:"mb-4",children:i.jsx(Et,{className:"py-3",children:i.jsxs("div",{className:`flex items-center justify-between ${Ar?.advanced_auth_enabled?"":"opacity-50"}`,children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white text-sm font-medium",children:a("settings.userNotificationsEnabled")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:Ar?.advanced_auth_enabled?a("settings.userNotificationsEnabledDescription"):a("settings.userNotificationsDisabledHint")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",className:"sr-only peer",checked:k.user_notifications_enabled??!0,disabled:!Ar?.advanced_auth_enabled,onChange:Se=>hn("user_notifications_enabled",Se.target.checked)}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green peer-disabled:cursor-not-allowed"})]})]})})}),ka&&i.jsx(Pt,{className:"mb-4",children:i.jsxs(Et,{className:"py-3",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("span",{className:"text-sm font-medium text-white",children:a("settings.testResults")}),i.jsx("button",{onClick:()=>Mo(null),className:"text-bambu-gray hover:text-white text-xs",children:a("common.dismiss")})]}),i.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[i.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[i.jsx(fr,{className:"w-4 h-4"}),a("settings.testPassedCount",{count:ka.success})]}),ka.failed>0&&i.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[i.jsx(qi,{className:"w-4 h-4"}),a("settings.testFailedCount",{count:ka.failed})]})]}),ka.results.filter(Se=>!Se.success).length>0&&i.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:ka.results.filter(Se=>!Se.success).map(Se=>i.jsxs("div",{className:"text-xs text-red-400",children:[i.jsxs("span",{className:"font-medium",children:[Se.provider_name,":"]})," ",Se.message]},Se.provider_id))})]})}),Ut?i.jsx("div",{className:"flex justify-center py-12",children:i.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):wt&&wt.length>0?i.jsx("div",{className:"space-y-3",children:wt.map(Se=>i.jsx(met,{provider:Se,onEdit:It=>{ie(It),I(!0)}},Se.id))}):i.jsx(Pt,{children:i.jsx(Et,{className:"py-8",children:i.jsxs("div",{className:"text-center text-bambu-gray",children:[i.jsx(xh,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),i.jsx("p",{className:"text-sm font-medium text-white mb-2",children:a("settings.noProvidersTitle")}),i.jsx("p",{className:"text-xs mb-3",children:a("settings.noProvidersDescription")}),i.jsxs(Ie,{size:"sm",onClick:()=>{ie(null),I(!0)},children:[i.jsx(ar,{className:"w-4 h-4"}),a("settings.addProvider")]})]})})})]}),i.jsxs("div",{children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[i.jsx(zs,{className:"w-5 h-5 text-bambu-green"}),a("settings.messageTemplates")]}),i.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:a("settings.messageTemplatesDescription")}),In?i.jsx("div",{className:"flex justify-center py-8",children:i.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):wn&&wn.length>0?i.jsx("div",{className:"space-y-2",children:[...wn].sort((Se,It)=>Se.name.localeCompare(It.name)).map(Se=>i.jsx(Pt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>ue(Se),children:i.jsx(Et,{className:"py-2.5 px-3",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"text-white font-medium text-sm truncate",children:Se.name}),i.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:Se.title_template})]}),i.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:It=>{It.stopPropagation(),ue(Se)},children:i.jsx(oh,{className:"w-4 h-4 text-bambu-gray"})})]})})},Se.id))}):i.jsx(Pt,{children:i.jsx(Et,{className:"py-8",children:i.jsxs("div",{className:"text-center text-bambu-gray",children:[i.jsx(zs,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),i.jsx("p",{className:"text-sm",children:a("settings.noTemplatesAvailable")})]})})})]})]}),q==="apikeys"&&i.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[i.jsxs("div",{className:"flex-1",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(Al,{className:"w-5 h-5 text-bambu-green"}),a("settings.apiKeys")]}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a("settings.apiKeysDescription")})]}),i.jsxs(Ie,{size:"sm",onClick:()=>$(!0),className:"flex-shrink-0",children:[i.jsx(ar,{className:"w-4 h-4"}),a("settings.createKey")]})]}),G&&i.jsx(Pt,{className:"mb-6 border-bambu-green",children:i.jsx(Et,{className:"py-4",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx(fr,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"flex-1",children:[i.jsx("p",{className:"text-white font-medium mb-1",children:a("settings.apiKeyCreated")}),i.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:a("settings.apiKeyCopyWarning")}),i.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[i.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:G}),i.jsx(Ie,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(G);else{const Se=document.createElement("textarea");Se.value=G,Se.style.position="fixed",Se.style.left="-999999px",document.body.appendChild(Se),Se.select(),document.execCommand("copy"),document.body.removeChild(Se)}o(a("settings.toast.keyCopied"))}catch{o(a("settings.toast.copyFailed"),"error")}},children:i.jsx(vo,{className:"w-4 h-4"})})]}),i.jsxs("div",{className:"flex gap-2 mt-3",children:[i.jsx(Ie,{variant:"secondary",size:"sm",onClick:()=>{ae(G),o(a("settings.toast.keyAddedToBrowser"))},children:a("settings.useInApiBrowser")}),i.jsx(Ie,{variant:"secondary",size:"sm",onClick:()=>re(null),children:a("common.dismiss")})]})]})]})})}),K&&i.jsxs(Pt,{className:"mb-6",children:[i.jsx(Hn,{children:i.jsx("h3",{className:"text-base font-semibold text-white",children:a("settings.createNewApiKey")})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.keyName")}),i.jsx("input",{type:"text",value:ne,onChange:Se=>O(Se.target.value),placeholder:a("settings.keyNamePlaceholder"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:a("common.permissions")}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:V.can_read_status,onChange:Se=>ee(It=>({...It,can_read_status:Se.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),i.jsxs("div",{children:[i.jsx("span",{className:"text-white",children:a("settings.readStatus")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:a("settings.readStatusDescription")})]})]}),i.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:V.can_queue,onChange:Se=>ee(It=>({...It,can_queue:Se.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),i.jsxs("div",{children:[i.jsx("span",{className:"text-white",children:a("settings.manageQueue")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:a("settings.manageQueueDescription")})]})]}),i.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:V.can_control_printer,onChange:Se=>ee(It=>({...It,can_control_printer:Se.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),i.jsxs("div",{children:[i.jsx("span",{className:"text-white",children:a("settings.controlPrinter")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:a("settings.controlPrinterDescription")})]})]})]})]}),i.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[i.jsxs(Ie,{onClick:()=>Gt.mutate({name:ne||a("settings.unnamedKey"),...V}),disabled:Gt.isPending,children:[Gt.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(ar,{className:"w-4 h-4"}),a("settings.createKey")]}),i.jsx(Ie,{variant:"secondary",onClick:()=>$(!1),children:a("common.cancel")})]})]})]}),zt?i.jsx("div",{className:"flex justify-center py-12",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Lt&&Lt.length>0?i.jsx("div",{className:"space-y-3",children:Lt.map(Se=>i.jsx(Pt,{children:i.jsx(Et,{className:"py-3",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Al,{className:`w-5 h-5 ${Se.enabled?"text-bambu-green":"text-bambu-gray"}`}),i.jsxs("div",{children:[i.jsx("p",{className:"text-white font-medium",children:Se.name}),i.jsxs("p",{className:"text-xs text-bambu-gray",children:[Se.key_prefix,"••••••••",Se.last_used&&` · ${a("settings.lastUsed")}: ${Cf(Se.last_used)}`]})]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"flex gap-1 text-xs",children:[Se.can_read_status&&i.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:a("settings.read")}),Se.can_queue&&i.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:a("queue.title")}),Se.can_control_printer&&i.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:a("settings.control")})]}),i.jsx(Ie,{variant:"secondary",size:"sm",onClick:()=>ge(Se.id),children:i.jsx(en,{className:"w-4 h-4 text-red-400"})})]})]})})},Se.id))}):i.jsx(Pt,{children:i.jsx(Et,{className:"py-12",children:i.jsxs("div",{className:"text-center text-bambu-gray",children:[i.jsx(Al,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),i.jsx("p",{className:"text-lg font-medium text-white mb-2",children:a("settings.apiKeysEmptyTitle")}),i.jsx("p",{className:"text-sm mb-4",children:a("settings.apiKeysEmptyDescription")}),i.jsxs(Ie,{onClick:()=>$(!0),children:[i.jsx(ar,{className:"w-4 h-4"}),a("settings.createFirstKey")]})]})})}),i.jsxs(Pt,{className:"mt-6",children:[i.jsx(Hn,{children:i.jsx("h3",{className:"text-base font-semibold text-white",children:a("settings.webhookEndpoints")})}),i.jsxs(Et,{className:"space-y-3 text-sm",children:[i.jsx("p",{className:"text-bambu-gray",children:a("settings.webhookApiKeyHint")}),i.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[i.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[i.jsx("span",{className:"text-blue-400",children:"GET"})," ",i.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),i.jsxs("span",{className:"text-bambu-gray",children:[" - ",a("settings.webhook.getAllStatus")]})]}),i.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[i.jsx("span",{className:"text-blue-400",children:"GET"})," ",i.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),i.jsxs("span",{className:"text-bambu-gray",children:[" - ",a("settings.webhook.getSpecificStatus")]})]}),i.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[i.jsx("span",{className:"text-green-400",children:"POST"})," ",i.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),i.jsxs("span",{className:"text-bambu-gray",children:[" - ",a("settings.webhook.addToQueue")]})]}),i.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[i.jsx("span",{className:"text-orange-400",children:"POST"})," ",i.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),i.jsxs("span",{className:"text-bambu-gray",children:[" - ",a("settings.webhook.pausePrint")]})]}),i.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[i.jsx("span",{className:"text-orange-400",children:"POST"})," ",i.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),i.jsxs("span",{className:"text-bambu-gray",children:[" - ",a("settings.webhook.resumePrint")]})]}),i.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[i.jsx("span",{className:"text-red-400",children:"POST"})," ",i.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),i.jsxs("span",{className:"text-bambu-gray",children:[" - ",a("settings.webhook.stopPrint")]})]})]})]})]})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"mb-6",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(wh,{className:"w-5 h-5 text-bambu-green"}),a("settings.apiBrowser")]}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a("settings.apiBrowserDescription")})]}),i.jsx(Pt,{className:"mb-4",children:i.jsxs(Et,{className:"py-3",children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:a("settings.apiKeyForTesting")}),i.jsx("input",{type:"text",value:xe,onChange:Se=>ae(Se.target.value),placeholder:a("settings.apiKeyPlaceholder"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm focus:border-bambu-green focus:outline-none"}),i.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:a("settings.apiKeyHint")})]})}),i.jsx(Oet,{apiKey:xe})]})]}),q==="virtual-printer"&&i.jsx(Aet,{}),q==="filament"&&k&&i.jsx(i.Fragment,{children:i.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[i.jsxs("div",{className:"lg:w-1/3 space-y-6",children:[i.jsx(vet,{}),i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:a("settings.filamentChecks")})}),i.jsx(Et,{className:"space-y-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:a("settings.disableFilamentWarnings")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.disableFilamentWarningsDesc")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:k.disable_filament_warnings,onChange:Se=>hn("disable_filament_warnings",Se.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})})]}),i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:a("settings.amsDisplayThresholds")})}),i.jsxs(Et,{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.amsThresholdsDescription")}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-white",children:[i.jsx(HL,{className:"w-4 h-4 text-blue-400"}),i.jsx("span",{className:"font-medium",children:a("settings.humidity")})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a("settings.goodGreen")," ≤"]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"number",min:"0",max:"100",value:k.ams_humidity_good??40,onChange:Se=>hn("ams_humidity_good",parseInt(Se.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),i.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a("settings.fairOrange")," ≤"]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"number",min:"0",max:"100",value:k.ams_humidity_fair??60,onChange:Se=>hn("ams_humidity_fair",parseInt(Se.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),i.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:a("settings.aboveFairBad")}),i.jsx("p",{className:"text-xs text-amber-400/70",children:a("settings.fairAlsoDryingThreshold")})]}),i.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-2 text-white",children:[i.jsx(sT,{className:"w-4 h-4 text-orange-400"}),i.jsx("span",{className:"font-medium",children:a("settings.temperature")})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a("settings.goodBlue")," ≤"]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:k.ams_temp_good??28,onChange:Se=>hn("ams_temp_good",parseFloat(Se.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),i.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a("settings.fairOrange")," ≤"]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:k.ams_temp_fair??35,onChange:Se=>hn("ams_temp_fair",parseFloat(Se.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),i.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:a("settings.aboveFairHot")})]}),i.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-2 text-white",children:[i.jsx(mu,{className:"w-4 h-4 text-purple-400"}),i.jsx("span",{className:"font-medium",children:a("settings.historyRetention")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:a("settings.keepSensorHistory")}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"number",min:"1",max:"365",value:k.ams_history_retention_days??30,onChange:Se=>hn("ams_history_retention_days",parseInt(Se.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),i.jsx("span",{className:"text-bambu-gray",children:a("common.days")})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:a("settings.historyRetentionDescription")})]}),i.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-2 text-white",children:[i.jsx(Ip,{className:"w-4 h-4 text-amber-400"}),i.jsx("span",{className:"font-medium",children:a("settings.queueDrying")})]}),i.jsx("p",{className:"text-xs text-bambu-gray",children:a("settings.queueDryingDescription")}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-white",children:a("settings.queueDryingEnabled")}),i.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:a("settings.queueDryingEnabledDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:k.queue_drying_enabled??!1,onChange:Se=>hn("queue_drying_enabled",Se.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),k.queue_drying_enabled&&i.jsx(i.Fragment,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-white",children:a("settings.queueDryingBlock")}),i.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:a("settings.queueDryingBlockDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:k.queue_drying_block??!1,onChange:Se=>hn("queue_drying_block",Se.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-amber-500"})]})]})}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-white",children:a("settings.ambientDryingEnabled")}),i.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:a("settings.ambientDryingEnabledDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:k.ambient_drying_enabled??!1,onChange:Se=>hn("ambient_drying_enabled",Se.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-sm text-white font-medium",children:a("settings.dryingPresets")}),i.jsx("p",{className:"text-xs text-bambu-gray",children:a("settings.dryingPresetsDescription")}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-xs",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"text-bambu-gray border-b border-bambu-dark-tertiary",children:[i.jsx("th",{className:"text-left py-1.5",children:a("settings.dryingFilament")}),i.jsx("th",{className:"text-center py-1.5",colSpan:2,children:"AMS 2 Pro"}),i.jsx("th",{className:"text-center py-1.5",colSpan:2,children:"AMS-HT"})]})}),i.jsx("tbody",{children:(()=>{const Se={PLA:{n3f:45,n3s:45,n3f_hours:12,n3s_hours:12},PETG:{n3f:65,n3s:65,n3f_hours:12,n3s_hours:12},TPU:{n3f:65,n3s:75,n3f_hours:12,n3s_hours:18},ABS:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},ASA:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},PA:{n3f:65,n3s:85,n3f_hours:12,n3s_hours:12},PC:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},PVA:{n3f:65,n3s:85,n3f_hours:12,n3s_hours:18}};let It={...Se};try{if(k.drying_presets){const zn=JSON.parse(k.drying_presets);typeof zn=="object"&&zn!==null&&(It={...Se,...zn})}}catch{}const gr=(zn,Ta,gt)=>{const Ot={...It,[zn]:{...It[zn],[Ta]:gt}};hn("drying_presets",JSON.stringify(Ot))};return Object.entries(It).map(([zn,Ta])=>i.jsxs("tr",{className:"border-b border-bambu-dark-tertiary/50",children:[i.jsx("td",{className:"py-1.5 pr-2 text-white font-medium",children:zn}),i.jsx("td",{className:"py-1 px-1",children:i.jsxs("div",{className:"flex items-center justify-end gap-1",children:[i.jsx("input",{type:"number",min:30,max:65,value:Ta.n3f,onChange:gt=>gr(zn,"n3f",Math.max(1,parseInt(gt.target.value)||0)),className:"w-14 px-1.5 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-center text-xs focus:border-amber-500/50 focus:outline-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),i.jsx("span",{className:"text-bambu-gray",children:"°C"})]})}),i.jsx("td",{className:"py-1 px-1",children:i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("input",{type:"number",min:1,max:24,value:Ta.n3f_hours,onChange:gt=>gr(zn,"n3f_hours",Math.max(1,parseInt(gt.target.value)||0)),className:"w-14 px-1.5 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-center text-xs focus:border-amber-500/50 focus:outline-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),i.jsx("span",{className:"text-bambu-gray",children:"h"})]})}),i.jsx("td",{className:"py-1 px-1",children:i.jsxs("div",{className:"flex items-center justify-end gap-1",children:[i.jsx("input",{type:"number",min:30,max:85,value:Ta.n3s,onChange:gt=>gr(zn,"n3s",Math.max(1,parseInt(gt.target.value)||0)),className:"w-14 px-1.5 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-center text-xs focus:border-amber-500/50 focus:outline-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),i.jsx("span",{className:"text-bambu-gray",children:"°C"})]})}),i.jsx("td",{className:"py-1 px-1",children:i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("input",{type:"number",min:1,max:24,value:Ta.n3s_hours,onChange:gt=>gr(zn,"n3s_hours",Math.max(1,parseInt(gt.target.value)||0)),className:"w-14 px-1.5 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-center text-xs focus:border-amber-500/50 focus:outline-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),i.jsx("span",{className:"text-bambu-gray",children:"h"})]})})]},zn))})()})]})})]})]}),i.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-2 text-white",children:[i.jsx(_r,{className:"w-4 h-4 text-bambu-green"}),i.jsx("span",{className:"font-medium",children:a("settings.printModal")})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-white",children:a("settings.expandCustomMapping")}),i.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:a("settings.expandCustomMappingDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:k.per_printer_mapping_expanded??!1,onChange:Se=>hn("per_printer_mapping_expanded",Se.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})]})]})]})]}),i.jsxs("div",{className:"lg:w-2/3 space-y-6",children:[i.jsx(wet,{}),i.jsx(_et,{})]})]})}),ce!==null&&i.jsx(_n,{title:a("settings.deleteApiKeyTitle"),message:a("settings.deleteApiKeyMessage"),confirmText:a("settings.deleteKey"),variant:"danger",onConfirm:()=>{nn.mutate(ce),ge(null)},onCancel:()=>ge(null)}),A&&i.jsx(det,{plug:B,onClose:()=>{D(!1),z(null)}}),W&&i.jsx(pet,{provider:J,onClose:()=>{I(!1),ie(null)}}),Q&&i.jsx(fet,{template:Q,onClose:()=>ue(null)}),me&&i.jsx(bet,{onClose:()=>pe(!1)}),L&&i.jsx(_n,{title:a("settings.clearNotificationLogs"),message:a("settings.clearLogsMessage"),confirmText:a("settings.clearLogs"),variant:"warning",onConfirm:async()=>{F(!1);try{const Se=await fe.clearNotificationLogs(30);o(Se.message,"success")}catch{o(a("settings.toast.clearLogsFailed"),"error")}},onCancel:()=>F(!1)}),te&&i.jsx(_n,{title:a("settings.resetUiPreferences"),message:a("settings.resetUiPreferencesMessage"),confirmText:a("settings.resetPreferences"),variant:"default",onConfirm:()=>{ve(!1),localStorage.clear(),o(a("settings.toast.uiPreferencesReset"),"success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>ve(!1)}),he&&i.jsx(_n,{title:`Turn All Plugs ${he==="on"?"On":"Off"}`,message:`This will turn ${he==="on"?"ON":"OFF"} all ${De?.filter(Se=>Se.enabled).length||0} enabled smart plugs. ${he==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${he==="on"?"On":"Off"}`,variant:he==="off"?"danger":"warning",onConfirm:()=>{const Se=he;de(null),la.mutate(Se)},onCancel:()=>de(null)}),ke&&yn?.release_notes&&i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>_e(!1),children:i.jsxs(Pt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:Se=>Se.stopPropagation(),children:[i.jsxs(Hn,{className:"flex flex-row items-center justify-between shrink-0",children:[i.jsxs("div",{children:[i.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",yn.latest_version]}),yn.release_name&&yn.release_name!==yn.latest_version&&i.jsx("p",{className:"text-sm text-bambu-gray",children:yn.release_name})]}),i.jsx("button",{onClick:()=>_e(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:i.jsx(Ht,{className:"w-5 h-5"})})]}),i.jsx(Et,{className:"overflow-y-auto flex-1",children:i.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:yn.release_notes})}),i.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[yn.release_url&&i.jsx("a",{href:yn.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:i.jsxs(Ie,{variant:"secondary",className:"w-full",children:[i.jsx(ti,{className:"w-4 h-4"}),"View on GitHub"]})}),i.jsx(Ie,{onClick:()=>_e(!1),className:"flex-1",children:"Close"})]})]})}),q==="users"&&i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex gap-1 border-b border-bambu-dark-tertiary",children:[i.jsxs("button",{onClick:()=>E("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${j==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[i.jsx(Jm,{className:"w-4 h-4"}),a("settings.tabs.users")]}),i.jsxs("button",{onClick:()=>E("email"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${j==="email"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[i.jsx(sx,{className:"w-4 h-4"}),a("settings.tabs.emailAuth")||"Email Authentication",Ar?.advanced_auth_enabled&&i.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"})]})]}),j==="users"&&i.jsxs(i.Fragment,{children:[i.jsx(Pt,{children:i.jsx(Et,{className:"py-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${l?"bg-green-500/20":"bg-gray-500/20"}`,children:l?i.jsx(Ep,{className:"w-5 h-5 text-green-400"}):i.jsx(X1,{className:"w-5 h-5 text-gray-400"})}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-white font-medium",children:a("settings.authentication")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:a(l?"settings.authEnabledDescription":"settings.authDisabledDescription")})]})]}),l?c?.is_admin&&i.jsxs(Ie,{variant:"secondary",onClick:()=>$e(!0),children:[i.jsx(X1,{className:"w-4 h-4"}),a("common.disable")]}):i.jsxs(Ie,{onClick:()=>e("/setup"),children:[i.jsx(Ep,{className:"w-4 h-4"}),a("common.enable")]})]})})}),Ar?.advanced_auth_enabled&&i.jsx(Pt,{className:"border-blue-500/30 bg-blue-500/5",children:i.jsx(Et,{className:"py-4",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center bg-blue-500/20 flex-shrink-0",children:i.jsx(sx,{className:"w-5 h-5 text-blue-400"})}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-white font-medium",children:a("settings.email.advancedAuthEnabled")}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a("settings.email.advancedAuthEnabledDesc")})]})]})})}),l&&i.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-6",children:[i.jsxs("div",{className:"space-y-6",children:[c&&i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(Jm,{className:"w-5 h-5 text-bambu-green"}),a("settings.currentUser")]}),i.jsxs(Ie,{size:"sm",variant:"ghost",onClick:()=>Ae(!0),children:[i.jsx(Al,{className:"w-4 h-4"}),a("settings.changePassword")]})]})}),i.jsx(Et,{children:i.jsx("div",{className:"flex items-center justify-between",children:i.jsxs("div",{children:[i.jsx("p",{className:"text-white font-medium text-lg",children:c.username}),i.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[c.is_admin&&i.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300",children:a("settings.admin")}),c.groups?.map(Se=>i.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${Se.name==="Administrators"?"bg-purple-500/20 text-purple-300":Se.name==="Operators"?"bg-blue-500/20 text-blue-300":Se.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:Se.name},Se.id))]})]})})})]}),i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(Jm,{className:"w-5 h-5 text-bambu-green"}),a("settings.users")]}),zi("users:create")&&i.jsxs(Ie,{size:"sm",onClick:()=>{Ke(!0),mt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:[i.jsx(ar,{className:"w-4 h-4"}),a("settings.addUser")]})]})}),i.jsx(Et,{children:ep?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):rm.length===0?i.jsx("p",{className:"text-center text-bambu-gray py-8",children:a("settings.noUsersFound")}):i.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:rm.map(Se=>i.jsxs("div",{className:"py-3 flex items-center justify-between",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-white font-medium truncate",children:Se.username}),i.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[Se.is_admin&&i.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300",children:a("settings.admin")}),Se.groups?.map(It=>i.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${It.name==="Administrators"?"bg-purple-500/20 text-purple-300":It.name==="Operators"?"bg-blue-500/20 text-blue-300":It.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:It.name},It.id))]})]}),i.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[zi("users:update")&&i.jsx(Ie,{size:"sm",variant:"ghost",onClick:()=>ju(Se),children:i.jsx(oh,{className:"w-4 h-4"})}),zi("users:delete")&&Se.id!==c?.id&&i.jsx(Ie,{size:"sm",variant:"ghost",onClick:()=>sl(Se.id),children:i.jsx(en,{className:"w-4 h-4"})})]})]},Se.id))})})]})]}),i.jsx("div",{children:i.jsxs(Pt,{children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(S3,{className:"w-5 h-5 text-bambu-green"}),a("settings.groups")]}),zi("groups:create")&&i.jsxs(Ie,{size:"sm",onClick:()=>e("/groups/new"),children:[i.jsx(ar,{className:"w-4 h-4"}),a("settings.addGroup")]})]})}),i.jsx(Et,{children:rg?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):To.length===0?i.jsx("p",{className:"text-center text-bambu-gray py-8",children:a("settings.noGroupsFound")}):i.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:To.map(Se=>i.jsxs("div",{className:"py-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(S3,{className:`w-4 h-4 ${Se.name==="Administrators"?"text-purple-400":Se.name==="Operators"?"text-blue-400":Se.name==="Viewers"?"text-green-400":"text-bambu-gray"}`}),i.jsx("span",{className:"text-white font-medium",children:Se.name}),Se.is_system&&i.jsx("span",{className:"px-2 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:a("settings.system")})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[zi("groups:update")&&i.jsx(Ie,{size:"sm",variant:"ghost",onClick:()=>e(`/groups/${Se.id}/edit`),children:i.jsx(oh,{className:"w-4 h-4"})}),zi("groups:delete")&&!Se.is_system&&i.jsx(Ie,{size:"sm",variant:"ghost",onClick:()=>qt(Se.id),children:i.jsx(en,{className:"w-4 h-4"})})]})]}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-6",children:Se.description||a("settings.noDescription")}),i.jsxs("div",{className:"flex items-center gap-4 mt-2 ml-6 text-xs text-bambu-gray",children:[i.jsx("span",{children:a("settings.userCount",{count:Se.user_count})}),i.jsx("span",{children:a("settings.permissionCount",{count:Se.permissions.length})})]})]},Se.id))})})]})})]}),!l&&i.jsx(Pt,{children:i.jsx(Et,{className:"py-6",children:i.jsxs("div",{className:"text-center",children:[i.jsx(X1,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),i.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:a("settings.authDisabledTitle")}),i.jsx("p",{className:"text-sm text-bambu-gray mb-4 max-w-md mx-auto",children:a("settings.authDisabledMessage")}),i.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray mb-6 text-left max-w-xs mx-auto",children:[i.jsxs("li",{className:"flex items-start gap-2",children:[i.jsx(fr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),i.jsx("span",{children:a("settings.authDisabledFeature1")})]}),i.jsxs("li",{className:"flex items-start gap-2",children:[i.jsx(fr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),i.jsx("span",{children:a("settings.authDisabledFeature2")})]}),i.jsxs("li",{className:"flex items-start gap-2",children:[i.jsx(fr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),i.jsx("span",{children:a("settings.authDisabledFeature3")})]})]}),i.jsxs(Ie,{onClick:()=>e("/setup"),children:[i.jsx(Ep,{className:"w-4 h-4"}),a("settings.enableAuthentication")]})]})})})]}),j==="email"&&i.jsx("div",{className:"max-w-2xl",children:i.jsx(Det,{})})]}),Ee&&!Ar?.advanced_auth_enabled&&i.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{Ke(!1),mt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:i.jsxs(Pt,{className:"w-full max-w-md",onClick:Se=>Se.stopPropagation(),children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Jm,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:a("settings.createUser")})]}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>{Ke(!1),mt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:i.jsx(Ht,{className:"w-5 h-5"})})]})}),i.jsxs(Et,{children:[i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:a("settings.username")}),i.jsx("input",{type:"text",value:Nt.username,onChange:Se=>mt({...Nt,username:Se.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:a("settings.enterUsername"),autoComplete:"username"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:a("settings.password")}),i.jsx("input",{type:"password",value:Nt.password,onChange:Se=>mt({...Nt,password:Se.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:a("settings.enterPassword"),autoComplete:"new-password",minLength:6})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:a("settings.confirmPassword")}),i.jsx("input",{type:"password",value:Nt.confirmPassword,onChange:Se=>mt({...Nt,confirmPassword:Se.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${Nt.confirmPassword&&Nt.password!==Nt.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:a("settings.confirmPasswordPlaceholder"),autoComplete:"new-password",minLength:6}),Nt.confirmPassword&&Nt.password!==Nt.confirmPassword&&i.jsx("p",{className:"text-red-400 text-xs mt-1",children:a("settings.passwordsDoNotMatch")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:a("settings.groups")}),i.jsxs("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:[To.map(Se=>i.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:Nt.group_ids.includes(Se.id),onChange:()=>im(Se.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),i.jsx("span",{className:"text-sm text-white",children:Se.name}),Se.is_system&&i.jsx("span",{className:"text-xs text-yellow-400",children:a("settings.systemBadge")})]},Se.id)),To.length===0&&i.jsx("p",{className:"text-sm text-bambu-gray",children:a("settings.noGroupsAvailable")})]})]})]}),i.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[i.jsx(Ie,{variant:"secondary",onClick:()=>{Ke(!1),mt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a("common.cancel")}),i.jsx(Ie,{onClick:Po,disabled:Eu.isPending||!Nt.username||!Nt.password||Nt.password!==Nt.confirmPassword||Nt.password.length<6,children:Eu.isPending?i.jsxs(i.Fragment,{children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),a("settings.creating")]}):i.jsxs(i.Fragment,{children:[i.jsx(ar,{className:"w-4 h-4"}),a("settings.createUser")]})})]})]})]})}),Ee&&Ar?.advanced_auth_enabled&&i.jsx(yet,{formData:Nt,setFormData:mt,groups:To,onClose:()=>{Ke(!1),mt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},onCreate:Po,isCreating:Eu.isPending,isCreateButtonDisabled:Eu.isPending||!Nt.username||!Nt.email}),Ve&&Ce!==null&&i.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{Ne(!1),He(null),mt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:i.jsxs(Pt,{className:"w-full max-w-md",onClick:Se=>Se.stopPropagation(),children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(oh,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:a("settings.editUser")})]}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>{Ne(!1),He(null),mt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:i.jsx(Ht,{className:"w-5 h-5"})})]})}),i.jsxs(Et,{children:[i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[a("settings.username")," ",Ar?.advanced_auth_enabled&&i.jsx("span",{className:"text-red-400",children:"*"})]}),i.jsx("input",{type:"text",value:Nt.username,onChange:Se=>mt({...Nt,username:Se.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:a("settings.enterUsername"),autoComplete:"username"})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[a("users.form.email")||"Email"," ",Ar?.advanced_auth_enabled?i.jsx("span",{className:"text-red-400",children:"*"}):i.jsxs("span",{className:"text-bambu-gray font-normal",children:["(",a("users.form.optional")||"optional",")"]})]}),i.jsx("input",{type:"email",value:Nt.email,onChange:Se=>mt({...Nt,email:Se.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:a("users.form.emailPlaceholder")||"user@example.com",required:Ar?.advanced_auth_enabled})]}),!Ar?.advanced_auth_enabled&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[a("users.form.password")||"Password"," ",i.jsxs("span",{className:"text-bambu-gray font-normal",children:["(",a("users.form.leaveBlankToKeep")||"leave blank to keep current",")"]})]}),i.jsx("input",{type:"password",value:Nt.password,onChange:Se=>mt({...Nt,password:Se.target.value,confirmPassword:""}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:a("settings.enterNewPassword"),autoComplete:"new-password",minLength:6})]}),Nt.password&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:a("settings.confirmPassword")}),i.jsx("input",{type:"password",value:Nt.confirmPassword,onChange:Se=>mt({...Nt,confirmPassword:Se.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${Nt.confirmPassword&&Nt.password!==Nt.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:a("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),Nt.confirmPassword&&Nt.password!==Nt.confirmPassword&&i.jsx("p",{className:"text-red-400 text-xs mt-1",children:a("settings.passwordsDoNotMatch")})]})]}),Ar?.advanced_auth_enabled&&i.jsxs("div",{className:"bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3 space-y-3",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:a("users.form.passwordManagedByAdvancedAuth")||'Password is managed by Advanced Authentication. Use "Reset Password" to send a new password to the user via email.'}),i.jsx(Ie,{variant:"secondary",size:"sm",onClick:()=>Ce&&ec.mutate(Ce),disabled:ec.isPending||!Nt.email,className:"w-full",children:ec.isPending?i.jsxs(i.Fragment,{children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),a("users.form.resettingPassword")||"Resetting Password..."]}):i.jsxs(i.Fragment,{children:[i.jsx(So,{className:"w-4 h-4"}),a("users.form.resetPassword")||"Reset Password"]})})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:a("users.form.groups")||"Groups"}),i.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:To.map(Se=>i.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:Nt.group_ids.includes(Se.id),onChange:()=>im(Se.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),i.jsx("span",{className:"text-sm text-white",children:Se.name}),Se.is_system&&i.jsxs("span",{className:"text-xs text-yellow-400",children:["(",a("users.system")||"System",")"]})]},Se.id))})]})]}),i.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[i.jsx(Ie,{variant:"secondary",onClick:()=>{Ne(!1),He(null),mt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a("users.modal.cancel")||"Cancel"}),i.jsx(Ie,{onClick:()=>eo(Ce),disabled:Ao.isPending||!Nt.username||Ar?.advanced_auth_enabled&&!Nt.email||!!(!Ar?.advanced_auth_enabled&&Nt.password&&(Nt.password!==Nt.confirmPassword||Nt.password.length<6)),children:Ao.isPending?i.jsxs(i.Fragment,{children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),a("users.modal.saving")||"Saving..."]}):i.jsxs(i.Fragment,{children:[i.jsx(ss,{className:"w-4 h-4"}),a("users.modal.saveChanges")||"Save Changes"]})})]})]})]})}),et!==null&&i.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:()=>{it(null),vt(null)},children:i.jsxs(Pt,{className:"w-full max-w-md",onClick:Se=>Se.stopPropagation(),children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center gap-2 text-red-400",children:[i.jsx(en,{className:"w-5 h-5"}),i.jsx("h3",{className:"text-lg font-semibold",children:a("settings.deleteUserTitle")})]})}),i.jsx(Et,{className:"space-y-4",children:qe?i.jsx("div",{className:"flex items-center justify-center py-4",children:i.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-bambu-green border-t-transparent"})}):xt&&xt.archives+xt.queue_items+xt.library_files>0?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"text-white",children:a("settings.userHasCreated")}),i.jsxs("ul",{className:"list-disc list-inside text-bambu-gray space-y-1",children:[xt.archives>0&&i.jsxs("li",{children:[xt.archives," archive",xt.archives!==1?"s":""]}),xt.queue_items>0&&i.jsxs("li",{children:[xt.queue_items," queue item",xt.queue_items!==1?"s":""]}),xt.library_files>0&&i.jsxs("li",{children:[xt.library_files," library file",xt.library_files!==1?"s":""]})]}),i.jsx("p",{className:"text-bambu-gray text-sm",children:a("settings.userItemsQuestion")}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(Ie,{variant:"danger",onClick:()=>Ui.mutate({id:et,deleteItems:!0}),disabled:Ui.isPending,className:"justify-center",children:a("settings.deleteUserAndItems")}),i.jsx(Ie,{variant:"secondary",onClick:()=>Ui.mutate({id:et,deleteItems:!1}),disabled:Ui.isPending,className:"justify-center",children:a("settings.deleteUserKeepItems")}),i.jsx(Ie,{variant:"ghost",onClick:()=>{it(null),vt(null)},disabled:Ui.isPending,className:"justify-center",children:a("common.cancel")})]})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"text-white",children:a("settings.deleteUserConfirm")}),i.jsx("p",{className:"text-bambu-gray text-sm",children:a("settings.actionCannotBeUndone")}),i.jsxs("div",{className:"flex gap-2 justify-end",children:[i.jsx(Ie,{variant:"ghost",onClick:()=>{it(null),vt(null)},disabled:Ui.isPending,children:a("common.cancel")}),i.jsx(Ie,{variant:"danger",onClick:()=>Ui.mutate({id:et,deleteItems:!1}),disabled:Ui.isPending,children:a("settings.deleteUserTitle")})]})]})})]})}),jt!==null&&i.jsx(_n,{title:a("settings.deleteGroupTitle"),message:a("settings.deleteGroupMessage"),confirmText:a("settings.deleteGroup"),variant:"danger",onConfirm:()=>{Js.mutate(jt),qt(null)},onCancel:()=>qt(null)}),q==="backup"&&i.jsx(Met,{}),Le&&i.jsx(_n,{title:a("settings.disableAuthenticationTitle"),message:a("settings.disableAuthenticationMessage"),confirmText:a("settings.disableAuthentication"),variant:"danger",onConfirm:async()=>{try{await fe.disableAuth(),o(a("settings.toast.authDisabled"),"success"),await u(),$e(!1),window.location.href="/"}catch(Se){const It=Se instanceof Error?Se.message:a("settings.toast.authDisableFailed");o(It,"error")}},onCancel:()=>$e(!1)}),Re&&i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{Ae(!1),Ue({currentPassword:"",newPassword:"",confirmPassword:""})},children:i.jsxs(Pt,{className:"w-full max-w-md",onClick:Se=>Se.stopPropagation(),children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Al,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:a("settings.changePassword")})]}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>{Ae(!1),Ue({currentPassword:"",newPassword:"",confirmPassword:""})},children:i.jsx(Ht,{className:"w-5 h-5"})})]})}),i.jsxs(Et,{children:[i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Current Password"}),i.jsx("input",{type:"password",value:Pe.currentPassword,onChange:Se=>Ue({...Pe,currentPassword:Se.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:a("settings.enterCurrentPassword"),autoComplete:"current-password"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"New Password"}),i.jsx("input",{type:"password",value:Pe.newPassword,onChange:Se=>Ue({...Pe,newPassword:Se.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:a("settings.enterNewPasswordMin6"),autoComplete:"new-password",minLength:6})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Confirm New Password"}),i.jsx("input",{type:"password",value:Pe.confirmPassword,onChange:Se=>Ue({...Pe,confirmPassword:Se.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${Pe.confirmPassword&&Pe.newPassword!==Pe.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:a("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),Pe.confirmPassword&&Pe.newPassword!==Pe.confirmPassword&&i.jsx("p",{className:"text-red-400 text-xs mt-1",children:a("settings.passwordsDoNotMatch")})]})]}),i.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[i.jsx(Ie,{variant:"secondary",onClick:()=>{Ae(!1),Ue({currentPassword:"",newPassword:"",confirmPassword:""})},children:a("common.cancel")}),i.jsx(Ie,{onClick:async()=>{if(Pe.newPassword!==Pe.confirmPassword){o(a("settings.toast.passwordsDoNotMatch"),"error");return}if(Pe.newPassword.length<6){o(a("settings.toast.passwordTooShort"),"error");return}Xe(!0);try{await fe.changePassword(Pe.currentPassword,Pe.newPassword),o(a("settings.toast.passwordChanged"),"success"),Ae(!1),Ue({currentPassword:"",newPassword:"",confirmPassword:""})}catch(Se){const It=Se instanceof Error?Se.message:"Failed to change password";o(It,"error")}finally{Xe(!1)}},disabled:je||!Pe.currentPassword||!Pe.newPassword||Pe.newPassword!==Pe.confirmPassword||Pe.newPassword.length<6,children:je?i.jsxs(i.Fragment,{children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),a("settings.changing")]}):i.jsxs(i.Fragment,{children:[i.jsx(Al,{className:"w-4 h-4"}),a("settings.changePassword")]})})]})]})]})})]})}const Loe=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},Bet=t=>t.startsWith("HH")?"HF":"S",Het=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},Ooe=t=>{const e=["High Flow_","High Flow ","Standard_","Standard ","HF_","HF ","S_","S "];for(const r of e)if(t.startsWith(r))return t.slice(r.length);const n=t.indexOf("_");return n>0?t.slice(n+1):t};function BD({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:a,onToggleSelect:s,note:o}){const l=Bet(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&s?s():e()};return i.jsxs("div",{className:"flex items-center gap-2",children:[r&&i.jsx("button",{onClick:s,className:"text-bambu-gray hover:text-white transition-colors p-1",children:a?i.jsx(_o,{className:"w-4 h-4 text-bambu-green"}):i.jsx(ql,{className:"w-4 h-4"})}),i.jsxs("button",{onClick:u,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${a?"ring-1 ring-bambu-green":""}`,children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:Loe(t.k_value)}),i.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),o&&i.jsx("span",{title:"Has note",children:i.jsx(ZX,{className:"w-3 h-3 text-yellow-500"})}),i.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[l," ",c]})]}),o&&i.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:o,children:["Note: ",o.length>50?o.substring(0,50)+"...":o]})]}),!r&&n&&i.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:i.jsx(vo,{className:"w-4 h-4"})})]})}function HD({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],builtinFilaments:a=[],isDualNozzle:s=!1,initialNote:o="",initialNoteKey:l=null,onClose:c,onSave:u,onSaveNote:d,hasPermission:m}){const{t:p}=Rt(),{showToast:f}=fn(),[y,v]=w.useState(t?.name||""),[b,g]=w.useState(t?.k_value?Loe(t.k_value):"0.020"),[_,N]=w.useState(t?.filament_id||""),[T,C]=w.useState(t?.nozzle_id?Het(t.nozzle_id):"HH00"),[P,k]=w.useState(t?.nozzle_diameter||n),[R,A]=w.useState(t?[t.extruder_id]:s?[0,1]:[0]),[D,B]=w.useState(!1),[z,W]=w.useState({current:0,total:0}),[I,J]=w.useState(o),ie=Wr.useMemo(()=>{const oe=new Map;for(const Me of a)oe.set(Me.filament_id,Me.name);const be=new Map;for(const Me of r)if(Me.filament_id&&!be.has(Me.filament_id)){const Z=oe.get(Me.filament_id)||Ooe(Me.name||"");be.set(Me.filament_id,{id:Me.filament_id,name:Z||Me.filament_id})}return Array.from(be.values()).sort((Me,q)=>Me.name.localeCompare(q.name))},[r,a]),Q=ft({mutationFn:oe=>(console.log("[KProfile] Calling API..."),fe.setKProfile(e,oe)),onSuccess:oe=>{if(console.log("[KProfile] Save success:",oe),f(p("kProfiles.toast.profileSaved")),d&&I!==o){let be;I===""&&l?be=l:t&&t.slot_id>0?be=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:be=`name_${y}_${_}`,d(be,I)}B(!0),setTimeout(()=>{B(!1),u()},2500)},onError:oe=>{console.error("[KProfile] Save error:",oe),f(oe.message,"error"),B(!1)}}),ue=ft({mutationFn:oe=>(console.log("[KProfile] Deleting profile..."),fe.deleteKProfile(e,oe)),onSuccess:oe=>{console.log("[KProfile] Delete success:",oe),f(p("kProfiles.toast.profileDeleted")),B(!0),setTimeout(()=>{B(!1),c()},4e3)},onError:oe=>{console.error("[KProfile] Delete error:",oe),f(oe.message,"error"),B(!1)}}),[me,pe]=w.useState(!1),Y=()=>{t&&ue.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},se=async oe=>{if(oe.preventDefault(),s&&!t&&R.length===0){f(p("kProfiles.toast.selectAtLeastOneExtruder"),"error");return}const be=parseFloat(b).toFixed(6),Me=`${T}-${P}`;if(t||R.length===1){const Z={name:y,k_value:be,filament_id:_,nozzle_id:Me,nozzle_diameter:P,extruder_id:t?t.extruder_id:R[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",Z),Q.mutate(Z);return}B(!0),W({current:1,total:R.length});const q=R.map(Z=>({name:y,k_value:be,filament_id:_,nozzle_id:Me,nozzle_diameter:P,extruder_id:Z,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${q.length} profiles in batch:`,q);try{if(await fe.setKProfilesBatch(e,q),f(p("kProfiles.toast.profilesSaved",{count:R.length})),d&&I){const Z=`name_${y}_${_}`;d(Z,I)}}catch(Z){console.error("[KProfile] Failed to save batch:",Z),f(p("kProfiles.toast.failedToSaveBatch"),"error"),B(!1),W({current:0,total:0});return}W({current:R.length,total:R.length}),setTimeout(()=>{B(!1),W({current:0,total:0}),u()},3e3)};return i.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[i.jsxs(Pt,{className:"w-full max-w-md relative",children:[D&&i.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),i.jsx("p",{className:"text-white font-medium",children:z.total>1?p("kProfiles.modal.savingExtruder",{current:z.current,total:z.total}):p("kProfiles.modal.syncing")}),i.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:p("kProfiles.modal.pleaseWait")})]}),i.jsxs(Et,{className:"p-0",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[i.jsx("h2",{className:"text-xl font-semibold text-white",children:p(t?"kProfiles.modal.editTitle":"kProfiles.modal.addTitle")}),i.jsx("button",{onClick:c,className:"text-bambu-gray hover:text-white transition-colors",disabled:D,children:i.jsx(Ht,{className:"w-5 h-5"})})]}),i.jsxs("form",{onSubmit:se,className:"p-4 space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:p("kProfiles.modal.profileName")}),i.jsx("input",{type:"text",value:y,onChange:oe=>v(oe.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:p("kProfiles.modal.profileNamePlaceholder"),required:!t})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:p("kProfiles.modal.kValue")}),i.jsx("input",{type:"text",inputMode:"decimal",value:b,onChange:oe=>{const be=oe.target.value;(be===""||/^\d*\.?\d*$/.test(be))&&g(be)},onBlur:oe=>{const be=parseFloat(oe.target.value);isNaN(be)||g((Math.trunc(be*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:p("kProfiles.modal.kValuePlaceholder"),required:!0}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:p("kProfiles.modal.kValueHelp")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:p("kProfiles.modal.filament")}),i.jsxs("select",{value:_,onChange:oe=>{const be=oe.target.value;if(N(be),!t&&be&&!y){const Me=ie.find(q=>q.id===be);Me&&v(`${T==="HH00"?"HF":"S"} ${Me.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[i.jsx("option",{value:"",children:p("kProfiles.modal.selectFilament")}),t?.filament_id&&i.jsx("option",{value:t.filament_id,children:ie.find(oe=>oe.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&ie.map(oe=>i.jsx("option",{value:oe.id,children:oe.name},oe.id))]}),!t&&ie.length===0&&i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:p("kProfiles.modal.noFilamentsHelp")})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:p("kProfiles.modal.flowType")}),i.jsxs("select",{value:T,onChange:oe=>{const be=oe.target.value;if(C(be),!t&&_&&!y){const Me=ie.find(q=>q.id===_);Me&&v(`${be==="HS00"?"HF":"S"} ${Me.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[i.jsx("option",{value:"HH00",children:p("kProfiles.modal.highFlow")}),i.jsx("option",{value:"HS00",children:p("kProfiles.modal.standard")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:p("kProfiles.modal.nozzleSize")}),i.jsxs("select",{value:P,onChange:oe=>k(oe.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[i.jsx("option",{value:"0.2",children:"0.2mm"}),i.jsx("option",{value:"0.4",children:"0.4mm"}),i.jsx("option",{value:"0.6",children:"0.6mm"}),i.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),s&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:p(t?"kProfiles.modal.extruder":"kProfiles.modal.extruders")}),t?i.jsx("div",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60",children:t.extruder_id===1?p("kProfiles.modal.left"):p("kProfiles.modal.right")}):i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:R.includes(1),onChange:oe=>{oe.target.checked?A([...R,1]):A(R.filter(be=>be!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),i.jsx("span",{className:"text-white",children:p("kProfiles.modal.left")})]}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:R.includes(0),onChange:oe=>{oe.target.checked?A([...R,0]):A(R.filter(be=>be!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),i.jsx("span",{className:"text-white",children:p("kProfiles.modal.right")})]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:p("kProfiles.modal.notes")}),i.jsx("textarea",{value:I,onChange:oe=>J(oe.target.value),placeholder:p("kProfiles.modal.notesPlaceholder"),rows:2,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none"}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:p("kProfiles.modal.notesHelp")})]}),i.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&i.jsx(Ie,{type:"button",variant:"secondary",onClick:()=>pe(!0),disabled:ue.isPending||D||!m("kprofiles:delete"),title:m("kprofiles:delete")?void 0:p("kProfiles.permission.noDelete"),className:"text-red-500 hover:bg-red-500/10",children:ue.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(en,{className:"w-4 h-4"})}),i.jsx(Ie,{type:"button",variant:"secondary",onClick:c,disabled:D,className:"flex-1",children:p("common.cancel")}),i.jsxs(Ie,{type:"submit",disabled:Q.isPending||D||!m(t?"kprofiles:update":"kprofiles:create"),title:m(t?"kprofiles:update":"kprofiles:create")?void 0:p(t?"kProfiles.permission.noUpdate":"kProfiles.permission.noCreate"),className:"flex-1",children:[Q.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(gw,{className:"w-4 h-4"}),p("common.save")]})]})]})]})]}),me&&i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:i.jsx(Pt,{className:"w-full max-w-sm",children:i.jsxs(Et,{className:"p-6",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[i.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:i.jsx(en,{className:"w-5 h-5 text-red-500"})}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-lg font-semibold text-white",children:p("kProfiles.deleteConfirm.title")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:p("kProfiles.deleteConfirm.cannotUndo")})]})]}),i.jsx("p",{className:"text-bambu-gray mb-6",children:p("kProfiles.deleteConfirm.message",{name:t?.name})}),i.jsxs("div",{className:"flex gap-3",children:[i.jsx(Ie,{variant:"secondary",onClick:()=>pe(!1),className:"flex-1",children:p("common.cancel")}),i.jsxs(Ie,{onClick:()=>{pe(!1),Y()},disabled:ue.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[ue.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(en,{className:"w-4 h-4"}),p("common.delete")]})]})]})})})]})}const W1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function $et(){const{t}=Rt(),{showToast:e}=fn(),{hasPermission:n}=Nr(),[r,a]=w.useState(null),[s,o]=w.useState(()=>localStorage.getItem(W1.NOZZLE_DIAMETER)||"0.4"),[l,c]=w.useState(null),[u,d]=w.useState(!1),[m,p]=w.useState(null),[f,y]=w.useState(""),[v,b]=w.useState("all"),[g,_]=w.useState("all"),[N,T]=w.useState(()=>localStorage.getItem(W1.SORT_OPTION)||"name"),[C,P]=w.useState(!1),[k,R]=w.useState(new Set),[A,D]=w.useState(!1),[B,z]=w.useState(!1),W=w.useCallback(F=>`${F.slot_id}_${F.extruder_id}`,[]);w.useEffect(()=>{localStorage.setItem(W1.NOZZLE_DIAMETER,s)},[s]),w.useEffect(()=>{localStorage.setItem(W1.SORT_OPTION,N)},[N]);const{data:I,isLoading:J}=tt({queryKey:["printers"],queryFn:fe.getPrinters}),{data:ie,isLoading:Q,isFetching:ue,error:me,refetch:pe}=tt({queryKey:["kprofiles",r,s],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",r,"nozzle",s);const F=await fe.getKProfiles(r,s);return console.log("[KProfiles] Received profiles:",F?.profiles?.length||0,"profiles"),F},enabled:!!r,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:Y}=tt({queryKey:["kprofiles",r,"0.4"],queryFn:()=>fe.getKProfiles(r,"0.4"),enabled:!!r,staleTime:6e4}),{data:se}=tt({queryKey:["builtinFilaments"],queryFn:()=>fe.getBuiltinFilaments(),staleTime:3e5}),{data:oe}=tt({queryKey:["filamentIdMap"],queryFn:()=>fe.getFilamentIdMap(),staleTime:3e5}),{data:be,refetch:Me}=tt({queryKey:["kprofile-notes",r],queryFn:()=>fe.getKProfileNotes(r),enabled:!!r,staleTime:3e4}),q=me?.message?.includes("not connected");w.useEffect(()=>{if(!r&&I&&I.length>0){const F=I.find(te=>te.is_active);F&&a(F.id)}},[r,I]),w.useEffect(()=>{if(r){const F=setTimeout(()=>{pe()},150);return()=>clearTimeout(F)}},[r,s]);const Z=I?.filter(F=>F.is_active)||[],j=Wr.useMemo(()=>{const F=new Map;if(se)for(const te of se)F.set(te.filament_id,te.name);if(oe)for(const[te,ve]of Object.entries(oe))F.has(te)||F.set(te,ve);return F},[se,oe]),E=Wr.useMemo(()=>Array.from(j.entries()).map(([F,te])=>({filament_id:F,name:te})),[j]),U=Wr.useCallback(F=>j.get(F.filament_id)||Ooe(F.name),[j]),K=Wr.useMemo(()=>ie?.profiles?ie.profiles.filter(te=>{const ve=f.toLowerCase(),he=!ve||te.name.toLowerCase().includes(ve)||te.filament_id.toLowerCase().includes(ve),de=v==="all"||v==="left"&&te.extruder_id===1||v==="right"&&te.extruder_id===0,ke=g==="all"||g==="hf"&&te.nozzle_id.startsWith("HH")||g==="s"&&te.nozzle_id.startsWith("HS");return he&&de&&ke}).sort((te,ve)=>{switch(N){case"k_value":return parseFloat(te.k_value)-parseFloat(ve.k_value);case"filament":return U(te).localeCompare(U(ve));default:return te.name.localeCompare(ve.name)}}):[],[ie?.profiles,f,v,g,N,U]),$=I?.find(F=>F.id===r),ne=$?.nozzle_count===2;w.useEffect(()=>{const F=te=>{te.target instanceof HTMLInputElement||te.target instanceof HTMLTextAreaElement||te.target instanceof HTMLSelectElement||l||u||m||(te.key==="r"||te.key==="R"?(te.preventDefault(),pe()):te.key==="n"||te.key==="N"?(te.preventDefault(),d(!0)):te.key==="Escape"&&C&&(te.preventDefault(),P(!1),R(new Set)))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[l,u,m,C,pe]);const O=w.useCallback(()=>{if(!ie?.profiles||ie.profiles.length===0){e(t("kProfiles.toast.noProfilesToExport"),"error");return}const F={version:1,exported_at:new Date().toISOString(),printer:$?.name||"Unknown",nozzle_diameter:s,profiles:ie.profiles.map(de=>({name:de.name,k_value:de.k_value,filament_id:de.filament_id,nozzle_id:de.nozzle_id,nozzle_diameter:de.nozzle_diameter,extruder_id:de.extruder_id}))},te=new Blob([JSON.stringify(F,null,2)],{type:"application/json"}),ve=URL.createObjectURL(te),he=document.createElement("a");he.href=ve,he.download=`kprofiles_${$?.name||"printer"}_${s}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(he),he.click(),document.body.removeChild(he),URL.revokeObjectURL(ve),e(t("kProfiles.toast.exportedProfiles",{count:ie.profiles.length}))},[ie?.profiles,$,s,e,t]),V=w.useCallback(()=>{const F=document.createElement("input");F.type="file",F.accept=".json",F.onchange=async te=>{const ve=te.target.files?.[0];if(ve)try{const he=await ve.text(),de=JSON.parse(he);if(!de.profiles||!Array.isArray(de.profiles)){e(t("kProfiles.toast.invalidFileFormat"),"error");return}let ke=0;for(const _e of de.profiles)if(!(!_e.name||!_e.k_value||!_e.filament_id))try{await fe.setKProfile(r,{name:_e.name,k_value:parseFloat(_e.k_value).toFixed(6),filament_id:_e.filament_id,nozzle_id:_e.nozzle_id||`HH00-${s}`,nozzle_diameter:_e.nozzle_diameter||s,extruder_id:_e.extruder_id??0,slot_id:0}),ke++,await new Promise(Le=>setTimeout(Le,500))}catch(Le){console.error("Failed to import profile:",_e.name,Le)}e(t("kProfiles.toast.importedProfiles",{count:ke,total:de.profiles.length})),pe()}catch(he){console.error("Import error:",he),e(t("kProfiles.toast.failedToParseImport"),"error")}},F.click()},[r,s,e,pe,t]),ee=w.useCallback(F=>{R(te=>{const ve=new Set(te);return ve.has(F)?ve.delete(F):ve.add(F),ve})},[]),G=w.useCallback(()=>{R(new Set(K.map(F=>W(F))))},[K,W]),re=w.useCallback(()=>{k.size!==0&&D(!0)},[k.size]),ce=w.useCallback(async()=>{const F=K.filter(ve=>k.has(W(ve)));z(!0);let te=0;for(const ve of F)try{await fe.deleteKProfile(r,{slot_id:ve.slot_id,extruder_id:ve.extruder_id,nozzle_id:ve.nozzle_id,nozzle_diameter:ve.nozzle_diameter,filament_id:ve.filament_id,setting_id:ve.setting_id}),te++,await new Promise(he=>setTimeout(he,300))}catch(he){console.error("Failed to delete profile:",ve.name,he)}e(t("kProfiles.toast.profilesDeleted",{count:te})),z(!1),D(!1),P(!1),R(new Set),pe()},[r,k,K,e,pe,W,t]),ge=w.useCallback(F=>{const te=[];return F.setting_id&&te.push(F.setting_id),te.push(`slot_${F.slot_id}_${F.filament_id}_${F.extruder_id}`),te.push(`name_${F.name}_${F.filament_id}`),te},[]),xe=w.useCallback(async(F,te)=>{if(r)try{await fe.setKProfileNote(r,F,te),Me()}catch(ve){console.error("Failed to save note:",ve),e(t("kProfiles.toast.failedToSaveNote"),"error")}},[r,Me,e,t]),ae=w.useCallback(F=>{if(!be?.notes)return{note:"",key:null};const te=ge(F);for(const ve of te)if(be.notes[ve])return{note:be.notes[ve],key:ve};return{note:"",key:null}},[be,ge]),L=w.useCallback(F=>ae(F).note,[ae]);return J?i.jsx("div",{className:"flex justify-center py-12",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!I||I.length===0?i.jsx(Pt,{children:i.jsxs(Et,{className:"py-12 text-center",children:[i.jsx(Li,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),i.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noPrintersConfigured")}),i.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.addPrinterInSettings")})]})}):Z.length===0?i.jsx(Pt,{children:i.jsxs(Et,{className:"py-12 text-center",children:[i.jsx(_r,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),i.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noActivePrinters")}),i.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.enablePrinterConnection")})]})}):i.jsxs(i.Fragment,{children:[ue&&!Q&&i.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[i.jsx(pt,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),i.jsx("p",{className:"text-white font-medium",children:t("kProfiles.loadingProfiles")})]}),i.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[i.jsxs("div",{className:"flex-1 min-w-48",children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("kProfiles.printer")}),i.jsx("select",{value:r||"",onChange:F=>a(parseInt(F.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:Z.map(F=>i.jsx("option",{value:F.id,children:F.name},F.id))})]}),i.jsxs("div",{className:"w-32",children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("kProfiles.nozzle")}),i.jsxs("select",{value:s,onChange:F=>o(F.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"0.2",children:"0.2mm"}),i.jsx("option",{value:"0.4",children:"0.4mm"}),i.jsx("option",{value:"0.6",children:"0.6mm"}),i.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),i.jsxs("div",{className:"flex items-end gap-2",children:[i.jsxs(Ie,{variant:"secondary",onClick:()=>pe(),disabled:ue||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noRead"),children:[i.jsx(Sr,{className:`w-4 h-4 ${ue?"animate-spin":""}`}),t("kProfiles.refresh")]}),i.jsxs(Ie,{onClick:()=>d(!0),disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noCreate"),children:[i.jsx(ar,{className:"w-4 h-4"}),t("kProfiles.addProfile")]})]})]}),i.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[i.jsxs("div",{className:"flex-1 min-w-48 relative",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),i.jsx("input",{type:"text",value:f,onChange:F=>y(F.target.value),placeholder:t("kProfiles.searchPlaceholder"),className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),ne&&i.jsx("div",{className:"w-36",children:i.jsxs("select",{value:v,onChange:F=>b(F.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"all",children:t("kProfiles.allExtruders")}),i.jsx("option",{value:"left",children:t("kProfiles.leftOnly")}),i.jsx("option",{value:"right",children:t("kProfiles.rightOnly")})]})}),i.jsx("div",{className:"w-32",children:i.jsxs("select",{value:g,onChange:F=>_(F.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"all",children:t("kProfiles.allFlow")}),i.jsx("option",{value:"hf",children:t("kProfiles.hfOnly")}),i.jsx("option",{value:"s",children:t("kProfiles.sOnly")})]})}),i.jsx("div",{className:"w-32",children:i.jsxs("select",{value:N,onChange:F=>T(F.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"name",children:t("kProfiles.sortName")}),i.jsx("option",{value:"k_value",children:t("kProfiles.sortKValue")}),i.jsx("option",{value:"filament",children:t("kProfiles.sortFilament")})]})})]}),i.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[i.jsxs(Ie,{variant:"secondary",onClick:O,disabled:!ie?.profiles?.length||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noExport"),children:[i.jsx(bi,{className:"w-4 h-4"}),t("kProfiles.export")]}),i.jsxs(Ie,{variant:"secondary",onClick:V,disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noImport"),children:[i.jsx(vi,{className:"w-4 h-4"}),t("kProfiles.import")]}),i.jsx("div",{className:"flex-1"}),C?i.jsxs(i.Fragment,{children:[i.jsxs(Ie,{variant:"secondary",onClick:G,children:[i.jsx(_o,{className:"w-4 h-4"}),t("kProfiles.selectAll")]}),i.jsxs(Ie,{variant:"secondary",onClick:re,disabled:k.size===0||!n("kprofiles:delete"),className:"text-red-500 hover:bg-red-500/10",title:n("kprofiles:delete")?void 0:t("kProfiles.permission.noDelete"),children:[i.jsx(en,{className:"w-4 h-4"}),t("kProfiles.delete")," (",k.size,")"]}),i.jsxs(Ie,{variant:"secondary",onClick:()=>{P(!1),R(new Set)},children:[i.jsx(Ht,{className:"w-4 h-4"}),t("common.cancel")]})]}):i.jsxs(Ie,{variant:"secondary",onClick:()=>P(!0),disabled:!K.length||!n("kprofiles:delete"),title:n("kprofiles:delete")?void 0:t("kProfiles.permission.noDelete"),children:[i.jsx(_o,{className:"w-4 h-4"}),t("kProfiles.select")]})]}),Q?i.jsx("div",{className:"flex justify-center py-12",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):q?i.jsx(Pt,{children:i.jsxs(Et,{className:"py-12 text-center",children:[i.jsx(Rh,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),i.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.printerOffline")}),i.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.printerOfflineDesc")}),i.jsxs(Ie,{variant:"secondary",onClick:()=>pe(),children:[i.jsx(Sr,{className:"w-4 h-4"}),t("common.refresh")]})]})}):K.length>0?ne?i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:t("kProfiles.leftExtruder")}),i.jsx("div",{className:"space-y-1",children:K.filter(F=>F.extruder_id===1).map(F=>i.jsx(BD,{profile:F,onEdit:()=>c(F),onCopy:()=>p(F),selectionMode:C,isSelected:k.has(W(F)),onToggleSelect:()=>ee(W(F)),note:L(F)},W(F)))})]}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:t("kProfiles.rightExtruder")}),i.jsx("div",{className:"space-y-1",children:K.filter(F=>F.extruder_id===0).map(F=>i.jsx(BD,{profile:F,onEdit:()=>c(F),onCopy:()=>p(F),selectionMode:C,isSelected:k.has(W(F)),onToggleSelect:()=>ee(W(F)),note:L(F)},W(F)))})]})]}):i.jsx("div",{className:"space-y-1",children:K.map(F=>i.jsx(BD,{profile:F,onEdit:()=>c(F),onCopy:()=>p(F),selectionMode:C,isSelected:k.has(W(F)),onToggleSelect:()=>ee(W(F)),note:L(F)},W(F)))}):f||v!=="all"||g!=="all"?i.jsx(Pt,{children:i.jsxs(Et,{className:"py-12 text-center",children:[i.jsx(Rr,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),i.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noMatchingProfiles")}),i.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.noMatchingProfilesDesc")})]})}):i.jsx(Pt,{children:i.jsxs(Et,{className:"py-12 text-center",children:[i.jsx(gw,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),i.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noKProfiles")}),i.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.noKProfilesDesc",{diameter:s})}),i.jsxs(Ie,{onClick:()=>d(!0),children:[i.jsx(ar,{className:"w-4 h-4"}),t("kProfiles.createFirstProfile")]})]})}),l&&r&&(()=>{const{note:F,key:te}=ae(l);return i.jsx(HD,{profile:l,printerId:r,nozzleDiameter:s,existingProfiles:Y?.profiles||ie?.profiles,builtinFilaments:E,isDualNozzle:ne,initialNote:F,initialNoteKey:te,onSaveNote:xe,hasPermission:n,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),c(null),pe()},onSave:()=>{c(null),pe()}})})(),u&&r&&i.jsx(HD,{printerId:r,nozzleDiameter:s,existingProfiles:Y?.profiles||ie?.profiles,builtinFilaments:E,isDualNozzle:ne,onSaveNote:xe,hasPermission:n,onClose:()=>{d(!1),pe()},onSave:()=>{d(!1),pe()}}),m&&r&&i.jsx(HD,{printerId:r,nozzleDiameter:s,existingProfiles:Y?.profiles||ie?.profiles,builtinFilaments:E,isDualNozzle:ne,onSaveNote:xe,hasPermission:n,profile:{...m,slot_id:0,name:`${m.name} (Copy)`},onClose:()=>{p(null),pe()},onSave:()=>{p(null),pe()}}),A&&i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:i.jsx(Pt,{className:"w-full max-w-sm",children:i.jsxs(Et,{className:"p-6",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[i.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:i.jsx(en,{className:"w-5 h-5 text-red-500"})}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-lg font-semibold text-white",children:t("kProfiles.bulkDelete.title")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("kProfiles.bulkDelete.cannotUndo")})]})]}),i.jsx("p",{className:"text-bambu-gray mb-6",children:t("kProfiles.bulkDelete.message",{count:k.size})}),i.jsxs("div",{className:"flex gap-3",children:[i.jsx(Ie,{variant:"secondary",onClick:()=>D(!1),disabled:B,className:"flex-1",children:t("common.cancel")}),i.jsxs(Ie,{onClick:ce,disabled:B,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[B?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(en,{className:"w-4 h-4"}),t("common.delete")]})]})]})})})]})}const Ioe=["PLA","PETG","PCTG","ABS","ASA","TPU","PC","PA","PVA","HIPS","PP","PET","NYLON"],qet={PLA:"E8E8E8",PETG:"4A90D9",ABS:"E67E22",ASA:"D35400",TPU:"9B59B6",PC:"BDC3C7",PA:"2ECC71",NYLON:"2ECC71",PVA:"F1C40F",HIPS:"95A5A6",PP:"ECF0F1",PET:"3498DB"};function Vet(t){const e=t.toUpperCase();for(const n of Ioe)if(new RegExp(`\\b${n}\\b`).test(e))return n;return null}function Get(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const r of Ioe){const a=n.indexOf(r);if(a>0){const s=e.slice(0,a).trim();if(s&&s.length>1)return s}}return null}function $D({preset:t,onDelete:e,onExpand:n,isExpanded:r}){const{t:a}=Rt(),{hasPermission:s}=Nr(),o=t.filament_type||Vet(t.name),l=t.filament_vendor||Get(t.name);let c=null,u=!1;if(t.default_filament_colour)try{const d=JSON.parse(t.default_filament_colour),m=Array.isArray(d)?d[0]:d;typeof m=="string"&&/^#?[0-9a-fA-F]{6,8}$/.test(m.replace("#",""))&&(c=m.replace("#","").slice(0,6),u=!0)}catch{const d=t.default_filament_colour;/^#?[0-9a-fA-F]{6,8}$/.test(d.replace("#",""))&&(c=d.replace("#","").slice(0,6),u=!0)}return!c&&o&&(c=qet[o.toUpperCase()]||null),i.jsx(Pt,{className:"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-dark-tertiary/80 transition-colors",children:i.jsxs(Et,{className:"p-3",children:[i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.preset_type==="filament"&&i.jsx("div",{className:`w-4 h-4 rounded-full border border-black/20 flex-shrink-0 ${!u&&!c?"opacity-25":u?"":"opacity-50"}`,style:{backgroundColor:c?`#${c}`:"#666"}}),i.jsx("span",{className:"text-sm font-medium text-white truncate",children:t.name})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o&&i.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-green/20 text-bambu-green",children:o}),l&&i.jsx("span",{className:"text-xs text-bambu-gray",children:l}),i.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400",children:a("profiles.localProfiles.badge")})]})]}),i.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s("settings:update")&&i.jsx("button",{onClick:()=>e(t.id),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",title:a("profiles.localProfiles.delete"),children:i.jsx(en,{className:"w-3.5 h-3.5"})}),i.jsx("button",{onClick:()=>n(r?null:t.id),className:"p-1 text-bambu-gray hover:text-white transition-colors",children:r?i.jsx($l,{className:"w-3.5 h-3.5"}):i.jsx(On,{className:"w-3.5 h-3.5"})})]})]}),r&&i.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary text-xs space-y-1.5",children:[o&&i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-bambu-gray",children:a("profiles.localProfiles.filamentType")}),i.jsx("span",{className:"text-white",children:o})]}),l&&i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-bambu-gray",children:a("profiles.localProfiles.vendor")}),i.jsx("span",{className:"text-white",children:l})]}),t.nozzle_temp_min!=null&&t.nozzle_temp_max!=null&&i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-bambu-gray",children:a("profiles.localProfiles.nozzleTemp")}),i.jsxs("span",{className:"text-white",children:[t.nozzle_temp_min,"–",t.nozzle_temp_max,"°C"]})]}),t.filament_cost&&i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-bambu-gray",children:a("profiles.localProfiles.cost")}),i.jsx("span",{className:"text-white",children:t.filament_cost})]}),t.filament_density&&i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-bambu-gray",children:a("profiles.localProfiles.density")}),i.jsxs("span",{className:"text-white",children:[t.filament_density," g/cm³"]})]}),t.pressure_advance&&i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-bambu-gray",children:a("profiles.localProfiles.pressureAdvance")}),i.jsx("span",{className:"text-white",children:t.pressure_advance})]}),t.compatible_printers&&i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-bambu-gray",children:a("profiles.localProfiles.compatiblePrinters")}),i.jsx("span",{className:"text-white truncate ml-2",children:(()=>{try{return JSON.parse(t.compatible_printers).join(", ")}catch{return t.compatible_printers}})()})]}),t.inherits&&t.inherits!==t.name&&i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-bambu-gray",children:a("profiles.localProfiles.inheritsFrom")}),i.jsx("span",{className:"text-white truncate ml-2",children:t.inherits})]}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-bambu-gray",children:a("profiles.localProfiles.source")}),i.jsx("span",{className:"text-white capitalize",children:t.source})]})]})]})})}function Wet(){const{t}=Rt(),{hasPermission:e}=Nr(),n=sn(),{showToast:r}=fn(),[a,s]=w.useState(""),[o,l]=w.useState(null),[c,u]=w.useState(!1),[d,m]=w.useState(null),{data:p,isLoading:f}=tt({queryKey:["localPresets"],queryFn:()=>fe.getLocalPresets()}),y=ft({mutationFn:async k=>{const R=[];for(const A of Array.from(k)){const D=new FormData;D.append("file",A),R.push(await fe.importLocalPresets(D))}return R},onSuccess:k=>{n.invalidateQueries({queryKey:["localPresets"]});let R=0,A=0,D=0;for(const B of k)R+=B.imported,A+=B.skipped,D+=B.errors.length;R>0&&r(t("profiles.localProfiles.toast.importSuccess",{count:R})),A>0&&r(t("profiles.localProfiles.toast.importSkipped",{count:A}),"warning"),D>0&&r(t("profiles.localProfiles.toast.importError",{count:D}),"error")},onError:k=>{r(k.message,"error")}}),v=ft({mutationFn:k=>fe.deleteLocalPreset(k),onSuccess:()=>{n.invalidateQueries({queryKey:["localPresets"]}),m(null),r(t("profiles.localProfiles.toast.deleted"))}}),b=w.useCallback(k=>{!k||k.length===0||y.mutate(k)},[y]),g=w.useCallback(k=>{k.preventDefault(),u(!1),b(k.dataTransfer.files)},[b]),_=w.useCallback(k=>{if(!a)return k;const R=a.toLowerCase();return k.filter(A=>A.name.toLowerCase().includes(R)||A.filament_type?.toLowerCase().includes(R)||A.filament_vendor?.toLowerCase().includes(R))},[a]),N=w.useMemo(()=>_(p?.filament||[]),[p?.filament,_]),T=w.useMemo(()=>_(p?.printer||[]),[p?.printer,_]),C=w.useMemo(()=>_(p?.process||[]),[p?.process,_]),P=N.length+T.length+C.length;return f?i.jsx("div",{className:"flex items-center justify-center py-16",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i.jsxs("div",{className:"space-y-6",children:[e("settings:update")&&i.jsxs("div",{onDragOver:k=>{k.preventDefault(),u(!0)},onDragLeave:()=>u(!1),onDrop:g,className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors ${c?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[i.jsx("input",{type:"file",accept:".json,.zip,.orca_filament,.bbscfg,.bbsflmt",multiple:!0,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",onChange:k=>b(k.target.files)}),y.isPending?i.jsxs("div",{className:"flex items-center justify-center gap-2",children:[i.jsx(pt,{className:"w-5 h-5 text-bambu-green animate-spin"}),i.jsx("span",{className:"text-bambu-gray",children:t("profiles.localProfiles.importing")})]}):i.jsxs(i.Fragment,{children:[i.jsx(vi,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),i.jsx("p",{className:"text-sm text-white font-medium",children:t("profiles.localProfiles.import")}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:t("profiles.localProfiles.importDesc")})]})]}),P>0&&i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),i.jsx("input",{type:"text",value:a,onChange:k=>s(k.target.value),placeholder:t("profiles.localProfiles.search"),className:"w-full pl-9 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),P===0&&!f&&i.jsxs("div",{className:"text-center py-12",children:[i.jsx(Ix,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3 opacity-50"}),i.jsx("p",{className:"text-bambu-gray",children:t("profiles.localProfiles.noPresets")}),i.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:t("profiles.localProfiles.importDesc")})]}),P>0&&i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[N.length>0&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(QC,{className:"w-4 h-4 text-bambu-green"}),i.jsx("h3",{className:"text-sm font-medium text-white",children:t("profiles.localProfiles.filament")}),i.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",N.length,")"]})]}),i.jsx("div",{className:"space-y-2",children:N.map(k=>i.jsx($D,{preset:k,onDelete:R=>m(R),onExpand:l,isExpanded:o===k.id},k.id))})]}),C.length>0&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(Vi,{className:"w-4 h-4 text-blue-400"}),i.jsx("h3",{className:"text-sm font-medium text-white",children:t("profiles.localProfiles.process")}),i.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",C.length,")"]})]}),i.jsx("div",{className:"space-y-2",children:C.map(k=>i.jsx($D,{preset:k,onDelete:R=>m(R),onExpand:l,isExpanded:o===k.id},k.id))})]}),T.length>0&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(Od,{className:"w-4 h-4 text-orange-400"}),i.jsx("h3",{className:"text-sm font-medium text-white",children:t("profiles.localProfiles.printer")}),i.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",T.length,")"]})]}),i.jsx("div",{className:"space-y-2",children:T.map(k=>i.jsx($D,{preset:k,onDelete:R=>m(R),onExpand:l,isExpanded:o===k.id},k.id))})]})]}),d!==null&&i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:i.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg p-6 max-w-sm mx-4",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(Li,{className:"w-5 h-5 text-red-400"}),i.jsx("h3",{className:"text-white font-medium",children:t("profiles.localProfiles.deleteConfirmTitle")})]}),i.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:t("profiles.localProfiles.deleteConfirm")}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(Ie,{variant:"secondary",size:"sm",onClick:()=>m(null),children:t("profiles.localProfiles.cancel")}),i.jsxs(Ie,{variant:"danger",size:"sm",onClick:()=>v.mutate(d),disabled:v.isPending,children:[v.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(en,{className:"w-4 h-4"}),t("profiles.localProfiles.delete")]})]})]})})]})}function C5(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),a=r?r[1].trim():null,s=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),o=s?(s[1]||s[2])+"mm":null,l=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=l?l[1]+"mm":null,u=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=u?u[1].toUpperCase():null;return{printer:a,nozzle:o,layerHeight:c,filamentType:d}}function uw(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function Ket({onSuccess:t,t:e}){const{showToast:n}=fn(),[r,a]=w.useState("email"),[s,o]=w.useState(""),[l,c]=w.useState(""),[u,d]=w.useState(""),[m,p]=w.useState(""),[f,y]=w.useState("global"),[v,b]=w.useState(null),[g,_]=w.useState(null),N=ft({mutationFn:()=>fe.cloudLogin(s,l,f),onSuccess:R=>{R.success?(n(e("profiles.login.toast.loggedIn")),t()):R.needs_verification?(b(R.verification_type||"email"),_(R.tfa_key||null),R.verification_type==="totp"?n(e("profiles.login.toast.enterTotp")):n(e("profiles.login.toast.codeSent")),a("code")):n(R.message,"error")},onError:R=>n(R.message,"error")}),T=ft({mutationFn:()=>fe.cloudVerify(s,u,g||void 0),onSuccess:R=>{R.success?(n(e("profiles.login.toast.loggedIn")),t()):n(R.message,"error")},onError:R=>n(R.message,"error")}),C=ft({mutationFn:()=>fe.cloudSetToken(m),onSuccess:()=>{n(e("profiles.login.toast.tokenSet")),t()},onError:R=>n(R.message,"error")}),P=R=>{R.preventDefault(),r==="email"?N.mutate():r==="code"?T.mutate():r==="token"&&C.mutate()},k=N.isPending||T.isPending||C.isPending;return i.jsx(Pt,{className:"max-w-md mx-auto",children:i.jsxs(Et,{children:[i.jsxs("div",{className:"text-center mb-6",children:[i.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:i.jsx(Ox,{className:"w-6 h-6 text-bambu-green"})}),i.jsx("h2",{className:"text-xl font-semibold text-white",children:e("profiles.login.title")}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:e("profiles.login.subtitle")})]}),i.jsxs("form",{onSubmit:P,className:"space-y-4",children:[r==="email"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.email")}),i.jsx("input",{type:"email",value:s,onChange:R=>o(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.password")}),i.jsx("input",{type:"password",value:l,onChange:R=>c(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.region")}),i.jsxs("select",{value:f,onChange:R=>y(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"global",children:e("profiles.login.regionGlobal")}),i.jsx("option",{value:"china",children:e("profiles.login.regionChina")})]})]})]}),r==="code"&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e(v==="totp"?"profiles.login.totpCode":"profiles.login.verificationCode")}),i.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:v==="totp"?e("profiles.login.enterTotpHint"):e("profiles.login.checkEmail",{email:s})}),i.jsx("input",{type:"text",value:u,onChange:R=>d(R.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),r==="token"&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.accessToken")}),i.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:e("profiles.login.accessTokenHint")}),i.jsx("textarea",{value:m,onChange:R=>p(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),i.jsxs("div",{className:"flex gap-2 max-[550px]:flex-wrap max-[550px]:items-center",children:[r==="code"&&i.jsx(Ie,{type:"button",variant:"secondary",onClick:()=>a("email"),className:"flex-1",children:e("profiles.login.back")}),i.jsxs(Ie,{type:"submit",disabled:k,className:"flex-1",children:[k?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(V8,{className:"w-4 h-4"}),e(r==="email"?"profiles.login.loginButton":r==="code"?"profiles.login.verifyButton":"profiles.login.setTokenButton")]})]}),r==="email"&&i.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:i.jsxs("button",{type:"button",onClick:()=>a("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[i.jsx(Al,{className:"w-4 h-4"}),e("profiles.login.useToken")]})}),r==="token"&&i.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:i.jsxs("button",{type:"button",onClick:()=>a("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[i.jsx(V8,{className:"w-4 h-4"}),e("profiles.login.useEmail")]})})]})]})})}function _b({label:t,value:e,options:n,onChange:r}){const[a,s]=w.useState(!1),o=n.find(l=>l.value===e);return i.jsxs("div",{className:"relative",children:[i.jsxs("button",{onClick:()=>s(!a),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[i.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),i.jsx("span",{children:o?.label||"All"}),i.jsx(On,{className:`w-4 h-4 text-bambu-gray transition-transform ${a?"rotate-180":""}`})]}),a&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),i.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto",children:n.map(l=>i.jsxs("button",{onClick:()=>{r(l.value),s(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===l.value?"text-bambu-green":"text-white"}`,children:[i.jsx("span",{children:l.label}),l.count!==void 0&&i.jsx("span",{className:"text-bambu-gray text-xs",children:l.count})]},l.value))})]})]})}function Yet(){const[t,e]=w.useState(!1);w.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?i.jsx("button",{onClick:n,className:"fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40","aria-label":"Scroll to top",children:i.jsx(Sf,{className:"w-5 h-5"})}):null}function qD({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:a,compareIndex:s,compareDisabled:o,t:l}){const c=C5(t.name),u=uw(t.setting_id);return i.jsxs("div",{className:"flex items-center gap-2 group",children:[i.jsx("button",{onClick:e,disabled:o,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${a?"bg-blue-500/20 border border-blue-500/50":o?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!o?"cursor-pointer":""}`,children:i.jsxs("div",{className:"flex items-center gap-2",children:[a&&s!==void 0&&i.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:s+1}),!a&&u&&i.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:l("profiles.presets.myPreset")}),i.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),c.filamentType&&t.type==="filament"&&i.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.filamentType}),c.layerHeight&&t.type==="process"&&i.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.layerHeight}),c.printer&&i.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.printer})]})}),i.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:l("profiles.presets.duplicate"),children:i.jsx(vo,{className:"w-4 h-4"})})]})}function vL(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(` `)){const a=t.replace(/\\n/g,` `).replace(/\\"/g,'"').replace(/\\t/g," ").split(` @@ -8712,7 +8712,7 @@ Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Is(t. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{ `+r.map(([s,o])=>n+" "+JSON.stringify(s)+": "+vL(o,e+1)).join(`, `)+` -`+n+"}"}return String(t)}function Xet({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:a,hasPermission:s,t:o}){const{showToast:l}=fn(),c=sn(),[u,d]=w.useState(!1),{data:m,isLoading:p}=tt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>fe.getCloudSettingDetail(t.setting_id)}),f=ft({mutationFn:()=>fe.deleteCloudSetting(t.setting_id),onSuccess:()=>{l(o("profiles.presets.toast.deleted")),c.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:b=>l(b.message,"error")}),y=uw(t.setting_id),v=C5(t.name,m?.setting?.inherits);return i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:i.jsx(Pt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:i.jsxs(Et,{className:"p-0 flex flex-col min-h-0 flex-1",children:[i.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),y&&i.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:o("profiles.presets.editable")})]}),i.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[i.jsx("span",{className:"capitalize",children:o(`profiles.presets.types.${t.type}`)}),v.printer&&i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"•"}),i.jsx("span",{children:v.printer})]})]})]}),i.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:i.jsx(Ht,{className:"w-5 h-5"})})]}),i.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:p?i.jsx("div",{className:"flex items-center justify-center py-16",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):m?i.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full",children:vL(m)}):i.jsx("div",{className:"text-center py-16 text-bambu-gray",children:o("profiles.presets.failedToLoadDetails")})}),u?i.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[i.jsx(Mn,{className:"w-5 h-5"}),i.jsx("span",{className:"font-medium",children:o("profiles.presets.deleteConfirm")})]}),i.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:o("profiles.presets.deleteWarning",{name:t.name})}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Ie,{variant:"secondary",onClick:()=>d(!1),disabled:f.isPending,className:"flex-1",children:o("common.cancel")}),i.jsxs(Ie,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(en,{className:"w-4 h-4"}),o("common.delete")]})]})]}):i.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Ie,{variant:"secondary",onClick:e,className:"flex-1",children:o("common.close")}),i.jsxs(Ie,{variant:"secondary",onClick:r,disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDuplicatePermission"),children:[i.jsx(vo,{className:"w-4 h-4"}),o("profiles.presets.duplicate")]}),y&&i.jsxs(i.Fragment,{children:[i.jsxs(Ie,{variant:"secondary",onClick:a,disabled:p||!m||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noEditPermission"),children:[i.jsx(Ki,{className:"w-4 h-4"}),o("common.edit")]}),i.jsx(Ie,{variant:"danger",onClick:()=>d(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDeletePermission"),children:i.jsx(en,{className:"w-4 h-4"})})]})]})})]})})})}function zoe(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Uoe(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function Qet({onClose:t,onApply:e,t:n}){const{showToast:r}=fn(),[a,s]=w.useState(zoe),[o,l]=w.useState("all"),[c,u]=w.useState(null),[d,m]=w.useState(""),[p,f]=w.useState(""),[y,v]=w.useState("{}"),[b,g]=w.useState(null),[_,N]=w.useState(null),T=o==="all"?a:a.filter(W=>W.type===o),C=W=>{s(W),Uoe(W)},P=W=>{const I=a.filter(J=>J.id!==W);C(I),N(null),r(n("profiles.templates.toast.deleted"))},k=W=>{u(W.id),m(W.name),f(W.description),v(JSON.stringify(W.settings,null,2)),g(null)},R=()=>{if(!(!c||!d.trim()))try{const W=JSON.parse(y),I=a.map(J=>J.id===c?{...J,name:d.trim(),description:p.trim(),settings:W}:J);C(I),u(null),r(n("profiles.templates.toast.updated"))}catch(W){g(W.message)}},A=()=>{u(null),m(""),f(""),v("{}"),g(null)},D=W=>{const I=a.map(J=>J.id===W?{...J,showInModal:!J.showInModal}:J);C(I)},B={filament:{label:n("profiles.presets.types.filament"),icon:QC,color:"text-amber-400"},print:{label:n("profiles.presets.types.process"),icon:Od,color:"text-blue-400"},printer:{label:n("profiles.presets.types.printer"),icon:_r,color:"text-purple-400"}},z=_?a.find(W=>W.id===_):null;return w.useEffect(()=>{const W=I=>{I.key==="Escape"&&(_?N(null):c?A():t())};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[_,c,t]),i.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[z&&i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:i.jsx(Pt,{className:"w-full max-w-md",children:i.jsxs(Et,{className:"p-6",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[i.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:i.jsx(Mn,{className:"w-6 h-6 text-red-400"})}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-lg font-semibold text-white",children:n("profiles.templates.deleteTitle")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:n("profiles.templates.deleteWarning")})]})]}),i.jsx("p",{className:"text-white mb-6",children:n("profiles.templates.deleteConfirm",{name:z.name})}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Ie,{variant:"secondary",onClick:()=>N(null),className:"flex-1",children:n("common.cancel")}),i.jsxs(Ie,{onClick:()=>P(_),className:"flex-1 bg-red-500 hover:bg-red-600",children:[i.jsx(en,{className:"w-4 h-4"}),n("common.delete")]})]})]})})}),i.jsx(Pt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:i.jsxs(Et,{className:"p-0 flex flex-col h-full",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(ox,{className:"w-5 h-5 text-amber-400"}),n("profiles.templates.title")]}),i.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:i.jsx(Ht,{className:"w-5 h-5"})})]}),i.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[i.jsx("span",{className:"text-sm text-bambu-gray",children:n("profiles.templates.typeFilter")}),["all","filament","print","printer"].map(W=>i.jsx("button",{onClick:()=>l(W),className:`px-3 py-1 text-sm rounded-lg transition-colors ${o===W?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:W==="all"?n("common.all"):B[W].label},W))]}),i.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:T.length===0?i.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[i.jsx(ox,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),i.jsx("p",{children:n("profiles.templates.noTemplates")}),i.jsx("p",{className:"text-sm mt-1",children:n("profiles.templates.createFirst")})]}):i.jsx("div",{className:"space-y-2",children:T.map(W=>{const I=B[W.type],J=I.icon;return c===W.id?i.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[i.jsx("input",{type:"text",value:d,onChange:ie=>m(ie.target.value),placeholder:n("profiles.templates.namePlaceholder"),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),i.jsx("input",{type:"text",value:p,onChange:ie=>f(ie.target.value),placeholder:n("profiles.templates.descriptionPlaceholder"),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:n("profiles.templates.settingsJson")}),i.jsx("textarea",{value:y,onChange:ie=>{v(ie.target.value),g(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${b?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),b&&i.jsx("p",{className:"text-xs text-red-400 mt-1",children:b})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs(Ie,{size:"sm",onClick:R,disabled:!d.trim(),children:[i.jsx(ss,{className:"w-4 h-4"}),"Save"]}),i.jsx(Ie,{size:"sm",variant:"secondary",onClick:A,children:"Cancel"})]})]},W.id):i.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[i.jsx(J,{className:`w-5 h-5 ${I.color} flex-shrink-0`}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-sm font-medium text-white",children:W.name}),i.jsx("p",{className:"text-xs text-bambu-gray truncate",children:W.description})]}),i.jsx("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:n("profiles.templates.fieldsCount",{count:Object.keys(W.settings).length})}),i.jsx("button",{onClick:()=>D(W.id),className:`p-1 transition-colors ${W.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:W.showInModal?n("profiles.templates.shownInModals"):n("profiles.templates.hiddenInModals"),children:W.showInModal?i.jsx(Ac,{className:"w-4 h-4"}):i.jsx(fw,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>e(W),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:n("profiles.templates.apply")}),i.jsx("button",{onClick:()=>k(W),className:"p-1 text-bambu-gray hover:text-white",title:n("common.edit"),children:i.jsx(Ki,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>N(W.id),className:"p-1 text-bambu-gray hover:text-red-400",title:n("common.delete"),children:i.jsx(en,{className:"w-4 h-4"})})]},W.id)})})})]})})]})}function Boe({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:a,t:s}){const[o,l]=w.useState("changes"),[c,u]=w.useState(""),d=w.useMemo(()=>{const y=new Set([...Object.keys(e),...Object.keys(n)]),v=[];for(const b of y){if(b==="inherits"||b==="version")continue;const g=e[b],_=n[b],N=b in e,T=b in n;let C;!N&&T?C="added":N&&!T?C="removed":JSON.stringify(g)!==JSON.stringify(_)?C="changed":C="same",v.push({key:b,left:g,right:_,status:C})}return v.sort((b,g)=>{const _={changed:0,added:1,removed:2,same:3};return _[b.status]!==_[g.status]?_[b.status]-_[g.status]:b.key.localeCompare(g.key)})},[e,n]),m=w.useMemo(()=>{let y=[...d];if(o==="changes"&&(y=y.filter(v=>v.status!=="same")),c){const v=c.toLowerCase();y=y.filter(b=>b.key.toLowerCase().includes(v)||String(b.left).toLowerCase().includes(v)||String(b.right).toLowerCase().includes(v))}return y},[d,o,c]),p=w.useMemo(()=>({added:d.filter(y=>y.status==="added").length,removed:d.filter(y=>y.status==="removed").length,changed:d.filter(y=>y.status==="changed").length,same:d.filter(y=>y.status==="same").length}),[d]),f=y=>{if(y===void 0)return"—";if(y===null)return"null";if(Array.isArray(y))return y.length===0?"[]":y.length===1?String(y[0]):y.join(", ");if(typeof y=="object")return JSON.stringify(y);const v=String(y);if(v.includes("\\n")||v.length>100){const b=v.split("\\n").length;if(b>1)return`[${b} lines of G-code/script]`;if(v.length>100)return v.substring(0,100)+"…"}return v};return w.useEffect(()=>{const y=v=>{v.key==="Escape"&&t()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[t]),i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:i.jsx(Pt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:i.jsxs(Et,{className:"p-0 flex flex-col min-h-0 flex-1",children:[i.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(Bb,{className:"w-5 h-5 text-blue-400"}),s("profiles.diff.title")]}),i.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:i.jsx(Ht,{className:"w-5 h-5"})})]}),i.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[i.jsxs("div",{className:"text-center",children:[i.jsx("span",{className:"text-sm text-bambu-gray",children:s("profiles.diff.left")}),i.jsx("p",{className:"text-white font-medium truncate",children:r})]}),i.jsxs("div",{className:"text-center",children:[i.jsx("span",{className:"text-sm text-bambu-gray",children:s("profiles.diff.right")}),i.jsx("p",{className:"text-white font-medium truncate",children:a})]})]}),i.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[i.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[i.jsx(ar,{className:"w-3.5 h-3.5"}),p.added," ",s("profiles.diff.added")]}),i.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[i.jsx(RN,{className:"w-3.5 h-3.5"}),p.removed," ",s("profiles.diff.removed")]}),i.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[i.jsx(g3,{className:"w-3.5 h-3.5"}),p.changed," ",s("profiles.diff.changed")]}),i.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[i.jsx($M,{className:"w-3.5 h-3.5"}),p.same," ",s("profiles.diff.same")]})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),i.jsx("input",{type:"text",value:c,onChange:y=>u(y.target.value),placeholder:s("profiles.diff.searchFields"),className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),p.same>0&&i.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[i.jsx("button",{onClick:()=>l("changes"),className:`px-3 py-1.5 text-sm transition-colors ${o==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s("profiles.diff.changes")}),i.jsx("button",{onClick:()=>l("all"),className:`px-3 py-1.5 text-sm transition-colors ${o==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s("common.all")})]})]})]}),i.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:m.length===0?i.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[i.jsx($M,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),i.jsx("p",{children:s(o==="changes"?"profiles.diff.noDifferences":"profiles.diff.noFieldsMatch")})]}):i.jsxs("table",{className:"w-full",children:[i.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:i.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[i.jsx("th",{className:"text-left p-3 w-1/3",children:s("profiles.diff.field")}),i.jsx("th",{className:"text-left p-3 w-1/3",children:r}),i.jsx("th",{className:"text-left p-3 w-1/3",children:a})]})}),i.jsx("tbody",{children:m.map(y=>{const v={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[y.status],b={added:i.jsx(ar,{className:"w-3.5 h-3.5 text-green-400"}),removed:i.jsx(RN,{className:"w-3.5 h-3.5 text-red-400"}),changed:i.jsx(g3,{className:"w-3.5 h-3.5 text-amber-400"}),same:i.jsx($M,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[y.status];return i.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${v}`,children:[i.jsx("td",{className:"p-3",children:i.jsxs("div",{className:"flex items-center gap-2",children:[b,i.jsx("span",{className:"text-sm text-white font-mono",children:y.key})]})}),i.jsx("td",{className:"p-3",children:i.jsx("span",{className:`text-sm font-mono break-all ${y.status==="removed"?"text-red-300":y.status==="changed"?"text-white":"text-bambu-gray"}`,children:f(y.left)})}),i.jsx("td",{className:"p-3",children:i.jsx("span",{className:`text-sm font-mono break-all ${y.status==="added"?"text-green-300":y.status==="changed"?"text-white":"text-bambu-gray"}`,children:f(y.right)})})]},y.key)})})]})})]})})})}function Zet({onClose:t,initialData:e,allPresets:n,t:r}){const{showToast:a}=fn(),s=sn(),o=!!e?.setting_id,[l,c]=w.useState("common"),[u,d]=w.useState(e?.type||"filament"),[m,p]=w.useState(e?.name?o?e.name:`${e.name} (Copy)`:""),[f,y]=w.useState(e?.base_id||""),[v,b]=w.useState(""),[g,_]=w.useState(e?.setting||{inherits:""}),[N,T]=w.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[C,P]=w.useState(null),[k,R]=w.useState(""),[A,D]=w.useState(!1),[B,z]=w.useState(""),[W,I]=w.useState(!1),[J,ie]=w.useState(zoe),[Q,ue]=w.useState(!1),[me,pe]=w.useState(""),[Y,se]=w.useState(""),[oe,be]=w.useState(!0),[Me,q]=w.useState(null),[Z,j]=w.useState(!1),E=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[u]||[],[n,u]),U=w.useMemo(()=>E.filter(Pe=>uw(Pe.setting_id)),[E]),{data:K}=tt({queryKey:["cloudFields",u],queryFn:()=>fe.getCloudFields(u==="print"?"process":u),staleTime:1e3*60*60}),{data:$}=tt({queryKey:["allPresetDetails",u,U.map(Pe=>Pe.setting_id).join(",")],queryFn:async()=>{const Pe={};for(let je=0;je{try{const Ee=await fe.getCloudSettingDetail(Ge.setting_id);return{id:Ge.setting_id,detail:Ee}}catch{return null}}))).forEach(Ge=>{Ge&&(Pe[Ge.id]=Ge.detail)})}return Pe},enabled:U.length>0,staleTime:1e3*60*10}),{data:ne,isLoading:O}=tt({queryKey:["cloudSettingDetail",f],queryFn:()=>fe.getCloudSettingDetail(f),enabled:!!f});w.useEffect(()=>{l!=="json"&&T(JSON.stringify(g,null,2))},[g,l]);const V=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[u]||[]).filter(Ue=>!uw(Ue.setting_id)).sort((Ue,je)=>Ue.name.localeCompare(je.name)),[n,u]);w.useEffect(()=>{if(!f)return;const Pe=V.find(Ue=>Ue.setting_id===f);Pe&&(b(Pe.name),o||(_({inherits:Pe.name}),T(JSON.stringify({inherits:Pe.name},null,2))))},[f,V,o]);const ee=w.useMemo(()=>{const Pe=K?.fields||[],Ue=new Set(Pe.map(Ge=>Ge.key)),je=new Set,Xe=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);$&&Object.values($).forEach(Ge=>{Ge?.setting&&Object.keys(Ge.setting).forEach(Ee=>{!Ue.has(Ee)&&!Xe.has(Ee)&&je.add(Ee)})}),Object.keys(g).forEach(Ge=>{!Ue.has(Ge)&&!Xe.has(Ge)&&je.add(Ge)});const ye=Array.from(je).sort().map(Ge=>({key:Ge,label:Ge.replace(/_/g," ").replace(/\b\w/g,Ee=>Ee.toUpperCase()),type:"text",category:"discovered",description:r("profiles.presets.discoveredFromPresets")}));return[...Pe,...ye]},[K,$,g,r]),G=ee.filter(Pe=>Pe.label.toLowerCase().includes(k.toLowerCase())||Pe.key.toLowerCase().includes(k.toLowerCase())),re=()=>{if(B.trim()){const Pe=B.trim().toLowerCase().replace(/\s+/g,"_");ce(Pe,""),z(""),I(!1),a(r("profiles.presets.toast.fieldAdded",{key:Pe}))}},ce=(Pe,Ue)=>{_(je=>{const Xe={...je};return Ue===""||Ue===void 0?delete Xe[Pe]:Xe[Pe]=Ue,Xe})},ge=Pe=>{_(Ue=>({...Ue,...Pe.settings})),q(Pe.name),a(r("profiles.templates.toast.applied"))},xe=()=>{if(!me.trim())return;const Pe={...g};if(delete Pe.inherits,Object.keys(Pe).length===0){a(r("profiles.presets.noOverridesToSave"),"error");return}const Ue={id:Date.now().toString(),name:me.trim(),description:Y.trim()||r("profiles.presets.customTemplate"),type:u,settings:Pe,showInModal:oe},je=[...J,Ue];ie(je),Uoe(je),ue(!1),pe(""),se(""),be(!0),a(r("profiles.templates.toast.created"))},ae=w.useMemo(()=>J.filter(Pe=>Pe.type===u&&Pe.showInModal),[u,J]),L=Pe=>{T(Pe);try{const Ue=JSON.parse(Pe);_(Ue),P(null)}catch(Ue){P(Ue.message)}},F=Pe=>{Pe.preventDefault(),D(!1);const Ue=Pe.dataTransfer.files[0];if(Ue&&Ue.name.endsWith(".json")){const je=new FileReader;je.onload=Xe=>{try{const ye=Xe.target?.result,Ge=JSON.parse(ye),Ee=Ge.setting||Ge;_(Ke=>({...Ke,...Ee})),T(JSON.stringify({...g,...Ee},null,2)),a(r("profiles.presets.fileImported"))}catch{a(r("profiles.presets.invalidJsonFile"),"error")}},je.readAsText(Ue)}},te=ft({mutationFn:()=>{const Pe={...g},Ue=u==="filament"?"filament_settings_id":u==="print"?"print_settings_id":"printer_settings_id";Pe[Ue]=`"${m}"`;const je={type:u,name:m,base_id:f,setting:Pe};return fe.createCloudSetting(je)},onSuccess:async()=>{a(r("profiles.presets.toast.created")),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:Pe=>a(Pe.message,"error")}),ve=ft({mutationFn:()=>{if(!e?.setting_id)throw new Error(r("profiles.presets.noSettingId"));return fe.updateCloudSetting(e.setting_id,{name:m,setting:g})},onSuccess:async()=>{a(r("profiles.presets.toast.updated")),s.removeQueries({queryKey:["cloudSettingDetail"]}),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:Pe=>a(Pe.message,"error")}),he=o?ve:te,de=ne?.setting?.inherits,ke=de?V.find(Pe=>Pe.name===de):void 0,{data:_e}=tt({queryKey:["cloudSettingDetail",ke?.setting_id],queryFn:()=>fe.getCloudSettingDetail(ke.setting_id),enabled:!!ke?.setting_id}),Le=w.useMemo(()=>{const Pe=_e?.setting||{},Ue=ne?.setting||{},je=f&&$?.[f]?.setting?$[f].setting:{};return{...Pe,...Ue,...je}},[f,ne,_e,$]),$e=Pe=>{if(Pe==null)return"";if(Array.isArray(Pe)){const Ue=[...new Set(Pe.map(je=>String(je)))];return Ue.length===1?Ue[0]:Pe.join(", ")}return String(Pe)},Re=Pe=>{const Ue=g[Pe.key],je=Le[Pe.key],Xe=$e(je),ye=O?r("common.loading"):Xe||"",Ge="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(Pe.type==="boolean"){const Ee=Ue==="1"||Ue===void 0&&je==="1";return i.jsx("button",{type:"button",onClick:()=>ce(Pe.key,Ue==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Ee?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:i.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Ee?"translate-x-3.5":"translate-x-0.5"}`})})}return Pe.type==="select"?i.jsxs("select",{value:Ue||"",onChange:Ee=>ce(Pe.key,Ee.target.value),className:Ge,children:[i.jsx("option",{value:"",children:ye}),Pe.options?.map(Ee=>i.jsx("option",{value:Ee.value,children:Ee.label},Ee.value))]}):i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:Pe.type==="number"?"number":"text",value:Ue!==void 0?String(Ue):"",onChange:Ee=>ce(Pe.key,Ee.target.value),step:Pe.step,min:Pe.min,max:Pe.max,placeholder:ye,className:Ge}),Pe.unit&&i.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:Pe.unit})]})},Ae=w.useMemo(()=>ne?.setting?ne.setting:{},[ne]);return i.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:Pe=>{Pe.preventDefault(),D(!0)},onDragLeave:()=>D(!1),onDrop:F,children:[Z&&f&&i.jsx(Boe,{onClose:()=>j(!1),leftPreset:Ae,rightPreset:g,leftLabel:r("profiles.presets.baseLabel",{name:v||f}),rightLabel:r("profiles.presets.currentLabel",{name:m||r("profiles.presets.newPreset")}),t:r}),i.jsx(Pt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col overflow-y-auto",children:i.jsxs(Et,{className:"p-0 flex flex-col h-full",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-semibold text-white",children:r(o?"profiles.presets.editPreset":e?"profiles.presets.duplicatePreset":"profiles.presets.createNewPreset")}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("profiles.presets.customizeSettings")})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[f&&i.jsxs("button",{onClick:()=>j(!0),className:"flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:r("profiles.presets.compareWithBase"),children:[i.jsx(Bb,{className:"w-4 h-4"}),r("profiles.presets.compare")]}),i.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:i.jsx(Ht,{className:"w-5 h-5"})})]})]}),A&&i.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:i.jsxs("div",{className:"text-center",children:[i.jsx(vi,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),i.jsx("p",{className:"text-bambu-green font-medium",children:r("profiles.presets.dropJsonToImport")})]})}),i.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[i.jsxs("div",{className:"grid grid-cols-3 gap-4 max-[640px]:grid-cols-1",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("common.type")}),i.jsxs("select",{value:u,onChange:Pe=>{d(Pe.target.value),y("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"filament",children:r("profiles.presets.types.filament")}),i.jsx("option",{value:"print",children:r("profiles.presets.types.process")}),i.jsx("option",{value:"printer",children:r("profiles.presets.types.printer")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.basePreset")}),i.jsxs("select",{value:f,onChange:Pe=>y(Pe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"",children:r("profiles.presets.selectBasePreset")}),V.map(Pe=>i.jsx("option",{value:Pe.setting_id,children:Pe.name},Pe.setting_id))]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.presetName")}),i.jsx("input",{type:"text",value:m,onChange:Pe=>p(Pe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:r("profiles.presets.myCustomPreset")})]})]}),v&&i.jsx("div",{className:"text-xs text-bambu-gray",children:i.jsxs("p",{className:"flex items-center gap-1",children:[i.jsx(Qr,{className:"w-3 h-3 text-bambu-green"}),r("profiles.presets.inheritsFrom")," ",i.jsx("span",{className:"text-white",children:v}),O&&i.jsx(pt,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),i.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary max-[640px]:flex-wrap max-[640px]:items-center",children:[i.jsxs("button",{onClick:()=>c("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[i.jsx(G8,{className:"w-4 h-4"}),r("profiles.presets.tabs.common")]}),i.jsxs("button",{onClick:()=>c("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[i.jsx(eT,{className:"w-4 h-4"}),r("profiles.presets.tabs.allFields")]}),i.jsxs("button",{onClick:()=>c("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[i.jsx(HX,{className:"w-4 h-4"}),"JSON",C&&i.jsx(Li,{className:"w-3 h-3 text-red-400"})]}),i.jsx("div",{className:"flex-1 max-[640px]:hidden"}),i.jsxs("button",{onClick:()=>{const Pe={name:m,type:u,base_id:f,setting:g},Ue=new Blob([JSON.stringify(Pe,null,2)],{type:"application/json"}),je=URL.createObjectURL(Ue),Xe=document.createElement("a");Xe.href=je,Xe.download=`${m||"preset"}.json`,document.body.appendChild(Xe),Xe.click(),document.body.removeChild(Xe),URL.revokeObjectURL(je),a(r("profiles.presets.toast.exported"))},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.exportToJson"),children:[i.jsx(bi,{className:"w-4 h-4"}),r("common.download")]}),i.jsxs("button",{onClick:()=>document.getElementById("file-import")?.click(),className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.importFromJson"),children:[i.jsx(vi,{className:"w-4 h-4"}),r("common.upload")]}),i.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:Pe=>{const Ue=Pe.target.files?.[0];if(Ue){const je=new FileReader;je.onload=Xe=>{try{const ye=JSON.parse(Xe.target?.result),Ge=ye.setting||ye;_(Ee=>({...Ee,...Ge})),a(r("profiles.presets.fileImported"))}catch{a(r("profiles.presets.invalidJson"),"error")}},je.readAsText(Ue)}}})]}),i.jsxs("div",{className:"flex-1 p-4",children:[l==="common"&&i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[i.jsx(ox,{className:"w-4 h-4 text-amber-400"}),r("profiles.templates.title")]}),Object.keys(g).filter(Pe=>Pe!=="inherits").length>0&&i.jsxs("button",{onClick:()=>ue(!Q),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[i.jsx(ss,{className:"w-3 h-3"}),r("profiles.presets.saveAsTemplate")]})]}),Q&&i.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[i.jsx("input",{type:"text",value:me,onChange:Pe=>pe(Pe.target.value),placeholder:r("profiles.templates.namePlaceholder"),className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),i.jsx("input",{type:"text",value:Y,onChange:Pe=>se(Pe.target.value),placeholder:r("profiles.templates.descriptionPlaceholder"),className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsxs(Ie,{size:"sm",onClick:xe,disabled:!me.trim(),children:[i.jsx(ss,{className:"w-3 h-3"}),r("common.save")]}),i.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>ue(!1),children:r("common.cancel")})]}),i.jsxs("button",{onClick:()=>be(!oe),className:`flex items-center gap-1.5 text-xs transition-colors ${oe?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[oe?i.jsx(Ac,{className:"w-3.5 h-3.5"}):i.jsx(fw,{className:"w-3.5 h-3.5"}),r(oe?"profiles.templates.shownInModals":"profiles.templates.hiddenInModals")]})]})]}),Me&&i.jsxs("div",{className:"mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2",children:[i.jsx(Qr,{className:"w-4 h-4 text-bambu-green"}),i.jsxs("span",{className:"text-sm text-bambu-green",children:[r("profiles.presets.templateApplied")," ",i.jsx("span",{className:"font-medium",children:Me})]}),i.jsx("button",{onClick:()=>q(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:i.jsx(Ht,{className:"w-4 h-4"})})]}),i.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[ae.map(Pe=>i.jsxs("button",{onClick:()=>ge(Pe),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[i.jsx("p",{className:"text-sm font-medium text-white",children:Pe.name}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:Pe.description})]},Pe.id)),ae.length===0&&i.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:r("profiles.presets.noTemplatesSelected")})]}),i.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:r("profiles.presets.manageTemplatesHint")})]}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.commonSettings")}),i.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:ee.slice(0,10).map(Pe=>i.jsxs("div",{className:"flex items-center justify-between gap-4 max-[640px]:flex-col max-[640px]:items-start",children:[i.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:Pe.label}),i.jsx("div",{className:"w-48 max-[640px]:w-full",children:Re(Pe)})]},Pe.key))})]}),Object.keys(g).length>1&&i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.currentOverrides")}),i.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(g).filter(([Pe])=>Pe!=="inherits").map(([Pe,Ue])=>i.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[Pe,": ",String(Ue).slice(0,20),i.jsx("button",{onClick:()=>ce(Pe,void 0),className:"hover:text-white",children:i.jsx(Ht,{className:"w-3 h-3"})})]},Pe))})]})]}),l==="fields"&&i.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[i.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[i.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.availableFields")}),i.jsx("span",{className:"text-xs text-bambu-gray",children:$?r("profiles.templates.fieldsCount",{count:ee.length}):r("common.loading")})]}),i.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),i.jsx("input",{type:"text",value:k,onChange:Pe=>R(Pe.target.value),placeholder:r("profiles.presets.searchFieldsPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[G.filter(Pe=>!(Pe.key in g)).map(Pe=>{const Ue=Le[Pe.key],je=$e(Ue);return i.jsxs("div",{onClick:()=>{_(Xe=>({...Xe,[Pe.key]:je||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"text-sm text-white truncate",children:Pe.label}),i.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:Pe.key})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[je&&i.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:je,children:[je.slice(0,20),je.length>20?"...":""]}),i.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:i.jsx(ar,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},Pe.key)}),G.filter(Pe=>!(Pe.key in g)).length===0&&i.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:r(k?"profiles.presets.noMatchingFields":"profiles.presets.allFieldsAdded")})]}),i.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:W?i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",value:B,onChange:Pe=>z(Pe.target.value),onKeyDown:Pe=>Pe.key==="Enter"&&re(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),i.jsx(Ie,{size:"sm",onClick:re,disabled:!B.trim(),children:i.jsx(ar,{className:"w-4 h-4"})}),i.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>{I(!1),z("")},children:i.jsx(Ht,{className:"w-4 h-4"})})]}):i.jsxs("button",{onClick:()=>I(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[i.jsx(ar,{className:"w-4 h-4"}),r("profiles.presets.addCustomField")]})})]}),i.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[i.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.yourOverrides")}),i.jsx("span",{className:"text-xs text-bambu-gray",children:r("profiles.templates.fieldsCount",{count:Object.keys(g).filter(Pe=>Pe!=="inherits").length})})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(g).filter(([Pe])=>Pe!=="inherits").map(([Pe,Ue])=>{const je=ee.find(Xe=>Xe.key===Pe);return i.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-medium text-white",children:je?.label||Pe}),i.jsx("p",{className:"text-xs text-bambu-gray-dark",children:Pe})]}),i.jsx("button",{onClick:()=>ce(Pe,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:i.jsx(Ht,{className:"w-4 h-4"})})]}),je?Re(je):i.jsx("input",{type:"text",value:String(Ue),onChange:Xe=>ce(Pe,Xe.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},Pe)}),Object.keys(g).filter(Pe=>Pe!=="inherits").length===0&&i.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[i.jsx(G8,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),i.jsx("p",{className:"text-sm",children:r("profiles.presets.noOverridesYet")}),i.jsx("p",{className:"text-xs mt-1",children:r("profiles.presets.clickFieldsToAdd")})]})]}),Object.keys(g).filter(Pe=>Pe!=="inherits").length>0&&i.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:i.jsxs("button",{onClick:()=>{ue(!0),c("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[i.jsx(ss,{className:"w-4 h-4"}),r("profiles.presets.saveAsTemplate")]})})]})]}),l==="json"&&i.jsxs("div",{className:"space-y-2",children:[C&&i.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[i.jsx(Li,{className:"w-4 h-4"}),C]}),i.jsx("textarea",{value:N,onChange:Pe=>L(Pe.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${C?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),i.jsx("p",{className:"text-xs text-bambu-gray",children:r("profiles.presets.jsonTip")})]})]}),i.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[i.jsx(Ie,{variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),i.jsxs(Ie,{onClick:()=>he.mutate(),disabled:he.isPending||!m.trim()||!o&&!f||!!C,className:"flex-1",children:[he.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):o?i.jsx(ss,{className:"w-4 h-4"}):i.jsx(ar,{className:"w-4 h-4"}),r(o?"common.save":e?"common.duplicate":"common.create")]})]})]})})]})}function Jet({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:a,hasPermission:s,t:o}){const[l,c]=w.useState(""),[u,d]=w.useState("all"),[m,p]=w.useState("all"),[f,y]=w.useState("all"),[v,b]=w.useState("all"),[g,_]=w.useState("all"),[N,T]=w.useState("all"),[C,P]=w.useState(null),[k,R]=w.useState(!1),[A,D]=w.useState(!1),[B,z]=w.useState(null),[W,I]=w.useState(null),[J,ie]=w.useState(null),[Q,ue]=w.useState(!1),[me,pe]=w.useState([null,null]),[Y,se]=w.useState(!1),[oe,be]=w.useState(null),Me=sn(),q=w.useMemo(()=>[...t.filament.map(re=>({...re,type:"filament"})),...t.printer.map(re=>({...re,type:"printer"})),...t.process.map(re=>({...re,type:"process"}))].map(re=>({...re,meta:C5(re.name)})),[t]),Z=w.useMemo(()=>{const G=new Set,re=new Set,ce=new Set;return q.forEach(ge=>{ge.meta.nozzle&&G.add(ge.meta.nozzle),ge.meta.filamentType&&re.add(ge.meta.filamentType),ge.meta.layerHeight&&ce.add(ge.meta.layerHeight)}),{printers:a.map(ge=>({id:ge.id.toString(),name:ge.name})),nozzles:Array.from(G).sort((ge,xe)=>parseFloat(ge)-parseFloat(xe)),filaments:Array.from(re).sort(),layerHeights:Array.from(ce).sort((ge,xe)=>parseFloat(ge)-parseFloat(xe))}},[q,a]),j=w.useMemo(()=>f==="all"?null:a.find(re=>re.id.toString()===f)?.model||null,[f,a]),E=w.useMemo(()=>q.filter(G=>u==="all"||G.type===u).filter(G=>{if(m==="all")return!0;const re=uw(G.setting_id);return m==="custom"?re:!re}).filter(G=>{if(f==="all"||!j)return!0;const re=G.meta.printer?.toLowerCase()||"",ce=j.toLowerCase();return re.includes(ce)||ce.includes(re)}).filter(G=>v==="all"||G.meta.nozzle===v).filter(G=>g==="all"||G.meta.filamentType===g).filter(G=>N==="all"||G.meta.layerHeight===N).filter(G=>l===""||G.name.toLowerCase().includes(l.toLowerCase())).sort((G,re)=>G.name.localeCompare(re.name)),[q,u,m,f,j,v,g,N,l]),U=G=>{if(Q){const re=me[0]?.setting_id===G.setting_id,ce=me[1]?.setting_id===G.setting_id;if(re)pe([me[1],null]);else if(ce)pe([me[0],null]);else if(!me[0])pe([G,null]);else if(me[1]){if(me[0].type!==G.type)return;pe([me[0],G])}else{if(me[0].type!==G.type)return;pe([me[0],G])}}else P(G)},K=G=>{if(me[0]?.setting_id===G.setting_id)return 0;if(me[1]?.setting_id===G.setting_id)return 1},$=async G=>{try{const re=await fe.getCloudSettingDetail(G.setting_id),ce=G.type==="process"?"print":G.type;z({type:ce,name:G.name,base_id:re.base_id||"GFSA00",setting:re.setting||{}}),P(null)}catch(re){console.error("Failed to fetch preset details for duplication:",re)}},ne=async G=>{try{Me.removeQueries({queryKey:["cloudSettingDetail",G.setting_id]});const re=await fe.getCloudSettingDetail(G.setting_id),ce=G.type==="process"?"print":G.type;I({type:ce,name:G.name,base_id:re.base_id||"GFSA00",setting:re.setting||{},setting_id:G.setting_id}),P(null)}catch(re){console.error("Failed to fetch preset details for editing:",re)}},O=()=>{d("all"),p("all"),y("all"),b("all"),_("all"),T("all"),c("")},V=u!=="all"||m!=="all"||f!=="all"||v!=="all"||g!=="all"||N!=="all"||l!=="",ee=t.filament.length+t.printer.length+t.process.length;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"space-y-4 mb-6",children:[i.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),i.jsx("input",{type:"text",value:l,onChange:G=>c(G.target.value),placeholder:o("profiles.cloudView.searchPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"flex gap-2 max-[550px]:flex-wrap max-[550px]:items-center",children:[i.jsxs(Ie,{variant:Q?"primary":"secondary",onClick:()=>{Q?(ue(!1),pe([null,null])):ue(!0)},children:[i.jsx(Bb,{className:"w-4 h-4"}),o(Q?"common.cancel":"profiles.presets.compare")]}),i.jsxs(Ie,{variant:"secondary",onClick:()=>D(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noTemplatesPermission"),children:[i.jsx(ox,{className:"w-4 h-4"}),o("profiles.cloudView.templates")]}),i.jsxs(Ie,{variant:"secondary",onClick:n,disabled:r||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noRefreshPermission"),children:[i.jsx(Sr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),o("profiles.cloudView.refresh")]}),i.jsxs(Ie,{onClick:()=>R(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noCreatePermission"),children:[i.jsx(ar,{className:"w-4 h-4"}),o("profiles.cloudView.newPreset")]})]})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsx(JC,{className:"w-4 h-4 text-bambu-gray"}),i.jsx(_b,{label:o("profiles.cloudView.filters.type"),value:u,options:[{value:"all",label:o("profiles.cloudView.filters.all"),count:ee},{value:"filament",label:o("profiles.cloudView.filters.filament"),count:t.filament.length},{value:"printer",label:o("profiles.cloudView.filters.printer"),count:t.printer.length},{value:"process",label:o("profiles.cloudView.filters.process"),count:t.process.length}],onChange:G=>d(G)}),i.jsx(_b,{label:o("profiles.cloudView.filters.owner"),value:m,options:[{value:"all",label:o("profiles.cloudView.filters.all")},{value:"custom",label:o("profiles.cloudView.filters.myPresets")},{value:"builtin",label:o("profiles.cloudView.filters.builtIn")}],onChange:G=>p(G)}),Z.printers.length>0&&i.jsx(_b,{label:o("profiles.cloudView.filters.printer"),value:f,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...Z.printers.map(G=>({value:G.id,label:G.name}))],onChange:y}),Z.nozzles.length>0&&i.jsx(_b,{label:o("profiles.cloudView.filters.nozzle"),value:v,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...Z.nozzles.map(G=>({value:G,label:G}))],onChange:b}),Z.filaments.length>0&&(u==="all"||u==="filament")&&i.jsx(_b,{label:o("profiles.cloudView.filters.filament"),value:g,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...Z.filaments.map(G=>({value:G,label:G}))],onChange:_}),Z.layerHeights.length>0&&(u==="all"||u==="process")&&i.jsx(_b,{label:o("profiles.cloudView.filters.layer"),value:N,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...Z.layerHeights.map(G=>({value:G,label:G}))],onChange:T}),V&&i.jsx("button",{onClick:O,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:o("profiles.cloudView.clearFilters")})]})]}),Q&&i.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(Bb,{className:"w-5 h-5 text-blue-400"}),i.jsx("span",{className:"text-white font-medium",children:o("profiles.cloudView.compareMode")}),i.jsx("span",{className:"text-bambu-gray",children:me[0]?o("profiles.cloudView.selectAnotherPreset",{type:me[0].type}):o("profiles.cloudView.clickTwoPresets")})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${me[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:me[0]?me[0].name:o("profiles.cloudView.selectFirst")}),i.jsx(g3,{className:"w-4 h-4 text-bambu-gray"}),i.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${me[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:me[1]?me[1].name:o("profiles.cloudView.selectSecond")})]}),me[0]&&me[1]&&i.jsxs(Ie,{size:"sm",onClick:async()=>{try{const[G,re]=await Promise.all([fe.getCloudSettingDetail(me[0].setting_id),fe.getCloudSettingDetail(me[1].setting_id)]);be([G.setting||{},re.setting||{}]),se(!0)}catch{}},children:[i.jsx(Bb,{className:"w-4 h-4"}),o("profiles.cloudView.compareNow")]})]})]})}),i.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx(Jn,{className:"w-3 h-3"}),o("profiles.cloudView.lastSynced")," ",w0(e.toISOString(),"system",o)]}),i.jsx("span",{children:o("profiles.cloudView.showingCount",{showing:E.length,total:ee})}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),i.jsxs("span",{children:["= ",o("profiles.presets.myPreset")]})]})]}),E.length===0?i.jsxs("div",{className:"text-center py-16",children:[i.jsx(Vi,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),i.jsx("p",{className:"text-bambu-gray",children:o("profiles.cloudView.noPresetsFound")}),V&&i.jsx("button",{onClick:O,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:o("profiles.cloudView.clearFilters")})]}):i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[i.jsx(QC,{className:"w-4 h-4 text-amber-400"}),i.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.filament")}),i.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",E.filter(G=>G.type==="filament").length,")"]})]}),i.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[E.filter(G=>G.type==="filament").map(G=>i.jsx(qD,{setting:G,onClick:()=>U(G),onDuplicate:()=>$(G),compareMode:Q,isCompareSelected:K(G)!==void 0,compareIndex:K(G),compareDisabled:Q&&!!me[0]&&me[0].type!==G.type,t:o},G.setting_id)),E.filter(G=>G.type==="filament").length===0&&i.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noFilamentPresets")})]})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[i.jsx(Od,{className:"w-4 h-4 text-blue-400"}),i.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.process")}),i.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",E.filter(G=>G.type==="process").length,")"]})]}),i.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[E.filter(G=>G.type==="process").map(G=>i.jsx(qD,{setting:G,onClick:()=>U(G),onDuplicate:()=>$(G),compareMode:Q,isCompareSelected:K(G)!==void 0,compareIndex:K(G),compareDisabled:Q&&!!me[0]&&me[0].type!==G.type,t:o},G.setting_id)),E.filter(G=>G.type==="process").length===0&&i.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noProcessPresets")})]})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[i.jsx(_r,{className:"w-4 h-4 text-purple-400"}),i.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.printer")}),i.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",E.filter(G=>G.type==="printer").length,")"]})]}),i.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[E.filter(G=>G.type==="printer").map(G=>i.jsx(qD,{setting:G,onClick:()=>U(G),onDuplicate:()=>$(G),compareMode:Q,isCompareSelected:K(G)!==void 0,compareIndex:K(G),compareDisabled:Q&&!!me[0]&&me[0].type!==G.type,t:o},G.setting_id)),E.filter(G=>G.type==="printer").length===0&&i.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noPrinterPresets")})]})]})]}),C&&i.jsx(Xet,{setting:C,onClose:()=>P(null),onDeleted:()=>P(null),onDuplicate:()=>$(C),onEdit:()=>ne(C),hasPermission:s,t:o}),(k||B||W||J)&&i.jsx(Zet,{onClose:()=>{R(!1),z(null),I(null),ie(null)},initialData:W||B||(J?{type:J.type,name:"",base_id:"",setting:J.setting}:void 0),allPresets:t,t:o}),A&&i.jsx(Qet,{onClose:()=>D(!1),onApply:G=>{ie({type:G.type,setting:G.settings}),D(!1)},t:o}),Y&&oe&&me[0]&&me[1]&&i.jsx(Boe,{onClose:()=>{se(!1),be(null)},leftPreset:oe[0],rightPreset:oe[1],leftLabel:me[0].name,rightLabel:me[1].name,t:o})]})}function ett(){const{t}=Rt(),e=sn(),{showToast:n}=fn(),{hasPermission:r}=Nr(),[a,s]=w.useState("cloud"),[o,l]=w.useState(),{data:c,isLoading:u}=tt({queryKey:["cloudStatus"],queryFn:fe.getCloudStatus}),{data:d=[]}=tt({queryKey:["printers"],queryFn:fe.getPrinters}),{data:m,isLoading:p,refetch:f,dataUpdatedAt:y}=tt({queryKey:["cloudSettings"],queryFn:()=>fe.getCloudSettings(),enabled:!!c?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{y&&l(new Date(y))},[y]);const v=ft({mutationFn:fe.cloudLogout,onSuccess:()=>{e.invalidateQueries({queryKey:["cloudStatus"]}),e.removeQueries({queryKey:["cloudSettings"]}),n(t("profiles.toast.loggedOut"))}}),b=()=>{e.invalidateQueries({queryKey:["cloudStatus"]})};return u?i.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i.jsxs("div",{className:"p-6 lg:p-8",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx("h1",{className:"text-2xl font-bold text-white",children:t("profiles.title")}),i.jsx("p",{className:"text-bambu-gray",children:t("profiles.subtitle")})]}),i.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[i.jsxs("button",{onClick:()=>s("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[i.jsx(Ox,{className:"w-4 h-4"}),t("profiles.tabs.cloud")]}),i.jsxs("button",{onClick:()=>s("local"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="local"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[i.jsx(Ix,{className:"w-4 h-4"}),t("profiles.tabs.local")]}),i.jsxs("button",{onClick:()=>s("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[i.jsx(gw,{className:"w-4 h-4"}),t("profiles.tabs.kprofiles")]})]}),a==="cloud"&&i.jsxs(i.Fragment,{children:[c?.is_authenticated&&i.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),i.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("profiles.connectedAs")," ",i.jsx("span",{className:"text-white",children:c.email})]})]}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>v.mutate(),disabled:v.isPending||!r("cloud:auth"),title:r("cloud:auth")?void 0:t("profiles.noLogoutPermission"),children:[i.jsx(v3,{className:"w-4 h-4"}),t("profiles.logout")]})]}),c?.is_authenticated?p?i.jsx("div",{className:"flex items-center justify-center py-16",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):m?i.jsx(Jet,{settings:m,lastSyncTime:o,onRefresh:()=>f(),isRefreshing:p,printers:d,hasPermission:r,t}):i.jsxs("div",{className:"text-center py-16",children:[i.jsx("p",{className:"text-bambu-gray mb-4",children:t("profiles.failedToLoad")}),i.jsx(Ie,{onClick:()=>f(),children:t("profiles.retry")})]}):i.jsx(Ket,{onSuccess:b,t})]}),a==="local"&&i.jsx(Wet,{}),a==="kprofiles"&&i.jsx($et,{}),i.jsx(Yet,{})]})}const Bv={Droplet:QC,Flame:Ip,Ruler:Tge,Sparkles:ox,Square:ql,Cable:BL,Wrench:kf,Calendar:Yr,Timer:yd,Cog:gpe,Fan:$X,Zap:Mc,Wind:nQ,Thermometer:sT,Layers:Vi,Box:na,Target:JX,RefreshCw:Sr,Settings:aT,Filter:JC,CircleDot:Qhe};function m0(t){return t&&Bv[t]||kf}function Nb(t,e,n){if(e==="days"){if(t<1)return n?n("common.today"):"Today";if(t===1)return n?n("maintenance.day"):"1 day";if(t<7){const a=Math.round(t);return n?n("maintenance.days",{count:a}):`${a} days`}if(t<180){const a=Math.round(t/7);return a===1?n?n("maintenance.week"):"1 week":n?n("maintenance.weeks",{count:a}):`${a} weeks`}const r=Math.round(t/30);return r===1?n?n("maintenance.month"):"1 month":n?n("maintenance.months",{count:r}):`${r} months`}else{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const r=t/24;if(r<7)return`${r<2?r.toFixed(1):Math.round(r)}d`;const a=r/7;return a<12?`${a<2?a.toFixed(1):Math.round(a)}w`:`${Math.round(a/4)}mo`}}function VD(t,e,n){return e==="days"?t===1?n?n("maintenance.day"):"1 day":t===7?n?n("maintenance.week"):"1 week":t===14?n?n("maintenance.weeks",{count:2}):"2 weeks":t===30?n?n("maintenance.month"):"1 month":t===60?n?n("maintenance.months",{count:2}):"2 months":t===90?n?n("maintenance.months",{count:3}):"3 months":t===180?n?n("maintenance.months",{count:6}):"6 months":t===365?n?n("maintenance.year"):"1 year":n?n("maintenance.days",{count:t}):`${t} days`:`${t}h`}function ttt(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),a=n.includes("P1"),s=n.includes("A1MINI"),o=n.includes("A1")&&!s,l=n.includes("H2D"),c=n.includes("H2C"),u=n.includes("H2S"),d=l||c||u,m=n.includes("P2S");switch(t){case"Lubricate Steel Rods":return m?"https://wiki.bambulab.com/en/p2s/maintenance/lubricate-x-y-z-axis":null;case"Clean Steel Rods":return m?"https://wiki.bambulab.com/en/p2s/maintenance/lubricate-x-y-z-axis":null;case"Lubricate Linear Rails":return s?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;case"Clean Nozzle/Hotend":return r||a?"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog":s||o?"https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog":d?"https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning":m?"https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend":"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog";case"Check Belt Tension":return r?"https://wiki.bambulab.com/en/x1/maintenance/belt-tension":a?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":s?"https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension":o?"https://wiki.bambulab.com/en/a1/maintenance/belt_tension":l?"https://wiki.bambulab.com/en/h2/maintenance/belt-tension":c?"https://wiki.bambulab.com/en/h2c/maintenance/belt-tension":u?"https://wiki.bambulab.com/en/h2s/maintenance/belt-tension":m?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/x1/maintenance/belt-tension";case"Clean Carbon Rods":return r||a?"https://wiki.bambulab.com/en/general/carbon-rods-clearance":null;case"Clean Linear Rails":return s?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;case"Clean Build Plate":return"https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide";case"Check PTFE Tube":return r||a?"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube":s||o?"https://wiki.bambulab.com/en/a1-mini/maintenance/ptfe-tube":l?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":u?"https://wiki.bambulab.com/en/h2s/maintenance/replace-ptfe-tube-on-h2s-printer":c?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube";case"Replace HEPA Filter":case"HEPA Filter":case"Replace Carbon Filter":case"Carbon Filter":return d?"https://wiki.bambulab.com/en/h2/maintenance/replace-smoke-purifier-air-filte":"https://wiki.bambulab.com/en/x1/maintenance/replace-carbon-filter";case"Lubricate Left Nozzle Rail":case"Left Nozzle Rail":return d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;default:return null}}function ntt({item:t,onPerform:e,onToggle:n,hasPermission:r,t:a}){const s=m0(t.maintenance_type_icon),o=t.interval_type||"hours",c=(()=>{if(o==="days"){const f=t.days_since_maintenance??0;return Math.max(0,Math.min(100,f/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),u=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",d=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",m=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",p=()=>{if(!t.enabled)return a("common.disabled");if(o==="days"){const f=t.days_until_due??0;return t.is_due?a("maintenance.overdueBy",{duration:Nb(Math.abs(f),"days",a)}):t.is_warning?a("maintenance.dueIn",{duration:Nb(f,"days",a)}):a("maintenance.timeLeft",{duration:Nb(f,"days",a)})}else return t.is_due?a("maintenance.overdueBy",{duration:Nb(Math.abs(t.hours_until_due),"hours",a)}):t.is_warning?a("maintenance.dueIn",{duration:Nb(t.hours_until_due,"hours",a)}):a("maintenance.timeLeft",{duration:Nb(t.hours_until_due,"hours",a)})};return i.jsx("div",{className:`rounded-xl border p-4 transition-all ${m()}`,children:i.jsxs("div",{className:"flex items-start gap-3 max-[550px]:flex-wrap",children:[i.jsxs("div",{className:`relative p-2.5 rounded-lg shrink-0 ${t.is_due?"bg-red-500/20":t.is_warning?"bg-amber-500/20":t.enabled?"bg-bambu-dark":"bg-bambu-dark/50"}`,children:[i.jsx(s,{className:`w-5 h-5 ${u()}`}),t.enabled&&(t.is_due||t.is_warning)&&i.jsx("span",{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${t.is_due?"bg-red-500":"bg-amber-500"} animate-pulse`})]}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),o==="days"&&i.jsx("span",{title:a("maintenance.timeBasedInterval"),children:i.jsx(Yr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const f=t.maintenance_type_wiki_url||ttt(t.maintenance_type_name,t.printer_model);return f?i.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:a("maintenance.viewDocumentation"),onClick:y=>y.stopPropagation(),children:i.jsx(ti,{className:"w-3.5 h-3.5"})}):null})()]}),i.jsx("div",{className:"mt-2 mb-1.5",children:i.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:i.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${d()}`,style:{width:`${c}%`}})})}),i.jsxs("div",{className:`text-xs flex items-center gap-1 ${u()}`,children:[t.is_due&&i.jsx(Mn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&i.jsx(Jn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&i.jsx(Qr,{className:"w-3 h-3"}),p()]})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0 max-[550px]:w-full max-[550px]:justify-end max-[550px]:mt-1",children:[i.jsx("span",{title:r("maintenance:update")?void 0:a("maintenance.noPermissionUpdate"),children:i.jsx(Bn,{checked:t.enabled,onChange:f=>n(t.id,f),disabled:!r("maintenance:update")})}),i.jsxs(Ie,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled||!r("maintenance:update"),title:r("maintenance:update")?void 0:a("maintenance.noPermissionPerform"),className:"!px-3",children:[i.jsx(So,{className:"w-3.5 h-3.5"}),a("common.reset")]})]})]})})}function rtt({overview:t,onPerform:e,onToggle:n,onSetHours:r,hasPermission:a,t:s}){const[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,m]=w.useState(t.total_print_hours.toFixed(1)),p=[...t.maintenance_items].sort((v,b)=>v.is_due&&!b.is_due?-1:!v.is_due&&b.is_due?1:v.is_warning&&!b.is_warning?-1:!v.is_warning&&b.is_warning?1:v.maintenance_type_id-b.maintenance_type_id),f=p.find(v=>v.enabled&&(v.is_due||v.is_warning)),y=()=>{const v=parseFloat(d);!isNaN(v)&&v>=0&&(r(t.printer_id,v),u(!1))};return i.jsxs(Pt,{className:"overflow-hidden",children:[i.jsxs("div",{className:"p-5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),i.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&i.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[i.jsx(Mn,{className:"w-3 h-3"}),s("maintenance.overdueCount",{count:t.due_count})]}),t.warning_count>0&&i.jsxs("span",{className:"px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[i.jsx(Jn,{className:"w-3 h-3"}),s("maintenance.dueSoonCount",{count:t.warning_count})]}),t.due_count===0&&t.warning_count===0&&i.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5",children:[i.jsx(Qr,{className:"w-3 h-3"}),s("maintenance.allGood")]})]})]}),i.jsxs("button",{onClick:()=>l(!o),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[o?i.jsx($l,{className:"w-4 h-4"}):i.jsx(On,{className:"w-4 h-4"}),s(o?"common.collapse":"common.expand")]})]}),i.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:i.jsx(yd,{className:"w-4 h-4 text-bambu-gray"})}),c?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"number",value:d,onChange:v=>m(v.target.value),onKeyDown:v=>{v.key==="Enter"&&y(),v.key==="Escape"&&u(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),i.jsx("span",{className:"text-xs text-bambu-gray",children:s("common.hours")}),i.jsx(Ie,{size:"sm",onClick:y,children:s("common.save")}),i.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>u(!1),children:s("common.cancel")})]}):i.jsxs("button",{onClick:()=>{a("maintenance:update")&&(m(Math.round(t.total_print_hours).toString()),u(!0))},className:`group ${a("maintenance:update")?"":"cursor-not-allowed opacity-60"}`,title:a("maintenance:update")?void 0:s("maintenance.noPermissionEditHours"),children:[i.jsxs("div",{className:`text-sm font-medium text-white ${a("maintenance:update")?"group-hover:text-bambu-green":""} transition-colors flex items-center gap-1`,children:[Math.round(t.total_print_hours)," ",s("common.hours"),i.jsx(_f,{className:`w-3 h-3 text-bambu-gray ${a("maintenance:update")?"group-hover:text-bambu-green":""}`})]}),i.jsx("div",{className:"text-xs text-bambu-gray",children:s("maintenance.totalPrintTime")})]})]}),i.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const v=m0(f.maintenance_type_icon);return i.jsx(v,{className:`w-4 h-4 ${f.is_due?"text-red-400":"text-amber-400"}`})})()}),i.jsxs("div",{children:[i.jsx("div",{className:`text-sm font-medium ${f.is_due?"text-red-400":"text-amber-400"}`,children:f.maintenance_type_name}),i.jsx("div",{className:`text-xs ${f.is_due?"text-red-400/70":"text-amber-400/70"}`,children:f.is_due?s("common.overdue"):s("maintenance.dueSoon")})]})]})]})]}),o&&i.jsx(Et,{className:"pt-0 border-t border-bambu-dark-tertiary",children:i.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:p.map(v=>i.jsx(ntt,{item:v,onPerform:e,onToggle:n,hasPermission:a,t:s},v.id))})})]})}function itt({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:a,onDeleteType:s,onRestoreDefaults:o,isRestoringDefaults:l,onAssignType:c,onRemoveItem:u,hasPermission:d,t:m}){const[p,f]=w.useState(null),[y,v]=w.useState(""),[b,g]=w.useState("hours"),[_,N]=w.useState(!1),[T,C]=w.useState(""),[P,k]=w.useState("100"),[R,A]=w.useState("hours"),[D,B]=w.useState("Wrench"),[z,W]=w.useState(""),[I,J]=w.useState(new Set),[ie,Q]=w.useState(null),[ue,me]=w.useState(null),pe=w.useMemo(()=>t?t.map(L=>({id:L.printer_id,name:L.printer_name})):[],[t]),Y=L=>t?t.filter(F=>F.maintenance_items.some(te=>te.maintenance_type_id===L)).map(F=>({printerId:F.printer_id,printerName:F.printer_name,itemId:F.maintenance_items.find(te=>te.maintenance_type_id===L)?.id})):[],se=L=>{if(!t)return[];const F=new Set(Y(L).map(te=>te.printerId));return pe.filter(te=>!F.has(te.id))},[oe,be]=w.useState(null),[Me,q]=w.useState(""),[Z,j]=w.useState(""),[E,U]=w.useState("hours"),[K,$]=w.useState("Wrench"),[ne,O]=w.useState(""),V=L=>{be(L),q(L.name),j(L.default_interval_hours.toString()),U(L.interval_type||"hours"),$(L.icon||"Wrench"),O(L.wiki_url||"")},ee=()=>{oe&&Me.trim()&&parseFloat(Z)>0&&(a(oe.id,{name:Me.trim(),default_interval_hours:parseFloat(Z),interval_type:E,icon:K,wiki_url:ne.trim()||null}),be(null))},G=(L,F,te)=>{const ve=parseFloat(y);if(!isNaN(ve)&&ve>0){const he=Math.abs(ve-F)<.01?null:ve;n(L,{custom_interval_hours:he,custom_interval_type:b!==te?b:null})}f(null)},re=L=>{L.preventDefault(),T.trim()&&parseFloat(P)>0&&I.size>0&&(r({name:T.trim(),default_interval_hours:parseFloat(P),interval_type:R,icon:D,wiki_url:z.trim()||null},Array.from(I)),C(""),k("100"),A("hours"),W(""),J(new Set),N(!1))},ce=L=>{J(F=>{const te=new Set(F);return te.has(L)?te.delete(L):te.add(L),te})},ge=t?.map(L=>({printerId:L.printer_id,printerName:L.printer_name,items:L.maintenance_items.sort((F,te)=>F.maintenance_type_id-te.maintenance_type_id)})).sort((L,F)=>L.printerName.localeCompare(F.printerName))||[],xe=e.filter(L=>L.is_system),ae=e.filter(L=>!L.is_system);return i.jsxs("div",{className:"space-y-8",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-lg font-semibold text-white",children:m("maintenance.maintenanceTypes")}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:m("maintenance.maintenanceTypesDescription")})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Ie,{variant:"secondary",onClick:o,disabled:!d("maintenance:delete")||l,title:d("maintenance:delete")?void 0:m("maintenance.noPermissionDeleteTypes"),children:m("maintenance.restoreDefaults")}),i.jsxs(Ie,{onClick:()=>N(!_),disabled:!d("maintenance:create"),title:d("maintenance:create")?void 0:m("maintenance.noPermissionEditTypes"),children:[i.jsx(ar,{className:"w-4 h-4"}),m("maintenance.addCustomType")]})]})]}),_&&i.jsx(Pt,{className:"mb-6",children:i.jsx(Et,{className:"py-4",children:i.jsxs("form",{onSubmit:re,children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[i.jsxs("div",{className:"lg:col-span-2",children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:m("common.name")}),i.jsx("input",{type:"text",value:T,onChange:L=>C(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:m("maintenance.exampleName"),autoFocus:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:m("maintenance.intervalType")}),i.jsxs("select",{value:R,onChange:L=>{A(L.target.value),L.target.value==="days"?k("30"):k("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"hours",children:m("maintenance.printHours")}),i.jsx("option",{value:"days",children:m("maintenance.calendarDays")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:m("maintenance.intervalValue",{type:R==="days"?m("maintenance.calendarDays").toLowerCase():m("common.hours")})}),i.jsx("input",{type:"number",value:P,onChange:L=>k(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),i.jsx("div",{className:"mt-4 flex items-end justify-between",children:i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:m("maintenance.icon")}),i.jsx("div",{className:"flex gap-1",children:Object.keys(Bv).map(L=>{const F=Bv[L];return i.jsx("button",{type:"button",onClick:()=>B(L),className:`p-2 rounded-lg transition-colors ${D===L?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:i.jsx(F,{className:"w-4 h-4"})},L)})})]})}),i.jsxs("div",{className:"mt-4",children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:m("maintenance.documentationLink")}),i.jsx("input",{type:"url",value:z,onChange:L=>W(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"https://wiki.bambulab.com/..."})]}),i.jsxs("div",{className:"mt-4",children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:m("maintenance.assignToPrinters")}),i.jsx("div",{className:"flex flex-wrap gap-2",children:pe.map(L=>i.jsx("button",{type:"button",onClick:()=>ce(L.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${I.has(L.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:L.name},L.id))}),I.size===0&&i.jsx("p",{className:"text-xs text-orange-400 mt-1",children:m("maintenance.selectAtLeastOnePrinter")})]}),i.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:()=>{N(!1),J(new Set)},children:m("common.cancel")}),i.jsx(Ie,{type:"submit",disabled:!T.trim()||I.size===0,children:m("maintenance.addType")})]})]})})}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[xe.map(L=>{const F=m0(L.icon),te=L.interval_type||"hours";return i.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:i.jsx(F,{className:"w-5 h-5 text-bambu-gray"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm font-medium text-white truncate",children:L.name}),i.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[te==="days"?i.jsx(Yr,{className:"w-3 h-3"}):i.jsx(yd,{className:"w-3 h-3"}),VD(L.default_interval_hours,te,m)]})]}),i.jsx("button",{onClick:()=>{d("maintenance:delete")&&me(L)},disabled:!d("maintenance:delete"),title:d("maintenance:delete")?void 0:m("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${d("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:i.jsx(en,{className:"w-4 h-4"})})]})},L.id)}),ae.map(L=>{const F=m0(L.icon),te=L.interval_type||"hours";if(oe?.id===L.id)return i.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:i.jsxs("div",{className:"space-y-3",children:[i.jsx("input",{type:"text",value:Me,onChange:_e=>q(_e.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:m("common.name"),autoFocus:!0}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("select",{value:E,onChange:_e=>U(_e.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"hours",children:m("maintenance.printHours")}),i.jsx("option",{value:"days",children:m("maintenance.calendarDays")})]}),i.jsx("input",{type:"number",value:Z,onChange:_e=>j(_e.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),i.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(Bv).map(_e=>{const Le=Bv[_e];return i.jsx("button",{type:"button",onClick:()=>$(_e),className:`p-1.5 rounded transition-colors ${K===_e?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:i.jsx(Le,{className:"w-3.5 h-3.5"})},_e)})}),i.jsx("input",{type:"url",value:ne,onChange:_e=>O(_e.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:m("maintenance.documentationLink")}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Ie,{size:"sm",onClick:ee,disabled:!Me.trim(),children:m("common.save")}),i.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>be(null),children:m("common.cancel")})]})]})},L.id);const he=Y(L.id),de=se(L.id),ke=ie===L.id;return i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:i.jsx(F,{className:"w-5 h-5 text-bambu-green"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-medium text-white truncate",children:L.name}),i.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:m("maintenance.custom")})]}),i.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[te==="days"?i.jsx(Yr,{className:"w-3 h-3"}):i.jsx(yd,{className:"w-3 h-3"}),VD(L.default_interval_hours,te,m)]})]}),i.jsxs("button",{onClick:()=>Q(ke?null:L.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${he.length>0?"border-bambu-green/50 bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20":"border-orange-400/50 bg-orange-400/10 text-orange-400 hover:bg-orange-400/20"}`,title:m("maintenance.printersAssignedClick",{count:he.length}),children:[i.jsx(_r,{className:"w-3 h-3"}),i.jsx("span",{className:"text-xs font-medium",children:he.length}),i.jsx(On,{className:`w-3 h-3 transition-transform ${ke?"rotate-180":""}`})]}),i.jsx("button",{onClick:()=>V(L),disabled:!d("maintenance:update"),title:d("maintenance:update")?void 0:m("maintenance.noPermissionEditTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors ${d("maintenance:update")?"":"opacity-50 cursor-not-allowed"}`,children:i.jsx(_f,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>{confirm(m("maintenance.deleteTypeConfirm",{name:L.name}))&&s(L.id)},disabled:!d("maintenance:delete"),title:d("maintenance:delete")?void 0:m("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${d("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:i.jsx(en,{className:"w-4 h-4"})})]}),ke&&i.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[i.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:m("maintenance.assignedToPrinters")}),he.length===0?i.jsx("p",{className:"text-xs text-orange-400",children:m("maintenance.noPrintersAssigned")}):i.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:he.map(_e=>i.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[_e.printerName,i.jsx("button",{onClick:()=>_e.itemId&&u(_e.itemId),disabled:!d("maintenance:delete"),title:d("maintenance:delete")?m("maintenance.removeFromPrinter"):m("maintenance.noPermissionRemovePrinter"),className:`ml-1 ${d("maintenance:delete")?"hover:text-red-400":"opacity-50 cursor-not-allowed"}`,children:"×"})]},_e.printerId))}),de.length>0&&i.jsxs("div",{className:"flex flex-wrap gap-1",children:[i.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:m("maintenance.addPrinterShort")}),de.map(_e=>i.jsxs("button",{onClick:()=>c(_e.id,L.id),disabled:!d("maintenance:create"),title:d("maintenance:create")?void 0:m("maintenance.noPermissionAssignPrinter"),className:`px-2 py-1 bg-bambu-dark rounded text-xs transition-colors ${d("maintenance:create")?"hover:bg-bambu-green/20 text-bambu-gray hover:text-bambu-green":"opacity-50 cursor-not-allowed text-bambu-gray"}`,children:["+ ",_e.name]},_e.id))]})]})]},L.id)})]})]}),ge.length>0&&i.jsxs("div",{children:[i.jsxs("div",{className:"mb-4",children:[i.jsx("h2",{className:"text-lg font-semibold text-white",children:m("maintenance.intervalOverrides")}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:m("maintenance.intervalOverridesDescription")})]}),i.jsx("div",{className:"space-y-4",children:ge.map(L=>i.jsx(Pt,{children:i.jsxs(Et,{className:"py-4",children:[i.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:L.printerName}),i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:L.items.map(F=>{const te=m0(F.maintenance_type_icon),ve=e.find(Le=>Le.id===F.maintenance_type_id),he=ve?.default_interval_hours||F.interval_hours,de=ve?.interval_type||"hours",ke=F.interval_type||"hours",_e=p===F.id;return i.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[i.jsx(te,{className:"w-4 h-4 text-bambu-gray shrink-0"}),i.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:F.maintenance_type_name}),_e?i.jsxs("div",{className:"flex items-center gap-1",children:[b==="days"?i.jsx(Yr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):i.jsx(yd,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),i.jsxs("select",{value:b,onChange:Le=>g(Le.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[i.jsx("option",{value:"hours",children:m("maintenance.printHours")}),i.jsx("option",{value:"days",children:m("maintenance.calendarDays")})]}),i.jsx("input",{type:"number",value:y,onChange:Le=>v(Le.target.value),onKeyDown:Le=>{Le.key==="Enter"&&G(F.id,he,de),Le.key==="Escape"&&f(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),i.jsx(Ie,{size:"sm",onClick:()=>G(F.id,he,de),children:"OK"})]}):i.jsxs("button",{onClick:()=>{d("maintenance:update")&&(f(F.id),v(F.interval_hours.toString()),g(ke))},disabled:!d("maintenance:update"),title:d("maintenance:update")?void 0:m("maintenance.noPermissionEditIntervals"),className:`px-2 py-1 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs font-medium text-white transition-colors flex items-center gap-1 ${d("maintenance:update")?"hover:bg-bambu-dark-secondary hover:border-bambu-green":"opacity-50 cursor-not-allowed"}`,children:[ke==="days"?i.jsx(Yr,{className:"w-3 h-3"}):i.jsx(yd,{className:"w-3 h-3"}),VD(F.interval_hours,ke,m),i.jsx(_f,{className:"w-3 h-3 text-bambu-gray"})]})]},F.id)})})]})},L.printerId))})]}),ge.length===0&&i.jsx(Pt,{children:i.jsxs(Et,{className:"text-center py-12",children:[i.jsx(Jn,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),i.jsx("p",{className:"text-bambu-gray",children:m("common.noPrinters")}),i.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:m("maintenance.intervalOverridesDescription")})]})}),ue&&i.jsx(_n,{title:m("maintenance.deleteSystemTypeTitle"),message:m("maintenance.deleteSystemTypeMessage",{name:ue.name}),confirmText:m("common.delete"),cancelText:m("common.cancel"),variant:"danger",cancelVariant:"primary",cardClassName:"bg-red-950/70 border border-red-800/70",onConfirm:()=>{s(ue.id),me(null)},onCancel:()=>me(null)})]})}function att(){const{t}=Rt(),e=sn(),{showToast:n}=fn(),{hasPermission:r}=Nr(),[a,s]=w.useState("status"),{data:o,isLoading:l}=tt({queryKey:["maintenanceOverview"],queryFn:fe.getMaintenanceOverview}),{data:c}=tt({queryKey:["maintenanceTypes"],queryFn:fe.getMaintenanceTypes}),u=ft({mutationFn:({id:P,notes:k})=>fe.performMaintenance(P,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.maintenanceComplete"))},onError:P=>{n(P.message,"error")}}),d=ft({mutationFn:({id:P,data:k})=>fe.updateMaintenanceItem(P,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:P=>{n(P.message,"error")}}),m=ft({mutationFn:({id:P,data:k})=>fe.updateMaintenanceType(P,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onError:P=>{n(P.message,"error")}}),p=ft({mutationFn:fe.deleteMaintenanceType,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeDeleted"))},onError:P=>{n(P.message,"error")}}),f=ft({mutationFn:fe.restoreDefaultMaintenanceTypes,onSuccess:P=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.defaultsRestored",{count:P.restored}))},onError:P=>{n(P.message,"error")}}),y=ft({mutationFn:({printerId:P,hours:k})=>fe.setPrinterHours(P,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.printHoursUpdated"))},onError:P=>{n(P.message,"error")}}),v=ft({mutationFn:({printerId:P,typeId:k})=>fe.assignMaintenanceType(P,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerAssigned"))},onError:P=>{n(P.message,"error")}}),b=ft({mutationFn:fe.removeMaintenanceItem,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerRemoved"))},onError:P=>{n(P.message,"error")}}),g=P=>{u.mutate({id:P})},_=(P,k)=>{d.mutate({id:P,data:{enabled:k}})},N=(P,k)=>{y.mutate({printerId:P,hours:k})};if(l)return i.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const T=o?.reduce((P,k)=>P+k.due_count,0)||0,C=o?.reduce((P,k)=>P+k.warning_count,0)||0;return i.jsxs("div",{className:"p-4 md:p-8",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx("h1",{className:"text-2xl font-bold text-white",children:t("maintenance.title")}),i.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:a==="status"?i.jsxs(i.Fragment,{children:[T>0&&i.jsx("span",{className:"text-red-400",children:t("maintenance.dueCount",{count:T})}),T>0&&C>0&&" · ",C>0&&i.jsx("span",{className:"text-amber-400",children:t("maintenance.warningCount",{count:C})}),T===0&&C===0&&i.jsx("span",{className:"text-bambu-green",children:t("maintenance.allOk")})]}):t("maintenance.configureSettings")})]}),i.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[i.jsx("button",{onClick:()=>s("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${a==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.statusTab")}),i.jsx("button",{onClick:()=>s("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${a==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.settingsTab")})]}),a==="status"?i.jsx("div",{className:"space-y-6",children:o&&o.length>0?[...o].sort((P,k)=>{const R=P.due_count*10+P.warning_count,A=k.due_count*10+k.warning_count;return R!==A?A-R:P.printer_name.localeCompare(k.printer_name)}).map(P=>i.jsx(rtt,{overview:P,onPerform:g,onToggle:_,onSetHours:N,hasPermission:r,t},P.printer_id)):i.jsx(Pt,{children:i.jsxs(Et,{className:"text-center py-16",children:[i.jsx(kf,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),i.jsx("p",{className:"text-lg font-medium text-white mb-2",children:t("common.noPrinters")}),i.jsx("p",{className:"text-bambu-gray",children:t("maintenance.configureSettings")})]})})}):i.jsx(itt,{overview:o,types:c||[],onUpdateInterval:(P,k)=>d.mutate({id:P,data:k}),onAddType:async(P,k)=>{const R=await fe.createMaintenanceType(P);for(const A of k)await fe.assignMaintenanceType(A,R.id);e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onUpdateType:(P,k)=>m.mutate({id:P,data:k}),onDeleteType:P=>p.mutate(P),onRestoreDefaults:()=>f.mutate(),isRestoringDefaults:f.isPending,onAssignType:(P,k)=>v.mutate({printerId:P,typeId:k}),onRemoveItem:P=>b.mutate(P),hasPermission:r,t})]})}const PY=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Hoe({project:t,onClose:e,onSave:n,isLoading:r,currencySymbol:a,t:s}){const[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.description||""),[d,m]=w.useState(t?.color||PY[0]),[p,f]=w.useState(t?.target_count?.toString()||""),[y,v]=w.useState(t?.target_parts_count?.toString()||""),[b,g]=w.useState(t?.status||"active"),[_,N]=w.useState(t?.tags||""),[T,C]=w.useState(t?.due_date?.split("T")[0]||""),[P,k]=w.useState(t?.priority||"normal"),[R,A]=w.useState(t?.budget?.toString()||""),D=B=>{B.preventDefault(),n({name:o.trim(),description:c.trim()||void 0,color:d,target_count:p?parseInt(p,10):void 0,target_parts_count:y?parseInt(y,10):void 0,tags:_.trim()||void 0,due_date:T||void 0,priority:P,budget:R.trim()?parseFloat(R):null,...t&&{status:b}})};return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[i.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:s(t?"projects.editProject":"projects.newProject")})}),i.jsxs("form",{onSubmit:D,className:"p-4 space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("common.name")}),i.jsx("input",{type:"text",value:o,onChange:B=>l(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:s("projects.namePlaceholder"),required:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("common.description")}),i.jsx("textarea",{value:c,onChange:B=>u(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green resize-none",placeholder:s("projects.descriptionPlaceholder"),rows:2})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("projects.color")}),i.jsx("div",{className:"flex gap-2 flex-wrap",children:PY.map(B=>i.jsx("button",{type:"button",onClick:()=>m(B),className:`w-8 h-8 rounded-full transition-transform ${d===B?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:B}},B))})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("projects.targetPlates")}),i.jsx("input",{type:"number",value:p,onChange:B=>f(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:s("projects.targetPlatesPlaceholder"),min:"1"}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:s("projects.targetPlatesHelp")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("projects.targetParts")}),i.jsx("input",{type:"number",value:y,onChange:B=>v(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:s("projects.targetPartsPlaceholder"),min:"1"}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:s("projects.targetPartsHelp")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("projects.tagsLabel")}),i.jsx("input",{type:"text",value:_,onChange:B=>N(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:s("projects.tagsPlaceholder")})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("projects.dueDate")}),i.jsx("input",{type:"date",value:T,onChange:B=>C(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("projects.priority")}),i.jsxs("select",{value:P,onChange:B=>k(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[i.jsx("option",{value:"low",children:s("projects.priorityLow")}),i.jsx("option",{value:"normal",children:s("projects.priorityNormal")}),i.jsx("option",{value:"high",children:s("projects.priorityHigh")}),i.jsx("option",{value:"urgent",children:s("projects.priorityUrgent")})]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("projectDetail.cost.budget")}),i.jsxs("div",{className:"relative",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray pointer-events-none",children:a}),i.jsx("input",{type:"number",step:"0.01",min:"0",value:R,onChange:B=>A(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded pl-8 pr-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"0.00"})]})]}),t&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("common.status")}),i.jsxs("select",{value:b,onChange:B=>g(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[i.jsx("option",{value:"active",children:s("projects.statusActive")}),i.jsx("option",{value:"completed",children:s("projects.statusCompleted")}),i.jsx("option",{value:"archived",children:s("projects.statusArchived")})]})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:e,children:s("common.cancel")}),i.jsx(Ie,{type:"submit",disabled:!o.trim()||r,children:r?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):s(t?"common.save":"projects.create")})]})]})]})})}function stt({project:t,onClick:e,onEdit:n,onDelete:r,hasPermission:a,t:s}){const o=t.target_count?Math.round(t.archive_count/t.target_count*100):0,l=t.target_parts_count?Math.round(t.completed_count/t.target_parts_count*100):0,c=t.status==="completed",u=t.status==="archived",[d,m]=w.useState(!1),f=c?{icon:su,color:"text-bambu-green",bg:"bg-bambu-green/10"}:u?{icon:$s,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:Jn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:Ss,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return i.jsxs("div",{className:"group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden",onClick:e,children:[i.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full",style:{backgroundColor:t.color||"#6b7280",boxShadow:`0 0 12px ${t.color||"#6b7280"}40`}}),i.jsxs("div",{className:"p-5 pl-6",children:[i.jsxs("div",{className:"flex items-start justify-between mb-4",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[i.jsx("div",{className:`p-2 rounded-lg ${f.bg} flex-shrink-0`,children:i.jsx(f.icon,{className:`w-5 h-5 ${f.color}`})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_parts_count?i.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${l>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," ",s("projects.parts")]}):t.target_count?i.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${o>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.archive_count,"/",t.target_count," ",s("projects.plates")]}):t.completed_count>0?i.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium bg-bambu-dark text-bambu-gray",children:[t.completed_count," ",s("projects.parts")]}):null,c&&i.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.done")}),u&&i.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.statusArchived")})]}),t.description&&i.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const y=t.archives.map(_=>_.filament_type).filter(Boolean).flatMap(_=>_.split(",").map(N=>N.trim())).filter(Boolean),v=[...new Set(y)],b=t.archives.map(_=>_.filament_color).filter(Boolean).flatMap(_=>_.split(",").map(N=>N.trim())).filter(_=>_.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(_)),g=[...new Set(b)];return v.length===0&&g.length===0?null:i.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[v.slice(0,3).map(_=>i.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:_},_)),g.length>0&&i.jsxs("div",{className:"flex items-center gap-0.5",children:[g.slice(0,5).map(_=>i.jsx("div",{className:"w-3 h-3 rounded-full border border-black/20",style:{backgroundColor:_.startsWith("#")?_:`#${_}`},title:_},_)),g.length>5&&i.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",g.length-5]})]})]})})()]})]}),i.jsxs("div",{className:"relative",onClick:y=>y.stopPropagation(),children:[i.jsx("button",{className:"p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100",onClick:()=>m(!d),children:i.jsx(yh,{className:"w-4 h-4"})}),d&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>m(!1)}),i.jsxs("div",{className:"absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[i.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${a("projects:update")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{a("projects:update")&&(n(),m(!1))},disabled:!a("projects:update"),title:a("projects:update")?void 0:s("projects.noEditPermission"),children:[i.jsx(_f,{className:"w-4 h-4"}),s("common.edit")]}),i.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${a("projects:delete")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{a("projects:delete")&&(r(),m(!1))},disabled:!a("projects:delete"),title:a("projects:delete")?void 0:s("projects.noDeletePermission"),children:[i.jsx(en,{className:"w-4 h-4"}),s("common.delete")]})]})]})]})]}),i.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?i.jsxs("div",{className:"space-y-3",children:[t.target_count&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[i.jsx("span",{className:"text-bambu-gray",children:s("projects.plates")}),i.jsxs("span",{className:o>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),i.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:i.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(o,100)}%`,background:o>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${o>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.target_parts_count&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[i.jsx("span",{className:"text-bambu-gray",children:s("projects.parts")}),i.jsxs("span",{className:l>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),i.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:i.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(l,100)}%`,background:l>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${l>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&i.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," ",s("projects.failed")]})]}):t.completed_count>0||t.failed_count>0?i.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&i.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[i.jsx($s,{className:"w-3.5 h-3.5"}),i.jsxs("span",{children:[t.completed_count," ",s("projects.completed")]})]}),t.failed_count>0&&i.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[i.jsx(Mn,{className:"w-3.5 h-3.5"}),i.jsxs("span",{children:[t.failed_count," ",s("projects.failed")]})]}),t.queue_count>0&&i.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[i.jsx(Jn,{className:"w-3.5 h-3.5"}),i.jsxs("span",{children:[t.queue_count," ",s("projects.inQueue")]})]})]}):i.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:s("projects.noPrintsYet")})}),t.archives&&t.archives.length>0&&i.jsxs("div",{className:"mb-4",children:[i.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(y=>i.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:y.print_name||"Unknown",children:[y.thumbnail_path?i.jsx("img",{src:fe.getArchiveThumbnail(y.id),alt:y.print_name||"",className:"w-full h-full object-cover"}):i.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:i.jsx(Gi,{className:"w-6 h-6"})}),y.status==="failed"&&i.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:i.jsx(Mn,{className:"w-4 h-4 text-white"})})]},y.id))}),t.archive_count>4&&i.jsx("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:s("common.more",{count:t.archive_count-4})})]}),i.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[i.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.printJobs"),children:[i.jsx(Vi,{className:"w-3.5 h-3.5 text-blue-400"}),i.jsxs("span",{children:[t.archive_count," ",s("projects.plates")]})]}),i.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.partsPrinted"),children:[i.jsx(Gi,{className:"w-3.5 h-3.5 text-bambu-green"}),i.jsxs("span",{children:[t.completed_count," ",s("projects.parts")]})]}),t.failed_count>0&&i.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:s("projects.failedParts"),children:[i.jsx(Mn,{className:"w-3.5 h-3.5"}),i.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&i.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:s("projects.inQueue"),children:[i.jsx(y3,{className:"w-3.5 h-3.5"}),i.jsx("span",{children:t.queue_count})]})]}),i.jsx(fa,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function ott(){const{t}=Rt(),e=al(),n=sn(),{showToast:r}=fn(),{hasPermission:a}=Nr(),[s,o]=w.useState(!1),[l,c]=w.useState(),[u,d]=w.useState("active"),[m,p]=w.useState(null),{data:f}=tt({queryKey:["settings"],queryFn:fe.getSettings}),y=Go(f?.currency||"USD"),{data:v,isLoading:b}=tt({queryKey:["projects",u==="all"?void 0:u],queryFn:()=>fe.getProjects(u==="all"?void 0:u)}),g=ft({mutationFn:J=>fe.createProject(J),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),r(t("projects.toast.created"),"success")},onError:J=>{r(J.message,"error")}}),_=ft({mutationFn:({id:J,data:ie})=>fe.updateProject(J,ie),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),c(void 0),r(t("projects.toast.updated"),"success")},onError:J=>{r(J.message,"error")}}),N=ft({mutationFn:J=>fe.deleteProject(J),onSuccess:()=>{p(null),r(t("projects.toast.deleted"),"success"),setTimeout(()=>window.location.reload(),100)},onError:J=>{p(null),r(J.message,"error")}}),T=ft({mutationFn:J=>fe.importProject(J),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success")},onError:J=>{r(J.message,"error")}}),C=w.useRef(null),P=async()=>{try{const J=await fe.getProjects(),ie=await Promise.all(J.map(async pe=>await fe.exportProjectJson(pe.id))),Q=new Blob([JSON.stringify(ie,null,2)],{type:"application/json"}),ue=URL.createObjectURL(Q),me=document.createElement("a");me.href=ue,me.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,me.click(),URL.revokeObjectURL(ue),r(t("projects.toast.exported"),"success")}catch(J){r(J.message,"error")}},k=()=>{C.current?.click()},R=async J=>{const ie=J.target.files?.[0];if(ie){try{if(ie.name.toLowerCase().endsWith(".zip"))await fe.importProjectFile(ie),n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success");else{const ue=await ie.text(),me=JSON.parse(ue),pe=Array.isArray(me)?me:[me];for(const Y of pe)await T.mutateAsync(Y);pe.length>1&&r(t("projects.toast.multipleImported",{count:pe.length}),"success")}}catch(Q){r(`${t("projects.toast.importFailed")}: ${Q.message}`,"error")}J.target.value=""}},A=J=>{l?_.mutate({id:l.id,data:J}):g.mutate(J)},D=J=>{c(J),o(!0)},B=J=>{e(`/projects/${J.id}`)},z=J=>{p(J)},W=()=>{m!==null&&N.mutate(m)},I=v?.reduce((J,ie)=>(J[ie.status]=(J[ie.status]||0)+1,J.all=(J.all||0)+1,J),{})||{};return i.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[i.jsx("input",{ref:C,type:"file",accept:".json,.zip",onChange:R,className:"hidden"}),i.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[i.jsxs("div",{children:[i.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[i.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:i.jsx(Ss,{className:"w-6 h-6 text-bambu-green"})}),t("projects.title")]}),i.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("projects.subtitle")})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs(Ie,{variant:"secondary",onClick:k,disabled:!a("projects:create"),title:a("projects:create")?t("projects.importProject"):t("projects.noImportPermission"),children:[i.jsx(vi,{className:"w-4 h-4 mr-2"}),t("projects.import")]}),i.jsxs(Ie,{variant:"secondary",onClick:P,disabled:!a("projects:read"),title:a("projects:read")?t("projects.exportAll"):t("projects.noExportPermission"),children:[i.jsx(bi,{className:"w-4 h-4 mr-2"}),t("projects.export")]}),i.jsxs(Ie,{onClick:()=>o(!0),className:"sm:w-auto w-full",disabled:!a("projects:create"),title:a("projects:create")?void 0:t("projects.noCreatePermission"),children:[i.jsx(ar,{className:"w-4 h-4 mr-2"}),t("projects.newProject")]})]})]}),i.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:t("projects.statusActive"),icon:Jn},{key:"completed",label:t("projects.statusCompleted"),icon:su},{key:"archived",label:t("projects.statusArchived"),icon:$s},{key:"all",label:t("common.all"),icon:Ss}].map(({key:J,label:ie,icon:Q})=>i.jsxs("button",{onClick:()=>d(J),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${u===J?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[i.jsx(Q,{className:"w-4 h-4"}),i.jsx("span",{children:ie}),I[J]>0&&i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${u===J?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:I[J]})]},J))}),b?i.jsx("div",{className:"flex items-center justify-center py-20",children:i.jsxs("div",{className:"flex flex-col items-center gap-3",children:[i.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("projects.loading")})]})}):v?.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[i.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:i.jsx(Ss,{className:"w-12 h-12 text-bambu-gray/50"})}),i.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:u==="all"?t("projects.noProjects"):t("projects.noProjectsFiltered",{status:u})}),i.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:u==="all"?t("projects.createFirst"):t("projects.noProjectsFilteredHelp",{status:u})}),u==="all"&&i.jsxs(Ie,{onClick:()=>o(!0),disabled:!a("projects:create"),title:a("projects:create")?void 0:t("projects.noCreatePermission"),children:[i.jsx(ar,{className:"w-4 h-4 mr-2"}),t("projects.createFirstButton")]})]}):i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:v?.map(J=>i.jsx(stt,{project:J,onClick:()=>B(J),onEdit:()=>D(J),onDelete:()=>z(J.id),hasPermission:a,t},J.id))}),m!==null&&i.jsx(_n,{title:t("projects.deleteProject"),message:t("projects.deleteConfirm"),confirmText:t("projects.deleteProject"),variant:"danger",onConfirm:W,onCancel:()=>p(null)}),s&&i.jsx(Hoe,{project:l,onClose:()=>{o(!1),c(void 0)},onSave:A,isLoading:g.isPending||_.isPending,currencySymbol:y,t})]})}function ltt(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function ctt({status:t,t:e}){const n={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},r=n[t]||n.active,a={active:e("projectDetail.status.active"),completed:e("projectDetail.status.completed"),archived:e("projectDetail.status.archived")};return i.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${r}`,children:a[t]||t.charAt(0).toUpperCase()+t.slice(1)})}function MY({icon:t,label:e,value:n,subValue:r,hint:a,color:s="text-bambu-gray"}){return i.jsx(Pt,{children:i.jsx(Et,{className:"p-4",children:i.jsxs("div",{className:"flex items-center gap-3",title:a,children:[i.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${s}`,children:i.jsx(t,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:e}),i.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&i.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function utt({archives:t,t:e}){return t.length===0?i.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[i.jsx(Gi,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),i.jsx("p",{children:e("projectDetail.noPrints")})]}):i.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:t.map(n=>i.jsxs(co,{to:`/archives?search=${encodeURIComponent(n.print_name||"")}`,className:"group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors",children:[n.thumbnail_path?i.jsx("img",{src:fe.getArchiveThumbnail(n.id),alt:n.print_name||"Print",className:"w-full h-full object-cover"}):i.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:i.jsx(Gi,{className:"w-8 h-8"})}),n.status==="failed"&&i.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:i.jsx(qi,{className:"w-8 h-8 text-white"})}),n.status==="completed"&&i.jsx("div",{className:"absolute top-1 right-1",children:i.jsx(fr,{className:"w-4 h-4 text-bambu-green"})}),i.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity",children:i.jsx("p",{className:"text-xs text-white truncate",children:n.print_name||"Unknown"})})]},n.id))})}function dtt({priority:t,t:e}){const n={low:{color:"bg-gray-500/20 text-gray-400",label:e("projectDetail.priority.low")},normal:{color:"bg-blue-500/20 text-blue-400",label:e("projectDetail.priority.normal")},high:{color:"bg-orange-500/20 text-orange-400",label:e("projectDetail.priority.high")},urgent:{color:"bg-red-500/20 text-red-400",label:e("projectDetail.priority.urgent")}},{color:r,label:a}=n[t]||n.normal;return i.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${r}`,children:[t==="urgent"&&i.jsx(Mn,{className:"w-3 h-3"}),a]})}function GD(t,e){if(!t)return null;const n=Zn(t);if(!n)return null;const r=new Date,a=Math.ceil((n.getTime()-r.getTime())/(1e3*60*60*24));return a<0?{color:"text-red-400",label:e("projectDetail.dueDate.overdue")}:a===0?{color:"text-orange-400",label:e("projectDetail.dueDate.today")}:a<=3?{color:"text-yellow-400",label:e("projectDetail.dueDate.daysLeft",{count:a})}:{color:"text-bambu-gray",label:e("projectDetail.dueDate.daysLeft",{count:a})}}function mtt(){const{id:t}=hw(),e=al(),{t:n}=Rt(),r=sn(),{showToast:a}=fn(),{hasPermission:s}=Nr(),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,m]=w.useState(""),p=parseInt(t||"0",10),{data:f,isLoading:y,error:v}=tt({queryKey:["project",p],queryFn:()=>fe.getProject(p),enabled:p>0}),{data:b,isLoading:g}=tt({queryKey:["project-archives",p],queryFn:()=>fe.getProjectArchives(p),enabled:p>0}),{data:_,isLoading:N}=tt({queryKey:["project-bom",p],queryFn:()=>fe.getProjectBOM(p),enabled:p>0}),{data:T,isLoading:C}=tt({queryKey:["project-timeline",p],queryFn:()=>fe.getProjectTimeline(p,20),enabled:p>0}),{data:P}=tt({queryKey:["settings"],queryFn:fe.getSettings}),{data:k}=tt({queryKey:["project-folders",p],queryFn:()=>fe.getLibraryFoldersByProject(p),enabled:p>0}),R=Go(P?.currency||"USD"),A=P?.time_format||"system",D=ft({mutationFn:je=>fe.updateProject(p,je),onSuccess:()=>{r.invalidateQueries({queryKey:["project",p]}),r.invalidateQueries({queryKey:["projects"]}),l(!1),u(!1),a(n("projectDetail.toast.projectUpdated"),"success")},onError:je=>{a(je.message,"error")}}),B=()=>{m(f?.notes||""),u(!0)},z=()=>{D.mutate({notes:d})},W=()=>{u(!1),m("")},[I,J]=w.useState(""),[ie,Q]=w.useState(1),[ue,me]=w.useState(""),[pe,Y]=w.useState(""),[se,oe]=w.useState(""),[be,Me]=w.useState(!1),[q,Z]=w.useState(!1),[j,E]=w.useState(null),[U,K]=w.useState(""),[$,ne]=w.useState(1),[O,V]=w.useState(""),[ee,G]=w.useState(""),[re,ce]=w.useState(""),[ge,xe]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),ae=ft({mutationFn:je=>fe.createBOMItem(p,je),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),J(""),Q(1),me(""),Y(""),oe(""),Me(!1),a(n("projectDetail.toast.partAdded"),"success")},onError:je=>a(je.message,"error")}),L=ft({mutationFn:({itemId:je,data:Xe})=>fe.updateBOMItem(p,je,Xe),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),E(null)},onError:je=>a(je.message,"error")}),F=ft({mutationFn:je=>fe.deleteBOMItem(p,je),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),a(n("projectDetail.toast.partRemoved"),"success")},onError:je=>a(je.message,"error")}),te=je=>{je.preventDefault(),I.trim()&&ae.mutate({name:I.trim(),quantity_needed:ie,unit_price:ue?parseFloat(ue):void 0,sourcing_url:pe.trim()||void 0,remarks:se.trim()||void 0})},ve=je=>{const Xe=je.is_complete?0:je.quantity_needed;L.mutate({itemId:je.id,data:{quantity_acquired:Xe}})},he=(je,Xe)=>{xe({isOpen:!0,title:n("projectDetail.bom.deletePart"),message:n("projectDetail.bom.deleteConfirm",{name:Xe}),onConfirm:()=>{xe(ye=>({...ye,isOpen:!1})),F.mutate(je)}})},de=je=>{E(je),K(je.name),ne(je.quantity_needed),V(je.unit_price?.toString()||""),G(je.sourcing_url||""),ce(je.remarks||"")},ke=je=>{je.preventDefault(),!(!j||!U.trim())&&L.mutate({itemId:j.id,data:{name:U.trim(),quantity_needed:$,unit_price:O?parseFloat(O):void 0,sourcing_url:ee.trim()||void 0,remarks:re.trim()||void 0}})},_e=()=>{E(null)},Le=async()=>{try{const{blob:je,filename:Xe}=await fe.exportProjectZip(Number(p)),ye=URL.createObjectURL(je),Ge=document.createElement("a");Ge.href=ye,Ge.download=Xe||`${f?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,Ge.click(),URL.revokeObjectURL(ye),a(n("projectDetail.toast.projectExported"),"success")}catch(je){a(je.message,"error")}},$e=ft({mutationFn:()=>fe.createTemplateFromProject(p),onSuccess:()=>{r.invalidateQueries({queryKey:["projects"]}),a(n("projectDetail.toast.templateCreated"),"success")},onError:je=>a(je.message,"error")}),Re=je=>Tf(je,A,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(y)return i.jsx("div",{className:"flex items-center justify-center py-24",children:i.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(v||!f)return i.jsxs("div",{className:"text-center py-24",children:[i.jsx("p",{className:"text-bambu-gray",children:v?`${n("common.error")}: ${v.message}`:n("projectDetail.notFound")}),i.jsx(Ie,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:n("projectDetail.backToProjects")})]});const Ae=f.stats,Pe=Ae?.progress_percent??0,Ue=Ae?.parts_progress_percent??0;return i.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[i.jsx(co,{to:"/projects",className:"hover:text-white transition-colors",children:n("navigation.projects")}),i.jsx(fa,{className:"w-4 h-4"}),i.jsx("span",{className:"text-white",children:f.name})]}),i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:i.jsx(IX,{className:"w-5 h-5 text-bambu-gray"})}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:f.color||"#6b7280"}}),i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold text-white",children:f.name}),f.description&&i.jsx("p",{className:"text-bambu-gray mt-1",children:f.description})]})]}),i.jsx(ctt,{status:f.status,t:n})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs(Ie,{variant:"secondary",onClick:Le,disabled:!s("projects:read"),title:s("projects:read")?n("projectDetail.exportProject"):n("projectDetail.noExportPermission"),children:[i.jsx(bi,{className:"w-4 h-4 mr-2"}),n("projectDetail.export")]}),i.jsxs(Ie,{onClick:()=>l(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.noEditPermission"),children:[i.jsx(_f,{className:"w-4 h-4 mr-2"}),n("common.edit")]})]})]}),(f.target_count||f.target_parts_count)&&i.jsx(Pt,{children:i.jsxs(Et,{className:"p-4 space-y-4",children:[f.target_count&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.platesProgress")}),i.jsxs("span",{className:"text-sm font-medium text-white",children:[Ae?.total_archives||0," / ",f.target_count," ",n("projectDetail.progress.printJobs")]})]}),i.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Pe,100)}%`,backgroundColor:Pe>=100?"#22c55e":f.color||"#6b7280"}})}),i.jsxs("div",{className:"flex justify-between mt-1",children:[i.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:Pe.toFixed(0)})}),Ae?.remaining_prints!=null&&Ae.remaining_prints>0&&i.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:Ae.remaining_prints})})]})]}),f.target_parts_count&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.partsProgress")}),i.jsxs("span",{className:"text-sm font-medium text-white",children:[Ae?.completed_prints||0," / ",f.target_parts_count," ",n("projectDetail.progress.parts")]})]}),i.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Ue,100)}%`,backgroundColor:Ue>=100?"#22c55e":f.color||"#6b7280"}})}),i.jsxs("div",{className:"flex justify-between mt-1",children:[i.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:Ue.toFixed(0)})}),Ae?.remaining_parts!=null&&Ae.remaining_parts>0&&i.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:Ae.remaining_parts})})]})]})]})}),Ae&&i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[i.jsx(Pt,{children:i.jsx(Et,{className:"p-4",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:i.jsx(Gi,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.printJobs")}),i.jsxs("p",{className:"text-xl font-semibold text-white",children:[Ae.total_archives," ",i.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:n("projectDetail.stats.total")})]}),Ae.failed_prints>0&&i.jsx("p",{className:"text-sm text-status-error",children:n("projectDetail.stats.failed",{count:Ae.failed_prints})}),i.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.partsPrinted",{count:Ae.completed_prints})})]})]})})}),i.jsx(MY,{icon:Jn,label:n("projectDetail.stats.printTime"),value:rxe(Ae.total_print_time_hours),color:"text-yellow-400"}),i.jsx(MY,{icon:_r,label:n("projectDetail.stats.filamentUsed"),value:ltt(Ae.total_filament_grams),color:"text-purple-400"})]}),Ae&&(()=>{const je=Ae.estimated_cost+Ae.total_energy_cost+Ae.bom_cost;return Ae.estimated_cost>0||je>0||f.budget!==null})()&&i.jsx(Pt,{children:i.jsxs(Et,{className:"p-4",children:[i.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:n("projectDetail.cost.title")}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.filamentCost")}),i.jsxs("p",{className:"text-lg font-semibold text-white",children:[R,Ae.estimated_cost.toFixed(2)]})]}),Ae.total_energy_kwh>0&&i.jsxs("div",{children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.energy")}),i.jsxs("p",{className:"text-lg font-semibold text-white",children:[Ae.total_energy_kwh.toFixed(3)," kWh",Ae.total_energy_cost>0&&i.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",R,Ae.total_energy_cost.toFixed(2),")"]})]})]}),(()=>{const je=Ae.estimated_cost+Ae.total_energy_cost+Ae.bom_cost;return je<=0?null:i.jsxs("div",{children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.totalCost")}),i.jsxs("p",{className:"text-lg font-semibold text-bambu-green",children:[R,je.toFixed(2)]}),Ae.bom_cost>0&&i.jsx("p",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.cost.includesBom")})]})})(),f.budget!==null&&(()=>{const je=Ae.estimated_cost+Ae.total_energy_cost+Ae.bom_cost,Xe=f.budget-je;return i.jsxs("div",{children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.budget")}),i.jsxs("p",{className:"text-sm text-bambu-gray",children:[n("projectDetail.cost.total"),": ",i.jsxs("span",{className:"text-white font-semibold",children:[R,f.budget.toFixed(2)]})]}),i.jsxs("p",{className:`text-sm ${Xe>=0?"text-bambu-green":"text-red-400"}`,children:[n("projectDetail.cost.remaining"),": ",i.jsxs("span",{className:"font-semibold",children:[R,Xe.toFixed(2)]})]})]})})()]})]})}),f.children&&f.children.length>0&&i.jsx(Pt,{children:i.jsxs(Et,{className:"p-4",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[i.jsx(Zpe,{className:"w-5 h-5"}),n("projectDetail.subProjects.title",{count:f.children.length})]}),i.jsx("div",{className:"space-y-2",children:f.children.map(je=>i.jsxs(co,{to:`/projects/${je.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:je.color||"#6b7280"}}),i.jsx("span",{className:"text-white",children:je.name}),i.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${je.status==="completed"?"bg-status-ok/20 text-status-ok":je.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:je.status})]}),je.progress_percent!==null&&i.jsxs("span",{className:"text-sm text-bambu-gray",children:[je.progress_percent.toFixed(0),"%"]})]},je.id))})]})}),f.parent_id&&f.parent_name&&i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx(Vi,{className:"w-4 h-4 text-bambu-gray"}),i.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.partOf")}),i.jsx(co,{to:`/projects/${f.parent_id}`,className:"text-bambu-green hover:underline",children:f.parent_name})]}),(f.tags||f.due_date||f.priority!=="normal")&&i.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[f.priority&&f.priority!=="normal"&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.priorityLabel")}),i.jsx(dtt,{priority:f.priority,t:n})]}),f.due_date&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Yr,{className:"w-4 h-4 text-bambu-gray"}),i.jsx("span",{className:"text-sm text-white",children:Cf(f.due_date,{year:"numeric",month:"short",day:"numeric"})}),GD(f.due_date,n)&&i.jsxs("span",{className:`text-xs ${GD(f.due_date,n).color}`,children:["(",GD(f.due_date,n).label,")"]})]}),f.tags&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Id,{className:"w-4 h-4 text-bambu-gray"}),i.jsx("div",{className:"flex flex-wrap gap-1",children:f.tags.split(",").map((je,Xe)=>i.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:je.trim()},Xe))})]})]}),i.jsx(Pt,{children:i.jsxs(Et,{className:"p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(zs,{className:"w-5 h-5"}),n("projectDetail.notes.title")]}),c?i.jsxs("div",{className:"flex gap-2",children:[i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:W,disabled:D.isPending,children:[i.jsx(Ht,{className:"w-4 h-4 mr-1"}),n("common.cancel")]}),i.jsxs(Ie,{size:"sm",onClick:z,disabled:D.isPending,children:[D.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin mr-1"}):i.jsx(ss,{className:"w-4 h-4 mr-1"}),n("common.save")]})]}):i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:B,disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.notes.noEditPermission"),children:[i.jsx(_f,{className:"w-4 h-4 mr-1"}),n("common.edit")]})]}),c?i.jsx(hL,{content:d,onChange:m,placeholder:n("projectDetail.notes.placeholder")}):f.notes?i.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:pie.sanitize(f.notes)}}):i.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.notes.empty")})]})}),i.jsx(Pt,{children:i.jsxs(Et,{className:"p-4",children:[i.jsx("div",{className:"flex items-center justify-between mb-3",children:i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(Pc,{className:"w-5 h-5"}),n("projectDetail.files.title")]})}),i.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[i.jsx(co,{to:"/files",className:"text-bambu-green hover:underline",children:n("projectDetail.files.linkFolders")})," ",n("projectDetail.files.forQuickAccess")]}),k&&k.length>0?i.jsx("div",{className:"space-y-2",children:k.map(je=>i.jsxs(co,{to:`/files?folder=${je.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[i.jsx(Pc,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm text-white truncate",children:je.name}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("projectDetail.files.fileCount",{count:je.file_count})})]})]}),i.jsx(fa,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},je.id))}):i.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.files.empty")})]})}),i.jsx(Pt,{children:i.jsxs(Et,{className:"p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(XX,{className:"w-5 h-5"}),n("projectDetail.bom.title"),Ae&&Ae.bom_total_items>0&&i.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",n("projectDetail.bom.acquired",{completed:Ae.bom_completed_items,total:Ae.bom_total_items}),")"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[_&&_.some(je=>je.is_complete)&&i.jsx("button",{onClick:()=>Z(!q),className:`text-xs px-2 py-1 rounded transition-colors ${q?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:n(q?"projectDetail.bom.showAll":"projectDetail.bom.hideDone")}),!be&&i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>Me(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noAddPermission"),children:[i.jsx(ar,{className:"w-4 h-4 mr-1"}),n("projectDetail.bom.addPart")]})]})]}),be&&i.jsxs("form",{onSubmit:te,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[i.jsx("input",{type:"text",value:I,onChange:je=>J(je.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.partNamePlaceholder"),autoFocus:!0}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"number",value:ie,onChange:je=>Q(parseInt(je.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:n("projectDetail.bom.qty")}),i.jsx("input",{type:"number",step:"0.01",value:ue,onChange:je=>me(je.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.price",{currency:R})})]})]}),i.jsx("input",{type:"url",value:pe,onChange:je=>Y(je.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.sourcingUrlPlaceholder")}),i.jsx("input",{type:"text",value:se,onChange:je=>oe(je.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.remarksPlaceholder")}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",size:"sm",onClick:()=>Me(!1),children:n("common.cancel")}),i.jsx(Ie,{type:"submit",size:"sm",disabled:!I.trim()||ae.isPending,children:ae.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):n("projectDetail.bom.addPart")})]})]}),N?i.jsx("div",{className:"flex items-center justify-center py-4",children:i.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):_&&_.length>0?i.jsxs("div",{className:"space-y-2",children:[_.filter(je=>!q||!je.is_complete).map(je=>i.jsx("div",{className:`p-3 rounded-lg transition-colors ${je.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:j?.id===je.id?i.jsxs("form",{onSubmit:ke,className:"space-y-3",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[i.jsx("input",{type:"text",value:U,onChange:Xe=>K(Xe.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.partName"),autoFocus:!0}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"number",value:$,onChange:Xe=>ne(parseInt(Xe.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:n("projectDetail.bom.qty")}),i.jsx("input",{type:"number",step:"0.01",value:O,onChange:Xe=>V(Xe.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.price",{currency:R})})]})]}),i.jsx("input",{type:"url",value:ee,onChange:Xe=>G(Xe.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.sourcingUrlPlaceholder")}),i.jsx("input",{type:"text",value:re,onChange:Xe=>ce(Xe.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.remarksPlaceholder")}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",size:"sm",onClick:_e,children:n("common.cancel")}),i.jsx(Ie,{type:"submit",size:"sm",disabled:!U.trim()||L.isPending,children:L.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):n("common.save")})]})]}):i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("button",{onClick:()=>s("projects:update")&&ve(je),disabled:L.isPending||!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noUpdatePermission"),className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${je.is_complete?"bg-status-ok border-status-ok text-white":s("projects:update")?"border-bambu-gray hover:border-bambu-green":"border-bambu-gray/50 cursor-not-allowed"}`,children:je.is_complete&&i.jsx(fr,{className:"w-3 h-3"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i.jsxs("p",{className:`text-sm font-medium ${je.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[je.name,i.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",je.quantity_needed]})]}),je.unit_price!==null&&i.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[R,(je.unit_price*je.quantity_needed).toFixed(2)]})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{onClick:()=>s("projects:update")&&de(je),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.edit"):n("projectDetail.bom.noEditPermission"),children:i.jsx(Ki,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>s("projects:update")&&he(je.id,je.name),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.delete"):n("projectDetail.bom.noDeletePermission"),children:i.jsx(en,{className:"w-4 h-4"})})]})]}),je.sourcing_url&&i.jsxs("a",{href:je.sourcing_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-1 text-xs text-blue-400 hover:text-blue-300 transition-colors",onClick:Xe=>Xe.stopPropagation(),children:[i.jsx(ti,{className:"w-3 h-3 flex-shrink-0"}),i.jsx("span",{className:"truncate",children:(()=>{try{return new URL(je.sourcing_url).hostname.replace("www.","")}catch{return je.sourcing_url}})()})]}),je.remarks&&i.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:je.remarks})]})]})},je.id)),Ae&&Ae.bom_cost>0&&i.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[i.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.bom.totalCost")}),i.jsxs("span",{className:"text-white font-medium",children:[R,Ae.bom_cost.toFixed(2)]})]})]}):i.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.bom.empty")})]})}),i.jsx(Pt,{children:i.jsxs(Et,{className:"p-4",children:[i.jsx("div",{className:"flex items-center justify-between mb-3",children:i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(x0,{className:"w-5 h-5"}),n("projectDetail.timeline.title")]})}),C?i.jsx("div",{className:"flex items-center justify-center py-4",children:i.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):T&&T.length>0?i.jsx("div",{className:"space-y-3",children:T.slice(0,10).map((je,Xe)=>i.jsxs("div",{className:"flex gap-3",children:[i.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${je.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":je.event_type==="print_failed"?"bg-status-error/20 text-status-error":je.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[je.event_type==="print_completed"&&i.jsx(fr,{className:"w-4 h-4"}),je.event_type==="print_failed"&&i.jsx(qi,{className:"w-4 h-4"}),je.event_type==="print_started"&&i.jsx(_r,{className:"w-4 h-4"}),je.event_type==="queued"&&i.jsx(y3,{className:"w-4 h-4"}),je.event_type==="project_created"&&i.jsx(ar,{className:"w-4 h-4"})]}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-sm text-white",children:je.title}),je.description&&i.jsx("p",{className:"text-xs text-bambu-gray truncate",children:je.description}),i.jsx("p",{className:"text-xs text-bambu-gray/70",children:Re(je.timestamp)})]})]},Xe))}):i.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.timeline.empty")})]})}),!f.is_template&&i.jsx("div",{className:"flex justify-end",children:i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>$e.mutate(),disabled:$e.isPending||!s("projects:create"),title:s("projects:create")?void 0:n("projectDetail.template.noCreatePermission"),children:[$e.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}):i.jsx(vo,{className:"w-4 h-4 mr-2"}),n("projectDetail.template.saveAsTemplate")]})}),Ae&&(Ae.queued_prints>0||Ae.in_progress_prints>0)&&i.jsx(Pt,{children:i.jsxs(Et,{className:"p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(y3,{className:"w-5 h-5"}),n("projectDetail.queue.title")]}),i.jsx(co,{to:`/queue?project=${p}`,className:"text-sm text-bambu-green hover:underline",children:n("projectDetail.queue.viewAll")})]}),i.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[Ae.in_progress_prints>0&&i.jsx("span",{className:"text-yellow-400",children:n("projectDetail.queue.printing",{count:Ae.in_progress_prints})}),Ae.queued_prints>0&&i.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.queue.queued",{count:Ae.queued_prints})})]})]})}),i.jsxs("div",{children:[i.jsx("div",{className:"flex items-center justify-between mb-4",children:i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(Gi,{className:"w-5 h-5"}),n("projectDetail.prints.title",{count:b?.length||0})]})}),g?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):i.jsx(utt,{archives:b||[],t:n})]}),o&&i.jsx(Hoe,{t:n,currencySymbol:R,project:{...f,archive_count:Ae?.total_archives||0,total_items:Ae?.total_items||0,completed_count:Ae?.completed_prints||0,failed_count:Ae?.failed_prints||0,queue_count:Ae?.queued_prints||0,progress_percent:Ae?.progress_percent||null,archives:[]},onClose:()=>l(!1),onSave:je=>D.mutate(je),isLoading:D.isPending}),ge.isOpen&&i.jsx(_n,{title:ge.title,message:ge.message,confirmText:n("common.delete"),variant:"danger",onConfirm:ge.onConfirm,onCancel:()=>xe(je=>({...je,isOpen:!1}))})]})}function htt({parentId:t,onClose:e,onSave:n,isLoading:r,t:a}){const[s,o]=w.useState(""),l=c=>{c.preventDefault(),n({name:s.trim(),parent_id:t})};return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[i.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:a("fileManager.newFolder")})}),i.jsxs("form",{onSubmit:l,className:"p-4 space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:a("fileManager.folderName")}),i.jsx("input",{type:"text",value:s,onChange:c=>o(c.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:a("fileManager.folderNamePlaceholder"),autoFocus:!0,required:!0})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:e,children:a("common.cancel")}),i.jsx(Ie,{type:"submit",disabled:!s.trim()||r,children:r?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):a("common.create")})]})]})]})})}function ptt({type:t,currentName:e,onClose:n,onSave:r,isLoading:a,t:s}){const[o,l]=w.useState(e),c=u=>{u.preventDefault(),o.trim()&&o.trim()!==e&&r(o.trim())};return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[i.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:s(t==="file"?"fileManager.renameFile":"fileManager.renameFolder")})}),i.jsxs("form",{onSubmit:c,className:"p-4 space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("common.name")}),i.jsx("input",{type:"text",value:o,onChange:u=>l(u.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",autoFocus:!0,required:!0})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:n,children:s("common.cancel")}),i.jsx(Ie,{type:"submit",disabled:!o.trim()||o.trim()===e||a,children:a?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):s("common.rename")})]})]})]})})}function ftt({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:a,isLoading:s,t:o}){const[l,c]=w.useState(null),u=(m,p=0)=>{const f=[];for(const y of m)f.push({id:y.id,name:y.name,depth:p}),y.children.length>0&&f.push(...u(y.children,p+1));return f},d=[{id:null,name:o("fileManager.rootNoFolder"),depth:0},...u(t)];return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[i.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:o("fileManager.moveFiles",{count:e.length})})}),i.jsxs("div",{className:"p-4 space-y-4",children:[i.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:d.map(m=>i.jsxs("button",{onClick:()=>c(m.id),disabled:m.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===m.id?"bg-bambu-green/20 text-bambu-green":m.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+m.depth*16}px`},children:[i.jsx(Pc,{className:"w-4 h-4"}),m.name,m.id===n&&i.jsxs("span",{className:"text-xs text-bambu-gray ml-auto",children:["(",o("fileManager.current"),")"]})]},m.id??"root"))}),i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:r,children:o("common.cancel")}),i.jsx(Ie,{onClick:()=>a(l),disabled:s,children:s?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):o("common.move")})]})]})]})})}function gtt({folder:t,onClose:e,onLink:n,isLoading:r,t:a}){const[s,o]=w.useState("project"),[l,c]=w.useState(t.project_id||t.archive_id||null);w.useState(()=>{t.archive_id&&o("archive")});const{data:u}=tt({queryKey:["projects"],queryFn:()=>fe.getProjects()}),{data:d}=tt({queryKey:["archives-for-link"],queryFn:()=>fe.getArchives(void 0,void 0,100)}),m=()=>{n(s==="project"?{project_id:l,archive_id:0}:{project_id:0,archive_id:l})},p=()=>{n({project_id:0,archive_id:0})},f=t.project_id||t.archive_id;return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(_h,{className:"w-5 h-5 text-bambu-green"}),a("fileManager.linkFolder")]}),i.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:i.jsx(Ht,{className:"w-5 h-5 text-bambu-gray"})})]}),i.jsxs("div",{className:"p-4 space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:a("fileManager.linkFolderDescription",{name:t.name})}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("button",{onClick:()=>{o("project"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${s==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[i.jsx(zX,{className:"w-4 h-4"}),a("fileManager.project")]}),i.jsxs("button",{onClick:()=>{o("archive"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${s==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[i.jsx($s,{className:"w-4 h-4"}),a("fileManager.archive")]})]}),i.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:s==="project"?u&&u.length>0?u.map(y=>i.jsxs("button",{onClick:()=>c(y.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===y.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[i.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:y.color||"#00ae42"}}),i.jsx("span",{className:"truncate",children:y.name})]},y.id)):i.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:a("fileManager.noProjectsFound")}):d&&d.length>0?d.map(y=>i.jsxs("button",{onClick:()=>c(y.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===y.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[i.jsx(sf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),i.jsx("span",{className:"truncate",children:y.print_name||y.filename})]},y.id)):i.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:a("fileManager.noArchivesFound")})})]}),i.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[f&&i.jsxs(Ie,{variant:"danger",onClick:p,disabled:r,children:[i.jsx(y0,{className:"w-4 h-4 mr-2"}),a("fileManager.unlink")]}),i.jsxs("div",{className:`flex gap-2 ${f?"":"ml-auto"}`,children:[i.jsx(Ie,{variant:"secondary",onClick:e,children:a("common.cancel")}),i.jsx(Ie,{onClick:m,disabled:!l||r,children:r?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):a("fileManager.link")})]})]})]})})}function $oe({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:a,onRename:s,depth:o=0,wrapNames:l=!1,hasPermission:c,t:u}){const[d,m]=w.useState(!0),[p,f]=w.useState(!1),y=t.children.length>0,v=t.project_id||t.archive_id;return i.jsxs("div",{children:[i.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${e===t.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${8+o*12}px`},onClick:()=>n(t.id),children:[y?i.jsx("button",{onClick:b=>{b.stopPropagation(),m(!d)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:i.jsx(fa,{className:`w-3.5 h-3.5 transition-transform ${d?"rotate-90":""}`})}):i.jsx("div",{className:"w-4.5"}),i.jsx(Pc,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),i.jsx("span",{className:`text-sm flex-1 min-w-0 ${l?"break-all":"truncate"}`,title:t.name,children:t.name}),v&&i.jsxs("button",{onClick:b=>{b.stopPropagation(),a(t)},className:"flex-shrink-0 flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",title:`${t.project_name?`Project: ${t.project_name}`:`Archive: ${t.archive_name}`} (click to change)`,children:[i.jsx(_h,{className:"w-3 h-3"}),t.project_name?i.jsx(zX,{className:"w-3 h-3"}):i.jsx($s,{className:"w-3 h-3"})]}),t.file_count>0&&i.jsx("span",{className:"flex-shrink-0 text-xs text-bambu-gray",children:t.file_count}),!v&&i.jsx("button",{onClick:b=>{b.stopPropagation(),a(t)},className:"flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary",title:u("fileManager.linkToProjectOrArchive"),children:i.jsx(_h,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),i.jsx("div",{className:`flex-shrink-0 flex items-center gap-0.5 transition-opacity ${l?"":"opacity-0 group-hover:opacity-100"}`,onClick:b=>b.stopPropagation(),children:i.jsxs("div",{className:"relative",children:[i.jsx("button",{onClick:()=>f(!p),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:i.jsx(yh,{className:"w-3.5 h-3.5 text-bambu-gray"})}),p&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>f(!1)}),i.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(s(t),f(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionRenameFolder"),children:[i.jsx(Ki,{className:"w-3.5 h-3.5"}),u("common.rename")]}),i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(a(t),f(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionLinkFolder"),children:[i.jsx(_h,{className:"w-3.5 h-3.5"}),u(v?"fileManager.changeLink":"fileManager.linkTo")]}),i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:delete_all")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:delete_all")&&(r(t.id),f(!1))},disabled:!c("library:delete_all"),title:c("library:delete_all")?void 0:u("fileManager.noPermissionDeleteFolder"),children:[i.jsx(en,{className:"w-3.5 h-3.5"}),u("common.delete")]})]})]})]})})]}),y&&d&&i.jsx("div",{children:t.children.map(b=>i.jsx($oe,{folder:b,selectedFolderId:e,onSelect:n,onDelete:r,onLink:a,onRename:s,depth:o+1,wrapNames:l,hasPermission:c,t:u},b.id))})]})}function wL(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function btt({file:t,isSelected:e,isMobile:n,onSelect:r,onDelete:a,onDownload:s,onAddToQueue:o,onPrint:l,onPreview3d:c,onRename:u,onGenerateThumbnail:d,thumbnailVersion:m,hasPermission:p,canModify:f,authEnabled:y,t:v}){const[b,g]=w.useState(!1);return i.jsxs("div",{className:`group relative bg-bambu-dark-secondary rounded-lg border transition-all cursor-pointer overflow-hidden ${e?"border-bambu-green ring-1 ring-bambu-green":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,onClick:()=>r(t.id),children:[i.jsxs("div",{className:"aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden",children:[t.thumbnail_path?i.jsx("img",{src:`${fe.getLibraryFileThumbnailUrl(t.id)}${m?`?v=${m}`:""}`,alt:t.filename,className:"w-full h-full object-cover"}):i.jsx(sf,{className:"w-12 h-12 text-bambu-gray/30"}),i.jsx("div",{className:`absolute top-2 right-2 text-xs px-1.5 py-0.5 rounded font-medium ${t.file_type==="3mf"?"bg-bambu-green/90 text-white":t.file_type==="gcode"?"bg-blue-500/90 text-white":t.file_type==="stl"?"bg-purple-500/90 text-white":"bg-bambu-gray/90 text-white"}`,children:t.file_type.toUpperCase()})]}),i.jsxs("div",{className:"p-3",children:[i.jsx("h3",{className:"text-sm font-medium text-white truncate",title:t.print_name||t.filename,children:t.print_name||t.filename}),i.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-bambu-gray",children:[i.jsx("span",{children:ho(t.file_size)}),t.print_time_seconds&&i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Jn,{className:"w-3 h-3"}),Is(t.print_time_seconds)]})]}),t.sliced_for_model&&i.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[i.jsx(_r,{className:"w-3 h-3"}),t.sliced_for_model]}),t.print_count>0&&i.jsx("div",{className:"mt-1 text-xs text-bambu-green",children:v("fileManager.printedCount",{count:t.print_count})}),y&&t.created_by_username&&i.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[i.jsx(zd,{className:"w-3 h-3"}),t.created_by_username]})]}),i.jsxs("div",{className:`absolute bottom-2 right-2 transition-opacity ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:_=>_.stopPropagation(),children:[i.jsx("button",{onClick:()=>g(!b),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:i.jsx(yh,{className:"w-4 h-4 text-bambu-gray"})}),b&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>g(!1)}),i.jsxs("div",{className:"absolute right-0 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]",children:[l&&wL(t.filename)&&i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("printers:control")?"text-bambu-green hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("printers:control")&&(l(t),g(!1))},disabled:!p("printers:control"),title:p("printers:control")?void 0:v("fileManager.noPermissionPrint"),children:[i.jsx(_r,{className:"w-3.5 h-3.5"}),v("common.print")]}),o&&wL(t.filename)&&i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("queue:create")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("queue:create")&&(o(t.id),g(!1))},disabled:!p("queue:create"),title:p("queue:create")?void 0:v("fileManager.noPermissionAddToQueue"),children:[i.jsx(Jn,{className:"w-3.5 h-3.5"}),v("fileManager.schedulePrint")]}),c&&(t.file_type==="3mf"||t.file_type==="gcode"||t.file_type==="stl")&&i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library:read")&&(c(t),g(!1))},disabled:!p("library:read"),title:p("library:read")?void 0:"You do not have permission to preview files",children:[i.jsx(na,{className:"w-3.5 h-3.5"}),"3D Preview"]}),i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library:read")&&(s(t.id),g(!1))},disabled:!p("library:read"),title:p("library:read")?void 0:v("fileManager.noPermissionDownload"),children:[i.jsx(bi,{className:"w-3.5 h-3.5"}),v("common.download")]}),u&&i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library","update",t.created_by_id)&&(u(t),g(!1))},disabled:!f("library","update",t.created_by_id),title:f("library","update",t.created_by_id)?void 0:v("fileManager.noPermissionRenameFile"),children:[i.jsx(Ki,{className:"w-3.5 h-3.5"}),v("common.rename")]}),d&&t.file_type==="stl"&&i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library","update",t.created_by_id)&&(d(t),g(!1))},disabled:!f("library","update",t.created_by_id),title:f("library","update",t.created_by_id)?void 0:v("fileManager.noPermissionGenerateThumbnail"),children:[i.jsx(Ld,{className:"w-3.5 h-3.5"}),v("fileManager.generateThumbnail")]}),i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library","delete",t.created_by_id)?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library","delete",t.created_by_id)&&(a(t.id),g(!1))},disabled:!f("library","delete",t.created_by_id),title:f("library","delete",t.created_by_id)?void 0:v("fileManager.noPermissionDeleteFile"),children:[i.jsx(en,{className:"w-3.5 h-3.5"}),v("common.delete")]})]})]})]}),i.jsx("div",{className:`absolute top-2 left-2 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${e?"bg-bambu-green border-bambu-green":`border-white/30 bg-black/30 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}`,children:e&&i.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function xtt(){const{t}=Rt(),e=sn(),{showToast:n}=fn(),{hasPermission:r,hasAnyPermission:a,canModify:s,authEnabled:o}=Nr(),[l]=jL(),c=l.get("folder"),u=c?parseInt(c,10):null,[d,m]=w.useState(u),[p,f]=w.useState([]),[y,v]=w.useState(!1),[b,g]=w.useState(!1),[_,N]=w.useState(!1),[T,C]=w.useState(null),[P,k]=w.useState(null),[R,A]=w.useState(null),[D,B]=w.useState(null),[z,W]=w.useState(null),[I,J]=w.useState(null),[ie,Q]=w.useState({}),[ue,me]=w.useState(null),[pe,Y]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[se,oe]=w.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[be,Me]=w.useState(()=>{const qe=localStorage.getItem("library-sidebar-width");return qe?parseInt(qe,10):256}),[q,Z]=w.useState(!1),j=w.useRef(null);w.useEffect(()=>{if(!q)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const qe=Nt=>{if(!j.current)return;const mt=j.current.parentElement?.getBoundingClientRect();if(!mt)return;const jt=Nt.clientX-mt.left,qt=Math.min(500,Math.max(200,jt));Me(qt)},_t=()=>{Z(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(be))};return document.addEventListener("mousemove",qe),document.addEventListener("mouseup",_t),()=>{document.removeEventListener("mousemove",qe),document.removeEventListener("mouseup",_t),document.body.style.userSelect="",document.body.style.cursor=""}},[q,be]);const[E,U]=w.useState(""),[K,$]=w.useState("all"),[ne,O]=w.useState(""),[V,ee]=w.useState(()=>localStorage.getItem("library-sort-field")||"name"),[G,re]=w.useState(()=>localStorage.getItem("library-sort-direction")||"asc"),ce=aie();w.useEffect(()=>{const qe=l.get("folder");if(qe){const _t=parseInt(qe,10);m(_t)}},[l]);const{data:ge}=tt({queryKey:["settings"],queryFn:()=>fe.getSettings()}),{data:xe,isLoading:ae}=tt({queryKey:["library-folders"],queryFn:()=>fe.getLibraryFolders()}),{data:L,isLoading:F}=tt({queryKey:["library-files",d],queryFn:()=>fe.getLibraryFiles(d,d===null)}),{data:te}=tt({queryKey:["library-stats"],queryFn:()=>fe.getLibraryStats()}),{data:ve}=tt({queryKey:["users"],queryFn:()=>fe.getUsers()}),he=w.useMemo(()=>{if(!L)return[];const qe=new Set(L.map(_t=>_t.file_type));return Array.from(qe).sort()},[L]),de=w.useMemo(()=>{if(!L)return[];let qe=[...L];if(E.trim()){const _t=E.toLowerCase();qe=qe.filter(Nt=>Nt.filename.toLowerCase().includes(_t)||Nt.print_name&&Nt.print_name.toLowerCase().includes(_t))}if(K!=="all"&&(qe=qe.filter(_t=>_t.file_type===K)),ne.trim()){const _t=ne.toLowerCase();qe=qe.filter(Nt=>Nt.created_by_username&&Nt.created_by_username.toLowerCase().includes(_t))}return qe.sort((_t,Nt)=>{let mt=0;switch(V){case"name":mt=(_t.print_name||_t.filename).localeCompare(Nt.print_name||Nt.filename);break;case"date":mt=(Zn(_t.created_at)?.getTime()??0)-(Zn(Nt.created_at)?.getTime()??0);break;case"size":mt=_t.file_size-Nt.file_size;break;case"type":mt=_t.file_type.localeCompare(Nt.file_type);break;case"prints":mt=_t.print_count-Nt.print_count;break}return G==="asc"?mt:-mt}),qe},[L,E,K,ne,V,G]),ke=w.useMemo(()=>{if(!te||!ge)return!1;const qe=(ge.library_disk_warning_gb||5)*1024*1024*1024;return te.disk_free_bytesfe.createLibraryFolder(qe),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),v(!1),n(t("fileManager.toast.folderCreated"),"success")},onError:qe=>n(qe.message,"error")}),Le=ft({mutationFn:qe=>fe.deleteLibraryFolder(qe),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-stats"]}),d===P?.id&&m(null),k(null),n(t("fileManager.toast.folderDeleted"),"success")},onError:qe=>{k(null),n(qe.message,"error")}}),$e=ft({mutationFn:qe=>fe.deleteLibraryFile(qe),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),f(qe=>qe.filter(_t=>_t!==P?.id)),k(null),n(t("fileManager.toast.fileDeleted"),"success")},onError:qe=>{k(null),n(qe.message,"error")}}),Re=ft({mutationFn:qe=>fe.bulkDeleteLibrary(qe,[]),onSuccess:(qe,_t)=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),n(t("fileManager.toast.filesDeleted",{count:_t.length}),"success"),f([]),k(null)},onError:qe=>{k(null),n(qe.message,"error")}}),Ae=ft({mutationFn:({fileIds:qe,folderId:_t})=>fe.moveLibraryFiles(qe,_t),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),f([]),g(!1),n(t("fileManager.toast.filesMoved"),"success")},onError:qe=>n(qe.message,"error")}),Pe=ft({mutationFn:({id:qe,data:_t})=>fe.updateLibraryFolder(qe,_t),onSuccess:(qe,_t)=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["project-folders"]}),e.invalidateQueries({queryKey:["archive-folders"]}),C(null);const Nt=_t.data.project_id===0&&_t.data.archive_id===0;n(t(Nt?"fileManager.toast.folderUnlinked":"fileManager.toast.folderLinked"),"success")},onError:qe=>n(qe.message,"error")}),Ue=ft({mutationFn:({id:qe,filename:_t})=>fe.updateLibraryFile(qe,{filename:_t}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),J(null),n(t("fileManager.toast.fileRenamed"),"success")},onError:qe=>{J(null),n(qe.message,"error")}}),je=ft({mutationFn:({id:qe,name:_t})=>fe.updateLibraryFolder(qe,{name:_t}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),J(null),n(t("fileManager.toast.folderRenamed"),"success")},onError:qe=>{J(null),n(qe.message,"error")}}),Xe=ft({mutationFn:()=>fe.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:qe=>{if(e.invalidateQueries({queryKey:["library-files"]}),qe.succeeded>0){const _t=Date.now(),Nt={};qe.results.forEach(mt=>{mt.success&&(Nt[mt.file_id]=_t)}),Q(mt=>({...mt,...Nt}))}qe.succeeded>0&&qe.failed===0?n(t("fileManager.toast.thumbnailsGenerated",{count:qe.succeeded}),"success"):qe.succeeded>0&&qe.failed>0?n(t("fileManager.toast.thumbnailsGeneratedPartial",{succeeded:qe.succeeded,failed:qe.failed}),"success"):qe.processed===0?n(t("fileManager.toast.noStlMissingThumbnails"),"info"):n(t("fileManager.toast.failedToGenerateThumbnails",{error:qe.results[0]?.error||"Unknown error"}),"error")},onError:qe=>n(qe.message,"error")}),ye=ft({mutationFn:qe=>fe.batchGenerateStlThumbnails({file_ids:[qe]}),onSuccess:qe=>{if(e.invalidateQueries({queryKey:["library-files"]}),qe.succeeded>0){const _t=qe.results[0]?.file_id;_t&&Q(Nt=>({...Nt,[_t]:Date.now()})),n(t("fileManager.toast.thumbnailGenerated"),"success")}else n(t("fileManager.toast.failedToGenerateThumbnail",{error:qe.results[0]?.error||"Unknown error"}),"error")},onError:qe=>n(qe.message,"error")}),Ge=w.useCallback(qe=>{const _t=qe.toLowerCase();return _t.endsWith(".gcode")||_t.includes(".gcode.")},[]),Ee=w.useMemo(()=>L?L.filter(qe=>p.includes(qe.id)&&Ge(qe.filename)):[],[L,p,Ge]),Ke=w.useCallback(qe=>{f(_t=>_t.includes(qe)?_t.filter(Nt=>Nt!==qe):[..._t,qe])},[]),Ve=w.useCallback(()=>{de.length>0&&f(de.map(qe=>qe.id))},[de]),Ne=w.useCallback(()=>{f([])},[]),Ce=()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]})},He=qe=>{fe.downloadLibraryFile(qe).catch(_t=>{console.error("Library file download failed:",_t)})},et=()=>{P&&(P.type==="file"?$e.mutate(P.id):P.type==="folder"?Le.mutate(P.id):P.type==="bulk"&&Re.mutate(p))},it=Le.isPending||$e.isPending||Re.isPending,xt=qe=>{Y(qe),localStorage.setItem("library-view-mode",qe)},vt=ae||F;return i.jsxs("div",{className:"p-4 md:p-8 min-h-[calc(100vh-64px)] lg:h-[calc(100vh-64px)] flex flex-col",children:[i.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[i.jsxs("div",{children:[i.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[i.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:i.jsx(Pc,{className:"w-6 h-6 text-bambu-green"})}),t("fileManager.title")]}),i.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("fileManager.subtitle")})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"flex items-center bg-bambu-dark rounded-lg p-1",children:[i.jsx("button",{onClick:()=>xt("grid"),className:`p-1.5 rounded transition-colors ${pe==="grid"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.gridView"),children:i.jsx(xw,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>xt("list"),className:`p-1.5 rounded transition-colors ${pe==="list"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.listView"),children:i.jsx(eT,{className:"w-4 h-4"})})]}),i.jsxs(Ie,{variant:"secondary",onClick:()=>Xe.mutate(),disabled:Xe.isPending||!a("library:update_own","library:update_all"),title:a("library:update_own","library:update_all")?t("fileManager.generateThumbnailsForMissing"):t("fileManager.noPermissionGenerateThumbnail"),children:[Xe.isPending?i.jsx(pt,{className:"w-4 h-4 mr-2 animate-spin"}):i.jsx(Ld,{className:"w-4 h-4 mr-2"}),t("fileManager.generateThumbnails")]}),i.jsxs(Ie,{variant:"secondary",onClick:()=>v(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionCreateFolder"),children:[i.jsx(Xpe,{className:"w-4 h-4 mr-2"}),t("fileManager.newFolder")]}),i.jsxs(Ie,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[i.jsx(vi,{className:"w-4 h-4 mr-2"}),t("common.upload")]})]})]}),ke&&te&&ge&&i.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[i.jsx(Mn,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),i.jsxs("div",{className:"flex-1",children:[i.jsx("p",{className:"text-sm text-amber-500 font-medium",children:t("fileManager.lowDiskSpaceWarning")}),i.jsx("p",{className:"text-xs text-amber-500/80",children:t("fileManager.lowDiskSpaceDetails",{free:ho(te.disk_free_bytes),total:ho(te.disk_total_bytes),threshold:ge.library_disk_warning_gb})})]})]}),te&&i.jsxs("div",{className:"flex flex-wrap items-center gap-3 sm:gap-6 mb-6 p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx(ZC,{className:"w-4 h-4 text-bambu-green"}),i.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.files"),":"]}),i.jsx("span",{className:"text-white font-medium",children:te.total_files})]}),i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx(Pc,{className:"w-4 h-4 text-blue-400"}),i.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.folders"),":"]}),i.jsx("span",{className:"text-white font-medium",children:te.total_folders})]}),i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx(Ix,{className:"w-4 h-4 text-amber-400"}),i.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.size"),":"]}),i.jsx("span",{className:"text-white font-medium",children:ho(te.total_size_bytes)})]}),i.jsxs("div",{className:"flex items-center gap-2 text-sm sm:ml-auto",children:[i.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.free"),":"]}),i.jsx("span",{className:`font-medium ${ke?"text-amber-500":"text-white"}`,children:ho(te.disk_free_bytes)})]})]}),i.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-4 lg:gap-6 min-h-0",children:[i.jsx("div",{className:"lg:hidden",children:i.jsxs("select",{value:d??"",onChange:qe=>m(qe.target.value?parseInt(qe.target.value,10):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg px-3 py-2.5 text-white focus:outline-none focus:border-bambu-green",children:[i.jsxs("option",{value:"",children:["📁 ",t("fileManager.allFiles")]}),xe&&(()=>{const qe=(_t,Nt=0)=>{const mt=[];for(const jt of _t)mt.push({id:jt.id,name:jt.name,fileCount:jt.file_count,depth:Nt}),jt.children.length>0&&mt.push(...qe(jt.children,Nt+1));return mt};return qe(xe).map(_t=>i.jsxs("option",{value:_t.id,children:["│ ".repeat(_t.depth),"📂 ",_t.name," ",_t.fileCount>0?`(${_t.fileCount})`:""]},_t.id))})()]})}),i.jsxs("div",{ref:j,className:"hidden lg:flex flex-shrink-0 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden flex-col relative",style:{width:`${be}px`},children:[i.jsx("div",{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 group/resize flex items-center justify-center transition-colors ${q?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:qe=>{qe.preventDefault(),Z(!0)},onDoubleClick:()=>{Me(256),localStorage.setItem("library-sidebar-width","256")},title:t("fileManager.dragToResizeTooltip"),children:i.jsxs("div",{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${q?"opacity-100":""}`,children:[i.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),i.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),i.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"})]})}),i.jsxs("div",{className:"p-3 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[i.jsx("h2",{className:"text-sm font-medium text-white",children:t("fileManager.folders")}),i.jsx("button",{onClick:()=>{const qe=!se;oe(qe),localStorage.setItem("library-wrap-folders",String(qe))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${se?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:t(se?"fileManager.disableTextWrapping":"fileManager.enableTextWrapping"),children:t("fileManager.wrap")})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[i.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${d===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>m(null),children:[i.jsx(sf,{className:"w-4 h-4"}),i.jsx("span",{className:"text-sm",children:t("fileManager.allFiles")})]}),xe?.map(qe=>i.jsx($oe,{folder:qe,selectedFolderId:d,onSelect:m,onDelete:_t=>k({type:"folder",id:_t}),onLink:C,onRename:_t=>J({type:"folder",id:_t.id,name:_t.name}),wrapNames:se,hasPermission:r,t},qe.id))]})]}),i.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[L&&L.length>0&&i.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mb-4 p-2 sm:p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-0 z-10 lg:static",children:[i.jsxs("div",{className:"relative w-full sm:w-auto sm:flex-1 sm:max-w-xs",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),i.jsx("input",{type:"text",placeholder:t("fileManager.searchFiles"),value:E,onChange:qe=>U(qe.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(JC,{className:"w-4 h-4 text-bambu-gray hidden sm:block"}),i.jsxs("select",{value:K,onChange:qe=>$(qe.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[i.jsx("option",{value:"all",children:t("fileManager.allTypes")}),he.map(qe=>i.jsx("option",{value:qe,children:qe.toUpperCase()},qe))]})]}),o&&i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:"text",placeholder:t("fileManager.filterByUser",{defaultValue:"Filter by user"}),value:ne,onChange:qe=>O(qe.target.value),list:"usernames-list",className:`w-32 sm:w-40 px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green ${ne?"pr-7":""}`,style:ne?{WebkitAppearance:"none",MozAppearance:"textfield"}:void 0}),ne&&i.jsx("button",{onClick:()=>O(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white z-10",children:i.jsx(Ht,{className:"w-3 h-3"})}),i.jsx("datalist",{id:"usernames-list",children:ve?.map(qe=>i.jsx("option",{value:qe.username},qe.id))})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("select",{value:V,onChange:qe=>{const _t=qe.target.value;ee(_t),localStorage.setItem("library-sort-field",_t)},className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[i.jsx("option",{value:"name",children:t("common.name")}),i.jsx("option",{value:"date",children:t("common.date")}),i.jsx("option",{value:"size",children:t("fileManager.size")}),i.jsx("option",{value:"type",children:t("common.type")}),i.jsx("option",{value:"prints",children:t("fileManager.prints")})]}),i.jsx("button",{onClick:()=>re(qe=>{const _t=qe==="asc"?"desc":"asc";return localStorage.setItem("library-sort-direction",_t),_t}),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:t(G==="asc"?"fileManager.ascending":"fileManager.descending"),children:G==="asc"?i.jsx(ghe,{className:"w-4 h-4 text-white"}):i.jsx(che,{className:"w-4 h-4 text-white"})})]}),(E||K!=="all"||ne)&&i.jsx("span",{className:"text-sm text-bambu-gray hidden sm:inline",children:t("fileManager.resultsCount",{showing:de.length,total:L.length})})]}),de.length>0&&i.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4 p-2 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-[52px] z-10 lg:static",children:[p.length===de.length&&p.length>0?i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:Ne,children:[i.jsx(ql,{className:"w-4 h-4 sm:mr-1"}),i.jsx("span",{className:"hidden sm:inline",children:t("fileManager.deselectAll")})]}):i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:Ve,children:[i.jsx(_o,{className:"w-4 h-4 sm:mr-1"}),i.jsx("span",{className:"hidden sm:inline",children:t("fileManager.selectAll")})]}),p.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-sm text-bambu-gray ml-2",children:t("fileManager.selected",{count:p.length})}),i.jsx("div",{className:"hidden sm:block flex-1"}),i.jsxs("div",{className:"w-full sm:w-auto flex flex-wrap items-center gap-2 mt-2 sm:mt-0",children:[Ee.length===1&&i.jsxs(Ie,{variant:"primary",size:"sm",onClick:()=>B(Ee[0]),disabled:!r("printers:control"),title:r("printers:control")?void 0:t("fileManager.noPermissionPrint"),children:[i.jsx(wo,{className:"w-4 h-4 sm:mr-1"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.print")})]}),Ee.length===1&&i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>W(Ee[0]),disabled:!r("queue:create"),title:r("queue:create")?void 0:t("fileManager.noPermissionAddToQueue"),children:[i.jsx(Jn,{className:"w-4 h-4 sm:mr-1"}),i.jsx("span",{className:"hidden sm:inline",children:t("fileManager.schedulePrint")})]}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>g(!0),disabled:!a("library:update_own","library:update_all"),title:a("library:update_own","library:update_all")?void 0:t("fileManager.noPermissionMoveFiles"),children:[i.jsx(sge,{className:"w-4 h-4 sm:mr-1"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.move")})]}),i.jsxs(Ie,{variant:"danger",size:"sm",onClick:()=>{p.length===1?k({type:"file",id:p[0]}):k({type:"bulk",id:0,count:p.length})},disabled:!a("library:delete_own","library:delete_all"),title:a("library:delete_own","library:delete_all")?void 0:t("fileManager.noPermissionDeleteFiles"),children:[i.jsx(en,{className:"w-4 h-4 sm:mr-1"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.delete")})]}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:Ne,children:[i.jsx(Ht,{className:"w-4 h-4 sm:mr-1"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.clear")})]})]})]})]}),vt?i.jsx("div",{className:"flex-1 flex items-center justify-center",children:i.jsxs("div",{className:"flex flex-col items-center gap-3",children:[i.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("fileManager.loadingFiles")})]})}):L?.length===0?i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[i.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:i.jsx(sf,{className:"w-12 h-12 text-bambu-gray/50"})}),i.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t(d!==null?"fileManager.folderIsEmpty":"fileManager.noFilesYet")}),i.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t(d!==null?"fileManager.folderEmptyDescription":"fileManager.noFilesDescription")}),i.jsxs(Ie,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[i.jsx(ar,{className:"w-4 h-4 mr-2"}),t("fileManager.uploadFiles")]})]}):de.length===0?i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[i.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:i.jsx(Rr,{className:"w-12 h-12 text-bambu-gray/50"})}),i.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t("fileManager.noMatchingFiles")}),i.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t("fileManager.noMatchingFilesDescription")}),i.jsx(Ie,{variant:"secondary",onClick:()=>{U(""),$("all")},children:t("fileManager.clearFilters")})]}):pe==="grid"?i.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:i.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4",children:de.map(qe=>i.jsx(btt,{file:qe,isSelected:p.includes(qe.id),isMobile:ce,t,onSelect:Ke,onDelete:_t=>k({type:"file",id:_t}),onDownload:He,onAddToQueue:_t=>{const Nt=L?.find(mt=>mt.id===_t);Nt&&W(Nt)},onPrint:A,onPreview3d:me,onRename:_t=>J({type:"file",id:_t.id,name:_t.filename}),onGenerateThumbnail:_t=>ye.mutate(_t.id),thumbnailVersion:ie[qe.id],hasPermission:r,canModify:s,authEnabled:o},qe.id))})}):i.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[i.jsxs("div",{className:`hidden sm:grid ${o?"grid-cols-[auto_1fr_120px_100px_100px_100px_80px]":"grid-cols-[auto_1fr_100px_100px_100px_80px]"} gap-4 px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary text-xs text-bambu-gray font-medium`,children:[i.jsx("div",{className:"w-6"}),i.jsx("div",{children:t("common.name")}),o&&i.jsx("div",{children:t("fileManager.uploadedBy",{defaultValue:"Uploaded By"})}),i.jsx("div",{children:t("common.type")}),i.jsx("div",{children:t("fileManager.size")}),i.jsx("div",{children:t("fileManager.prints")}),i.jsx("div",{})]}),de.map(qe=>i.jsxs("div",{className:`grid ${o?"grid-cols-[auto_1fr_120px_100px_100px_100px_80px]":"grid-cols-[auto_1fr_100px_100px_100px_80px]"} gap-4 px-4 py-3 items-center border-b border-bambu-dark-tertiary last:border-b-0 cursor-pointer hover:bg-bambu-dark/50 transition-colors ${p.includes(qe.id)?"bg-bambu-green/10":""}`,onClick:()=>Ke(qe.id),children:[i.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${p.includes(qe.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:p.includes(qe.id)&&i.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})}),i.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[i.jsxs("div",{className:"relative group/thumb",children:[i.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden",children:qe.thumbnail_path?i.jsx("img",{src:`${fe.getLibraryFileThumbnailUrl(qe.id)}${ie[qe.id]?`?v=${ie[qe.id]}`:""}`,alt:"",className:"w-full h-full object-cover"}):i.jsx("div",{className:"w-full h-full flex items-center justify-center",children:i.jsx(sf,{className:"w-5 h-5 text-bambu-gray/50"})})}),qe.thumbnail_path&&i.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:i.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:i.jsx("img",{src:`${fe.getLibraryFileThumbnailUrl(qe.id)}${ie[qe.id]?`?v=${ie[qe.id]}`:""}`,alt:qe.filename,className:"w-full h-full object-contain"})})})]}),i.jsx("div",{className:"min-w-0",children:i.jsx("div",{className:"text-sm text-white truncate",children:qe.print_name||qe.filename})})]}),o&&i.jsx("div",{className:"text-sm text-bambu-gray flex items-center gap-1",children:qe.created_by_username?i.jsxs(i.Fragment,{children:[i.jsx(zd,{className:"w-3 h-3"}),i.jsx("span",{className:"truncate",children:qe.created_by_username})]}):"-"}),i.jsx("div",{children:i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${qe.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":qe.file_type==="gcode"?"bg-blue-500/20 text-blue-400":qe.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:qe.file_type.toUpperCase()})}),i.jsx("div",{className:"text-sm text-bambu-gray",children:ho(qe.file_size)}),i.jsx("div",{className:"text-sm text-bambu-gray",children:qe.print_count>0?`${qe.print_count}x`:"-"}),i.jsxs("div",{className:"flex items-center gap-1",onClick:_t=>_t.stopPropagation(),children:[wL(qe.filename)&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>r("printers:control")&&A(qe),className:`p-1.5 rounded transition-colors ${r("printers:control")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("printers:control")?t("common.print"):t("fileManager.noPermissionPrint"),disabled:!r("printers:control"),children:i.jsx(_r,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>{r("queue:create")&&W(qe)},className:`p-1.5 rounded transition-colors ${r("queue:create")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("queue:create")?t("fileManager.schedulePrint"):t("fileManager.noPermissionAddToQueue"),disabled:!r("queue:create"),children:i.jsx(Jn,{className:"w-4 h-4"})})]}),(qe.file_type==="3mf"||qe.file_type==="gcode"||qe.file_type==="stl")&&i.jsx("button",{onClick:()=>r("library:read")&&me(qe),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?"3D Preview":"You do not have permission to preview files",disabled:!r("library:read"),children:i.jsx(na,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>r("library:read")&&He(qe.id),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?t("common.download"):t("fileManager.noPermissionDownload"),disabled:!r("library:read"),children:i.jsx(bi,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>s("library","update",qe.created_by_id)&&J({type:"file",id:qe.id,name:qe.filename}),className:`p-1.5 rounded transition-colors ${s("library","update",qe.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",qe.created_by_id)?t("common.rename"):t("fileManager.noPermissionRenameFile"),disabled:!s("library","update",qe.created_by_id),children:i.jsx(Ki,{className:"w-4 h-4"})}),qe.file_type==="stl"&&i.jsx("button",{onClick:()=>s("library","update",qe.created_by_id)&&ye.mutate(qe.id),className:`p-1.5 rounded transition-colors ${s("library","update",qe.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",qe.created_by_id)?t("fileManager.generateThumbnail"):t("fileManager.noPermissionGenerateThumbnail"),disabled:ye.isPending||!s("library","update",qe.created_by_id),children:i.jsx(Ld,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>s("library","delete",qe.created_by_id)&&k({type:"file",id:qe.id}),className:`p-1.5 rounded transition-colors ${s("library","delete",qe.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","delete",qe.created_by_id)?t("common.delete"):t("fileManager.noPermissionDeleteFile"),disabled:!s("library","delete",qe.created_by_id),children:i.jsx(en,{className:"w-4 h-4"})})]})]},qe.id))]})})]})]}),y&&i.jsx(htt,{parentId:d,onClose:()=>v(!1),onSave:qe=>_e.mutate(qe),isLoading:_e.isPending,t}),b&&xe&&i.jsx(ftt,{folders:xe,selectedFiles:p,currentFolderId:d,onClose:()=>g(!1),onMove:qe=>Ae.mutate({fileIds:p,folderId:qe}),isLoading:Ae.isPending,t}),_&&i.jsx(Qre,{folderId:d,onClose:()=>N(!1),onUploadComplete:Ce}),T&&i.jsx(gtt,{folder:T,onClose:()=>C(null),onLink:qe=>Pe.mutate({id:T.id,data:qe}),isLoading:Pe.isPending,t}),P&&i.jsx(_n,{title:P.type==="folder"?t("fileManager.deleteFolder"):P.type==="bulk"?t("fileManager.deleteFilesCount",{count:P.count}):t("fileManager.deleteFile"),message:P.type==="folder"?t("fileManager.deleteFolderConfirm"):P.type==="bulk"?t("fileManager.deleteFilesConfirm",{count:P.count}):t("fileManager.deleteFileConfirm"),confirmText:t("common.delete"),variant:"danger",isLoading:it,loadingText:t("fileManager.deleting"),onConfirm:et,onCancel:()=>k(null)}),R&&i.jsx(bu,{mode:"reprint",libraryFileId:R.id,archiveName:R.print_name||R.filename,onClose:()=>A(null),onSuccess:()=>{A(null),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),D&&i.jsx(bu,{mode:"reprint",libraryFileId:D.id,archiveName:D.print_name||D.filename,onClose:()=>B(null),onSuccess:()=>{B(null),f([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),z&&i.jsx(bu,{mode:"add-to-queue",libraryFileId:z.id,archiveName:z.print_name||z.filename,onClose:()=>W(null),onSuccess:()=>{W(null),f([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["queue"]}),e.invalidateQueries({queryKey:["archives"]})}}),ue&&i.jsx(jI,{libraryFileId:ue.id,title:ue.print_name||ue.filename,fileType:ue.file_type,onClose:()=>me(null)}),I&&i.jsx(ptt,{type:I.type,currentName:I.name,onClose:()=>J(null),onSave:qe=>{I.type==="file"?Ue.mutate({id:I.id,filename:qe}):je.mutate({id:I.id,name:qe})},isLoading:Ue.isPending||je.isPending,t})]})}const WD=5,ytt=2e3,vtt=3e4,wtt=5e3;function Stt(){const{t}=Rt(),e=sn(),{showToast:n}=fn(),{hasPermission:r}=Nr(),{printerId:a}=hw(),s=parseInt(a||"0",10),[o,l]=w.useState("stream"),[c,u]=w.useState(!1),[d,m]=w.useState(!1),[p,f]=w.useState(!0),[y,v]=w.useState(Date.now()),[b,g]=w.useState(!1),[_,N]=w.useState(!1),[T,C]=w.useState(0),[P,k]=w.useState(!1),[R,A]=w.useState(0),[D,B]=w.useState(1),[z,W]=w.useState({x:0,y:0}),[I,J]=w.useState(!1),[ie,Q]=w.useState({x:0,y:0}),[ue,me]=w.useState(null),[pe,Y]=w.useState(null),se=w.useRef(null),oe=w.useRef(null),be=w.useRef(null),Me=w.useRef(null),q=w.useRef(null),{data:Z}=tt({queryKey:["printer",s],queryFn:()=>fe.getPrinter(s),enabled:s>0}),{data:j}=tt({queryKey:["printerStatus",s],queryFn:()=>fe.getPrinterStatus(s),refetchInterval:3e4,enabled:s>0}),E=ft({mutationFn:Ae=>fe.setChamberLight(s,Ae),onMutate:async Ae=>{await e.cancelQueries({queryKey:["printerStatus",s]});const Pe=e.getQueryData(["printerStatus",s]);return e.setQueryData(["printerStatus",s],Ue=>({...Ue,chamber_light:Ae})),{previousStatus:Pe}},onSuccess:(Ae,Pe)=>{n(`Chamber light ${Pe?"on":"off"}`)},onError:(Ae,Pe,Ue)=>{Ue?.previousStatus&&e.setQueryData(["printerStatus",s],Ue.previousStatus),n(Ae.message||t("printers.toast.failedToControlChamberLight"),"error")}}),U=(j?.state==="RUNNING"||j?.state==="PAUSE")&&(j?.printable_objects_count??0)>=2;w.useEffect(()=>(Z&&(document.title=`${Z.name} - Camera`),()=>{document.title="Bambuddy"}),[Z]);const K=w.useRef(!1);w.useEffect(()=>{const Ae=`/api/v1/printers/${s}/camera/stop`;K.current=!1;const Pe=()=>{if(s>0&&!K.current){K.current=!0;const Xe={},ye=Ud();ye&&(Xe.Authorization=`Bearer ${ye}`),fetch(Ae,{method:"POST",keepalive:!0,headers:Xe}).catch(()=>{})}},Ue=()=>{Pe()};window.addEventListener("beforeunload",Ue);const je=se.current;return()=>{window.removeEventListener("beforeunload",Ue),je&&(je.src=""),Pe()}},[s]),w.useEffect(()=>{if(p&&!b){const Pe=setTimeout(()=>{f(!1)},o==="stream"?3e3:2e4);return()=>clearTimeout(Pe)}},[o,p,y,b]),w.useEffect(()=>{const Ae=()=>{const Pe=!!document.fullscreenElement;N(Pe),B(1),W({x:0,y:0}),o==="stream"&&!b&&(se.current&&(se.current.src=""),setTimeout(()=>{f(!0),v(Date.now())},200))};return document.addEventListener("fullscreenchange",Ae),()=>document.removeEventListener("fullscreenchange",Ae)},[o,b]),w.useEffect(()=>{let Ae;const Pe=()=>{clearTimeout(Ae),Ae=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",Pe),()=>{clearTimeout(Ae),window.removeEventListener("resize",Pe)}},[]),w.useEffect(()=>()=>{be.current&&clearTimeout(be.current),Me.current&&clearInterval(Me.current),q.current&&clearInterval(q.current)},[]);const $=w.useCallback(()=>{if(T>=WD){k(!1),m(!0);return}const Ae=Math.min(ytt*Math.pow(2,T),vtt);k(!0),A(Math.ceil(Ae/1e3)),Me.current=setInterval(()=>{A(Pe=>Pe<=1?(Me.current&&clearInterval(Me.current),0):Pe-1)},1e3),be.current=setTimeout(()=>{C(Pe=>Pe+1),k(!1),f(!0),m(!1),se.current&&(se.current.src=""),v(Date.now())},Ae)},[T]);w.useEffect(()=>{if(o!=="stream"||p||P||b){q.current&&(clearInterval(q.current),q.current=null);return}return q.current=setInterval(async()=>{try{const Ae=await fe.getCameraStatus(s);(Ae.stalled||!Ae.active&&!d)&&(console.log(`Stream issue detected: stalled=${Ae.stalled}, active=${Ae.active}, reconnecting...`),q.current&&(clearInterval(q.current),q.current=null),f(!1),$())}catch{}},wtt),()=>{q.current&&(clearInterval(q.current),q.current=null)}},[o,p,d,P,b,s,$]);const ne=()=>{f(!1),o==="stream"&&T{if(f(!1),m(!1),C(0),k(!1),be.current&&clearTimeout(be.current),Me.current&&clearInterval(Me.current),se.current&&!localStorage.getItem("cameraWindowState")){const Ae=se.current,Pe=Ae.naturalWidth,Ue=Ae.naturalHeight;if(Pe>0&&Ue>0){const ye=window.outerWidth-window.innerWidth,Ge=window.outerHeight-window.innerHeight,Ee=Pe+16+ye,Ke=Ue+45+16+Ge;try{window.resizeTo(Ee,Ke)}catch{}}}},V=()=>{if(s>0){const Ae={},Pe=Ud();Pe&&(Ae.Authorization=`Bearer ${Pe}`),fetch(`/api/v1/printers/${s}/camera/stop`,{method:"POST",headers:Ae}).catch(()=>{})}},ee=Ae=>{o===Ae||b||(g(!0),f(!0),m(!1),C(0),k(!1),B(1),W({x:0,y:0}),be.current&&clearTimeout(be.current),Me.current&&clearInterval(Me.current),se.current&&(se.current.src=""),o==="stream"&&V(),setTimeout(()=>{l(Ae),v(Date.now()),g(!1)},100))},G=()=>{b||(g(!0),f(!0),m(!1),C(0),k(!1),be.current&&clearTimeout(be.current),Me.current&&clearInterval(Me.current),se.current&&(se.current.src=""),o==="stream"&&V(),setTimeout(()=>{v(Date.now()),g(!1)},100))},re=()=>{oe.current&&(document.fullscreenElement?document.exitFullscreen():oe.current.requestFullscreen())},ce=()=>{B(Ae=>Math.min(Ae+.5,4))},ge=()=>{B(Ae=>{const Pe=Math.max(Ae-.5,1);return Pe===1&&W({x:0,y:0}),Pe})},xe=Ae=>{Ae.preventDefault(),Ae.deltaY<0?ce():ge()},ae=Ae=>{D>1&&(Ae.preventDefault(),J(!0),Q({x:Ae.clientX-z.x,y:Ae.clientY-z.y}))},L=w.useCallback(()=>{if(!oe.current)return{x:300,y:200};const Ae=oe.current.getBoundingClientRect(),Pe=Ae.width*(D-1)/2,Ue=Ae.height*(D-1)/2;return{x:Math.max(50,Pe),y:Math.max(50,Ue)}},[D]),F=Ae=>{if(I&&D>1){const Pe=Ae.clientX-ie.x,Ue=Ae.clientY-ie.y,je=L();W({x:Math.max(-je.x,Math.min(je.x,Pe)),y:Math.max(-je.y,Math.min(je.y,Ue))})}},te=()=>{J(!1)},ve=Ae=>{if(Ae.length<2)return 0;const Pe=Ae[0].clientX-Ae[1].clientX,Ue=Ae[0].clientY-Ae[1].clientY;return Math.sqrt(Pe*Pe+Ue*Ue)},he=Ae=>Ae.length<2?{x:Ae[0].clientX,y:Ae[0].clientY}:{x:(Ae[0].clientX+Ae[1].clientX)/2,y:(Ae[0].clientY+Ae[1].clientY)/2},de=Ae=>{Ae.touches.length===2?(Ae.preventDefault(),me(ve(Ae.touches)),Y(he(Ae.touches))):Ae.touches.length===1&&D>1&&(Ae.preventDefault(),J(!0),Q({x:Ae.touches[0].clientX-z.x,y:Ae.touches[0].clientY-z.y}))},ke=Ae=>{if(Ae.touches.length===2&&ue!==null){Ae.preventDefault();const Pe=ve(Ae.touches),Ue=Pe/ue;B(Xe=>{const ye=Math.max(1,Math.min(4,Xe*Ue));return ye===1&&W({x:0,y:0}),ye}),me(Pe);const je=he(Ae.touches);if(pe){const Xe=L();W(ye=>({x:Math.max(-Xe.x,Math.min(Xe.x,ye.x+(je.x-pe.x))),y:Math.max(-Xe.y,Math.min(Xe.y,ye.y+(je.y-pe.y)))}))}Y(je)}else if(Ae.touches.length===1&&I&&D>1){Ae.preventDefault();const Pe=Ae.touches[0].clientX-ie.x,Ue=Ae.touches[0].clientY-ie.y,je=L();W({x:Math.max(-je.x,Math.min(je.x,Pe)),y:Math.max(-je.y,Math.min(je.y,Ue))})}},_e=Ae=>{Ae.touches.length<2&&(me(null),Y(null)),Ae.touches.length===0&&J(!1)},Le=()=>{B(1),W({x:0,y:0})},$e=b?"":o==="stream"?`/api/v1/printers/${s}/camera/stream?fps=15&t=${y}`:`/api/v1/printers/${s}/camera/snapshot?t=${y}`,Re=p||b||P;return s?i.jsxs("div",{ref:oe,className:"min-h-screen bg-black flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[i.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[i.jsx(ax,{className:"w-4 h-4"}),Z?.name||`Printer ${s}`]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[i.jsx("button",{onClick:()=>ee("stream"),disabled:Re,className:`px-3 py-1 text-xs rounded transition-colors ${o==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.live")}),i.jsx("button",{onClick:()=>ee("snapshot"),disabled:Re,className:`px-3 py-1 text-xs rounded transition-colors ${o==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.snapshot")})]}),i.jsx("button",{onClick:()=>E.mutate(!j?.chamber_light),disabled:!j?.connected||E.isPending||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${j?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30":"hover:bg-bambu-dark-tertiary"}`,title:r("printers:control")?t("camera.chamberLight"):t("printers.permission.noControl"),children:i.jsx(kO,{on:j?.chamber_light??!1,className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>u(!0),disabled:!U||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${U&&r("printers:control")?"hover:bg-bambu-dark-tertiary":""}`,title:r("printers:control")?t(U?"printers.skipObjects.tooltip":"printers.skipObjects.onlyWhilePrinting"):t("printers.permission.noControl"),children:i.jsx(xT,{className:"w-4 h-4 text-bambu-gray"})}),i.jsx("button",{onClick:G,disabled:Re,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:t(o==="stream"?"camera.restartStream":"camera.refreshSnapshot"),children:i.jsx(Sr,{className:`w-4 h-4 text-bambu-gray ${Re?"animate-spin":""}`})}),i.jsx("button",{onClick:re,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:t(_?"camera.exitFullscreen":"camera.fullscreen"),children:_?i.jsx(KX,{className:"w-4 h-4 text-bambu-gray"}):i.jsx(Kfe,{className:"w-4 h-4 text-bambu-gray"})})]})]}),i.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:xe,onMouseMove:F,onMouseUp:te,onMouseLeave:te,onTouchStart:de,onTouchMove:ke,onTouchEnd:_e,style:{touchAction:"none"},children:i.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(p||b)&&!P&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:i.jsxs("div",{className:"text-center",children:[i.jsx(Sr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t(o==="stream"?"camera.connectingToCamera":"camera.capturingSnapshot")})]})}),P&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:i.jsxs("div",{className:"text-center p-4",children:[i.jsx(Rh,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),i.jsx("p",{className:"text-white mb-2",children:t("camera.connectionLost")}),i.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:t("camera.reconnecting",{countdown:R,attempt:T+1,max:WD})}),i.jsx("button",{onClick:G,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.reconnectNow")})]})}),d&&!P&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:i.jsxs("div",{className:"text-center p-4",children:[i.jsx(Mn,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),i.jsx("p",{className:"text-white mb-2",children:t("camera.cameraUnavailable")}),i.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:t("camera.cameraUnavailableDesc")}),i.jsx("button",{onClick:G,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.retry")})]})}),i.jsx("img",{ref:se,src:$e,alt:t("camera.cameraStream"),className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${D}) translate(${z.x/D}px, ${z.y/D}px) rotate(${Z?.camera_rotation||0}deg)`,...Z?.camera_rotation===90||Z?.camera_rotation===270?{maxWidth:"100vh",maxHeight:"100vw"}:{},cursor:D>1?I?"grabbing":"grab":"default"},onError:$e?ne:void 0,onLoad:$e?O:void 0,onMouseDown:ae,draggable:!1},y),i.jsxs("div",{className:"absolute bottom-4 left-4 flex items-center gap-1.5 bg-black/60 rounded-lg px-2 py-1.5",children:[i.jsx("button",{onClick:ge,disabled:D<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomOut"),children:i.jsx(YL,{className:"w-4 h-4 text-white"})}),i.jsxs("button",{onClick:Le,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:t("camera.resetZoom"),children:[Math.round(D*100),"%"]}),i.jsx("button",{onClick:ce,disabled:D>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomIn"),children:i.jsx(KL,{className:"w-4 h-4 text-white"})})]})]})}),i.jsx(CO,{printerId:s,isOpen:c,onClose:()=>u(!1)})]}):i.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:i.jsx("p",{className:"text-white",children:t("camera.invalidPrinterId")})})}function _tt(t){const e=t.get("show")?.split(",")||["progress","layers","eta","filename","status"],n=parseInt(t.get("fps")||"15",10),r=Math.min(Math.max(isNaN(n)?15:n,1),30),a=t.get("camera"),s=a!=="false"&&a!=="0";return{size:t.get("size")||"medium",fps:r,showCamera:s,showProgress:e.includes("progress"),showLayers:e.includes("layers"),showEta:e.includes("eta"),showFilename:e.includes("filename"),showStatus:e.includes("status"),showPrinter:e.includes("printer")}}function Ntt(t,e){if(t.stg_cur_name)return t.stg_cur_name;switch(t.state){case"RUNNING":return e("streamOverlay.status.printing");case"PAUSE":return e("streamOverlay.status.paused");case"FINISH":return e("streamOverlay.status.finished");case"FAILED":return e("streamOverlay.status.failed");case"IDLE":return e("streamOverlay.status.idle");default:return t.state||e("streamOverlay.status.unknown")}}function ktt(t){switch(t){case"small":return{container:"p-3",text:"text-sm",textLarge:"text-lg",progressHeight:"h-2",icon:"w-3 h-3",gap:"gap-2",logoHeight:"h-12"};case"large":return{container:"p-6",text:"text-xl",textLarge:"text-3xl",progressHeight:"h-4",icon:"w-6 h-6",gap:"gap-4",logoHeight:"h-24"};default:return{container:"p-4",text:"text-base",textLarge:"text-xl",progressHeight:"h-3",icon:"w-4 h-4",gap:"gap-3",logoHeight:"h-16"}}}function Ctt(){const{printerId:t}=hw(),[e]=jL(),{t:n}=Rt(),r=sn(),a=parseInt(t||"0",10),[s,o]=w.useState(Date.now()),l=w.useMemo(()=>_tt(e),[e]),c=ktt(l.size),{data:u}=tt({queryKey:["printer",a],queryFn:()=>fe.getPrinter(a),enabled:a>0}),{data:d}=tt({queryKey:["printerStatus",a],queryFn:()=>fe.getPrinterStatus(a),enabled:a>0,refetchInterval:2e3}),{data:m}=tt({queryKey:["settings"],queryFn:fe.getSettings}),p=m?.time_format||"system";w.useEffect(()=>{if(!a)return;const _=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,N=new WebSocket(_);return N.onmessage=T=>{try{const C=JSON.parse(T.data);C.type==="printer_status"&&C.printer_id===a&&r.setQueryData(["printerStatus",a],C.status)}catch{}},N.onerror=()=>{},()=>{N.close()}},[a,r]),w.useEffect(()=>(document.title=u?`${u.name} - ${n("streamOverlay.title")}`:n("streamOverlay.title"),()=>{document.title="Bambuddy"}),[u,n]);const f=()=>{setTimeout(()=>{o(Date.now())},3e3)};if(!a)return i.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:i.jsx("p",{className:"text-white",children:n("streamOverlay.invalidPrinterId")})});if(!d)return i.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:i.jsx("p",{className:"text-gray-400",children:n("common.loading")})});const y=d.state==="RUNNING"||d.state==="PAUSE",v=d.progress||0,b=`/api/v1/printers/${a}/camera/stream?fps=${l.fps}&t=${s}`;return i.jsxs("div",{className:"min-h-screen bg-black relative overflow-hidden",children:[l.showCamera&&i.jsx("img",{src:b,alt:n("streamOverlay.cameraStream"),className:"absolute inset-0 w-full h-full object-contain",style:u?.camera_rotation?{transform:`rotate(${u.camera_rotation}deg)`}:void 0,onError:f},s),i.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"absolute top-4 right-4 z-10",children:i.jsx("img",{src:"/img/bambuddy_logo_dark_transparent.png",alt:"Bambuddy",className:`${c.logoHeight} object-contain drop-shadow-lg hover:scale-105 transition-transform`})}),i.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-10 bg-gradient-to-t from-black/80 via-black/60 to-transparent",children:i.jsxs("div",{className:`${c.container}`,children:[l.showPrinter&&u&&i.jsxs("div",{className:`flex items-center ${c.gap} mb-2`,children:[i.jsx(_r,{className:`${c.icon} text-white/70`}),i.jsx("span",{className:`${c.text} text-white font-medium`,children:u.name})]}),l.showFilename&&d.current_print&&i.jsx("div",{className:`${c.textLarge} text-white font-semibold mb-2 truncate drop-shadow-md`,children:d.current_print.replace(/\.gcode\.3mf$|\.3mf$|\.gcode$/i,"")}),l.showStatus&&i.jsx("div",{className:`${c.text} text-white/70 mb-2`,children:Ntt(d,n)}),l.showProgress&&y&&i.jsxs("div",{className:"mb-3",children:[i.jsxs("div",{className:`flex items-center justify-between mb-1 ${c.text}`,children:[i.jsx("span",{className:"text-white/70",children:n("streamOverlay.progress")}),i.jsxs("span",{className:"text-white font-bold",children:[Math.round(v),"%"]})]}),i.jsx("div",{className:`w-full bg-white/20 rounded-full ${c.progressHeight}`,children:i.jsx("div",{className:`bg-bambu-green ${c.progressHeight} rounded-full transition-all duration-500`,style:{width:`${v}%`}})})]}),y&&(l.showLayers||l.showEta)&&i.jsxs("div",{className:`flex items-center ${c.gap} flex-wrap`,children:[l.showLayers&&d.layer_num!=null&&d.total_layers!=null&&d.total_layers>0&&i.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[i.jsx(Vi,{className:c.icon}),i.jsxs("span",{className:c.text,children:[i.jsx("span",{className:"text-white",children:d.layer_num}),i.jsx("span",{className:"mx-1",children:"/"}),i.jsx("span",{children:d.total_layers})]})]}),l.showEta&&d.remaining_time!=null&&d.remaining_time>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[i.jsx(yd,{className:c.icon}),i.jsx("span",{className:`${c.text} text-white`,children:Is(d.remaining_time*60)})]}),i.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[i.jsx(Jn,{className:c.icon}),i.jsxs("span",{className:`${c.text} text-white`,children:[n("streamOverlay.eta")," ",XL(d.remaining_time,p,n)]})]})]})]}),!y&&i.jsx("div",{className:`${c.text} text-white/70 py-2`,children:d.connected?n("streamOverlay.printerIdle"):n("streamOverlay.printerOffline")})]})})]})}function Ttt(){const{t}=Rt(),{id:e}=hw(),{mode:n}=Xf(),{data:r,isLoading:a,error:s}=tt({queryKey:["external-link",e],queryFn:()=>fe.getExternalLink(Number(e)),enabled:!!e});return a?i.jsx("div",{className:"flex items-center justify-center h-full",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s||!r?i.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[i.jsx(Mn,{className:"w-12 h-12"}),i.jsx("p",{children:t("common.linkNotFound")})]}):i.jsx("iframe",{src:r.url,className:"h-full w-full border-0",style:{colorScheme:n},title:r.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}function EY(){const{id:t}=hw(),e=al(),n=sn(),{t:r}=Rt(),{showToast:a}=fn(),s=!!t,[o,l]=w.useState(""),[c,u]=w.useState(""),[d,m]=w.useState([]),[p,f]=w.useState(""),[y,v]=w.useState(!1),{data:b,isLoading:g}=tt({queryKey:["group",t],queryFn:()=>fe.getGroup(Number(t)),enabled:s}),{data:_,isLoading:N}=tt({queryKey:["permissions"],queryFn:()=>fe.getPermissions()});s&&b&&!y&&(l(b.name),u(b.description||""),m(b.permissions),v(!0));const T=ft({mutationFn:Q=>fe.createGroup(Q),onSuccess:()=>{n.invalidateQueries({queryKey:["groups"]}),a(r("groups.toast.created")),e("/settings?tab=users")},onError:Q=>{a(Q.message,"error")}}),C=ft({mutationFn:Q=>fe.updateGroup(Number(t),Q),onSuccess:()=>{n.invalidateQueries({queryKey:["groups"]}),a(r("groups.toast.updated")),e("/settings?tab=users")},onError:Q=>{a(Q.message,"error")}}),P=T.isPending||C.isPending,k=()=>{if(!o.trim()){a(r("groups.toast.enterGroupName"),"error");return}s?C.mutate({name:o!==b?.name?o:void 0,description:c,permissions:d}):T.mutate({name:o,description:c||void 0,permissions:d})},R=Q=>{m(ue=>ue.includes(Q)?ue.filter(me=>me!==Q):[...ue,Q])},A=(Q,ue)=>{const me=Q.permissions.map(pe=>pe.value);m(pe=>{const Y=pe.filter(se=>!me.includes(se));return ue?[...Y,...me]:Y})},D=Q=>Q.permissions.every(ue=>d.includes(ue.value)),B=Q=>{const ue=Q.permissions.filter(me=>d.includes(me.value)).length;return ue>0&&ue{_&&m(_.all_permissions)},W=()=>{m([])},I=p.toLowerCase(),J=w.useMemo(()=>_?I?_.categories.map(Q=>({...Q,permissions:Q.permissions.filter(ue=>ue.label.toLowerCase().includes(I))})).filter(Q=>Q.permissions.length>0):_.categories:[],[_,I]),ie=_?.all_permissions.length??0;return g||N?i.jsx("div",{className:"flex items-center justify-center py-16",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("button",{onClick:()=>e("/settings?tab=users"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",children:i.jsx(IX,{className:"w-5 h-5"})}),i.jsx("h1",{className:"text-xl font-bold text-white",children:r(s?"groups.editor.title":"groups.editor.createTitle")})]}),s&&b?.is_system&&i.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-lg bg-yellow-500/10 border border-yellow-500/20 text-yellow-400 text-sm",children:[i.jsx(Mn,{className:"w-4 h-4 shrink-0"}),r("groups.form.systemGroupWarning")]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:r("groups.form.groupName")}),i.jsx("input",{type:"text",value:o,onChange:Q=>l(Q.target.value),disabled:s&&b?.is_system,className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors disabled:opacity-50",placeholder:r("groups.form.groupNamePlaceholder")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:r("groups.form.description")}),i.jsx("input",{type:"text",value:c,onChange:Q=>u(Q.target.value),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:r("groups.form.descriptionPlaceholder")})]})]}),i.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("span",{className:"text-sm text-bambu-gray",children:[r("groups.editor.permissionsSelected",{count:d.length})," / ",ie]}),i.jsx(Ie,{size:"sm",variant:"ghost",onClick:z,children:r("groups.editor.selectAll")}),i.jsx(Ie,{size:"sm",variant:"ghost",onClick:W,children:r("groups.editor.clearAll")})]}),i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray"}),i.jsx("input",{type:"text",value:p,onChange:Q=>f(Q.target.value),placeholder:r("groups.editor.search"),className:"pl-9 pr-4 py-2 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors w-64"})]})]}),J.length===0?i.jsx("div",{className:"text-center py-12 text-bambu-gray",children:r("groups.editor.noResults")}):i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:J.map(Q=>{const ue=_.categories.find(oe=>oe.name===Q.name),me=ue.permissions.filter(oe=>d.includes(oe.value)).length,pe=ue.permissions.length,Y=D(ue),se=B(ue);return i.jsxs(Pt,{children:[i.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between px-4 py-3 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary rounded-t-xl",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("button",{type:"button",onClick:()=>A(ue,!Y),className:`w-5 h-5 rounded border flex items-center justify-center transition-colors shrink-0 ${Y?"bg-bambu-green border-bambu-green":se?"bg-bambu-green/50 border-bambu-green":"border-bambu-gray hover:border-white"}`,children:[Y&&i.jsx(Qr,{className:"w-3 h-3 text-white"}),se&&!Y&&i.jsx(RN,{className:"w-3 h-3 text-white"})]}),i.jsx(S3,{className:"w-4 h-4 text-bambu-gray shrink-0"}),i.jsx("span",{className:"text-white font-medium text-sm",children:Q.name})]}),i.jsxs("span",{className:"text-xs text-bambu-gray tabular-nums",children:[me,"/",pe]})]}),i.jsx("div",{className:"p-3 space-y-1",children:Q.permissions.map(oe=>i.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-secondary cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:d.includes(oe.value),onChange:()=>R(oe.value),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark-secondary"}),i.jsx("span",{className:"text-sm text-bambu-gray",children:oe.label})]},oe.value))})]},Q.name)})}),i.jsx("div",{className:"h-16"}),i.jsxs("div",{className:"fixed bottom-0 left-0 right-0 z-20 px-6 py-3 bg-bambu-dark-secondary border-t border-bambu-dark-tertiary flex items-center justify-center gap-3",children:[i.jsx(Ie,{variant:"secondary",onClick:()=>e("/settings?tab=users"),children:r("common.cancel")}),i.jsx(Ie,{onClick:k,disabled:P||!o.trim(),children:P?i.jsxs(i.Fragment,{children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),r("common.saving")]}):i.jsxs(i.Fragment,{children:[i.jsx(ss,{className:"w-4 h-4"}),r("common.save")]})})]})]})}const jY={material:"",subtype:"",brand:"",color_name:"",rgba:"808080FF",label_weight:1e3,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:"",note:"",cost_per_kg:null};function Att(t,e=!1){const n={};return e?(t.material||(n.material="Material is required"),{isValid:Object.keys(n).length===0,errors:n}):(t.slicer_filament||(n.slicer_filament="Slicer preset is required"),t.material||(n.material="Material is required"),t.brand||(n.brand="Brand is required"),t.subtype||(n.subtype="Subtype is required"),{isValid:Object.keys(n).length===0,errors:n})}const Ptt=["PLA","PETG","ABS","TPU","ASA","PC","PA","PVA","HIPS","PA-CF","PETG-CF","PLA-CF"],Mtt=["Bambu","PolyLite","PolyTerra","eSUN","Overture","Fiberon","SUNLU","Inland","Hatchbox","Generic"],h0=["Basic","Matte","Silk","Tough","HF","High Flow","Engineering","Galaxy","Glow","Marble","Metal","Rainbow","Sparkle","Wood","Translucent","Transparent","Clear","Lite","Pro","Plus","Max","Super","Ultra","Flex","Soft","Hard","Strong","Impact","Heat Resistant","UV Resistant","ESD","Conductive","Magnetic","Gradient","Dual Color","Tri Color","Multicolor"],qoe=[{name:"Black",hex:"000000"},{name:"White",hex:"FFFFFF"},{name:"Gray",hex:"808080"},{name:"Red",hex:"FF0000"},{name:"Orange",hex:"FFA500"},{name:"Yellow",hex:"FFFF00"},{name:"Green",hex:"00AE42"},{name:"Blue",hex:"0066FF"},{name:"Purple",hex:"8B00FF"},{name:"Pink",hex:"FF69B4"},{name:"Brown",hex:"8B4513"},{name:"Silver",hex:"C0C0C0"}],Ett=[{name:"Dark Red",hex:"8B0000"},{name:"Crimson",hex:"DC143C"},{name:"Coral",hex:"FF7F50"},{name:"Salmon",hex:"FA8072"},{name:"Dark Orange",hex:"FF8C00"},{name:"Peach",hex:"FFDAB9"},{name:"Gold",hex:"FFD700"},{name:"Khaki",hex:"F0E68C"},{name:"Lemon",hex:"FFF44F"},{name:"Lime",hex:"32CD32"},{name:"Forest Green",hex:"228B22"},{name:"Olive",hex:"808000"},{name:"Mint",hex:"98FF98"},{name:"Teal",hex:"008080"},{name:"Navy",hex:"000080"},{name:"Sky Blue",hex:"87CEEB"},{name:"Royal Blue",hex:"4169E1"},{name:"Cyan",hex:"00FFFF"},{name:"Turquoise",hex:"40E0D0"},{name:"Violet",hex:"EE82EE"},{name:"Magenta",hex:"FF00FF"},{name:"Indigo",hex:"4B0082"},{name:"Lavender",hex:"E6E6FA"},{name:"Plum",hex:"DDA0DD"},{name:"Hot Pink",hex:"FF69B4"},{name:"Rose",hex:"FF007F"},{name:"Blush",hex:"FFB6C1"},{name:"Chocolate",hex:"D2691E"},{name:"Tan",hex:"D2B48C"},{name:"Beige",hex:"F5F5DC"},{name:"Maroon",hex:"800000"},{name:"Dark Gray",hex:"404040"},{name:"Light Gray",hex:"D3D3D3"},{name:"Charcoal",hex:"36454F"},{name:"Ivory",hex:"FFFFF0"},{name:"Bambu Green",hex:"00AE42"},{name:"Jade White",hex:"E8E8E8"},{name:"Titan Gray",hex:"5A5A5A"}],DY=[...qoe,...Ett],Voe="bambuddy-recent-colors",jtt=8,Dtt=[{code:"GFL00",name:"Bambu PLA Basic",displayName:"Bambu PLA Basic",isCustom:!1,allCodes:["GFL00"]},{code:"GFL01",name:"Bambu PLA Matte",displayName:"Bambu PLA Matte",isCustom:!1,allCodes:["GFL01"]},{code:"GFL05",name:"Generic PLA",displayName:"Generic PLA",isCustom:!1,allCodes:["GFL05"]},{code:"GFG00",name:"Bambu PETG Basic",displayName:"Bambu PETG Basic",isCustom:!1,allCodes:["GFG00"]},{code:"GFG05",name:"Generic PETG",displayName:"Generic PETG",isCustom:!1,allCodes:["GFG05"]},{code:"GFB00",name:"Bambu ABS Basic",displayName:"Bambu ABS Basic",isCustom:!1,allCodes:["GFB00"]},{code:"GFB05",name:"Generic ABS",displayName:"Generic ABS",isCustom:!1,allCodes:["GFB05"]},{code:"GFA00",name:"Bambu ASA Basic",displayName:"Bambu ASA Basic",isCustom:!1,allCodes:["GFA00"]},{code:"GFU00",name:"Bambu TPU 95A",displayName:"Bambu TPU 95A",isCustom:!1,allCodes:["GFU00"]},{code:"GFU05",name:"Generic TPU",displayName:"Generic TPU",isCustom:!1,allCodes:["GFU05"]},{code:"GFC00",name:"Bambu PC Basic",displayName:"Bambu PC Basic",isCustom:!1,allCodes:["GFC00"]},{code:"GFN00",name:"Bambu PA Basic",displayName:"Bambu PA Basic",isCustom:!1,allCodes:["GFN00"]},{code:"GFN05",name:"Generic PA",displayName:"Generic PA",isCustom:!1,allCodes:["GFN05"]},{code:"GFS00",name:"Bambu PLA-CF",displayName:"Bambu PLA-CF",isCustom:!1,allCodes:["GFS00"]},{code:"GFT00",name:"Bambu PETG-CF",displayName:"Bambu PETG-CF",isCustom:!1,allCodes:["GFT00"]},{code:"GFNC0",name:"Bambu PA-CF",displayName:"Bambu PA-CF",isCustom:!1,allCodes:["GFNC0"]},{code:"GFV00",name:"Bambu PVA",displayName:"Bambu PVA",isCustom:!1,allCodes:["GFV00"]}];function Dx(t){let e=t.replace(/@.*$/,"").trim();e=e.replace(/\(Custom\)/i,"").trim(),e=e.replace(/^[#*]+\s*/,"").trim();const n=["PLA-CF","PETG-CF","ABS-GF","ASA-CF","PA-CF","PAHT-CF","PA6-CF","PA6-GF","PPA-CF","PPA-GF","PET-CF","PPS-CF","PC-CF","PC-ABS","ABS-GF","PCTG","PETG","PLA","ABS","ASA","PC","PA","TPU","PVA","HIPS","BVOH","PPS","PEEK","PEI"];let r="",a=-1;for(const c of n){const u=e.toUpperCase().indexOf(c.toUpperCase());if(u!==-1){r=c,a=u;break}}let s="";a>0&&(s=e.substring(0,a).trim(),s=s.replace(/[-_\s]+$/,""));let o="";a!==-1&&r&&(o=e.substring(a+r.length).trim(),o=o.replace(/^[-_\s]+/,""));let l="";for(const c of h0)if(o.toLowerCase().includes(c.toLowerCase())){l=c;break}if(!l&&s)for(const c of h0){const u=new RegExp(`\\s+${c}$`,"i");if(u.test(s)){l=c,s=s.replace(u,"").trim();break}}return{brand:s,material:r,variant:l}}function Rtt(t,e){const n=new Set(Mtt);for(const r of t){const{brand:a}=Dx(r.name);a&&a.length>1&&n.add(a)}if(e)for(const r of e)if(r.filament_vendor&&r.filament_vendor.length>1)n.add(r.filament_vendor);else{const{brand:a}=Dx(r.name);a&&a.length>1&&n.add(a)}return Array.from(n).sort((r,a)=>r.localeCompare(a))}function Ftt(t){const e=t.filter(r=>r.preset_type==="filament");if(e.length===0)return[];const n=new Map;for(const r of e){const a=r.name.replace(/@.*$/,"").trim(),s=n.get(a);if(s)s.allCodes.push(String(r.id));else{const o=r.filament_type||String(r.id);n.set(a,{code:o,name:a,displayName:a,isCustom:!1,allCodes:[o]})}}return Array.from(n.values()).sort((r,a)=>r.displayName.localeCompare(a.displayName))}function Ltt(t,e,n){if(t.length>0){const r=[],a=new Map;for(const s of t)if(s.is_custom){const o=s.name.toUpperCase();(e.size===0||Array.from(e).some(c=>o.includes(c))||!o.includes("@"))&&r.push({code:s.setting_id,name:s.name,displayName:`${s.name} (Custom)`,isCustom:!0,allCodes:[s.setting_id]})}else{const o=s.name.replace(/@.*$/,"").trim(),l=a.get(o);l?l.allCodes.push(s.setting_id):a.set(o,{code:s.setting_id,name:o,displayName:o,isCustom:!1,allCodes:[s.setting_id]})}return[...r,...Array.from(a.values())].sort((s,o)=>s.displayName.localeCompare(o.displayName))}if(n&&n.length>0){const r=Ftt(n);if(r.length>0)return r}return Dtt}function Ott(t,e){if(!t)return;let n=e.find(r=>r.code===t);if(n||(n=e.find(r=>r.allCodes.includes(t))),!n){const r=t.toLowerCase();n=e.find(a=>a.code.toLowerCase()===r||a.allCodes.some(s=>s.toLowerCase()===r))}return n}function Itt(){try{const t=localStorage.getItem(Voe);if(t)return JSON.parse(t)}catch{}return[]}function ztt(t,e){const n=e.filter(a=>a.hex.toUpperCase()!==t.hex.toUpperCase()),r=[t,...n].slice(0,jtt);try{localStorage.setItem(Voe,JSON.stringify(r))}catch{}return r}function KD(t,e){if(!e.material)return!1;const r=(t.name||"").replace(/^High Flow[_\s]+/i,"").replace(/^Standard[_\s]+/i,"").replace(/^HF[_\s]+/i,"").replace(/^S[_\s]+/i,"").trim(),a=Dx(r);return!(!(a.material.toUpperCase()===e.material.toUpperCase())||e.brand&&!(a.brand.toLowerCase().includes(e.brand.toLowerCase())||e.brand.toLowerCase().includes(a.brand.toLowerCase()))||e.subtype&&!(a.variant.toLowerCase().includes(e.subtype.toLowerCase())||e.subtype.toLowerCase().includes(a.variant.toLowerCase())||r.toLowerCase().includes(e.subtype.toLowerCase())))}function Utt({formData:t,updateField:e,cloudAuthenticated:n,loadingCloudPresets:r,presetInputValue:a,setPresetInputValue:s,selectedPresetOption:o,filamentOptions:l,availableBrands:c,availableMaterials:u,quickAdd:d,quantity:m,onQuantityChange:p,errors:f}){const{t:y}=Rt(),[v,b]=w.useState(!1),[g,_]=w.useState(!1),[N,T]=w.useState(!1),[C,P]=w.useState(!1),[k,R]=w.useState(""),[A,D]=w.useState(""),[B,z]=w.useState(""),[W,I]=w.useState(String(t.label_weight)),[J,ie]=w.useState(!1),Q=w.useRef(null),ue=w.useRef(null),me=w.useRef(null),pe=w.useRef(null);w.useEffect(()=>{const q=Z=>{Q.current&&!Q.current.contains(Z.target)&&b(!1),pe.current&&!pe.current.contains(Z.target)&&P(!1),ue.current&&!ue.current.contains(Z.target)&&_(!1),me.current&&!me.current.contains(Z.target)&&T(!1)};return document.addEventListener("mousedown",q),()=>document.removeEventListener("mousedown",q)},[]);const Y=w.useMemo(()=>{if(!a)return l;const q=a.toLowerCase();return l.filter(Z=>Z.displayName.toLowerCase().includes(q)||Z.code.toLowerCase().includes(q))},[l,a]),se=w.useMemo(()=>{if(!k)return c;const q=k.toLowerCase();return c.filter(j=>j.toLowerCase().includes(q)).sort((j,E)=>{const U=j.toLowerCase()===q,K=E.toLowerCase()===q;return U&&!K?-1:!U&&K?1:j.localeCompare(E)})},[c,k]),oe=w.useMemo(()=>{if(!A)return h0;const q=A.toLowerCase();return h0.filter(Z=>Z.toLowerCase().includes(q))},[A]),be=w.useMemo(()=>{if(!B)return u;const q=B.toLowerCase();return u.filter(j=>j.toLowerCase().includes(q)).sort((j,E)=>{const U=j.toLowerCase()===q,K=E.toLowerCase()===q;return U&&!K?-1:!U&&K?1:j.localeCompare(E)})},[B,u]);w.useEffect(()=>{J||I(String(t.label_weight))},[t.label_weight,J]);const Me=q=>{e("slicer_filament",q.code),s(q.displayName),b(!1);const Z=Dx(q.name);Z.material&&e("material",Z.material),Z.brand&&e("brand",Z.brand),Z.variant&&e("subtype",Z.variant)};return i.jsxs("div",{className:"space-y-4",children:[!d&&i.jsx("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:r?i.jsxs(i.Fragment,{children:[i.jsx(pt,{className:"w-3 h-3 animate-spin"})," ",y("inventory.loadingPresets")]}):n?i.jsxs(i.Fragment,{children:[i.jsx(Ox,{className:"w-3 h-3 text-bambu-green"})," ",y("inventory.cloudConnected")]}):i.jsxs(i.Fragment,{children:[i.jsx(spe,{className:"w-3 h-3"})," ",y("inventory.cloudNotConnected")]})}),!d&&i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[y("inventory.slicerPreset")," *"]}),i.jsxs("div",{className:"relative",ref:Q,children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),i.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:y("inventory.searchPresets"),value:a,onChange:q=>{s(q.target.value),b(!0)},onFocus:()=>{b(!0),s("")}}),v&&i.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:Y.length===0?i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:y("inventory.noPresetsFound")}):Y.map(q=>i.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary truncate ${o?.code===q.code?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>Me(q),children:q.displayName},q.code))})]}),o&&i.jsxs("div",{className:"mt-1 text-xs text-bambu-gray",children:[y("inventory.selectedPreset"),": ",i.jsx("span",{className:"font-mono text-bambu-green",children:o.code})]}),f?.slicer_filament&&i.jsx("p",{className:"mt-1 text-xs text-red-400",children:f.slicer_filament})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[y("inventory.material")," *"]}),i.jsxs("div",{className:"relative",ref:pe,children:[i.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:y("inventory.selectMaterial"),value:C?B:t.material,onChange:q=>{z(q.target.value),P(!0)},onFocus:()=>{P(!0),z("")}}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),C&&i.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:[be.length===0?i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:y("inventory.noResults")}):be.map(q=>i.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.material===q?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("material",q),P(!1),z("")},children:q},q)),B&&!be.includes(B)&&i.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:()=>{e("material",B),P(!1),z("")},children:y("inventory.useCustomMaterial",{material:B})})]})]}),f?.material&&i.jsx("p",{className:"mt-1 text-xs text-red-400",children:f.material})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[y("inventory.brand"),!d&&" *"]}),i.jsxs("div",{className:"relative",ref:ue,children:[i.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:y("inventory.searchBrand"),value:g?k:t.brand,onChange:q=>{R(q.target.value),_(!0)},onFocus:()=>{_(!0),R("")}}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),g&&i.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:[se.length===0?i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:y("inventory.noResults")}):se.map(q=>i.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.brand===q?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("brand",q),_(!1),R("")},children:q},q)),k&&!se.includes(k)&&i.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:()=>{e("brand",k),_(!1),R("")},children:y("inventory.useCustomBrand",{brand:k})})]})]}),f?.brand&&i.jsx("p",{className:"mt-1 text-xs text-red-400",children:f.brand})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[y("inventory.subtype"),!d&&" *"]}),i.jsxs("div",{className:"relative",ref:me,children:[i.jsx("input",{type:"text",value:N?A:t.subtype,onChange:q=>{D(q.target.value),T(!0)},onFocus:()=>{T(!0),D("")},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"}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),N&&i.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:[oe.length===0?i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:y("inventory.noResults")}):oe.map(q=>i.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.subtype===q?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("subtype",q),T(!1),D("")},children:q},q)),A&&!h0.some(q=>q.toLowerCase()===A.toLowerCase().trim())&&i.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:()=>{e("subtype",A),T(!1),D("")},children:y("inventory.useCustomBrand",{brand:A})})]})]}),f?.subtype&&i.jsx("p",{className:"mt-1 text-xs text-red-400",children:f.subtype})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:y("inventory.labelWeight")}),i.jsxs("div",{className:"relative",children:[i.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:W,min:0,onFocus:()=>ie(!0),onChange:q=>I(q.target.value),onBlur:()=>{ie(!1);const q=W.trim(),Z=Number(q);if(!q||!Number.isFinite(Z)||Z<0){I(String(t.label_weight));return}const j=Math.round(Z);e("label_weight",j),I(String(j))}}),i.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]})]}),d&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:y("inventory.quantity")}),i.jsx("input",{type:"number",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:m,min:1,max:100,onChange:q=>{const Z=Math.max(1,Math.min(100,parseInt(q.target.value)||1));p(Z)}})]})]})}function Btt({formData:t,updateField:e,recentColors:n,onColorUsed:r,catalogColors:a}){const{t:s}=Rt(),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=t.rgba.replace("#","").substring(0,6),m=g=>d.toUpperCase()===g.toUpperCase(),p=(g,_)=>{e("rgba",g.toUpperCase()+"FF"),e("color_name",_),r({name:_,hex:g})},f=w.useMemo(()=>{if(a.length===0)return[];const g=t.brand?.trim(),_=t.material?.toLowerCase().trim(),N=t.subtype?.toLowerCase().trim();if(!g&&!_)return[];const T=g?g.toLowerCase().split(/[\s\-_]+/).filter(k=>k.length>=2):[],C=k=>{if(T.length===0)return!0;const R=k.toLowerCase();return T.some(A=>R.includes(A))};if(g&&!_){const k=a.filter(R=>C(R.manufacturer));if(k.length>0)return k.map(R=>({name:R.color_name,hex:R.hex_color.replace("#","").substring(0,6),manufacturer:R.manufacturer,material:typeof R.material=="string"?R.material:void 0}))}const P=_&&N?`${_} ${N}`:"";if(P){const k=a.filter(A=>C(A.manufacturer)&&A.material?.toLowerCase()===P);if(k.length>0)return k.map(A=>({name:A.color_name,hex:A.hex_color.replace("#","").substring(0,6),manufacturer:A.manufacturer,material:typeof A.material=="string"?A.material:void 0}));const R=P.replace(/\+$/,"");if(R!==P){const A=a.filter(D=>C(D.manufacturer)&&D.material?.toLowerCase()===R);if(A.length>0)return A.map(D=>({name:D.color_name,hex:D.hex_color.replace("#","").substring(0,6),manufacturer:D.manufacturer,material:typeof D.material=="string"?D.material:void 0}))}}if(_){const k=a.filter(R=>C(R.manufacturer)&&(!R.material||R.material.toLowerCase().startsWith(_)));if(k.length>0)return k.map(R=>({name:R.color_name,hex:R.hex_color.replace("#","").substring(0,6),manufacturer:R.manufacturer,material:typeof R.material=="string"?R.material:void 0}))}return[]},[a,t.brand,t.material,t.subtype]),y=w.useMemo(()=>{if(!c)return f;if(f.length===0)return[];const g=c.toLowerCase();return f.filter(N=>N.name.toLowerCase().includes(g)||(N.manufacturer?.toLowerCase().includes(g)??!1)||(N.material?.toLowerCase().includes(g)??!1))},[c,f]),v=f.length>0,b=w.useMemo(()=>c?DY.filter(g=>g.name.toLowerCase().includes(c.toLowerCase())):o?DY:qoe,[c,o]);return i.jsxs("div",{className:"space-y-3",children:[i.jsx("div",{className:"h-10 rounded-lg border border-bambu-dark-tertiary",style:{backgroundColor:`#${d}`}}),n.length>0&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-bambu-gray shrink-0",children:[i.jsx(Jn,{className:"w-3 h-3"}),i.jsx("span",{children:s("inventory.recentColors")})]}),i.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.map(g=>i.jsx("button",{type:"button",onClick:()=>p(g.hex,g.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 ${m(g.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${g.hex}`},title:g.name},g.hex))})]}),i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),i.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:s("inventory.searchColors"),value:c,onChange:g=>u(g.target.value)})]}),v?i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("span",{className:"text-xs text-bambu-gray",children:c?s("inventory.searchResults"):`${t.brand}${t.material?` ${t.material}`:""}`}),i.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[y.map(g=>i.jsx("button",{type:"button",onClick:()=>p(g.hex,g.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${m(g.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${g.hex}`},title:g.manufacturer&&g.material?`${g.name} (${g.manufacturer} — ${g.material})`:g.manufacturer?`${g.name} (${g.manufacturer})`:g.name,children:i.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:g.manufacturer&&g.material?`${g.name} (${g.manufacturer} — ${g.material})`:g.manufacturer?`${g.name} (${g.manufacturer})`:g.name})},`${g.hex}-${g.name}-${g.manufacturer??""}`)),y.length===0&&i.jsx("p",{className:"text-sm text-bambu-gray py-1",children:s("inventory.noColorsFound")})]})]}):i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray",children:[i.jsx("span",{children:s(c?"inventory.searchResults":o?"inventory.allColors":"inventory.commonColors")}),!c&&i.jsx("button",{type:"button",onClick:()=>l(!o),className:"flex items-center gap-1 hover:text-white transition-colors",children:o?i.jsxs(i.Fragment,{children:[s("inventory.showLess")," ",i.jsx($l,{className:"w-3 h-3"})]}):i.jsxs(i.Fragment,{children:[s("inventory.showAll")," ",i.jsx(On,{className:"w-3 h-3"})]})})]}),i.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[b.map(g=>i.jsx("button",{type:"button",onClick:()=>p(g.hex,g.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${m(g.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${g.hex}`},title:g.name,children:i.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:g.name})},g.hex)),b.length===0&&i.jsx("p",{className:"text-sm text-bambu-gray py-1",children:s("inventory.noColorsFound")})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:s("inventory.colorName")}),i.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:s("inventory.colorNamePlaceholder"),value:t.color_name,onChange:g=>e("color_name",g.target.value)})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:s("inventory.hexColor")}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray",children:"#"}),i.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:d.toUpperCase(),onChange:g=>{const _=g.target.value.replace("#","").replace(/[^0-9A-Fa-f]/g,"");_.length<=8&&e("rgba",_.toUpperCase()+(_.length<=6?"FF":""))}})]}),i.jsx("input",{type:"color",className:"w-11 h-[38px] rounded-lg cursor-pointer border border-bambu-dark-tertiary shrink-0 bg-transparent",value:`#${d}`,onChange:g=>{const _=g.target.value.replace("#","").toUpperCase();e("rgba",_+"FF")},title:s("inventory.pickColor")})]})]})]})]})}function Htt({catalog:t,value:e,onChange:n,catalogId:r,onCatalogIdChange:a}){const{t:s}=Rt(),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=w.useRef(null),m=w.useRef(null);w.useEffect(()=>{const v=b=>{d.current&&!d.current.contains(b.target)&&l(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]),w.useEffect(()=>{if(t.length===0)return;const v=t.filter(b=>b.weight===e);if(r){const b=t.find(g=>g.id===r);if(b&&b.weight===e)return}v.length===1?a(v[0].id):v.length===0&&r!==null&&a(null)},[e,t,r,a]);const p=w.useMemo(()=>{if(!c)return t;const v=c.toLowerCase();return t.filter(b=>b.name.toLowerCase().includes(v)||b.weight.toString().includes(v))},[t,c]),f=w.useMemo(()=>t.filter(v=>v.weight===e),[t,e]),y=w.useMemo(()=>{if(o)return c;if(r){const v=t.find(b=>b.id===r);if(v)return v.name}return f.length>0?f[0].name:""},[o,c,r,t,f]);return i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(Mge,{className:"w-3.5 h-3.5 text-bambu-gray"}),s("inventory.coreWeight")]})}),i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsxs("div",{className:"flex-1 min-w-0 relative",ref:d,children:[i.jsx("input",{ref:m,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:s("inventory.searchSpoolWeight"),value:y,onFocus:()=>{l(!0),u("")},onChange:v=>{u(v.target.value),l(!0)}}),o&&i.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:p.length===0?i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:s("inventory.noResults")}):p.map(v=>i.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 ${(r?v.id===r:v.weight===e)?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{a(v.id),n(v.weight),l(!1),u("")},children:[i.jsx("span",{className:"truncate",children:v.name}),i.jsxs("span",{className:"font-mono text-xs text-bambu-gray ml-2 shrink-0",children:[v.weight,"g"]})]},v.id))})]}),i.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[i.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:e,min:0,max:2e3,onChange:v=>{const b=parseInt(v.target.value);!isNaN(b)&&b>=0&&n(b)}}),i.jsx("span",{className:"text-bambu-gray text-sm",children:"g"})]})]})]})}function $tt({formData:t,updateField:e,spoolCatalog:n,currencySymbol:r}){const{t:a}=Rt(),{showToast:s}=fn(),[o,l]=w.useState(""),[c,u]=w.useState(!1),[d,m]=w.useState(""),[p,f]=w.useState(!1),y=Math.max(0,t.label_weight-t.weight_used),v=t.core_weight+y;return w.useEffect(()=>{c||l(String(v))},[c,v]),w.useEffect(()=>{p||m(String(y))},[p,y]),i.jsxs("div",{className:"space-y-4",children:[i.jsx(Htt,{catalog:n,value:t.core_weight,onChange:b=>e("core_weight",b),catalogId:t.core_weight_catalog_id,onCatalogIdChange:b=>e("core_weight_catalog_id",b)}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:a("inventory.currentWeight")}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx("input",{type:"number",value:d,min:0,max:t.label_weight,onFocus:()=>f(!0),onChange:b=>{m(b.target.value)},onBlur:()=>{f(!1);const b=d.trim(),g=Number(b);if(!b||!Number.isFinite(g)||g<0||g>t.label_weight){m(String(y));return}const _=Math.round(g);e("weight_used",Math.max(0,t.label_weight-_)),m(String(_))},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"}),i.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]}),i.jsxs("span",{className:"text-xs text-bambu-gray shrink-0",children:["/ ",t.label_weight,"g"]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:a("inventory.measuredWeight")}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx("input",{type:"number",value:o,min:0,onFocus:()=>u(!0),onChange:b=>{l(b.target.value)},onBlur:()=>{u(!1);const b=o.trim(),g=Number(b),_=t.core_weight,N=t.core_weight+t.label_weight;if(!b||!Number.isFinite(g)||g<_||g>N){s(a("inventory.measuredWeightError",{min:_,max:N}),"error"),l(String(v));return}const T=Math.round(g),C=Math.max(0,Math.min(t.label_weight,T-t.core_weight));e("weight_used",Math.max(0,t.label_weight-C)),l(String(T))},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"}),i.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]}),i.jsxs("span",{className:"text-xs text-bambu-gray shrink-0",children:["/ ",t.core_weight+t.label_weight,"g"]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:a("inventory.costPerKg","Cost per kg")}),i.jsx("div",{className:"flex items-center gap-2",children:i.jsxs("div",{className:"relative flex-1",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none",children:r}),i.jsx("input",{type:"number",value:t.cost_per_kg??"",min:0,step:.01,placeholder:"0.00",onChange:b=>{const g=b.target.value===""?null:parseFloat(b.target.value);e("cost_per_kg",g)},style:{paddingLeft:`${Math.max(2,r.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"})]})})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:a("inventory.note")}),i.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:a("inventory.notePlaceholder"),value:t.note,onChange:b=>e("note",b.target.value)})]})]})}function qtt({formData:t,printersWithCalibrations:e,selectedProfiles:n,setSelectedProfiles:r,expandedPrinters:a,setExpandedPrinters:s}){const{t:o}=Rt(),l=p=>{s(f=>{const y=new Set(f);return y.has(p)?y.delete(p):y.add(p),y})},c=(p,f,y)=>{const v=`${p}:${f}:${y??"null"}`,b=`${p}:${y??"null"}`;r(g=>{const _=new Set(g);if(_.has(v))_.delete(v);else{for(const N of Array.from(_)){const T=N.split(":");`${T[0]}:${T[2]}`===b&&_.delete(N)}_.add(v)}return _})},u=()=>{const p=new Set;for(const{printer:f,calibrations:y}of e){if(!f.connected)continue;const v=y.filter(g=>KD(g,t)),b=new Map;for(const g of v){const _=`${g.extruder_id??"null"}`;b.has(_)||b.set(_,[]),b.get(_).push(g)}for(const[g,_]of b)if(_.length>0){const T=[..._].sort((C,P)=>P.k_value-C.k_value)[0];p.add(`${f.id}:${T.cali_idx}:${g}`)}}r(p)};if(!t.material)return i.jsx("div",{className:"p-6 bg-bambu-dark rounded-lg text-center",children:i.jsx("p",{className:"text-bambu-gray",children:o("inventory.selectMaterialFirst")})});if(e.length===0)return i.jsx("div",{className:"p-6 bg-bambu-dark rounded-lg text-center",children:i.jsx("p",{className:"text-bambu-gray",children:o("inventory.noPrintersConfigured")})});const d=e.reduce((p,{printer:f,calibrations:y})=>f.connected?p+y.filter(v=>KD(v,t)).length:p,0),m=(p,f)=>{const y=`${p.id}:${f.cali_idx}:${f.extruder_id??"null"}`,v=n.has(y);return i.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-all border ${v?"bg-bambu-green/10 border-bambu-green/30":"bg-bambu-dark border-transparent hover:bg-bambu-dark/80"}`,children:[i.jsx("input",{type:"checkbox",checked:v,onChange:()=>c(String(p.id),f.cali_idx,f.extruder_id),className:"w-4 h-4 rounded border-bambu-dark-tertiary text-bambu-green focus:ring-bambu-green"}),i.jsx("div",{className:"flex-1 min-w-0",children:i.jsx("span",{className:`text-sm font-medium ${v?"text-bambu-green":"text-white"}`,children:f.name||f.filament_id})}),i.jsx("div",{className:"flex items-center gap-2 shrink-0",children:i.jsxs("span",{className:"text-xs font-mono px-2 py-0.5 rounded bg-bambu-dark text-bambu-gray",children:["K=",f.k_value.toFixed(3)]})})]},`${f.cali_idx}-${f.extruder_id}`)};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("p",{className:"text-xs text-bambu-gray",children:[o("inventory.matchingFilter"),": ",t.brand||o("inventory.anyBrand")," / ",t.material," / ",t.subtype||o("inventory.anyVariant")]}),d>0&&i.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-1.5 px-2 py-1 text-xs bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white hover:border-bambu-green transition-colors",children:[i.jsx(ox,{className:"w-3.5 h-3.5"}),o("inventory.autoSelect")," (",d,")"]})]}),i.jsx("div",{className:"space-y-3",children:e.map(({printer:p,calibrations:f})=>{const y=a.has(String(p.id)),v=f.filter(T=>KD(T,t)),b=v.length,g=v.some(T=>T.extruder_id!==void 0&&T.extruder_id!==null&&T.extruder_id>0),_=v.filter(T=>T.extruder_id===1),N=v.filter(T=>T.extruder_id===0||T.extruder_id===void 0||T.extruder_id===null);return i.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[i.jsxs("button",{type:"button",onClick:()=>l(String(p.id)),className:"w-full px-4 py-3 flex items-center justify-between bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary transition-colors",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[y?i.jsx(On,{className:"w-4 h-4 text-bambu-gray"}):i.jsx(fa,{className:"w-4 h-4 text-bambu-gray"}),i.jsx("span",{className:"font-medium text-white",children:p.name}),b>0?i.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:[b," ",o(b!==1?"inventory.matches":"inventory.match")]}):i.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray",children:o("inventory.noMatches")})]}),i.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${p.connected?"bg-green-500/20 text-green-500":"bg-bambu-gray/20 text-bambu-gray"}`,children:p.connected?o("inventory.connected"):o("inventory.offline")})]}),y&&i.jsx("div",{className:"px-4 py-3 space-y-3 bg-bambu-dark border-t border-bambu-dark-tertiary",children:p.connected?b===0?i.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:o("inventory.noKProfilesMatch")}):g?i.jsxs(i.Fragment,{children:[_.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wide",children:o("inventory.leftNozzle")}),i.jsx("div",{className:"space-y-2",children:_.map(T=>m(p,T))})]}),N.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wide",children:o("inventory.rightNozzle")}),i.jsx("div",{className:"space-y-2",children:N.map(T=>m(p,T))})]})]}):i.jsx("div",{className:"space-y-2",children:v.map(T=>m(p,T))}):i.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:o("inventory.printerOffline")})})]},p.id)})}),n.size>0&&i.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:i.jsxs("p",{className:"text-sm text-white",children:[i.jsx("span",{className:"font-semibold",children:n.size})," ",o("inventory.profilesSelected")]})})]})}function Vtt(t){const e=new Date(t);return e.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"})+" "+e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})}const Gtt={completed:"text-bambu-green",failed:"text-red-400",aborted:"text-yellow-400"};function Wtt({spoolId:t}){const{t:e}=Rt(),n=sn(),{showToast:r}=fn(),{data:a,isLoading:s}=tt({queryKey:["spool-usage",t],queryFn:()=>fe.getSpoolUsageHistory(t)}),o=ft({mutationFn:()=>fe.clearSpoolUsageHistory(t),onSuccess:()=>{n.invalidateQueries({queryKey:["spool-usage",t]}),r(e("inventory.historyCleared"),"success")}});return s?i.jsx("div",{className:"flex justify-center py-4",children:i.jsx(pt,{className:"w-5 h-5 animate-spin text-bambu-green"})}):!a||a.length===0?i.jsxs("div",{className:"text-center py-4 text-bambu-gray text-sm",children:[i.jsx(Jn,{className:"w-5 h-5 mx-auto mb-2 opacity-50"}),e("inventory.noUsageHistory")]}):i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h4",{className:"text-sm font-medium text-white",children:e("inventory.usageHistory")}),i.jsxs(Ie,{variant:"ghost",size:"sm",onClick:()=>o.mutate(),disabled:o.isPending,className:"text-xs text-bambu-gray hover:text-red-400",children:[i.jsx(en,{className:"w-3 h-3 mr-1"}),e("inventory.clearHistory")]})]}),i.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:a.map(l=>i.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-bambu-dark/50 text-xs",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("span",{className:"text-bambu-gray",children:Vtt(l.created_at)}),l.print_name&&i.jsx("span",{className:"text-white ml-2 truncate",title:l.print_name,children:l.print_name})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-2",children:[i.jsxs("span",{className:"text-white font-medium",children:[l.weight_used.toFixed(1),"g"]}),i.jsxs("span",{className:"text-bambu-gray",children:["(",l.percent_used,"%)"]}),i.jsx("span",{className:Gtt[l.status]||"text-bambu-gray",children:l.status})]})]},l.id))})]})}function Ktt({isOpen:t,onClose:e,spool:n,printersWithCalibrations:r=[],currencySymbol:a}){const{t:s}=Rt(),o=sn(),{showToast:l}=fn(),c=!!n,[u,d]=w.useState(jY),[m,p]=w.useState({}),[f,y]=w.useState("filament"),[v,b]=w.useState(!1),[g,_]=w.useState(!1),[N,T]=w.useState(1),[C,P]=w.useState(!1),[k,R]=w.useState(!1),[A,D]=w.useState([]),[B,z]=w.useState(""),[W,I]=w.useState([]),[J,ie]=w.useState([]),[Q,ue]=w.useState([]),[me,pe]=w.useState([]),[Y,se]=w.useState([]),[oe,be]=w.useState(new Set),[Me,q]=w.useState(new Set),Z=r.length>0?r:Y,j=w.useMemo(()=>oe.size,[oe]);w.useEffect(()=>{pe(Itt())},[]),w.useEffect(()=>{t&&((async()=>{R(!0);try{const de=await fe.getCloudStatus();if(P(de.is_authenticated),de.is_authenticated){const ke=await fe.getFilamentPresets();D(ke)}}catch(de){console.error("Failed to fetch cloud presets:",de),P(!1)}finally{R(!1)}})(),fe.getSpoolCatalog().then(I).catch(console.error),fe.getColorCatalog().then(ue).catch(console.error),fe.getLocalPresets().then(de=>ie(de.filament)).catch(console.error),r.length===0&&(async()=>{try{const de=await fe.getPrinters(),ke=await Promise.all(de.map(Le=>fe.getPrinterStatus(Le.id).catch(()=>null))),_e=[];for(let Le=0;Le({cali_idx:je.slot_id,filament_id:je.filament_id,setting_id:je.setting_id||"",name:je.name,k_value:parseFloat(je.k_value)||0,n_coef:parseFloat(je.n_coef)||0,extruder_id:je.extruder_id,nozzle_diameter:je.nozzle_diameter}))}catch{}_e.push({printer:{...$e,connected:Ae},calibrations:Pe})}se(_e)}catch(de){console.error("Failed to fetch printer calibrations:",de)}})())},[t,r.length]);const E=w.useMemo(()=>Ltt(A,new Set,J),[A,J]),U=w.useMemo(()=>{const he=Rtt(A,J),de=Q.map(_e=>_e.manufacturer?.trim()).filter(_e=>!!_e),ke=new Set([...he,...de]);return Array.from(ke).sort((_e,Le)=>_e.localeCompare(Le))},[A,J,Q]),K=w.useMemo(()=>{const he=Q.map(ke=>ke.material?.trim()).filter(ke=>!!ke),de=new Set([...Ptt,...he]);return Array.from(de).sort((ke,_e)=>ke.localeCompare(_e))},[Q]),$=w.useMemo(()=>{const he=[];for(const de of Q){const ke=de.manufacturer?.trim(),_e=de.material?.trim();ke&&_e&&he.push({brand:ke,material:_e})}for(const de of A){const ke=Dx(de.name);ke.brand&&ke.material&&he.push({brand:ke.brand,material:ke.material})}for(const de of J){const ke=Dx(de.name),_e=de.filament_vendor?.trim()||ke.brand,Le=ke.material;_e&&Le&&he.push({brand:_e,material:Le})}return he},[A,Q,J]),ne=w.useMemo(()=>{const he=new Map;for(const de of $){const ke=de.brand.toLowerCase(),_e=de.material.toLowerCase();he.has(ke)||he.set(ke,new Set),he.get(ke).add(_e)}return he},[$]),O=w.useMemo(()=>{const he=new Map;for(const de of $){const ke=de.brand.toLowerCase(),_e=de.material.toLowerCase();he.has(_e)||he.set(_e,new Set),he.get(_e).add(ke)}return he},[$]),V=w.useMemo(()=>{if(!u.material)return U;const he=u.material.toLowerCase(),de=O.get(he);return!de||de.size===0?U:U.filter(ke=>de.has(ke.toLowerCase()))},[U,u.material,O]),ee=w.useMemo(()=>{if(!u.brand)return K;const he=u.brand.toLowerCase(),de=ne.get(he);return!de||de.size===0?K:K.filter(ke=>de.has(ke.toLowerCase()))},[K,u.brand,ne]),G=w.useMemo(()=>Ott(u.slicer_filament,E),[u.slicer_filament,E]);w.useEffect(()=>{if(t){if(n)if(d({material:n.material||"",subtype:n.subtype||"",brand:n.brand||"",color_name:n.color_name||"",rgba:n.rgba||"808080FF",label_weight:n.label_weight||1e3,core_weight:n.core_weight||250,core_weight_catalog_id:n.core_weight_catalog_id??null,weight_used:n.weight_used||0,slicer_filament:n.slicer_filament||"",note:n.note||"",cost_per_kg:n.cost_per_kg??null}),z(n.slicer_filament_name||n.slicer_filament||""),n.k_profiles&&n.k_profiles.length>0){const he=new Set;for(const de of n.k_profiles)de.cali_idx!==null&&de.cali_idx!==void 0&&he.add(`${de.printer_id}:${de.cali_idx}:${de.extruder??"null"}`);be(he)}else be(new Set);else d(jY),z(""),be(new Set),_(!1),T(1);p({}),y("filament"),b(!1)}},[t,n]),w.useEffect(()=>{t&&Z.length>0&&q(new Set(Z.map(he=>String(he.printer.id))))},[t,Z]);const re=(he,de)=>{d(ke=>({...ke,[he]:de})),he==="weight_used"&&b(!0),m[he]&&p(ke=>({...ke,[he]:void 0}))},ce=he=>{pe(de=>ztt(he,de))},ge=ft({mutationFn:he=>fe.createSpool(he),onSuccess:async he=>{oe.size>0&&he?.id&&await F(he.id),await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolCreated"),"success"),e()},onError:he=>{l(he.message,"error")}}),xe=ft({mutationFn:({data:he,qty:de})=>fe.bulkCreateSpools(he,de),onSuccess:async he=>{if(oe.size>0)for(const de of he)await F(de.id);await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolsCreated",{count:he.length}),"success"),e()},onError:he=>{l(he.message,"error")}}),ae=ft({mutationFn:he=>fe.updateSpool(n.id,he),onSuccess:async()=>{n?.id&&await F(n.id),await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolUpdated"),"success"),e()},onError:he=>{l(he.message,"error")}}),L=ft({mutationFn:()=>fe.updateSpool(n.id,{tag_uid:null}),onSuccess:async()=>{await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.tagDeleted","Tag removed"),"success"),e()},onError:he=>{l(he.message,"error")}}),F=async he=>{if(oe.size===0){try{await fe.saveSpoolKProfiles(he,[])}catch{}return}const de=[];for(const ke of oe){const[_e,Le,$e]=ke.split(":"),Re=parseInt(_e),Ae=parseInt(Le),Pe=$e==="null"?0:parseInt($e),Ue=Z.find(je=>je.printer.id===Re);if(Ue){const je=Ue.calibrations.find(Xe=>Xe.cali_idx===Ae);je&&de.push({printer_id:Re,extruder:Pe,nozzle_diameter:je.nozzle_diameter||"0.4",k_value:je.k_value,name:je.name||null,cali_idx:je.cali_idx,setting_id:je.setting_id||null})}}if(de.length>0)try{await fe.saveSpoolKProfiles(he,de)}catch(ke){console.error("Failed to save K-profiles:",ke)}};if(w.useEffect(()=>{if(!t)return;const he=de=>{de.key==="Escape"&&e()};return document.addEventListener("keydown",he),()=>document.removeEventListener("keydown",he)},[t,e]),!t)return null;const te=()=>{const he=Att(u,g);if(!he.isValid){p(he.errors),(he.errors.slicer_filament||he.errors.material||he.errors.brand||he.errors.subtype)&&y("filament");return}const de=G?.displayName||B||null,ke={material:u.material,subtype:u.subtype||null,brand:u.brand||null,color_name:u.color_name||null,rgba:u.rgba||null,label_weight:u.label_weight,core_weight:u.core_weight,core_weight_catalog_id:u.core_weight_catalog_id,slicer_filament:u.slicer_filament||null,slicer_filament_name:de,nozzle_temp_min:null,nozzle_temp_max:null,note:u.note||null,cost_per_kg:u.cost_per_kg};(!c||v)&&(ke.weight_used=u.weight_used),c?ae.mutate(ke):N>1?xe.mutate({data:ke,qty:N}):ge.mutate(ke)},ve=ge.isPending||xe.isPending||ae.isPending||L.isPending;return i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[i.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),i.jsxs("div",{className:"relative w-full max-w-xl mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[i.jsx("h2",{className:"text-lg font-semibold text-white",children:s(c?"inventory.editSpool":"inventory.addSpool")}),i.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:i.jsx(Ht,{className:"w-5 h-5"})})]}),!c&&i.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-bambu-dark-tertiary flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Mc,{className:"w-4 h-4 text-amber-400"}),i.jsx("span",{className:"text-sm text-white",children:s("inventory.quickAdd")})]}),i.jsx("button",{type:"button",onClick:()=>{_(!g),g||y("filament")},className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${g?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:i.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${g?"translate-x-4":"translate-x-0.5"}`})})]}),i.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary flex-shrink-0",children:[i.jsxs("button",{onClick:()=>y("filament"),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${f==="filament"?"text-bambu-green border-b-2 border-bambu-green":"text-bambu-gray hover:text-white"}`,children:[i.jsx(yw,{className:"w-4 h-4"}),s("inventory.filamentInfoTab")]}),!g&&i.jsxs("button",{onClick:()=>y("pa-profile"),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${f==="pa-profile"?"text-bambu-green border-b-2 border-bambu-green":"text-bambu-gray hover:text-white"}`,children:[i.jsx(yhe,{className:"w-4 h-4"}),s("inventory.paProfileTab"),j>0&&i.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:j})]})]}),i.jsx("div",{className:"p-4 overflow-y-auto flex-1",style:{scrollbarGutter:"stable"},children:f==="filament"?i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:s("inventory.filamentInfo")}),i.jsx(Utt,{formData:u,updateField:re,cloudAuthenticated:C,loadingCloudPresets:k,presetInputValue:B,setPresetInputValue:z,selectedPresetOption:G,filamentOptions:E,availableBrands:V,availableMaterials:ee,quickAdd:g,quantity:N,onQuantityChange:T,errors:m})]}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:s("inventory.color")}),i.jsx(Btt,{formData:u,updateField:re,recentColors:me,onColorUsed:ce,catalogColors:Q})]}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:s("inventory.additional")}),i.jsx($tt,{formData:u,updateField:re,spoolCatalog:W,currencySymbol:a})]}),c&&n&&i.jsx("div",{children:i.jsx(Wtt,{spoolId:n.id})})]}):i.jsx(qtt,{formData:u,updateField:re,printersWithCalibrations:Z,selectedProfiles:oe,setSelectedProfiles:be,expandedPrinters:Me,setExpandedPrinters:q})}),i.jsxs("div",{className:"flex gap-2 p-4 border-t border-bambu-dark-tertiary flex-shrink-0",children:[c&&i.jsxs(Ie,{variant:"secondary",onClick:()=>L.mutate(),disabled:ve||!n?.tag_uid,className:"mr-auto",children:[i.jsx(Id,{className:"w-4 h-4"}),s("inventory.deleteTag","Delete Tag")]}),i.jsxs("div",{className:"flex gap-2 ml-auto",children:[i.jsx(Ie,{variant:"secondary",onClick:e,children:s("common.cancel")}),i.jsx(Ie,{onClick:te,disabled:ve,children:ve?i.jsxs(i.Fragment,{children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),s("common.saving")]}):i.jsxs(i.Fragment,{children:[i.jsx(ss,{className:"w-4 h-4"}),s(c?"common.save":"inventory.addSpool")]})})]})]})]})]})}function Ytt({isOpen:t,onClose:e,columns:n,defaultColumns:r,onSave:a}){const{t:s}=Rt(),[o,l]=w.useState(n),[c,u]=w.useState(null),d=w.useRef(null);if(w.useEffect(()=>{t&&l(n.map(T=>({...T})))},[t,n]),w.useEffect(()=>{if(!t)return;const T=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t,e]),!t)return null;const m=T=>{l(C=>C.map((P,k)=>k===T?{...P,visible:!P.visible}:P))},p=(T,C)=>{C<0||C>=o.length||l(P=>{const k=[...P],[R]=k.splice(T,1);return k.splice(C,0,R),k})},f=(T,C)=>{d.current=C,u(C),T.dataTransfer.effectAllowed="move"},y=(T,C)=>{T.preventDefault(),T.dataTransfer.dropEffect="move";const P=d.current;P!==null&&P!==C&&(p(P,C),d.current=C,u(C))},v=T=>{T.preventDefault()},b=()=>{d.current=null,u(null)},g=()=>{l(r.map(T=>({...T})))},_=()=>{a(o),e()},N=o.filter(T=>T.visible).length;return i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:i.jsx(Pt,{className:"w-full max-w-md max-h-[80vh] flex flex-col",onClick:T=>T.stopPropagation(),children:i.jsxs(Et,{className:"p-6 flex flex-col min-h-0",children:[i.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:s("inventory.configureColumns")}),i.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:[s("inventory.configureColumnsDesc"),i.jsxs("span",{className:"ml-2 text-bambu-gray/60",children:["(",N," ",s("inventory.of")," ",o.length," ",s("inventory.visible"),")"]})]}),i.jsx("div",{className:"space-y-1 overflow-y-auto flex-1 min-h-0 pr-1",children:o.map((T,C)=>i.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg border transition-colors ${c===C?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-tertiary/50"} ${T.visible?"":"opacity-50"}`,draggable:!0,onDragStart:P=>f(P,C),onDragOver:P=>y(P,C),onDrop:v,onDragEnd:b,children:[i.jsx("div",{className:"cursor-grab text-bambu-gray/50 hover:text-bambu-gray",children:i.jsx(Sh,{className:"w-4 h-4"})}),i.jsx("span",{className:"flex-1 font-medium text-sm text-white",children:T.label}),i.jsxs("div",{className:"flex items-center gap-0.5",children:[i.jsx("button",{onClick:()=>p(C,C-1),disabled:C===0,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed",title:s("inventory.moveUp"),children:i.jsx($l,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>p(C,C+1),disabled:C===o.length-1,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed",title:s("inventory.moveDown"),children:i.jsx(On,{className:"w-4 h-4"})})]}),i.jsx("button",{onClick:()=>m(C),className:`p-1.5 rounded transition-colors ${T.visible?"text-bambu-green hover:bg-bambu-green/10":"text-bambu-gray/50 hover:bg-bambu-dark-secondary"}`,title:T.visible?s("inventory.hideColumn"):s("inventory.showColumn"),children:T.visible?i.jsx(Ac,{className:"w-4 h-4"}):i.jsx(fw,{className:"w-4 h-4"})})]},T.id))}),i.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[i.jsxs(Ie,{variant:"secondary",onClick:g,className:"mr-auto",children:[i.jsx(So,{className:"w-4 h-4"}),s("inventory.reset")]}),i.jsx(Ie,{variant:"secondary",onClick:e,children:s("inventory.cancel")}),i.jsx(Ie,{onClick:_,children:s("inventory.applyChanges")})]})]})})})}function RY(t){return`${t.material}|${t.subtype||""}|${t.brand||""}|${t.color_name||""}|${t.rgba||""}|${t.label_weight}`}const Goe="bambuddy-inventory-columns",SN=[{id:"id",label:"#",visible:!0},{id:"added_time",label:"Added",visible:!0},{id:"encode_time",label:"Encoded",visible:!1},{id:"last_used_time",label:"Last Used",visible:!1},{id:"rgba",label:"Color",visible:!0},{id:"material",label:"Material",visible:!0},{id:"subtype",label:"Subtype",visible:!0},{id:"color_name",label:"Color Name",visible:!1},{id:"brand",label:"Brand",visible:!0},{id:"slicer_filament",label:"Slicer Filament",visible:!1},{id:"location",label:"Location",visible:!0},{id:"label_weight",label:"Label",visible:!0},{id:"net",label:"Net",visible:!0},{id:"gross",label:"Gross",visible:!1},{id:"added_full",label:"Full",visible:!1},{id:"used",label:"Used",visible:!1},{id:"printed_total",label:"Printed Total",visible:!1},{id:"printed_since_weight",label:"Printed Since Weight",visible:!1},{id:"note",label:"Note",visible:!1},{id:"pa_k",label:"PA(K)",visible:!0},{id:"tag_id",label:"Tag ID",visible:!1},{id:"data_origin",label:"Data Origin",visible:!1},{id:"tag_type",label:"Linked Tag Type",visible:!1},{id:"stock",label:"Stock",visible:!1},{id:"remaining",label:"Remaining",visible:!0},{id:"spool_name",label:"Spool",visible:!1},{id:"cost_per_kg",label:"Cost/kg",visible:!1},{id:"weight_check",label:"Weight Check",visible:!1}];function Xtt(){try{const t=localStorage.getItem(Goe);if(t){const e=JSON.parse(t),n=new Set(SN.map(o=>o.id)),r=new Set(e.map(o=>o.id)),a=e.filter(o=>n.has(o.id)),s=SN.filter(o=>!r.has(o.id));return[...a,...s]}}catch{}return SN.map(t=>({...t}))}function Qtt(t){try{localStorage.setItem(Goe,JSON.stringify(t))}catch{}}function du(t,e=!1){return e&&t>=1e3?`${(t/1e3).toFixed(1)}kg`:`${Math.round(t)}g`}const Ztt={PLA:"bg-green-500/20 text-green-400",ABS:"bg-red-500/20 text-red-400",PETG:"bg-blue-500/20 text-blue-400",TPU:"bg-purple-500/20 text-purple-400",ASA:"bg-orange-500/20 text-orange-400",PA:"bg-yellow-500/20 text-yellow-400",PC:"bg-cyan-500/20 text-cyan-400",PET:"bg-sky-500/20 text-sky-400"};function YD(t,e="system"){if(!t)return"-";const n=Zn(t);return n?N3(n,e):"-"}const Jtt={id:()=>"#",added_time:()=>"Added",encode_time:()=>"Encoded",last_used_time:()=>"Last Used",rgba:t=>t("inventory.color"),material:t=>t("inventory.material"),subtype:t=>t("inventory.subtype"),color_name:t=>t("inventory.colorName"),brand:t=>t("inventory.brand"),slicer_filament:t=>t("inventory.slicerFilament"),location:()=>"Location",label_weight:t=>t("inventory.labelWeight"),net:t=>t("inventory.net"),gross:()=>"Gross",added_full:()=>"Full",used:t=>t("inventory.weightUsed"),printed_total:()=>"Printed Total",printed_since_weight:()=>"Printed Since Weight",note:t=>t("inventory.note"),pa_k:()=>"PA(K)",tag_id:()=>"Tag ID",data_origin:()=>"Data Origin",tag_type:()=>"Linked Tag Type",stock:t=>t("inventory.stock"),remaining:t=>t("inventory.remaining"),spool_name:t=>t("inventory.spoolName"),cost_per_kg:t=>t("inventory.costPerKg"),weight_check:t=>t("inventory.weightCheck")},SL={id:({spool:t})=>i.jsx("span",{className:"text-sm font-medium text-white",children:t.id}),added_time:({spool:t,dateFormat:e})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:YD(t.created_at,e)}),encode_time:({spool:t,dateFormat:e})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:YD(t.encode_time,e)}),last_used_time:({spool:t,dateFormat:e})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:t.last_used?YD(t.last_used,e):"Never"}),rgba:({spool:t})=>i.jsx("div",{className:"flex items-center justify-center",children:i.jsx("span",{className:"w-5 h-5 rounded-full border border-black/20 flex-shrink-0",style:{backgroundColor:t.rgba?`#${t.rgba.substring(0,6)}`:"#808080"},title:t.rgba?`#${t.rgba.substring(0,6)}`:void 0})}),material:({spool:t})=>i.jsx("span",{className:"text-sm text-white",children:t.material}),subtype:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:t.subtype||"-"}),color_name:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:PI(t.color_name,t.rgba)||"-"}),brand:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:t.brand||"-"}),slicer_filament:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray",title:t.slicer_filament||void 0,children:t.slicer_filament_name||t.slicer_filament||"-"}),location:({spool:t,assignmentMap:e})=>{const n=e[t.id];if(!n)return i.jsx("span",{className:"text-sm text-bambu-gray",children:"-"});const r=n.printer_name||`Printer ${n.printer_id}`,a=n.ams_id===254||n.ams_id===255,s=!a&&n.ams_id>=128,o=EI(n.ams_id,n.tray_id,s,a);return i.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-purple-500/20 text-purple-400",children:[r," ",o,n.ams_label?` (${n.ams_label})`:""]})},label_weight:({spool:t})=>i.jsx("span",{className:"text-sm text-white",children:du(t.label_weight)}),net:({remaining:t})=>i.jsx("span",{className:"text-sm text-white",children:du(t)}),gross:({spool:t,remaining:e})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:du(e+t.core_weight)}),added_full:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:t.added_full==null?"-":t.added_full?"Yes":"No"}),used:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:t.weight_used>0?du(t.weight_used):"-"}),printed_total:()=>i.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"}),printed_since_weight:()=>i.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"}),note:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray max-w-[150px] truncate block",title:t.note||void 0,children:t.note||"-"}),pa_k:({spool:t})=>(t.k_profiles?.length??0)===0?i.jsx("span",{className:"text-sm text-bambu-gray",children:"-"}):i.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-bambu-green/20 text-bambu-green",children:"K"}),tag_id:({spool:t})=>{const e=t.tag_uid||t.tray_uuid;return e?i.jsx("span",{className:"text-sm text-bambu-gray font-mono",title:e,children:e.length>12?`${e.slice(0,6)}...${e.slice(-4)}`:e}):i.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"})},data_origin:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:t.data_origin||"-"}),tag_type:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:t.tag_type||"-"}),stock:({spool:t,t:e})=>t.slicer_filament?i.jsx("span",{className:"text-sm text-bambu-gray",children:"-"}):i.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-amber-500/20 text-amber-400",children:e("inventory.stock")}),remaining:({remaining:t,pct:e})=>i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:i.jsx("div",{className:`h-full rounded-full ${e>50?"bg-bambu-green":e>20?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(e,100)}%`}})}),i.jsxs("span",{className:"text-xs text-bambu-gray min-w-[40px] text-right",children:[Math.round(t),"g"]})]}),spool_name:({spool:t,catalogMap:e})=>{const n=t.core_weight_catalog_id!=null?e[t.core_weight_catalog_id]:void 0;return i.jsx("span",{className:"text-sm text-bambu-gray",children:n?.name||"-"})},cost_per_kg:({spool:t,currencySymbol:e})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:t.cost_per_kg!=null?`${e}${t.cost_per_kg.toFixed(2)}`:"-"}),weight_check:({spool:t,onSyncWeight:e})=>{const n=t.last_scale_weight;if(n==null)return i.jsx("span",{className:"text-sm text-bambu-gray/50",title:"No scale measurement",children:"-"});const r=t.core_weight||0,a=Math.max(0,t.label_weight-t.weight_used)+r;let s,o;n0?`+${Math.round(s)}`:`${Math.round(s)}`,c=o?`Scale: ${Math.round(n)}g +`+n+"}"}return String(t)}function Xet({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:a,hasPermission:s,t:o}){const{showToast:l}=fn(),c=sn(),[u,d]=w.useState(!1),{data:m,isLoading:p}=tt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>fe.getCloudSettingDetail(t.setting_id)}),f=ft({mutationFn:()=>fe.deleteCloudSetting(t.setting_id),onSuccess:()=>{l(o("profiles.presets.toast.deleted")),c.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:b=>l(b.message,"error")}),y=uw(t.setting_id),v=C5(t.name,m?.setting?.inherits);return i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:i.jsx(Pt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:i.jsxs(Et,{className:"p-0 flex flex-col min-h-0 flex-1",children:[i.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),y&&i.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:o("profiles.presets.editable")})]}),i.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[i.jsx("span",{className:"capitalize",children:o(`profiles.presets.types.${t.type}`)}),v.printer&&i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"•"}),i.jsx("span",{children:v.printer})]})]})]}),i.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:i.jsx(Ht,{className:"w-5 h-5"})})]}),i.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:p?i.jsx("div",{className:"flex items-center justify-center py-16",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):m?i.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full",children:vL(m)}):i.jsx("div",{className:"text-center py-16 text-bambu-gray",children:o("profiles.presets.failedToLoadDetails")})}),u?i.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[i.jsx(Mn,{className:"w-5 h-5"}),i.jsx("span",{className:"font-medium",children:o("profiles.presets.deleteConfirm")})]}),i.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:o("profiles.presets.deleteWarning",{name:t.name})}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Ie,{variant:"secondary",onClick:()=>d(!1),disabled:f.isPending,className:"flex-1",children:o("common.cancel")}),i.jsxs(Ie,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):i.jsx(en,{className:"w-4 h-4"}),o("common.delete")]})]})]}):i.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Ie,{variant:"secondary",onClick:e,className:"flex-1",children:o("common.close")}),i.jsxs(Ie,{variant:"secondary",onClick:r,disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDuplicatePermission"),children:[i.jsx(vo,{className:"w-4 h-4"}),o("profiles.presets.duplicate")]}),y&&i.jsxs(i.Fragment,{children:[i.jsxs(Ie,{variant:"secondary",onClick:a,disabled:p||!m||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noEditPermission"),children:[i.jsx(Ki,{className:"w-4 h-4"}),o("common.edit")]}),i.jsx(Ie,{variant:"danger",onClick:()=>d(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDeletePermission"),children:i.jsx(en,{className:"w-4 h-4"})})]})]})})]})})})}function zoe(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Uoe(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function Qet({onClose:t,onApply:e,t:n}){const{showToast:r}=fn(),[a,s]=w.useState(zoe),[o,l]=w.useState("all"),[c,u]=w.useState(null),[d,m]=w.useState(""),[p,f]=w.useState(""),[y,v]=w.useState("{}"),[b,g]=w.useState(null),[_,N]=w.useState(null),T=o==="all"?a:a.filter(W=>W.type===o),C=W=>{s(W),Uoe(W)},P=W=>{const I=a.filter(J=>J.id!==W);C(I),N(null),r(n("profiles.templates.toast.deleted"))},k=W=>{u(W.id),m(W.name),f(W.description),v(JSON.stringify(W.settings,null,2)),g(null)},R=()=>{if(!(!c||!d.trim()))try{const W=JSON.parse(y),I=a.map(J=>J.id===c?{...J,name:d.trim(),description:p.trim(),settings:W}:J);C(I),u(null),r(n("profiles.templates.toast.updated"))}catch(W){g(W.message)}},A=()=>{u(null),m(""),f(""),v("{}"),g(null)},D=W=>{const I=a.map(J=>J.id===W?{...J,showInModal:!J.showInModal}:J);C(I)},B={filament:{label:n("profiles.presets.types.filament"),icon:QC,color:"text-amber-400"},print:{label:n("profiles.presets.types.process"),icon:Od,color:"text-blue-400"},printer:{label:n("profiles.presets.types.printer"),icon:_r,color:"text-purple-400"}},z=_?a.find(W=>W.id===_):null;return w.useEffect(()=>{const W=I=>{I.key==="Escape"&&(_?N(null):c?A():t())};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[_,c,t]),i.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[z&&i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:i.jsx(Pt,{className:"w-full max-w-md",children:i.jsxs(Et,{className:"p-6",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[i.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:i.jsx(Mn,{className:"w-6 h-6 text-red-400"})}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-lg font-semibold text-white",children:n("profiles.templates.deleteTitle")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:n("profiles.templates.deleteWarning")})]})]}),i.jsx("p",{className:"text-white mb-6",children:n("profiles.templates.deleteConfirm",{name:z.name})}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Ie,{variant:"secondary",onClick:()=>N(null),className:"flex-1",children:n("common.cancel")}),i.jsxs(Ie,{onClick:()=>P(_),className:"flex-1 bg-red-500 hover:bg-red-600",children:[i.jsx(en,{className:"w-4 h-4"}),n("common.delete")]})]})]})})}),i.jsx(Pt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:i.jsxs(Et,{className:"p-0 flex flex-col h-full",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(ox,{className:"w-5 h-5 text-amber-400"}),n("profiles.templates.title")]}),i.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:i.jsx(Ht,{className:"w-5 h-5"})})]}),i.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[i.jsx("span",{className:"text-sm text-bambu-gray",children:n("profiles.templates.typeFilter")}),["all","filament","print","printer"].map(W=>i.jsx("button",{onClick:()=>l(W),className:`px-3 py-1 text-sm rounded-lg transition-colors ${o===W?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:W==="all"?n("common.all"):B[W].label},W))]}),i.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:T.length===0?i.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[i.jsx(ox,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),i.jsx("p",{children:n("profiles.templates.noTemplates")}),i.jsx("p",{className:"text-sm mt-1",children:n("profiles.templates.createFirst")})]}):i.jsx("div",{className:"space-y-2",children:T.map(W=>{const I=B[W.type],J=I.icon;return c===W.id?i.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[i.jsx("input",{type:"text",value:d,onChange:ie=>m(ie.target.value),placeholder:n("profiles.templates.namePlaceholder"),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),i.jsx("input",{type:"text",value:p,onChange:ie=>f(ie.target.value),placeholder:n("profiles.templates.descriptionPlaceholder"),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:n("profiles.templates.settingsJson")}),i.jsx("textarea",{value:y,onChange:ie=>{v(ie.target.value),g(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${b?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),b&&i.jsx("p",{className:"text-xs text-red-400 mt-1",children:b})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs(Ie,{size:"sm",onClick:R,disabled:!d.trim(),children:[i.jsx(ss,{className:"w-4 h-4"}),"Save"]}),i.jsx(Ie,{size:"sm",variant:"secondary",onClick:A,children:"Cancel"})]})]},W.id):i.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[i.jsx(J,{className:`w-5 h-5 ${I.color} flex-shrink-0`}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-sm font-medium text-white",children:W.name}),i.jsx("p",{className:"text-xs text-bambu-gray truncate",children:W.description})]}),i.jsx("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:n("profiles.templates.fieldsCount",{count:Object.keys(W.settings).length})}),i.jsx("button",{onClick:()=>D(W.id),className:`p-1 transition-colors ${W.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:W.showInModal?n("profiles.templates.shownInModals"):n("profiles.templates.hiddenInModals"),children:W.showInModal?i.jsx(Ac,{className:"w-4 h-4"}):i.jsx(fw,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>e(W),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:n("profiles.templates.apply")}),i.jsx("button",{onClick:()=>k(W),className:"p-1 text-bambu-gray hover:text-white",title:n("common.edit"),children:i.jsx(Ki,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>N(W.id),className:"p-1 text-bambu-gray hover:text-red-400",title:n("common.delete"),children:i.jsx(en,{className:"w-4 h-4"})})]},W.id)})})})]})})]})}function Boe({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:a,t:s}){const[o,l]=w.useState("changes"),[c,u]=w.useState(""),d=w.useMemo(()=>{const y=new Set([...Object.keys(e),...Object.keys(n)]),v=[];for(const b of y){if(b==="inherits"||b==="version")continue;const g=e[b],_=n[b],N=b in e,T=b in n;let C;!N&&T?C="added":N&&!T?C="removed":JSON.stringify(g)!==JSON.stringify(_)?C="changed":C="same",v.push({key:b,left:g,right:_,status:C})}return v.sort((b,g)=>{const _={changed:0,added:1,removed:2,same:3};return _[b.status]!==_[g.status]?_[b.status]-_[g.status]:b.key.localeCompare(g.key)})},[e,n]),m=w.useMemo(()=>{let y=[...d];if(o==="changes"&&(y=y.filter(v=>v.status!=="same")),c){const v=c.toLowerCase();y=y.filter(b=>b.key.toLowerCase().includes(v)||String(b.left).toLowerCase().includes(v)||String(b.right).toLowerCase().includes(v))}return y},[d,o,c]),p=w.useMemo(()=>({added:d.filter(y=>y.status==="added").length,removed:d.filter(y=>y.status==="removed").length,changed:d.filter(y=>y.status==="changed").length,same:d.filter(y=>y.status==="same").length}),[d]),f=y=>{if(y===void 0)return"—";if(y===null)return"null";if(Array.isArray(y))return y.length===0?"[]":y.length===1?String(y[0]):y.join(", ");if(typeof y=="object")return JSON.stringify(y);const v=String(y);if(v.includes("\\n")||v.length>100){const b=v.split("\\n").length;if(b>1)return`[${b} lines of G-code/script]`;if(v.length>100)return v.substring(0,100)+"…"}return v};return w.useEffect(()=>{const y=v=>{v.key==="Escape"&&t()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[t]),i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:i.jsx(Pt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:i.jsxs(Et,{className:"p-0 flex flex-col min-h-0 flex-1",children:[i.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(Bb,{className:"w-5 h-5 text-blue-400"}),s("profiles.diff.title")]}),i.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:i.jsx(Ht,{className:"w-5 h-5"})})]}),i.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[i.jsxs("div",{className:"text-center",children:[i.jsx("span",{className:"text-sm text-bambu-gray",children:s("profiles.diff.left")}),i.jsx("p",{className:"text-white font-medium truncate",children:r})]}),i.jsxs("div",{className:"text-center",children:[i.jsx("span",{className:"text-sm text-bambu-gray",children:s("profiles.diff.right")}),i.jsx("p",{className:"text-white font-medium truncate",children:a})]})]}),i.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[i.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[i.jsx(ar,{className:"w-3.5 h-3.5"}),p.added," ",s("profiles.diff.added")]}),i.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[i.jsx(RN,{className:"w-3.5 h-3.5"}),p.removed," ",s("profiles.diff.removed")]}),i.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[i.jsx(g3,{className:"w-3.5 h-3.5"}),p.changed," ",s("profiles.diff.changed")]}),i.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[i.jsx($M,{className:"w-3.5 h-3.5"}),p.same," ",s("profiles.diff.same")]})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),i.jsx("input",{type:"text",value:c,onChange:y=>u(y.target.value),placeholder:s("profiles.diff.searchFields"),className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),p.same>0&&i.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[i.jsx("button",{onClick:()=>l("changes"),className:`px-3 py-1.5 text-sm transition-colors ${o==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s("profiles.diff.changes")}),i.jsx("button",{onClick:()=>l("all"),className:`px-3 py-1.5 text-sm transition-colors ${o==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s("common.all")})]})]})]}),i.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:m.length===0?i.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[i.jsx($M,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),i.jsx("p",{children:s(o==="changes"?"profiles.diff.noDifferences":"profiles.diff.noFieldsMatch")})]}):i.jsxs("table",{className:"w-full",children:[i.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:i.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[i.jsx("th",{className:"text-left p-3 w-1/3",children:s("profiles.diff.field")}),i.jsx("th",{className:"text-left p-3 w-1/3",children:r}),i.jsx("th",{className:"text-left p-3 w-1/3",children:a})]})}),i.jsx("tbody",{children:m.map(y=>{const v={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[y.status],b={added:i.jsx(ar,{className:"w-3.5 h-3.5 text-green-400"}),removed:i.jsx(RN,{className:"w-3.5 h-3.5 text-red-400"}),changed:i.jsx(g3,{className:"w-3.5 h-3.5 text-amber-400"}),same:i.jsx($M,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[y.status];return i.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${v}`,children:[i.jsx("td",{className:"p-3",children:i.jsxs("div",{className:"flex items-center gap-2",children:[b,i.jsx("span",{className:"text-sm text-white font-mono",children:y.key})]})}),i.jsx("td",{className:"p-3",children:i.jsx("span",{className:`text-sm font-mono break-all ${y.status==="removed"?"text-red-300":y.status==="changed"?"text-white":"text-bambu-gray"}`,children:f(y.left)})}),i.jsx("td",{className:"p-3",children:i.jsx("span",{className:`text-sm font-mono break-all ${y.status==="added"?"text-green-300":y.status==="changed"?"text-white":"text-bambu-gray"}`,children:f(y.right)})})]},y.key)})})]})})]})})})}function Zet({onClose:t,initialData:e,allPresets:n,t:r}){const{showToast:a}=fn(),s=sn(),o=!!e?.setting_id,[l,c]=w.useState("common"),[u,d]=w.useState(e?.type||"filament"),[m,p]=w.useState(e?.name?o?e.name:`${e.name} (Copy)`:""),[f,y]=w.useState(e?.base_id||""),[v,b]=w.useState(""),[g,_]=w.useState(e?.setting||{inherits:""}),[N,T]=w.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[C,P]=w.useState(null),[k,R]=w.useState(""),[A,D]=w.useState(!1),[B,z]=w.useState(""),[W,I]=w.useState(!1),[J,ie]=w.useState(zoe),[Q,ue]=w.useState(!1),[me,pe]=w.useState(""),[Y,se]=w.useState(""),[oe,be]=w.useState(!0),[Me,q]=w.useState(null),[Z,j]=w.useState(!1),E=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[u]||[],[n,u]),U=w.useMemo(()=>E.filter(Pe=>uw(Pe.setting_id)),[E]),{data:K}=tt({queryKey:["cloudFields",u],queryFn:()=>fe.getCloudFields(u==="print"?"process":u),staleTime:1e3*60*60}),{data:$}=tt({queryKey:["allPresetDetails",u,U.map(Pe=>Pe.setting_id).join(",")],queryFn:async()=>{const Pe={};for(let je=0;je{try{const Ee=await fe.getCloudSettingDetail(Ge.setting_id);return{id:Ge.setting_id,detail:Ee}}catch{return null}}))).forEach(Ge=>{Ge&&(Pe[Ge.id]=Ge.detail)})}return Pe},enabled:U.length>0,staleTime:1e3*60*10}),{data:ne,isLoading:O}=tt({queryKey:["cloudSettingDetail",f],queryFn:()=>fe.getCloudSettingDetail(f),enabled:!!f});w.useEffect(()=>{l!=="json"&&T(JSON.stringify(g,null,2))},[g,l]);const V=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[u]||[]).filter(Ue=>!uw(Ue.setting_id)).sort((Ue,je)=>Ue.name.localeCompare(je.name)),[n,u]);w.useEffect(()=>{if(!f)return;const Pe=V.find(Ue=>Ue.setting_id===f);Pe&&(b(Pe.name),o||(_({inherits:Pe.name}),T(JSON.stringify({inherits:Pe.name},null,2))))},[f,V,o]);const ee=w.useMemo(()=>{const Pe=K?.fields||[],Ue=new Set(Pe.map(Ge=>Ge.key)),je=new Set,Xe=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);$&&Object.values($).forEach(Ge=>{Ge?.setting&&Object.keys(Ge.setting).forEach(Ee=>{!Ue.has(Ee)&&!Xe.has(Ee)&&je.add(Ee)})}),Object.keys(g).forEach(Ge=>{!Ue.has(Ge)&&!Xe.has(Ge)&&je.add(Ge)});const ye=Array.from(je).sort().map(Ge=>({key:Ge,label:Ge.replace(/_/g," ").replace(/\b\w/g,Ee=>Ee.toUpperCase()),type:"text",category:"discovered",description:r("profiles.presets.discoveredFromPresets")}));return[...Pe,...ye]},[K,$,g,r]),G=ee.filter(Pe=>Pe.label.toLowerCase().includes(k.toLowerCase())||Pe.key.toLowerCase().includes(k.toLowerCase())),re=()=>{if(B.trim()){const Pe=B.trim().toLowerCase().replace(/\s+/g,"_");ce(Pe,""),z(""),I(!1),a(r("profiles.presets.toast.fieldAdded",{key:Pe}))}},ce=(Pe,Ue)=>{_(je=>{const Xe={...je};return Ue===""||Ue===void 0?delete Xe[Pe]:Xe[Pe]=Ue,Xe})},ge=Pe=>{_(Ue=>({...Ue,...Pe.settings})),q(Pe.name),a(r("profiles.templates.toast.applied"))},xe=()=>{if(!me.trim())return;const Pe={...g};if(delete Pe.inherits,Object.keys(Pe).length===0){a(r("profiles.presets.noOverridesToSave"),"error");return}const Ue={id:Date.now().toString(),name:me.trim(),description:Y.trim()||r("profiles.presets.customTemplate"),type:u,settings:Pe,showInModal:oe},je=[...J,Ue];ie(je),Uoe(je),ue(!1),pe(""),se(""),be(!0),a(r("profiles.templates.toast.created"))},ae=w.useMemo(()=>J.filter(Pe=>Pe.type===u&&Pe.showInModal),[u,J]),L=Pe=>{T(Pe);try{const Ue=JSON.parse(Pe);_(Ue),P(null)}catch(Ue){P(Ue.message)}},F=Pe=>{Pe.preventDefault(),D(!1);const Ue=Pe.dataTransfer.files[0];if(Ue&&Ue.name.endsWith(".json")){const je=new FileReader;je.onload=Xe=>{try{const ye=Xe.target?.result,Ge=JSON.parse(ye),Ee=Ge.setting||Ge;_(Ke=>({...Ke,...Ee})),T(JSON.stringify({...g,...Ee},null,2)),a(r("profiles.presets.fileImported"))}catch{a(r("profiles.presets.invalidJsonFile"),"error")}},je.readAsText(Ue)}},te=ft({mutationFn:()=>{const Pe={...g},Ue=u==="filament"?"filament_settings_id":u==="print"?"print_settings_id":"printer_settings_id";Pe[Ue]=`"${m}"`;const je={type:u,name:m,base_id:f,setting:Pe};return fe.createCloudSetting(je)},onSuccess:async()=>{a(r("profiles.presets.toast.created")),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:Pe=>a(Pe.message,"error")}),ve=ft({mutationFn:()=>{if(!e?.setting_id)throw new Error(r("profiles.presets.noSettingId"));return fe.updateCloudSetting(e.setting_id,{name:m,setting:g})},onSuccess:async()=>{a(r("profiles.presets.toast.updated")),s.removeQueries({queryKey:["cloudSettingDetail"]}),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:Pe=>a(Pe.message,"error")}),he=o?ve:te,de=ne?.setting?.inherits,ke=de?V.find(Pe=>Pe.name===de):void 0,{data:_e}=tt({queryKey:["cloudSettingDetail",ke?.setting_id],queryFn:()=>fe.getCloudSettingDetail(ke.setting_id),enabled:!!ke?.setting_id}),Le=w.useMemo(()=>{const Pe=_e?.setting||{},Ue=ne?.setting||{},je=f&&$?.[f]?.setting?$[f].setting:{};return{...Pe,...Ue,...je}},[f,ne,_e,$]),$e=Pe=>{if(Pe==null)return"";if(Array.isArray(Pe)){const Ue=[...new Set(Pe.map(je=>String(je)))];return Ue.length===1?Ue[0]:Pe.join(", ")}return String(Pe)},Re=Pe=>{const Ue=g[Pe.key],je=Le[Pe.key],Xe=$e(je),ye=O?r("common.loading"):Xe||"",Ge="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(Pe.type==="boolean"){const Ee=Ue==="1"||Ue===void 0&&je==="1";return i.jsx("button",{type:"button",onClick:()=>ce(Pe.key,Ue==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Ee?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:i.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Ee?"translate-x-3.5":"translate-x-0.5"}`})})}return Pe.type==="select"?i.jsxs("select",{value:Ue||"",onChange:Ee=>ce(Pe.key,Ee.target.value),className:Ge,children:[i.jsx("option",{value:"",children:ye}),Pe.options?.map(Ee=>i.jsx("option",{value:Ee.value,children:Ee.label},Ee.value))]}):i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:Pe.type==="number"?"number":"text",value:Ue!==void 0?String(Ue):"",onChange:Ee=>ce(Pe.key,Ee.target.value),step:Pe.step,min:Pe.min,max:Pe.max,placeholder:ye,className:Ge}),Pe.unit&&i.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:Pe.unit})]})},Ae=w.useMemo(()=>ne?.setting?ne.setting:{},[ne]);return i.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:Pe=>{Pe.preventDefault(),D(!0)},onDragLeave:()=>D(!1),onDrop:F,children:[Z&&f&&i.jsx(Boe,{onClose:()=>j(!1),leftPreset:Ae,rightPreset:g,leftLabel:r("profiles.presets.baseLabel",{name:v||f}),rightLabel:r("profiles.presets.currentLabel",{name:m||r("profiles.presets.newPreset")}),t:r}),i.jsx(Pt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col overflow-y-auto",children:i.jsxs(Et,{className:"p-0 flex flex-col h-full",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-semibold text-white",children:r(o?"profiles.presets.editPreset":e?"profiles.presets.duplicatePreset":"profiles.presets.createNewPreset")}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("profiles.presets.customizeSettings")})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[f&&i.jsxs("button",{onClick:()=>j(!0),className:"flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:r("profiles.presets.compareWithBase"),children:[i.jsx(Bb,{className:"w-4 h-4"}),r("profiles.presets.compare")]}),i.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:i.jsx(Ht,{className:"w-5 h-5"})})]})]}),A&&i.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:i.jsxs("div",{className:"text-center",children:[i.jsx(vi,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),i.jsx("p",{className:"text-bambu-green font-medium",children:r("profiles.presets.dropJsonToImport")})]})}),i.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[i.jsxs("div",{className:"grid grid-cols-3 gap-4 max-[640px]:grid-cols-1",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("common.type")}),i.jsxs("select",{value:u,onChange:Pe=>{d(Pe.target.value),y("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"filament",children:r("profiles.presets.types.filament")}),i.jsx("option",{value:"print",children:r("profiles.presets.types.process")}),i.jsx("option",{value:"printer",children:r("profiles.presets.types.printer")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.basePreset")}),i.jsxs("select",{value:f,onChange:Pe=>y(Pe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"",children:r("profiles.presets.selectBasePreset")}),V.map(Pe=>i.jsx("option",{value:Pe.setting_id,children:Pe.name},Pe.setting_id))]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.presetName")}),i.jsx("input",{type:"text",value:m,onChange:Pe=>p(Pe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:r("profiles.presets.myCustomPreset")})]})]}),v&&i.jsx("div",{className:"text-xs text-bambu-gray",children:i.jsxs("p",{className:"flex items-center gap-1",children:[i.jsx(Qr,{className:"w-3 h-3 text-bambu-green"}),r("profiles.presets.inheritsFrom")," ",i.jsx("span",{className:"text-white",children:v}),O&&i.jsx(pt,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),i.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary max-[640px]:flex-wrap max-[640px]:items-center",children:[i.jsxs("button",{onClick:()=>c("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[i.jsx(G8,{className:"w-4 h-4"}),r("profiles.presets.tabs.common")]}),i.jsxs("button",{onClick:()=>c("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[i.jsx(eT,{className:"w-4 h-4"}),r("profiles.presets.tabs.allFields")]}),i.jsxs("button",{onClick:()=>c("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[i.jsx(HX,{className:"w-4 h-4"}),"JSON",C&&i.jsx(Li,{className:"w-3 h-3 text-red-400"})]}),i.jsx("div",{className:"flex-1 max-[640px]:hidden"}),i.jsxs("button",{onClick:()=>{const Pe={name:m,type:u,base_id:f,setting:g},Ue=new Blob([JSON.stringify(Pe,null,2)],{type:"application/json"}),je=URL.createObjectURL(Ue),Xe=document.createElement("a");Xe.href=je,Xe.download=`${m||"preset"}.json`,document.body.appendChild(Xe),Xe.click(),document.body.removeChild(Xe),URL.revokeObjectURL(je),a(r("profiles.presets.toast.exported"))},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.exportToJson"),children:[i.jsx(bi,{className:"w-4 h-4"}),r("common.download")]}),i.jsxs("button",{onClick:()=>document.getElementById("file-import")?.click(),className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.importFromJson"),children:[i.jsx(vi,{className:"w-4 h-4"}),r("common.upload")]}),i.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:Pe=>{const Ue=Pe.target.files?.[0];if(Ue){const je=new FileReader;je.onload=Xe=>{try{const ye=JSON.parse(Xe.target?.result),Ge=ye.setting||ye;_(Ee=>({...Ee,...Ge})),a(r("profiles.presets.fileImported"))}catch{a(r("profiles.presets.invalidJson"),"error")}},je.readAsText(Ue)}}})]}),i.jsxs("div",{className:"flex-1 p-4",children:[l==="common"&&i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[i.jsx(ox,{className:"w-4 h-4 text-amber-400"}),r("profiles.templates.title")]}),Object.keys(g).filter(Pe=>Pe!=="inherits").length>0&&i.jsxs("button",{onClick:()=>ue(!Q),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[i.jsx(ss,{className:"w-3 h-3"}),r("profiles.presets.saveAsTemplate")]})]}),Q&&i.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[i.jsx("input",{type:"text",value:me,onChange:Pe=>pe(Pe.target.value),placeholder:r("profiles.templates.namePlaceholder"),className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),i.jsx("input",{type:"text",value:Y,onChange:Pe=>se(Pe.target.value),placeholder:r("profiles.templates.descriptionPlaceholder"),className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsxs(Ie,{size:"sm",onClick:xe,disabled:!me.trim(),children:[i.jsx(ss,{className:"w-3 h-3"}),r("common.save")]}),i.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>ue(!1),children:r("common.cancel")})]}),i.jsxs("button",{onClick:()=>be(!oe),className:`flex items-center gap-1.5 text-xs transition-colors ${oe?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[oe?i.jsx(Ac,{className:"w-3.5 h-3.5"}):i.jsx(fw,{className:"w-3.5 h-3.5"}),r(oe?"profiles.templates.shownInModals":"profiles.templates.hiddenInModals")]})]})]}),Me&&i.jsxs("div",{className:"mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2",children:[i.jsx(Qr,{className:"w-4 h-4 text-bambu-green"}),i.jsxs("span",{className:"text-sm text-bambu-green",children:[r("profiles.presets.templateApplied")," ",i.jsx("span",{className:"font-medium",children:Me})]}),i.jsx("button",{onClick:()=>q(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:i.jsx(Ht,{className:"w-4 h-4"})})]}),i.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[ae.map(Pe=>i.jsxs("button",{onClick:()=>ge(Pe),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[i.jsx("p",{className:"text-sm font-medium text-white",children:Pe.name}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:Pe.description})]},Pe.id)),ae.length===0&&i.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:r("profiles.presets.noTemplatesSelected")})]}),i.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:r("profiles.presets.manageTemplatesHint")})]}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.commonSettings")}),i.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:ee.slice(0,10).map(Pe=>i.jsxs("div",{className:"flex items-center justify-between gap-4 max-[640px]:flex-col max-[640px]:items-start",children:[i.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:Pe.label}),i.jsx("div",{className:"w-48 max-[640px]:w-full",children:Re(Pe)})]},Pe.key))})]}),Object.keys(g).length>1&&i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.currentOverrides")}),i.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(g).filter(([Pe])=>Pe!=="inherits").map(([Pe,Ue])=>i.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[Pe,": ",String(Ue).slice(0,20),i.jsx("button",{onClick:()=>ce(Pe,void 0),className:"hover:text-white",children:i.jsx(Ht,{className:"w-3 h-3"})})]},Pe))})]})]}),l==="fields"&&i.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[i.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[i.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.availableFields")}),i.jsx("span",{className:"text-xs text-bambu-gray",children:$?r("profiles.templates.fieldsCount",{count:ee.length}):r("common.loading")})]}),i.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),i.jsx("input",{type:"text",value:k,onChange:Pe=>R(Pe.target.value),placeholder:r("profiles.presets.searchFieldsPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[G.filter(Pe=>!(Pe.key in g)).map(Pe=>{const Ue=Le[Pe.key],je=$e(Ue);return i.jsxs("div",{onClick:()=>{_(Xe=>({...Xe,[Pe.key]:je||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"text-sm text-white truncate",children:Pe.label}),i.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:Pe.key})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[je&&i.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:je,children:[je.slice(0,20),je.length>20?"...":""]}),i.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:i.jsx(ar,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},Pe.key)}),G.filter(Pe=>!(Pe.key in g)).length===0&&i.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:r(k?"profiles.presets.noMatchingFields":"profiles.presets.allFieldsAdded")})]}),i.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:W?i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",value:B,onChange:Pe=>z(Pe.target.value),onKeyDown:Pe=>Pe.key==="Enter"&&re(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),i.jsx(Ie,{size:"sm",onClick:re,disabled:!B.trim(),children:i.jsx(ar,{className:"w-4 h-4"})}),i.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>{I(!1),z("")},children:i.jsx(Ht,{className:"w-4 h-4"})})]}):i.jsxs("button",{onClick:()=>I(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[i.jsx(ar,{className:"w-4 h-4"}),r("profiles.presets.addCustomField")]})})]}),i.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[i.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.yourOverrides")}),i.jsx("span",{className:"text-xs text-bambu-gray",children:r("profiles.templates.fieldsCount",{count:Object.keys(g).filter(Pe=>Pe!=="inherits").length})})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(g).filter(([Pe])=>Pe!=="inherits").map(([Pe,Ue])=>{const je=ee.find(Xe=>Xe.key===Pe);return i.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-medium text-white",children:je?.label||Pe}),i.jsx("p",{className:"text-xs text-bambu-gray-dark",children:Pe})]}),i.jsx("button",{onClick:()=>ce(Pe,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:i.jsx(Ht,{className:"w-4 h-4"})})]}),je?Re(je):i.jsx("input",{type:"text",value:String(Ue),onChange:Xe=>ce(Pe,Xe.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},Pe)}),Object.keys(g).filter(Pe=>Pe!=="inherits").length===0&&i.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[i.jsx(G8,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),i.jsx("p",{className:"text-sm",children:r("profiles.presets.noOverridesYet")}),i.jsx("p",{className:"text-xs mt-1",children:r("profiles.presets.clickFieldsToAdd")})]})]}),Object.keys(g).filter(Pe=>Pe!=="inherits").length>0&&i.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:i.jsxs("button",{onClick:()=>{ue(!0),c("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[i.jsx(ss,{className:"w-4 h-4"}),r("profiles.presets.saveAsTemplate")]})})]})]}),l==="json"&&i.jsxs("div",{className:"space-y-2",children:[C&&i.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[i.jsx(Li,{className:"w-4 h-4"}),C]}),i.jsx("textarea",{value:N,onChange:Pe=>L(Pe.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${C?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),i.jsx("p",{className:"text-xs text-bambu-gray",children:r("profiles.presets.jsonTip")})]})]}),i.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[i.jsx(Ie,{variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),i.jsxs(Ie,{onClick:()=>he.mutate(),disabled:he.isPending||!m.trim()||!o&&!f||!!C,className:"flex-1",children:[he.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):o?i.jsx(ss,{className:"w-4 h-4"}):i.jsx(ar,{className:"w-4 h-4"}),r(o?"common.save":e?"common.duplicate":"common.create")]})]})]})})]})}function Jet({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:a,hasPermission:s,t:o}){const[l,c]=w.useState(""),[u,d]=w.useState("all"),[m,p]=w.useState("all"),[f,y]=w.useState("all"),[v,b]=w.useState("all"),[g,_]=w.useState("all"),[N,T]=w.useState("all"),[C,P]=w.useState(null),[k,R]=w.useState(!1),[A,D]=w.useState(!1),[B,z]=w.useState(null),[W,I]=w.useState(null),[J,ie]=w.useState(null),[Q,ue]=w.useState(!1),[me,pe]=w.useState([null,null]),[Y,se]=w.useState(!1),[oe,be]=w.useState(null),Me=sn(),q=w.useMemo(()=>[...t.filament.map(re=>({...re,type:"filament"})),...t.printer.map(re=>({...re,type:"printer"})),...t.process.map(re=>({...re,type:"process"}))].map(re=>({...re,meta:C5(re.name)})),[t]),Z=w.useMemo(()=>{const G=new Set,re=new Set,ce=new Set;return q.forEach(ge=>{ge.meta.nozzle&&G.add(ge.meta.nozzle),ge.meta.filamentType&&re.add(ge.meta.filamentType),ge.meta.layerHeight&&ce.add(ge.meta.layerHeight)}),{printers:a.map(ge=>({id:ge.id.toString(),name:ge.name})),nozzles:Array.from(G).sort((ge,xe)=>parseFloat(ge)-parseFloat(xe)),filaments:Array.from(re).sort(),layerHeights:Array.from(ce).sort((ge,xe)=>parseFloat(ge)-parseFloat(xe))}},[q,a]),j=w.useMemo(()=>f==="all"?null:a.find(re=>re.id.toString()===f)?.model||null,[f,a]),E=w.useMemo(()=>q.filter(G=>u==="all"||G.type===u).filter(G=>{if(m==="all")return!0;const re=uw(G.setting_id);return m==="custom"?re:!re}).filter(G=>{if(f==="all"||!j)return!0;const re=G.meta.printer?.toLowerCase()||"",ce=j.toLowerCase();return re.includes(ce)||ce.includes(re)}).filter(G=>v==="all"||G.meta.nozzle===v).filter(G=>g==="all"||G.meta.filamentType===g).filter(G=>N==="all"||G.meta.layerHeight===N).filter(G=>l===""||G.name.toLowerCase().includes(l.toLowerCase())).sort((G,re)=>G.name.localeCompare(re.name)),[q,u,m,f,j,v,g,N,l]),U=G=>{if(Q){const re=me[0]?.setting_id===G.setting_id,ce=me[1]?.setting_id===G.setting_id;if(re)pe([me[1],null]);else if(ce)pe([me[0],null]);else if(!me[0])pe([G,null]);else if(me[1]){if(me[0].type!==G.type)return;pe([me[0],G])}else{if(me[0].type!==G.type)return;pe([me[0],G])}}else P(G)},K=G=>{if(me[0]?.setting_id===G.setting_id)return 0;if(me[1]?.setting_id===G.setting_id)return 1},$=async G=>{try{const re=await fe.getCloudSettingDetail(G.setting_id),ce=G.type==="process"?"print":G.type;z({type:ce,name:G.name,base_id:re.base_id||"GFSA00",setting:re.setting||{}}),P(null)}catch(re){console.error("Failed to fetch preset details for duplication:",re)}},ne=async G=>{try{Me.removeQueries({queryKey:["cloudSettingDetail",G.setting_id]});const re=await fe.getCloudSettingDetail(G.setting_id),ce=G.type==="process"?"print":G.type;I({type:ce,name:G.name,base_id:re.base_id||"GFSA00",setting:re.setting||{},setting_id:G.setting_id}),P(null)}catch(re){console.error("Failed to fetch preset details for editing:",re)}},O=()=>{d("all"),p("all"),y("all"),b("all"),_("all"),T("all"),c("")},V=u!=="all"||m!=="all"||f!=="all"||v!=="all"||g!=="all"||N!=="all"||l!=="",ee=t.filament.length+t.printer.length+t.process.length;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"space-y-4 mb-6",children:[i.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),i.jsx("input",{type:"text",value:l,onChange:G=>c(G.target.value),placeholder:o("profiles.cloudView.searchPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),i.jsxs("div",{className:"flex gap-2 max-[550px]:flex-wrap max-[550px]:items-center",children:[i.jsxs(Ie,{variant:Q?"primary":"secondary",onClick:()=>{Q?(ue(!1),pe([null,null])):ue(!0)},children:[i.jsx(Bb,{className:"w-4 h-4"}),o(Q?"common.cancel":"profiles.presets.compare")]}),i.jsxs(Ie,{variant:"secondary",onClick:()=>D(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noTemplatesPermission"),children:[i.jsx(ox,{className:"w-4 h-4"}),o("profiles.cloudView.templates")]}),i.jsxs(Ie,{variant:"secondary",onClick:n,disabled:r||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noRefreshPermission"),children:[i.jsx(Sr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),o("profiles.cloudView.refresh")]}),i.jsxs(Ie,{onClick:()=>R(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noCreatePermission"),children:[i.jsx(ar,{className:"w-4 h-4"}),o("profiles.cloudView.newPreset")]})]})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsx(JC,{className:"w-4 h-4 text-bambu-gray"}),i.jsx(_b,{label:o("profiles.cloudView.filters.type"),value:u,options:[{value:"all",label:o("profiles.cloudView.filters.all"),count:ee},{value:"filament",label:o("profiles.cloudView.filters.filament"),count:t.filament.length},{value:"printer",label:o("profiles.cloudView.filters.printer"),count:t.printer.length},{value:"process",label:o("profiles.cloudView.filters.process"),count:t.process.length}],onChange:G=>d(G)}),i.jsx(_b,{label:o("profiles.cloudView.filters.owner"),value:m,options:[{value:"all",label:o("profiles.cloudView.filters.all")},{value:"custom",label:o("profiles.cloudView.filters.myPresets")},{value:"builtin",label:o("profiles.cloudView.filters.builtIn")}],onChange:G=>p(G)}),Z.printers.length>0&&i.jsx(_b,{label:o("profiles.cloudView.filters.printer"),value:f,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...Z.printers.map(G=>({value:G.id,label:G.name}))],onChange:y}),Z.nozzles.length>0&&i.jsx(_b,{label:o("profiles.cloudView.filters.nozzle"),value:v,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...Z.nozzles.map(G=>({value:G,label:G}))],onChange:b}),Z.filaments.length>0&&(u==="all"||u==="filament")&&i.jsx(_b,{label:o("profiles.cloudView.filters.filament"),value:g,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...Z.filaments.map(G=>({value:G,label:G}))],onChange:_}),Z.layerHeights.length>0&&(u==="all"||u==="process")&&i.jsx(_b,{label:o("profiles.cloudView.filters.layer"),value:N,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...Z.layerHeights.map(G=>({value:G,label:G}))],onChange:T}),V&&i.jsx("button",{onClick:O,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:o("profiles.cloudView.clearFilters")})]})]}),Q&&i.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(Bb,{className:"w-5 h-5 text-blue-400"}),i.jsx("span",{className:"text-white font-medium",children:o("profiles.cloudView.compareMode")}),i.jsx("span",{className:"text-bambu-gray",children:me[0]?o("profiles.cloudView.selectAnotherPreset",{type:me[0].type}):o("profiles.cloudView.clickTwoPresets")})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${me[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:me[0]?me[0].name:o("profiles.cloudView.selectFirst")}),i.jsx(g3,{className:"w-4 h-4 text-bambu-gray"}),i.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${me[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:me[1]?me[1].name:o("profiles.cloudView.selectSecond")})]}),me[0]&&me[1]&&i.jsxs(Ie,{size:"sm",onClick:async()=>{try{const[G,re]=await Promise.all([fe.getCloudSettingDetail(me[0].setting_id),fe.getCloudSettingDetail(me[1].setting_id)]);be([G.setting||{},re.setting||{}]),se(!0)}catch{}},children:[i.jsx(Bb,{className:"w-4 h-4"}),o("profiles.cloudView.compareNow")]})]})]})}),i.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx(Jn,{className:"w-3 h-3"}),o("profiles.cloudView.lastSynced")," ",w0(e.toISOString(),"system",o)]}),i.jsx("span",{children:o("profiles.cloudView.showingCount",{showing:E.length,total:ee})}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),i.jsxs("span",{children:["= ",o("profiles.presets.myPreset")]})]})]}),E.length===0?i.jsxs("div",{className:"text-center py-16",children:[i.jsx(Vi,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),i.jsx("p",{className:"text-bambu-gray",children:o("profiles.cloudView.noPresetsFound")}),V&&i.jsx("button",{onClick:O,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:o("profiles.cloudView.clearFilters")})]}):i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[i.jsx(QC,{className:"w-4 h-4 text-amber-400"}),i.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.filament")}),i.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",E.filter(G=>G.type==="filament").length,")"]})]}),i.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[E.filter(G=>G.type==="filament").map(G=>i.jsx(qD,{setting:G,onClick:()=>U(G),onDuplicate:()=>$(G),compareMode:Q,isCompareSelected:K(G)!==void 0,compareIndex:K(G),compareDisabled:Q&&!!me[0]&&me[0].type!==G.type,t:o},G.setting_id)),E.filter(G=>G.type==="filament").length===0&&i.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noFilamentPresets")})]})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[i.jsx(Od,{className:"w-4 h-4 text-blue-400"}),i.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.process")}),i.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",E.filter(G=>G.type==="process").length,")"]})]}),i.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[E.filter(G=>G.type==="process").map(G=>i.jsx(qD,{setting:G,onClick:()=>U(G),onDuplicate:()=>$(G),compareMode:Q,isCompareSelected:K(G)!==void 0,compareIndex:K(G),compareDisabled:Q&&!!me[0]&&me[0].type!==G.type,t:o},G.setting_id)),E.filter(G=>G.type==="process").length===0&&i.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noProcessPresets")})]})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[i.jsx(_r,{className:"w-4 h-4 text-purple-400"}),i.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.printer")}),i.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",E.filter(G=>G.type==="printer").length,")"]})]}),i.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[E.filter(G=>G.type==="printer").map(G=>i.jsx(qD,{setting:G,onClick:()=>U(G),onDuplicate:()=>$(G),compareMode:Q,isCompareSelected:K(G)!==void 0,compareIndex:K(G),compareDisabled:Q&&!!me[0]&&me[0].type!==G.type,t:o},G.setting_id)),E.filter(G=>G.type==="printer").length===0&&i.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noPrinterPresets")})]})]})]}),C&&i.jsx(Xet,{setting:C,onClose:()=>P(null),onDeleted:()=>P(null),onDuplicate:()=>$(C),onEdit:()=>ne(C),hasPermission:s,t:o}),(k||B||W||J)&&i.jsx(Zet,{onClose:()=>{R(!1),z(null),I(null),ie(null)},initialData:W||B||(J?{type:J.type,name:"",base_id:"",setting:J.setting}:void 0),allPresets:t,t:o}),A&&i.jsx(Qet,{onClose:()=>D(!1),onApply:G=>{ie({type:G.type,setting:G.settings}),D(!1)},t:o}),Y&&oe&&me[0]&&me[1]&&i.jsx(Boe,{onClose:()=>{se(!1),be(null)},leftPreset:oe[0],rightPreset:oe[1],leftLabel:me[0].name,rightLabel:me[1].name,t:o})]})}function ett(){const{t}=Rt(),e=sn(),{showToast:n}=fn(),{hasPermission:r}=Nr(),[a,s]=w.useState("cloud"),[o,l]=w.useState(),{data:c,isLoading:u}=tt({queryKey:["cloudStatus"],queryFn:fe.getCloudStatus}),{data:d=[]}=tt({queryKey:["printers"],queryFn:fe.getPrinters}),{data:m,isLoading:p,refetch:f,dataUpdatedAt:y}=tt({queryKey:["cloudSettings"],queryFn:()=>fe.getCloudSettings(),enabled:!!c?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{y&&l(new Date(y))},[y]);const v=ft({mutationFn:fe.cloudLogout,onSuccess:()=>{e.invalidateQueries({queryKey:["cloudStatus"]}),e.removeQueries({queryKey:["cloudSettings"]}),n(t("profiles.toast.loggedOut"))}}),b=()=>{e.invalidateQueries({queryKey:["cloudStatus"]})};return u?i.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i.jsxs("div",{className:"p-6 lg:p-8",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx("h1",{className:"text-2xl font-bold text-white",children:t("profiles.title")}),i.jsx("p",{className:"text-bambu-gray",children:t("profiles.subtitle")})]}),i.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[i.jsxs("button",{onClick:()=>s("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[i.jsx(Ox,{className:"w-4 h-4"}),t("profiles.tabs.cloud")]}),i.jsxs("button",{onClick:()=>s("local"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="local"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[i.jsx(Ix,{className:"w-4 h-4"}),t("profiles.tabs.local")]}),i.jsxs("button",{onClick:()=>s("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[i.jsx(gw,{className:"w-4 h-4"}),t("profiles.tabs.kprofiles")]})]}),a==="cloud"&&i.jsxs(i.Fragment,{children:[c?.is_authenticated&&i.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),i.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("profiles.connectedAs")," ",i.jsx("span",{className:"text-white",children:c.email})]})]}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>v.mutate(),disabled:v.isPending||!r("cloud:auth"),title:r("cloud:auth")?void 0:t("profiles.noLogoutPermission"),children:[i.jsx(v3,{className:"w-4 h-4"}),t("profiles.logout")]})]}),c?.is_authenticated?p?i.jsx("div",{className:"flex items-center justify-center py-16",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):m?i.jsx(Jet,{settings:m,lastSyncTime:o,onRefresh:()=>f(),isRefreshing:p,printers:d,hasPermission:r,t}):i.jsxs("div",{className:"text-center py-16",children:[i.jsx("p",{className:"text-bambu-gray mb-4",children:t("profiles.failedToLoad")}),i.jsx(Ie,{onClick:()=>f(),children:t("profiles.retry")})]}):i.jsx(Ket,{onSuccess:b,t})]}),a==="local"&&i.jsx(Wet,{}),a==="kprofiles"&&i.jsx($et,{}),i.jsx(Yet,{})]})}const Bv={Droplet:QC,Flame:Ip,Ruler:Tge,Sparkles:ox,Square:ql,Cable:BL,Wrench:kf,Calendar:Yr,Timer:yd,Cog:gpe,Fan:$X,Zap:Mc,Wind:nQ,Thermometer:sT,Layers:Vi,Box:na,Target:JX,RefreshCw:Sr,Settings:aT,Filter:JC,CircleDot:Qhe};function m0(t){return t&&Bv[t]||kf}function Nb(t,e,n){if(e==="days"){if(t<1)return n?n("common.today"):"Today";if(t===1)return n?n("maintenance.day"):"1 day";if(t<7){const a=Math.round(t);return n?n("maintenance.days",{count:a}):`${a} days`}if(t<180){const a=Math.round(t/7);return a===1?n?n("maintenance.week"):"1 week":n?n("maintenance.weeks",{count:a}):`${a} weeks`}const r=Math.round(t/30);return r===1?n?n("maintenance.month"):"1 month":n?n("maintenance.months",{count:r}):`${r} months`}else{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const r=t/24;if(r<7)return`${r<2?r.toFixed(1):Math.round(r)}d`;const a=r/7;return a<12?`${a<2?a.toFixed(1):Math.round(a)}w`:`${Math.round(a/4)}mo`}}function VD(t,e,n){return e==="days"?t===1?n?n("maintenance.day"):"1 day":t===7?n?n("maintenance.week"):"1 week":t===14?n?n("maintenance.weeks",{count:2}):"2 weeks":t===30?n?n("maintenance.month"):"1 month":t===60?n?n("maintenance.months",{count:2}):"2 months":t===90?n?n("maintenance.months",{count:3}):"3 months":t===180?n?n("maintenance.months",{count:6}):"6 months":t===365?n?n("maintenance.year"):"1 year":n?n("maintenance.days",{count:t}):`${t} days`:`${t}h`}function ttt(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),a=n.includes("P1"),s=n.includes("A1MINI"),o=n.includes("A1")&&!s,l=n.includes("H2D"),c=n.includes("H2C"),u=n.includes("H2S"),d=l||c||u,m=n.includes("P2S");switch(t){case"Lubricate Steel Rods":return m?"https://wiki.bambulab.com/en/p2s/maintenance/lubricate-x-y-z-axis":null;case"Clean Steel Rods":return m?"https://wiki.bambulab.com/en/p2s/maintenance/lubricate-x-y-z-axis":null;case"Lubricate Linear Rails":return s?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;case"Clean Nozzle/Hotend":return r||a?"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog":s||o?"https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog":d?"https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning":m?"https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend":"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog";case"Check Belt Tension":return r?"https://wiki.bambulab.com/en/x1/maintenance/belt-tension":a?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":s?"https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension":o?"https://wiki.bambulab.com/en/a1/maintenance/belt_tension":l?"https://wiki.bambulab.com/en/h2/maintenance/belt-tension":c?"https://wiki.bambulab.com/en/h2c/maintenance/belt-tension":u?"https://wiki.bambulab.com/en/h2s/maintenance/belt-tension":m?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/x1/maintenance/belt-tension";case"Clean Carbon Rods":return r||a?"https://wiki.bambulab.com/en/general/carbon-rods-clearance":null;case"Clean Linear Rails":return s?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;case"Clean Build Plate":return"https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide";case"Check PTFE Tube":return r||a?"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube":s||o?"https://wiki.bambulab.com/en/a1-mini/maintenance/ptfe-tube":l?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":u?"https://wiki.bambulab.com/en/h2s/maintenance/replace-ptfe-tube-on-h2s-printer":c?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube";case"Replace HEPA Filter":case"HEPA Filter":case"Replace Carbon Filter":case"Carbon Filter":return d?"https://wiki.bambulab.com/en/h2/maintenance/replace-smoke-purifier-air-filte":"https://wiki.bambulab.com/en/x1/maintenance/replace-carbon-filter";case"Lubricate Left Nozzle Rail":case"Left Nozzle Rail":return d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;default:return null}}function ntt({item:t,onPerform:e,onToggle:n,hasPermission:r,t:a}){const s=m0(t.maintenance_type_icon),o=t.interval_type||"hours",c=(()=>{if(o==="days"){const f=t.days_since_maintenance??0;return Math.max(0,Math.min(100,f/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),u=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",d=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",m=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",p=()=>{if(!t.enabled)return a("common.disabled");if(o==="days"){const f=t.days_until_due??0;return t.is_due?a("maintenance.overdueBy",{duration:Nb(Math.abs(f),"days",a)}):t.is_warning?a("maintenance.dueIn",{duration:Nb(f,"days",a)}):a("maintenance.timeLeft",{duration:Nb(f,"days",a)})}else return t.is_due?a("maintenance.overdueBy",{duration:Nb(Math.abs(t.hours_until_due),"hours",a)}):t.is_warning?a("maintenance.dueIn",{duration:Nb(t.hours_until_due,"hours",a)}):a("maintenance.timeLeft",{duration:Nb(t.hours_until_due,"hours",a)})};return i.jsx("div",{className:`rounded-xl border p-4 transition-all ${m()}`,children:i.jsxs("div",{className:"flex items-start gap-3 max-[550px]:flex-wrap",children:[i.jsxs("div",{className:`relative p-2.5 rounded-lg shrink-0 ${t.is_due?"bg-red-500/20":t.is_warning?"bg-amber-500/20":t.enabled?"bg-bambu-dark":"bg-bambu-dark/50"}`,children:[i.jsx(s,{className:`w-5 h-5 ${u()}`}),t.enabled&&(t.is_due||t.is_warning)&&i.jsx("span",{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${t.is_due?"bg-red-500":"bg-amber-500"} animate-pulse`})]}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),o==="days"&&i.jsx("span",{title:a("maintenance.timeBasedInterval"),children:i.jsx(Yr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const f=t.maintenance_type_wiki_url||ttt(t.maintenance_type_name,t.printer_model);return f?i.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:a("maintenance.viewDocumentation"),onClick:y=>y.stopPropagation(),children:i.jsx(ti,{className:"w-3.5 h-3.5"})}):null})()]}),i.jsx("div",{className:"mt-2 mb-1.5",children:i.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:i.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${d()}`,style:{width:`${c}%`}})})}),i.jsxs("div",{className:`text-xs flex items-center gap-1 ${u()}`,children:[t.is_due&&i.jsx(Mn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&i.jsx(Jn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&i.jsx(Qr,{className:"w-3 h-3"}),p()]})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0 max-[550px]:w-full max-[550px]:justify-end max-[550px]:mt-1",children:[i.jsx("span",{title:r("maintenance:update")?void 0:a("maintenance.noPermissionUpdate"),children:i.jsx(Bn,{checked:t.enabled,onChange:f=>n(t.id,f),disabled:!r("maintenance:update")})}),i.jsxs(Ie,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled||!r("maintenance:update"),title:r("maintenance:update")?void 0:a("maintenance.noPermissionPerform"),className:"!px-3",children:[i.jsx(So,{className:"w-3.5 h-3.5"}),a("common.reset")]})]})]})})}function rtt({overview:t,onPerform:e,onToggle:n,onSetHours:r,hasPermission:a,t:s}){const[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,m]=w.useState(t.total_print_hours.toFixed(1)),p=[...t.maintenance_items].sort((v,b)=>v.is_due&&!b.is_due?-1:!v.is_due&&b.is_due?1:v.is_warning&&!b.is_warning?-1:!v.is_warning&&b.is_warning?1:v.maintenance_type_id-b.maintenance_type_id),f=p.find(v=>v.enabled&&(v.is_due||v.is_warning)),y=()=>{const v=parseFloat(d);!isNaN(v)&&v>=0&&(r(t.printer_id,v),u(!1))};return i.jsxs(Pt,{className:"overflow-hidden",children:[i.jsxs("div",{className:"p-5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),i.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&i.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[i.jsx(Mn,{className:"w-3 h-3"}),s("maintenance.overdueCount",{count:t.due_count})]}),t.warning_count>0&&i.jsxs("span",{className:"px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[i.jsx(Jn,{className:"w-3 h-3"}),s("maintenance.dueSoonCount",{count:t.warning_count})]}),t.due_count===0&&t.warning_count===0&&i.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5",children:[i.jsx(Qr,{className:"w-3 h-3"}),s("maintenance.allGood")]})]})]}),i.jsxs("button",{onClick:()=>l(!o),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[o?i.jsx($l,{className:"w-4 h-4"}):i.jsx(On,{className:"w-4 h-4"}),s(o?"common.collapse":"common.expand")]})]}),i.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:i.jsx(yd,{className:"w-4 h-4 text-bambu-gray"})}),c?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"number",value:d,onChange:v=>m(v.target.value),onKeyDown:v=>{v.key==="Enter"&&y(),v.key==="Escape"&&u(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),i.jsx("span",{className:"text-xs text-bambu-gray",children:s("common.hours")}),i.jsx(Ie,{size:"sm",onClick:y,children:s("common.save")}),i.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>u(!1),children:s("common.cancel")})]}):i.jsxs("button",{onClick:()=>{a("maintenance:update")&&(m(Math.round(t.total_print_hours).toString()),u(!0))},className:`group ${a("maintenance:update")?"":"cursor-not-allowed opacity-60"}`,title:a("maintenance:update")?void 0:s("maintenance.noPermissionEditHours"),children:[i.jsxs("div",{className:`text-sm font-medium text-white ${a("maintenance:update")?"group-hover:text-bambu-green":""} transition-colors flex items-center gap-1`,children:[Math.round(t.total_print_hours)," ",s("common.hours"),i.jsx(_f,{className:`w-3 h-3 text-bambu-gray ${a("maintenance:update")?"group-hover:text-bambu-green":""}`})]}),i.jsx("div",{className:"text-xs text-bambu-gray",children:s("maintenance.totalPrintTime")})]})]}),i.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const v=m0(f.maintenance_type_icon);return i.jsx(v,{className:`w-4 h-4 ${f.is_due?"text-red-400":"text-amber-400"}`})})()}),i.jsxs("div",{children:[i.jsx("div",{className:`text-sm font-medium ${f.is_due?"text-red-400":"text-amber-400"}`,children:f.maintenance_type_name}),i.jsx("div",{className:`text-xs ${f.is_due?"text-red-400/70":"text-amber-400/70"}`,children:f.is_due?s("common.overdue"):s("maintenance.dueSoon")})]})]})]})]}),o&&i.jsx(Et,{className:"pt-0 border-t border-bambu-dark-tertiary",children:i.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:p.map(v=>i.jsx(ntt,{item:v,onPerform:e,onToggle:n,hasPermission:a,t:s},v.id))})})]})}function itt({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:a,onDeleteType:s,onRestoreDefaults:o,isRestoringDefaults:l,onAssignType:c,onRemoveItem:u,hasPermission:d,t:m}){const[p,f]=w.useState(null),[y,v]=w.useState(""),[b,g]=w.useState("hours"),[_,N]=w.useState(!1),[T,C]=w.useState(""),[P,k]=w.useState("100"),[R,A]=w.useState("hours"),[D,B]=w.useState("Wrench"),[z,W]=w.useState(""),[I,J]=w.useState(new Set),[ie,Q]=w.useState(null),[ue,me]=w.useState(null),pe=w.useMemo(()=>t?t.map(L=>({id:L.printer_id,name:L.printer_name})):[],[t]),Y=L=>t?t.filter(F=>F.maintenance_items.some(te=>te.maintenance_type_id===L)).map(F=>({printerId:F.printer_id,printerName:F.printer_name,itemId:F.maintenance_items.find(te=>te.maintenance_type_id===L)?.id})):[],se=L=>{if(!t)return[];const F=new Set(Y(L).map(te=>te.printerId));return pe.filter(te=>!F.has(te.id))},[oe,be]=w.useState(null),[Me,q]=w.useState(""),[Z,j]=w.useState(""),[E,U]=w.useState("hours"),[K,$]=w.useState("Wrench"),[ne,O]=w.useState(""),V=L=>{be(L),q(L.name),j(L.default_interval_hours.toString()),U(L.interval_type||"hours"),$(L.icon||"Wrench"),O(L.wiki_url||"")},ee=()=>{oe&&Me.trim()&&parseFloat(Z)>0&&(a(oe.id,{name:Me.trim(),default_interval_hours:parseFloat(Z),interval_type:E,icon:K,wiki_url:ne.trim()||null}),be(null))},G=(L,F,te)=>{const ve=parseFloat(y);if(!isNaN(ve)&&ve>0){const he=Math.abs(ve-F)<.01?null:ve;n(L,{custom_interval_hours:he,custom_interval_type:b!==te?b:null})}f(null)},re=L=>{L.preventDefault(),T.trim()&&parseFloat(P)>0&&I.size>0&&(r({name:T.trim(),default_interval_hours:parseFloat(P),interval_type:R,icon:D,wiki_url:z.trim()||null},Array.from(I)),C(""),k("100"),A("hours"),W(""),J(new Set),N(!1))},ce=L=>{J(F=>{const te=new Set(F);return te.has(L)?te.delete(L):te.add(L),te})},ge=t?.map(L=>({printerId:L.printer_id,printerName:L.printer_name,items:L.maintenance_items.sort((F,te)=>F.maintenance_type_id-te.maintenance_type_id)})).sort((L,F)=>L.printerName.localeCompare(F.printerName))||[],xe=e.filter(L=>L.is_system),ae=e.filter(L=>!L.is_system);return i.jsxs("div",{className:"space-y-8",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-lg font-semibold text-white",children:m("maintenance.maintenanceTypes")}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:m("maintenance.maintenanceTypesDescription")})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Ie,{variant:"secondary",onClick:o,disabled:!d("maintenance:delete")||l,title:d("maintenance:delete")?void 0:m("maintenance.noPermissionDeleteTypes"),children:m("maintenance.restoreDefaults")}),i.jsxs(Ie,{onClick:()=>N(!_),disabled:!d("maintenance:create"),title:d("maintenance:create")?void 0:m("maintenance.noPermissionEditTypes"),children:[i.jsx(ar,{className:"w-4 h-4"}),m("maintenance.addCustomType")]})]})]}),_&&i.jsx(Pt,{className:"mb-6",children:i.jsx(Et,{className:"py-4",children:i.jsxs("form",{onSubmit:re,children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[i.jsxs("div",{className:"lg:col-span-2",children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:m("common.name")}),i.jsx("input",{type:"text",value:T,onChange:L=>C(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:m("maintenance.exampleName"),autoFocus:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:m("maintenance.intervalType")}),i.jsxs("select",{value:R,onChange:L=>{A(L.target.value),L.target.value==="days"?k("30"):k("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"hours",children:m("maintenance.printHours")}),i.jsx("option",{value:"days",children:m("maintenance.calendarDays")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:m("maintenance.intervalValue",{type:R==="days"?m("maintenance.calendarDays").toLowerCase():m("common.hours")})}),i.jsx("input",{type:"number",value:P,onChange:L=>k(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),i.jsx("div",{className:"mt-4 flex items-end justify-between",children:i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:m("maintenance.icon")}),i.jsx("div",{className:"flex gap-1",children:Object.keys(Bv).map(L=>{const F=Bv[L];return i.jsx("button",{type:"button",onClick:()=>B(L),className:`p-2 rounded-lg transition-colors ${D===L?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:i.jsx(F,{className:"w-4 h-4"})},L)})})]})}),i.jsxs("div",{className:"mt-4",children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:m("maintenance.documentationLink")}),i.jsx("input",{type:"url",value:z,onChange:L=>W(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"https://wiki.bambulab.com/..."})]}),i.jsxs("div",{className:"mt-4",children:[i.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:m("maintenance.assignToPrinters")}),i.jsx("div",{className:"flex flex-wrap gap-2",children:pe.map(L=>i.jsx("button",{type:"button",onClick:()=>ce(L.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${I.has(L.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:L.name},L.id))}),I.size===0&&i.jsx("p",{className:"text-xs text-orange-400 mt-1",children:m("maintenance.selectAtLeastOnePrinter")})]}),i.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:()=>{N(!1),J(new Set)},children:m("common.cancel")}),i.jsx(Ie,{type:"submit",disabled:!T.trim()||I.size===0,children:m("maintenance.addType")})]})]})})}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[xe.map(L=>{const F=m0(L.icon),te=L.interval_type||"hours";return i.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:i.jsx(F,{className:"w-5 h-5 text-bambu-gray"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm font-medium text-white truncate",children:L.name}),i.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[te==="days"?i.jsx(Yr,{className:"w-3 h-3"}):i.jsx(yd,{className:"w-3 h-3"}),VD(L.default_interval_hours,te,m)]})]}),i.jsx("button",{onClick:()=>{d("maintenance:delete")&&me(L)},disabled:!d("maintenance:delete"),title:d("maintenance:delete")?void 0:m("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${d("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:i.jsx(en,{className:"w-4 h-4"})})]})},L.id)}),ae.map(L=>{const F=m0(L.icon),te=L.interval_type||"hours";if(oe?.id===L.id)return i.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:i.jsxs("div",{className:"space-y-3",children:[i.jsx("input",{type:"text",value:Me,onChange:_e=>q(_e.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:m("common.name"),autoFocus:!0}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("select",{value:E,onChange:_e=>U(_e.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[i.jsx("option",{value:"hours",children:m("maintenance.printHours")}),i.jsx("option",{value:"days",children:m("maintenance.calendarDays")})]}),i.jsx("input",{type:"number",value:Z,onChange:_e=>j(_e.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),i.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(Bv).map(_e=>{const Le=Bv[_e];return i.jsx("button",{type:"button",onClick:()=>$(_e),className:`p-1.5 rounded transition-colors ${K===_e?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:i.jsx(Le,{className:"w-3.5 h-3.5"})},_e)})}),i.jsx("input",{type:"url",value:ne,onChange:_e=>O(_e.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:m("maintenance.documentationLink")}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Ie,{size:"sm",onClick:ee,disabled:!Me.trim(),children:m("common.save")}),i.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>be(null),children:m("common.cancel")})]})]})},L.id);const he=Y(L.id),de=se(L.id),ke=ie===L.id;return i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:i.jsx(F,{className:"w-5 h-5 text-bambu-green"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-medium text-white truncate",children:L.name}),i.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:m("maintenance.custom")})]}),i.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[te==="days"?i.jsx(Yr,{className:"w-3 h-3"}):i.jsx(yd,{className:"w-3 h-3"}),VD(L.default_interval_hours,te,m)]})]}),i.jsxs("button",{onClick:()=>Q(ke?null:L.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${he.length>0?"border-bambu-green/50 bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20":"border-orange-400/50 bg-orange-400/10 text-orange-400 hover:bg-orange-400/20"}`,title:m("maintenance.printersAssignedClick",{count:he.length}),children:[i.jsx(_r,{className:"w-3 h-3"}),i.jsx("span",{className:"text-xs font-medium",children:he.length}),i.jsx(On,{className:`w-3 h-3 transition-transform ${ke?"rotate-180":""}`})]}),i.jsx("button",{onClick:()=>V(L),disabled:!d("maintenance:update"),title:d("maintenance:update")?void 0:m("maintenance.noPermissionEditTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors ${d("maintenance:update")?"":"opacity-50 cursor-not-allowed"}`,children:i.jsx(_f,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>{confirm(m("maintenance.deleteTypeConfirm",{name:L.name}))&&s(L.id)},disabled:!d("maintenance:delete"),title:d("maintenance:delete")?void 0:m("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${d("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:i.jsx(en,{className:"w-4 h-4"})})]}),ke&&i.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[i.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:m("maintenance.assignedToPrinters")}),he.length===0?i.jsx("p",{className:"text-xs text-orange-400",children:m("maintenance.noPrintersAssigned")}):i.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:he.map(_e=>i.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[_e.printerName,i.jsx("button",{onClick:()=>_e.itemId&&u(_e.itemId),disabled:!d("maintenance:delete"),title:d("maintenance:delete")?m("maintenance.removeFromPrinter"):m("maintenance.noPermissionRemovePrinter"),className:`ml-1 ${d("maintenance:delete")?"hover:text-red-400":"opacity-50 cursor-not-allowed"}`,children:"×"})]},_e.printerId))}),de.length>0&&i.jsxs("div",{className:"flex flex-wrap gap-1",children:[i.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:m("maintenance.addPrinterShort")}),de.map(_e=>i.jsxs("button",{onClick:()=>c(_e.id,L.id),disabled:!d("maintenance:create"),title:d("maintenance:create")?void 0:m("maintenance.noPermissionAssignPrinter"),className:`px-2 py-1 bg-bambu-dark rounded text-xs transition-colors ${d("maintenance:create")?"hover:bg-bambu-green/20 text-bambu-gray hover:text-bambu-green":"opacity-50 cursor-not-allowed text-bambu-gray"}`,children:["+ ",_e.name]},_e.id))]})]})]},L.id)})]})]}),ge.length>0&&i.jsxs("div",{children:[i.jsxs("div",{className:"mb-4",children:[i.jsx("h2",{className:"text-lg font-semibold text-white",children:m("maintenance.intervalOverrides")}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:m("maintenance.intervalOverridesDescription")})]}),i.jsx("div",{className:"space-y-4",children:ge.map(L=>i.jsx(Pt,{children:i.jsxs(Et,{className:"py-4",children:[i.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:L.printerName}),i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:L.items.map(F=>{const te=m0(F.maintenance_type_icon),ve=e.find(Le=>Le.id===F.maintenance_type_id),he=ve?.default_interval_hours||F.interval_hours,de=ve?.interval_type||"hours",ke=F.interval_type||"hours",_e=p===F.id;return i.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[i.jsx(te,{className:"w-4 h-4 text-bambu-gray shrink-0"}),i.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:F.maintenance_type_name}),_e?i.jsxs("div",{className:"flex items-center gap-1",children:[b==="days"?i.jsx(Yr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):i.jsx(yd,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),i.jsxs("select",{value:b,onChange:Le=>g(Le.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[i.jsx("option",{value:"hours",children:m("maintenance.printHours")}),i.jsx("option",{value:"days",children:m("maintenance.calendarDays")})]}),i.jsx("input",{type:"number",value:y,onChange:Le=>v(Le.target.value),onKeyDown:Le=>{Le.key==="Enter"&&G(F.id,he,de),Le.key==="Escape"&&f(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),i.jsx(Ie,{size:"sm",onClick:()=>G(F.id,he,de),children:"OK"})]}):i.jsxs("button",{onClick:()=>{d("maintenance:update")&&(f(F.id),v(F.interval_hours.toString()),g(ke))},disabled:!d("maintenance:update"),title:d("maintenance:update")?void 0:m("maintenance.noPermissionEditIntervals"),className:`px-2 py-1 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs font-medium text-white transition-colors flex items-center gap-1 ${d("maintenance:update")?"hover:bg-bambu-dark-secondary hover:border-bambu-green":"opacity-50 cursor-not-allowed"}`,children:[ke==="days"?i.jsx(Yr,{className:"w-3 h-3"}):i.jsx(yd,{className:"w-3 h-3"}),VD(F.interval_hours,ke,m),i.jsx(_f,{className:"w-3 h-3 text-bambu-gray"})]})]},F.id)})})]})},L.printerId))})]}),ge.length===0&&i.jsx(Pt,{children:i.jsxs(Et,{className:"text-center py-12",children:[i.jsx(Jn,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),i.jsx("p",{className:"text-bambu-gray",children:m("common.noPrinters")}),i.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:m("maintenance.intervalOverridesDescription")})]})}),ue&&i.jsx(_n,{title:m("maintenance.deleteSystemTypeTitle"),message:m("maintenance.deleteSystemTypeMessage",{name:ue.name}),confirmText:m("common.delete"),cancelText:m("common.cancel"),variant:"danger",cancelVariant:"primary",cardClassName:"bg-red-950/70 border border-red-800/70",onConfirm:()=>{s(ue.id),me(null)},onCancel:()=>me(null)})]})}function att(){const{t}=Rt(),e=sn(),{showToast:n}=fn(),{hasPermission:r}=Nr(),[a,s]=w.useState("status"),{data:o,isLoading:l}=tt({queryKey:["maintenanceOverview"],queryFn:fe.getMaintenanceOverview}),{data:c}=tt({queryKey:["maintenanceTypes"],queryFn:fe.getMaintenanceTypes}),u=ft({mutationFn:({id:P,notes:k})=>fe.performMaintenance(P,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.maintenanceComplete"))},onError:P=>{n(P.message,"error")}}),d=ft({mutationFn:({id:P,data:k})=>fe.updateMaintenanceItem(P,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:P=>{n(P.message,"error")}}),m=ft({mutationFn:({id:P,data:k})=>fe.updateMaintenanceType(P,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onError:P=>{n(P.message,"error")}}),p=ft({mutationFn:fe.deleteMaintenanceType,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeDeleted"))},onError:P=>{n(P.message,"error")}}),f=ft({mutationFn:fe.restoreDefaultMaintenanceTypes,onSuccess:P=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.defaultsRestored",{count:P.restored}))},onError:P=>{n(P.message,"error")}}),y=ft({mutationFn:({printerId:P,hours:k})=>fe.setPrinterHours(P,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.printHoursUpdated"))},onError:P=>{n(P.message,"error")}}),v=ft({mutationFn:({printerId:P,typeId:k})=>fe.assignMaintenanceType(P,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerAssigned"))},onError:P=>{n(P.message,"error")}}),b=ft({mutationFn:fe.removeMaintenanceItem,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerRemoved"))},onError:P=>{n(P.message,"error")}}),g=P=>{u.mutate({id:P})},_=(P,k)=>{d.mutate({id:P,data:{enabled:k}})},N=(P,k)=>{y.mutate({printerId:P,hours:k})};if(l)return i.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const T=o?.reduce((P,k)=>P+k.due_count,0)||0,C=o?.reduce((P,k)=>P+k.warning_count,0)||0;return i.jsxs("div",{className:"p-4 md:p-8",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx("h1",{className:"text-2xl font-bold text-white",children:t("maintenance.title")}),i.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:a==="status"?i.jsxs(i.Fragment,{children:[T>0&&i.jsx("span",{className:"text-red-400",children:t("maintenance.dueCount",{count:T})}),T>0&&C>0&&" · ",C>0&&i.jsx("span",{className:"text-amber-400",children:t("maintenance.warningCount",{count:C})}),T===0&&C===0&&i.jsx("span",{className:"text-bambu-green",children:t("maintenance.allOk")})]}):t("maintenance.configureSettings")})]}),i.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[i.jsx("button",{onClick:()=>s("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${a==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.statusTab")}),i.jsx("button",{onClick:()=>s("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${a==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.settingsTab")})]}),a==="status"?i.jsx("div",{className:"space-y-6",children:o&&o.length>0?[...o].sort((P,k)=>{const R=P.due_count*10+P.warning_count,A=k.due_count*10+k.warning_count;return R!==A?A-R:P.printer_name.localeCompare(k.printer_name)}).map(P=>i.jsx(rtt,{overview:P,onPerform:g,onToggle:_,onSetHours:N,hasPermission:r,t},P.printer_id)):i.jsx(Pt,{children:i.jsxs(Et,{className:"text-center py-16",children:[i.jsx(kf,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),i.jsx("p",{className:"text-lg font-medium text-white mb-2",children:t("common.noPrinters")}),i.jsx("p",{className:"text-bambu-gray",children:t("maintenance.configureSettings")})]})})}):i.jsx(itt,{overview:o,types:c||[],onUpdateInterval:(P,k)=>d.mutate({id:P,data:k}),onAddType:async(P,k)=>{const R=await fe.createMaintenanceType(P);for(const A of k)await fe.assignMaintenanceType(A,R.id);e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onUpdateType:(P,k)=>m.mutate({id:P,data:k}),onDeleteType:P=>p.mutate(P),onRestoreDefaults:()=>f.mutate(),isRestoringDefaults:f.isPending,onAssignType:(P,k)=>v.mutate({printerId:P,typeId:k}),onRemoveItem:P=>b.mutate(P),hasPermission:r,t})]})}const PY=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Hoe({project:t,onClose:e,onSave:n,isLoading:r,currencySymbol:a,t:s}){const[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.description||""),[d,m]=w.useState(t?.color||PY[0]),[p,f]=w.useState(t?.target_count?.toString()||""),[y,v]=w.useState(t?.target_parts_count?.toString()||""),[b,g]=w.useState(t?.status||"active"),[_,N]=w.useState(t?.tags||""),[T,C]=w.useState(t?.due_date?.split("T")[0]||""),[P,k]=w.useState(t?.priority||"normal"),[R,A]=w.useState(t?.budget?.toString()||""),D=B=>{B.preventDefault(),n({name:o.trim(),description:c.trim()||void 0,color:d,target_count:p?parseInt(p,10):void 0,target_parts_count:y?parseInt(y,10):void 0,tags:_.trim()||void 0,due_date:T||void 0,priority:P,budget:R.trim()?parseFloat(R):null,...t&&{status:b}})};return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[i.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:s(t?"projects.editProject":"projects.newProject")})}),i.jsxs("form",{onSubmit:D,className:"p-4 space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("common.name")}),i.jsx("input",{type:"text",value:o,onChange:B=>l(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:s("projects.namePlaceholder"),required:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("common.description")}),i.jsx("textarea",{value:c,onChange:B=>u(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green resize-none",placeholder:s("projects.descriptionPlaceholder"),rows:2})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("projects.color")}),i.jsx("div",{className:"flex gap-2 flex-wrap",children:PY.map(B=>i.jsx("button",{type:"button",onClick:()=>m(B),className:`w-8 h-8 rounded-full transition-transform ${d===B?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:B}},B))})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("projects.targetPlates")}),i.jsx("input",{type:"number",value:p,onChange:B=>f(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:s("projects.targetPlatesPlaceholder"),min:"1"}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:s("projects.targetPlatesHelp")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("projects.targetParts")}),i.jsx("input",{type:"number",value:y,onChange:B=>v(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:s("projects.targetPartsPlaceholder"),min:"1"}),i.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:s("projects.targetPartsHelp")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("projects.tagsLabel")}),i.jsx("input",{type:"text",value:_,onChange:B=>N(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:s("projects.tagsPlaceholder")})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("projects.dueDate")}),i.jsx("input",{type:"date",value:T,onChange:B=>C(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("projects.priority")}),i.jsxs("select",{value:P,onChange:B=>k(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[i.jsx("option",{value:"low",children:s("projects.priorityLow")}),i.jsx("option",{value:"normal",children:s("projects.priorityNormal")}),i.jsx("option",{value:"high",children:s("projects.priorityHigh")}),i.jsx("option",{value:"urgent",children:s("projects.priorityUrgent")})]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("projectDetail.cost.budget")}),i.jsxs("div",{className:"relative",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray pointer-events-none",children:a}),i.jsx("input",{type:"number",step:"0.01",min:"0",value:R,onChange:B=>A(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded pl-8 pr-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"0.00"})]})]}),t&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("common.status")}),i.jsxs("select",{value:b,onChange:B=>g(B.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[i.jsx("option",{value:"active",children:s("projects.statusActive")}),i.jsx("option",{value:"completed",children:s("projects.statusCompleted")}),i.jsx("option",{value:"archived",children:s("projects.statusArchived")})]})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:e,children:s("common.cancel")}),i.jsx(Ie,{type:"submit",disabled:!o.trim()||r,children:r?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):s(t?"common.save":"projects.create")})]})]})]})})}function stt({project:t,onClick:e,onEdit:n,onDelete:r,hasPermission:a,t:s}){const o=t.target_count?Math.round(t.archive_count/t.target_count*100):0,l=t.target_parts_count?Math.round(t.completed_count/t.target_parts_count*100):0,c=t.status==="completed",u=t.status==="archived",[d,m]=w.useState(!1),f=c?{icon:su,color:"text-bambu-green",bg:"bg-bambu-green/10"}:u?{icon:$s,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:Jn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:Ss,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return i.jsxs("div",{className:"group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden",onClick:e,children:[i.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full",style:{backgroundColor:t.color||"#6b7280",boxShadow:`0 0 12px ${t.color||"#6b7280"}40`}}),i.jsxs("div",{className:"p-5 pl-6",children:[i.jsxs("div",{className:"flex items-start justify-between mb-4",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[i.jsx("div",{className:`p-2 rounded-lg ${f.bg} flex-shrink-0`,children:i.jsx(f.icon,{className:`w-5 h-5 ${f.color}`})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_parts_count?i.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${l>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," ",s("projects.parts")]}):t.target_count?i.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${o>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.archive_count,"/",t.target_count," ",s("projects.plates")]}):t.completed_count>0?i.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium bg-bambu-dark text-bambu-gray",children:[t.completed_count," ",s("projects.parts")]}):null,c&&i.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.done")}),u&&i.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.statusArchived")})]}),t.description&&i.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const y=t.archives.map(_=>_.filament_type).filter(Boolean).flatMap(_=>_.split(",").map(N=>N.trim())).filter(Boolean),v=[...new Set(y)],b=t.archives.map(_=>_.filament_color).filter(Boolean).flatMap(_=>_.split(",").map(N=>N.trim())).filter(_=>_.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(_)),g=[...new Set(b)];return v.length===0&&g.length===0?null:i.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[v.slice(0,3).map(_=>i.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:_},_)),g.length>0&&i.jsxs("div",{className:"flex items-center gap-0.5",children:[g.slice(0,5).map(_=>i.jsx("div",{className:"w-3 h-3 rounded-full border border-black/20",style:{backgroundColor:_.startsWith("#")?_:`#${_}`},title:_},_)),g.length>5&&i.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",g.length-5]})]})]})})()]})]}),i.jsxs("div",{className:"relative",onClick:y=>y.stopPropagation(),children:[i.jsx("button",{className:"p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100",onClick:()=>m(!d),children:i.jsx(yh,{className:"w-4 h-4"})}),d&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>m(!1)}),i.jsxs("div",{className:"absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[i.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${a("projects:update")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{a("projects:update")&&(n(),m(!1))},disabled:!a("projects:update"),title:a("projects:update")?void 0:s("projects.noEditPermission"),children:[i.jsx(_f,{className:"w-4 h-4"}),s("common.edit")]}),i.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${a("projects:delete")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{a("projects:delete")&&(r(),m(!1))},disabled:!a("projects:delete"),title:a("projects:delete")?void 0:s("projects.noDeletePermission"),children:[i.jsx(en,{className:"w-4 h-4"}),s("common.delete")]})]})]})]})]}),i.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?i.jsxs("div",{className:"space-y-3",children:[t.target_count&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[i.jsx("span",{className:"text-bambu-gray",children:s("projects.plates")}),i.jsxs("span",{className:o>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),i.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:i.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(o,100)}%`,background:o>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${o>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.target_parts_count&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[i.jsx("span",{className:"text-bambu-gray",children:s("projects.parts")}),i.jsxs("span",{className:l>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),i.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:i.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(l,100)}%`,background:l>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${l>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&i.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," ",s("projects.failed")]})]}):t.completed_count>0||t.failed_count>0?i.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&i.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[i.jsx($s,{className:"w-3.5 h-3.5"}),i.jsxs("span",{children:[t.completed_count," ",s("projects.completed")]})]}),t.failed_count>0&&i.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[i.jsx(Mn,{className:"w-3.5 h-3.5"}),i.jsxs("span",{children:[t.failed_count," ",s("projects.failed")]})]}),t.queue_count>0&&i.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[i.jsx(Jn,{className:"w-3.5 h-3.5"}),i.jsxs("span",{children:[t.queue_count," ",s("projects.inQueue")]})]})]}):i.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:s("projects.noPrintsYet")})}),t.archives&&t.archives.length>0&&i.jsxs("div",{className:"mb-4",children:[i.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(y=>i.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:y.print_name||"Unknown",children:[y.thumbnail_path?i.jsx("img",{src:fe.getArchiveThumbnail(y.id),alt:y.print_name||"",className:"w-full h-full object-cover"}):i.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:i.jsx(Gi,{className:"w-6 h-6"})}),y.status==="failed"&&i.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:i.jsx(Mn,{className:"w-4 h-4 text-white"})})]},y.id))}),t.archive_count>4&&i.jsx("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:s("common.more",{count:t.archive_count-4})})]}),i.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[i.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.printJobs"),children:[i.jsx(Vi,{className:"w-3.5 h-3.5 text-blue-400"}),i.jsxs("span",{children:[t.archive_count," ",s("projects.plates")]})]}),i.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.partsPrinted"),children:[i.jsx(Gi,{className:"w-3.5 h-3.5 text-bambu-green"}),i.jsxs("span",{children:[t.completed_count," ",s("projects.parts")]})]}),t.failed_count>0&&i.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:s("projects.failedParts"),children:[i.jsx(Mn,{className:"w-3.5 h-3.5"}),i.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&i.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:s("projects.inQueue"),children:[i.jsx(y3,{className:"w-3.5 h-3.5"}),i.jsx("span",{children:t.queue_count})]})]}),i.jsx(fa,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function ott(){const{t}=Rt(),e=al(),n=sn(),{showToast:r}=fn(),{hasPermission:a}=Nr(),[s,o]=w.useState(!1),[l,c]=w.useState(),[u,d]=w.useState("active"),[m,p]=w.useState(null),{data:f}=tt({queryKey:["settings"],queryFn:fe.getSettings}),y=Go(f?.currency||"USD"),{data:v,isLoading:b}=tt({queryKey:["projects",u==="all"?void 0:u],queryFn:()=>fe.getProjects(u==="all"?void 0:u)}),g=ft({mutationFn:J=>fe.createProject(J),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),r(t("projects.toast.created"),"success")},onError:J=>{r(J.message,"error")}}),_=ft({mutationFn:({id:J,data:ie})=>fe.updateProject(J,ie),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),c(void 0),r(t("projects.toast.updated"),"success")},onError:J=>{r(J.message,"error")}}),N=ft({mutationFn:J=>fe.deleteProject(J),onSuccess:()=>{p(null),r(t("projects.toast.deleted"),"success"),setTimeout(()=>window.location.reload(),100)},onError:J=>{p(null),r(J.message,"error")}}),T=ft({mutationFn:J=>fe.importProject(J),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success")},onError:J=>{r(J.message,"error")}}),C=w.useRef(null),P=async()=>{try{const J=await fe.getProjects(),ie=await Promise.all(J.map(async pe=>await fe.exportProjectJson(pe.id))),Q=new Blob([JSON.stringify(ie,null,2)],{type:"application/json"}),ue=URL.createObjectURL(Q),me=document.createElement("a");me.href=ue,me.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,me.click(),URL.revokeObjectURL(ue),r(t("projects.toast.exported"),"success")}catch(J){r(J.message,"error")}},k=()=>{C.current?.click()},R=async J=>{const ie=J.target.files?.[0];if(ie){try{if(ie.name.toLowerCase().endsWith(".zip"))await fe.importProjectFile(ie),n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success");else{const ue=await ie.text(),me=JSON.parse(ue),pe=Array.isArray(me)?me:[me];for(const Y of pe)await T.mutateAsync(Y);pe.length>1&&r(t("projects.toast.multipleImported",{count:pe.length}),"success")}}catch(Q){r(`${t("projects.toast.importFailed")}: ${Q.message}`,"error")}J.target.value=""}},A=J=>{l?_.mutate({id:l.id,data:J}):g.mutate(J)},D=J=>{c(J),o(!0)},B=J=>{e(`/projects/${J.id}`)},z=J=>{p(J)},W=()=>{m!==null&&N.mutate(m)},I=v?.reduce((J,ie)=>(J[ie.status]=(J[ie.status]||0)+1,J.all=(J.all||0)+1,J),{})||{};return i.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[i.jsx("input",{ref:C,type:"file",accept:".json,.zip",onChange:R,className:"hidden"}),i.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[i.jsxs("div",{children:[i.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[i.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:i.jsx(Ss,{className:"w-6 h-6 text-bambu-green"})}),t("projects.title")]}),i.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("projects.subtitle")})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs(Ie,{variant:"secondary",onClick:k,disabled:!a("projects:create"),title:a("projects:create")?t("projects.importProject"):t("projects.noImportPermission"),children:[i.jsx(vi,{className:"w-4 h-4 mr-2"}),t("projects.import")]}),i.jsxs(Ie,{variant:"secondary",onClick:P,disabled:!a("projects:read"),title:a("projects:read")?t("projects.exportAll"):t("projects.noExportPermission"),children:[i.jsx(bi,{className:"w-4 h-4 mr-2"}),t("projects.export")]}),i.jsxs(Ie,{onClick:()=>o(!0),className:"sm:w-auto w-full",disabled:!a("projects:create"),title:a("projects:create")?void 0:t("projects.noCreatePermission"),children:[i.jsx(ar,{className:"w-4 h-4 mr-2"}),t("projects.newProject")]})]})]}),i.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:t("projects.statusActive"),icon:Jn},{key:"completed",label:t("projects.statusCompleted"),icon:su},{key:"archived",label:t("projects.statusArchived"),icon:$s},{key:"all",label:t("common.all"),icon:Ss}].map(({key:J,label:ie,icon:Q})=>i.jsxs("button",{onClick:()=>d(J),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${u===J?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[i.jsx(Q,{className:"w-4 h-4"}),i.jsx("span",{children:ie}),I[J]>0&&i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${u===J?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:I[J]})]},J))}),b?i.jsx("div",{className:"flex items-center justify-center py-20",children:i.jsxs("div",{className:"flex flex-col items-center gap-3",children:[i.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("projects.loading")})]})}):v?.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[i.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:i.jsx(Ss,{className:"w-12 h-12 text-bambu-gray/50"})}),i.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:u==="all"?t("projects.noProjects"):t("projects.noProjectsFiltered",{status:u})}),i.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:u==="all"?t("projects.createFirst"):t("projects.noProjectsFilteredHelp",{status:u})}),u==="all"&&i.jsxs(Ie,{onClick:()=>o(!0),disabled:!a("projects:create"),title:a("projects:create")?void 0:t("projects.noCreatePermission"),children:[i.jsx(ar,{className:"w-4 h-4 mr-2"}),t("projects.createFirstButton")]})]}):i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:v?.map(J=>i.jsx(stt,{project:J,onClick:()=>B(J),onEdit:()=>D(J),onDelete:()=>z(J.id),hasPermission:a,t},J.id))}),m!==null&&i.jsx(_n,{title:t("projects.deleteProject"),message:t("projects.deleteConfirm"),confirmText:t("projects.deleteProject"),variant:"danger",onConfirm:W,onCancel:()=>p(null)}),s&&i.jsx(Hoe,{project:l,onClose:()=>{o(!1),c(void 0)},onSave:A,isLoading:g.isPending||_.isPending,currencySymbol:y,t})]})}function ltt(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function ctt({status:t,t:e}){const n={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},r=n[t]||n.active,a={active:e("projectDetail.status.active"),completed:e("projectDetail.status.completed"),archived:e("projectDetail.status.archived")};return i.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${r}`,children:a[t]||t.charAt(0).toUpperCase()+t.slice(1)})}function MY({icon:t,label:e,value:n,subValue:r,hint:a,color:s="text-bambu-gray"}){return i.jsx(Pt,{children:i.jsx(Et,{className:"p-4",children:i.jsxs("div",{className:"flex items-center gap-3",title:a,children:[i.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${s}`,children:i.jsx(t,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:e}),i.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&i.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function utt({archives:t,t:e}){return t.length===0?i.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[i.jsx(Gi,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),i.jsx("p",{children:e("projectDetail.noPrints")})]}):i.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:t.map(n=>i.jsxs(co,{to:`/archives?search=${encodeURIComponent(n.print_name||"")}`,className:"group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors",children:[n.thumbnail_path?i.jsx("img",{src:fe.getArchiveThumbnail(n.id),alt:n.print_name||"Print",className:"w-full h-full object-cover"}):i.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:i.jsx(Gi,{className:"w-8 h-8"})}),n.status==="failed"&&i.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:i.jsx(qi,{className:"w-8 h-8 text-white"})}),n.status==="completed"&&i.jsx("div",{className:"absolute top-1 right-1",children:i.jsx(fr,{className:"w-4 h-4 text-bambu-green"})}),i.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity",children:i.jsx("p",{className:"text-xs text-white truncate",children:n.print_name||"Unknown"})})]},n.id))})}function dtt({priority:t,t:e}){const n={low:{color:"bg-gray-500/20 text-gray-400",label:e("projectDetail.priority.low")},normal:{color:"bg-blue-500/20 text-blue-400",label:e("projectDetail.priority.normal")},high:{color:"bg-orange-500/20 text-orange-400",label:e("projectDetail.priority.high")},urgent:{color:"bg-red-500/20 text-red-400",label:e("projectDetail.priority.urgent")}},{color:r,label:a}=n[t]||n.normal;return i.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${r}`,children:[t==="urgent"&&i.jsx(Mn,{className:"w-3 h-3"}),a]})}function GD(t,e){if(!t)return null;const n=Zn(t);if(!n)return null;const r=new Date,a=Math.ceil((n.getTime()-r.getTime())/(1e3*60*60*24));return a<0?{color:"text-red-400",label:e("projectDetail.dueDate.overdue")}:a===0?{color:"text-orange-400",label:e("projectDetail.dueDate.today")}:a<=3?{color:"text-yellow-400",label:e("projectDetail.dueDate.daysLeft",{count:a})}:{color:"text-bambu-gray",label:e("projectDetail.dueDate.daysLeft",{count:a})}}function mtt(){const{id:t}=hw(),e=al(),{t:n}=Rt(),r=sn(),{showToast:a}=fn(),{hasPermission:s}=Nr(),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,m]=w.useState(""),p=parseInt(t||"0",10),{data:f,isLoading:y,error:v}=tt({queryKey:["project",p],queryFn:()=>fe.getProject(p),enabled:p>0}),{data:b,isLoading:g}=tt({queryKey:["project-archives",p],queryFn:()=>fe.getProjectArchives(p),enabled:p>0}),{data:_,isLoading:N}=tt({queryKey:["project-bom",p],queryFn:()=>fe.getProjectBOM(p),enabled:p>0}),{data:T,isLoading:C}=tt({queryKey:["project-timeline",p],queryFn:()=>fe.getProjectTimeline(p,20),enabled:p>0}),{data:P}=tt({queryKey:["settings"],queryFn:fe.getSettings}),{data:k}=tt({queryKey:["project-folders",p],queryFn:()=>fe.getLibraryFoldersByProject(p),enabled:p>0}),R=Go(P?.currency||"USD"),A=P?.time_format||"system",D=ft({mutationFn:je=>fe.updateProject(p,je),onSuccess:()=>{r.invalidateQueries({queryKey:["project",p]}),r.invalidateQueries({queryKey:["projects"]}),l(!1),u(!1),a(n("projectDetail.toast.projectUpdated"),"success")},onError:je=>{a(je.message,"error")}}),B=()=>{m(f?.notes||""),u(!0)},z=()=>{D.mutate({notes:d})},W=()=>{u(!1),m("")},[I,J]=w.useState(""),[ie,Q]=w.useState(1),[ue,me]=w.useState(""),[pe,Y]=w.useState(""),[se,oe]=w.useState(""),[be,Me]=w.useState(!1),[q,Z]=w.useState(!1),[j,E]=w.useState(null),[U,K]=w.useState(""),[$,ne]=w.useState(1),[O,V]=w.useState(""),[ee,G]=w.useState(""),[re,ce]=w.useState(""),[ge,xe]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),ae=ft({mutationFn:je=>fe.createBOMItem(p,je),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),J(""),Q(1),me(""),Y(""),oe(""),Me(!1),a(n("projectDetail.toast.partAdded"),"success")},onError:je=>a(je.message,"error")}),L=ft({mutationFn:({itemId:je,data:Xe})=>fe.updateBOMItem(p,je,Xe),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),E(null)},onError:je=>a(je.message,"error")}),F=ft({mutationFn:je=>fe.deleteBOMItem(p,je),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),a(n("projectDetail.toast.partRemoved"),"success")},onError:je=>a(je.message,"error")}),te=je=>{je.preventDefault(),I.trim()&&ae.mutate({name:I.trim(),quantity_needed:ie,unit_price:ue?parseFloat(ue):void 0,sourcing_url:pe.trim()||void 0,remarks:se.trim()||void 0})},ve=je=>{const Xe=je.is_complete?0:je.quantity_needed;L.mutate({itemId:je.id,data:{quantity_acquired:Xe}})},he=(je,Xe)=>{xe({isOpen:!0,title:n("projectDetail.bom.deletePart"),message:n("projectDetail.bom.deleteConfirm",{name:Xe}),onConfirm:()=>{xe(ye=>({...ye,isOpen:!1})),F.mutate(je)}})},de=je=>{E(je),K(je.name),ne(je.quantity_needed),V(je.unit_price?.toString()||""),G(je.sourcing_url||""),ce(je.remarks||"")},ke=je=>{je.preventDefault(),!(!j||!U.trim())&&L.mutate({itemId:j.id,data:{name:U.trim(),quantity_needed:$,unit_price:O?parseFloat(O):void 0,sourcing_url:ee.trim()||void 0,remarks:re.trim()||void 0}})},_e=()=>{E(null)},Le=async()=>{try{const{blob:je,filename:Xe}=await fe.exportProjectZip(Number(p)),ye=URL.createObjectURL(je),Ge=document.createElement("a");Ge.href=ye,Ge.download=Xe||`${f?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,Ge.click(),URL.revokeObjectURL(ye),a(n("projectDetail.toast.projectExported"),"success")}catch(je){a(je.message,"error")}},$e=ft({mutationFn:()=>fe.createTemplateFromProject(p),onSuccess:()=>{r.invalidateQueries({queryKey:["projects"]}),a(n("projectDetail.toast.templateCreated"),"success")},onError:je=>a(je.message,"error")}),Re=je=>Tf(je,A,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(y)return i.jsx("div",{className:"flex items-center justify-center py-24",children:i.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(v||!f)return i.jsxs("div",{className:"text-center py-24",children:[i.jsx("p",{className:"text-bambu-gray",children:v?`${n("common.error")}: ${v.message}`:n("projectDetail.notFound")}),i.jsx(Ie,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:n("projectDetail.backToProjects")})]});const Ae=f.stats,Pe=Ae?.progress_percent??0,Ue=Ae?.parts_progress_percent??0;return i.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[i.jsx(co,{to:"/projects",className:"hover:text-white transition-colors",children:n("navigation.projects")}),i.jsx(fa,{className:"w-4 h-4"}),i.jsx("span",{className:"text-white",children:f.name})]}),i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:i.jsx(IX,{className:"w-5 h-5 text-bambu-gray"})}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:f.color||"#6b7280"}}),i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold text-white",children:f.name}),f.description&&i.jsx("p",{className:"text-bambu-gray mt-1",children:f.description})]})]}),i.jsx(ctt,{status:f.status,t:n})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs(Ie,{variant:"secondary",onClick:Le,disabled:!s("projects:read"),title:s("projects:read")?n("projectDetail.exportProject"):n("projectDetail.noExportPermission"),children:[i.jsx(bi,{className:"w-4 h-4 mr-2"}),n("projectDetail.export")]}),i.jsxs(Ie,{onClick:()=>l(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.noEditPermission"),children:[i.jsx(_f,{className:"w-4 h-4 mr-2"}),n("common.edit")]})]})]}),(f.target_count||f.target_parts_count)&&i.jsx(Pt,{children:i.jsxs(Et,{className:"p-4 space-y-4",children:[f.target_count&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.platesProgress")}),i.jsxs("span",{className:"text-sm font-medium text-white",children:[Ae?.total_archives||0," / ",f.target_count," ",n("projectDetail.progress.printJobs")]})]}),i.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Pe,100)}%`,backgroundColor:Pe>=100?"#22c55e":f.color||"#6b7280"}})}),i.jsxs("div",{className:"flex justify-between mt-1",children:[i.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:Pe.toFixed(0)})}),Ae?.remaining_prints!=null&&Ae.remaining_prints>0&&i.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:Ae.remaining_prints})})]})]}),f.target_parts_count&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.partsProgress")}),i.jsxs("span",{className:"text-sm font-medium text-white",children:[Ae?.completed_prints||0," / ",f.target_parts_count," ",n("projectDetail.progress.parts")]})]}),i.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Ue,100)}%`,backgroundColor:Ue>=100?"#22c55e":f.color||"#6b7280"}})}),i.jsxs("div",{className:"flex justify-between mt-1",children:[i.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:Ue.toFixed(0)})}),Ae?.remaining_parts!=null&&Ae.remaining_parts>0&&i.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:Ae.remaining_parts})})]})]})]})}),Ae&&i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[i.jsx(Pt,{children:i.jsx(Et,{className:"p-4",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:i.jsx(Gi,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.printJobs")}),i.jsxs("p",{className:"text-xl font-semibold text-white",children:[Ae.total_archives," ",i.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:n("projectDetail.stats.total")})]}),Ae.failed_prints>0&&i.jsx("p",{className:"text-sm text-status-error",children:n("projectDetail.stats.failed",{count:Ae.failed_prints})}),i.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.partsPrinted",{count:Ae.completed_prints})})]})]})})}),i.jsx(MY,{icon:Jn,label:n("projectDetail.stats.printTime"),value:rxe(Ae.total_print_time_hours),color:"text-yellow-400"}),i.jsx(MY,{icon:_r,label:n("projectDetail.stats.filamentUsed"),value:ltt(Ae.total_filament_grams),color:"text-purple-400"})]}),Ae&&(()=>{const je=Ae.estimated_cost+Ae.total_energy_cost+Ae.bom_cost;return Ae.estimated_cost>0||je>0||f.budget!==null})()&&i.jsx(Pt,{children:i.jsxs(Et,{className:"p-4",children:[i.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:n("projectDetail.cost.title")}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.filamentCost")}),i.jsxs("p",{className:"text-lg font-semibold text-white",children:[R,Ae.estimated_cost.toFixed(2)]})]}),Ae.total_energy_kwh>0&&i.jsxs("div",{children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.energy")}),i.jsxs("p",{className:"text-lg font-semibold text-white",children:[Ae.total_energy_kwh.toFixed(3)," kWh",Ae.total_energy_cost>0&&i.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",R,Ae.total_energy_cost.toFixed(2),")"]})]})]}),(()=>{const je=Ae.estimated_cost+Ae.total_energy_cost+Ae.bom_cost;return je<=0?null:i.jsxs("div",{children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.totalCost")}),i.jsxs("p",{className:"text-lg font-semibold text-bambu-green",children:[R,je.toFixed(2)]}),Ae.bom_cost>0&&i.jsx("p",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.cost.includesBom")})]})})(),f.budget!==null&&(()=>{const je=Ae.estimated_cost+Ae.total_energy_cost+Ae.bom_cost,Xe=f.budget-je;return i.jsxs("div",{children:[i.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.budget")}),i.jsxs("p",{className:"text-sm text-bambu-gray",children:[n("projectDetail.cost.total"),": ",i.jsxs("span",{className:"text-white font-semibold",children:[R,f.budget.toFixed(2)]})]}),i.jsxs("p",{className:`text-sm ${Xe>=0?"text-bambu-green":"text-red-400"}`,children:[n("projectDetail.cost.remaining"),": ",i.jsxs("span",{className:"font-semibold",children:[R,Xe.toFixed(2)]})]})]})})()]})]})}),f.children&&f.children.length>0&&i.jsx(Pt,{children:i.jsxs(Et,{className:"p-4",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[i.jsx(Zpe,{className:"w-5 h-5"}),n("projectDetail.subProjects.title",{count:f.children.length})]}),i.jsx("div",{className:"space-y-2",children:f.children.map(je=>i.jsxs(co,{to:`/projects/${je.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:je.color||"#6b7280"}}),i.jsx("span",{className:"text-white",children:je.name}),i.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${je.status==="completed"?"bg-status-ok/20 text-status-ok":je.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:je.status})]}),je.progress_percent!==null&&i.jsxs("span",{className:"text-sm text-bambu-gray",children:[je.progress_percent.toFixed(0),"%"]})]},je.id))})]})}),f.parent_id&&f.parent_name&&i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx(Vi,{className:"w-4 h-4 text-bambu-gray"}),i.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.partOf")}),i.jsx(co,{to:`/projects/${f.parent_id}`,className:"text-bambu-green hover:underline",children:f.parent_name})]}),(f.tags||f.due_date||f.priority!=="normal")&&i.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[f.priority&&f.priority!=="normal"&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.priorityLabel")}),i.jsx(dtt,{priority:f.priority,t:n})]}),f.due_date&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Yr,{className:"w-4 h-4 text-bambu-gray"}),i.jsx("span",{className:"text-sm text-white",children:Cf(f.due_date,{year:"numeric",month:"short",day:"numeric"})}),GD(f.due_date,n)&&i.jsxs("span",{className:`text-xs ${GD(f.due_date,n).color}`,children:["(",GD(f.due_date,n).label,")"]})]}),f.tags&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Id,{className:"w-4 h-4 text-bambu-gray"}),i.jsx("div",{className:"flex flex-wrap gap-1",children:f.tags.split(",").map((je,Xe)=>i.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:je.trim()},Xe))})]})]}),i.jsx(Pt,{children:i.jsxs(Et,{className:"p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(zs,{className:"w-5 h-5"}),n("projectDetail.notes.title")]}),c?i.jsxs("div",{className:"flex gap-2",children:[i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:W,disabled:D.isPending,children:[i.jsx(Ht,{className:"w-4 h-4 mr-1"}),n("common.cancel")]}),i.jsxs(Ie,{size:"sm",onClick:z,disabled:D.isPending,children:[D.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin mr-1"}):i.jsx(ss,{className:"w-4 h-4 mr-1"}),n("common.save")]})]}):i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:B,disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.notes.noEditPermission"),children:[i.jsx(_f,{className:"w-4 h-4 mr-1"}),n("common.edit")]})]}),c?i.jsx(hL,{content:d,onChange:m,placeholder:n("projectDetail.notes.placeholder")}):f.notes?i.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:pie.sanitize(f.notes)}}):i.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.notes.empty")})]})}),i.jsx(Pt,{children:i.jsxs(Et,{className:"p-4",children:[i.jsx("div",{className:"flex items-center justify-between mb-3",children:i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(Pc,{className:"w-5 h-5"}),n("projectDetail.files.title")]})}),i.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[i.jsx(co,{to:"/files",className:"text-bambu-green hover:underline",children:n("projectDetail.files.linkFolders")})," ",n("projectDetail.files.forQuickAccess")]}),k&&k.length>0?i.jsx("div",{className:"space-y-2",children:k.map(je=>i.jsxs(co,{to:`/files?folder=${je.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[i.jsx(Pc,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm text-white truncate",children:je.name}),i.jsx("p",{className:"text-xs text-bambu-gray",children:n("projectDetail.files.fileCount",{count:je.file_count})})]})]}),i.jsx(fa,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},je.id))}):i.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.files.empty")})]})}),i.jsx(Pt,{children:i.jsxs(Et,{className:"p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(XX,{className:"w-5 h-5"}),n("projectDetail.bom.title"),Ae&&Ae.bom_total_items>0&&i.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",n("projectDetail.bom.acquired",{completed:Ae.bom_completed_items,total:Ae.bom_total_items}),")"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[_&&_.some(je=>je.is_complete)&&i.jsx("button",{onClick:()=>Z(!q),className:`text-xs px-2 py-1 rounded transition-colors ${q?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:n(q?"projectDetail.bom.showAll":"projectDetail.bom.hideDone")}),!be&&i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>Me(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noAddPermission"),children:[i.jsx(ar,{className:"w-4 h-4 mr-1"}),n("projectDetail.bom.addPart")]})]})]}),be&&i.jsxs("form",{onSubmit:te,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[i.jsx("input",{type:"text",value:I,onChange:je=>J(je.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.partNamePlaceholder"),autoFocus:!0}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"number",value:ie,onChange:je=>Q(parseInt(je.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:n("projectDetail.bom.qty")}),i.jsx("input",{type:"number",step:"0.01",value:ue,onChange:je=>me(je.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.price",{currency:R})})]})]}),i.jsx("input",{type:"url",value:pe,onChange:je=>Y(je.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.sourcingUrlPlaceholder")}),i.jsx("input",{type:"text",value:se,onChange:je=>oe(je.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.remarksPlaceholder")}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",size:"sm",onClick:()=>Me(!1),children:n("common.cancel")}),i.jsx(Ie,{type:"submit",size:"sm",disabled:!I.trim()||ae.isPending,children:ae.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):n("projectDetail.bom.addPart")})]})]}),N?i.jsx("div",{className:"flex items-center justify-center py-4",children:i.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):_&&_.length>0?i.jsxs("div",{className:"space-y-2",children:[_.filter(je=>!q||!je.is_complete).map(je=>i.jsx("div",{className:`p-3 rounded-lg transition-colors ${je.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:j?.id===je.id?i.jsxs("form",{onSubmit:ke,className:"space-y-3",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[i.jsx("input",{type:"text",value:U,onChange:Xe=>K(Xe.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.partName"),autoFocus:!0}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"number",value:$,onChange:Xe=>ne(parseInt(Xe.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:n("projectDetail.bom.qty")}),i.jsx("input",{type:"number",step:"0.01",value:O,onChange:Xe=>V(Xe.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.price",{currency:R})})]})]}),i.jsx("input",{type:"url",value:ee,onChange:Xe=>G(Xe.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.sourcingUrlPlaceholder")}),i.jsx("input",{type:"text",value:re,onChange:Xe=>ce(Xe.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.remarksPlaceholder")}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",size:"sm",onClick:_e,children:n("common.cancel")}),i.jsx(Ie,{type:"submit",size:"sm",disabled:!U.trim()||L.isPending,children:L.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):n("common.save")})]})]}):i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("button",{onClick:()=>s("projects:update")&&ve(je),disabled:L.isPending||!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noUpdatePermission"),className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${je.is_complete?"bg-status-ok border-status-ok text-white":s("projects:update")?"border-bambu-gray hover:border-bambu-green":"border-bambu-gray/50 cursor-not-allowed"}`,children:je.is_complete&&i.jsx(fr,{className:"w-3 h-3"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i.jsxs("p",{className:`text-sm font-medium ${je.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[je.name,i.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",je.quantity_needed]})]}),je.unit_price!==null&&i.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[R,(je.unit_price*je.quantity_needed).toFixed(2)]})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{onClick:()=>s("projects:update")&&de(je),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.edit"):n("projectDetail.bom.noEditPermission"),children:i.jsx(Ki,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>s("projects:update")&&he(je.id,je.name),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.delete"):n("projectDetail.bom.noDeletePermission"),children:i.jsx(en,{className:"w-4 h-4"})})]})]}),je.sourcing_url&&i.jsxs("a",{href:je.sourcing_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-1 text-xs text-blue-400 hover:text-blue-300 transition-colors",onClick:Xe=>Xe.stopPropagation(),children:[i.jsx(ti,{className:"w-3 h-3 flex-shrink-0"}),i.jsx("span",{className:"truncate",children:(()=>{try{return new URL(je.sourcing_url).hostname.replace("www.","")}catch{return je.sourcing_url}})()})]}),je.remarks&&i.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:je.remarks})]})]})},je.id)),Ae&&Ae.bom_cost>0&&i.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[i.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.bom.totalCost")}),i.jsxs("span",{className:"text-white font-medium",children:[R,Ae.bom_cost.toFixed(2)]})]})]}):i.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.bom.empty")})]})}),i.jsx(Pt,{children:i.jsxs(Et,{className:"p-4",children:[i.jsx("div",{className:"flex items-center justify-between mb-3",children:i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(x0,{className:"w-5 h-5"}),n("projectDetail.timeline.title")]})}),C?i.jsx("div",{className:"flex items-center justify-center py-4",children:i.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):T&&T.length>0?i.jsx("div",{className:"space-y-3",children:T.slice(0,10).map((je,Xe)=>i.jsxs("div",{className:"flex gap-3",children:[i.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${je.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":je.event_type==="print_failed"?"bg-status-error/20 text-status-error":je.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[je.event_type==="print_completed"&&i.jsx(fr,{className:"w-4 h-4"}),je.event_type==="print_failed"&&i.jsx(qi,{className:"w-4 h-4"}),je.event_type==="print_started"&&i.jsx(_r,{className:"w-4 h-4"}),je.event_type==="queued"&&i.jsx(y3,{className:"w-4 h-4"}),je.event_type==="project_created"&&i.jsx(ar,{className:"w-4 h-4"})]}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-sm text-white",children:je.title}),je.description&&i.jsx("p",{className:"text-xs text-bambu-gray truncate",children:je.description}),i.jsx("p",{className:"text-xs text-bambu-gray/70",children:Re(je.timestamp)})]})]},Xe))}):i.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.timeline.empty")})]})}),!f.is_template&&i.jsx("div",{className:"flex justify-end",children:i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>$e.mutate(),disabled:$e.isPending||!s("projects:create"),title:s("projects:create")?void 0:n("projectDetail.template.noCreatePermission"),children:[$e.isPending?i.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}):i.jsx(vo,{className:"w-4 h-4 mr-2"}),n("projectDetail.template.saveAsTemplate")]})}),Ae&&(Ae.queued_prints>0||Ae.in_progress_prints>0)&&i.jsx(Pt,{children:i.jsxs(Et,{className:"p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(y3,{className:"w-5 h-5"}),n("projectDetail.queue.title")]}),i.jsx(co,{to:`/queue?project=${p}`,className:"text-sm text-bambu-green hover:underline",children:n("projectDetail.queue.viewAll")})]}),i.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[Ae.in_progress_prints>0&&i.jsx("span",{className:"text-yellow-400",children:n("projectDetail.queue.printing",{count:Ae.in_progress_prints})}),Ae.queued_prints>0&&i.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.queue.queued",{count:Ae.queued_prints})})]})]})}),i.jsxs("div",{children:[i.jsx("div",{className:"flex items-center justify-between mb-4",children:i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(Gi,{className:"w-5 h-5"}),n("projectDetail.prints.title",{count:b?.length||0})]})}),g?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):i.jsx(utt,{archives:b||[],t:n})]}),o&&i.jsx(Hoe,{t:n,currencySymbol:R,project:{...f,archive_count:Ae?.total_archives||0,total_items:Ae?.total_items||0,completed_count:Ae?.completed_prints||0,failed_count:Ae?.failed_prints||0,queue_count:Ae?.queued_prints||0,progress_percent:Ae?.progress_percent||null,archives:[]},onClose:()=>l(!1),onSave:je=>D.mutate(je),isLoading:D.isPending}),ge.isOpen&&i.jsx(_n,{title:ge.title,message:ge.message,confirmText:n("common.delete"),variant:"danger",onConfirm:ge.onConfirm,onCancel:()=>xe(je=>({...je,isOpen:!1}))})]})}function htt({parentId:t,onClose:e,onSave:n,isLoading:r,t:a}){const[s,o]=w.useState(""),l=c=>{c.preventDefault(),n({name:s.trim(),parent_id:t})};return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[i.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:a("fileManager.newFolder")})}),i.jsxs("form",{onSubmit:l,className:"p-4 space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:a("fileManager.folderName")}),i.jsx("input",{type:"text",value:s,onChange:c=>o(c.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:a("fileManager.folderNamePlaceholder"),autoFocus:!0,required:!0})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:e,children:a("common.cancel")}),i.jsx(Ie,{type:"submit",disabled:!s.trim()||r,children:r?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):a("common.create")})]})]})]})})}function ptt({type:t,currentName:e,onClose:n,onSave:r,isLoading:a,t:s}){const o=t==="file"?e.match(/(\.gcode\.3mf|\.3mf|\.gcode)$/i)?.[1]??"":"",l=t==="file"&&o?e.slice(0,-o.length):e,[c,u]=w.useState(l),d=m=>{m.preventDefault();const p=t==="file"?c.trim()+o:c.trim();c.trim()&&p!==e&&r(p)};return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[i.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:s(t==="file"?"fileManager.renameFile":"fileManager.renameFolder")})}),i.jsxs("form",{onSubmit:d,className:"p-4 space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("common.name")}),i.jsxs("div",{className:"flex items-center bg-bambu-dark border border-bambu-dark-tertiary rounded focus-within:border-bambu-green",children:[i.jsx("input",{type:"text",value:c,onChange:m=>u(m.target.value),className:"flex-1 bg-transparent px-3 py-2 text-white placeholder-bambu-gray focus:outline-none min-w-0",autoFocus:!0,required:!0}),o&&i.jsx("span",{className:"pr-3 text-bambu-gray text-sm select-none whitespace-nowrap",children:o})]})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:n,children:s("common.cancel")}),i.jsx(Ie,{type:"submit",disabled:!c.trim()||c.trim()===l||a,children:a?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):s("common.rename")})]})]})]})})}function ftt({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:a,isLoading:s,t:o}){const[l,c]=w.useState(null),u=(m,p=0)=>{const f=[];for(const y of m)f.push({id:y.id,name:y.name,depth:p}),y.children.length>0&&f.push(...u(y.children,p+1));return f},d=[{id:null,name:o("fileManager.rootNoFolder"),depth:0},...u(t)];return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[i.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:i.jsx("h2",{className:"text-lg font-semibold text-white",children:o("fileManager.moveFiles",{count:e.length})})}),i.jsxs("div",{className:"p-4 space-y-4",children:[i.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:d.map(m=>i.jsxs("button",{onClick:()=>c(m.id),disabled:m.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===m.id?"bg-bambu-green/20 text-bambu-green":m.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+m.depth*16}px`},children:[i.jsx(Pc,{className:"w-4 h-4"}),m.name,m.id===n&&i.jsxs("span",{className:"text-xs text-bambu-gray ml-auto",children:["(",o("fileManager.current"),")"]})]},m.id??"root"))}),i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx(Ie,{type:"button",variant:"secondary",onClick:r,children:o("common.cancel")}),i.jsx(Ie,{onClick:()=>a(l),disabled:s,children:s?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):o("common.move")})]})]})]})})}function gtt({folder:t,onClose:e,onLink:n,isLoading:r,t:a}){const[s,o]=w.useState("project"),[l,c]=w.useState(t.project_id||t.archive_id||null);w.useState(()=>{t.archive_id&&o("archive")});const{data:u}=tt({queryKey:["projects"],queryFn:()=>fe.getProjects()}),{data:d}=tt({queryKey:["archives-for-link"],queryFn:()=>fe.getArchives(void 0,void 0,100)}),m=()=>{n(s==="project"?{project_id:l,archive_id:0}:{project_id:0,archive_id:l})},p=()=>{n({project_id:0,archive_id:0})},f=t.project_id||t.archive_id;return i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[i.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[i.jsx(_h,{className:"w-5 h-5 text-bambu-green"}),a("fileManager.linkFolder")]}),i.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:i.jsx(Ht,{className:"w-5 h-5 text-bambu-gray"})})]}),i.jsxs("div",{className:"p-4 space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:a("fileManager.linkFolderDescription",{name:t.name})}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("button",{onClick:()=>{o("project"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${s==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[i.jsx(zX,{className:"w-4 h-4"}),a("fileManager.project")]}),i.jsxs("button",{onClick:()=>{o("archive"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${s==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[i.jsx($s,{className:"w-4 h-4"}),a("fileManager.archive")]})]}),i.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:s==="project"?u&&u.length>0?u.map(y=>i.jsxs("button",{onClick:()=>c(y.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===y.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[i.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:y.color||"#00ae42"}}),i.jsx("span",{className:"truncate",children:y.name})]},y.id)):i.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:a("fileManager.noProjectsFound")}):d&&d.length>0?d.map(y=>i.jsxs("button",{onClick:()=>c(y.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===y.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[i.jsx(sf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),i.jsx("span",{className:"truncate",children:y.print_name||y.filename})]},y.id)):i.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:a("fileManager.noArchivesFound")})})]}),i.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[f&&i.jsxs(Ie,{variant:"danger",onClick:p,disabled:r,children:[i.jsx(y0,{className:"w-4 h-4 mr-2"}),a("fileManager.unlink")]}),i.jsxs("div",{className:`flex gap-2 ${f?"":"ml-auto"}`,children:[i.jsx(Ie,{variant:"secondary",onClick:e,children:a("common.cancel")}),i.jsx(Ie,{onClick:m,disabled:!l||r,children:r?i.jsx(pt,{className:"w-4 h-4 animate-spin"}):a("fileManager.link")})]})]})]})})}function $oe({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:a,onRename:s,depth:o=0,wrapNames:l=!1,hasPermission:c,t:u}){const[d,m]=w.useState(!0),[p,f]=w.useState(!1),y=t.children.length>0,v=t.project_id||t.archive_id;return i.jsxs("div",{children:[i.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${e===t.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${8+o*12}px`},onClick:()=>n(t.id),children:[y?i.jsx("button",{onClick:b=>{b.stopPropagation(),m(!d)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:i.jsx(fa,{className:`w-3.5 h-3.5 transition-transform ${d?"rotate-90":""}`})}):i.jsx("div",{className:"w-4.5"}),i.jsx(Pc,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),i.jsx("span",{className:`text-sm flex-1 min-w-0 ${l?"break-all":"truncate"}`,title:t.name,children:t.name}),v&&i.jsxs("button",{onClick:b=>{b.stopPropagation(),a(t)},className:"flex-shrink-0 flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",title:`${t.project_name?`Project: ${t.project_name}`:`Archive: ${t.archive_name}`} (click to change)`,children:[i.jsx(_h,{className:"w-3 h-3"}),t.project_name?i.jsx(zX,{className:"w-3 h-3"}):i.jsx($s,{className:"w-3 h-3"})]}),t.file_count>0&&i.jsx("span",{className:"flex-shrink-0 text-xs text-bambu-gray",children:t.file_count}),!v&&i.jsx("button",{onClick:b=>{b.stopPropagation(),a(t)},className:"flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary",title:u("fileManager.linkToProjectOrArchive"),children:i.jsx(_h,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),i.jsx("div",{className:`flex-shrink-0 flex items-center gap-0.5 transition-opacity ${l?"":"opacity-0 group-hover:opacity-100"}`,onClick:b=>b.stopPropagation(),children:i.jsxs("div",{className:"relative",children:[i.jsx("button",{onClick:()=>f(!p),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:i.jsx(yh,{className:"w-3.5 h-3.5 text-bambu-gray"})}),p&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>f(!1)}),i.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(s(t),f(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionRenameFolder"),children:[i.jsx(Ki,{className:"w-3.5 h-3.5"}),u("common.rename")]}),i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(a(t),f(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionLinkFolder"),children:[i.jsx(_h,{className:"w-3.5 h-3.5"}),u(v?"fileManager.changeLink":"fileManager.linkTo")]}),i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:delete_all")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:delete_all")&&(r(t.id),f(!1))},disabled:!c("library:delete_all"),title:c("library:delete_all")?void 0:u("fileManager.noPermissionDeleteFolder"),children:[i.jsx(en,{className:"w-3.5 h-3.5"}),u("common.delete")]})]})]})]})})]}),y&&d&&i.jsx("div",{children:t.children.map(b=>i.jsx($oe,{folder:b,selectedFolderId:e,onSelect:n,onDelete:r,onLink:a,onRename:s,depth:o+1,wrapNames:l,hasPermission:c,t:u},b.id))})]})}function wL(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function btt({file:t,isSelected:e,isMobile:n,onSelect:r,onDelete:a,onDownload:s,onAddToQueue:o,onPrint:l,onPreview3d:c,onRename:u,onGenerateThumbnail:d,thumbnailVersion:m,hasPermission:p,canModify:f,authEnabled:y,t:v}){const[b,g]=w.useState(!1);return i.jsxs("div",{className:`group relative bg-bambu-dark-secondary rounded-lg border transition-all cursor-pointer overflow-hidden ${e?"border-bambu-green ring-1 ring-bambu-green":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,onClick:()=>r(t.id),children:[i.jsxs("div",{className:"aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden",children:[t.thumbnail_path?i.jsx("img",{src:`${fe.getLibraryFileThumbnailUrl(t.id)}${m?`?v=${m}`:""}`,alt:t.filename,className:"w-full h-full object-cover"}):i.jsx(sf,{className:"w-12 h-12 text-bambu-gray/30"}),i.jsx("div",{className:`absolute top-2 right-2 text-xs px-1.5 py-0.5 rounded font-medium ${t.file_type==="3mf"?"bg-bambu-green/90 text-white":t.file_type==="gcode"?"bg-blue-500/90 text-white":t.file_type==="stl"?"bg-purple-500/90 text-white":"bg-bambu-gray/90 text-white"}`,children:t.file_type.toUpperCase()})]}),i.jsxs("div",{className:"p-3",children:[i.jsx("h3",{className:"text-sm font-medium text-white truncate",title:t.print_name||t.filename,children:t.print_name||t.filename}),i.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-bambu-gray",children:[i.jsx("span",{children:ho(t.file_size)}),t.print_time_seconds&&i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Jn,{className:"w-3 h-3"}),Is(t.print_time_seconds)]})]}),t.sliced_for_model&&i.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[i.jsx(_r,{className:"w-3 h-3"}),t.sliced_for_model]}),t.print_count>0&&i.jsx("div",{className:"mt-1 text-xs text-bambu-green",children:v("fileManager.printedCount",{count:t.print_count})}),y&&t.created_by_username&&i.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[i.jsx(zd,{className:"w-3 h-3"}),t.created_by_username]})]}),i.jsxs("div",{className:`absolute bottom-2 right-2 transition-opacity ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:_=>_.stopPropagation(),children:[i.jsx("button",{onClick:()=>g(!b),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:i.jsx(yh,{className:"w-4 h-4 text-bambu-gray"})}),b&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>g(!1)}),i.jsxs("div",{className:"absolute right-0 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]",children:[l&&wL(t.filename)&&i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("printers:control")?"text-bambu-green hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("printers:control")&&(l(t),g(!1))},disabled:!p("printers:control"),title:p("printers:control")?void 0:v("fileManager.noPermissionPrint"),children:[i.jsx(_r,{className:"w-3.5 h-3.5"}),v("common.print")]}),o&&wL(t.filename)&&i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("queue:create")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("queue:create")&&(o(t.id),g(!1))},disabled:!p("queue:create"),title:p("queue:create")?void 0:v("fileManager.noPermissionAddToQueue"),children:[i.jsx(Jn,{className:"w-3.5 h-3.5"}),v("fileManager.schedulePrint")]}),c&&(t.file_type==="3mf"||t.file_type==="gcode"||t.file_type==="stl")&&i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library:read")&&(c(t),g(!1))},disabled:!p("library:read"),title:p("library:read")?void 0:"You do not have permission to preview files",children:[i.jsx(na,{className:"w-3.5 h-3.5"}),"3D Preview"]}),i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library:read")&&(s(t.id),g(!1))},disabled:!p("library:read"),title:p("library:read")?void 0:v("fileManager.noPermissionDownload"),children:[i.jsx(bi,{className:"w-3.5 h-3.5"}),v("common.download")]}),u&&i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library","update",t.created_by_id)&&(u(t),g(!1))},disabled:!f("library","update",t.created_by_id),title:f("library","update",t.created_by_id)?void 0:v("fileManager.noPermissionRenameFile"),children:[i.jsx(Ki,{className:"w-3.5 h-3.5"}),v("common.rename")]}),d&&t.file_type==="stl"&&i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library","update",t.created_by_id)&&(d(t),g(!1))},disabled:!f("library","update",t.created_by_id),title:f("library","update",t.created_by_id)?void 0:v("fileManager.noPermissionGenerateThumbnail"),children:[i.jsx(Ld,{className:"w-3.5 h-3.5"}),v("fileManager.generateThumbnail")]}),i.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library","delete",t.created_by_id)?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library","delete",t.created_by_id)&&(a(t.id),g(!1))},disabled:!f("library","delete",t.created_by_id),title:f("library","delete",t.created_by_id)?void 0:v("fileManager.noPermissionDeleteFile"),children:[i.jsx(en,{className:"w-3.5 h-3.5"}),v("common.delete")]})]})]})]}),i.jsx("div",{className:`absolute top-2 left-2 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${e?"bg-bambu-green border-bambu-green":`border-white/30 bg-black/30 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}`,children:e&&i.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function xtt(){const{t}=Rt(),e=sn(),{showToast:n}=fn(),{hasPermission:r,hasAnyPermission:a,canModify:s,authEnabled:o}=Nr(),[l]=jL(),c=l.get("folder"),u=c?parseInt(c,10):null,[d,m]=w.useState(u),[p,f]=w.useState([]),[y,v]=w.useState(!1),[b,g]=w.useState(!1),[_,N]=w.useState(!1),[T,C]=w.useState(null),[P,k]=w.useState(null),[R,A]=w.useState(null),[D,B]=w.useState(null),[z,W]=w.useState(null),[I,J]=w.useState(null),[ie,Q]=w.useState({}),[ue,me]=w.useState(null),[pe,Y]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[se,oe]=w.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[be,Me]=w.useState(()=>{const qe=localStorage.getItem("library-sidebar-width");return qe?parseInt(qe,10):256}),[q,Z]=w.useState(!1),j=w.useRef(null);w.useEffect(()=>{if(!q)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const qe=Nt=>{if(!j.current)return;const mt=j.current.parentElement?.getBoundingClientRect();if(!mt)return;const jt=Nt.clientX-mt.left,qt=Math.min(500,Math.max(200,jt));Me(qt)},_t=()=>{Z(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(be))};return document.addEventListener("mousemove",qe),document.addEventListener("mouseup",_t),()=>{document.removeEventListener("mousemove",qe),document.removeEventListener("mouseup",_t),document.body.style.userSelect="",document.body.style.cursor=""}},[q,be]);const[E,U]=w.useState(""),[K,$]=w.useState("all"),[ne,O]=w.useState(""),[V,ee]=w.useState(()=>localStorage.getItem("library-sort-field")||"name"),[G,re]=w.useState(()=>localStorage.getItem("library-sort-direction")||"asc"),ce=aie();w.useEffect(()=>{const qe=l.get("folder");if(qe){const _t=parseInt(qe,10);m(_t)}},[l]);const{data:ge}=tt({queryKey:["settings"],queryFn:()=>fe.getSettings()}),{data:xe,isLoading:ae}=tt({queryKey:["library-folders"],queryFn:()=>fe.getLibraryFolders()}),{data:L,isLoading:F}=tt({queryKey:["library-files",d],queryFn:()=>fe.getLibraryFiles(d,d===null)}),{data:te}=tt({queryKey:["library-stats"],queryFn:()=>fe.getLibraryStats()}),{data:ve}=tt({queryKey:["users"],queryFn:()=>fe.getUsers()}),he=w.useMemo(()=>{if(!L)return[];const qe=new Set(L.map(_t=>_t.file_type));return Array.from(qe).sort()},[L]),de=w.useMemo(()=>{if(!L)return[];let qe=[...L];if(E.trim()){const _t=E.toLowerCase();qe=qe.filter(Nt=>Nt.filename.toLowerCase().includes(_t)||Nt.print_name&&Nt.print_name.toLowerCase().includes(_t))}if(K!=="all"&&(qe=qe.filter(_t=>_t.file_type===K)),ne.trim()){const _t=ne.toLowerCase();qe=qe.filter(Nt=>Nt.created_by_username&&Nt.created_by_username.toLowerCase().includes(_t))}return qe.sort((_t,Nt)=>{let mt=0;switch(V){case"name":mt=(_t.print_name||_t.filename).localeCompare(Nt.print_name||Nt.filename);break;case"date":mt=(Zn(_t.created_at)?.getTime()??0)-(Zn(Nt.created_at)?.getTime()??0);break;case"size":mt=_t.file_size-Nt.file_size;break;case"type":mt=_t.file_type.localeCompare(Nt.file_type);break;case"prints":mt=_t.print_count-Nt.print_count;break}return G==="asc"?mt:-mt}),qe},[L,E,K,ne,V,G]),ke=w.useMemo(()=>{if(!te||!ge)return!1;const qe=(ge.library_disk_warning_gb||5)*1024*1024*1024;return te.disk_free_bytesfe.createLibraryFolder(qe),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),v(!1),n(t("fileManager.toast.folderCreated"),"success")},onError:qe=>n(qe.message,"error")}),Le=ft({mutationFn:qe=>fe.deleteLibraryFolder(qe),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-stats"]}),d===P?.id&&m(null),k(null),n(t("fileManager.toast.folderDeleted"),"success")},onError:qe=>{k(null),n(qe.message,"error")}}),$e=ft({mutationFn:qe=>fe.deleteLibraryFile(qe),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),f(qe=>qe.filter(_t=>_t!==P?.id)),k(null),n(t("fileManager.toast.fileDeleted"),"success")},onError:qe=>{k(null),n(qe.message,"error")}}),Re=ft({mutationFn:qe=>fe.bulkDeleteLibrary(qe,[]),onSuccess:(qe,_t)=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),n(t("fileManager.toast.filesDeleted",{count:_t.length}),"success"),f([]),k(null)},onError:qe=>{k(null),n(qe.message,"error")}}),Ae=ft({mutationFn:({fileIds:qe,folderId:_t})=>fe.moveLibraryFiles(qe,_t),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),f([]),g(!1),n(t("fileManager.toast.filesMoved"),"success")},onError:qe=>n(qe.message,"error")}),Pe=ft({mutationFn:({id:qe,data:_t})=>fe.updateLibraryFolder(qe,_t),onSuccess:(qe,_t)=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["project-folders"]}),e.invalidateQueries({queryKey:["archive-folders"]}),C(null);const Nt=_t.data.project_id===0&&_t.data.archive_id===0;n(t(Nt?"fileManager.toast.folderUnlinked":"fileManager.toast.folderLinked"),"success")},onError:qe=>n(qe.message,"error")}),Ue=ft({mutationFn:({id:qe,filename:_t})=>fe.updateLibraryFile(qe,{filename:_t}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),J(null),n(t("fileManager.toast.fileRenamed"),"success")},onError:qe=>{J(null),n(qe.message,"error")}}),je=ft({mutationFn:({id:qe,name:_t})=>fe.updateLibraryFolder(qe,{name:_t}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),J(null),n(t("fileManager.toast.folderRenamed"),"success")},onError:qe=>{J(null),n(qe.message,"error")}}),Xe=ft({mutationFn:()=>fe.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:qe=>{if(e.invalidateQueries({queryKey:["library-files"]}),qe.succeeded>0){const _t=Date.now(),Nt={};qe.results.forEach(mt=>{mt.success&&(Nt[mt.file_id]=_t)}),Q(mt=>({...mt,...Nt}))}qe.succeeded>0&&qe.failed===0?n(t("fileManager.toast.thumbnailsGenerated",{count:qe.succeeded}),"success"):qe.succeeded>0&&qe.failed>0?n(t("fileManager.toast.thumbnailsGeneratedPartial",{succeeded:qe.succeeded,failed:qe.failed}),"success"):qe.processed===0?n(t("fileManager.toast.noStlMissingThumbnails"),"info"):n(t("fileManager.toast.failedToGenerateThumbnails",{error:qe.results[0]?.error||"Unknown error"}),"error")},onError:qe=>n(qe.message,"error")}),ye=ft({mutationFn:qe=>fe.batchGenerateStlThumbnails({file_ids:[qe]}),onSuccess:qe=>{if(e.invalidateQueries({queryKey:["library-files"]}),qe.succeeded>0){const _t=qe.results[0]?.file_id;_t&&Q(Nt=>({...Nt,[_t]:Date.now()})),n(t("fileManager.toast.thumbnailGenerated"),"success")}else n(t("fileManager.toast.failedToGenerateThumbnail",{error:qe.results[0]?.error||"Unknown error"}),"error")},onError:qe=>n(qe.message,"error")}),Ge=w.useCallback(qe=>{const _t=qe.toLowerCase();return _t.endsWith(".gcode")||_t.includes(".gcode.")},[]),Ee=w.useMemo(()=>L?L.filter(qe=>p.includes(qe.id)&&Ge(qe.filename)):[],[L,p,Ge]),Ke=w.useCallback(qe=>{f(_t=>_t.includes(qe)?_t.filter(Nt=>Nt!==qe):[..._t,qe])},[]),Ve=w.useCallback(()=>{de.length>0&&f(de.map(qe=>qe.id))},[de]),Ne=w.useCallback(()=>{f([])},[]),Ce=()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]})},He=qe=>{fe.downloadLibraryFile(qe).catch(_t=>{console.error("Library file download failed:",_t)})},et=()=>{P&&(P.type==="file"?$e.mutate(P.id):P.type==="folder"?Le.mutate(P.id):P.type==="bulk"&&Re.mutate(p))},it=Le.isPending||$e.isPending||Re.isPending,xt=qe=>{Y(qe),localStorage.setItem("library-view-mode",qe)},vt=ae||F;return i.jsxs("div",{className:"p-4 md:p-8 min-h-[calc(100vh-64px)] lg:h-[calc(100vh-64px)] flex flex-col",children:[i.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[i.jsxs("div",{children:[i.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[i.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:i.jsx(Pc,{className:"w-6 h-6 text-bambu-green"})}),t("fileManager.title")]}),i.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("fileManager.subtitle")})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"flex items-center bg-bambu-dark rounded-lg p-1",children:[i.jsx("button",{onClick:()=>xt("grid"),className:`p-1.5 rounded transition-colors ${pe==="grid"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.gridView"),children:i.jsx(xw,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>xt("list"),className:`p-1.5 rounded transition-colors ${pe==="list"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.listView"),children:i.jsx(eT,{className:"w-4 h-4"})})]}),i.jsxs(Ie,{variant:"secondary",onClick:()=>Xe.mutate(),disabled:Xe.isPending||!a("library:update_own","library:update_all"),title:a("library:update_own","library:update_all")?t("fileManager.generateThumbnailsForMissing"):t("fileManager.noPermissionGenerateThumbnail"),children:[Xe.isPending?i.jsx(pt,{className:"w-4 h-4 mr-2 animate-spin"}):i.jsx(Ld,{className:"w-4 h-4 mr-2"}),t("fileManager.generateThumbnails")]}),i.jsxs(Ie,{variant:"secondary",onClick:()=>v(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionCreateFolder"),children:[i.jsx(Xpe,{className:"w-4 h-4 mr-2"}),t("fileManager.newFolder")]}),i.jsxs(Ie,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[i.jsx(vi,{className:"w-4 h-4 mr-2"}),t("common.upload")]})]})]}),ke&&te&&ge&&i.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[i.jsx(Mn,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),i.jsxs("div",{className:"flex-1",children:[i.jsx("p",{className:"text-sm text-amber-500 font-medium",children:t("fileManager.lowDiskSpaceWarning")}),i.jsx("p",{className:"text-xs text-amber-500/80",children:t("fileManager.lowDiskSpaceDetails",{free:ho(te.disk_free_bytes),total:ho(te.disk_total_bytes),threshold:ge.library_disk_warning_gb})})]})]}),te&&i.jsxs("div",{className:"flex flex-wrap items-center gap-3 sm:gap-6 mb-6 p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx(ZC,{className:"w-4 h-4 text-bambu-green"}),i.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.files"),":"]}),i.jsx("span",{className:"text-white font-medium",children:te.total_files})]}),i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx(Pc,{className:"w-4 h-4 text-blue-400"}),i.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.folders"),":"]}),i.jsx("span",{className:"text-white font-medium",children:te.total_folders})]}),i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx(Ix,{className:"w-4 h-4 text-amber-400"}),i.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.size"),":"]}),i.jsx("span",{className:"text-white font-medium",children:ho(te.total_size_bytes)})]}),i.jsxs("div",{className:"flex items-center gap-2 text-sm sm:ml-auto",children:[i.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.free"),":"]}),i.jsx("span",{className:`font-medium ${ke?"text-amber-500":"text-white"}`,children:ho(te.disk_free_bytes)})]})]}),i.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-4 lg:gap-6 min-h-0",children:[i.jsx("div",{className:"lg:hidden",children:i.jsxs("select",{value:d??"",onChange:qe=>m(qe.target.value?parseInt(qe.target.value,10):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg px-3 py-2.5 text-white focus:outline-none focus:border-bambu-green",children:[i.jsxs("option",{value:"",children:["📁 ",t("fileManager.allFiles")]}),xe&&(()=>{const qe=(_t,Nt=0)=>{const mt=[];for(const jt of _t)mt.push({id:jt.id,name:jt.name,fileCount:jt.file_count,depth:Nt}),jt.children.length>0&&mt.push(...qe(jt.children,Nt+1));return mt};return qe(xe).map(_t=>i.jsxs("option",{value:_t.id,children:["│ ".repeat(_t.depth),"📂 ",_t.name," ",_t.fileCount>0?`(${_t.fileCount})`:""]},_t.id))})()]})}),i.jsxs("div",{ref:j,className:"hidden lg:flex flex-shrink-0 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden flex-col relative",style:{width:`${be}px`},children:[i.jsx("div",{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 group/resize flex items-center justify-center transition-colors ${q?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:qe=>{qe.preventDefault(),Z(!0)},onDoubleClick:()=>{Me(256),localStorage.setItem("library-sidebar-width","256")},title:t("fileManager.dragToResizeTooltip"),children:i.jsxs("div",{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${q?"opacity-100":""}`,children:[i.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),i.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),i.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"})]})}),i.jsxs("div",{className:"p-3 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[i.jsx("h2",{className:"text-sm font-medium text-white",children:t("fileManager.folders")}),i.jsx("button",{onClick:()=>{const qe=!se;oe(qe),localStorage.setItem("library-wrap-folders",String(qe))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${se?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:t(se?"fileManager.disableTextWrapping":"fileManager.enableTextWrapping"),children:t("fileManager.wrap")})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[i.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${d===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>m(null),children:[i.jsx(sf,{className:"w-4 h-4"}),i.jsx("span",{className:"text-sm",children:t("fileManager.allFiles")})]}),xe?.map(qe=>i.jsx($oe,{folder:qe,selectedFolderId:d,onSelect:m,onDelete:_t=>k({type:"folder",id:_t}),onLink:C,onRename:_t=>J({type:"folder",id:_t.id,name:_t.name}),wrapNames:se,hasPermission:r,t},qe.id))]})]}),i.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[L&&L.length>0&&i.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mb-4 p-2 sm:p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-0 z-10 lg:static",children:[i.jsxs("div",{className:"relative w-full sm:w-auto sm:flex-1 sm:max-w-xs",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),i.jsx("input",{type:"text",placeholder:t("fileManager.searchFiles"),value:E,onChange:qe=>U(qe.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(JC,{className:"w-4 h-4 text-bambu-gray hidden sm:block"}),i.jsxs("select",{value:K,onChange:qe=>$(qe.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[i.jsx("option",{value:"all",children:t("fileManager.allTypes")}),he.map(qe=>i.jsx("option",{value:qe,children:qe.toUpperCase()},qe))]})]}),o&&i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:"text",placeholder:t("fileManager.filterByUser",{defaultValue:"Filter by user"}),value:ne,onChange:qe=>O(qe.target.value),list:"usernames-list",className:`w-32 sm:w-40 px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green ${ne?"pr-7":""}`,style:ne?{WebkitAppearance:"none",MozAppearance:"textfield"}:void 0}),ne&&i.jsx("button",{onClick:()=>O(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white z-10",children:i.jsx(Ht,{className:"w-3 h-3"})}),i.jsx("datalist",{id:"usernames-list",children:ve?.map(qe=>i.jsx("option",{value:qe.username},qe.id))})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("select",{value:V,onChange:qe=>{const _t=qe.target.value;ee(_t),localStorage.setItem("library-sort-field",_t)},className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[i.jsx("option",{value:"name",children:t("common.name")}),i.jsx("option",{value:"date",children:t("common.date")}),i.jsx("option",{value:"size",children:t("fileManager.size")}),i.jsx("option",{value:"type",children:t("common.type")}),i.jsx("option",{value:"prints",children:t("fileManager.prints")})]}),i.jsx("button",{onClick:()=>re(qe=>{const _t=qe==="asc"?"desc":"asc";return localStorage.setItem("library-sort-direction",_t),_t}),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:t(G==="asc"?"fileManager.ascending":"fileManager.descending"),children:G==="asc"?i.jsx(ghe,{className:"w-4 h-4 text-white"}):i.jsx(che,{className:"w-4 h-4 text-white"})})]}),(E||K!=="all"||ne)&&i.jsx("span",{className:"text-sm text-bambu-gray hidden sm:inline",children:t("fileManager.resultsCount",{showing:de.length,total:L.length})})]}),de.length>0&&i.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4 p-2 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-[52px] z-10 lg:static",children:[p.length===de.length&&p.length>0?i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:Ne,children:[i.jsx(ql,{className:"w-4 h-4 sm:mr-1"}),i.jsx("span",{className:"hidden sm:inline",children:t("fileManager.deselectAll")})]}):i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:Ve,children:[i.jsx(_o,{className:"w-4 h-4 sm:mr-1"}),i.jsx("span",{className:"hidden sm:inline",children:t("fileManager.selectAll")})]}),p.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-sm text-bambu-gray ml-2",children:t("fileManager.selected",{count:p.length})}),i.jsx("div",{className:"hidden sm:block flex-1"}),i.jsxs("div",{className:"w-full sm:w-auto flex flex-wrap items-center gap-2 mt-2 sm:mt-0",children:[Ee.length===1&&i.jsxs(Ie,{variant:"primary",size:"sm",onClick:()=>B(Ee[0]),disabled:!r("printers:control"),title:r("printers:control")?void 0:t("fileManager.noPermissionPrint"),children:[i.jsx(wo,{className:"w-4 h-4 sm:mr-1"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.print")})]}),Ee.length===1&&i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>W(Ee[0]),disabled:!r("queue:create"),title:r("queue:create")?void 0:t("fileManager.noPermissionAddToQueue"),children:[i.jsx(Jn,{className:"w-4 h-4 sm:mr-1"}),i.jsx("span",{className:"hidden sm:inline",children:t("fileManager.schedulePrint")})]}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>g(!0),disabled:!a("library:update_own","library:update_all"),title:a("library:update_own","library:update_all")?void 0:t("fileManager.noPermissionMoveFiles"),children:[i.jsx(sge,{className:"w-4 h-4 sm:mr-1"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.move")})]}),i.jsxs(Ie,{variant:"danger",size:"sm",onClick:()=>{p.length===1?k({type:"file",id:p[0]}):k({type:"bulk",id:0,count:p.length})},disabled:!a("library:delete_own","library:delete_all"),title:a("library:delete_own","library:delete_all")?void 0:t("fileManager.noPermissionDeleteFiles"),children:[i.jsx(en,{className:"w-4 h-4 sm:mr-1"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.delete")})]}),i.jsxs(Ie,{variant:"secondary",size:"sm",onClick:Ne,children:[i.jsx(Ht,{className:"w-4 h-4 sm:mr-1"}),i.jsx("span",{className:"hidden sm:inline",children:t("common.clear")})]})]})]})]}),vt?i.jsx("div",{className:"flex-1 flex items-center justify-center",children:i.jsxs("div",{className:"flex flex-col items-center gap-3",children:[i.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("fileManager.loadingFiles")})]})}):L?.length===0?i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[i.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:i.jsx(sf,{className:"w-12 h-12 text-bambu-gray/50"})}),i.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t(d!==null?"fileManager.folderIsEmpty":"fileManager.noFilesYet")}),i.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t(d!==null?"fileManager.folderEmptyDescription":"fileManager.noFilesDescription")}),i.jsxs(Ie,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[i.jsx(ar,{className:"w-4 h-4 mr-2"}),t("fileManager.uploadFiles")]})]}):de.length===0?i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[i.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:i.jsx(Rr,{className:"w-12 h-12 text-bambu-gray/50"})}),i.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t("fileManager.noMatchingFiles")}),i.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t("fileManager.noMatchingFilesDescription")}),i.jsx(Ie,{variant:"secondary",onClick:()=>{U(""),$("all")},children:t("fileManager.clearFilters")})]}):pe==="grid"?i.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:i.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4",children:de.map(qe=>i.jsx(btt,{file:qe,isSelected:p.includes(qe.id),isMobile:ce,t,onSelect:Ke,onDelete:_t=>k({type:"file",id:_t}),onDownload:He,onAddToQueue:_t=>{const Nt=L?.find(mt=>mt.id===_t);Nt&&W(Nt)},onPrint:A,onPreview3d:me,onRename:_t=>J({type:"file",id:_t.id,name:_t.filename}),onGenerateThumbnail:_t=>ye.mutate(_t.id),thumbnailVersion:ie[qe.id],hasPermission:r,canModify:s,authEnabled:o},qe.id))})}):i.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[i.jsxs("div",{className:`hidden sm:grid ${o?"grid-cols-[auto_1fr_120px_100px_100px_100px_80px]":"grid-cols-[auto_1fr_100px_100px_100px_80px]"} gap-4 px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary text-xs text-bambu-gray font-medium`,children:[i.jsx("div",{className:"w-6"}),i.jsx("div",{children:t("common.name")}),o&&i.jsx("div",{children:t("fileManager.uploadedBy",{defaultValue:"Uploaded By"})}),i.jsx("div",{children:t("common.type")}),i.jsx("div",{children:t("fileManager.size")}),i.jsx("div",{children:t("fileManager.prints")}),i.jsx("div",{})]}),de.map(qe=>i.jsxs("div",{className:`grid ${o?"grid-cols-[auto_1fr_120px_100px_100px_100px_80px]":"grid-cols-[auto_1fr_100px_100px_100px_80px]"} gap-4 px-4 py-3 items-center border-b border-bambu-dark-tertiary last:border-b-0 cursor-pointer hover:bg-bambu-dark/50 transition-colors ${p.includes(qe.id)?"bg-bambu-green/10":""}`,onClick:()=>Ke(qe.id),children:[i.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${p.includes(qe.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:p.includes(qe.id)&&i.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})}),i.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[i.jsxs("div",{className:"relative group/thumb",children:[i.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden",children:qe.thumbnail_path?i.jsx("img",{src:`${fe.getLibraryFileThumbnailUrl(qe.id)}${ie[qe.id]?`?v=${ie[qe.id]}`:""}`,alt:"",className:"w-full h-full object-cover"}):i.jsx("div",{className:"w-full h-full flex items-center justify-center",children:i.jsx(sf,{className:"w-5 h-5 text-bambu-gray/50"})})}),qe.thumbnail_path&&i.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:i.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:i.jsx("img",{src:`${fe.getLibraryFileThumbnailUrl(qe.id)}${ie[qe.id]?`?v=${ie[qe.id]}`:""}`,alt:qe.filename,className:"w-full h-full object-contain"})})})]}),i.jsx("div",{className:"min-w-0",children:i.jsx("div",{className:"text-sm text-white truncate",children:qe.print_name||qe.filename})})]}),o&&i.jsx("div",{className:"text-sm text-bambu-gray flex items-center gap-1",children:qe.created_by_username?i.jsxs(i.Fragment,{children:[i.jsx(zd,{className:"w-3 h-3"}),i.jsx("span",{className:"truncate",children:qe.created_by_username})]}):"-"}),i.jsx("div",{children:i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${qe.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":qe.file_type==="gcode"?"bg-blue-500/20 text-blue-400":qe.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:qe.file_type.toUpperCase()})}),i.jsx("div",{className:"text-sm text-bambu-gray",children:ho(qe.file_size)}),i.jsx("div",{className:"text-sm text-bambu-gray",children:qe.print_count>0?`${qe.print_count}x`:"-"}),i.jsxs("div",{className:"flex items-center gap-1",onClick:_t=>_t.stopPropagation(),children:[wL(qe.filename)&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>r("printers:control")&&A(qe),className:`p-1.5 rounded transition-colors ${r("printers:control")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("printers:control")?t("common.print"):t("fileManager.noPermissionPrint"),disabled:!r("printers:control"),children:i.jsx(_r,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>{r("queue:create")&&W(qe)},className:`p-1.5 rounded transition-colors ${r("queue:create")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("queue:create")?t("fileManager.schedulePrint"):t("fileManager.noPermissionAddToQueue"),disabled:!r("queue:create"),children:i.jsx(Jn,{className:"w-4 h-4"})})]}),(qe.file_type==="3mf"||qe.file_type==="gcode"||qe.file_type==="stl")&&i.jsx("button",{onClick:()=>r("library:read")&&me(qe),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?"3D Preview":"You do not have permission to preview files",disabled:!r("library:read"),children:i.jsx(na,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>r("library:read")&&He(qe.id),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?t("common.download"):t("fileManager.noPermissionDownload"),disabled:!r("library:read"),children:i.jsx(bi,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>s("library","update",qe.created_by_id)&&J({type:"file",id:qe.id,name:qe.filename}),className:`p-1.5 rounded transition-colors ${s("library","update",qe.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",qe.created_by_id)?t("common.rename"):t("fileManager.noPermissionRenameFile"),disabled:!s("library","update",qe.created_by_id),children:i.jsx(Ki,{className:"w-4 h-4"})}),qe.file_type==="stl"&&i.jsx("button",{onClick:()=>s("library","update",qe.created_by_id)&&ye.mutate(qe.id),className:`p-1.5 rounded transition-colors ${s("library","update",qe.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",qe.created_by_id)?t("fileManager.generateThumbnail"):t("fileManager.noPermissionGenerateThumbnail"),disabled:ye.isPending||!s("library","update",qe.created_by_id),children:i.jsx(Ld,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>s("library","delete",qe.created_by_id)&&k({type:"file",id:qe.id}),className:`p-1.5 rounded transition-colors ${s("library","delete",qe.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","delete",qe.created_by_id)?t("common.delete"):t("fileManager.noPermissionDeleteFile"),disabled:!s("library","delete",qe.created_by_id),children:i.jsx(en,{className:"w-4 h-4"})})]})]},qe.id))]})})]})]}),y&&i.jsx(htt,{parentId:d,onClose:()=>v(!1),onSave:qe=>_e.mutate(qe),isLoading:_e.isPending,t}),b&&xe&&i.jsx(ftt,{folders:xe,selectedFiles:p,currentFolderId:d,onClose:()=>g(!1),onMove:qe=>Ae.mutate({fileIds:p,folderId:qe}),isLoading:Ae.isPending,t}),_&&i.jsx(Qre,{folderId:d,onClose:()=>N(!1),onUploadComplete:Ce}),T&&i.jsx(gtt,{folder:T,onClose:()=>C(null),onLink:qe=>Pe.mutate({id:T.id,data:qe}),isLoading:Pe.isPending,t}),P&&i.jsx(_n,{title:P.type==="folder"?t("fileManager.deleteFolder"):P.type==="bulk"?t("fileManager.deleteFilesCount",{count:P.count}):t("fileManager.deleteFile"),message:P.type==="folder"?t("fileManager.deleteFolderConfirm"):P.type==="bulk"?t("fileManager.deleteFilesConfirm",{count:P.count}):t("fileManager.deleteFileConfirm"),confirmText:t("common.delete"),variant:"danger",isLoading:it,loadingText:t("fileManager.deleting"),onConfirm:et,onCancel:()=>k(null)}),R&&i.jsx(bu,{mode:"reprint",libraryFileId:R.id,archiveName:R.print_name||R.filename,onClose:()=>A(null),onSuccess:()=>{A(null),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),D&&i.jsx(bu,{mode:"reprint",libraryFileId:D.id,archiveName:D.print_name||D.filename,onClose:()=>B(null),onSuccess:()=>{B(null),f([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),z&&i.jsx(bu,{mode:"add-to-queue",libraryFileId:z.id,archiveName:z.print_name||z.filename,onClose:()=>W(null),onSuccess:()=>{W(null),f([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["queue"]}),e.invalidateQueries({queryKey:["archives"]})}}),ue&&i.jsx(jI,{libraryFileId:ue.id,title:ue.print_name||ue.filename,fileType:ue.file_type,onClose:()=>me(null)}),I&&i.jsx(ptt,{type:I.type,currentName:I.name,onClose:()=>J(null),onSave:qe=>{I.type==="file"?Ue.mutate({id:I.id,filename:qe}):je.mutate({id:I.id,name:qe})},isLoading:Ue.isPending||je.isPending,t})]})}const WD=5,ytt=2e3,vtt=3e4,wtt=5e3;function Stt(){const{t}=Rt(),e=sn(),{showToast:n}=fn(),{hasPermission:r}=Nr(),{printerId:a}=hw(),s=parseInt(a||"0",10),[o,l]=w.useState("stream"),[c,u]=w.useState(!1),[d,m]=w.useState(!1),[p,f]=w.useState(!0),[y,v]=w.useState(Date.now()),[b,g]=w.useState(!1),[_,N]=w.useState(!1),[T,C]=w.useState(0),[P,k]=w.useState(!1),[R,A]=w.useState(0),[D,B]=w.useState(1),[z,W]=w.useState({x:0,y:0}),[I,J]=w.useState(!1),[ie,Q]=w.useState({x:0,y:0}),[ue,me]=w.useState(null),[pe,Y]=w.useState(null),se=w.useRef(null),oe=w.useRef(null),be=w.useRef(null),Me=w.useRef(null),q=w.useRef(null),{data:Z}=tt({queryKey:["printer",s],queryFn:()=>fe.getPrinter(s),enabled:s>0}),{data:j}=tt({queryKey:["printerStatus",s],queryFn:()=>fe.getPrinterStatus(s),refetchInterval:3e4,enabled:s>0}),E=ft({mutationFn:Ae=>fe.setChamberLight(s,Ae),onMutate:async Ae=>{await e.cancelQueries({queryKey:["printerStatus",s]});const Pe=e.getQueryData(["printerStatus",s]);return e.setQueryData(["printerStatus",s],Ue=>({...Ue,chamber_light:Ae})),{previousStatus:Pe}},onSuccess:(Ae,Pe)=>{n(`Chamber light ${Pe?"on":"off"}`)},onError:(Ae,Pe,Ue)=>{Ue?.previousStatus&&e.setQueryData(["printerStatus",s],Ue.previousStatus),n(Ae.message||t("printers.toast.failedToControlChamberLight"),"error")}}),U=(j?.state==="RUNNING"||j?.state==="PAUSE")&&(j?.printable_objects_count??0)>=2;w.useEffect(()=>(Z&&(document.title=`${Z.name} - Camera`),()=>{document.title="Bambuddy"}),[Z]);const K=w.useRef(!1);w.useEffect(()=>{const Ae=`/api/v1/printers/${s}/camera/stop`;K.current=!1;const Pe=()=>{if(s>0&&!K.current){K.current=!0;const Xe={},ye=Ud();ye&&(Xe.Authorization=`Bearer ${ye}`),fetch(Ae,{method:"POST",keepalive:!0,headers:Xe}).catch(()=>{})}},Ue=()=>{Pe()};window.addEventListener("beforeunload",Ue);const je=se.current;return()=>{window.removeEventListener("beforeunload",Ue),je&&(je.src=""),Pe()}},[s]),w.useEffect(()=>{if(p&&!b){const Pe=setTimeout(()=>{f(!1)},o==="stream"?3e3:2e4);return()=>clearTimeout(Pe)}},[o,p,y,b]),w.useEffect(()=>{const Ae=()=>{const Pe=!!document.fullscreenElement;N(Pe),B(1),W({x:0,y:0}),o==="stream"&&!b&&(se.current&&(se.current.src=""),setTimeout(()=>{f(!0),v(Date.now())},200))};return document.addEventListener("fullscreenchange",Ae),()=>document.removeEventListener("fullscreenchange",Ae)},[o,b]),w.useEffect(()=>{let Ae;const Pe=()=>{clearTimeout(Ae),Ae=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",Pe),()=>{clearTimeout(Ae),window.removeEventListener("resize",Pe)}},[]),w.useEffect(()=>()=>{be.current&&clearTimeout(be.current),Me.current&&clearInterval(Me.current),q.current&&clearInterval(q.current)},[]);const $=w.useCallback(()=>{if(T>=WD){k(!1),m(!0);return}const Ae=Math.min(ytt*Math.pow(2,T),vtt);k(!0),A(Math.ceil(Ae/1e3)),Me.current=setInterval(()=>{A(Pe=>Pe<=1?(Me.current&&clearInterval(Me.current),0):Pe-1)},1e3),be.current=setTimeout(()=>{C(Pe=>Pe+1),k(!1),f(!0),m(!1),se.current&&(se.current.src=""),v(Date.now())},Ae)},[T]);w.useEffect(()=>{if(o!=="stream"||p||P||b){q.current&&(clearInterval(q.current),q.current=null);return}return q.current=setInterval(async()=>{try{const Ae=await fe.getCameraStatus(s);(Ae.stalled||!Ae.active&&!d)&&(console.log(`Stream issue detected: stalled=${Ae.stalled}, active=${Ae.active}, reconnecting...`),q.current&&(clearInterval(q.current),q.current=null),f(!1),$())}catch{}},wtt),()=>{q.current&&(clearInterval(q.current),q.current=null)}},[o,p,d,P,b,s,$]);const ne=()=>{f(!1),o==="stream"&&T{if(f(!1),m(!1),C(0),k(!1),be.current&&clearTimeout(be.current),Me.current&&clearInterval(Me.current),se.current&&!localStorage.getItem("cameraWindowState")){const Ae=se.current,Pe=Ae.naturalWidth,Ue=Ae.naturalHeight;if(Pe>0&&Ue>0){const ye=window.outerWidth-window.innerWidth,Ge=window.outerHeight-window.innerHeight,Ee=Pe+16+ye,Ke=Ue+45+16+Ge;try{window.resizeTo(Ee,Ke)}catch{}}}},V=()=>{if(s>0){const Ae={},Pe=Ud();Pe&&(Ae.Authorization=`Bearer ${Pe}`),fetch(`/api/v1/printers/${s}/camera/stop`,{method:"POST",headers:Ae}).catch(()=>{})}},ee=Ae=>{o===Ae||b||(g(!0),f(!0),m(!1),C(0),k(!1),B(1),W({x:0,y:0}),be.current&&clearTimeout(be.current),Me.current&&clearInterval(Me.current),se.current&&(se.current.src=""),o==="stream"&&V(),setTimeout(()=>{l(Ae),v(Date.now()),g(!1)},100))},G=()=>{b||(g(!0),f(!0),m(!1),C(0),k(!1),be.current&&clearTimeout(be.current),Me.current&&clearInterval(Me.current),se.current&&(se.current.src=""),o==="stream"&&V(),setTimeout(()=>{v(Date.now()),g(!1)},100))},re=()=>{oe.current&&(document.fullscreenElement?document.exitFullscreen():oe.current.requestFullscreen())},ce=()=>{B(Ae=>Math.min(Ae+.5,4))},ge=()=>{B(Ae=>{const Pe=Math.max(Ae-.5,1);return Pe===1&&W({x:0,y:0}),Pe})},xe=Ae=>{Ae.preventDefault(),Ae.deltaY<0?ce():ge()},ae=Ae=>{D>1&&(Ae.preventDefault(),J(!0),Q({x:Ae.clientX-z.x,y:Ae.clientY-z.y}))},L=w.useCallback(()=>{if(!oe.current)return{x:300,y:200};const Ae=oe.current.getBoundingClientRect(),Pe=Ae.width*(D-1)/2,Ue=Ae.height*(D-1)/2;return{x:Math.max(50,Pe),y:Math.max(50,Ue)}},[D]),F=Ae=>{if(I&&D>1){const Pe=Ae.clientX-ie.x,Ue=Ae.clientY-ie.y,je=L();W({x:Math.max(-je.x,Math.min(je.x,Pe)),y:Math.max(-je.y,Math.min(je.y,Ue))})}},te=()=>{J(!1)},ve=Ae=>{if(Ae.length<2)return 0;const Pe=Ae[0].clientX-Ae[1].clientX,Ue=Ae[0].clientY-Ae[1].clientY;return Math.sqrt(Pe*Pe+Ue*Ue)},he=Ae=>Ae.length<2?{x:Ae[0].clientX,y:Ae[0].clientY}:{x:(Ae[0].clientX+Ae[1].clientX)/2,y:(Ae[0].clientY+Ae[1].clientY)/2},de=Ae=>{Ae.touches.length===2?(Ae.preventDefault(),me(ve(Ae.touches)),Y(he(Ae.touches))):Ae.touches.length===1&&D>1&&(Ae.preventDefault(),J(!0),Q({x:Ae.touches[0].clientX-z.x,y:Ae.touches[0].clientY-z.y}))},ke=Ae=>{if(Ae.touches.length===2&&ue!==null){Ae.preventDefault();const Pe=ve(Ae.touches),Ue=Pe/ue;B(Xe=>{const ye=Math.max(1,Math.min(4,Xe*Ue));return ye===1&&W({x:0,y:0}),ye}),me(Pe);const je=he(Ae.touches);if(pe){const Xe=L();W(ye=>({x:Math.max(-Xe.x,Math.min(Xe.x,ye.x+(je.x-pe.x))),y:Math.max(-Xe.y,Math.min(Xe.y,ye.y+(je.y-pe.y)))}))}Y(je)}else if(Ae.touches.length===1&&I&&D>1){Ae.preventDefault();const Pe=Ae.touches[0].clientX-ie.x,Ue=Ae.touches[0].clientY-ie.y,je=L();W({x:Math.max(-je.x,Math.min(je.x,Pe)),y:Math.max(-je.y,Math.min(je.y,Ue))})}},_e=Ae=>{Ae.touches.length<2&&(me(null),Y(null)),Ae.touches.length===0&&J(!1)},Le=()=>{B(1),W({x:0,y:0})},$e=b?"":o==="stream"?`/api/v1/printers/${s}/camera/stream?fps=15&t=${y}`:`/api/v1/printers/${s}/camera/snapshot?t=${y}`,Re=p||b||P;return s?i.jsxs("div",{ref:oe,className:"min-h-screen bg-black flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[i.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[i.jsx(ax,{className:"w-4 h-4"}),Z?.name||`Printer ${s}`]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[i.jsx("button",{onClick:()=>ee("stream"),disabled:Re,className:`px-3 py-1 text-xs rounded transition-colors ${o==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.live")}),i.jsx("button",{onClick:()=>ee("snapshot"),disabled:Re,className:`px-3 py-1 text-xs rounded transition-colors ${o==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.snapshot")})]}),i.jsx("button",{onClick:()=>E.mutate(!j?.chamber_light),disabled:!j?.connected||E.isPending||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${j?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30":"hover:bg-bambu-dark-tertiary"}`,title:r("printers:control")?t("camera.chamberLight"):t("printers.permission.noControl"),children:i.jsx(kO,{on:j?.chamber_light??!1,className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>u(!0),disabled:!U||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${U&&r("printers:control")?"hover:bg-bambu-dark-tertiary":""}`,title:r("printers:control")?t(U?"printers.skipObjects.tooltip":"printers.skipObjects.onlyWhilePrinting"):t("printers.permission.noControl"),children:i.jsx(xT,{className:"w-4 h-4 text-bambu-gray"})}),i.jsx("button",{onClick:G,disabled:Re,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:t(o==="stream"?"camera.restartStream":"camera.refreshSnapshot"),children:i.jsx(Sr,{className:`w-4 h-4 text-bambu-gray ${Re?"animate-spin":""}`})}),i.jsx("button",{onClick:re,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:t(_?"camera.exitFullscreen":"camera.fullscreen"),children:_?i.jsx(KX,{className:"w-4 h-4 text-bambu-gray"}):i.jsx(Kfe,{className:"w-4 h-4 text-bambu-gray"})})]})]}),i.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:xe,onMouseMove:F,onMouseUp:te,onMouseLeave:te,onTouchStart:de,onTouchMove:ke,onTouchEnd:_e,style:{touchAction:"none"},children:i.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(p||b)&&!P&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:i.jsxs("div",{className:"text-center",children:[i.jsx(Sr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t(o==="stream"?"camera.connectingToCamera":"camera.capturingSnapshot")})]})}),P&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:i.jsxs("div",{className:"text-center p-4",children:[i.jsx(Rh,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),i.jsx("p",{className:"text-white mb-2",children:t("camera.connectionLost")}),i.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:t("camera.reconnecting",{countdown:R,attempt:T+1,max:WD})}),i.jsx("button",{onClick:G,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.reconnectNow")})]})}),d&&!P&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:i.jsxs("div",{className:"text-center p-4",children:[i.jsx(Mn,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),i.jsx("p",{className:"text-white mb-2",children:t("camera.cameraUnavailable")}),i.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:t("camera.cameraUnavailableDesc")}),i.jsx("button",{onClick:G,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.retry")})]})}),i.jsx("img",{ref:se,src:$e,alt:t("camera.cameraStream"),className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${D}) translate(${z.x/D}px, ${z.y/D}px) rotate(${Z?.camera_rotation||0}deg)`,...Z?.camera_rotation===90||Z?.camera_rotation===270?{maxWidth:"100vh",maxHeight:"100vw"}:{},cursor:D>1?I?"grabbing":"grab":"default"},onError:$e?ne:void 0,onLoad:$e?O:void 0,onMouseDown:ae,draggable:!1},y),i.jsxs("div",{className:"absolute bottom-4 left-4 flex items-center gap-1.5 bg-black/60 rounded-lg px-2 py-1.5",children:[i.jsx("button",{onClick:ge,disabled:D<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomOut"),children:i.jsx(YL,{className:"w-4 h-4 text-white"})}),i.jsxs("button",{onClick:Le,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:t("camera.resetZoom"),children:[Math.round(D*100),"%"]}),i.jsx("button",{onClick:ce,disabled:D>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomIn"),children:i.jsx(KL,{className:"w-4 h-4 text-white"})})]})]})}),i.jsx(CO,{printerId:s,isOpen:c,onClose:()=>u(!1)})]}):i.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:i.jsx("p",{className:"text-white",children:t("camera.invalidPrinterId")})})}function _tt(t){const e=t.get("show")?.split(",")||["progress","layers","eta","filename","status"],n=parseInt(t.get("fps")||"15",10),r=Math.min(Math.max(isNaN(n)?15:n,1),30),a=t.get("camera"),s=a!=="false"&&a!=="0";return{size:t.get("size")||"medium",fps:r,showCamera:s,showProgress:e.includes("progress"),showLayers:e.includes("layers"),showEta:e.includes("eta"),showFilename:e.includes("filename"),showStatus:e.includes("status"),showPrinter:e.includes("printer")}}function Ntt(t,e){if(t.stg_cur_name)return t.stg_cur_name;switch(t.state){case"RUNNING":return e("streamOverlay.status.printing");case"PAUSE":return e("streamOverlay.status.paused");case"FINISH":return e("streamOverlay.status.finished");case"FAILED":return e("streamOverlay.status.failed");case"IDLE":return e("streamOverlay.status.idle");default:return t.state||e("streamOverlay.status.unknown")}}function ktt(t){switch(t){case"small":return{container:"p-3",text:"text-sm",textLarge:"text-lg",progressHeight:"h-2",icon:"w-3 h-3",gap:"gap-2",logoHeight:"h-12"};case"large":return{container:"p-6",text:"text-xl",textLarge:"text-3xl",progressHeight:"h-4",icon:"w-6 h-6",gap:"gap-4",logoHeight:"h-24"};default:return{container:"p-4",text:"text-base",textLarge:"text-xl",progressHeight:"h-3",icon:"w-4 h-4",gap:"gap-3",logoHeight:"h-16"}}}function Ctt(){const{printerId:t}=hw(),[e]=jL(),{t:n}=Rt(),r=sn(),a=parseInt(t||"0",10),[s,o]=w.useState(Date.now()),l=w.useMemo(()=>_tt(e),[e]),c=ktt(l.size),{data:u}=tt({queryKey:["printer",a],queryFn:()=>fe.getPrinter(a),enabled:a>0}),{data:d}=tt({queryKey:["printerStatus",a],queryFn:()=>fe.getPrinterStatus(a),enabled:a>0,refetchInterval:2e3}),{data:m}=tt({queryKey:["settings"],queryFn:fe.getSettings}),p=m?.time_format||"system";w.useEffect(()=>{if(!a)return;const _=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,N=new WebSocket(_);return N.onmessage=T=>{try{const C=JSON.parse(T.data);C.type==="printer_status"&&C.printer_id===a&&r.setQueryData(["printerStatus",a],C.status)}catch{}},N.onerror=()=>{},()=>{N.close()}},[a,r]),w.useEffect(()=>(document.title=u?`${u.name} - ${n("streamOverlay.title")}`:n("streamOverlay.title"),()=>{document.title="Bambuddy"}),[u,n]);const f=()=>{setTimeout(()=>{o(Date.now())},3e3)};if(!a)return i.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:i.jsx("p",{className:"text-white",children:n("streamOverlay.invalidPrinterId")})});if(!d)return i.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:i.jsx("p",{className:"text-gray-400",children:n("common.loading")})});const y=d.state==="RUNNING"||d.state==="PAUSE",v=d.progress||0,b=`/api/v1/printers/${a}/camera/stream?fps=${l.fps}&t=${s}`;return i.jsxs("div",{className:"min-h-screen bg-black relative overflow-hidden",children:[l.showCamera&&i.jsx("img",{src:b,alt:n("streamOverlay.cameraStream"),className:"absolute inset-0 w-full h-full object-contain",style:u?.camera_rotation?{transform:`rotate(${u.camera_rotation}deg)`}:void 0,onError:f},s),i.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"absolute top-4 right-4 z-10",children:i.jsx("img",{src:"/img/bambuddy_logo_dark_transparent.png",alt:"Bambuddy",className:`${c.logoHeight} object-contain drop-shadow-lg hover:scale-105 transition-transform`})}),i.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-10 bg-gradient-to-t from-black/80 via-black/60 to-transparent",children:i.jsxs("div",{className:`${c.container}`,children:[l.showPrinter&&u&&i.jsxs("div",{className:`flex items-center ${c.gap} mb-2`,children:[i.jsx(_r,{className:`${c.icon} text-white/70`}),i.jsx("span",{className:`${c.text} text-white font-medium`,children:u.name})]}),l.showFilename&&d.current_print&&i.jsx("div",{className:`${c.textLarge} text-white font-semibold mb-2 truncate drop-shadow-md`,children:d.current_print.replace(/\.gcode\.3mf$|\.3mf$|\.gcode$/i,"")}),l.showStatus&&i.jsx("div",{className:`${c.text} text-white/70 mb-2`,children:Ntt(d,n)}),l.showProgress&&y&&i.jsxs("div",{className:"mb-3",children:[i.jsxs("div",{className:`flex items-center justify-between mb-1 ${c.text}`,children:[i.jsx("span",{className:"text-white/70",children:n("streamOverlay.progress")}),i.jsxs("span",{className:"text-white font-bold",children:[Math.round(v),"%"]})]}),i.jsx("div",{className:`w-full bg-white/20 rounded-full ${c.progressHeight}`,children:i.jsx("div",{className:`bg-bambu-green ${c.progressHeight} rounded-full transition-all duration-500`,style:{width:`${v}%`}})})]}),y&&(l.showLayers||l.showEta)&&i.jsxs("div",{className:`flex items-center ${c.gap} flex-wrap`,children:[l.showLayers&&d.layer_num!=null&&d.total_layers!=null&&d.total_layers>0&&i.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[i.jsx(Vi,{className:c.icon}),i.jsxs("span",{className:c.text,children:[i.jsx("span",{className:"text-white",children:d.layer_num}),i.jsx("span",{className:"mx-1",children:"/"}),i.jsx("span",{children:d.total_layers})]})]}),l.showEta&&d.remaining_time!=null&&d.remaining_time>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[i.jsx(yd,{className:c.icon}),i.jsx("span",{className:`${c.text} text-white`,children:Is(d.remaining_time*60)})]}),i.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[i.jsx(Jn,{className:c.icon}),i.jsxs("span",{className:`${c.text} text-white`,children:[n("streamOverlay.eta")," ",XL(d.remaining_time,p,n)]})]})]})]}),!y&&i.jsx("div",{className:`${c.text} text-white/70 py-2`,children:d.connected?n("streamOverlay.printerIdle"):n("streamOverlay.printerOffline")})]})})]})}function Ttt(){const{t}=Rt(),{id:e}=hw(),{mode:n}=Xf(),{data:r,isLoading:a,error:s}=tt({queryKey:["external-link",e],queryFn:()=>fe.getExternalLink(Number(e)),enabled:!!e});return a?i.jsx("div",{className:"flex items-center justify-center h-full",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s||!r?i.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[i.jsx(Mn,{className:"w-12 h-12"}),i.jsx("p",{children:t("common.linkNotFound")})]}):i.jsx("iframe",{src:r.url,className:"h-full w-full border-0",style:{colorScheme:n},title:r.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}function EY(){const{id:t}=hw(),e=al(),n=sn(),{t:r}=Rt(),{showToast:a}=fn(),s=!!t,[o,l]=w.useState(""),[c,u]=w.useState(""),[d,m]=w.useState([]),[p,f]=w.useState(""),[y,v]=w.useState(!1),{data:b,isLoading:g}=tt({queryKey:["group",t],queryFn:()=>fe.getGroup(Number(t)),enabled:s}),{data:_,isLoading:N}=tt({queryKey:["permissions"],queryFn:()=>fe.getPermissions()});s&&b&&!y&&(l(b.name),u(b.description||""),m(b.permissions),v(!0));const T=ft({mutationFn:Q=>fe.createGroup(Q),onSuccess:()=>{n.invalidateQueries({queryKey:["groups"]}),a(r("groups.toast.created")),e("/settings?tab=users")},onError:Q=>{a(Q.message,"error")}}),C=ft({mutationFn:Q=>fe.updateGroup(Number(t),Q),onSuccess:()=>{n.invalidateQueries({queryKey:["groups"]}),a(r("groups.toast.updated")),e("/settings?tab=users")},onError:Q=>{a(Q.message,"error")}}),P=T.isPending||C.isPending,k=()=>{if(!o.trim()){a(r("groups.toast.enterGroupName"),"error");return}s?C.mutate({name:o!==b?.name?o:void 0,description:c,permissions:d}):T.mutate({name:o,description:c||void 0,permissions:d})},R=Q=>{m(ue=>ue.includes(Q)?ue.filter(me=>me!==Q):[...ue,Q])},A=(Q,ue)=>{const me=Q.permissions.map(pe=>pe.value);m(pe=>{const Y=pe.filter(se=>!me.includes(se));return ue?[...Y,...me]:Y})},D=Q=>Q.permissions.every(ue=>d.includes(ue.value)),B=Q=>{const ue=Q.permissions.filter(me=>d.includes(me.value)).length;return ue>0&&ue{_&&m(_.all_permissions)},W=()=>{m([])},I=p.toLowerCase(),J=w.useMemo(()=>_?I?_.categories.map(Q=>({...Q,permissions:Q.permissions.filter(ue=>ue.label.toLowerCase().includes(I))})).filter(Q=>Q.permissions.length>0):_.categories:[],[_,I]),ie=_?.all_permissions.length??0;return g||N?i.jsx("div",{className:"flex items-center justify-center py-16",children:i.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("button",{onClick:()=>e("/settings?tab=users"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",children:i.jsx(IX,{className:"w-5 h-5"})}),i.jsx("h1",{className:"text-xl font-bold text-white",children:r(s?"groups.editor.title":"groups.editor.createTitle")})]}),s&&b?.is_system&&i.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-lg bg-yellow-500/10 border border-yellow-500/20 text-yellow-400 text-sm",children:[i.jsx(Mn,{className:"w-4 h-4 shrink-0"}),r("groups.form.systemGroupWarning")]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:r("groups.form.groupName")}),i.jsx("input",{type:"text",value:o,onChange:Q=>l(Q.target.value),disabled:s&&b?.is_system,className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors disabled:opacity-50",placeholder:r("groups.form.groupNamePlaceholder")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:r("groups.form.description")}),i.jsx("input",{type:"text",value:c,onChange:Q=>u(Q.target.value),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:r("groups.form.descriptionPlaceholder")})]})]}),i.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("span",{className:"text-sm text-bambu-gray",children:[r("groups.editor.permissionsSelected",{count:d.length})," / ",ie]}),i.jsx(Ie,{size:"sm",variant:"ghost",onClick:z,children:r("groups.editor.selectAll")}),i.jsx(Ie,{size:"sm",variant:"ghost",onClick:W,children:r("groups.editor.clearAll")})]}),i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray"}),i.jsx("input",{type:"text",value:p,onChange:Q=>f(Q.target.value),placeholder:r("groups.editor.search"),className:"pl-9 pr-4 py-2 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors w-64"})]})]}),J.length===0?i.jsx("div",{className:"text-center py-12 text-bambu-gray",children:r("groups.editor.noResults")}):i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:J.map(Q=>{const ue=_.categories.find(oe=>oe.name===Q.name),me=ue.permissions.filter(oe=>d.includes(oe.value)).length,pe=ue.permissions.length,Y=D(ue),se=B(ue);return i.jsxs(Pt,{children:[i.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between px-4 py-3 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary rounded-t-xl",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("button",{type:"button",onClick:()=>A(ue,!Y),className:`w-5 h-5 rounded border flex items-center justify-center transition-colors shrink-0 ${Y?"bg-bambu-green border-bambu-green":se?"bg-bambu-green/50 border-bambu-green":"border-bambu-gray hover:border-white"}`,children:[Y&&i.jsx(Qr,{className:"w-3 h-3 text-white"}),se&&!Y&&i.jsx(RN,{className:"w-3 h-3 text-white"})]}),i.jsx(S3,{className:"w-4 h-4 text-bambu-gray shrink-0"}),i.jsx("span",{className:"text-white font-medium text-sm",children:Q.name})]}),i.jsxs("span",{className:"text-xs text-bambu-gray tabular-nums",children:[me,"/",pe]})]}),i.jsx("div",{className:"p-3 space-y-1",children:Q.permissions.map(oe=>i.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-secondary cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:d.includes(oe.value),onChange:()=>R(oe.value),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark-secondary"}),i.jsx("span",{className:"text-sm text-bambu-gray",children:oe.label})]},oe.value))})]},Q.name)})}),i.jsx("div",{className:"h-16"}),i.jsxs("div",{className:"fixed bottom-0 left-0 right-0 z-20 px-6 py-3 bg-bambu-dark-secondary border-t border-bambu-dark-tertiary flex items-center justify-center gap-3",children:[i.jsx(Ie,{variant:"secondary",onClick:()=>e("/settings?tab=users"),children:r("common.cancel")}),i.jsx(Ie,{onClick:k,disabled:P||!o.trim(),children:P?i.jsxs(i.Fragment,{children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),r("common.saving")]}):i.jsxs(i.Fragment,{children:[i.jsx(ss,{className:"w-4 h-4"}),r("common.save")]})})]})]})}const jY={material:"",subtype:"",brand:"",color_name:"",rgba:"808080FF",label_weight:1e3,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:"",note:"",cost_per_kg:null};function Att(t,e=!1){const n={};return e?(t.material||(n.material="Material is required"),{isValid:Object.keys(n).length===0,errors:n}):(t.slicer_filament||(n.slicer_filament="Slicer preset is required"),t.material||(n.material="Material is required"),t.brand||(n.brand="Brand is required"),t.subtype||(n.subtype="Subtype is required"),{isValid:Object.keys(n).length===0,errors:n})}const Ptt=["PLA","PETG","ABS","TPU","ASA","PC","PA","PVA","HIPS","PA-CF","PETG-CF","PLA-CF"],Mtt=["Bambu","PolyLite","PolyTerra","eSUN","Overture","Fiberon","SUNLU","Inland","Hatchbox","Generic"],h0=["Basic","Matte","Silk","Tough","HF","High Flow","Engineering","Galaxy","Glow","Marble","Metal","Rainbow","Sparkle","Wood","Translucent","Transparent","Clear","Lite","Pro","Plus","Max","Super","Ultra","Flex","Soft","Hard","Strong","Impact","Heat Resistant","UV Resistant","ESD","Conductive","Magnetic","Gradient","Dual Color","Tri Color","Multicolor"],qoe=[{name:"Black",hex:"000000"},{name:"White",hex:"FFFFFF"},{name:"Gray",hex:"808080"},{name:"Red",hex:"FF0000"},{name:"Orange",hex:"FFA500"},{name:"Yellow",hex:"FFFF00"},{name:"Green",hex:"00AE42"},{name:"Blue",hex:"0066FF"},{name:"Purple",hex:"8B00FF"},{name:"Pink",hex:"FF69B4"},{name:"Brown",hex:"8B4513"},{name:"Silver",hex:"C0C0C0"}],Ett=[{name:"Dark Red",hex:"8B0000"},{name:"Crimson",hex:"DC143C"},{name:"Coral",hex:"FF7F50"},{name:"Salmon",hex:"FA8072"},{name:"Dark Orange",hex:"FF8C00"},{name:"Peach",hex:"FFDAB9"},{name:"Gold",hex:"FFD700"},{name:"Khaki",hex:"F0E68C"},{name:"Lemon",hex:"FFF44F"},{name:"Lime",hex:"32CD32"},{name:"Forest Green",hex:"228B22"},{name:"Olive",hex:"808000"},{name:"Mint",hex:"98FF98"},{name:"Teal",hex:"008080"},{name:"Navy",hex:"000080"},{name:"Sky Blue",hex:"87CEEB"},{name:"Royal Blue",hex:"4169E1"},{name:"Cyan",hex:"00FFFF"},{name:"Turquoise",hex:"40E0D0"},{name:"Violet",hex:"EE82EE"},{name:"Magenta",hex:"FF00FF"},{name:"Indigo",hex:"4B0082"},{name:"Lavender",hex:"E6E6FA"},{name:"Plum",hex:"DDA0DD"},{name:"Hot Pink",hex:"FF69B4"},{name:"Rose",hex:"FF007F"},{name:"Blush",hex:"FFB6C1"},{name:"Chocolate",hex:"D2691E"},{name:"Tan",hex:"D2B48C"},{name:"Beige",hex:"F5F5DC"},{name:"Maroon",hex:"800000"},{name:"Dark Gray",hex:"404040"},{name:"Light Gray",hex:"D3D3D3"},{name:"Charcoal",hex:"36454F"},{name:"Ivory",hex:"FFFFF0"},{name:"Bambu Green",hex:"00AE42"},{name:"Jade White",hex:"E8E8E8"},{name:"Titan Gray",hex:"5A5A5A"}],DY=[...qoe,...Ett],Voe="bambuddy-recent-colors",jtt=8,Dtt=[{code:"GFL00",name:"Bambu PLA Basic",displayName:"Bambu PLA Basic",isCustom:!1,allCodes:["GFL00"]},{code:"GFL01",name:"Bambu PLA Matte",displayName:"Bambu PLA Matte",isCustom:!1,allCodes:["GFL01"]},{code:"GFL05",name:"Generic PLA",displayName:"Generic PLA",isCustom:!1,allCodes:["GFL05"]},{code:"GFG00",name:"Bambu PETG Basic",displayName:"Bambu PETG Basic",isCustom:!1,allCodes:["GFG00"]},{code:"GFG05",name:"Generic PETG",displayName:"Generic PETG",isCustom:!1,allCodes:["GFG05"]},{code:"GFB00",name:"Bambu ABS Basic",displayName:"Bambu ABS Basic",isCustom:!1,allCodes:["GFB00"]},{code:"GFB05",name:"Generic ABS",displayName:"Generic ABS",isCustom:!1,allCodes:["GFB05"]},{code:"GFA00",name:"Bambu ASA Basic",displayName:"Bambu ASA Basic",isCustom:!1,allCodes:["GFA00"]},{code:"GFU00",name:"Bambu TPU 95A",displayName:"Bambu TPU 95A",isCustom:!1,allCodes:["GFU00"]},{code:"GFU05",name:"Generic TPU",displayName:"Generic TPU",isCustom:!1,allCodes:["GFU05"]},{code:"GFC00",name:"Bambu PC Basic",displayName:"Bambu PC Basic",isCustom:!1,allCodes:["GFC00"]},{code:"GFN00",name:"Bambu PA Basic",displayName:"Bambu PA Basic",isCustom:!1,allCodes:["GFN00"]},{code:"GFN05",name:"Generic PA",displayName:"Generic PA",isCustom:!1,allCodes:["GFN05"]},{code:"GFS00",name:"Bambu PLA-CF",displayName:"Bambu PLA-CF",isCustom:!1,allCodes:["GFS00"]},{code:"GFT00",name:"Bambu PETG-CF",displayName:"Bambu PETG-CF",isCustom:!1,allCodes:["GFT00"]},{code:"GFNC0",name:"Bambu PA-CF",displayName:"Bambu PA-CF",isCustom:!1,allCodes:["GFNC0"]},{code:"GFV00",name:"Bambu PVA",displayName:"Bambu PVA",isCustom:!1,allCodes:["GFV00"]}];function Dx(t){let e=t.replace(/@.*$/,"").trim();e=e.replace(/\(Custom\)/i,"").trim(),e=e.replace(/^[#*]+\s*/,"").trim();const n=["PLA-CF","PETG-CF","ABS-GF","ASA-CF","PA-CF","PAHT-CF","PA6-CF","PA6-GF","PPA-CF","PPA-GF","PET-CF","PPS-CF","PC-CF","PC-ABS","ABS-GF","PCTG","PETG","PLA","ABS","ASA","PC","PA","TPU","PVA","HIPS","BVOH","PPS","PEEK","PEI"];let r="",a=-1;for(const c of n){const u=e.toUpperCase().indexOf(c.toUpperCase());if(u!==-1){r=c,a=u;break}}let s="";a>0&&(s=e.substring(0,a).trim(),s=s.replace(/[-_\s]+$/,""));let o="";a!==-1&&r&&(o=e.substring(a+r.length).trim(),o=o.replace(/^[-_\s]+/,""));let l="";for(const c of h0)if(o.toLowerCase().includes(c.toLowerCase())){l=c;break}if(!l&&s)for(const c of h0){const u=new RegExp(`\\s+${c}$`,"i");if(u.test(s)){l=c,s=s.replace(u,"").trim();break}}return{brand:s,material:r,variant:l}}function Rtt(t,e){const n=new Set(Mtt);for(const r of t){const{brand:a}=Dx(r.name);a&&a.length>1&&n.add(a)}if(e)for(const r of e)if(r.filament_vendor&&r.filament_vendor.length>1)n.add(r.filament_vendor);else{const{brand:a}=Dx(r.name);a&&a.length>1&&n.add(a)}return Array.from(n).sort((r,a)=>r.localeCompare(a))}function Ftt(t){const e=t.filter(r=>r.preset_type==="filament");if(e.length===0)return[];const n=new Map;for(const r of e){const a=r.name.replace(/@.*$/,"").trim(),s=n.get(a);if(s)s.allCodes.push(String(r.id));else{const o=r.filament_type||String(r.id);n.set(a,{code:o,name:a,displayName:a,isCustom:!1,allCodes:[o]})}}return Array.from(n.values()).sort((r,a)=>r.displayName.localeCompare(a.displayName))}function Ltt(t,e,n){if(t.length>0){const r=[],a=new Map;for(const s of t)if(s.is_custom){const o=s.name.toUpperCase();(e.size===0||Array.from(e).some(c=>o.includes(c))||!o.includes("@"))&&r.push({code:s.setting_id,name:s.name,displayName:`${s.name} (Custom)`,isCustom:!0,allCodes:[s.setting_id]})}else{const o=s.name.replace(/@.*$/,"").trim(),l=a.get(o);l?l.allCodes.push(s.setting_id):a.set(o,{code:s.setting_id,name:o,displayName:o,isCustom:!1,allCodes:[s.setting_id]})}return[...r,...Array.from(a.values())].sort((s,o)=>s.displayName.localeCompare(o.displayName))}if(n&&n.length>0){const r=Ftt(n);if(r.length>0)return r}return Dtt}function Ott(t,e){if(!t)return;let n=e.find(r=>r.code===t);if(n||(n=e.find(r=>r.allCodes.includes(t))),!n){const r=t.toLowerCase();n=e.find(a=>a.code.toLowerCase()===r||a.allCodes.some(s=>s.toLowerCase()===r))}return n}function Itt(){try{const t=localStorage.getItem(Voe);if(t)return JSON.parse(t)}catch{}return[]}function ztt(t,e){const n=e.filter(a=>a.hex.toUpperCase()!==t.hex.toUpperCase()),r=[t,...n].slice(0,jtt);try{localStorage.setItem(Voe,JSON.stringify(r))}catch{}return r}function KD(t,e){if(!e.material)return!1;const r=(t.name||"").replace(/^High Flow[_\s]+/i,"").replace(/^Standard[_\s]+/i,"").replace(/^HF[_\s]+/i,"").replace(/^S[_\s]+/i,"").trim(),a=Dx(r);return!(!(a.material.toUpperCase()===e.material.toUpperCase())||e.brand&&!(a.brand.toLowerCase().includes(e.brand.toLowerCase())||e.brand.toLowerCase().includes(a.brand.toLowerCase()))||e.subtype&&!(a.variant.toLowerCase().includes(e.subtype.toLowerCase())||e.subtype.toLowerCase().includes(a.variant.toLowerCase())||r.toLowerCase().includes(e.subtype.toLowerCase())))}function Utt({formData:t,updateField:e,cloudAuthenticated:n,loadingCloudPresets:r,presetInputValue:a,setPresetInputValue:s,selectedPresetOption:o,filamentOptions:l,availableBrands:c,availableMaterials:u,quickAdd:d,quantity:m,onQuantityChange:p,errors:f}){const{t:y}=Rt(),[v,b]=w.useState(!1),[g,_]=w.useState(!1),[N,T]=w.useState(!1),[C,P]=w.useState(!1),[k,R]=w.useState(""),[A,D]=w.useState(""),[B,z]=w.useState(""),[W,I]=w.useState(String(t.label_weight)),[J,ie]=w.useState(!1),Q=w.useRef(null),ue=w.useRef(null),me=w.useRef(null),pe=w.useRef(null);w.useEffect(()=>{const q=Z=>{Q.current&&!Q.current.contains(Z.target)&&b(!1),pe.current&&!pe.current.contains(Z.target)&&P(!1),ue.current&&!ue.current.contains(Z.target)&&_(!1),me.current&&!me.current.contains(Z.target)&&T(!1)};return document.addEventListener("mousedown",q),()=>document.removeEventListener("mousedown",q)},[]);const Y=w.useMemo(()=>{if(!a)return l;const q=a.toLowerCase();return l.filter(Z=>Z.displayName.toLowerCase().includes(q)||Z.code.toLowerCase().includes(q))},[l,a]),se=w.useMemo(()=>{if(!k)return c;const q=k.toLowerCase();return c.filter(j=>j.toLowerCase().includes(q)).sort((j,E)=>{const U=j.toLowerCase()===q,K=E.toLowerCase()===q;return U&&!K?-1:!U&&K?1:j.localeCompare(E)})},[c,k]),oe=w.useMemo(()=>{if(!A)return h0;const q=A.toLowerCase();return h0.filter(Z=>Z.toLowerCase().includes(q))},[A]),be=w.useMemo(()=>{if(!B)return u;const q=B.toLowerCase();return u.filter(j=>j.toLowerCase().includes(q)).sort((j,E)=>{const U=j.toLowerCase()===q,K=E.toLowerCase()===q;return U&&!K?-1:!U&&K?1:j.localeCompare(E)})},[B,u]);w.useEffect(()=>{J||I(String(t.label_weight))},[t.label_weight,J]);const Me=q=>{e("slicer_filament",q.code),s(q.displayName),b(!1);const Z=Dx(q.name);Z.material&&e("material",Z.material),Z.brand&&e("brand",Z.brand),Z.variant&&e("subtype",Z.variant)};return i.jsxs("div",{className:"space-y-4",children:[!d&&i.jsx("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:r?i.jsxs(i.Fragment,{children:[i.jsx(pt,{className:"w-3 h-3 animate-spin"})," ",y("inventory.loadingPresets")]}):n?i.jsxs(i.Fragment,{children:[i.jsx(Ox,{className:"w-3 h-3 text-bambu-green"})," ",y("inventory.cloudConnected")]}):i.jsxs(i.Fragment,{children:[i.jsx(spe,{className:"w-3 h-3"})," ",y("inventory.cloudNotConnected")]})}),!d&&i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[y("inventory.slicerPreset")," *"]}),i.jsxs("div",{className:"relative",ref:Q,children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),i.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:y("inventory.searchPresets"),value:a,onChange:q=>{s(q.target.value),b(!0)},onFocus:()=>{b(!0),s("")}}),v&&i.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:Y.length===0?i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:y("inventory.noPresetsFound")}):Y.map(q=>i.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary truncate ${o?.code===q.code?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>Me(q),children:q.displayName},q.code))})]}),o&&i.jsxs("div",{className:"mt-1 text-xs text-bambu-gray",children:[y("inventory.selectedPreset"),": ",i.jsx("span",{className:"font-mono text-bambu-green",children:o.code})]}),f?.slicer_filament&&i.jsx("p",{className:"mt-1 text-xs text-red-400",children:f.slicer_filament})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[y("inventory.material")," *"]}),i.jsxs("div",{className:"relative",ref:pe,children:[i.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:y("inventory.selectMaterial"),value:C?B:t.material,onChange:q=>{z(q.target.value),P(!0)},onFocus:()=>{P(!0),z("")}}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),C&&i.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:[be.length===0?i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:y("inventory.noResults")}):be.map(q=>i.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.material===q?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("material",q),P(!1),z("")},children:q},q)),B&&!be.includes(B)&&i.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:()=>{e("material",B),P(!1),z("")},children:y("inventory.useCustomMaterial",{material:B})})]})]}),f?.material&&i.jsx("p",{className:"mt-1 text-xs text-red-400",children:f.material})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[y("inventory.brand"),!d&&" *"]}),i.jsxs("div",{className:"relative",ref:ue,children:[i.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:y("inventory.searchBrand"),value:g?k:t.brand,onChange:q=>{R(q.target.value),_(!0)},onFocus:()=>{_(!0),R("")}}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),g&&i.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:[se.length===0?i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:y("inventory.noResults")}):se.map(q=>i.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.brand===q?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("brand",q),_(!1),R("")},children:q},q)),k&&!se.includes(k)&&i.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:()=>{e("brand",k),_(!1),R("")},children:y("inventory.useCustomBrand",{brand:k})})]})]}),f?.brand&&i.jsx("p",{className:"mt-1 text-xs text-red-400",children:f.brand})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[y("inventory.subtype"),!d&&" *"]}),i.jsxs("div",{className:"relative",ref:me,children:[i.jsx("input",{type:"text",value:N?A:t.subtype,onChange:q=>{D(q.target.value),T(!0)},onFocus:()=>{T(!0),D("")},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"}),i.jsx(On,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),N&&i.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:[oe.length===0?i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:y("inventory.noResults")}):oe.map(q=>i.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.subtype===q?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("subtype",q),T(!1),D("")},children:q},q)),A&&!h0.some(q=>q.toLowerCase()===A.toLowerCase().trim())&&i.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:()=>{e("subtype",A),T(!1),D("")},children:y("inventory.useCustomBrand",{brand:A})})]})]}),f?.subtype&&i.jsx("p",{className:"mt-1 text-xs text-red-400",children:f.subtype})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:y("inventory.labelWeight")}),i.jsxs("div",{className:"relative",children:[i.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:W,min:0,onFocus:()=>ie(!0),onChange:q=>I(q.target.value),onBlur:()=>{ie(!1);const q=W.trim(),Z=Number(q);if(!q||!Number.isFinite(Z)||Z<0){I(String(t.label_weight));return}const j=Math.round(Z);e("label_weight",j),I(String(j))}}),i.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]})]}),d&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:y("inventory.quantity")}),i.jsx("input",{type:"number",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:m,min:1,max:100,onChange:q=>{const Z=Math.max(1,Math.min(100,parseInt(q.target.value)||1));p(Z)}})]})]})}function Btt({formData:t,updateField:e,recentColors:n,onColorUsed:r,catalogColors:a}){const{t:s}=Rt(),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=t.rgba.replace("#","").substring(0,6),m=g=>d.toUpperCase()===g.toUpperCase(),p=(g,_)=>{e("rgba",g.toUpperCase()+"FF"),e("color_name",_),r({name:_,hex:g})},f=w.useMemo(()=>{if(a.length===0)return[];const g=t.brand?.trim(),_=t.material?.toLowerCase().trim(),N=t.subtype?.toLowerCase().trim();if(!g&&!_)return[];const T=g?g.toLowerCase().split(/[\s\-_]+/).filter(k=>k.length>=2):[],C=k=>{if(T.length===0)return!0;const R=k.toLowerCase();return T.some(A=>R.includes(A))};if(g&&!_){const k=a.filter(R=>C(R.manufacturer));if(k.length>0)return k.map(R=>({name:R.color_name,hex:R.hex_color.replace("#","").substring(0,6),manufacturer:R.manufacturer,material:typeof R.material=="string"?R.material:void 0}))}const P=_&&N?`${_} ${N}`:"";if(P){const k=a.filter(A=>C(A.manufacturer)&&A.material?.toLowerCase()===P);if(k.length>0)return k.map(A=>({name:A.color_name,hex:A.hex_color.replace("#","").substring(0,6),manufacturer:A.manufacturer,material:typeof A.material=="string"?A.material:void 0}));const R=P.replace(/\+$/,"");if(R!==P){const A=a.filter(D=>C(D.manufacturer)&&D.material?.toLowerCase()===R);if(A.length>0)return A.map(D=>({name:D.color_name,hex:D.hex_color.replace("#","").substring(0,6),manufacturer:D.manufacturer,material:typeof D.material=="string"?D.material:void 0}))}}if(_){const k=a.filter(R=>C(R.manufacturer)&&(!R.material||R.material.toLowerCase().startsWith(_)));if(k.length>0)return k.map(R=>({name:R.color_name,hex:R.hex_color.replace("#","").substring(0,6),manufacturer:R.manufacturer,material:typeof R.material=="string"?R.material:void 0}))}return[]},[a,t.brand,t.material,t.subtype]),y=w.useMemo(()=>{if(!c)return f;if(f.length===0)return[];const g=c.toLowerCase();return f.filter(N=>N.name.toLowerCase().includes(g)||(N.manufacturer?.toLowerCase().includes(g)??!1)||(N.material?.toLowerCase().includes(g)??!1))},[c,f]),v=f.length>0,b=w.useMemo(()=>c?DY.filter(g=>g.name.toLowerCase().includes(c.toLowerCase())):o?DY:qoe,[c,o]);return i.jsxs("div",{className:"space-y-3",children:[i.jsx("div",{className:"h-10 rounded-lg border border-bambu-dark-tertiary",style:{backgroundColor:`#${d}`}}),n.length>0&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-bambu-gray shrink-0",children:[i.jsx(Jn,{className:"w-3 h-3"}),i.jsx("span",{children:s("inventory.recentColors")})]}),i.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.map(g=>i.jsx("button",{type:"button",onClick:()=>p(g.hex,g.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 ${m(g.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${g.hex}`},title:g.name},g.hex))})]}),i.jsxs("div",{className:"relative",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),i.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:s("inventory.searchColors"),value:c,onChange:g=>u(g.target.value)})]}),v?i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("span",{className:"text-xs text-bambu-gray",children:c?s("inventory.searchResults"):`${t.brand}${t.material?` ${t.material}`:""}`}),i.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[y.map(g=>i.jsx("button",{type:"button",onClick:()=>p(g.hex,g.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${m(g.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${g.hex}`},title:g.manufacturer&&g.material?`${g.name} (${g.manufacturer} — ${g.material})`:g.manufacturer?`${g.name} (${g.manufacturer})`:g.name,children:i.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:g.manufacturer&&g.material?`${g.name} (${g.manufacturer} — ${g.material})`:g.manufacturer?`${g.name} (${g.manufacturer})`:g.name})},`${g.hex}-${g.name}-${g.manufacturer??""}`)),y.length===0&&i.jsx("p",{className:"text-sm text-bambu-gray py-1",children:s("inventory.noColorsFound")})]})]}):i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray",children:[i.jsx("span",{children:s(c?"inventory.searchResults":o?"inventory.allColors":"inventory.commonColors")}),!c&&i.jsx("button",{type:"button",onClick:()=>l(!o),className:"flex items-center gap-1 hover:text-white transition-colors",children:o?i.jsxs(i.Fragment,{children:[s("inventory.showLess")," ",i.jsx($l,{className:"w-3 h-3"})]}):i.jsxs(i.Fragment,{children:[s("inventory.showAll")," ",i.jsx(On,{className:"w-3 h-3"})]})})]}),i.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[b.map(g=>i.jsx("button",{type:"button",onClick:()=>p(g.hex,g.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${m(g.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${g.hex}`},title:g.name,children:i.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:g.name})},g.hex)),b.length===0&&i.jsx("p",{className:"text-sm text-bambu-gray py-1",children:s("inventory.noColorsFound")})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:s("inventory.colorName")}),i.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:s("inventory.colorNamePlaceholder"),value:t.color_name,onChange:g=>e("color_name",g.target.value)})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:s("inventory.hexColor")}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray",children:"#"}),i.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:d.toUpperCase(),onChange:g=>{const _=g.target.value.replace("#","").replace(/[^0-9A-Fa-f]/g,"");_.length<=8&&e("rgba",_.toUpperCase()+(_.length<=6?"FF":""))}})]}),i.jsx("input",{type:"color",className:"w-11 h-[38px] rounded-lg cursor-pointer border border-bambu-dark-tertiary shrink-0 bg-transparent",value:`#${d}`,onChange:g=>{const _=g.target.value.replace("#","").toUpperCase();e("rgba",_+"FF")},title:s("inventory.pickColor")})]})]})]})]})}function Htt({catalog:t,value:e,onChange:n,catalogId:r,onCatalogIdChange:a}){const{t:s}=Rt(),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=w.useRef(null),m=w.useRef(null);w.useEffect(()=>{const v=b=>{d.current&&!d.current.contains(b.target)&&l(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]),w.useEffect(()=>{if(t.length===0)return;const v=t.filter(b=>b.weight===e);if(r){const b=t.find(g=>g.id===r);if(b&&b.weight===e)return}v.length===1?a(v[0].id):v.length===0&&r!==null&&a(null)},[e,t,r,a]);const p=w.useMemo(()=>{if(!c)return t;const v=c.toLowerCase();return t.filter(b=>b.name.toLowerCase().includes(v)||b.weight.toString().includes(v))},[t,c]),f=w.useMemo(()=>t.filter(v=>v.weight===e),[t,e]),y=w.useMemo(()=>{if(o)return c;if(r){const v=t.find(b=>b.id===r);if(v)return v.name}return f.length>0?f[0].name:""},[o,c,r,t,f]);return i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(Mge,{className:"w-3.5 h-3.5 text-bambu-gray"}),s("inventory.coreWeight")]})}),i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsxs("div",{className:"flex-1 min-w-0 relative",ref:d,children:[i.jsx("input",{ref:m,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:s("inventory.searchSpoolWeight"),value:y,onFocus:()=>{l(!0),u("")},onChange:v=>{u(v.target.value),l(!0)}}),o&&i.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:p.length===0?i.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:s("inventory.noResults")}):p.map(v=>i.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 ${(r?v.id===r:v.weight===e)?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{a(v.id),n(v.weight),l(!1),u("")},children:[i.jsx("span",{className:"truncate",children:v.name}),i.jsxs("span",{className:"font-mono text-xs text-bambu-gray ml-2 shrink-0",children:[v.weight,"g"]})]},v.id))})]}),i.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[i.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:e,min:0,max:2e3,onChange:v=>{const b=parseInt(v.target.value);!isNaN(b)&&b>=0&&n(b)}}),i.jsx("span",{className:"text-bambu-gray text-sm",children:"g"})]})]})]})}function $tt({formData:t,updateField:e,spoolCatalog:n,currencySymbol:r}){const{t:a}=Rt(),{showToast:s}=fn(),[o,l]=w.useState(""),[c,u]=w.useState(!1),[d,m]=w.useState(""),[p,f]=w.useState(!1),y=Math.max(0,t.label_weight-t.weight_used),v=t.core_weight+y;return w.useEffect(()=>{c||l(String(v))},[c,v]),w.useEffect(()=>{p||m(String(y))},[p,y]),i.jsxs("div",{className:"space-y-4",children:[i.jsx(Htt,{catalog:n,value:t.core_weight,onChange:b=>e("core_weight",b),catalogId:t.core_weight_catalog_id,onCatalogIdChange:b=>e("core_weight_catalog_id",b)}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:a("inventory.currentWeight")}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx("input",{type:"number",value:d,min:0,max:t.label_weight,onFocus:()=>f(!0),onChange:b=>{m(b.target.value)},onBlur:()=>{f(!1);const b=d.trim(),g=Number(b);if(!b||!Number.isFinite(g)||g<0||g>t.label_weight){m(String(y));return}const _=Math.round(g);e("weight_used",Math.max(0,t.label_weight-_)),m(String(_))},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"}),i.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]}),i.jsxs("span",{className:"text-xs text-bambu-gray shrink-0",children:["/ ",t.label_weight,"g"]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:a("inventory.measuredWeight")}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx("input",{type:"number",value:o,min:0,onFocus:()=>u(!0),onChange:b=>{l(b.target.value)},onBlur:()=>{u(!1);const b=o.trim(),g=Number(b),_=t.core_weight,N=t.core_weight+t.label_weight;if(!b||!Number.isFinite(g)||g<_||g>N){s(a("inventory.measuredWeightError",{min:_,max:N}),"error"),l(String(v));return}const T=Math.round(g),C=Math.max(0,Math.min(t.label_weight,T-t.core_weight));e("weight_used",Math.max(0,t.label_weight-C)),l(String(T))},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"}),i.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]}),i.jsxs("span",{className:"text-xs text-bambu-gray shrink-0",children:["/ ",t.core_weight+t.label_weight,"g"]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:a("inventory.costPerKg","Cost per kg")}),i.jsx("div",{className:"flex items-center gap-2",children:i.jsxs("div",{className:"relative flex-1",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none",children:r}),i.jsx("input",{type:"number",value:t.cost_per_kg??"",min:0,step:.01,placeholder:"0.00",onChange:b=>{const g=b.target.value===""?null:parseFloat(b.target.value);e("cost_per_kg",g)},style:{paddingLeft:`${Math.max(2,r.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"})]})})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:a("inventory.note")}),i.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:a("inventory.notePlaceholder"),value:t.note,onChange:b=>e("note",b.target.value)})]})]})}function qtt({formData:t,printersWithCalibrations:e,selectedProfiles:n,setSelectedProfiles:r,expandedPrinters:a,setExpandedPrinters:s}){const{t:o}=Rt(),l=p=>{s(f=>{const y=new Set(f);return y.has(p)?y.delete(p):y.add(p),y})},c=(p,f,y)=>{const v=`${p}:${f}:${y??"null"}`,b=`${p}:${y??"null"}`;r(g=>{const _=new Set(g);if(_.has(v))_.delete(v);else{for(const N of Array.from(_)){const T=N.split(":");`${T[0]}:${T[2]}`===b&&_.delete(N)}_.add(v)}return _})},u=()=>{const p=new Set;for(const{printer:f,calibrations:y}of e){if(!f.connected)continue;const v=y.filter(g=>KD(g,t)),b=new Map;for(const g of v){const _=`${g.extruder_id??"null"}`;b.has(_)||b.set(_,[]),b.get(_).push(g)}for(const[g,_]of b)if(_.length>0){const T=[..._].sort((C,P)=>P.k_value-C.k_value)[0];p.add(`${f.id}:${T.cali_idx}:${g}`)}}r(p)};if(!t.material)return i.jsx("div",{className:"p-6 bg-bambu-dark rounded-lg text-center",children:i.jsx("p",{className:"text-bambu-gray",children:o("inventory.selectMaterialFirst")})});if(e.length===0)return i.jsx("div",{className:"p-6 bg-bambu-dark rounded-lg text-center",children:i.jsx("p",{className:"text-bambu-gray",children:o("inventory.noPrintersConfigured")})});const d=e.reduce((p,{printer:f,calibrations:y})=>f.connected?p+y.filter(v=>KD(v,t)).length:p,0),m=(p,f)=>{const y=`${p.id}:${f.cali_idx}:${f.extruder_id??"null"}`,v=n.has(y);return i.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-all border ${v?"bg-bambu-green/10 border-bambu-green/30":"bg-bambu-dark border-transparent hover:bg-bambu-dark/80"}`,children:[i.jsx("input",{type:"checkbox",checked:v,onChange:()=>c(String(p.id),f.cali_idx,f.extruder_id),className:"w-4 h-4 rounded border-bambu-dark-tertiary text-bambu-green focus:ring-bambu-green"}),i.jsx("div",{className:"flex-1 min-w-0",children:i.jsx("span",{className:`text-sm font-medium ${v?"text-bambu-green":"text-white"}`,children:f.name||f.filament_id})}),i.jsx("div",{className:"flex items-center gap-2 shrink-0",children:i.jsxs("span",{className:"text-xs font-mono px-2 py-0.5 rounded bg-bambu-dark text-bambu-gray",children:["K=",f.k_value.toFixed(3)]})})]},`${f.cali_idx}-${f.extruder_id}`)};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("p",{className:"text-xs text-bambu-gray",children:[o("inventory.matchingFilter"),": ",t.brand||o("inventory.anyBrand")," / ",t.material," / ",t.subtype||o("inventory.anyVariant")]}),d>0&&i.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-1.5 px-2 py-1 text-xs bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white hover:border-bambu-green transition-colors",children:[i.jsx(ox,{className:"w-3.5 h-3.5"}),o("inventory.autoSelect")," (",d,")"]})]}),i.jsx("div",{className:"space-y-3",children:e.map(({printer:p,calibrations:f})=>{const y=a.has(String(p.id)),v=f.filter(T=>KD(T,t)),b=v.length,g=v.some(T=>T.extruder_id!==void 0&&T.extruder_id!==null&&T.extruder_id>0),_=v.filter(T=>T.extruder_id===1),N=v.filter(T=>T.extruder_id===0||T.extruder_id===void 0||T.extruder_id===null);return i.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[i.jsxs("button",{type:"button",onClick:()=>l(String(p.id)),className:"w-full px-4 py-3 flex items-center justify-between bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary transition-colors",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[y?i.jsx(On,{className:"w-4 h-4 text-bambu-gray"}):i.jsx(fa,{className:"w-4 h-4 text-bambu-gray"}),i.jsx("span",{className:"font-medium text-white",children:p.name}),b>0?i.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:[b," ",o(b!==1?"inventory.matches":"inventory.match")]}):i.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray",children:o("inventory.noMatches")})]}),i.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${p.connected?"bg-green-500/20 text-green-500":"bg-bambu-gray/20 text-bambu-gray"}`,children:p.connected?o("inventory.connected"):o("inventory.offline")})]}),y&&i.jsx("div",{className:"px-4 py-3 space-y-3 bg-bambu-dark border-t border-bambu-dark-tertiary",children:p.connected?b===0?i.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:o("inventory.noKProfilesMatch")}):g?i.jsxs(i.Fragment,{children:[_.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wide",children:o("inventory.leftNozzle")}),i.jsx("div",{className:"space-y-2",children:_.map(T=>m(p,T))})]}),N.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wide",children:o("inventory.rightNozzle")}),i.jsx("div",{className:"space-y-2",children:N.map(T=>m(p,T))})]})]}):i.jsx("div",{className:"space-y-2",children:v.map(T=>m(p,T))}):i.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:o("inventory.printerOffline")})})]},p.id)})}),n.size>0&&i.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:i.jsxs("p",{className:"text-sm text-white",children:[i.jsx("span",{className:"font-semibold",children:n.size})," ",o("inventory.profilesSelected")]})})]})}function Vtt(t){const e=new Date(t);return e.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"})+" "+e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})}const Gtt={completed:"text-bambu-green",failed:"text-red-400",aborted:"text-yellow-400"};function Wtt({spoolId:t}){const{t:e}=Rt(),n=sn(),{showToast:r}=fn(),{data:a,isLoading:s}=tt({queryKey:["spool-usage",t],queryFn:()=>fe.getSpoolUsageHistory(t)}),o=ft({mutationFn:()=>fe.clearSpoolUsageHistory(t),onSuccess:()=>{n.invalidateQueries({queryKey:["spool-usage",t]}),r(e("inventory.historyCleared"),"success")}});return s?i.jsx("div",{className:"flex justify-center py-4",children:i.jsx(pt,{className:"w-5 h-5 animate-spin text-bambu-green"})}):!a||a.length===0?i.jsxs("div",{className:"text-center py-4 text-bambu-gray text-sm",children:[i.jsx(Jn,{className:"w-5 h-5 mx-auto mb-2 opacity-50"}),e("inventory.noUsageHistory")]}):i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h4",{className:"text-sm font-medium text-white",children:e("inventory.usageHistory")}),i.jsxs(Ie,{variant:"ghost",size:"sm",onClick:()=>o.mutate(),disabled:o.isPending,className:"text-xs text-bambu-gray hover:text-red-400",children:[i.jsx(en,{className:"w-3 h-3 mr-1"}),e("inventory.clearHistory")]})]}),i.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:a.map(l=>i.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-bambu-dark/50 text-xs",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("span",{className:"text-bambu-gray",children:Vtt(l.created_at)}),l.print_name&&i.jsx("span",{className:"text-white ml-2 truncate",title:l.print_name,children:l.print_name})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-2",children:[i.jsxs("span",{className:"text-white font-medium",children:[l.weight_used.toFixed(1),"g"]}),i.jsxs("span",{className:"text-bambu-gray",children:["(",l.percent_used,"%)"]}),i.jsx("span",{className:Gtt[l.status]||"text-bambu-gray",children:l.status})]})]},l.id))})]})}function Ktt({isOpen:t,onClose:e,spool:n,printersWithCalibrations:r=[],currencySymbol:a}){const{t:s}=Rt(),o=sn(),{showToast:l}=fn(),c=!!n,[u,d]=w.useState(jY),[m,p]=w.useState({}),[f,y]=w.useState("filament"),[v,b]=w.useState(!1),[g,_]=w.useState(!1),[N,T]=w.useState(1),[C,P]=w.useState(!1),[k,R]=w.useState(!1),[A,D]=w.useState([]),[B,z]=w.useState(""),[W,I]=w.useState([]),[J,ie]=w.useState([]),[Q,ue]=w.useState([]),[me,pe]=w.useState([]),[Y,se]=w.useState([]),[oe,be]=w.useState(new Set),[Me,q]=w.useState(new Set),Z=r.length>0?r:Y,j=w.useMemo(()=>oe.size,[oe]);w.useEffect(()=>{pe(Itt())},[]),w.useEffect(()=>{t&&((async()=>{R(!0);try{const de=await fe.getCloudStatus();if(P(de.is_authenticated),de.is_authenticated){const ke=await fe.getFilamentPresets();D(ke)}}catch(de){console.error("Failed to fetch cloud presets:",de),P(!1)}finally{R(!1)}})(),fe.getSpoolCatalog().then(I).catch(console.error),fe.getColorCatalog().then(ue).catch(console.error),fe.getLocalPresets().then(de=>ie(de.filament)).catch(console.error),r.length===0&&(async()=>{try{const de=await fe.getPrinters(),ke=await Promise.all(de.map(Le=>fe.getPrinterStatus(Le.id).catch(()=>null))),_e=[];for(let Le=0;Le({cali_idx:je.slot_id,filament_id:je.filament_id,setting_id:je.setting_id||"",name:je.name,k_value:parseFloat(je.k_value)||0,n_coef:parseFloat(je.n_coef)||0,extruder_id:je.extruder_id,nozzle_diameter:je.nozzle_diameter}))}catch{}_e.push({printer:{...$e,connected:Ae},calibrations:Pe})}se(_e)}catch(de){console.error("Failed to fetch printer calibrations:",de)}})())},[t,r.length]);const E=w.useMemo(()=>Ltt(A,new Set,J),[A,J]),U=w.useMemo(()=>{const he=Rtt(A,J),de=Q.map(_e=>_e.manufacturer?.trim()).filter(_e=>!!_e),ke=new Set([...he,...de]);return Array.from(ke).sort((_e,Le)=>_e.localeCompare(Le))},[A,J,Q]),K=w.useMemo(()=>{const he=Q.map(ke=>ke.material?.trim()).filter(ke=>!!ke),de=new Set([...Ptt,...he]);return Array.from(de).sort((ke,_e)=>ke.localeCompare(_e))},[Q]),$=w.useMemo(()=>{const he=[];for(const de of Q){const ke=de.manufacturer?.trim(),_e=de.material?.trim();ke&&_e&&he.push({brand:ke,material:_e})}for(const de of A){const ke=Dx(de.name);ke.brand&&ke.material&&he.push({brand:ke.brand,material:ke.material})}for(const de of J){const ke=Dx(de.name),_e=de.filament_vendor?.trim()||ke.brand,Le=ke.material;_e&&Le&&he.push({brand:_e,material:Le})}return he},[A,Q,J]),ne=w.useMemo(()=>{const he=new Map;for(const de of $){const ke=de.brand.toLowerCase(),_e=de.material.toLowerCase();he.has(ke)||he.set(ke,new Set),he.get(ke).add(_e)}return he},[$]),O=w.useMemo(()=>{const he=new Map;for(const de of $){const ke=de.brand.toLowerCase(),_e=de.material.toLowerCase();he.has(_e)||he.set(_e,new Set),he.get(_e).add(ke)}return he},[$]),V=w.useMemo(()=>{if(!u.material)return U;const he=u.material.toLowerCase(),de=O.get(he);return!de||de.size===0?U:U.filter(ke=>de.has(ke.toLowerCase()))},[U,u.material,O]),ee=w.useMemo(()=>{if(!u.brand)return K;const he=u.brand.toLowerCase(),de=ne.get(he);return!de||de.size===0?K:K.filter(ke=>de.has(ke.toLowerCase()))},[K,u.brand,ne]),G=w.useMemo(()=>Ott(u.slicer_filament,E),[u.slicer_filament,E]);w.useEffect(()=>{if(t){if(n)if(d({material:n.material||"",subtype:n.subtype||"",brand:n.brand||"",color_name:n.color_name||"",rgba:n.rgba||"808080FF",label_weight:n.label_weight||1e3,core_weight:n.core_weight||250,core_weight_catalog_id:n.core_weight_catalog_id??null,weight_used:n.weight_used||0,slicer_filament:n.slicer_filament||"",note:n.note||"",cost_per_kg:n.cost_per_kg??null}),z(n.slicer_filament_name||n.slicer_filament||""),n.k_profiles&&n.k_profiles.length>0){const he=new Set;for(const de of n.k_profiles)de.cali_idx!==null&&de.cali_idx!==void 0&&he.add(`${de.printer_id}:${de.cali_idx}:${de.extruder??"null"}`);be(he)}else be(new Set);else d(jY),z(""),be(new Set),_(!1),T(1);p({}),y("filament"),b(!1)}},[t,n]),w.useEffect(()=>{t&&Z.length>0&&q(new Set(Z.map(he=>String(he.printer.id))))},[t,Z]);const re=(he,de)=>{d(ke=>({...ke,[he]:de})),he==="weight_used"&&b(!0),m[he]&&p(ke=>({...ke,[he]:void 0}))},ce=he=>{pe(de=>ztt(he,de))},ge=ft({mutationFn:he=>fe.createSpool(he),onSuccess:async he=>{oe.size>0&&he?.id&&await F(he.id),await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolCreated"),"success"),e()},onError:he=>{l(he.message,"error")}}),xe=ft({mutationFn:({data:he,qty:de})=>fe.bulkCreateSpools(he,de),onSuccess:async he=>{if(oe.size>0)for(const de of he)await F(de.id);await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolsCreated",{count:he.length}),"success"),e()},onError:he=>{l(he.message,"error")}}),ae=ft({mutationFn:he=>fe.updateSpool(n.id,he),onSuccess:async()=>{n?.id&&await F(n.id),await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolUpdated"),"success"),e()},onError:he=>{l(he.message,"error")}}),L=ft({mutationFn:()=>fe.updateSpool(n.id,{tag_uid:null}),onSuccess:async()=>{await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.tagDeleted","Tag removed"),"success"),e()},onError:he=>{l(he.message,"error")}}),F=async he=>{if(oe.size===0){try{await fe.saveSpoolKProfiles(he,[])}catch{}return}const de=[];for(const ke of oe){const[_e,Le,$e]=ke.split(":"),Re=parseInt(_e),Ae=parseInt(Le),Pe=$e==="null"?0:parseInt($e),Ue=Z.find(je=>je.printer.id===Re);if(Ue){const je=Ue.calibrations.find(Xe=>Xe.cali_idx===Ae);je&&de.push({printer_id:Re,extruder:Pe,nozzle_diameter:je.nozzle_diameter||"0.4",k_value:je.k_value,name:je.name||null,cali_idx:je.cali_idx,setting_id:je.setting_id||null})}}if(de.length>0)try{await fe.saveSpoolKProfiles(he,de)}catch(ke){console.error("Failed to save K-profiles:",ke)}};if(w.useEffect(()=>{if(!t)return;const he=de=>{de.key==="Escape"&&e()};return document.addEventListener("keydown",he),()=>document.removeEventListener("keydown",he)},[t,e]),!t)return null;const te=()=>{const he=Att(u,g);if(!he.isValid){p(he.errors),(he.errors.slicer_filament||he.errors.material||he.errors.brand||he.errors.subtype)&&y("filament");return}const de=G?.displayName||B||null,ke={material:u.material,subtype:u.subtype||null,brand:u.brand||null,color_name:u.color_name||null,rgba:u.rgba||null,label_weight:u.label_weight,core_weight:u.core_weight,core_weight_catalog_id:u.core_weight_catalog_id,slicer_filament:u.slicer_filament||null,slicer_filament_name:de,nozzle_temp_min:null,nozzle_temp_max:null,note:u.note||null,cost_per_kg:u.cost_per_kg};(!c||v)&&(ke.weight_used=u.weight_used),c?ae.mutate(ke):N>1?xe.mutate({data:ke,qty:N}):ge.mutate(ke)},ve=ge.isPending||xe.isPending||ae.isPending||L.isPending;return i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[i.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),i.jsxs("div",{className:"relative w-full max-w-xl mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[i.jsx("h2",{className:"text-lg font-semibold text-white",children:s(c?"inventory.editSpool":"inventory.addSpool")}),i.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:i.jsx(Ht,{className:"w-5 h-5"})})]}),!c&&i.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-bambu-dark-tertiary flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Mc,{className:"w-4 h-4 text-amber-400"}),i.jsx("span",{className:"text-sm text-white",children:s("inventory.quickAdd")})]}),i.jsx("button",{type:"button",onClick:()=>{_(!g),g||y("filament")},className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${g?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:i.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${g?"translate-x-4":"translate-x-0.5"}`})})]}),i.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary flex-shrink-0",children:[i.jsxs("button",{onClick:()=>y("filament"),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${f==="filament"?"text-bambu-green border-b-2 border-bambu-green":"text-bambu-gray hover:text-white"}`,children:[i.jsx(yw,{className:"w-4 h-4"}),s("inventory.filamentInfoTab")]}),!g&&i.jsxs("button",{onClick:()=>y("pa-profile"),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${f==="pa-profile"?"text-bambu-green border-b-2 border-bambu-green":"text-bambu-gray hover:text-white"}`,children:[i.jsx(yhe,{className:"w-4 h-4"}),s("inventory.paProfileTab"),j>0&&i.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:j})]})]}),i.jsx("div",{className:"p-4 overflow-y-auto flex-1",style:{scrollbarGutter:"stable"},children:f==="filament"?i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:s("inventory.filamentInfo")}),i.jsx(Utt,{formData:u,updateField:re,cloudAuthenticated:C,loadingCloudPresets:k,presetInputValue:B,setPresetInputValue:z,selectedPresetOption:G,filamentOptions:E,availableBrands:V,availableMaterials:ee,quickAdd:g,quantity:N,onQuantityChange:T,errors:m})]}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:s("inventory.color")}),i.jsx(Btt,{formData:u,updateField:re,recentColors:me,onColorUsed:ce,catalogColors:Q})]}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:s("inventory.additional")}),i.jsx($tt,{formData:u,updateField:re,spoolCatalog:W,currencySymbol:a})]}),c&&n&&i.jsx("div",{children:i.jsx(Wtt,{spoolId:n.id})})]}):i.jsx(qtt,{formData:u,updateField:re,printersWithCalibrations:Z,selectedProfiles:oe,setSelectedProfiles:be,expandedPrinters:Me,setExpandedPrinters:q})}),i.jsxs("div",{className:"flex gap-2 p-4 border-t border-bambu-dark-tertiary flex-shrink-0",children:[c&&i.jsxs(Ie,{variant:"secondary",onClick:()=>L.mutate(),disabled:ve||!n?.tag_uid,className:"mr-auto",children:[i.jsx(Id,{className:"w-4 h-4"}),s("inventory.deleteTag","Delete Tag")]}),i.jsxs("div",{className:"flex gap-2 ml-auto",children:[i.jsx(Ie,{variant:"secondary",onClick:e,children:s("common.cancel")}),i.jsx(Ie,{onClick:te,disabled:ve,children:ve?i.jsxs(i.Fragment,{children:[i.jsx(pt,{className:"w-4 h-4 animate-spin"}),s("common.saving")]}):i.jsxs(i.Fragment,{children:[i.jsx(ss,{className:"w-4 h-4"}),s(c?"common.save":"inventory.addSpool")]})})]})]})]})]})}function Ytt({isOpen:t,onClose:e,columns:n,defaultColumns:r,onSave:a}){const{t:s}=Rt(),[o,l]=w.useState(n),[c,u]=w.useState(null),d=w.useRef(null);if(w.useEffect(()=>{t&&l(n.map(T=>({...T})))},[t,n]),w.useEffect(()=>{if(!t)return;const T=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t,e]),!t)return null;const m=T=>{l(C=>C.map((P,k)=>k===T?{...P,visible:!P.visible}:P))},p=(T,C)=>{C<0||C>=o.length||l(P=>{const k=[...P],[R]=k.splice(T,1);return k.splice(C,0,R),k})},f=(T,C)=>{d.current=C,u(C),T.dataTransfer.effectAllowed="move"},y=(T,C)=>{T.preventDefault(),T.dataTransfer.dropEffect="move";const P=d.current;P!==null&&P!==C&&(p(P,C),d.current=C,u(C))},v=T=>{T.preventDefault()},b=()=>{d.current=null,u(null)},g=()=>{l(r.map(T=>({...T})))},_=()=>{a(o),e()},N=o.filter(T=>T.visible).length;return i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:i.jsx(Pt,{className:"w-full max-w-md max-h-[80vh] flex flex-col",onClick:T=>T.stopPropagation(),children:i.jsxs(Et,{className:"p-6 flex flex-col min-h-0",children:[i.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:s("inventory.configureColumns")}),i.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:[s("inventory.configureColumnsDesc"),i.jsxs("span",{className:"ml-2 text-bambu-gray/60",children:["(",N," ",s("inventory.of")," ",o.length," ",s("inventory.visible"),")"]})]}),i.jsx("div",{className:"space-y-1 overflow-y-auto flex-1 min-h-0 pr-1",children:o.map((T,C)=>i.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg border transition-colors ${c===C?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-tertiary/50"} ${T.visible?"":"opacity-50"}`,draggable:!0,onDragStart:P=>f(P,C),onDragOver:P=>y(P,C),onDrop:v,onDragEnd:b,children:[i.jsx("div",{className:"cursor-grab text-bambu-gray/50 hover:text-bambu-gray",children:i.jsx(Sh,{className:"w-4 h-4"})}),i.jsx("span",{className:"flex-1 font-medium text-sm text-white",children:T.label}),i.jsxs("div",{className:"flex items-center gap-0.5",children:[i.jsx("button",{onClick:()=>p(C,C-1),disabled:C===0,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed",title:s("inventory.moveUp"),children:i.jsx($l,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>p(C,C+1),disabled:C===o.length-1,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed",title:s("inventory.moveDown"),children:i.jsx(On,{className:"w-4 h-4"})})]}),i.jsx("button",{onClick:()=>m(C),className:`p-1.5 rounded transition-colors ${T.visible?"text-bambu-green hover:bg-bambu-green/10":"text-bambu-gray/50 hover:bg-bambu-dark-secondary"}`,title:T.visible?s("inventory.hideColumn"):s("inventory.showColumn"),children:T.visible?i.jsx(Ac,{className:"w-4 h-4"}):i.jsx(fw,{className:"w-4 h-4"})})]},T.id))}),i.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[i.jsxs(Ie,{variant:"secondary",onClick:g,className:"mr-auto",children:[i.jsx(So,{className:"w-4 h-4"}),s("inventory.reset")]}),i.jsx(Ie,{variant:"secondary",onClick:e,children:s("inventory.cancel")}),i.jsx(Ie,{onClick:_,children:s("inventory.applyChanges")})]})]})})})}function RY(t){return`${t.material}|${t.subtype||""}|${t.brand||""}|${t.color_name||""}|${t.rgba||""}|${t.label_weight}`}const Goe="bambuddy-inventory-columns",SN=[{id:"id",label:"#",visible:!0},{id:"added_time",label:"Added",visible:!0},{id:"encode_time",label:"Encoded",visible:!1},{id:"last_used_time",label:"Last Used",visible:!1},{id:"rgba",label:"Color",visible:!0},{id:"material",label:"Material",visible:!0},{id:"subtype",label:"Subtype",visible:!0},{id:"color_name",label:"Color Name",visible:!1},{id:"brand",label:"Brand",visible:!0},{id:"slicer_filament",label:"Slicer Filament",visible:!1},{id:"location",label:"Location",visible:!0},{id:"label_weight",label:"Label",visible:!0},{id:"net",label:"Net",visible:!0},{id:"gross",label:"Gross",visible:!1},{id:"added_full",label:"Full",visible:!1},{id:"used",label:"Used",visible:!1},{id:"printed_total",label:"Printed Total",visible:!1},{id:"printed_since_weight",label:"Printed Since Weight",visible:!1},{id:"note",label:"Note",visible:!1},{id:"pa_k",label:"PA(K)",visible:!0},{id:"tag_id",label:"Tag ID",visible:!1},{id:"data_origin",label:"Data Origin",visible:!1},{id:"tag_type",label:"Linked Tag Type",visible:!1},{id:"stock",label:"Stock",visible:!1},{id:"remaining",label:"Remaining",visible:!0},{id:"spool_name",label:"Spool",visible:!1},{id:"cost_per_kg",label:"Cost/kg",visible:!1},{id:"weight_check",label:"Weight Check",visible:!1}];function Xtt(){try{const t=localStorage.getItem(Goe);if(t){const e=JSON.parse(t),n=new Set(SN.map(o=>o.id)),r=new Set(e.map(o=>o.id)),a=e.filter(o=>n.has(o.id)),s=SN.filter(o=>!r.has(o.id));return[...a,...s]}}catch{}return SN.map(t=>({...t}))}function Qtt(t){try{localStorage.setItem(Goe,JSON.stringify(t))}catch{}}function du(t,e=!1){return e&&t>=1e3?`${(t/1e3).toFixed(1)}kg`:`${Math.round(t)}g`}const Ztt={PLA:"bg-green-500/20 text-green-400",ABS:"bg-red-500/20 text-red-400",PETG:"bg-blue-500/20 text-blue-400",TPU:"bg-purple-500/20 text-purple-400",ASA:"bg-orange-500/20 text-orange-400",PA:"bg-yellow-500/20 text-yellow-400",PC:"bg-cyan-500/20 text-cyan-400",PET:"bg-sky-500/20 text-sky-400"};function YD(t,e="system"){if(!t)return"-";const n=Zn(t);return n?N3(n,e):"-"}const Jtt={id:()=>"#",added_time:()=>"Added",encode_time:()=>"Encoded",last_used_time:()=>"Last Used",rgba:t=>t("inventory.color"),material:t=>t("inventory.material"),subtype:t=>t("inventory.subtype"),color_name:t=>t("inventory.colorName"),brand:t=>t("inventory.brand"),slicer_filament:t=>t("inventory.slicerFilament"),location:()=>"Location",label_weight:t=>t("inventory.labelWeight"),net:t=>t("inventory.net"),gross:()=>"Gross",added_full:()=>"Full",used:t=>t("inventory.weightUsed"),printed_total:()=>"Printed Total",printed_since_weight:()=>"Printed Since Weight",note:t=>t("inventory.note"),pa_k:()=>"PA(K)",tag_id:()=>"Tag ID",data_origin:()=>"Data Origin",tag_type:()=>"Linked Tag Type",stock:t=>t("inventory.stock"),remaining:t=>t("inventory.remaining"),spool_name:t=>t("inventory.spoolName"),cost_per_kg:t=>t("inventory.costPerKg"),weight_check:t=>t("inventory.weightCheck")},SL={id:({spool:t})=>i.jsx("span",{className:"text-sm font-medium text-white",children:t.id}),added_time:({spool:t,dateFormat:e})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:YD(t.created_at,e)}),encode_time:({spool:t,dateFormat:e})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:YD(t.encode_time,e)}),last_used_time:({spool:t,dateFormat:e})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:t.last_used?YD(t.last_used,e):"Never"}),rgba:({spool:t})=>i.jsx("div",{className:"flex items-center justify-center",children:i.jsx("span",{className:"w-5 h-5 rounded-full border border-black/20 flex-shrink-0",style:{backgroundColor:t.rgba?`#${t.rgba.substring(0,6)}`:"#808080"},title:t.rgba?`#${t.rgba.substring(0,6)}`:void 0})}),material:({spool:t})=>i.jsx("span",{className:"text-sm text-white",children:t.material}),subtype:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:t.subtype||"-"}),color_name:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:PI(t.color_name,t.rgba)||"-"}),brand:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:t.brand||"-"}),slicer_filament:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray",title:t.slicer_filament||void 0,children:t.slicer_filament_name||t.slicer_filament||"-"}),location:({spool:t,assignmentMap:e})=>{const n=e[t.id];if(!n)return i.jsx("span",{className:"text-sm text-bambu-gray",children:"-"});const r=n.printer_name||`Printer ${n.printer_id}`,a=n.ams_id===254||n.ams_id===255,s=!a&&n.ams_id>=128,o=EI(n.ams_id,n.tray_id,s,a);return i.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-purple-500/20 text-purple-400",children:[r," ",o,n.ams_label?` (${n.ams_label})`:""]})},label_weight:({spool:t})=>i.jsx("span",{className:"text-sm text-white",children:du(t.label_weight)}),net:({remaining:t})=>i.jsx("span",{className:"text-sm text-white",children:du(t)}),gross:({spool:t,remaining:e})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:du(e+t.core_weight)}),added_full:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:t.added_full==null?"-":t.added_full?"Yes":"No"}),used:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:t.weight_used>0?du(t.weight_used):"-"}),printed_total:()=>i.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"}),printed_since_weight:()=>i.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"}),note:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray max-w-[150px] truncate block",title:t.note||void 0,children:t.note||"-"}),pa_k:({spool:t})=>(t.k_profiles?.length??0)===0?i.jsx("span",{className:"text-sm text-bambu-gray",children:"-"}):i.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-bambu-green/20 text-bambu-green",children:"K"}),tag_id:({spool:t})=>{const e=t.tag_uid||t.tray_uuid;return e?i.jsx("span",{className:"text-sm text-bambu-gray font-mono",title:e,children:e.length>12?`${e.slice(0,6)}...${e.slice(-4)}`:e}):i.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"})},data_origin:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:t.data_origin||"-"}),tag_type:({spool:t})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:t.tag_type||"-"}),stock:({spool:t,t:e})=>t.slicer_filament?i.jsx("span",{className:"text-sm text-bambu-gray",children:"-"}):i.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-amber-500/20 text-amber-400",children:e("inventory.stock")}),remaining:({remaining:t,pct:e})=>i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:i.jsx("div",{className:`h-full rounded-full ${e>50?"bg-bambu-green":e>20?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(e,100)}%`}})}),i.jsxs("span",{className:"text-xs text-bambu-gray min-w-[40px] text-right",children:[Math.round(t),"g"]})]}),spool_name:({spool:t,catalogMap:e})=>{const n=t.core_weight_catalog_id!=null?e[t.core_weight_catalog_id]:void 0;return i.jsx("span",{className:"text-sm text-bambu-gray",children:n?.name||"-"})},cost_per_kg:({spool:t,currencySymbol:e})=>i.jsx("span",{className:"text-sm text-bambu-gray",children:t.cost_per_kg!=null?`${e}${t.cost_per_kg.toFixed(2)}`:"-"}),weight_check:({spool:t,onSyncWeight:e})=>{const n=t.last_scale_weight;if(n==null)return i.jsx("span",{className:"text-sm text-bambu-gray/50",title:"No scale measurement",children:"-"});const r=t.core_weight||0,a=Math.max(0,t.label_weight-t.weight_used)+r;let s,o;n0?`+${Math.round(s)}`:`${Math.round(s)}`,c=o?`Scale: ${Math.round(n)}g Calculated: ${Math.round(a)}g Difference: ${l}g (within tolerance)`:`Scale: ${Math.round(n)}g Calculated: ${Math.round(a)}g diff --git a/static/assets/index-DS0IE7o1.css b/static/assets/index-hPK_4Ftq.css similarity index 67% rename from static/assets/index-DS0IE7o1.css rename to static/assets/index-hPK_4Ftq.css index 173a47271..9c0d4e4d1 100644 --- a/static/assets/index-DS0IE7o1.css +++ b/static/assets/index-hPK_4Ftq.css @@ -1 +1 @@ -@import"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap";@layer properties,theme,base,components,utilities;@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-red-950:oklch(25.8% .092 26.042);--color-orange-200:oklch(90.1% .076 70.697);--color-orange-300:oklch(83.7% .128 66.29);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-600:oklch(64.6% .222 41.116);--color-orange-700:oklch(55.3% .195 38.402);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-700:oklch(55.5% .163 48.998);--color-amber-800:oklch(47.3% .137 46.201);--color-amber-900:oklch(41.4% .112 45.904);--color-yellow-200:oklch(94.5% .129 101.54);--color-yellow-300:oklch(90.5% .182 98.111);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-yellow-600:oklch(68.1% .162 75.834);--color-yellow-700:oklch(55.4% .135 66.442);--color-lime-500:oklch(76.8% .233 130.85);--color-green-100:oklch(96.2% .044 156.743);--color-green-200:oklch(92.5% .084 155.995);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-green-800:oklch(44.8% .119 151.328);--color-green-900:oklch(39.3% .095 152.535);--color-emerald-300:oklch(84.5% .143 164.978);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-600:oklch(59.6% .145 163.225);--color-emerald-700:oklch(50.8% .118 165.612);--color-teal-400:oklch(77.7% .152 181.912);--color-teal-500:oklch(70.4% .14 182.503);--color-cyan-300:oklch(86.5% .127 207.078);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-500:oklch(71.5% .143 215.221);--color-cyan-600:oklch(60.9% .126 221.723);--color-sky-400:oklch(74.6% .16 232.661);--color-sky-500:oklch(68.5% .169 237.323);--color-blue-50:oklch(97% .014 254.604);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-blue-900:oklch(37.9% .146 265.522);--color-indigo-400:oklch(67.3% .182 276.935);--color-indigo-500:oklch(58.5% .233 277.117);--color-violet-500:oklch(60.6% .25 292.717);--color-purple-300:oklch(82.7% .119 306.383);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-500:oklch(62.7% .265 303.9);--color-purple-600:oklch(55.8% .288 302.321);--color-purple-700:oklch(49.6% .265 301.924);--color-fuchsia-500:oklch(66.7% .295 322.15);--color-rose-300:oklch(81% .117 11.638);--color-rose-400:oklch(71.2% .194 13.428);--color-rose-500:oklch(64.5% .246 16.439);--color-rose-600:oklch(58.6% .253 17.585);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-500:oklch(55.4% .046 257.417);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-gray-900:oklch(21% .034 264.665);--color-zinc-100:oklch(96.7% .001 286.375);--color-zinc-200:oklch(92% .004 286.32);--color-zinc-300:oklch(87.1% .006 286.286);--color-zinc-400:oklch(70.5% .015 286.067);--color-zinc-500:oklch(55.2% .016 285.938);--color-zinc-600:oklch(44.2% .017 285.786);--color-zinc-700:oklch(37% .013 285.805);--color-zinc-800:oklch(27.4% .006 286.033);--color-zinc-900:oklch(21% .006 285.885);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-xl:36rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--container-5xl:64rem;--container-6xl:72rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--text-3xl:1.875rem;--text-3xl--line-height: 1.2 ;--text-5xl:3rem;--text-5xl--line-height:1;--font-weight-light:300;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--tracking-wider:.05em;--tracking-widest:.1em;--leading-tight:1.25;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--drop-shadow-md:0 3px 3px #0000001f;--drop-shadow-lg:0 4px 4px #00000026;--ease-out:cubic-bezier(0,0,.2,1);--ease-in-out:cubic-bezier(.4,0,.2,1);--animate-spin:spin 1s linear infinite;--animate-ping:ping 1s cubic-bezier(0,0,.2,1)infinite;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--blur-sm:8px;--blur-2xl:40px;--aspect-video:16/9;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-bambu-green:var(--accent);--color-bambu-green-light:var(--accent-light);--color-bambu-green-dark:var(--accent-dark);--color-status-ok:var(--status-ok);--color-status-error:var(--status-error);--color-status-warning:var(--status-warning);--color-bambu-dark:var(--bg-primary);--color-bambu-dark-secondary:var(--bg-secondary);--color-bambu-dark-tertiary:var(--bg-tertiary);--color-bambu-gray:var(--text-muted);--color-bambu-gray-light:var(--text-secondary);--color-bambu-gray-dark:var(--text-tertiary)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.-inset-4{inset:calc(var(--spacing)*-4)}.inset-0{inset:calc(var(--spacing)*0)}.inset-2{inset:calc(var(--spacing)*2)}.inset-x-0{inset-inline:calc(var(--spacing)*0)}.inset-y-0{inset-block:calc(var(--spacing)*0)}.-top-0\.5{top:calc(var(--spacing)*-.5)}.-top-1{top:calc(var(--spacing)*-1)}.-top-1\.5{top:calc(var(--spacing)*-1.5)}.top-0{top:calc(var(--spacing)*0)}.top-0\.5{top:calc(var(--spacing)*.5)}.top-1{top:calc(var(--spacing)*1)}.top-1\.5{top:calc(var(--spacing)*1.5)}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing)*2)}.top-2\.5{top:calc(var(--spacing)*2.5)}.top-3{top:calc(var(--spacing)*3)}.top-4{top:calc(var(--spacing)*4)}.top-8{top:calc(var(--spacing)*8)}.top-\[2px\]{top:2px}.top-\[3px\]{top:3px}.top-\[52px\]{top:52px}.top-full{top:100%}.-right-0\.5{right:calc(var(--spacing)*-.5)}.-right-1{right:calc(var(--spacing)*-1)}.-right-1\.5{right:calc(var(--spacing)*-1.5)}.-right-2{right:calc(var(--spacing)*-2)}.right-0{right:calc(var(--spacing)*0)}.right-1{right:calc(var(--spacing)*1)}.right-1\.5{right:calc(var(--spacing)*1.5)}.right-2{right:calc(var(--spacing)*2)}.right-3{right:calc(var(--spacing)*3)}.right-4{right:calc(var(--spacing)*4)}.right-6{right:calc(var(--spacing)*6)}.right-12{right:calc(var(--spacing)*12)}.right-20{right:calc(var(--spacing)*20)}.right-\[5\.5rem\]{right:5.5rem}.right-full{right:100%}.-bottom-0\.5{bottom:calc(var(--spacing)*-.5)}.-bottom-1{bottom:calc(var(--spacing)*-1)}.-bottom-2{bottom:calc(var(--spacing)*-2)}.-bottom-7{bottom:calc(var(--spacing)*-7)}.bottom-0{bottom:calc(var(--spacing)*0)}.bottom-1{bottom:calc(var(--spacing)*1)}.bottom-2{bottom:calc(var(--spacing)*2)}.bottom-3{bottom:calc(var(--spacing)*3)}.bottom-4{bottom:calc(var(--spacing)*4)}.bottom-6{bottom:calc(var(--spacing)*6)}.bottom-8{bottom:calc(var(--spacing)*8)}.bottom-20{bottom:calc(var(--spacing)*20)}.bottom-full{bottom:100%}.-left-2{left:calc(var(--spacing)*-2)}.left-0{left:calc(var(--spacing)*0)}.left-0\.5{left:calc(var(--spacing)*.5)}.left-1{left:calc(var(--spacing)*1)}.left-1\/2{left:50%}.left-2{left:calc(var(--spacing)*2)}.left-2\.5{left:calc(var(--spacing)*2.5)}.left-3{left:calc(var(--spacing)*3)}.left-4{left:calc(var(--spacing)*4)}.left-10{left:calc(var(--spacing)*10)}.left-12{left:calc(var(--spacing)*12)}.left-\[2px\]{left:2px}.left-\[3px\]{left:3px}.left-full{left:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-60,.z-\[60\]{z-index:60}.z-\[100\]{z-index:100}.z-\[101\]{z-index:101}.z-\[9998\]{z-index:9998}.z-\[9999\]{z-index:9999}.col-span-1{grid-column:span 1/span 1}.col-span-2{grid-column:span 2/span 2}.col-span-3{grid-column:span 3/span 3}.col-span-4{grid-column:span 4/span 4}.col-span-full{grid-column:1/-1}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.-m-4{margin:calc(var(--spacing)*-4)}.-mx-4{margin-inline:calc(var(--spacing)*-4)}.mx-1{margin-inline:calc(var(--spacing)*1)}.mx-1\.5{margin-inline:calc(var(--spacing)*1.5)}.mx-2{margin-inline:calc(var(--spacing)*2)}.mx-4{margin-inline:calc(var(--spacing)*4)}.mx-5{margin-inline:calc(var(--spacing)*5)}.mx-auto{margin-inline:auto}.my-1{margin-block:calc(var(--spacing)*1)}.my-2{margin-block:calc(var(--spacing)*2)}.my-8{margin-block:calc(var(--spacing)*8)}.-mt-0\.5{margin-top:calc(var(--spacing)*-.5)}.-mt-2{margin-top:calc(var(--spacing)*-2)}.mt-0\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-1\.5{margin-top:calc(var(--spacing)*1.5)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-6{margin-top:calc(var(--spacing)*6)}.mt-8{margin-top:calc(var(--spacing)*8)}.mt-14{margin-top:calc(var(--spacing)*14)}.mt-auto{margin-top:auto}.mr-1{margin-right:calc(var(--spacing)*1)}.mr-1\.5{margin-right:calc(var(--spacing)*1.5)}.mr-2{margin-right:calc(var(--spacing)*2)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-4{margin-right:calc(var(--spacing)*4)}.mr-auto{margin-right:auto}.-mb-px{margin-bottom:-1px}.mb-0\.5{margin-bottom:calc(var(--spacing)*.5)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-1\.5{margin-bottom:calc(var(--spacing)*1.5)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-2\.5{margin-bottom:calc(var(--spacing)*2.5)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.mb-5{margin-bottom:calc(var(--spacing)*5)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.-ml-1{margin-left:calc(var(--spacing)*-1)}.-ml-2{margin-left:calc(var(--spacing)*-2)}.ml-0\.5{margin-left:calc(var(--spacing)*.5)}.ml-1{margin-left:calc(var(--spacing)*1)}.ml-1\.5{margin-left:calc(var(--spacing)*1.5)}.ml-2{margin-left:calc(var(--spacing)*2)}.ml-3{margin-left:calc(var(--spacing)*3)}.ml-4{margin-left:calc(var(--spacing)*4)}.ml-6{margin-left:calc(var(--spacing)*6)}.ml-7{margin-left:calc(var(--spacing)*7)}.ml-9{margin-left:calc(var(--spacing)*9)}.ml-14{margin-left:calc(var(--spacing)*14)}.ml-16{margin-left:calc(var(--spacing)*16)}.ml-64{margin-left:calc(var(--spacing)*64)}.ml-auto{margin-left:auto}.line-clamp-1{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.aspect-square{aspect-ratio:1}.aspect-video{aspect-ratio:var(--aspect-video)}.h-0{height:calc(var(--spacing)*0)}.h-0\.5{height:calc(var(--spacing)*.5)}.h-1{height:calc(var(--spacing)*1)}.h-1\.5{height:calc(var(--spacing)*1.5)}.h-2{height:calc(var(--spacing)*2)}.h-2\.5{height:calc(var(--spacing)*2.5)}.h-3{height:calc(var(--spacing)*3)}.h-3\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-9{height:calc(var(--spacing)*9)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-14{height:calc(var(--spacing)*14)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-24{height:calc(var(--spacing)*24)}.h-32{height:calc(var(--spacing)*32)}.h-40{height:calc(var(--spacing)*40)}.h-48{height:calc(var(--spacing)*48)}.h-64{height:calc(var(--spacing)*64)}.h-80{height:calc(var(--spacing)*80)}.h-\[18px\]{height:18px}.h-\[38px\]{height:38px}.h-\[40px\]{height:40px}.h-\[48px\]{height:48px}.h-\[80vh\]{height:80vh}.h-\[160px\]{height:160px}.h-\[300px\]{height:300px}.h-\[calc\(100\%-40px\)\]{height:calc(100% - 40px)}.h-full{height:100%}.h-px{height:1px}.h-screen{height:100vh}.max-h-40{max-height:calc(var(--spacing)*40)}.max-h-48{max-height:calc(var(--spacing)*48)}.max-h-60{max-height:calc(var(--spacing)*60)}.max-h-64{max-height:calc(var(--spacing)*64)}.max-h-80{max-height:calc(var(--spacing)*80)}.max-h-96{max-height:calc(var(--spacing)*96)}.max-h-\[60vh\]{max-height:60vh}.max-h-\[80vh\]{max-height:80vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[300px\]{max-height:300px}.max-h-\[400px\]{max-height:400px}.max-h-\[500px\]{max-height:500px}.max-h-\[600px\]{max-height:600px}.max-h-\[calc\(90vh-80px\)\]{max-height:calc(90vh - 80px)}.max-h-\[calc\(100vh-320px\)\]{max-height:calc(100vh - 320px)}.max-h-full{max-height:100%}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-\[36px\]{min-height:36px}.min-h-\[40px\]{min-height:40px}.min-h-\[44px\]{min-height:44px}.min-h-\[48px\]{min-height:48px}.min-h-\[80px\]{min-height:80px}.min-h-\[120px\]{min-height:120px}.min-h-\[300px\]{min-height:300px}.min-h-\[400px\]{min-height:400px}.min-h-\[calc\(100vh-64px\)\]{min-height:calc(100vh - 64px)}.min-h-screen{min-height:100vh}.w-0{width:calc(var(--spacing)*0)}.w-0\.5{width:calc(var(--spacing)*.5)}.w-1{width:calc(var(--spacing)*1)}.w-1\.5{width:calc(var(--spacing)*1.5)}.w-1\/2{width:50%}.w-1\/3{width:33.3333%}.w-2{width:calc(var(--spacing)*2)}.w-2\.5{width:calc(var(--spacing)*2.5)}.w-3{width:calc(var(--spacing)*3)}.w-3\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-4\.5{width:calc(var(--spacing)*4.5)}.w-5{width:calc(var(--spacing)*5)}.w-5\/12{width:41.6667%}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-7\/12{width:58.3333%}.w-8{width:calc(var(--spacing)*8)}.w-9{width:calc(var(--spacing)*9)}.w-10{width:calc(var(--spacing)*10)}.w-11{width:calc(var(--spacing)*11)}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.w-16{width:calc(var(--spacing)*16)}.w-20{width:calc(var(--spacing)*20)}.w-24{width:calc(var(--spacing)*24)}.w-32{width:calc(var(--spacing)*32)}.w-36{width:calc(var(--spacing)*36)}.w-40{width:calc(var(--spacing)*40)}.w-44{width:calc(var(--spacing)*44)}.w-48{width:calc(var(--spacing)*48)}.w-52{width:calc(var(--spacing)*52)}.w-56{width:calc(var(--spacing)*56)}.w-64{width:calc(var(--spacing)*64)}.w-72{width:calc(var(--spacing)*72)}.w-96{width:calc(var(--spacing)*96)}.w-\[240px\]{width:240px}.w-\[340px\]{width:340px}.w-\[420px\]{width:420px}.w-\[560px\]{width:560px}.w-auto{width:auto}.w-fit{width:fit-content}.w-full{width:100%}.w-px{width:1px}.w-screen{width:100vw}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-5xl{max-width:var(--container-5xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-32{max-width:calc(var(--spacing)*32)}.max-w-\[40\%\]{max-width:40%}.max-w-\[50\%\]{max-width:50%}.max-w-\[80px\]{max-width:80px}.max-w-\[90vw\]{max-width:90vw}.max-w-\[100px\]{max-width:100px}.max-w-\[120px\]{max-width:120px}.max-w-\[150px\]{max-width:150px}.max-w-\[160px\]{max-width:160px}.max-w-\[200px\]{max-width:200px}.max-w-\[280px\]{max-width:280px}.max-w-\[600px\]{max-width:600px}.max-w-full{max-width:100%}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.max-w-xl{max-width:var(--container-xl)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-48{min-width:calc(var(--spacing)*48)}.min-w-\[16px\]{min-width:16px}.min-w-\[18px\]{min-width:18px}.min-w-\[32px\]{min-width:32px}.min-w-\[40px\]{min-width:40px}.min-w-\[48px\]{min-width:48px}.min-w-\[50px\]{min-width:50px}.min-w-\[80px\]{min-width:80px}.min-w-\[100px\]{min-width:100px}.min-w-\[120px\]{min-width:120px}.min-w-\[130px\]{min-width:130px}.min-w-\[140px\]{min-width:140px}.min-w-\[150px\]{min-width:150px}.min-w-\[160px\]{min-width:160px}.min-w-\[180px\]{min-width:180px}.min-w-\[200px\]{min-width:200px}.min-w-full{min-width:100%}.flex-1{flex:1}.flex-\[2_1_190px\]{flex:2 190px}.flex-shrink{flex-shrink:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-x-full{--tw-translate-x:-100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0\.5{--tw-translate-x:calc(var(--spacing)*.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-1{--tw-translate-x:calc(var(--spacing)*1);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-3\.5{--tw-translate-x:calc(var(--spacing)*3.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-4{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-5{--tw-translate-x:calc(var(--spacing)*5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-6{--tw-translate-x:calc(var(--spacing)*6);translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.scale-105{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-\[1\.02\]{scale:1.02}.-rotate-90{rotate:-90deg}.rotate-90{rotate:90deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-col-resize{cursor:col-resize}.cursor-default{cursor:default}.cursor-ew-resize{cursor:ew-resize}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-row-resize{cursor:row-resize}.cursor-se-resize{cursor:se-resize}.touch-manipulation{touch-action:manipulation}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.\[appearance\:textfield\]{appearance:textfield}.appearance-none{appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}.grid-cols-\[auto_1fr_100px_100px_100px_80px\]{grid-template-columns:auto 1fr 100px 100px 100px 80px}.grid-cols-\[auto_1fr_120px_100px_100px_100px_80px\]{grid-template-columns:auto 1fr 120px 100px 100px 100px 80px}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0{gap:calc(var(--spacing)*0)}.gap-0\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-2\.5{gap:calc(var(--spacing)*2.5)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-6{gap:calc(var(--spacing)*6)}.gap-8{gap:calc(var(--spacing)*8)}.gap-\[3px\]{gap:3px}:where(.space-y-0>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*0)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*0)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*4)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*4)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*6)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*6)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}.gap-x-3{column-gap:calc(var(--spacing)*3)}.gap-x-4{column-gap:calc(var(--spacing)*4)}.gap-x-6{column-gap:calc(var(--spacing)*6)}.gap-y-1{row-gap:calc(var(--spacing)*1)}.gap-y-2{row-gap:calc(var(--spacing)*2)}.gap-y-3{row-gap:calc(var(--spacing)*3)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px*var(--tw-divide-y-reverse));border-bottom-width:calc(1px*calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-bambu-dark-tertiary>:not(:last-child)),:where(.divide-bambu-dark-tertiary\/30>:not(:last-child)){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){:where(.divide-bambu-dark-tertiary\/30>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}:where(.divide-bambu-gray\/20>:not(:last-child)){border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){:where(.divide-bambu-gray\/20>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-none{border-radius:0}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-t-lg{border-top-left-radius:var(--radius-lg);border-top-right-radius:var(--radius-lg)}.rounded-t-xl{border-top-left-radius:var(--radius-xl);border-top-right-radius:var(--radius-xl)}.\!rounded-l-none{border-top-left-radius:0!important;border-bottom-left-radius:0!important}.rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-l-lg{border-top-left-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.rounded-tl{border-top-left-radius:.25rem}.\!rounded-r-none{border-top-right-radius:0!important;border-bottom-right-radius:0!important}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.rounded-r-lg{border-top-right-radius:var(--radius-lg);border-bottom-right-radius:var(--radius-lg)}.rounded-b-lg{border-bottom-right-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-4{border-style:var(--tw-border-style);border-width:4px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-2{border-top-style:var(--tw-border-style);border-top-width:2px}.border-t-\[5px\]{border-top-style:var(--tw-border-style);border-top-width:5px}.border-t-\[6px\]{border-top-style:var(--tw-border-style);border-top-width:6px}.\!border-r-0{border-right-style:var(--tw-border-style)!important;border-right-width:0!important}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-\[5px\]{border-right-style:var(--tw-border-style);border-right-width:5px}.border-r-\[6px\]{border-right-style:var(--tw-border-style);border-right-width:6px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-b-\[6px\]{border-bottom-style:var(--tw-border-style);border-bottom-width:6px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-l-\[5px\]{border-left-style:var(--tw-border-style);border-left-width:5px}.border-l-\[6px\]{border-left-style:var(--tw-border-style);border-left-width:6px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.\!border-green-500{border-color:var(--color-green-500)!important}.\!border-yellow-500{border-color:var(--color-yellow-500)!important}.border-amber-200{border-color:var(--color-amber-200)}.border-amber-300{border-color:var(--color-amber-300)}.border-amber-500{border-color:var(--color-amber-500)}.border-amber-500\/20{border-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/20{border-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.border-amber-500\/30{border-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/30{border-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.border-bambu-dark-secondary{border-color:var(--color-bambu-dark-secondary)}.border-bambu-dark-tertiary,.border-bambu-dark-tertiary\/20{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/20{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)20%,transparent)}}.border-bambu-dark-tertiary\/30{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/30{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.border-bambu-dark-tertiary\/40{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/40{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.border-bambu-dark-tertiary\/50{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/50{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.border-bambu-gray,.border-bambu-gray\/20{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/20{border-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.border-bambu-gray\/30{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/30{border-color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.border-bambu-gray\/50{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/50{border-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.border-bambu-green,.border-bambu-green\/20{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/20{border-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.border-bambu-green\/30{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/30{border-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.border-bambu-green\/40{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/40{border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.border-bambu-green\/50{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/50{border-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.border-black\/20{border-color:#0003}@supports (color:color-mix(in lab,red,red)){.border-black\/20{border-color:color-mix(in oklab,var(--color-black)20%,transparent)}}.border-blue-400\/20{border-color:#54a2ff33}@supports (color:color-mix(in lab,red,red)){.border-blue-400\/20{border-color:color-mix(in oklab,var(--color-blue-400)20%,transparent)}}.border-blue-400\/50{border-color:#54a2ff80}@supports (color:color-mix(in lab,red,red)){.border-blue-400\/50{border-color:color-mix(in oklab,var(--color-blue-400)50%,transparent)}}.border-blue-500{border-color:var(--color-blue-500)}.border-blue-500\/20{border-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/20{border-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.border-blue-500\/30{border-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/30{border-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.border-blue-500\/40{border-color:#3080ff66}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/40{border-color:color-mix(in oklab,var(--color-blue-500)40%,transparent)}}.border-blue-500\/50{border-color:#3080ff80}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/50{border-color:color-mix(in oklab,var(--color-blue-500)50%,transparent)}}.border-gray-200{border-color:var(--color-gray-200)}.border-gray-300{border-color:var(--color-gray-300)}.border-gray-400\/20{border-color:#99a1af33}@supports (color:color-mix(in lab,red,red)){.border-gray-400\/20{border-color:color-mix(in oklab,var(--color-gray-400)20%,transparent)}}.border-gray-500{border-color:var(--color-gray-500)}.border-gray-500\/20{border-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.border-gray-500\/20{border-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.border-gray-700{border-color:var(--color-gray-700)}.border-green-300{border-color:var(--color-green-300)}.border-green-500{border-color:var(--color-green-500)}.border-green-500\/10{border-color:#00c7581a}@supports (color:color-mix(in lab,red,red)){.border-green-500\/10{border-color:color-mix(in oklab,var(--color-green-500)10%,transparent)}}.border-green-500\/20{border-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.border-green-500\/20{border-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500)30%,transparent)}}.border-green-500\/40{border-color:#00c75866}@supports (color:color-mix(in lab,red,red)){.border-green-500\/40{border-color:color-mix(in oklab,var(--color-green-500)40%,transparent)}}.border-green-500\/50{border-color:#00c75880}@supports (color:color-mix(in lab,red,red)){.border-green-500\/50{border-color:color-mix(in oklab,var(--color-green-500)50%,transparent)}}.border-green-800{border-color:var(--color-green-800)}.border-orange-400\/20{border-color:#ff8b1a33}@supports (color:color-mix(in lab,red,red)){.border-orange-400\/20{border-color:color-mix(in oklab,var(--color-orange-400)20%,transparent)}}.border-orange-400\/50{border-color:#ff8b1a80}@supports (color:color-mix(in lab,red,red)){.border-orange-400\/50{border-color:color-mix(in oklab,var(--color-orange-400)50%,transparent)}}.border-orange-500\/20{border-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/20{border-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.border-orange-500\/30{border-color:#fe6e004d}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/30{border-color:color-mix(in oklab,var(--color-orange-500)30%,transparent)}}.border-purple-400\/20{border-color:#c07eff33}@supports (color:color-mix(in lab,red,red)){.border-purple-400\/20{border-color:color-mix(in oklab,var(--color-purple-400)20%,transparent)}}.border-purple-500{border-color:var(--color-purple-500)}.border-purple-500\/20{border-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/20{border-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.border-purple-500\/30{border-color:#ac4bff4d}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/30{border-color:color-mix(in oklab,var(--color-purple-500)30%,transparent)}}.border-red-300{border-color:var(--color-red-300)}.border-red-500{border-color:var(--color-red-500)}.border-red-500\/20{border-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.border-red-500\/20{border-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.border-red-500\/40{border-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.border-red-500\/40{border-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.border-red-500\/50{border-color:#fb2c3680}@supports (color:color-mix(in lab,red,red)){.border-red-500\/50{border-color:color-mix(in oklab,var(--color-red-500)50%,transparent)}}.border-red-800{border-color:var(--color-red-800)}.border-red-800\/70{border-color:#9f0712b3}@supports (color:color-mix(in lab,red,red)){.border-red-800\/70{border-color:color-mix(in oklab,var(--color-red-800)70%,transparent)}}.border-slate-500{border-color:var(--color-slate-500)}.border-status-error\/20{border-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.border-status-error\/20{border-color:color-mix(in oklab,var(--color-status-error)20%,transparent)}}.border-status-ok,.border-status-ok\/20{border-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.border-status-ok\/20{border-color:color-mix(in oklab,var(--color-status-ok)20%,transparent)}}.border-status-warning\/20{border-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.border-status-warning\/20{border-color:color-mix(in oklab,var(--color-status-warning)20%,transparent)}}.border-transparent{border-color:#0000}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.border-white\/20{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.border-white\/20{border-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.border-white\/30{border-color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.border-white\/30{border-color:color-mix(in oklab,var(--color-white)30%,transparent)}}.border-yellow-400\/20{border-color:#fac80033}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/20{border-color:color-mix(in oklab,var(--color-yellow-400)20%,transparent)}}.border-yellow-400\/30{border-color:#fac8004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/30{border-color:color-mix(in oklab,var(--color-yellow-400)30%,transparent)}}.border-yellow-400\/50{border-color:#fac80080}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/50{border-color:color-mix(in oklab,var(--color-yellow-400)50%,transparent)}}.border-yellow-500{border-color:var(--color-yellow-500)}.border-yellow-500\/20{border-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/20{border-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.border-yellow-500\/30{border-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/30{border-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.border-yellow-500\/50{border-color:#edb20080}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/50{border-color:color-mix(in oklab,var(--color-yellow-500)50%,transparent)}}.border-zinc-500{border-color:var(--color-zinc-500)}.border-zinc-600{border-color:var(--color-zinc-600)}.border-zinc-700{border-color:var(--color-zinc-700)}.border-zinc-700\/50{border-color:#3f3f4680}@supports (color:color-mix(in lab,red,red)){.border-zinc-700\/50{border-color:color-mix(in oklab,var(--color-zinc-700)50%,transparent)}}.border-zinc-800{border-color:var(--color-zinc-800)}.border-t-bambu-dark-tertiary{border-top-color:var(--color-bambu-dark-tertiary)}.border-t-transparent{border-top-color:#0000}.border-r-transparent{border-right-color:#0000}.border-b-bambu-dark-tertiary{border-bottom-color:var(--color-bambu-dark-tertiary)}.border-l-transparent{border-left-color:#0000}.border-l-yellow-500{border-left-color:var(--color-yellow-500)}.\!bg-bambu-green{background-color:var(--color-bambu-green)!important}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-500\/5{background-color:#f99c000d}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/5{background-color:color-mix(in oklab,var(--color-amber-500)5%,transparent)}}.bg-amber-500\/10{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/10{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.bg-amber-500\/20{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/20{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.bg-amber-600\/20{background-color:#dd740033}@supports (color:color-mix(in lab,red,red)){.bg-amber-600\/20{background-color:color-mix(in oklab,var(--color-amber-600)20%,transparent)}}.bg-bambu-dark{background-color:var(--color-bambu-dark)}.bg-bambu-dark-secondary,.bg-bambu-dark-secondary\/30{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/30{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)30%,transparent)}}.bg-bambu-dark-secondary\/50{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/50{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)50%,transparent)}}.bg-bambu-dark-secondary\/60{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/60{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)60%,transparent)}}.bg-bambu-dark-secondary\/90{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/90{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)90%,transparent)}}.bg-bambu-dark-secondary\/95{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/95{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)95%,transparent)}}.bg-bambu-dark-tertiary,.bg-bambu-dark-tertiary\/20{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/20{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)20%,transparent)}}.bg-bambu-dark-tertiary\/30{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/30{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.bg-bambu-dark-tertiary\/40{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/40{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.bg-bambu-dark-tertiary\/50{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/50{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.bg-bambu-dark-tertiary\/70{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/70{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)70%,transparent)}}.bg-bambu-dark-tertiary\/80{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/80{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.bg-bambu-dark\/20{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/20{background-color:color-mix(in oklab,var(--color-bambu-dark)20%,transparent)}}.bg-bambu-dark\/30{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/30{background-color:color-mix(in oklab,var(--color-bambu-dark)30%,transparent)}}.bg-bambu-dark\/50{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/50{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.bg-bambu-dark\/80{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/80{background-color:color-mix(in oklab,var(--color-bambu-dark)80%,transparent)}}.bg-bambu-dark\/90{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/90{background-color:color-mix(in oklab,var(--color-bambu-dark)90%,transparent)}}.bg-bambu-gray,.bg-bambu-gray\/10{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/10{background-color:color-mix(in oklab,var(--color-bambu-gray)10%,transparent)}}.bg-bambu-gray\/20{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/20{background-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.bg-bambu-gray\/30{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/30{background-color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.bg-bambu-gray\/50{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/50{background-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.bg-bambu-gray\/60{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/60{background-color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.bg-bambu-gray\/90{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/90{background-color:color-mix(in oklab,var(--color-bambu-gray)90%,transparent)}}.bg-bambu-green,.bg-bambu-green\/5{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/5{background-color:color-mix(in oklab,var(--color-bambu-green)5%,transparent)}}.bg-bambu-green\/10{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/10{background-color:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.bg-bambu-green\/15{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/15{background-color:color-mix(in oklab,var(--color-bambu-green)15%,transparent)}}.bg-bambu-green\/20{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/20{background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.bg-bambu-green\/30{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/30{background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.bg-bambu-green\/50{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/50{background-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.bg-bambu-green\/75{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/75{background-color:color-mix(in oklab,var(--color-bambu-green)75%,transparent)}}.bg-bambu-green\/90{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/90{background-color:color-mix(in oklab,var(--color-bambu-green)90%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/15{background-color:#00000026}@supports (color:color-mix(in lab,red,red)){.bg-black\/15{background-color:color-mix(in oklab,var(--color-black)15%,transparent)}}.bg-black\/30{background-color:#0000004d}@supports (color:color-mix(in lab,red,red)){.bg-black\/30{background-color:color-mix(in oklab,var(--color-black)30%,transparent)}}.bg-black\/40{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.bg-black\/40{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black)60%,transparent)}}.bg-black\/70{background-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.bg-black\/70{background-color:color-mix(in oklab,var(--color-black)70%,transparent)}}.bg-black\/80{background-color:#000c}@supports (color:color-mix(in lab,red,red)){.bg-black\/80{background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.bg-black\/90{background-color:#000000e6}@supports (color:color-mix(in lab,red,red)){.bg-black\/90{background-color:color-mix(in oklab,var(--color-black)90%,transparent)}}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-blue-400{background-color:var(--color-blue-400)}.bg-blue-400\/10{background-color:#54a2ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-400\/10{background-color:color-mix(in oklab,var(--color-blue-400)10%,transparent)}}.bg-blue-500{background-color:var(--color-blue-500)}.bg-blue-500\/5{background-color:#3080ff0d}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/5{background-color:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.bg-blue-500\/10{background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/10{background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.bg-blue-500\/20{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/20{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.bg-blue-500\/30{background-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/30{background-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.bg-blue-500\/90{background-color:#3080ffe6}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/90{background-color:color-mix(in oklab,var(--color-blue-500)90%,transparent)}}.bg-blue-600{background-color:var(--color-blue-600)}.bg-blue-600\/20{background-color:#155dfc33}@supports (color:color-mix(in lab,red,red)){.bg-blue-600\/20{background-color:color-mix(in oklab,var(--color-blue-600)20%,transparent)}}.bg-cyan-500{background-color:var(--color-cyan-500)}.bg-cyan-500\/10{background-color:#00b7d71a}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/10{background-color:color-mix(in oklab,var(--color-cyan-500)10%,transparent)}}.bg-cyan-500\/20{background-color:#00b7d733}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/20{background-color:color-mix(in oklab,var(--color-cyan-500)20%,transparent)}}.bg-cyan-600\/20{background-color:#0092b533}@supports (color:color-mix(in lab,red,red)){.bg-cyan-600\/20{background-color:color-mix(in oklab,var(--color-cyan-600)20%,transparent)}}.bg-emerald-500\/20{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/20{background-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.bg-emerald-600\/20{background-color:#00976733}@supports (color:color-mix(in lab,red,red)){.bg-emerald-600\/20{background-color:color-mix(in oklab,var(--color-emerald-600)20%,transparent)}}.bg-emerald-700{background-color:var(--color-emerald-700)}.bg-fuchsia-500{background-color:var(--color-fuchsia-500)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-100{background-color:var(--color-gray-100)}.bg-gray-400{background-color:var(--color-gray-400)}.bg-gray-400\/10{background-color:#99a1af1a}@supports (color:color-mix(in lab,red,red)){.bg-gray-400\/10{background-color:color-mix(in oklab,var(--color-gray-400)10%,transparent)}}.bg-gray-500{background-color:var(--color-gray-500)}.bg-gray-500\/20{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.bg-gray-500\/20{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.bg-gray-600{background-color:var(--color-gray-600)}.bg-gray-800{background-color:var(--color-gray-800)}.bg-gray-900{background-color:var(--color-gray-900)}.bg-green-100{background-color:var(--color-green-100)}.bg-green-400{background-color:var(--color-green-400)}.bg-green-500{background-color:var(--color-green-500)}.bg-green-500\/10{background-color:#00c7581a}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/10{background-color:color-mix(in oklab,var(--color-green-500)10%,transparent)}}.bg-green-500\/15{background-color:#00c75826}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/15{background-color:color-mix(in oklab,var(--color-green-500)15%,transparent)}}.bg-green-500\/20{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/20{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.bg-green-600{background-color:var(--color-green-600)}.bg-green-600\/20{background-color:#00a54433}@supports (color:color-mix(in lab,red,red)){.bg-green-600\/20{background-color:color-mix(in oklab,var(--color-green-600)20%,transparent)}}.bg-green-600\/40{background-color:#00a54466}@supports (color:color-mix(in lab,red,red)){.bg-green-600\/40{background-color:color-mix(in oklab,var(--color-green-600)40%,transparent)}}.bg-green-900\/30{background-color:#0d542b4d}@supports (color:color-mix(in lab,red,red)){.bg-green-900\/30{background-color:color-mix(in oklab,var(--color-green-900)30%,transparent)}}.bg-green-900\/50{background-color:#0d542b80}@supports (color:color-mix(in lab,red,red)){.bg-green-900\/50{background-color:color-mix(in oklab,var(--color-green-900)50%,transparent)}}.bg-indigo-500\/20{background-color:#625fff33}@supports (color:color-mix(in lab,red,red)){.bg-indigo-500\/20{background-color:color-mix(in oklab,var(--color-indigo-500)20%,transparent)}}.bg-lime-500{background-color:var(--color-lime-500)}.bg-orange-400\/10{background-color:#ff8b1a1a}@supports (color:color-mix(in lab,red,red)){.bg-orange-400\/10{background-color:color-mix(in oklab,var(--color-orange-400)10%,transparent)}}.bg-orange-500{background-color:var(--color-orange-500)}.bg-orange-500\/10{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/10{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.bg-orange-500\/20{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/20{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.bg-orange-600{background-color:var(--color-orange-600)}.bg-orange-600\/20{background-color:#f0510033}@supports (color:color-mix(in lab,red,red)){.bg-orange-600\/20{background-color:color-mix(in oklab,var(--color-orange-600)20%,transparent)}}.bg-purple-400\/10{background-color:#c07eff1a}@supports (color:color-mix(in lab,red,red)){.bg-purple-400\/10{background-color:color-mix(in oklab,var(--color-purple-400)10%,transparent)}}.bg-purple-500{background-color:var(--color-purple-500)}.bg-purple-500\/10{background-color:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/10{background-color:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.bg-purple-500\/20{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/20{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.bg-purple-500\/80{background-color:#ac4bffcc}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/80{background-color:color-mix(in oklab,var(--color-purple-500)80%,transparent)}}.bg-purple-500\/90{background-color:#ac4bffe6}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/90{background-color:color-mix(in oklab,var(--color-purple-500)90%,transparent)}}.bg-purple-700{background-color:var(--color-purple-700)}.bg-red-50{background-color:var(--color-red-50)}.bg-red-100{background-color:var(--color-red-100)}.bg-red-400{background-color:var(--color-red-400)}.bg-red-500{background-color:var(--color-red-500)}.bg-red-500\/5{background-color:#fb2c360d}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/5{background-color:color-mix(in oklab,var(--color-red-500)5%,transparent)}}.bg-red-500\/10{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/10{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.bg-red-500\/15{background-color:#fb2c3626}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/15{background-color:color-mix(in oklab,var(--color-red-500)15%,transparent)}}.bg-red-500\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.bg-red-500\/30{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/30{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.bg-red-500\/40{background-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/40{background-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.bg-red-500\/80{background-color:#fb2c36cc}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/80{background-color:color-mix(in oklab,var(--color-red-500)80%,transparent)}}.bg-red-600{background-color:var(--color-red-600)}.bg-red-900\/30{background-color:#82181a4d}@supports (color:color-mix(in lab,red,red)){.bg-red-900\/30{background-color:color-mix(in oklab,var(--color-red-900)30%,transparent)}}.bg-red-950\/70{background-color:#460809b3}@supports (color:color-mix(in lab,red,red)){.bg-red-950\/70{background-color:color-mix(in oklab,var(--color-red-950)70%,transparent)}}.bg-rose-500\/20{background-color:#ff235733}@supports (color:color-mix(in lab,red,red)){.bg-rose-500\/20{background-color:color-mix(in oklab,var(--color-rose-500)20%,transparent)}}.bg-rose-600\/20{background-color:#e7004433}@supports (color:color-mix(in lab,red,red)){.bg-rose-600\/20{background-color:color-mix(in oklab,var(--color-rose-600)20%,transparent)}}.bg-sky-500{background-color:var(--color-sky-500)}.bg-sky-500\/20{background-color:#00a5ef33}@supports (color:color-mix(in lab,red,red)){.bg-sky-500\/20{background-color:color-mix(in oklab,var(--color-sky-500)20%,transparent)}}.bg-status-error,.bg-status-error\/10{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/10{background-color:color-mix(in oklab,var(--color-status-error)10%,transparent)}}.bg-status-error\/20{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/20{background-color:color-mix(in oklab,var(--color-status-error)20%,transparent)}}.bg-status-error\/80{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/80{background-color:color-mix(in oklab,var(--color-status-error)80%,transparent)}}.bg-status-ok,.bg-status-ok\/10{background-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.bg-status-ok\/10{background-color:color-mix(in oklab,var(--color-status-ok)10%,transparent)}}.bg-status-ok\/20{background-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.bg-status-ok\/20{background-color:color-mix(in oklab,var(--color-status-ok)20%,transparent)}}.bg-status-warning,.bg-status-warning\/10{background-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.bg-status-warning\/10{background-color:color-mix(in oklab,var(--color-status-warning)10%,transparent)}}.bg-status-warning\/20{background-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.bg-status-warning\/20{background-color:color-mix(in oklab,var(--color-status-warning)20%,transparent)}}.bg-teal-500{background-color:var(--color-teal-500)}.bg-teal-500\/20{background-color:#00baa733}@supports (color:color-mix(in lab,red,red)){.bg-teal-500\/20{background-color:color-mix(in oklab,var(--color-teal-500)20%,transparent)}}.bg-transparent{background-color:#0000}.bg-violet-500{background-color:var(--color-violet-500)}.bg-white{background-color:var(--color-white)}.bg-white\/10{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.bg-white\/10{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.bg-white\/20{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.bg-white\/20{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.bg-white\/50{background-color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.bg-white\/50{background-color:color-mix(in oklab,var(--color-white)50%,transparent)}}.bg-white\/70{background-color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.bg-white\/70{background-color:color-mix(in oklab,var(--color-white)70%,transparent)}}.bg-white\/90{background-color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.bg-white\/90{background-color:color-mix(in oklab,var(--color-white)90%,transparent)}}.bg-yellow-400{background-color:var(--color-yellow-400)}.bg-yellow-400\/10{background-color:#fac8001a}@supports (color:color-mix(in lab,red,red)){.bg-yellow-400\/10{background-color:color-mix(in oklab,var(--color-yellow-400)10%,transparent)}}.bg-yellow-400\/20{background-color:#fac80033}@supports (color:color-mix(in lab,red,red)){.bg-yellow-400\/20{background-color:color-mix(in oklab,var(--color-yellow-400)20%,transparent)}}.bg-yellow-500{background-color:var(--color-yellow-500)}.bg-yellow-500\/5{background-color:#edb2000d}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/5{background-color:color-mix(in oklab,var(--color-yellow-500)5%,transparent)}}.bg-yellow-500\/10{background-color:#edb2001a}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/10{background-color:color-mix(in oklab,var(--color-yellow-500)10%,transparent)}}.bg-yellow-500\/20{background-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/20{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.bg-zinc-600{background-color:var(--color-zinc-600)}.bg-zinc-700{background-color:var(--color-zinc-700)}.bg-zinc-700\/50{background-color:#3f3f4680}@supports (color:color-mix(in lab,red,red)){.bg-zinc-700\/50{background-color:color-mix(in oklab,var(--color-zinc-700)50%,transparent)}}.bg-zinc-800{background-color:var(--color-zinc-800)}.bg-zinc-800\/50{background-color:#27272a80}@supports (color:color-mix(in lab,red,red)){.bg-zinc-800\/50{background-color:color-mix(in oklab,var(--color-zinc-800)50%,transparent)}}.bg-zinc-900{background-color:var(--color-zinc-900)}.bg-zinc-900\/50{background-color:#18181b80}@supports (color:color-mix(in lab,red,red)){.bg-zinc-900\/50{background-color:color-mix(in oklab,var(--color-zinc-900)50%,transparent)}}.bg-gradient-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-r{--tw-gradient-position:to right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-t{--tw-gradient-position:to top in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-bambu-dark-secondary{--tw-gradient-from:var(--color-bambu-dark-secondary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-bambu-green\/10{--tw-gradient-from:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.from-bambu-green\/10{--tw-gradient-from:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.from-bambu-green\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-black\/80{--tw-gradient-from:#000c}@supports (color:color-mix(in lab,red,red)){.from-black\/80{--tw-gradient-from:color-mix(in oklab,var(--color-black)80%,transparent)}}.from-black\/80{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/5{--tw-gradient-from:#3080ff0d}@supports (color:color-mix(in lab,red,red)){.from-blue-500\/5{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.from-blue-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/10{--tw-gradient-from:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.from-blue-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.from-blue-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-gray-500\/10{--tw-gradient-from:#6a72821a}@supports (color:color-mix(in lab,red,red)){.from-gray-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-gray-500)10%,transparent)}}.from-gray-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-purple-500\/10{--tw-gradient-from:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.from-purple-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.from-purple-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-white\/10{--tw-gradient-from:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.from-white\/10{--tw-gradient-from:color-mix(in oklab,var(--color-white)10%,transparent)}}.from-white\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-yellow-500\/10{--tw-gradient-from:#edb2001a}@supports (color:color-mix(in lab,red,red)){.from-yellow-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-yellow-500)10%,transparent)}}.from-yellow-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.via-black\/60{--tw-gradient-via:#0009}@supports (color:color-mix(in lab,red,red)){.via-black\/60{--tw-gradient-via:color-mix(in oklab,var(--color-black)60%,transparent)}}.via-black\/60{--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-via)var(--tw-gradient-via-position),var(--tw-gradient-to)var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-bambu-dark-secondary{--tw-gradient-to:var(--color-bambu-dark-secondary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-bambu-dark-tertiary{--tw-gradient-to:var(--color-bambu-dark-tertiary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-transparent{--tw-gradient-to:transparent;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.bg-cover{background-size:cover}.bg-center{background-position:50%}.fill-yellow-400{fill:var(--color-yellow-400)}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.object-left{object-position:left}.p-0{padding:calc(var(--spacing)*0)}.p-0\.5{padding:calc(var(--spacing)*.5)}.p-1{padding:calc(var(--spacing)*1)}.p-1\.5{padding:calc(var(--spacing)*1.5)}.p-2{padding:calc(var(--spacing)*2)}.p-2\.5{padding:calc(var(--spacing)*2.5)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.p-8{padding:calc(var(--spacing)*8)}.p-12{padding:calc(var(--spacing)*12)}.\!px-1\.5{padding-inline:calc(var(--spacing)*1.5)!important}.\!px-3{padding-inline:calc(var(--spacing)*3)!important}.px-1{padding-inline:calc(var(--spacing)*1)}.px-1\.5{padding-inline:calc(var(--spacing)*1.5)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-2\.5{padding-inline:calc(var(--spacing)*2.5)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-5{padding-inline:calc(var(--spacing)*5)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-0\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-6{padding-block:calc(var(--spacing)*6)}.py-8{padding-block:calc(var(--spacing)*8)}.py-12{padding-block:calc(var(--spacing)*12)}.py-16{padding-block:calc(var(--spacing)*16)}.py-20{padding-block:calc(var(--spacing)*20)}.py-24{padding-block:calc(var(--spacing)*24)}.pt-0{padding-top:calc(var(--spacing)*0)}.pt-1{padding-top:calc(var(--spacing)*1)}.pt-2{padding-top:calc(var(--spacing)*2)}.pt-3{padding-top:calc(var(--spacing)*3)}.pt-4{padding-top:calc(var(--spacing)*4)}.pr-1{padding-right:calc(var(--spacing)*1)}.pr-2{padding-right:calc(var(--spacing)*2)}.pr-3{padding-right:calc(var(--spacing)*3)}.pr-4{padding-right:calc(var(--spacing)*4)}.pr-6{padding-right:calc(var(--spacing)*6)}.pr-7{padding-right:calc(var(--spacing)*7)}.pr-8{padding-right:calc(var(--spacing)*8)}.pr-10{padding-right:calc(var(--spacing)*10)}.pb-1{padding-bottom:calc(var(--spacing)*1)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-3{padding-bottom:calc(var(--spacing)*3)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pl-2{padding-left:calc(var(--spacing)*2)}.pl-4{padding-left:calc(var(--spacing)*4)}.pl-5{padding-left:calc(var(--spacing)*5)}.pl-6{padding-left:calc(var(--spacing)*6)}.pl-7{padding-left:calc(var(--spacing)*7)}.pl-8{padding-left:calc(var(--spacing)*8)}.pl-9{padding-left:calc(var(--spacing)*9)}.pl-10{padding-left:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-5xl{font-size:var(--text-5xl);line-height:var(--tw-leading,var(--text-5xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[6px\]{font-size:6px}.text-\[7px\]{font-size:7px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-none{--tw-leading:1;line-height:1}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-light{--tw-font-weight:var(--font-weight-light);font-weight:var(--font-weight-light)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.whitespace-pre-wrap{white-space:pre-wrap}.\!text-green-400{color:var(--color-green-400)!important}.\!text-white{color:var(--color-white)!important}.\!text-yellow-400{color:var(--color-yellow-400)!important}.text-amber-200{color:var(--color-amber-200)}.text-amber-200\/80{color:#fee685cc}@supports (color:color-mix(in lab,red,red)){.text-amber-200\/80{color:color-mix(in oklab,var(--color-amber-200)80%,transparent)}}.text-amber-300{color:var(--color-amber-300)}.text-amber-300\/60{color:#ffd23699}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/60{color:color-mix(in oklab,var(--color-amber-300)60%,transparent)}}.text-amber-300\/70{color:#ffd236b3}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/70{color:color-mix(in oklab,var(--color-amber-300)70%,transparent)}}.text-amber-300\/80{color:#ffd236cc}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/80{color:color-mix(in oklab,var(--color-amber-300)80%,transparent)}}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/70{color:#fcbb00b3}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/70{color:color-mix(in oklab,var(--color-amber-400)70%,transparent)}}.text-amber-500{color:var(--color-amber-500)}.text-amber-500\/80{color:#f99c00cc}@supports (color:color-mix(in lab,red,red)){.text-amber-500\/80{color:color-mix(in oklab,var(--color-amber-500)80%,transparent)}}.text-amber-600{color:var(--color-amber-600)}.text-amber-700{color:var(--color-amber-700)}.text-amber-800{color:var(--color-amber-800)}.text-bambu-dark-tertiary{color:var(--color-bambu-dark-tertiary)}.text-bambu-gray{color:var(--color-bambu-gray)}.text-bambu-gray-dark{color:var(--color-bambu-gray-dark)}.text-bambu-gray-light{color:var(--color-bambu-gray-light)}.text-bambu-gray\/30{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/30{color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.text-bambu-gray\/40{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/40{color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.text-bambu-gray\/50{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/50{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.text-bambu-gray\/60{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/60{color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.text-bambu-gray\/70{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/70{color:color-mix(in oklab,var(--color-bambu-gray)70%,transparent)}}.text-bambu-gray\/80{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/80{color:color-mix(in oklab,var(--color-bambu-gray)80%,transparent)}}.text-bambu-green,.text-bambu-green\/70{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.text-bambu-green\/70{color:color-mix(in oklab,var(--color-bambu-green)70%,transparent)}}.text-black{color:var(--color-black)}.text-black\/80{color:#000c}@supports (color:color-mix(in lab,red,red)){.text-black\/80{color:color-mix(in oklab,var(--color-black)80%,transparent)}}.text-blue-300{color:var(--color-blue-300)}.text-blue-300\/70{color:#90c5ffb3}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/70{color:color-mix(in oklab,var(--color-blue-300)70%,transparent)}}.text-blue-300\/80{color:#90c5ffcc}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/80{color:color-mix(in oklab,var(--color-blue-300)80%,transparent)}}.text-blue-400{color:var(--color-blue-400)}.text-blue-500{color:var(--color-blue-500)}.text-blue-500\/70{color:#3080ffb3}@supports (color:color-mix(in lab,red,red)){.text-blue-500\/70{color:color-mix(in oklab,var(--color-blue-500)70%,transparent)}}.text-blue-600{color:var(--color-blue-600)}.text-blue-700{color:var(--color-blue-700)}.text-cyan-300{color:var(--color-cyan-300)}.text-cyan-400{color:var(--color-cyan-400)}.text-emerald-300{color:var(--color-emerald-300)}.text-emerald-400{color:var(--color-emerald-400)}.text-gray-300{color:var(--color-gray-300)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-gray-800{color:var(--color-gray-800)}.text-gray-900{color:var(--color-gray-900)}.text-green-200{color:var(--color-green-200)}.text-green-300{color:var(--color-green-300)}.text-green-400{color:var(--color-green-400)}.text-green-400\/60{color:#05df7299}@supports (color:color-mix(in lab,red,red)){.text-green-400\/60{color:color-mix(in oklab,var(--color-green-400)60%,transparent)}}.text-green-500{color:var(--color-green-500)}.text-green-500\/60{color:#00c75899}@supports (color:color-mix(in lab,red,red)){.text-green-500\/60{color:color-mix(in oklab,var(--color-green-500)60%,transparent)}}.text-green-600{color:var(--color-green-600)}.text-indigo-400{color:var(--color-indigo-400)}.text-orange-200{color:var(--color-orange-200)}.text-orange-300{color:var(--color-orange-300)}.text-orange-400{color:var(--color-orange-400)}.text-orange-500{color:var(--color-orange-500)}.text-orange-600{color:var(--color-orange-600)}.text-orange-700{color:var(--color-orange-700)}.text-purple-300{color:var(--color-purple-300)}.text-purple-300\/70{color:#d9b3ffb3}@supports (color:color-mix(in lab,red,red)){.text-purple-300\/70{color:color-mix(in oklab,var(--color-purple-300)70%,transparent)}}.text-purple-400{color:var(--color-purple-400)}.text-purple-400\/80{color:#c07effcc}@supports (color:color-mix(in lab,red,red)){.text-purple-400\/80{color:color-mix(in oklab,var(--color-purple-400)80%,transparent)}}.text-purple-500{color:var(--color-purple-500)}.text-red-200{color:var(--color-red-200)}.text-red-300{color:var(--color-red-300)}.text-red-300\/80{color:#ffa3a3cc}@supports (color:color-mix(in lab,red,red)){.text-red-300\/80{color:color-mix(in oklab,var(--color-red-300)80%,transparent)}}.text-red-400{color:var(--color-red-400)}.text-red-400\/50{color:#ff656880}@supports (color:color-mix(in lab,red,red)){.text-red-400\/50{color:color-mix(in oklab,var(--color-red-400)50%,transparent)}}.text-red-400\/60{color:#ff656899}@supports (color:color-mix(in lab,red,red)){.text-red-400\/60{color:color-mix(in oklab,var(--color-red-400)60%,transparent)}}.text-red-400\/70{color:#ff6568b3}@supports (color:color-mix(in lab,red,red)){.text-red-400\/70{color:color-mix(in oklab,var(--color-red-400)70%,transparent)}}.text-red-500{color:var(--color-red-500)}.text-red-600{color:var(--color-red-600)}.text-rose-300{color:var(--color-rose-300)}.text-rose-400{color:var(--color-rose-400)}.text-sky-400{color:var(--color-sky-400)}.text-slate-300{color:var(--color-slate-300)}.text-status-error{color:var(--color-status-error)}.text-status-ok{color:var(--color-status-ok)}.text-status-warning{color:var(--color-status-warning)}.text-teal-400{color:var(--color-teal-400)}.text-white{color:var(--color-white)}.text-white\/30{color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.text-white\/30{color:color-mix(in oklab,var(--color-white)30%,transparent)}}.text-white\/40{color:#fff6}@supports (color:color-mix(in lab,red,red)){.text-white\/40{color:color-mix(in oklab,var(--color-white)40%,transparent)}}.text-white\/50{color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.text-white\/50{color:color-mix(in oklab,var(--color-white)50%,transparent)}}.text-white\/60{color:#fff9}@supports (color:color-mix(in lab,red,red)){.text-white\/60{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.text-white\/70{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.text-white\/80{color:#fffc}@supports (color:color-mix(in lab,red,red)){.text-white\/80{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.text-white\/90{color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.text-white\/90{color:color-mix(in oklab,var(--color-white)90%,transparent)}}.text-yellow-200{color:var(--color-yellow-200)}.text-yellow-200\/70{color:#fff085b3}@supports (color:color-mix(in lab,red,red)){.text-yellow-200\/70{color:color-mix(in oklab,var(--color-yellow-200)70%,transparent)}}.text-yellow-300{color:var(--color-yellow-300)}.text-yellow-400{color:var(--color-yellow-400)}.text-yellow-500{color:var(--color-yellow-500)}.text-yellow-500\/70{color:#edb200b3}@supports (color:color-mix(in lab,red,red)){.text-yellow-500\/70{color:color-mix(in oklab,var(--color-yellow-500)70%,transparent)}}.text-yellow-500\/80{color:#edb200cc}@supports (color:color-mix(in lab,red,red)){.text-yellow-500\/80{color:color-mix(in oklab,var(--color-yellow-500)80%,transparent)}}.text-yellow-600{color:var(--color-yellow-600)}.text-yellow-700{color:var(--color-yellow-700)}.text-zinc-100{color:var(--color-zinc-100)}.text-zinc-200{color:var(--color-zinc-200)}.text-zinc-300{color:var(--color-zinc-300)}.text-zinc-400{color:var(--color-zinc-400)}.text-zinc-500{color:var(--color-zinc-500)}.text-zinc-600{color:var(--color-zinc-600)}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.line-through{text-decoration-line:line-through}.underline{text-decoration-line:underline}.placeholder-bambu-gray::placeholder{color:var(--color-bambu-gray)}.placeholder-bambu-gray-dark::placeholder{color:var(--color-bambu-gray-dark)}.placeholder-bambu-gray\/40::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder-bambu-gray\/40::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.placeholder-bambu-gray\/50::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder-bambu-gray\/50::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.placeholder-bambu-gray\/60::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder-bambu-gray\/60::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.placeholder-gray-400::placeholder{color:var(--color-gray-400)}.placeholder-zinc-500::placeholder{color:var(--color-zinc-500)}.accent-amber-500{accent-color:var(--color-amber-500)}.accent-bambu-green{accent-color:var(--color-bambu-green)}.accent-green-500{accent-color:var(--color-green-500)}.\[color-scheme\:dark\]{color-scheme:dark}.opacity-0{opacity:0}.opacity-20{opacity:.2}.opacity-25{opacity:.25}.opacity-30{opacity:.3}.opacity-40{opacity:.4}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-80{opacity:.8}.opacity-100{opacity:1}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_6px_rgba\(34\,197\,94\,0\.5\)\]{--tw-shadow:0 0 6px var(--tw-shadow-color,#22c55e80);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow\/depth{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring,.ring-1{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-bambu-green\/20{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.shadow-bambu-green\/20{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)20%,transparent)var(--tw-shadow-alpha),transparent)}}.shadow-bambu-green\/25{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.shadow-bambu-green\/25{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)25%,transparent)var(--tw-shadow-alpha),transparent)}}.ring-bambu-green,.ring-bambu-green\/30{--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.ring-bambu-green\/30{--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.ring-blue-400\/50{--tw-ring-color:#54a2ff80}@supports (color:color-mix(in lab,red,red)){.ring-blue-400\/50{--tw-ring-color:color-mix(in oklab,var(--color-blue-400)50%,transparent)}}.ring-green-500{--tw-ring-color:var(--color-green-500)}.ring-white{--tw-ring-color:var(--color-white)}.ring-offset-1{--tw-ring-offset-width:1px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-2{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-bambu-dark{--tw-ring-offset-color:var(--color-bambu-dark)}.ring-offset-bambu-dark-secondary{--tw-ring-offset-color:var(--color-bambu-dark-secondary)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.blur-2xl{--tw-blur:blur(var(--blur-2xl));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow-lg{--tw-drop-shadow-size:drop-shadow(0 4px 4px var(--tw-drop-shadow-color,#00000026));--tw-drop-shadow:drop-shadow(var(--drop-shadow-lg));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow-md{--tw-drop-shadow-size:drop-shadow(0 3px 3px var(--tw-drop-shadow-color,#0000001f));--tw-drop-shadow:drop-shadow(var(--drop-shadow-md));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-500{--tw-duration:.5s;transition-duration:.5s}.duration-1000{--tw-duration:1s;transition-duration:1s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.select-none{-webkit-user-select:none;user-select:none}@media(hover:hover){.group-hover\:bg-bambu-green\/20:is(:where(.group):hover *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.group-hover\:bg-bambu-green\/20:is(:where(.group):hover *){background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.group-hover\:text-bambu-gray:is(:where(.group):hover *){color:var(--color-bambu-gray)}.group-hover\:text-bambu-green:is(:where(.group):hover *){color:var(--color-bambu-green)}.group-hover\:opacity-50:is(:where(.group):hover *){opacity:.5}.group-hover\:opacity-100:is(:where(.group):hover *),.group-hover\/resize\:opacity-100:is(:where(.group\/resize):hover *){opacity:1}.group-hover\/thumb\:block:is(:where(.group\/thumb):hover *){display:block}}.peer-checked\:bg-amber-500:is(:where(.peer):checked~*){background-color:var(--color-amber-500)}.peer-checked\:bg-bambu-green:is(:where(.peer):checked~*){background-color:var(--color-bambu-green)}.peer-focus\:outline-none:is(:where(.peer):focus~*){--tw-outline-style:none;outline-style:none}.peer-disabled\:cursor-not-allowed:is(:where(.peer):disabled~*){cursor:not-allowed}.placeholder\:text-bambu-gray::placeholder,.placeholder\:text-bambu-gray\/50::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-bambu-gray\/50::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:top-0:before{content:var(--tw-content);top:calc(var(--spacing)*0)}.before\:right-0:before{content:var(--tw-content);right:calc(var(--spacing)*0)}.before\:left-0:before{content:var(--tw-content);left:calc(var(--spacing)*0)}.before\:h-0\.5:before{content:var(--tw-content);height:calc(var(--spacing)*.5)}.before\:bg-bambu-green:before{content:var(--tw-content);background-color:var(--color-bambu-green)}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:top-\[2px\]:after{content:var(--tw-content);top:2px}.after\:left-\[2px\]:after{content:var(--tw-content);left:2px}.after\:h-4:after{content:var(--tw-content);height:calc(var(--spacing)*4)}.after\:h-5:after{content:var(--tw-content);height:calc(var(--spacing)*5)}.after\:w-4:after{content:var(--tw-content);width:calc(var(--spacing)*4)}.after\:w-5:after{content:var(--tw-content);width:calc(var(--spacing)*5)}.after\:rounded-full:after{content:var(--tw-content);border-radius:3.40282e38px}.after\:border:after{content:var(--tw-content);border-style:var(--tw-border-style);border-width:1px}.after\:border-gray-300:after{content:var(--tw-content);border-color:var(--color-gray-300)}.after\:bg-white:after{content:var(--tw-content);background-color:var(--color-white)}.after\:transition-all:after{content:var(--tw-content);transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.after\:content-\[\'\'\]:after{--tw-content:"";content:var(--tw-content)}.peer-checked\:after\:translate-x-full:is(:where(.peer):checked~*):after{content:var(--tw-content);--tw-translate-x:100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.peer-checked\:after\:border-white:is(:where(.peer):checked~*):after{content:var(--tw-content);border-color:var(--color-white)}.last\:border-0:last-child{border-style:var(--tw-border-style);border-width:0}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media(hover:hover){.hover\:z-20:hover{z-index:20}.hover\:scale-105:hover{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\:border-bambu-dark-tertiary\/80:hover{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-dark-tertiary\/80:hover{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.hover\:border-bambu-gray:hover{border-color:var(--color-bambu-gray)}.hover\:border-bambu-gray-dark:hover{border-color:var(--color-bambu-gray-dark)}.hover\:border-bambu-gray\/50:hover{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-gray\/50:hover{border-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.hover\:border-bambu-green:hover,.hover\:border-bambu-green\/50:hover{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-green\/50:hover{border-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.hover\:border-gray-400:hover{border-color:var(--color-gray-400)}.hover\:border-green-500\/50:hover{border-color:#00c75880}@supports (color:color-mix(in lab,red,red)){.hover\:border-green-500\/50:hover{border-color:color-mix(in oklab,var(--color-green-500)50%,transparent)}}.hover\:border-white:hover{border-color:var(--color-white)}.hover\:border-white\/40:hover{border-color:#fff6}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/40:hover{border-color:color-mix(in oklab,var(--color-white)40%,transparent)}}.hover\:\!bg-bambu-green\/80:hover{background-color:var(--color-bambu-green)!important}@supports (color:color-mix(in lab,red,red)){.hover\:\!bg-bambu-green\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)!important}}.hover\:\!bg-green-500\/20:hover{background-color:#00c75833!important}@supports (color:color-mix(in lab,red,red)){.hover\:\!bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)!important}}.hover\:\!bg-yellow-500\/20:hover{background-color:#edb20033!important}@supports (color:color-mix(in lab,red,red)){.hover\:\!bg-yellow-500\/20:hover{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)!important}}.hover\:bg-amber-400:hover{background-color:var(--color-amber-400)}.hover\:bg-amber-500\/20:hover{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/20:hover{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.hover\:bg-amber-500\/30:hover{background-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/30:hover{background-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.hover\:bg-bambu-dark:hover{background-color:var(--color-bambu-dark)}.hover\:bg-bambu-dark-secondary:hover,.hover\:bg-bambu-dark-secondary\/50:hover{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-secondary\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)50%,transparent)}}.hover\:bg-bambu-dark-secondary\/80:hover{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-secondary\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)80%,transparent)}}.hover\:bg-bambu-dark-tertiary:hover,.hover\:bg-bambu-dark-tertiary\/30:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.hover\:bg-bambu-dark-tertiary\/50:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.hover\:bg-bambu-dark-tertiary\/70:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/70:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)70%,transparent)}}.hover\:bg-bambu-dark-tertiary\/80:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.hover\:bg-bambu-dark\/50:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.hover\:bg-bambu-dark\/80:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)80%,transparent)}}.hover\:bg-bambu-gray-dark:hover{background-color:var(--color-bambu-gray-dark)}.hover\:bg-bambu-green:hover{background-color:var(--color-bambu-green)}.hover\:bg-bambu-green-dark:hover{background-color:var(--color-bambu-green-dark)}.hover\:bg-bambu-green-light:hover{background-color:var(--color-bambu-green-light)}.hover\:bg-bambu-green\/10:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/10:hover{background-color:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.hover\:bg-bambu-green\/20:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/20:hover{background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.hover\:bg-bambu-green\/30:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.hover\:bg-bambu-green\/50:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.hover\:bg-bambu-green\/80:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)}}.hover\:bg-black\/40:hover{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/40:hover{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.hover\:bg-black\/70:hover{background-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/70:hover{background-color:color-mix(in oklab,var(--color-black)70%,transparent)}}.hover\:bg-black\/80:hover{background-color:#000c}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/80:hover{background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.hover\:bg-blue-500\/30:hover{background-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-500\/30:hover{background-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.hover\:bg-gray-50:hover{background-color:var(--color-gray-50)}.hover\:bg-gray-100:hover{background-color:var(--color-gray-100)}.hover\:bg-gray-200:hover{background-color:var(--color-gray-200)}.hover\:bg-gray-700:hover{background-color:var(--color-gray-700)}.hover\:bg-green-500\/20:hover{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.hover\:bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.hover\:bg-green-700:hover{background-color:var(--color-green-700)}.hover\:bg-orange-400\/20:hover{background-color:#ff8b1a33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-orange-400\/20:hover{background-color:color-mix(in oklab,var(--color-orange-400)20%,transparent)}}.hover\:bg-purple-600\/90:hover{background-color:#9810fae6}@supports (color:color-mix(in lab,red,red)){.hover\:bg-purple-600\/90:hover{background-color:color-mix(in oklab,var(--color-purple-600)90%,transparent)}}.hover\:bg-red-200:hover{background-color:var(--color-red-200)}.hover\:bg-red-400\/10:hover{background-color:#ff65681a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-400\/10:hover{background-color:color-mix(in oklab,var(--color-red-400)10%,transparent)}}.hover\:bg-red-500\/10:hover{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/10:hover{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.hover\:bg-red-500\/30:hover{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/30:hover{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.hover\:bg-red-600:hover{background-color:var(--color-red-600)}.hover\:bg-red-700:hover{background-color:var(--color-red-700)}.hover\:bg-white\/5:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/5:hover{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.hover\:bg-white\/10:hover{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/10:hover{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.hover\:bg-white\/80:hover{background-color:#fffc}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/80:hover{background-color:color-mix(in oklab,var(--color-white)80%,transparent)}}.hover\:bg-yellow-500\/30:hover{background-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-yellow-500\/30:hover{background-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.hover\:bg-yellow-600:hover{background-color:var(--color-yellow-600)}.hover\:bg-zinc-600:hover{background-color:var(--color-zinc-600)}.hover\:bg-zinc-700:hover{background-color:var(--color-zinc-700)}.hover\:bg-zinc-700\/50:hover{background-color:#3f3f4680}@supports (color:color-mix(in lab,red,red)){.hover\:bg-zinc-700\/50:hover{background-color:color-mix(in oklab,var(--color-zinc-700)50%,transparent)}}.hover\:bg-zinc-800:hover{background-color:var(--color-zinc-800)}.hover\:text-amber-300:hover{color:var(--color-amber-300)}.hover\:text-amber-800:hover{color:var(--color-amber-800)}.hover\:text-bambu-gray:hover{color:var(--color-bambu-gray)}.hover\:text-bambu-green:hover{color:var(--color-bambu-green)}.hover\:text-bambu-green-light:hover{color:var(--color-bambu-green-light)}.hover\:text-bambu-green\/70:hover{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:text-bambu-green\/70:hover{color:color-mix(in oklab,var(--color-bambu-green)70%,transparent)}}.hover\:text-bambu-green\/80:hover{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:text-bambu-green\/80:hover{color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)}}.hover\:text-blue-300:hover{color:var(--color-blue-300)}.hover\:text-blue-600:hover{color:var(--color-blue-600)}.hover\:text-gray-600:hover{color:var(--color-gray-600)}.hover\:text-gray-900:hover{color:var(--color-gray-900)}.hover\:text-orange-300:hover{color:var(--color-orange-300)}.hover\:text-red-200:hover{color:var(--color-red-200)}.hover\:text-red-300:hover{color:var(--color-red-300)}.hover\:text-red-400:hover{color:var(--color-red-400)}.hover\:text-white:hover{color:var(--color-white)}.hover\:text-white\/70:hover{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/70:hover{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.hover\:text-white\/80:hover{color:#fffc}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/80:hover{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.hover\:text-yellow-400:hover{color:var(--color-yellow-400)}.hover\:text-zinc-200:hover{color:var(--color-zinc-200)}.hover\:text-zinc-300:hover{color:var(--color-zinc-300)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-70:hover{opacity:.7}.hover\:opacity-80:hover{opacity:.8}.hover\:shadow-lg:hover{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:shadow-xl:hover{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:shadow-bambu-green\/5:hover{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:shadow-bambu-green\/5:hover{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)5%,transparent)var(--tw-shadow-alpha),transparent)}}.hover\:shadow-bambu-green\/30:hover{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:shadow-bambu-green\/30:hover{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)30%,transparent)var(--tw-shadow-alpha),transparent)}}}.focus\:border-amber-500\/50:focus{border-color:#f99c0080}@supports (color:color-mix(in lab,red,red)){.focus\:border-amber-500\/50:focus{border-color:color-mix(in oklab,var(--color-amber-500)50%,transparent)}}.focus\:border-bambu-green:focus{border-color:var(--color-bambu-green)}.focus\:border-red-500:focus{border-color:var(--color-red-500)}.focus\:border-transparent:focus{border-color:#0000}.focus\:ring-1:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-bambu-gray:focus{--tw-ring-color:var(--color-bambu-gray)}.focus\:ring-bambu-green:focus,.focus\:ring-bambu-green\/50:focus{--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.focus\:ring-bambu-green\/50:focus{--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.focus\:ring-blue-500:focus{--tw-ring-color:var(--color-blue-500)}.focus\:ring-red-500:focus{--tw-ring-color:var(--color-red-500)}.focus\:ring-offset-0:focus{--tw-ring-offset-width:0px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:ring-offset-bambu-dark:focus{--tw-ring-offset-color:var(--color-bambu-dark)}.focus\:ring-offset-bambu-dark-secondary:focus{--tw-ring-offset-color:var(--color-bambu-dark-secondary)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.active\:scale-95:active{--tw-scale-x:95%;--tw-scale-y:95%;--tw-scale-z:95%;scale:var(--tw-scale-x)var(--tw-scale-y)}.active\:cursor-grabbing:active{cursor:grabbing}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}@media(hover:hover){.disabled\:hover\:bg-bambu-green:disabled:hover{background-color:var(--color-bambu-green)}}@media not all and (min-width:640px){.max-\[640px\]\:hidden{display:none}.max-\[640px\]\:w-full{width:100%}.max-\[640px\]\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.max-\[640px\]\:flex-col{flex-direction:column}.max-\[640px\]\:flex-wrap{flex-wrap:wrap}.max-\[640px\]\:items-center{align-items:center}.max-\[640px\]\:items-start{align-items:flex-start}}@media not all and (min-width:550px){.max-\[550px\]\:order-1{order:1}.max-\[550px\]\:order-2{order:2}.max-\[550px\]\:order-3{order:3}.max-\[550px\]\:order-4{order:4}.max-\[550px\]\:mt-1{margin-top:calc(var(--spacing)*1)}.max-\[550px\]\:w-full{width:100%}.max-\[550px\]\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.max-\[550px\]\:flex-col{flex-direction:column}.max-\[550px\]\:flex-wrap{flex-wrap:wrap}.max-\[550px\]\:items-center{align-items:center}.max-\[550px\]\:items-start{align-items:flex-start}.max-\[550px\]\:justify-end{justify-content:flex-end}.max-\[550px\]\:gap-1\.5{gap:calc(var(--spacing)*1.5)}.max-\[550px\]\:gap-3{gap:calc(var(--spacing)*3)}.max-\[550px\]\:self-start{align-self:flex-start}}@media(min-width:40rem){.sm\:col-span-1{grid-column:span 1/span 1}.sm\:mt-0{margin-top:calc(var(--spacing)*0)}.sm\:mt-2{margin-top:calc(var(--spacing)*2)}.sm\:mt-3{margin-top:calc(var(--spacing)*3)}.sm\:mr-1{margin-right:calc(var(--spacing)*1)}.sm\:mb-4{margin-bottom:calc(var(--spacing)*4)}.sm\:ml-auto{margin-left:auto}.sm\:block{display:block}.sm\:flex{display:flex}.sm\:grid{display:grid}.sm\:hidden{display:none}.sm\:inline{display:inline}.sm\:h-2{height:calc(var(--spacing)*2)}.sm\:h-3{height:calc(var(--spacing)*3)}.sm\:h-3\.5{height:calc(var(--spacing)*3.5)}.sm\:h-4{height:calc(var(--spacing)*4)}.sm\:h-5{height:calc(var(--spacing)*5)}.sm\:h-6{height:calc(var(--spacing)*6)}.sm\:h-10{height:calc(var(--spacing)*10)}.sm\:h-14{height:calc(var(--spacing)*14)}.sm\:w-3{width:calc(var(--spacing)*3)}.sm\:w-3\.5{width:calc(var(--spacing)*3.5)}.sm\:w-4{width:calc(var(--spacing)*4)}.sm\:w-5{width:calc(var(--spacing)*5)}.sm\:w-6{width:calc(var(--spacing)*6)}.sm\:w-10{width:calc(var(--spacing)*10)}.sm\:w-14{width:calc(var(--spacing)*14)}.sm\:w-16{width:calc(var(--spacing)*16)}.sm\:w-40{width:calc(var(--spacing)*40)}.sm\:w-auto{width:auto}.sm\:max-w-none{max-width:none}.sm\:max-w-xs{max-width:var(--container-xs)}.sm\:flex-1{flex:1}.sm\:flex-none{flex:none}.sm\:cursor-default{cursor:default}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:gap-1{gap:calc(var(--spacing)*1)}.sm\:gap-1\.5{gap:calc(var(--spacing)*1.5)}.sm\:gap-2{gap:calc(var(--spacing)*2)}.sm\:gap-3{gap:calc(var(--spacing)*3)}.sm\:gap-4{gap:calc(var(--spacing)*4)}.sm\:gap-6{gap:calc(var(--spacing)*6)}:where(.sm\:space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.sm\:space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}.sm\:border-bambu-dark-tertiary{border-color:var(--color-bambu-dark-tertiary)}.sm\:p-1\.5{padding:calc(var(--spacing)*1.5)}.sm\:p-2{padding:calc(var(--spacing)*2)}.sm\:p-3{padding:calc(var(--spacing)*3)}.sm\:p-4{padding:calc(var(--spacing)*4)}.sm\:px-2{padding-inline:calc(var(--spacing)*2)}.sm\:px-3{padding-inline:calc(var(--spacing)*3)}.sm\:text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.sm\:text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.sm\:text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.sm\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.sm\:text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}}@media(min-width:48rem){.md\:top-\[2px\]{top:2px}.md\:left-\[2px\]{left:2px}.md\:mx-0{margin-inline:calc(var(--spacing)*0)}.md\:block{display:block}.md\:inline{display:inline}.md\:h-4{height:calc(var(--spacing)*4)}.md\:h-5{height:calc(var(--spacing)*5)}.md\:min-h-0{min-height:calc(var(--spacing)*0)}.md\:w-4{width:calc(var(--spacing)*4)}.md\:w-9{width:calc(var(--spacing)*9)}.md\:min-w-\[200px\]{min-width:200px}.md\:flex-1{flex:1}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.md\:flex-row{flex-direction:row}.md\:flex-wrap{flex-wrap:wrap}.md\:items-center{align-items:center}.md\:gap-4{gap:calc(var(--spacing)*4)}.md\:p-6{padding:calc(var(--spacing)*6)}.md\:p-8{padding:calc(var(--spacing)*8)}.md\:px-0{padding-inline:calc(var(--spacing)*0)}.md\:py-2{padding-block:calc(var(--spacing)*2)}.md\:pb-0{padding-bottom:calc(var(--spacing)*0)}}@media(min-width:64rem){.lg\:static{position:static}.lg\:col-span-2{grid-column:span 2/span 2}.lg\:col-span-3{grid-column:span 3/span 3}.lg\:flex{display:flex}.lg\:hidden{display:none}.lg\:h-\[calc\(100vh-64px\)\]{height:calc(100vh - 64px)}.lg\:w-1\/3{width:33.3333%}.lg\:w-2\/3{width:66.6667%}.lg\:w-80{width:calc(var(--spacing)*80)}.lg\:w-\[480px\]{width:480px}.lg\:max-w-md{max-width:var(--container-md)}.lg\:max-w-sm{max-width:var(--container-sm)}.lg\:max-w-xl{max-width:var(--container-xl)}.lg\:flex-shrink-0{flex-shrink:0}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.lg\:flex-row{flex-direction:row}.lg\:gap-4{gap:calc(var(--spacing)*4)}.lg\:gap-6{gap:calc(var(--spacing)*6)}.lg\:gap-8{gap:calc(var(--spacing)*8)}.lg\:overflow-y-auto{overflow-y:auto}.lg\:p-8{padding:calc(var(--spacing)*8)}}@media(min-width:80rem){.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}@media(min-width:96rem){.\32xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}.dark\:border-amber-700:where(.dark,.dark *){border-color:var(--color-amber-700)}.dark\:border-amber-800:where(.dark,.dark *){border-color:var(--color-amber-800)}.dark\:border-bambu-dark-tertiary:where(.dark,.dark *),.dark\:border-bambu-dark-tertiary\/50:where(.dark,.dark *){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.dark\:border-bambu-dark-tertiary\/50:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.dark\:border-bambu-green\/40:where(.dark,.dark *){border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:border-bambu-green\/40:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.dark\:border-gray-600:where(.dark,.dark *){border-color:var(--color-gray-600)}.dark\:border-gray-700:where(.dark,.dark *){border-color:var(--color-gray-700)}.dark\:border-red-500\/30:where(.dark,.dark *){border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.dark\:border-red-500\/30:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.dark\:border-red-500\/40:where(.dark,.dark *){border-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.dark\:border-red-500\/40:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.dark\:bg-amber-500\/10:where(.dark,.dark *){background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-amber-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.dark\:bg-amber-900\/20:where(.dark,.dark *){background-color:#7b330633}@supports (color:color-mix(in lab,red,red)){.dark\:bg-amber-900\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-amber-900)20%,transparent)}}.dark\:bg-bambu-dark:where(.dark,.dark *){background-color:var(--color-bambu-dark)}.dark\:bg-bambu-dark-secondary:where(.dark,.dark *){background-color:var(--color-bambu-dark-secondary)}.dark\:bg-bambu-green\/20:where(.dark,.dark *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:bg-bambu-green\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.dark\:bg-black\/80:where(.dark,.dark *){background-color:#000c}@supports (color:color-mix(in lab,red,red)){.dark\:bg-black\/80:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.dark\:bg-blue-500\/10:where(.dark,.dark *){background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-blue-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.dark\:bg-blue-500\/20:where(.dark,.dark *){background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.dark\:bg-blue-500\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.dark\:bg-blue-900\/20:where(.dark,.dark *){background-color:#1c398e33}@supports (color:color-mix(in lab,red,red)){.dark\:bg-blue-900\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-900)20%,transparent)}}.dark\:bg-gray-700:where(.dark,.dark *){background-color:var(--color-gray-700)}.dark\:bg-gray-800:where(.dark,.dark *){background-color:var(--color-gray-800)}.dark\:bg-gray-900:where(.dark,.dark *){background-color:var(--color-gray-900)}.dark\:bg-red-500\/10:where(.dark,.dark *){background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-red-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.dark\:bg-red-500\/20:where(.dark,.dark *){background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.dark\:bg-red-500\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.dark\:text-amber-200:where(.dark,.dark *){color:var(--color-amber-200)}.dark\:text-amber-300:where(.dark,.dark *){color:var(--color-amber-300)}.dark\:text-amber-400:where(.dark,.dark *){color:var(--color-amber-400)}.dark\:text-bambu-gray:where(.dark,.dark *),.dark\:text-bambu-gray\/30:where(.dark,.dark *){color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-gray\/30:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.dark\:text-bambu-gray\/50:where(.dark,.dark *){color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-gray\/50:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.dark\:text-bambu-green:where(.dark,.dark *),.dark\:text-bambu-green\/60:where(.dark,.dark *){color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-green\/60:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-green)60%,transparent)}}.dark\:text-blue-200:where(.dark,.dark *){color:var(--color-blue-200)}.dark\:text-blue-200\/80:where(.dark,.dark *){color:#bedbffcc}@supports (color:color-mix(in lab,red,red)){.dark\:text-blue-200\/80:where(.dark,.dark *){color:color-mix(in oklab,var(--color-blue-200)80%,transparent)}}.dark\:text-blue-300:where(.dark,.dark *){color:var(--color-blue-300)}.dark\:text-blue-300\/60:where(.dark,.dark *){color:#90c5ff99}@supports (color:color-mix(in lab,red,red)){.dark\:text-blue-300\/60:where(.dark,.dark *){color:color-mix(in oklab,var(--color-blue-300)60%,transparent)}}.dark\:text-blue-400:where(.dark,.dark *){color:var(--color-blue-400)}.dark\:text-gray-300:where(.dark,.dark *){color:var(--color-gray-300)}.dark\:text-gray-400:where(.dark,.dark *){color:var(--color-gray-400)}.dark\:text-orange-200:where(.dark,.dark *){color:var(--color-orange-200)}.dark\:text-orange-400:where(.dark,.dark *){color:var(--color-orange-400)}.dark\:text-red-400:where(.dark,.dark *){color:var(--color-red-400)}.dark\:text-red-400\/70:where(.dark,.dark *){color:#ff6568b3}@supports (color:color-mix(in lab,red,red)){.dark\:text-red-400\/70:where(.dark,.dark *){color:color-mix(in oklab,var(--color-red-400)70%,transparent)}}.dark\:text-white:where(.dark,.dark *){color:var(--color-white)}.dark\:text-yellow-200:where(.dark,.dark *){color:var(--color-yellow-200)}.dark\:text-yellow-200\/70:where(.dark,.dark *){color:#fff085b3}@supports (color:color-mix(in lab,red,red)){.dark\:text-yellow-200\/70:where(.dark,.dark *){color:color-mix(in oklab,var(--color-yellow-200)70%,transparent)}}@media(hover:hover){.dark\:hover\:border-gray-500:where(.dark,.dark *):hover{border-color:var(--color-gray-500)}.dark\:hover\:bg-bambu-dark-tertiary:where(.dark,.dark *):hover{background-color:var(--color-bambu-dark-tertiary)}.dark\:hover\:bg-bambu-dark\/50:where(.dark,.dark *):hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.dark\:hover\:bg-bambu-dark\/50:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.dark\:hover\:bg-gray-600:where(.dark,.dark *):hover{background-color:var(--color-gray-600)}.dark\:hover\:bg-red-500\/30:where(.dark,.dark *):hover{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.dark\:hover\:bg-red-500\/30:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.dark\:hover\:text-amber-200:where(.dark,.dark *):hover{color:var(--color-amber-200)}.dark\:hover\:text-gray-300:where(.dark,.dark *):hover{color:var(--color-gray-300)}.dark\:hover\:text-white:where(.dark,.dark *):hover{color:var(--color-white)}}.\[\&\:\:-webkit-inner-spin-button\]\:appearance-none::-webkit-inner-spin-button{appearance:none}.\[\&\:\:-webkit-outer-spin-button\]\:appearance-none::-webkit-outer-spin-button{appearance:none}.\[\&\:\:-webkit-slider-thumb\]\:h-3::-webkit-slider-thumb{height:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:w-3::-webkit-slider-thumb{width:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:cursor-pointer::-webkit-slider-thumb{cursor:pointer}.\[\&\:\:-webkit-slider-thumb\]\:appearance-none::-webkit-slider-thumb{appearance:none}.\[\&\:\:-webkit-slider-thumb\]\:rounded-full::-webkit-slider-thumb{border-radius:3.40282e38px}.\[\&\:\:-webkit-slider-thumb\]\:bg-bambu-green::-webkit-slider-thumb{background-color:var(--color-bambu-green)}}:root{--accent:#00ae42;--accent-light:#00c64d;--accent-dark:#009438;--status-ok:#22c55e;--status-error:#ef4444;--status-warning:#f59e0b;--bg-primary:#f5f5f5;--bg-secondary:#fff;--bg-tertiary:#e5e5e5;--text-primary:#1a1a1a;--text-secondary:#4a4a4a;--text-muted:#6b6b6b;--text-tertiary:gray;--border-color:#d4d4d4;--card-shadow:0 2px 8px #00000014;--glow-color:transparent;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,system-ui,sans-serif;font-weight:400;line-height:1.5}.dark{--bg-primary:#1a1a1a;--bg-secondary:#2d2d2d;--bg-tertiary:#3d3d3d;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:gray;--text-tertiary:#4a4a4a;--border-color:#3d3d3d;--card-shadow:0 4px 16px #0006}.bg-warm{--bg-primary:#faf8f5;--bg-secondary:#fffefa;--bg-tertiary:#e8e4dd;--text-primary:#2d2a26;--text-secondary:#5c5750;--text-muted:#7a756c;--text-tertiary:#9a9590;--border-color:#d8d4cc}.bg-cool{--bg-primary:#f0f4f8;--bg-secondary:#fff;--bg-tertiary:#dce4ec;--text-primary:#1a2530;--text-secondary:#4a5568;--text-muted:#6b7a8a;--text-tertiary:#8a9aaa;--border-color:#c8d4e0}.dark.bg-neutral{--bg-primary:#1a1a1a;--bg-secondary:#2d2d2d;--bg-tertiary:#3d3d3d;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:gray;--text-tertiary:#4a4a4a;--border-color:#3d3d3d}.dark.bg-warm{--bg-primary:#1c1a18;--bg-secondary:#2e2a26;--bg-tertiary:#3e3a36;--text-primary:#f5f0ea;--text-secondary:#b0a898;--text-muted:#8a8278;--text-tertiary:#5a5248;--border-color:#3e3a36}.dark.bg-cool{--bg-primary:#181c20;--bg-secondary:#262c32;--bg-tertiary:#363e46;--text-primary:#f0f4f8;--text-secondary:#98a8b8;--text-muted:#788898;--text-tertiary:#4a5a6a;--border-color:#363e46}.dark.bg-oled{--bg-primary:#000;--bg-secondary:#141414;--bg-tertiary:#1f1f1f;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:#707070;--text-tertiary:#404040;--border-color:#2a2a2a}.dark.bg-slate{--bg-primary:#0f172a;--bg-secondary:#1e293b;--bg-tertiary:#334155;--text-primary:#f1f5f9;--text-secondary:#94a3b8;--text-muted:#64748b;--text-tertiary:#475569;--border-color:#334155}.dark.bg-forest{--bg-primary:#121a16;--bg-secondary:#1c2a22;--bg-tertiary:#2a3d30;--text-primary:#e8f5ec;--text-secondary:#8aa894;--text-muted:#6a8874;--text-tertiary:#4a6854;--border-color:#2a3d30}.printer-control-buttons-container{container-type:inline-size}@container (max-width:220px){.printer-control-buttons{flex-direction:column;align-items:stretch}.printer-control-buttons>button{width:100%}}.style-glow{--card-shadow:0 2px 8px #00000014,0 0 25px var(--accent)}@supports (color:color-mix(in lab,red,red)){.style-glow{--card-shadow:0 2px 8px #00000014,0 0 25px color-mix(in srgb,var(--accent)12%,transparent)}}.dark.style-glow{--card-shadow:0 4px 20px #00000080,0 0 40px var(--accent)}@supports (color:color-mix(in lab,red,red)){.dark.style-glow{--card-shadow:0 4px 20px #00000080,0 0 40px color-mix(in srgb,var(--accent)15%,transparent)}}.style-vibrant{--card-shadow:0 8px 30px #00000026,0 2px 8px #0000001a}.dark.style-vibrant{--card-shadow:0 10px 40px #0009,0 4px 12px #0006}.accent-green{--accent:#00ae42;--accent-light:#00c64d;--accent-dark:#009438}.accent-teal{--accent:#14b8a6;--accent-light:#2dd4bf;--accent-dark:#0d9488}.accent-blue{--accent:#3b82f6;--accent-light:#60a5fa;--accent-dark:#2563eb}.accent-orange{--accent:#f97316;--accent-light:#fb923c;--accent-dark:#ea580c}.accent-purple{--accent:#8b5cf6;--accent-light:#a78bfa;--accent-dark:#7c3aed}.accent-red{--accent:#ef4444;--accent-light:#f87171;--accent-dark:#dc2626}body{background-color:var(--bg-primary);color:var(--text-primary);min-height:100vh;margin:0;transition:background-color .2s,color .2s}#root{min-height:100vh}.text-white{color:var(--text-primary)}.bg-bambu-dark,.bg-bambu-dark-secondary,.bg-bambu-dark-tertiary,.border-bambu-dark-tertiary{transition:background-color .2s,border-color .2s}@keyframes slide-in{0%{opacity:0;transform:translate(100%)}to{opacity:1;transform:translate(0)}}.animate-slide-in{animation:.2s ease-out slide-in}.icon-theme{opacity:.5}.dark .icon-theme{filter:invert();opacity:.4}.icon-green{filter:invert(48%)sepia(89%)saturate(459%)hue-rotate(93deg)brightness(95%)contrast(92%);opacity:1}.icon-heating{filter:invert(50%)sepia()saturate(1000%)hue-rotate(360deg)brightness()contrast();opacity:1}.dark .jogpad-theme{filter:brightness(.35)contrast(1.2)}.ams-empty-slot{background:repeating-linear-gradient(45deg,#444,#444 2px,#222 2px 4px)}.dark .ams-empty-slot{background:repeating-linear-gradient(45deg,#555,#555 2px,#333 2px 4px)}.touch-manipulation{touch-action:manipulation}.safe-area-bottom{padding-bottom:env(safe-area-inset-bottom,0)}.safe-area-top{padding-top:env(safe-area-inset-top,0)}.scrollbar-hide{-ms-overflow-style:none;scrollbar-width:none}.scrollbar-hide::-webkit-scrollbar{display:none}@keyframes slide-in-left{0%{transform:translate(-100%)}to{transform:translate(0)}}.animate-slide-in-left{animation:.3s ease-out slide-in-left}.card-shadow{box-shadow:var(--card-shadow)}.calendar-scroll{scrollbar-width:thin;scrollbar-color:var(--text-muted)transparent}@supports (color:color-mix(in lab,red,red)){.calendar-scroll{scrollbar-color:color-mix(in srgb,var(--text-muted)60%,transparent)transparent}}.calendar-scroll::-webkit-scrollbar{width:8px}.calendar-scroll::-webkit-scrollbar-track{background:0 0}.calendar-scroll::-webkit-scrollbar-thumb{background-color:var(--text-muted)}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb{background-color:color-mix(in srgb,var(--text-muted)60%,transparent)}}.calendar-scroll::-webkit-scrollbar-thumb{border:2px solid var(--bg-secondary);border-radius:999px}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb{border:2px solid color-mix(in srgb,var(--bg-secondary)70%,transparent)}}.calendar-scroll::-webkit-scrollbar-thumb:hover{background-color:var(--text-muted)}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb:hover{background-color:color-mix(in srgb,var(--text-muted)80%,transparent)}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@property --tw-content{syntax:"*";inherits:false;initial-value:""}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:""}}}.hg-theme-default{background-color:#ececec;border-radius:5px;box-sizing:border-box;font-family:HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;overflow:hidden;padding:5px;touch-action:manipulation;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}.hg-theme-default .hg-button span,.hg-theme-default .hg-button span svg{pointer-events:none}.hg-theme-default button.hg-button{border-width:0;font-size:inherit}.hg-theme-default .hg-button{display:inline-block;flex-grow:1}.hg-theme-default .hg-row{display:flex}.hg-theme-default .hg-row:not(:last-child){margin-bottom:5px}.hg-theme-default .hg-row .hg-button-container,.hg-theme-default .hg-row .hg-button:not(:last-child){margin-right:5px}.hg-theme-default .hg-row>div:last-child{margin-right:0}.hg-theme-default .hg-row .hg-button-container{display:flex}.hg-theme-default .hg-button{align-items:center;background:#fff;border-bottom:1px solid #b5b5b5;border-radius:5px;box-shadow:0 0 3px -1px #0000004d;box-sizing:border-box;cursor:pointer;display:flex;height:40px;justify-content:center;padding:5px;-webkit-tap-highlight-color:rgba(0,0,0,0)}.hg-theme-default .hg-button.hg-standardBtn{width:20px}.hg-theme-default .hg-button.hg-activeButton{background:#efefef}.hg-theme-default.hg-layout-numeric .hg-button{align-items:center;display:flex;height:60px;justify-content:center;width:33.3%}.hg-theme-default .hg-button.hg-button-numpadadd,.hg-theme-default .hg-button.hg-button-numpadenter{height:85px}.hg-theme-default .hg-button.hg-button-numpad0{width:105px}.hg-theme-default .hg-button.hg-button-com{max-width:85px}.hg-theme-default .hg-button.hg-standardBtn.hg-button-at{max-width:45px}.hg-theme-default .hg-button.hg-selectedButton{background:#05194687;color:#fff}.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=".com"]{max-width:82px}.hg-theme-default .hg-button.hg-standardBtn[data-skbtn="@"]{max-width:60px}.hg-candidate-box{background:#ececec;border-bottom:2px solid #b5b5b5;border-radius:5px;display:inline-flex;margin-top:-10px;position:absolute;transform:translateY(-100%);-webkit-user-select:none;-moz-user-select:none;user-select:none}ul.hg-candidate-box-list{display:flex;flex:1;list-style:none;margin:0;padding:0}li.hg-candidate-box-list-item{align-items:center;display:flex;height:40px;justify-content:center;width:40px}li.hg-candidate-box-list-item:hover{background:#00000008;cursor:pointer}li.hg-candidate-box-list-item:active{background:#0000001a}.hg-candidate-box-prev:before{content:"◄"}.hg-candidate-box-next:before{content:"►"}.hg-candidate-box-next,.hg-candidate-box-prev{align-items:center;color:#969696;cursor:pointer;display:flex;padding:0 10px}.hg-candidate-box-next{border-bottom-right-radius:5px;border-top-right-radius:5px}.hg-candidate-box-prev{border-bottom-left-radius:5px;border-top-left-radius:5px}.hg-candidate-box-btn-active{color:#444}.simple-keyboard.vkb-theme{background:#1a1a1a;border-top:1px solid #333;padding:8px 4px;font-family:inherit}.simple-keyboard.vkb-theme .hg-row{display:flex!important;flex-direction:row!important;flex-wrap:nowrap!important;gap:4px;margin-bottom:4px}.simple-keyboard.vkb-theme .hg-row:last-child{margin-bottom:0}.simple-keyboard.vkb-theme .hg-button{display:inline-flex!important;align-items:center;justify-content:center;flex-grow:1;flex-shrink:1;flex-basis:auto;background:#2d2d2d;color:#e0e0e0;border:none;border-radius:6px;height:44px;font-size:16px;font-weight:500;box-shadow:0 1px 2px #0000004d;transition:background .1s;cursor:pointer;padding:0 2px;min-width:0}.simple-keyboard.vkb-theme .hg-button:active{background:#00ae42;color:#fff}.simple-keyboard.vkb-theme .hg-button-bksp,.simple-keyboard.vkb-theme .hg-button-shift,.simple-keyboard.vkb-theme .hg-button-lock{background:#3a3a3a;color:#aaa;flex-grow:1.5}.simple-keyboard.vkb-theme .hg-button-close{background:#3a3a3a;color:#aaa;flex-grow:2;font-weight:600}.simple-keyboard.vkb-theme .hg-button-close:active{background:#555}.simple-keyboard.vkb-theme .hg-button-space{flex-grow:7}.simple-keyboard.vkb-theme .hg-activeButton{background:#00ae42;color:#fff} +@import"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap";@layer properties,theme,base,components,utilities;@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-red-950:oklch(25.8% .092 26.042);--color-orange-200:oklch(90.1% .076 70.697);--color-orange-300:oklch(83.7% .128 66.29);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-600:oklch(64.6% .222 41.116);--color-orange-700:oklch(55.3% .195 38.402);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-700:oklch(55.5% .163 48.998);--color-amber-800:oklch(47.3% .137 46.201);--color-amber-900:oklch(41.4% .112 45.904);--color-yellow-200:oklch(94.5% .129 101.54);--color-yellow-300:oklch(90.5% .182 98.111);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-yellow-600:oklch(68.1% .162 75.834);--color-yellow-700:oklch(55.4% .135 66.442);--color-lime-500:oklch(76.8% .233 130.85);--color-green-100:oklch(96.2% .044 156.743);--color-green-200:oklch(92.5% .084 155.995);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-green-800:oklch(44.8% .119 151.328);--color-green-900:oklch(39.3% .095 152.535);--color-emerald-300:oklch(84.5% .143 164.978);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-600:oklch(59.6% .145 163.225);--color-emerald-700:oklch(50.8% .118 165.612);--color-teal-400:oklch(77.7% .152 181.912);--color-teal-500:oklch(70.4% .14 182.503);--color-cyan-300:oklch(86.5% .127 207.078);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-500:oklch(71.5% .143 215.221);--color-cyan-600:oklch(60.9% .126 221.723);--color-sky-400:oklch(74.6% .16 232.661);--color-sky-500:oklch(68.5% .169 237.323);--color-blue-50:oklch(97% .014 254.604);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-blue-900:oklch(37.9% .146 265.522);--color-indigo-400:oklch(67.3% .182 276.935);--color-indigo-500:oklch(58.5% .233 277.117);--color-violet-500:oklch(60.6% .25 292.717);--color-purple-300:oklch(82.7% .119 306.383);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-500:oklch(62.7% .265 303.9);--color-purple-600:oklch(55.8% .288 302.321);--color-purple-700:oklch(49.6% .265 301.924);--color-fuchsia-500:oklch(66.7% .295 322.15);--color-rose-300:oklch(81% .117 11.638);--color-rose-400:oklch(71.2% .194 13.428);--color-rose-500:oklch(64.5% .246 16.439);--color-rose-600:oklch(58.6% .253 17.585);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-500:oklch(55.4% .046 257.417);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-gray-900:oklch(21% .034 264.665);--color-zinc-100:oklch(96.7% .001 286.375);--color-zinc-200:oklch(92% .004 286.32);--color-zinc-300:oklch(87.1% .006 286.286);--color-zinc-400:oklch(70.5% .015 286.067);--color-zinc-500:oklch(55.2% .016 285.938);--color-zinc-600:oklch(44.2% .017 285.786);--color-zinc-700:oklch(37% .013 285.805);--color-zinc-800:oklch(27.4% .006 286.033);--color-zinc-900:oklch(21% .006 285.885);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-xl:36rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--container-5xl:64rem;--container-6xl:72rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--text-3xl:1.875rem;--text-3xl--line-height: 1.2 ;--text-5xl:3rem;--text-5xl--line-height:1;--font-weight-light:300;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--tracking-wider:.05em;--tracking-widest:.1em;--leading-tight:1.25;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--drop-shadow-md:0 3px 3px #0000001f;--drop-shadow-lg:0 4px 4px #00000026;--ease-out:cubic-bezier(0,0,.2,1);--ease-in-out:cubic-bezier(.4,0,.2,1);--animate-spin:spin 1s linear infinite;--animate-ping:ping 1s cubic-bezier(0,0,.2,1)infinite;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--blur-sm:8px;--blur-2xl:40px;--aspect-video:16/9;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-bambu-green:var(--accent);--color-bambu-green-light:var(--accent-light);--color-bambu-green-dark:var(--accent-dark);--color-status-ok:var(--status-ok);--color-status-error:var(--status-error);--color-status-warning:var(--status-warning);--color-bambu-dark:var(--bg-primary);--color-bambu-dark-secondary:var(--bg-secondary);--color-bambu-dark-tertiary:var(--bg-tertiary);--color-bambu-gray:var(--text-muted);--color-bambu-gray-light:var(--text-secondary);--color-bambu-gray-dark:var(--text-tertiary)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.-inset-4{inset:calc(var(--spacing)*-4)}.inset-0{inset:calc(var(--spacing)*0)}.inset-2{inset:calc(var(--spacing)*2)}.inset-x-0{inset-inline:calc(var(--spacing)*0)}.inset-y-0{inset-block:calc(var(--spacing)*0)}.-top-0\.5{top:calc(var(--spacing)*-.5)}.-top-1{top:calc(var(--spacing)*-1)}.-top-1\.5{top:calc(var(--spacing)*-1.5)}.top-0{top:calc(var(--spacing)*0)}.top-0\.5{top:calc(var(--spacing)*.5)}.top-1{top:calc(var(--spacing)*1)}.top-1\.5{top:calc(var(--spacing)*1.5)}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing)*2)}.top-2\.5{top:calc(var(--spacing)*2.5)}.top-3{top:calc(var(--spacing)*3)}.top-4{top:calc(var(--spacing)*4)}.top-8{top:calc(var(--spacing)*8)}.top-\[2px\]{top:2px}.top-\[3px\]{top:3px}.top-\[52px\]{top:52px}.top-full{top:100%}.-right-0\.5{right:calc(var(--spacing)*-.5)}.-right-1{right:calc(var(--spacing)*-1)}.-right-1\.5{right:calc(var(--spacing)*-1.5)}.-right-2{right:calc(var(--spacing)*-2)}.right-0{right:calc(var(--spacing)*0)}.right-1{right:calc(var(--spacing)*1)}.right-1\.5{right:calc(var(--spacing)*1.5)}.right-2{right:calc(var(--spacing)*2)}.right-3{right:calc(var(--spacing)*3)}.right-4{right:calc(var(--spacing)*4)}.right-6{right:calc(var(--spacing)*6)}.right-12{right:calc(var(--spacing)*12)}.right-20{right:calc(var(--spacing)*20)}.right-\[5\.5rem\]{right:5.5rem}.right-full{right:100%}.-bottom-0\.5{bottom:calc(var(--spacing)*-.5)}.-bottom-1{bottom:calc(var(--spacing)*-1)}.-bottom-2{bottom:calc(var(--spacing)*-2)}.-bottom-7{bottom:calc(var(--spacing)*-7)}.bottom-0{bottom:calc(var(--spacing)*0)}.bottom-1{bottom:calc(var(--spacing)*1)}.bottom-2{bottom:calc(var(--spacing)*2)}.bottom-3{bottom:calc(var(--spacing)*3)}.bottom-4{bottom:calc(var(--spacing)*4)}.bottom-6{bottom:calc(var(--spacing)*6)}.bottom-8{bottom:calc(var(--spacing)*8)}.bottom-20{bottom:calc(var(--spacing)*20)}.bottom-full{bottom:100%}.-left-2{left:calc(var(--spacing)*-2)}.left-0{left:calc(var(--spacing)*0)}.left-0\.5{left:calc(var(--spacing)*.5)}.left-1{left:calc(var(--spacing)*1)}.left-1\/2{left:50%}.left-2{left:calc(var(--spacing)*2)}.left-2\.5{left:calc(var(--spacing)*2.5)}.left-3{left:calc(var(--spacing)*3)}.left-4{left:calc(var(--spacing)*4)}.left-10{left:calc(var(--spacing)*10)}.left-12{left:calc(var(--spacing)*12)}.left-\[2px\]{left:2px}.left-\[3px\]{left:3px}.left-full{left:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-60,.z-\[60\]{z-index:60}.z-\[100\]{z-index:100}.z-\[101\]{z-index:101}.z-\[9998\]{z-index:9998}.z-\[9999\]{z-index:9999}.col-span-1{grid-column:span 1/span 1}.col-span-2{grid-column:span 2/span 2}.col-span-3{grid-column:span 3/span 3}.col-span-4{grid-column:span 4/span 4}.col-span-full{grid-column:1/-1}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.-m-4{margin:calc(var(--spacing)*-4)}.-mx-4{margin-inline:calc(var(--spacing)*-4)}.mx-1{margin-inline:calc(var(--spacing)*1)}.mx-1\.5{margin-inline:calc(var(--spacing)*1.5)}.mx-2{margin-inline:calc(var(--spacing)*2)}.mx-4{margin-inline:calc(var(--spacing)*4)}.mx-5{margin-inline:calc(var(--spacing)*5)}.mx-auto{margin-inline:auto}.my-1{margin-block:calc(var(--spacing)*1)}.my-2{margin-block:calc(var(--spacing)*2)}.my-8{margin-block:calc(var(--spacing)*8)}.-mt-0\.5{margin-top:calc(var(--spacing)*-.5)}.-mt-2{margin-top:calc(var(--spacing)*-2)}.mt-0\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-1\.5{margin-top:calc(var(--spacing)*1.5)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-6{margin-top:calc(var(--spacing)*6)}.mt-8{margin-top:calc(var(--spacing)*8)}.mt-14{margin-top:calc(var(--spacing)*14)}.mt-auto{margin-top:auto}.mr-1{margin-right:calc(var(--spacing)*1)}.mr-1\.5{margin-right:calc(var(--spacing)*1.5)}.mr-2{margin-right:calc(var(--spacing)*2)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-4{margin-right:calc(var(--spacing)*4)}.mr-auto{margin-right:auto}.-mb-px{margin-bottom:-1px}.mb-0\.5{margin-bottom:calc(var(--spacing)*.5)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-1\.5{margin-bottom:calc(var(--spacing)*1.5)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-2\.5{margin-bottom:calc(var(--spacing)*2.5)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.mb-5{margin-bottom:calc(var(--spacing)*5)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.-ml-1{margin-left:calc(var(--spacing)*-1)}.-ml-2{margin-left:calc(var(--spacing)*-2)}.ml-0\.5{margin-left:calc(var(--spacing)*.5)}.ml-1{margin-left:calc(var(--spacing)*1)}.ml-1\.5{margin-left:calc(var(--spacing)*1.5)}.ml-2{margin-left:calc(var(--spacing)*2)}.ml-3{margin-left:calc(var(--spacing)*3)}.ml-4{margin-left:calc(var(--spacing)*4)}.ml-6{margin-left:calc(var(--spacing)*6)}.ml-7{margin-left:calc(var(--spacing)*7)}.ml-9{margin-left:calc(var(--spacing)*9)}.ml-14{margin-left:calc(var(--spacing)*14)}.ml-16{margin-left:calc(var(--spacing)*16)}.ml-64{margin-left:calc(var(--spacing)*64)}.ml-auto{margin-left:auto}.line-clamp-1{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.aspect-square{aspect-ratio:1}.aspect-video{aspect-ratio:var(--aspect-video)}.h-0{height:calc(var(--spacing)*0)}.h-0\.5{height:calc(var(--spacing)*.5)}.h-1{height:calc(var(--spacing)*1)}.h-1\.5{height:calc(var(--spacing)*1.5)}.h-2{height:calc(var(--spacing)*2)}.h-2\.5{height:calc(var(--spacing)*2.5)}.h-3{height:calc(var(--spacing)*3)}.h-3\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-9{height:calc(var(--spacing)*9)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-14{height:calc(var(--spacing)*14)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-24{height:calc(var(--spacing)*24)}.h-32{height:calc(var(--spacing)*32)}.h-40{height:calc(var(--spacing)*40)}.h-48{height:calc(var(--spacing)*48)}.h-64{height:calc(var(--spacing)*64)}.h-80{height:calc(var(--spacing)*80)}.h-\[18px\]{height:18px}.h-\[38px\]{height:38px}.h-\[40px\]{height:40px}.h-\[48px\]{height:48px}.h-\[80vh\]{height:80vh}.h-\[160px\]{height:160px}.h-\[300px\]{height:300px}.h-\[calc\(100\%-40px\)\]{height:calc(100% - 40px)}.h-full{height:100%}.h-px{height:1px}.h-screen{height:100vh}.max-h-40{max-height:calc(var(--spacing)*40)}.max-h-48{max-height:calc(var(--spacing)*48)}.max-h-60{max-height:calc(var(--spacing)*60)}.max-h-64{max-height:calc(var(--spacing)*64)}.max-h-80{max-height:calc(var(--spacing)*80)}.max-h-96{max-height:calc(var(--spacing)*96)}.max-h-\[60vh\]{max-height:60vh}.max-h-\[80vh\]{max-height:80vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[300px\]{max-height:300px}.max-h-\[400px\]{max-height:400px}.max-h-\[500px\]{max-height:500px}.max-h-\[600px\]{max-height:600px}.max-h-\[calc\(90vh-80px\)\]{max-height:calc(90vh - 80px)}.max-h-\[calc\(100vh-320px\)\]{max-height:calc(100vh - 320px)}.max-h-full{max-height:100%}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-\[36px\]{min-height:36px}.min-h-\[40px\]{min-height:40px}.min-h-\[44px\]{min-height:44px}.min-h-\[48px\]{min-height:48px}.min-h-\[80px\]{min-height:80px}.min-h-\[120px\]{min-height:120px}.min-h-\[300px\]{min-height:300px}.min-h-\[400px\]{min-height:400px}.min-h-\[calc\(100vh-64px\)\]{min-height:calc(100vh - 64px)}.min-h-screen{min-height:100vh}.w-0{width:calc(var(--spacing)*0)}.w-0\.5{width:calc(var(--spacing)*.5)}.w-1{width:calc(var(--spacing)*1)}.w-1\.5{width:calc(var(--spacing)*1.5)}.w-1\/2{width:50%}.w-1\/3{width:33.3333%}.w-2{width:calc(var(--spacing)*2)}.w-2\.5{width:calc(var(--spacing)*2.5)}.w-3{width:calc(var(--spacing)*3)}.w-3\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-4\.5{width:calc(var(--spacing)*4.5)}.w-5{width:calc(var(--spacing)*5)}.w-5\/12{width:41.6667%}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-7\/12{width:58.3333%}.w-8{width:calc(var(--spacing)*8)}.w-9{width:calc(var(--spacing)*9)}.w-10{width:calc(var(--spacing)*10)}.w-11{width:calc(var(--spacing)*11)}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.w-16{width:calc(var(--spacing)*16)}.w-20{width:calc(var(--spacing)*20)}.w-24{width:calc(var(--spacing)*24)}.w-32{width:calc(var(--spacing)*32)}.w-36{width:calc(var(--spacing)*36)}.w-40{width:calc(var(--spacing)*40)}.w-44{width:calc(var(--spacing)*44)}.w-48{width:calc(var(--spacing)*48)}.w-52{width:calc(var(--spacing)*52)}.w-56{width:calc(var(--spacing)*56)}.w-64{width:calc(var(--spacing)*64)}.w-72{width:calc(var(--spacing)*72)}.w-96{width:calc(var(--spacing)*96)}.w-\[240px\]{width:240px}.w-\[340px\]{width:340px}.w-\[420px\]{width:420px}.w-\[560px\]{width:560px}.w-auto{width:auto}.w-fit{width:fit-content}.w-full{width:100%}.w-px{width:1px}.w-screen{width:100vw}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-5xl{max-width:var(--container-5xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-32{max-width:calc(var(--spacing)*32)}.max-w-\[40\%\]{max-width:40%}.max-w-\[50\%\]{max-width:50%}.max-w-\[80px\]{max-width:80px}.max-w-\[90vw\]{max-width:90vw}.max-w-\[100px\]{max-width:100px}.max-w-\[120px\]{max-width:120px}.max-w-\[150px\]{max-width:150px}.max-w-\[160px\]{max-width:160px}.max-w-\[200px\]{max-width:200px}.max-w-\[280px\]{max-width:280px}.max-w-\[600px\]{max-width:600px}.max-w-full{max-width:100%}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.max-w-xl{max-width:var(--container-xl)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-48{min-width:calc(var(--spacing)*48)}.min-w-\[16px\]{min-width:16px}.min-w-\[18px\]{min-width:18px}.min-w-\[32px\]{min-width:32px}.min-w-\[40px\]{min-width:40px}.min-w-\[48px\]{min-width:48px}.min-w-\[50px\]{min-width:50px}.min-w-\[80px\]{min-width:80px}.min-w-\[100px\]{min-width:100px}.min-w-\[120px\]{min-width:120px}.min-w-\[130px\]{min-width:130px}.min-w-\[140px\]{min-width:140px}.min-w-\[150px\]{min-width:150px}.min-w-\[160px\]{min-width:160px}.min-w-\[180px\]{min-width:180px}.min-w-\[200px\]{min-width:200px}.min-w-full{min-width:100%}.flex-1{flex:1}.flex-\[2_1_190px\]{flex:2 190px}.flex-shrink{flex-shrink:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-x-full{--tw-translate-x:-100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0\.5{--tw-translate-x:calc(var(--spacing)*.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-1{--tw-translate-x:calc(var(--spacing)*1);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-3\.5{--tw-translate-x:calc(var(--spacing)*3.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-4{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-5{--tw-translate-x:calc(var(--spacing)*5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-6{--tw-translate-x:calc(var(--spacing)*6);translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.scale-105{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-\[1\.02\]{scale:1.02}.-rotate-90{rotate:-90deg}.rotate-90{rotate:90deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-col-resize{cursor:col-resize}.cursor-default{cursor:default}.cursor-ew-resize{cursor:ew-resize}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-row-resize{cursor:row-resize}.cursor-se-resize{cursor:se-resize}.touch-manipulation{touch-action:manipulation}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.\[appearance\:textfield\]{appearance:textfield}.appearance-none{appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}.grid-cols-\[auto_1fr_100px_100px_100px_80px\]{grid-template-columns:auto 1fr 100px 100px 100px 80px}.grid-cols-\[auto_1fr_120px_100px_100px_100px_80px\]{grid-template-columns:auto 1fr 120px 100px 100px 100px 80px}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0{gap:calc(var(--spacing)*0)}.gap-0\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-2\.5{gap:calc(var(--spacing)*2.5)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-6{gap:calc(var(--spacing)*6)}.gap-8{gap:calc(var(--spacing)*8)}.gap-\[3px\]{gap:3px}:where(.space-y-0>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*0)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*0)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*4)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*4)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*6)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*6)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}.gap-x-3{column-gap:calc(var(--spacing)*3)}.gap-x-4{column-gap:calc(var(--spacing)*4)}.gap-x-6{column-gap:calc(var(--spacing)*6)}.gap-y-1{row-gap:calc(var(--spacing)*1)}.gap-y-2{row-gap:calc(var(--spacing)*2)}.gap-y-3{row-gap:calc(var(--spacing)*3)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px*var(--tw-divide-y-reverse));border-bottom-width:calc(1px*calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-bambu-dark-tertiary>:not(:last-child)),:where(.divide-bambu-dark-tertiary\/30>:not(:last-child)){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){:where(.divide-bambu-dark-tertiary\/30>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}:where(.divide-bambu-gray\/20>:not(:last-child)){border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){:where(.divide-bambu-gray\/20>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-none{border-radius:0}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-t-lg{border-top-left-radius:var(--radius-lg);border-top-right-radius:var(--radius-lg)}.rounded-t-xl{border-top-left-radius:var(--radius-xl);border-top-right-radius:var(--radius-xl)}.\!rounded-l-none{border-top-left-radius:0!important;border-bottom-left-radius:0!important}.rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-l-lg{border-top-left-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.rounded-tl{border-top-left-radius:.25rem}.\!rounded-r-none{border-top-right-radius:0!important;border-bottom-right-radius:0!important}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.rounded-r-lg{border-top-right-radius:var(--radius-lg);border-bottom-right-radius:var(--radius-lg)}.rounded-b-lg{border-bottom-right-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-4{border-style:var(--tw-border-style);border-width:4px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-2{border-top-style:var(--tw-border-style);border-top-width:2px}.border-t-\[5px\]{border-top-style:var(--tw-border-style);border-top-width:5px}.border-t-\[6px\]{border-top-style:var(--tw-border-style);border-top-width:6px}.\!border-r-0{border-right-style:var(--tw-border-style)!important;border-right-width:0!important}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-\[5px\]{border-right-style:var(--tw-border-style);border-right-width:5px}.border-r-\[6px\]{border-right-style:var(--tw-border-style);border-right-width:6px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-b-\[6px\]{border-bottom-style:var(--tw-border-style);border-bottom-width:6px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-l-\[5px\]{border-left-style:var(--tw-border-style);border-left-width:5px}.border-l-\[6px\]{border-left-style:var(--tw-border-style);border-left-width:6px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.\!border-green-500{border-color:var(--color-green-500)!important}.\!border-yellow-500{border-color:var(--color-yellow-500)!important}.border-amber-200{border-color:var(--color-amber-200)}.border-amber-300{border-color:var(--color-amber-300)}.border-amber-500{border-color:var(--color-amber-500)}.border-amber-500\/20{border-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/20{border-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.border-amber-500\/30{border-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/30{border-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.border-bambu-dark-secondary{border-color:var(--color-bambu-dark-secondary)}.border-bambu-dark-tertiary,.border-bambu-dark-tertiary\/20{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/20{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)20%,transparent)}}.border-bambu-dark-tertiary\/30{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/30{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.border-bambu-dark-tertiary\/40{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/40{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.border-bambu-dark-tertiary\/50{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/50{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.border-bambu-gray,.border-bambu-gray\/20{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/20{border-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.border-bambu-gray\/30{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/30{border-color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.border-bambu-gray\/50{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/50{border-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.border-bambu-green,.border-bambu-green\/20{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/20{border-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.border-bambu-green\/30{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/30{border-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.border-bambu-green\/40{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/40{border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.border-bambu-green\/50{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/50{border-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.border-black\/20{border-color:#0003}@supports (color:color-mix(in lab,red,red)){.border-black\/20{border-color:color-mix(in oklab,var(--color-black)20%,transparent)}}.border-blue-400\/20{border-color:#54a2ff33}@supports (color:color-mix(in lab,red,red)){.border-blue-400\/20{border-color:color-mix(in oklab,var(--color-blue-400)20%,transparent)}}.border-blue-400\/50{border-color:#54a2ff80}@supports (color:color-mix(in lab,red,red)){.border-blue-400\/50{border-color:color-mix(in oklab,var(--color-blue-400)50%,transparent)}}.border-blue-500{border-color:var(--color-blue-500)}.border-blue-500\/20{border-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/20{border-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.border-blue-500\/30{border-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/30{border-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.border-blue-500\/40{border-color:#3080ff66}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/40{border-color:color-mix(in oklab,var(--color-blue-500)40%,transparent)}}.border-blue-500\/50{border-color:#3080ff80}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/50{border-color:color-mix(in oklab,var(--color-blue-500)50%,transparent)}}.border-gray-200{border-color:var(--color-gray-200)}.border-gray-300{border-color:var(--color-gray-300)}.border-gray-400\/20{border-color:#99a1af33}@supports (color:color-mix(in lab,red,red)){.border-gray-400\/20{border-color:color-mix(in oklab,var(--color-gray-400)20%,transparent)}}.border-gray-500{border-color:var(--color-gray-500)}.border-gray-500\/20{border-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.border-gray-500\/20{border-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.border-gray-700{border-color:var(--color-gray-700)}.border-green-300{border-color:var(--color-green-300)}.border-green-500{border-color:var(--color-green-500)}.border-green-500\/10{border-color:#00c7581a}@supports (color:color-mix(in lab,red,red)){.border-green-500\/10{border-color:color-mix(in oklab,var(--color-green-500)10%,transparent)}}.border-green-500\/20{border-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.border-green-500\/20{border-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500)30%,transparent)}}.border-green-500\/40{border-color:#00c75866}@supports (color:color-mix(in lab,red,red)){.border-green-500\/40{border-color:color-mix(in oklab,var(--color-green-500)40%,transparent)}}.border-green-500\/50{border-color:#00c75880}@supports (color:color-mix(in lab,red,red)){.border-green-500\/50{border-color:color-mix(in oklab,var(--color-green-500)50%,transparent)}}.border-green-800{border-color:var(--color-green-800)}.border-orange-400\/20{border-color:#ff8b1a33}@supports (color:color-mix(in lab,red,red)){.border-orange-400\/20{border-color:color-mix(in oklab,var(--color-orange-400)20%,transparent)}}.border-orange-400\/50{border-color:#ff8b1a80}@supports (color:color-mix(in lab,red,red)){.border-orange-400\/50{border-color:color-mix(in oklab,var(--color-orange-400)50%,transparent)}}.border-orange-500\/20{border-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/20{border-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.border-orange-500\/30{border-color:#fe6e004d}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/30{border-color:color-mix(in oklab,var(--color-orange-500)30%,transparent)}}.border-purple-400\/20{border-color:#c07eff33}@supports (color:color-mix(in lab,red,red)){.border-purple-400\/20{border-color:color-mix(in oklab,var(--color-purple-400)20%,transparent)}}.border-purple-500{border-color:var(--color-purple-500)}.border-purple-500\/20{border-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/20{border-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.border-purple-500\/30{border-color:#ac4bff4d}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/30{border-color:color-mix(in oklab,var(--color-purple-500)30%,transparent)}}.border-red-300{border-color:var(--color-red-300)}.border-red-500{border-color:var(--color-red-500)}.border-red-500\/20{border-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.border-red-500\/20{border-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.border-red-500\/40{border-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.border-red-500\/40{border-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.border-red-500\/50{border-color:#fb2c3680}@supports (color:color-mix(in lab,red,red)){.border-red-500\/50{border-color:color-mix(in oklab,var(--color-red-500)50%,transparent)}}.border-red-800{border-color:var(--color-red-800)}.border-red-800\/70{border-color:#9f0712b3}@supports (color:color-mix(in lab,red,red)){.border-red-800\/70{border-color:color-mix(in oklab,var(--color-red-800)70%,transparent)}}.border-slate-500{border-color:var(--color-slate-500)}.border-status-error\/20{border-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.border-status-error\/20{border-color:color-mix(in oklab,var(--color-status-error)20%,transparent)}}.border-status-ok,.border-status-ok\/20{border-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.border-status-ok\/20{border-color:color-mix(in oklab,var(--color-status-ok)20%,transparent)}}.border-status-warning\/20{border-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.border-status-warning\/20{border-color:color-mix(in oklab,var(--color-status-warning)20%,transparent)}}.border-transparent{border-color:#0000}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.border-white\/20{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.border-white\/20{border-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.border-white\/30{border-color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.border-white\/30{border-color:color-mix(in oklab,var(--color-white)30%,transparent)}}.border-yellow-400\/20{border-color:#fac80033}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/20{border-color:color-mix(in oklab,var(--color-yellow-400)20%,transparent)}}.border-yellow-400\/30{border-color:#fac8004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/30{border-color:color-mix(in oklab,var(--color-yellow-400)30%,transparent)}}.border-yellow-400\/50{border-color:#fac80080}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/50{border-color:color-mix(in oklab,var(--color-yellow-400)50%,transparent)}}.border-yellow-500{border-color:var(--color-yellow-500)}.border-yellow-500\/20{border-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/20{border-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.border-yellow-500\/30{border-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/30{border-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.border-yellow-500\/50{border-color:#edb20080}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/50{border-color:color-mix(in oklab,var(--color-yellow-500)50%,transparent)}}.border-zinc-500{border-color:var(--color-zinc-500)}.border-zinc-600{border-color:var(--color-zinc-600)}.border-zinc-700{border-color:var(--color-zinc-700)}.border-zinc-700\/50{border-color:#3f3f4680}@supports (color:color-mix(in lab,red,red)){.border-zinc-700\/50{border-color:color-mix(in oklab,var(--color-zinc-700)50%,transparent)}}.border-zinc-800{border-color:var(--color-zinc-800)}.border-t-bambu-dark-tertiary{border-top-color:var(--color-bambu-dark-tertiary)}.border-t-transparent{border-top-color:#0000}.border-r-transparent{border-right-color:#0000}.border-b-bambu-dark-tertiary{border-bottom-color:var(--color-bambu-dark-tertiary)}.border-l-transparent{border-left-color:#0000}.border-l-yellow-500{border-left-color:var(--color-yellow-500)}.\!bg-bambu-green{background-color:var(--color-bambu-green)!important}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-500\/5{background-color:#f99c000d}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/5{background-color:color-mix(in oklab,var(--color-amber-500)5%,transparent)}}.bg-amber-500\/10{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/10{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.bg-amber-500\/20{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/20{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.bg-amber-600\/20{background-color:#dd740033}@supports (color:color-mix(in lab,red,red)){.bg-amber-600\/20{background-color:color-mix(in oklab,var(--color-amber-600)20%,transparent)}}.bg-bambu-dark{background-color:var(--color-bambu-dark)}.bg-bambu-dark-secondary,.bg-bambu-dark-secondary\/30{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/30{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)30%,transparent)}}.bg-bambu-dark-secondary\/50{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/50{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)50%,transparent)}}.bg-bambu-dark-secondary\/60{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/60{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)60%,transparent)}}.bg-bambu-dark-secondary\/90{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/90{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)90%,transparent)}}.bg-bambu-dark-secondary\/95{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/95{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)95%,transparent)}}.bg-bambu-dark-tertiary,.bg-bambu-dark-tertiary\/20{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/20{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)20%,transparent)}}.bg-bambu-dark-tertiary\/30{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/30{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.bg-bambu-dark-tertiary\/40{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/40{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.bg-bambu-dark-tertiary\/50{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/50{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.bg-bambu-dark-tertiary\/70{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/70{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)70%,transparent)}}.bg-bambu-dark-tertiary\/80{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/80{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.bg-bambu-dark\/20{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/20{background-color:color-mix(in oklab,var(--color-bambu-dark)20%,transparent)}}.bg-bambu-dark\/30{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/30{background-color:color-mix(in oklab,var(--color-bambu-dark)30%,transparent)}}.bg-bambu-dark\/50{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/50{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.bg-bambu-dark\/80{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/80{background-color:color-mix(in oklab,var(--color-bambu-dark)80%,transparent)}}.bg-bambu-dark\/90{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/90{background-color:color-mix(in oklab,var(--color-bambu-dark)90%,transparent)}}.bg-bambu-gray,.bg-bambu-gray\/10{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/10{background-color:color-mix(in oklab,var(--color-bambu-gray)10%,transparent)}}.bg-bambu-gray\/20{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/20{background-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.bg-bambu-gray\/30{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/30{background-color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.bg-bambu-gray\/50{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/50{background-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.bg-bambu-gray\/60{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/60{background-color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.bg-bambu-gray\/90{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/90{background-color:color-mix(in oklab,var(--color-bambu-gray)90%,transparent)}}.bg-bambu-green,.bg-bambu-green\/5{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/5{background-color:color-mix(in oklab,var(--color-bambu-green)5%,transparent)}}.bg-bambu-green\/10{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/10{background-color:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.bg-bambu-green\/15{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/15{background-color:color-mix(in oklab,var(--color-bambu-green)15%,transparent)}}.bg-bambu-green\/20{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/20{background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.bg-bambu-green\/30{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/30{background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.bg-bambu-green\/50{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/50{background-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.bg-bambu-green\/75{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/75{background-color:color-mix(in oklab,var(--color-bambu-green)75%,transparent)}}.bg-bambu-green\/90{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/90{background-color:color-mix(in oklab,var(--color-bambu-green)90%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/15{background-color:#00000026}@supports (color:color-mix(in lab,red,red)){.bg-black\/15{background-color:color-mix(in oklab,var(--color-black)15%,transparent)}}.bg-black\/30{background-color:#0000004d}@supports (color:color-mix(in lab,red,red)){.bg-black\/30{background-color:color-mix(in oklab,var(--color-black)30%,transparent)}}.bg-black\/40{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.bg-black\/40{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black)60%,transparent)}}.bg-black\/70{background-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.bg-black\/70{background-color:color-mix(in oklab,var(--color-black)70%,transparent)}}.bg-black\/80{background-color:#000c}@supports (color:color-mix(in lab,red,red)){.bg-black\/80{background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.bg-black\/90{background-color:#000000e6}@supports (color:color-mix(in lab,red,red)){.bg-black\/90{background-color:color-mix(in oklab,var(--color-black)90%,transparent)}}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-blue-400{background-color:var(--color-blue-400)}.bg-blue-400\/10{background-color:#54a2ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-400\/10{background-color:color-mix(in oklab,var(--color-blue-400)10%,transparent)}}.bg-blue-500{background-color:var(--color-blue-500)}.bg-blue-500\/5{background-color:#3080ff0d}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/5{background-color:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.bg-blue-500\/10{background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/10{background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.bg-blue-500\/20{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/20{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.bg-blue-500\/30{background-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/30{background-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.bg-blue-500\/90{background-color:#3080ffe6}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/90{background-color:color-mix(in oklab,var(--color-blue-500)90%,transparent)}}.bg-blue-600{background-color:var(--color-blue-600)}.bg-blue-600\/20{background-color:#155dfc33}@supports (color:color-mix(in lab,red,red)){.bg-blue-600\/20{background-color:color-mix(in oklab,var(--color-blue-600)20%,transparent)}}.bg-cyan-500{background-color:var(--color-cyan-500)}.bg-cyan-500\/10{background-color:#00b7d71a}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/10{background-color:color-mix(in oklab,var(--color-cyan-500)10%,transparent)}}.bg-cyan-500\/20{background-color:#00b7d733}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/20{background-color:color-mix(in oklab,var(--color-cyan-500)20%,transparent)}}.bg-cyan-600\/20{background-color:#0092b533}@supports (color:color-mix(in lab,red,red)){.bg-cyan-600\/20{background-color:color-mix(in oklab,var(--color-cyan-600)20%,transparent)}}.bg-emerald-500\/20{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/20{background-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.bg-emerald-600\/20{background-color:#00976733}@supports (color:color-mix(in lab,red,red)){.bg-emerald-600\/20{background-color:color-mix(in oklab,var(--color-emerald-600)20%,transparent)}}.bg-emerald-700{background-color:var(--color-emerald-700)}.bg-fuchsia-500{background-color:var(--color-fuchsia-500)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-100{background-color:var(--color-gray-100)}.bg-gray-400{background-color:var(--color-gray-400)}.bg-gray-400\/10{background-color:#99a1af1a}@supports (color:color-mix(in lab,red,red)){.bg-gray-400\/10{background-color:color-mix(in oklab,var(--color-gray-400)10%,transparent)}}.bg-gray-500{background-color:var(--color-gray-500)}.bg-gray-500\/20{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.bg-gray-500\/20{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.bg-gray-600{background-color:var(--color-gray-600)}.bg-gray-800{background-color:var(--color-gray-800)}.bg-gray-900{background-color:var(--color-gray-900)}.bg-green-100{background-color:var(--color-green-100)}.bg-green-400{background-color:var(--color-green-400)}.bg-green-500{background-color:var(--color-green-500)}.bg-green-500\/10{background-color:#00c7581a}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/10{background-color:color-mix(in oklab,var(--color-green-500)10%,transparent)}}.bg-green-500\/15{background-color:#00c75826}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/15{background-color:color-mix(in oklab,var(--color-green-500)15%,transparent)}}.bg-green-500\/20{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/20{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.bg-green-600{background-color:var(--color-green-600)}.bg-green-600\/20{background-color:#00a54433}@supports (color:color-mix(in lab,red,red)){.bg-green-600\/20{background-color:color-mix(in oklab,var(--color-green-600)20%,transparent)}}.bg-green-600\/40{background-color:#00a54466}@supports (color:color-mix(in lab,red,red)){.bg-green-600\/40{background-color:color-mix(in oklab,var(--color-green-600)40%,transparent)}}.bg-green-900\/30{background-color:#0d542b4d}@supports (color:color-mix(in lab,red,red)){.bg-green-900\/30{background-color:color-mix(in oklab,var(--color-green-900)30%,transparent)}}.bg-green-900\/50{background-color:#0d542b80}@supports (color:color-mix(in lab,red,red)){.bg-green-900\/50{background-color:color-mix(in oklab,var(--color-green-900)50%,transparent)}}.bg-indigo-500\/20{background-color:#625fff33}@supports (color:color-mix(in lab,red,red)){.bg-indigo-500\/20{background-color:color-mix(in oklab,var(--color-indigo-500)20%,transparent)}}.bg-lime-500{background-color:var(--color-lime-500)}.bg-orange-400\/10{background-color:#ff8b1a1a}@supports (color:color-mix(in lab,red,red)){.bg-orange-400\/10{background-color:color-mix(in oklab,var(--color-orange-400)10%,transparent)}}.bg-orange-500{background-color:var(--color-orange-500)}.bg-orange-500\/10{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/10{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.bg-orange-500\/20{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/20{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.bg-orange-600{background-color:var(--color-orange-600)}.bg-orange-600\/20{background-color:#f0510033}@supports (color:color-mix(in lab,red,red)){.bg-orange-600\/20{background-color:color-mix(in oklab,var(--color-orange-600)20%,transparent)}}.bg-purple-400\/10{background-color:#c07eff1a}@supports (color:color-mix(in lab,red,red)){.bg-purple-400\/10{background-color:color-mix(in oklab,var(--color-purple-400)10%,transparent)}}.bg-purple-500{background-color:var(--color-purple-500)}.bg-purple-500\/10{background-color:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/10{background-color:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.bg-purple-500\/20{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/20{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.bg-purple-500\/80{background-color:#ac4bffcc}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/80{background-color:color-mix(in oklab,var(--color-purple-500)80%,transparent)}}.bg-purple-500\/90{background-color:#ac4bffe6}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/90{background-color:color-mix(in oklab,var(--color-purple-500)90%,transparent)}}.bg-purple-700{background-color:var(--color-purple-700)}.bg-red-50{background-color:var(--color-red-50)}.bg-red-100{background-color:var(--color-red-100)}.bg-red-400{background-color:var(--color-red-400)}.bg-red-500{background-color:var(--color-red-500)}.bg-red-500\/5{background-color:#fb2c360d}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/5{background-color:color-mix(in oklab,var(--color-red-500)5%,transparent)}}.bg-red-500\/10{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/10{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.bg-red-500\/15{background-color:#fb2c3626}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/15{background-color:color-mix(in oklab,var(--color-red-500)15%,transparent)}}.bg-red-500\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.bg-red-500\/30{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/30{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.bg-red-500\/40{background-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/40{background-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.bg-red-500\/80{background-color:#fb2c36cc}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/80{background-color:color-mix(in oklab,var(--color-red-500)80%,transparent)}}.bg-red-600{background-color:var(--color-red-600)}.bg-red-900\/30{background-color:#82181a4d}@supports (color:color-mix(in lab,red,red)){.bg-red-900\/30{background-color:color-mix(in oklab,var(--color-red-900)30%,transparent)}}.bg-red-950\/70{background-color:#460809b3}@supports (color:color-mix(in lab,red,red)){.bg-red-950\/70{background-color:color-mix(in oklab,var(--color-red-950)70%,transparent)}}.bg-rose-500\/20{background-color:#ff235733}@supports (color:color-mix(in lab,red,red)){.bg-rose-500\/20{background-color:color-mix(in oklab,var(--color-rose-500)20%,transparent)}}.bg-rose-600\/20{background-color:#e7004433}@supports (color:color-mix(in lab,red,red)){.bg-rose-600\/20{background-color:color-mix(in oklab,var(--color-rose-600)20%,transparent)}}.bg-sky-500{background-color:var(--color-sky-500)}.bg-sky-500\/20{background-color:#00a5ef33}@supports (color:color-mix(in lab,red,red)){.bg-sky-500\/20{background-color:color-mix(in oklab,var(--color-sky-500)20%,transparent)}}.bg-status-error,.bg-status-error\/10{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/10{background-color:color-mix(in oklab,var(--color-status-error)10%,transparent)}}.bg-status-error\/20{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/20{background-color:color-mix(in oklab,var(--color-status-error)20%,transparent)}}.bg-status-error\/80{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/80{background-color:color-mix(in oklab,var(--color-status-error)80%,transparent)}}.bg-status-ok,.bg-status-ok\/10{background-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.bg-status-ok\/10{background-color:color-mix(in oklab,var(--color-status-ok)10%,transparent)}}.bg-status-ok\/20{background-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.bg-status-ok\/20{background-color:color-mix(in oklab,var(--color-status-ok)20%,transparent)}}.bg-status-warning,.bg-status-warning\/10{background-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.bg-status-warning\/10{background-color:color-mix(in oklab,var(--color-status-warning)10%,transparent)}}.bg-status-warning\/20{background-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.bg-status-warning\/20{background-color:color-mix(in oklab,var(--color-status-warning)20%,transparent)}}.bg-teal-500{background-color:var(--color-teal-500)}.bg-teal-500\/20{background-color:#00baa733}@supports (color:color-mix(in lab,red,red)){.bg-teal-500\/20{background-color:color-mix(in oklab,var(--color-teal-500)20%,transparent)}}.bg-transparent{background-color:#0000}.bg-violet-500{background-color:var(--color-violet-500)}.bg-white{background-color:var(--color-white)}.bg-white\/10{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.bg-white\/10{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.bg-white\/20{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.bg-white\/20{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.bg-white\/50{background-color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.bg-white\/50{background-color:color-mix(in oklab,var(--color-white)50%,transparent)}}.bg-white\/70{background-color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.bg-white\/70{background-color:color-mix(in oklab,var(--color-white)70%,transparent)}}.bg-white\/90{background-color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.bg-white\/90{background-color:color-mix(in oklab,var(--color-white)90%,transparent)}}.bg-yellow-400{background-color:var(--color-yellow-400)}.bg-yellow-400\/10{background-color:#fac8001a}@supports (color:color-mix(in lab,red,red)){.bg-yellow-400\/10{background-color:color-mix(in oklab,var(--color-yellow-400)10%,transparent)}}.bg-yellow-400\/20{background-color:#fac80033}@supports (color:color-mix(in lab,red,red)){.bg-yellow-400\/20{background-color:color-mix(in oklab,var(--color-yellow-400)20%,transparent)}}.bg-yellow-500{background-color:var(--color-yellow-500)}.bg-yellow-500\/5{background-color:#edb2000d}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/5{background-color:color-mix(in oklab,var(--color-yellow-500)5%,transparent)}}.bg-yellow-500\/10{background-color:#edb2001a}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/10{background-color:color-mix(in oklab,var(--color-yellow-500)10%,transparent)}}.bg-yellow-500\/20{background-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/20{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.bg-zinc-600{background-color:var(--color-zinc-600)}.bg-zinc-700{background-color:var(--color-zinc-700)}.bg-zinc-700\/50{background-color:#3f3f4680}@supports (color:color-mix(in lab,red,red)){.bg-zinc-700\/50{background-color:color-mix(in oklab,var(--color-zinc-700)50%,transparent)}}.bg-zinc-800{background-color:var(--color-zinc-800)}.bg-zinc-800\/50{background-color:#27272a80}@supports (color:color-mix(in lab,red,red)){.bg-zinc-800\/50{background-color:color-mix(in oklab,var(--color-zinc-800)50%,transparent)}}.bg-zinc-900{background-color:var(--color-zinc-900)}.bg-zinc-900\/50{background-color:#18181b80}@supports (color:color-mix(in lab,red,red)){.bg-zinc-900\/50{background-color:color-mix(in oklab,var(--color-zinc-900)50%,transparent)}}.bg-gradient-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-r{--tw-gradient-position:to right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-t{--tw-gradient-position:to top in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-bambu-dark-secondary{--tw-gradient-from:var(--color-bambu-dark-secondary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-bambu-green\/10{--tw-gradient-from:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.from-bambu-green\/10{--tw-gradient-from:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.from-bambu-green\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-black\/80{--tw-gradient-from:#000c}@supports (color:color-mix(in lab,red,red)){.from-black\/80{--tw-gradient-from:color-mix(in oklab,var(--color-black)80%,transparent)}}.from-black\/80{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/5{--tw-gradient-from:#3080ff0d}@supports (color:color-mix(in lab,red,red)){.from-blue-500\/5{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.from-blue-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/10{--tw-gradient-from:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.from-blue-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.from-blue-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-gray-500\/10{--tw-gradient-from:#6a72821a}@supports (color:color-mix(in lab,red,red)){.from-gray-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-gray-500)10%,transparent)}}.from-gray-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-purple-500\/10{--tw-gradient-from:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.from-purple-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.from-purple-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-white\/10{--tw-gradient-from:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.from-white\/10{--tw-gradient-from:color-mix(in oklab,var(--color-white)10%,transparent)}}.from-white\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-yellow-500\/10{--tw-gradient-from:#edb2001a}@supports (color:color-mix(in lab,red,red)){.from-yellow-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-yellow-500)10%,transparent)}}.from-yellow-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.via-black\/60{--tw-gradient-via:#0009}@supports (color:color-mix(in lab,red,red)){.via-black\/60{--tw-gradient-via:color-mix(in oklab,var(--color-black)60%,transparent)}}.via-black\/60{--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-via)var(--tw-gradient-via-position),var(--tw-gradient-to)var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-bambu-dark-secondary{--tw-gradient-to:var(--color-bambu-dark-secondary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-bambu-dark-tertiary{--tw-gradient-to:var(--color-bambu-dark-tertiary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-transparent{--tw-gradient-to:transparent;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.bg-cover{background-size:cover}.bg-center{background-position:50%}.fill-yellow-400{fill:var(--color-yellow-400)}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.object-left{object-position:left}.p-0{padding:calc(var(--spacing)*0)}.p-0\.5{padding:calc(var(--spacing)*.5)}.p-1{padding:calc(var(--spacing)*1)}.p-1\.5{padding:calc(var(--spacing)*1.5)}.p-2{padding:calc(var(--spacing)*2)}.p-2\.5{padding:calc(var(--spacing)*2.5)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.p-8{padding:calc(var(--spacing)*8)}.p-12{padding:calc(var(--spacing)*12)}.\!px-1\.5{padding-inline:calc(var(--spacing)*1.5)!important}.\!px-3{padding-inline:calc(var(--spacing)*3)!important}.px-1{padding-inline:calc(var(--spacing)*1)}.px-1\.5{padding-inline:calc(var(--spacing)*1.5)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-2\.5{padding-inline:calc(var(--spacing)*2.5)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-5{padding-inline:calc(var(--spacing)*5)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-0\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-6{padding-block:calc(var(--spacing)*6)}.py-8{padding-block:calc(var(--spacing)*8)}.py-12{padding-block:calc(var(--spacing)*12)}.py-16{padding-block:calc(var(--spacing)*16)}.py-20{padding-block:calc(var(--spacing)*20)}.py-24{padding-block:calc(var(--spacing)*24)}.pt-0{padding-top:calc(var(--spacing)*0)}.pt-1{padding-top:calc(var(--spacing)*1)}.pt-2{padding-top:calc(var(--spacing)*2)}.pt-3{padding-top:calc(var(--spacing)*3)}.pt-4{padding-top:calc(var(--spacing)*4)}.pr-1{padding-right:calc(var(--spacing)*1)}.pr-2{padding-right:calc(var(--spacing)*2)}.pr-3{padding-right:calc(var(--spacing)*3)}.pr-4{padding-right:calc(var(--spacing)*4)}.pr-6{padding-right:calc(var(--spacing)*6)}.pr-7{padding-right:calc(var(--spacing)*7)}.pr-8{padding-right:calc(var(--spacing)*8)}.pr-10{padding-right:calc(var(--spacing)*10)}.pb-1{padding-bottom:calc(var(--spacing)*1)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-3{padding-bottom:calc(var(--spacing)*3)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pl-2{padding-left:calc(var(--spacing)*2)}.pl-4{padding-left:calc(var(--spacing)*4)}.pl-5{padding-left:calc(var(--spacing)*5)}.pl-6{padding-left:calc(var(--spacing)*6)}.pl-7{padding-left:calc(var(--spacing)*7)}.pl-8{padding-left:calc(var(--spacing)*8)}.pl-9{padding-left:calc(var(--spacing)*9)}.pl-10{padding-left:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-5xl{font-size:var(--text-5xl);line-height:var(--tw-leading,var(--text-5xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[6px\]{font-size:6px}.text-\[7px\]{font-size:7px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-none{--tw-leading:1;line-height:1}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-light{--tw-font-weight:var(--font-weight-light);font-weight:var(--font-weight-light)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.whitespace-pre-wrap{white-space:pre-wrap}.\!text-green-400{color:var(--color-green-400)!important}.\!text-white{color:var(--color-white)!important}.\!text-yellow-400{color:var(--color-yellow-400)!important}.text-amber-200{color:var(--color-amber-200)}.text-amber-200\/80{color:#fee685cc}@supports (color:color-mix(in lab,red,red)){.text-amber-200\/80{color:color-mix(in oklab,var(--color-amber-200)80%,transparent)}}.text-amber-300{color:var(--color-amber-300)}.text-amber-300\/60{color:#ffd23699}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/60{color:color-mix(in oklab,var(--color-amber-300)60%,transparent)}}.text-amber-300\/70{color:#ffd236b3}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/70{color:color-mix(in oklab,var(--color-amber-300)70%,transparent)}}.text-amber-300\/80{color:#ffd236cc}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/80{color:color-mix(in oklab,var(--color-amber-300)80%,transparent)}}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/70{color:#fcbb00b3}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/70{color:color-mix(in oklab,var(--color-amber-400)70%,transparent)}}.text-amber-500{color:var(--color-amber-500)}.text-amber-500\/80{color:#f99c00cc}@supports (color:color-mix(in lab,red,red)){.text-amber-500\/80{color:color-mix(in oklab,var(--color-amber-500)80%,transparent)}}.text-amber-600{color:var(--color-amber-600)}.text-amber-700{color:var(--color-amber-700)}.text-amber-800{color:var(--color-amber-800)}.text-bambu-dark-tertiary{color:var(--color-bambu-dark-tertiary)}.text-bambu-gray{color:var(--color-bambu-gray)}.text-bambu-gray-dark{color:var(--color-bambu-gray-dark)}.text-bambu-gray-light{color:var(--color-bambu-gray-light)}.text-bambu-gray\/30{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/30{color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.text-bambu-gray\/40{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/40{color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.text-bambu-gray\/50{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/50{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.text-bambu-gray\/60{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/60{color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.text-bambu-gray\/70{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/70{color:color-mix(in oklab,var(--color-bambu-gray)70%,transparent)}}.text-bambu-gray\/80{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/80{color:color-mix(in oklab,var(--color-bambu-gray)80%,transparent)}}.text-bambu-green,.text-bambu-green\/70{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.text-bambu-green\/70{color:color-mix(in oklab,var(--color-bambu-green)70%,transparent)}}.text-black{color:var(--color-black)}.text-black\/80{color:#000c}@supports (color:color-mix(in lab,red,red)){.text-black\/80{color:color-mix(in oklab,var(--color-black)80%,transparent)}}.text-blue-300{color:var(--color-blue-300)}.text-blue-300\/70{color:#90c5ffb3}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/70{color:color-mix(in oklab,var(--color-blue-300)70%,transparent)}}.text-blue-300\/80{color:#90c5ffcc}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/80{color:color-mix(in oklab,var(--color-blue-300)80%,transparent)}}.text-blue-400{color:var(--color-blue-400)}.text-blue-500{color:var(--color-blue-500)}.text-blue-500\/70{color:#3080ffb3}@supports (color:color-mix(in lab,red,red)){.text-blue-500\/70{color:color-mix(in oklab,var(--color-blue-500)70%,transparent)}}.text-blue-600{color:var(--color-blue-600)}.text-blue-700{color:var(--color-blue-700)}.text-cyan-300{color:var(--color-cyan-300)}.text-cyan-400{color:var(--color-cyan-400)}.text-emerald-300{color:var(--color-emerald-300)}.text-emerald-400{color:var(--color-emerald-400)}.text-gray-300{color:var(--color-gray-300)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-gray-800{color:var(--color-gray-800)}.text-gray-900{color:var(--color-gray-900)}.text-green-200{color:var(--color-green-200)}.text-green-300{color:var(--color-green-300)}.text-green-400{color:var(--color-green-400)}.text-green-400\/60{color:#05df7299}@supports (color:color-mix(in lab,red,red)){.text-green-400\/60{color:color-mix(in oklab,var(--color-green-400)60%,transparent)}}.text-green-500{color:var(--color-green-500)}.text-green-500\/60{color:#00c75899}@supports (color:color-mix(in lab,red,red)){.text-green-500\/60{color:color-mix(in oklab,var(--color-green-500)60%,transparent)}}.text-green-600{color:var(--color-green-600)}.text-indigo-400{color:var(--color-indigo-400)}.text-orange-200{color:var(--color-orange-200)}.text-orange-300{color:var(--color-orange-300)}.text-orange-400{color:var(--color-orange-400)}.text-orange-500{color:var(--color-orange-500)}.text-orange-600{color:var(--color-orange-600)}.text-orange-700{color:var(--color-orange-700)}.text-purple-300{color:var(--color-purple-300)}.text-purple-300\/70{color:#d9b3ffb3}@supports (color:color-mix(in lab,red,red)){.text-purple-300\/70{color:color-mix(in oklab,var(--color-purple-300)70%,transparent)}}.text-purple-400{color:var(--color-purple-400)}.text-purple-400\/80{color:#c07effcc}@supports (color:color-mix(in lab,red,red)){.text-purple-400\/80{color:color-mix(in oklab,var(--color-purple-400)80%,transparent)}}.text-purple-500{color:var(--color-purple-500)}.text-red-200{color:var(--color-red-200)}.text-red-300{color:var(--color-red-300)}.text-red-300\/80{color:#ffa3a3cc}@supports (color:color-mix(in lab,red,red)){.text-red-300\/80{color:color-mix(in oklab,var(--color-red-300)80%,transparent)}}.text-red-400{color:var(--color-red-400)}.text-red-400\/50{color:#ff656880}@supports (color:color-mix(in lab,red,red)){.text-red-400\/50{color:color-mix(in oklab,var(--color-red-400)50%,transparent)}}.text-red-400\/60{color:#ff656899}@supports (color:color-mix(in lab,red,red)){.text-red-400\/60{color:color-mix(in oklab,var(--color-red-400)60%,transparent)}}.text-red-400\/70{color:#ff6568b3}@supports (color:color-mix(in lab,red,red)){.text-red-400\/70{color:color-mix(in oklab,var(--color-red-400)70%,transparent)}}.text-red-500{color:var(--color-red-500)}.text-red-600{color:var(--color-red-600)}.text-rose-300{color:var(--color-rose-300)}.text-rose-400{color:var(--color-rose-400)}.text-sky-400{color:var(--color-sky-400)}.text-slate-300{color:var(--color-slate-300)}.text-status-error{color:var(--color-status-error)}.text-status-ok{color:var(--color-status-ok)}.text-status-warning{color:var(--color-status-warning)}.text-teal-400{color:var(--color-teal-400)}.text-white{color:var(--color-white)}.text-white\/30{color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.text-white\/30{color:color-mix(in oklab,var(--color-white)30%,transparent)}}.text-white\/40{color:#fff6}@supports (color:color-mix(in lab,red,red)){.text-white\/40{color:color-mix(in oklab,var(--color-white)40%,transparent)}}.text-white\/50{color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.text-white\/50{color:color-mix(in oklab,var(--color-white)50%,transparent)}}.text-white\/60{color:#fff9}@supports (color:color-mix(in lab,red,red)){.text-white\/60{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.text-white\/70{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.text-white\/80{color:#fffc}@supports (color:color-mix(in lab,red,red)){.text-white\/80{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.text-white\/90{color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.text-white\/90{color:color-mix(in oklab,var(--color-white)90%,transparent)}}.text-yellow-200{color:var(--color-yellow-200)}.text-yellow-200\/70{color:#fff085b3}@supports (color:color-mix(in lab,red,red)){.text-yellow-200\/70{color:color-mix(in oklab,var(--color-yellow-200)70%,transparent)}}.text-yellow-300{color:var(--color-yellow-300)}.text-yellow-400{color:var(--color-yellow-400)}.text-yellow-500{color:var(--color-yellow-500)}.text-yellow-500\/70{color:#edb200b3}@supports (color:color-mix(in lab,red,red)){.text-yellow-500\/70{color:color-mix(in oklab,var(--color-yellow-500)70%,transparent)}}.text-yellow-500\/80{color:#edb200cc}@supports (color:color-mix(in lab,red,red)){.text-yellow-500\/80{color:color-mix(in oklab,var(--color-yellow-500)80%,transparent)}}.text-yellow-600{color:var(--color-yellow-600)}.text-yellow-700{color:var(--color-yellow-700)}.text-zinc-100{color:var(--color-zinc-100)}.text-zinc-200{color:var(--color-zinc-200)}.text-zinc-300{color:var(--color-zinc-300)}.text-zinc-400{color:var(--color-zinc-400)}.text-zinc-500{color:var(--color-zinc-500)}.text-zinc-600{color:var(--color-zinc-600)}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.line-through{text-decoration-line:line-through}.underline{text-decoration-line:underline}.placeholder-bambu-gray::placeholder{color:var(--color-bambu-gray)}.placeholder-bambu-gray-dark::placeholder{color:var(--color-bambu-gray-dark)}.placeholder-bambu-gray\/40::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder-bambu-gray\/40::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.placeholder-bambu-gray\/50::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder-bambu-gray\/50::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.placeholder-bambu-gray\/60::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder-bambu-gray\/60::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.placeholder-gray-400::placeholder{color:var(--color-gray-400)}.placeholder-zinc-500::placeholder{color:var(--color-zinc-500)}.accent-amber-500{accent-color:var(--color-amber-500)}.accent-bambu-green{accent-color:var(--color-bambu-green)}.accent-green-500{accent-color:var(--color-green-500)}.\[color-scheme\:dark\]{color-scheme:dark}.opacity-0{opacity:0}.opacity-20{opacity:.2}.opacity-25{opacity:.25}.opacity-30{opacity:.3}.opacity-40{opacity:.4}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-80{opacity:.8}.opacity-100{opacity:1}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_6px_rgba\(34\,197\,94\,0\.5\)\]{--tw-shadow:0 0 6px var(--tw-shadow-color,#22c55e80);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow\/depth{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring,.ring-1{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-bambu-green\/20{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.shadow-bambu-green\/20{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)20%,transparent)var(--tw-shadow-alpha),transparent)}}.shadow-bambu-green\/25{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.shadow-bambu-green\/25{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)25%,transparent)var(--tw-shadow-alpha),transparent)}}.ring-bambu-green,.ring-bambu-green\/30{--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.ring-bambu-green\/30{--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.ring-blue-400\/50{--tw-ring-color:#54a2ff80}@supports (color:color-mix(in lab,red,red)){.ring-blue-400\/50{--tw-ring-color:color-mix(in oklab,var(--color-blue-400)50%,transparent)}}.ring-green-500{--tw-ring-color:var(--color-green-500)}.ring-white{--tw-ring-color:var(--color-white)}.ring-offset-1{--tw-ring-offset-width:1px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-2{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-bambu-dark{--tw-ring-offset-color:var(--color-bambu-dark)}.ring-offset-bambu-dark-secondary{--tw-ring-offset-color:var(--color-bambu-dark-secondary)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.blur-2xl{--tw-blur:blur(var(--blur-2xl));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow-lg{--tw-drop-shadow-size:drop-shadow(0 4px 4px var(--tw-drop-shadow-color,#00000026));--tw-drop-shadow:drop-shadow(var(--drop-shadow-lg));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow-md{--tw-drop-shadow-size:drop-shadow(0 3px 3px var(--tw-drop-shadow-color,#0000001f));--tw-drop-shadow:drop-shadow(var(--drop-shadow-md));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-500{--tw-duration:.5s;transition-duration:.5s}.duration-1000{--tw-duration:1s;transition-duration:1s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.select-none{-webkit-user-select:none;user-select:none}@media(hover:hover){.group-hover\:bg-bambu-green\/20:is(:where(.group):hover *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.group-hover\:bg-bambu-green\/20:is(:where(.group):hover *){background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.group-hover\:text-bambu-gray:is(:where(.group):hover *){color:var(--color-bambu-gray)}.group-hover\:text-bambu-green:is(:where(.group):hover *){color:var(--color-bambu-green)}.group-hover\:opacity-50:is(:where(.group):hover *){opacity:.5}.group-hover\:opacity-100:is(:where(.group):hover *),.group-hover\/resize\:opacity-100:is(:where(.group\/resize):hover *){opacity:1}.group-hover\/thumb\:block:is(:where(.group\/thumb):hover *){display:block}}.peer-checked\:bg-amber-500:is(:where(.peer):checked~*){background-color:var(--color-amber-500)}.peer-checked\:bg-bambu-green:is(:where(.peer):checked~*){background-color:var(--color-bambu-green)}.peer-focus\:outline-none:is(:where(.peer):focus~*){--tw-outline-style:none;outline-style:none}.peer-disabled\:cursor-not-allowed:is(:where(.peer):disabled~*){cursor:not-allowed}.placeholder\:text-bambu-gray::placeholder,.placeholder\:text-bambu-gray\/50::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-bambu-gray\/50::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:top-0:before{content:var(--tw-content);top:calc(var(--spacing)*0)}.before\:right-0:before{content:var(--tw-content);right:calc(var(--spacing)*0)}.before\:left-0:before{content:var(--tw-content);left:calc(var(--spacing)*0)}.before\:h-0\.5:before{content:var(--tw-content);height:calc(var(--spacing)*.5)}.before\:bg-bambu-green:before{content:var(--tw-content);background-color:var(--color-bambu-green)}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:top-\[2px\]:after{content:var(--tw-content);top:2px}.after\:left-\[2px\]:after{content:var(--tw-content);left:2px}.after\:h-4:after{content:var(--tw-content);height:calc(var(--spacing)*4)}.after\:h-5:after{content:var(--tw-content);height:calc(var(--spacing)*5)}.after\:w-4:after{content:var(--tw-content);width:calc(var(--spacing)*4)}.after\:w-5:after{content:var(--tw-content);width:calc(var(--spacing)*5)}.after\:rounded-full:after{content:var(--tw-content);border-radius:3.40282e38px}.after\:border:after{content:var(--tw-content);border-style:var(--tw-border-style);border-width:1px}.after\:border-gray-300:after{content:var(--tw-content);border-color:var(--color-gray-300)}.after\:bg-white:after{content:var(--tw-content);background-color:var(--color-white)}.after\:transition-all:after{content:var(--tw-content);transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.after\:content-\[\'\'\]:after{--tw-content:"";content:var(--tw-content)}.peer-checked\:after\:translate-x-full:is(:where(.peer):checked~*):after{content:var(--tw-content);--tw-translate-x:100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.peer-checked\:after\:border-white:is(:where(.peer):checked~*):after{content:var(--tw-content);border-color:var(--color-white)}.last\:border-0:last-child{border-style:var(--tw-border-style);border-width:0}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.focus-within\:border-bambu-green:focus-within{border-color:var(--color-bambu-green)}@media(hover:hover){.hover\:z-20:hover{z-index:20}.hover\:scale-105:hover{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\:border-bambu-dark-tertiary\/80:hover{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-dark-tertiary\/80:hover{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.hover\:border-bambu-gray:hover{border-color:var(--color-bambu-gray)}.hover\:border-bambu-gray-dark:hover{border-color:var(--color-bambu-gray-dark)}.hover\:border-bambu-gray\/50:hover{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-gray\/50:hover{border-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.hover\:border-bambu-green:hover,.hover\:border-bambu-green\/50:hover{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-green\/50:hover{border-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.hover\:border-gray-400:hover{border-color:var(--color-gray-400)}.hover\:border-green-500\/50:hover{border-color:#00c75880}@supports (color:color-mix(in lab,red,red)){.hover\:border-green-500\/50:hover{border-color:color-mix(in oklab,var(--color-green-500)50%,transparent)}}.hover\:border-white:hover{border-color:var(--color-white)}.hover\:border-white\/40:hover{border-color:#fff6}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/40:hover{border-color:color-mix(in oklab,var(--color-white)40%,transparent)}}.hover\:\!bg-bambu-green\/80:hover{background-color:var(--color-bambu-green)!important}@supports (color:color-mix(in lab,red,red)){.hover\:\!bg-bambu-green\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)!important}}.hover\:\!bg-green-500\/20:hover{background-color:#00c75833!important}@supports (color:color-mix(in lab,red,red)){.hover\:\!bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)!important}}.hover\:\!bg-yellow-500\/20:hover{background-color:#edb20033!important}@supports (color:color-mix(in lab,red,red)){.hover\:\!bg-yellow-500\/20:hover{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)!important}}.hover\:bg-amber-400:hover{background-color:var(--color-amber-400)}.hover\:bg-amber-500\/20:hover{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/20:hover{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.hover\:bg-amber-500\/30:hover{background-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/30:hover{background-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.hover\:bg-bambu-dark:hover{background-color:var(--color-bambu-dark)}.hover\:bg-bambu-dark-secondary:hover,.hover\:bg-bambu-dark-secondary\/50:hover{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-secondary\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)50%,transparent)}}.hover\:bg-bambu-dark-secondary\/80:hover{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-secondary\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)80%,transparent)}}.hover\:bg-bambu-dark-tertiary:hover,.hover\:bg-bambu-dark-tertiary\/30:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.hover\:bg-bambu-dark-tertiary\/50:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.hover\:bg-bambu-dark-tertiary\/70:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/70:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)70%,transparent)}}.hover\:bg-bambu-dark-tertiary\/80:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.hover\:bg-bambu-dark\/50:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.hover\:bg-bambu-dark\/80:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)80%,transparent)}}.hover\:bg-bambu-gray-dark:hover{background-color:var(--color-bambu-gray-dark)}.hover\:bg-bambu-green:hover{background-color:var(--color-bambu-green)}.hover\:bg-bambu-green-dark:hover{background-color:var(--color-bambu-green-dark)}.hover\:bg-bambu-green-light:hover{background-color:var(--color-bambu-green-light)}.hover\:bg-bambu-green\/10:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/10:hover{background-color:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.hover\:bg-bambu-green\/20:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/20:hover{background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.hover\:bg-bambu-green\/30:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.hover\:bg-bambu-green\/50:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.hover\:bg-bambu-green\/80:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)}}.hover\:bg-black\/40:hover{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/40:hover{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.hover\:bg-black\/70:hover{background-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/70:hover{background-color:color-mix(in oklab,var(--color-black)70%,transparent)}}.hover\:bg-black\/80:hover{background-color:#000c}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/80:hover{background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.hover\:bg-blue-500\/30:hover{background-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-500\/30:hover{background-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.hover\:bg-gray-50:hover{background-color:var(--color-gray-50)}.hover\:bg-gray-100:hover{background-color:var(--color-gray-100)}.hover\:bg-gray-200:hover{background-color:var(--color-gray-200)}.hover\:bg-gray-700:hover{background-color:var(--color-gray-700)}.hover\:bg-green-500\/20:hover{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.hover\:bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.hover\:bg-green-700:hover{background-color:var(--color-green-700)}.hover\:bg-orange-400\/20:hover{background-color:#ff8b1a33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-orange-400\/20:hover{background-color:color-mix(in oklab,var(--color-orange-400)20%,transparent)}}.hover\:bg-purple-600\/90:hover{background-color:#9810fae6}@supports (color:color-mix(in lab,red,red)){.hover\:bg-purple-600\/90:hover{background-color:color-mix(in oklab,var(--color-purple-600)90%,transparent)}}.hover\:bg-red-200:hover{background-color:var(--color-red-200)}.hover\:bg-red-400\/10:hover{background-color:#ff65681a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-400\/10:hover{background-color:color-mix(in oklab,var(--color-red-400)10%,transparent)}}.hover\:bg-red-500\/10:hover{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/10:hover{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.hover\:bg-red-500\/30:hover{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/30:hover{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.hover\:bg-red-600:hover{background-color:var(--color-red-600)}.hover\:bg-red-700:hover{background-color:var(--color-red-700)}.hover\:bg-white\/5:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/5:hover{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.hover\:bg-white\/10:hover{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/10:hover{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.hover\:bg-white\/80:hover{background-color:#fffc}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/80:hover{background-color:color-mix(in oklab,var(--color-white)80%,transparent)}}.hover\:bg-yellow-500\/30:hover{background-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-yellow-500\/30:hover{background-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.hover\:bg-yellow-600:hover{background-color:var(--color-yellow-600)}.hover\:bg-zinc-600:hover{background-color:var(--color-zinc-600)}.hover\:bg-zinc-700:hover{background-color:var(--color-zinc-700)}.hover\:bg-zinc-700\/50:hover{background-color:#3f3f4680}@supports (color:color-mix(in lab,red,red)){.hover\:bg-zinc-700\/50:hover{background-color:color-mix(in oklab,var(--color-zinc-700)50%,transparent)}}.hover\:bg-zinc-800:hover{background-color:var(--color-zinc-800)}.hover\:text-amber-300:hover{color:var(--color-amber-300)}.hover\:text-amber-800:hover{color:var(--color-amber-800)}.hover\:text-bambu-gray:hover{color:var(--color-bambu-gray)}.hover\:text-bambu-green:hover{color:var(--color-bambu-green)}.hover\:text-bambu-green-light:hover{color:var(--color-bambu-green-light)}.hover\:text-bambu-green\/70:hover{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:text-bambu-green\/70:hover{color:color-mix(in oklab,var(--color-bambu-green)70%,transparent)}}.hover\:text-bambu-green\/80:hover{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:text-bambu-green\/80:hover{color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)}}.hover\:text-blue-300:hover{color:var(--color-blue-300)}.hover\:text-blue-600:hover{color:var(--color-blue-600)}.hover\:text-gray-600:hover{color:var(--color-gray-600)}.hover\:text-gray-900:hover{color:var(--color-gray-900)}.hover\:text-orange-300:hover{color:var(--color-orange-300)}.hover\:text-red-200:hover{color:var(--color-red-200)}.hover\:text-red-300:hover{color:var(--color-red-300)}.hover\:text-red-400:hover{color:var(--color-red-400)}.hover\:text-white:hover{color:var(--color-white)}.hover\:text-white\/70:hover{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/70:hover{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.hover\:text-white\/80:hover{color:#fffc}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/80:hover{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.hover\:text-yellow-400:hover{color:var(--color-yellow-400)}.hover\:text-zinc-200:hover{color:var(--color-zinc-200)}.hover\:text-zinc-300:hover{color:var(--color-zinc-300)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-70:hover{opacity:.7}.hover\:opacity-80:hover{opacity:.8}.hover\:shadow-lg:hover{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:shadow-xl:hover{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:shadow-bambu-green\/5:hover{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:shadow-bambu-green\/5:hover{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)5%,transparent)var(--tw-shadow-alpha),transparent)}}.hover\:shadow-bambu-green\/30:hover{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:shadow-bambu-green\/30:hover{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)30%,transparent)var(--tw-shadow-alpha),transparent)}}}.focus\:border-amber-500\/50:focus{border-color:#f99c0080}@supports (color:color-mix(in lab,red,red)){.focus\:border-amber-500\/50:focus{border-color:color-mix(in oklab,var(--color-amber-500)50%,transparent)}}.focus\:border-bambu-green:focus{border-color:var(--color-bambu-green)}.focus\:border-red-500:focus{border-color:var(--color-red-500)}.focus\:border-transparent:focus{border-color:#0000}.focus\:ring-1:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-bambu-gray:focus{--tw-ring-color:var(--color-bambu-gray)}.focus\:ring-bambu-green:focus,.focus\:ring-bambu-green\/50:focus{--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.focus\:ring-bambu-green\/50:focus{--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.focus\:ring-blue-500:focus{--tw-ring-color:var(--color-blue-500)}.focus\:ring-red-500:focus{--tw-ring-color:var(--color-red-500)}.focus\:ring-offset-0:focus{--tw-ring-offset-width:0px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:ring-offset-bambu-dark:focus{--tw-ring-offset-color:var(--color-bambu-dark)}.focus\:ring-offset-bambu-dark-secondary:focus{--tw-ring-offset-color:var(--color-bambu-dark-secondary)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.active\:scale-95:active{--tw-scale-x:95%;--tw-scale-y:95%;--tw-scale-z:95%;scale:var(--tw-scale-x)var(--tw-scale-y)}.active\:cursor-grabbing:active{cursor:grabbing}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}@media(hover:hover){.disabled\:hover\:bg-bambu-green:disabled:hover{background-color:var(--color-bambu-green)}}@media not all and (min-width:640px){.max-\[640px\]\:hidden{display:none}.max-\[640px\]\:w-full{width:100%}.max-\[640px\]\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.max-\[640px\]\:flex-col{flex-direction:column}.max-\[640px\]\:flex-wrap{flex-wrap:wrap}.max-\[640px\]\:items-center{align-items:center}.max-\[640px\]\:items-start{align-items:flex-start}}@media not all and (min-width:550px){.max-\[550px\]\:order-1{order:1}.max-\[550px\]\:order-2{order:2}.max-\[550px\]\:order-3{order:3}.max-\[550px\]\:order-4{order:4}.max-\[550px\]\:mt-1{margin-top:calc(var(--spacing)*1)}.max-\[550px\]\:w-full{width:100%}.max-\[550px\]\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.max-\[550px\]\:flex-col{flex-direction:column}.max-\[550px\]\:flex-wrap{flex-wrap:wrap}.max-\[550px\]\:items-center{align-items:center}.max-\[550px\]\:items-start{align-items:flex-start}.max-\[550px\]\:justify-end{justify-content:flex-end}.max-\[550px\]\:gap-1\.5{gap:calc(var(--spacing)*1.5)}.max-\[550px\]\:gap-3{gap:calc(var(--spacing)*3)}.max-\[550px\]\:self-start{align-self:flex-start}}@media(min-width:40rem){.sm\:col-span-1{grid-column:span 1/span 1}.sm\:mt-0{margin-top:calc(var(--spacing)*0)}.sm\:mt-2{margin-top:calc(var(--spacing)*2)}.sm\:mt-3{margin-top:calc(var(--spacing)*3)}.sm\:mr-1{margin-right:calc(var(--spacing)*1)}.sm\:mb-4{margin-bottom:calc(var(--spacing)*4)}.sm\:ml-auto{margin-left:auto}.sm\:block{display:block}.sm\:flex{display:flex}.sm\:grid{display:grid}.sm\:hidden{display:none}.sm\:inline{display:inline}.sm\:h-2{height:calc(var(--spacing)*2)}.sm\:h-3{height:calc(var(--spacing)*3)}.sm\:h-3\.5{height:calc(var(--spacing)*3.5)}.sm\:h-4{height:calc(var(--spacing)*4)}.sm\:h-5{height:calc(var(--spacing)*5)}.sm\:h-6{height:calc(var(--spacing)*6)}.sm\:h-10{height:calc(var(--spacing)*10)}.sm\:h-14{height:calc(var(--spacing)*14)}.sm\:w-3{width:calc(var(--spacing)*3)}.sm\:w-3\.5{width:calc(var(--spacing)*3.5)}.sm\:w-4{width:calc(var(--spacing)*4)}.sm\:w-5{width:calc(var(--spacing)*5)}.sm\:w-6{width:calc(var(--spacing)*6)}.sm\:w-10{width:calc(var(--spacing)*10)}.sm\:w-14{width:calc(var(--spacing)*14)}.sm\:w-16{width:calc(var(--spacing)*16)}.sm\:w-40{width:calc(var(--spacing)*40)}.sm\:w-auto{width:auto}.sm\:max-w-none{max-width:none}.sm\:max-w-xs{max-width:var(--container-xs)}.sm\:flex-1{flex:1}.sm\:flex-none{flex:none}.sm\:cursor-default{cursor:default}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:gap-1{gap:calc(var(--spacing)*1)}.sm\:gap-1\.5{gap:calc(var(--spacing)*1.5)}.sm\:gap-2{gap:calc(var(--spacing)*2)}.sm\:gap-3{gap:calc(var(--spacing)*3)}.sm\:gap-4{gap:calc(var(--spacing)*4)}.sm\:gap-6{gap:calc(var(--spacing)*6)}:where(.sm\:space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.sm\:space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}.sm\:border-bambu-dark-tertiary{border-color:var(--color-bambu-dark-tertiary)}.sm\:p-1\.5{padding:calc(var(--spacing)*1.5)}.sm\:p-2{padding:calc(var(--spacing)*2)}.sm\:p-3{padding:calc(var(--spacing)*3)}.sm\:p-4{padding:calc(var(--spacing)*4)}.sm\:px-2{padding-inline:calc(var(--spacing)*2)}.sm\:px-3{padding-inline:calc(var(--spacing)*3)}.sm\:text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.sm\:text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.sm\:text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.sm\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.sm\:text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}}@media(min-width:48rem){.md\:top-\[2px\]{top:2px}.md\:left-\[2px\]{left:2px}.md\:mx-0{margin-inline:calc(var(--spacing)*0)}.md\:block{display:block}.md\:inline{display:inline}.md\:h-4{height:calc(var(--spacing)*4)}.md\:h-5{height:calc(var(--spacing)*5)}.md\:min-h-0{min-height:calc(var(--spacing)*0)}.md\:w-4{width:calc(var(--spacing)*4)}.md\:w-9{width:calc(var(--spacing)*9)}.md\:min-w-\[200px\]{min-width:200px}.md\:flex-1{flex:1}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.md\:flex-row{flex-direction:row}.md\:flex-wrap{flex-wrap:wrap}.md\:items-center{align-items:center}.md\:gap-4{gap:calc(var(--spacing)*4)}.md\:p-6{padding:calc(var(--spacing)*6)}.md\:p-8{padding:calc(var(--spacing)*8)}.md\:px-0{padding-inline:calc(var(--spacing)*0)}.md\:py-2{padding-block:calc(var(--spacing)*2)}.md\:pb-0{padding-bottom:calc(var(--spacing)*0)}}@media(min-width:64rem){.lg\:static{position:static}.lg\:col-span-2{grid-column:span 2/span 2}.lg\:col-span-3{grid-column:span 3/span 3}.lg\:flex{display:flex}.lg\:hidden{display:none}.lg\:h-\[calc\(100vh-64px\)\]{height:calc(100vh - 64px)}.lg\:w-1\/3{width:33.3333%}.lg\:w-2\/3{width:66.6667%}.lg\:w-80{width:calc(var(--spacing)*80)}.lg\:w-\[480px\]{width:480px}.lg\:max-w-md{max-width:var(--container-md)}.lg\:max-w-sm{max-width:var(--container-sm)}.lg\:max-w-xl{max-width:var(--container-xl)}.lg\:flex-shrink-0{flex-shrink:0}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.lg\:flex-row{flex-direction:row}.lg\:gap-4{gap:calc(var(--spacing)*4)}.lg\:gap-6{gap:calc(var(--spacing)*6)}.lg\:gap-8{gap:calc(var(--spacing)*8)}.lg\:overflow-y-auto{overflow-y:auto}.lg\:p-8{padding:calc(var(--spacing)*8)}}@media(min-width:80rem){.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}@media(min-width:96rem){.\32xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}.dark\:border-amber-700:where(.dark,.dark *){border-color:var(--color-amber-700)}.dark\:border-amber-800:where(.dark,.dark *){border-color:var(--color-amber-800)}.dark\:border-bambu-dark-tertiary:where(.dark,.dark *),.dark\:border-bambu-dark-tertiary\/50:where(.dark,.dark *){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.dark\:border-bambu-dark-tertiary\/50:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.dark\:border-bambu-green\/40:where(.dark,.dark *){border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:border-bambu-green\/40:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.dark\:border-gray-600:where(.dark,.dark *){border-color:var(--color-gray-600)}.dark\:border-gray-700:where(.dark,.dark *){border-color:var(--color-gray-700)}.dark\:border-red-500\/30:where(.dark,.dark *){border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.dark\:border-red-500\/30:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.dark\:border-red-500\/40:where(.dark,.dark *){border-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.dark\:border-red-500\/40:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.dark\:bg-amber-500\/10:where(.dark,.dark *){background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-amber-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.dark\:bg-amber-900\/20:where(.dark,.dark *){background-color:#7b330633}@supports (color:color-mix(in lab,red,red)){.dark\:bg-amber-900\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-amber-900)20%,transparent)}}.dark\:bg-bambu-dark:where(.dark,.dark *){background-color:var(--color-bambu-dark)}.dark\:bg-bambu-dark-secondary:where(.dark,.dark *){background-color:var(--color-bambu-dark-secondary)}.dark\:bg-bambu-green\/20:where(.dark,.dark *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:bg-bambu-green\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.dark\:bg-black\/80:where(.dark,.dark *){background-color:#000c}@supports (color:color-mix(in lab,red,red)){.dark\:bg-black\/80:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.dark\:bg-blue-500\/10:where(.dark,.dark *){background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-blue-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.dark\:bg-blue-500\/20:where(.dark,.dark *){background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.dark\:bg-blue-500\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.dark\:bg-blue-900\/20:where(.dark,.dark *){background-color:#1c398e33}@supports (color:color-mix(in lab,red,red)){.dark\:bg-blue-900\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-900)20%,transparent)}}.dark\:bg-gray-700:where(.dark,.dark *){background-color:var(--color-gray-700)}.dark\:bg-gray-800:where(.dark,.dark *){background-color:var(--color-gray-800)}.dark\:bg-gray-900:where(.dark,.dark *){background-color:var(--color-gray-900)}.dark\:bg-red-500\/10:where(.dark,.dark *){background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-red-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.dark\:bg-red-500\/20:where(.dark,.dark *){background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.dark\:bg-red-500\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.dark\:text-amber-200:where(.dark,.dark *){color:var(--color-amber-200)}.dark\:text-amber-300:where(.dark,.dark *){color:var(--color-amber-300)}.dark\:text-amber-400:where(.dark,.dark *){color:var(--color-amber-400)}.dark\:text-bambu-gray:where(.dark,.dark *),.dark\:text-bambu-gray\/30:where(.dark,.dark *){color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-gray\/30:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.dark\:text-bambu-gray\/50:where(.dark,.dark *){color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-gray\/50:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.dark\:text-bambu-green:where(.dark,.dark *),.dark\:text-bambu-green\/60:where(.dark,.dark *){color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-green\/60:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-green)60%,transparent)}}.dark\:text-blue-200:where(.dark,.dark *){color:var(--color-blue-200)}.dark\:text-blue-200\/80:where(.dark,.dark *){color:#bedbffcc}@supports (color:color-mix(in lab,red,red)){.dark\:text-blue-200\/80:where(.dark,.dark *){color:color-mix(in oklab,var(--color-blue-200)80%,transparent)}}.dark\:text-blue-300:where(.dark,.dark *){color:var(--color-blue-300)}.dark\:text-blue-300\/60:where(.dark,.dark *){color:#90c5ff99}@supports (color:color-mix(in lab,red,red)){.dark\:text-blue-300\/60:where(.dark,.dark *){color:color-mix(in oklab,var(--color-blue-300)60%,transparent)}}.dark\:text-blue-400:where(.dark,.dark *){color:var(--color-blue-400)}.dark\:text-gray-300:where(.dark,.dark *){color:var(--color-gray-300)}.dark\:text-gray-400:where(.dark,.dark *){color:var(--color-gray-400)}.dark\:text-orange-200:where(.dark,.dark *){color:var(--color-orange-200)}.dark\:text-orange-400:where(.dark,.dark *){color:var(--color-orange-400)}.dark\:text-red-400:where(.dark,.dark *){color:var(--color-red-400)}.dark\:text-red-400\/70:where(.dark,.dark *){color:#ff6568b3}@supports (color:color-mix(in lab,red,red)){.dark\:text-red-400\/70:where(.dark,.dark *){color:color-mix(in oklab,var(--color-red-400)70%,transparent)}}.dark\:text-white:where(.dark,.dark *){color:var(--color-white)}.dark\:text-yellow-200:where(.dark,.dark *){color:var(--color-yellow-200)}.dark\:text-yellow-200\/70:where(.dark,.dark *){color:#fff085b3}@supports (color:color-mix(in lab,red,red)){.dark\:text-yellow-200\/70:where(.dark,.dark *){color:color-mix(in oklab,var(--color-yellow-200)70%,transparent)}}@media(hover:hover){.dark\:hover\:border-gray-500:where(.dark,.dark *):hover{border-color:var(--color-gray-500)}.dark\:hover\:bg-bambu-dark-tertiary:where(.dark,.dark *):hover{background-color:var(--color-bambu-dark-tertiary)}.dark\:hover\:bg-bambu-dark\/50:where(.dark,.dark *):hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.dark\:hover\:bg-bambu-dark\/50:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.dark\:hover\:bg-gray-600:where(.dark,.dark *):hover{background-color:var(--color-gray-600)}.dark\:hover\:bg-red-500\/30:where(.dark,.dark *):hover{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.dark\:hover\:bg-red-500\/30:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.dark\:hover\:text-amber-200:where(.dark,.dark *):hover{color:var(--color-amber-200)}.dark\:hover\:text-gray-300:where(.dark,.dark *):hover{color:var(--color-gray-300)}.dark\:hover\:text-white:where(.dark,.dark *):hover{color:var(--color-white)}}.\[\&\:\:-webkit-inner-spin-button\]\:appearance-none::-webkit-inner-spin-button{appearance:none}.\[\&\:\:-webkit-outer-spin-button\]\:appearance-none::-webkit-outer-spin-button{appearance:none}.\[\&\:\:-webkit-slider-thumb\]\:h-3::-webkit-slider-thumb{height:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:w-3::-webkit-slider-thumb{width:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:cursor-pointer::-webkit-slider-thumb{cursor:pointer}.\[\&\:\:-webkit-slider-thumb\]\:appearance-none::-webkit-slider-thumb{appearance:none}.\[\&\:\:-webkit-slider-thumb\]\:rounded-full::-webkit-slider-thumb{border-radius:3.40282e38px}.\[\&\:\:-webkit-slider-thumb\]\:bg-bambu-green::-webkit-slider-thumb{background-color:var(--color-bambu-green)}}:root{--accent:#00ae42;--accent-light:#00c64d;--accent-dark:#009438;--status-ok:#22c55e;--status-error:#ef4444;--status-warning:#f59e0b;--bg-primary:#f5f5f5;--bg-secondary:#fff;--bg-tertiary:#e5e5e5;--text-primary:#1a1a1a;--text-secondary:#4a4a4a;--text-muted:#6b6b6b;--text-tertiary:gray;--border-color:#d4d4d4;--card-shadow:0 2px 8px #00000014;--glow-color:transparent;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,system-ui,sans-serif;font-weight:400;line-height:1.5}.dark{--bg-primary:#1a1a1a;--bg-secondary:#2d2d2d;--bg-tertiary:#3d3d3d;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:gray;--text-tertiary:#4a4a4a;--border-color:#3d3d3d;--card-shadow:0 4px 16px #0006}.bg-warm{--bg-primary:#faf8f5;--bg-secondary:#fffefa;--bg-tertiary:#e8e4dd;--text-primary:#2d2a26;--text-secondary:#5c5750;--text-muted:#7a756c;--text-tertiary:#9a9590;--border-color:#d8d4cc}.bg-cool{--bg-primary:#f0f4f8;--bg-secondary:#fff;--bg-tertiary:#dce4ec;--text-primary:#1a2530;--text-secondary:#4a5568;--text-muted:#6b7a8a;--text-tertiary:#8a9aaa;--border-color:#c8d4e0}.dark.bg-neutral{--bg-primary:#1a1a1a;--bg-secondary:#2d2d2d;--bg-tertiary:#3d3d3d;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:gray;--text-tertiary:#4a4a4a;--border-color:#3d3d3d}.dark.bg-warm{--bg-primary:#1c1a18;--bg-secondary:#2e2a26;--bg-tertiary:#3e3a36;--text-primary:#f5f0ea;--text-secondary:#b0a898;--text-muted:#8a8278;--text-tertiary:#5a5248;--border-color:#3e3a36}.dark.bg-cool{--bg-primary:#181c20;--bg-secondary:#262c32;--bg-tertiary:#363e46;--text-primary:#f0f4f8;--text-secondary:#98a8b8;--text-muted:#788898;--text-tertiary:#4a5a6a;--border-color:#363e46}.dark.bg-oled{--bg-primary:#000;--bg-secondary:#141414;--bg-tertiary:#1f1f1f;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:#707070;--text-tertiary:#404040;--border-color:#2a2a2a}.dark.bg-slate{--bg-primary:#0f172a;--bg-secondary:#1e293b;--bg-tertiary:#334155;--text-primary:#f1f5f9;--text-secondary:#94a3b8;--text-muted:#64748b;--text-tertiary:#475569;--border-color:#334155}.dark.bg-forest{--bg-primary:#121a16;--bg-secondary:#1c2a22;--bg-tertiary:#2a3d30;--text-primary:#e8f5ec;--text-secondary:#8aa894;--text-muted:#6a8874;--text-tertiary:#4a6854;--border-color:#2a3d30}.printer-control-buttons-container{container-type:inline-size}@container (max-width:220px){.printer-control-buttons{flex-direction:column;align-items:stretch}.printer-control-buttons>button{width:100%}}.style-glow{--card-shadow:0 2px 8px #00000014,0 0 25px var(--accent)}@supports (color:color-mix(in lab,red,red)){.style-glow{--card-shadow:0 2px 8px #00000014,0 0 25px color-mix(in srgb,var(--accent)12%,transparent)}}.dark.style-glow{--card-shadow:0 4px 20px #00000080,0 0 40px var(--accent)}@supports (color:color-mix(in lab,red,red)){.dark.style-glow{--card-shadow:0 4px 20px #00000080,0 0 40px color-mix(in srgb,var(--accent)15%,transparent)}}.style-vibrant{--card-shadow:0 8px 30px #00000026,0 2px 8px #0000001a}.dark.style-vibrant{--card-shadow:0 10px 40px #0009,0 4px 12px #0006}.accent-green{--accent:#00ae42;--accent-light:#00c64d;--accent-dark:#009438}.accent-teal{--accent:#14b8a6;--accent-light:#2dd4bf;--accent-dark:#0d9488}.accent-blue{--accent:#3b82f6;--accent-light:#60a5fa;--accent-dark:#2563eb}.accent-orange{--accent:#f97316;--accent-light:#fb923c;--accent-dark:#ea580c}.accent-purple{--accent:#8b5cf6;--accent-light:#a78bfa;--accent-dark:#7c3aed}.accent-red{--accent:#ef4444;--accent-light:#f87171;--accent-dark:#dc2626}body{background-color:var(--bg-primary);color:var(--text-primary);min-height:100vh;margin:0;transition:background-color .2s,color .2s}#root{min-height:100vh}.text-white{color:var(--text-primary)}.bg-bambu-dark,.bg-bambu-dark-secondary,.bg-bambu-dark-tertiary,.border-bambu-dark-tertiary{transition:background-color .2s,border-color .2s}@keyframes slide-in{0%{opacity:0;transform:translate(100%)}to{opacity:1;transform:translate(0)}}.animate-slide-in{animation:.2s ease-out slide-in}.icon-theme{opacity:.5}.dark .icon-theme{filter:invert();opacity:.4}.icon-green{filter:invert(48%)sepia(89%)saturate(459%)hue-rotate(93deg)brightness(95%)contrast(92%);opacity:1}.icon-heating{filter:invert(50%)sepia()saturate(1000%)hue-rotate(360deg)brightness()contrast();opacity:1}.dark .jogpad-theme{filter:brightness(.35)contrast(1.2)}.ams-empty-slot{background:repeating-linear-gradient(45deg,#444,#444 2px,#222 2px 4px)}.dark .ams-empty-slot{background:repeating-linear-gradient(45deg,#555,#555 2px,#333 2px 4px)}.touch-manipulation{touch-action:manipulation}.safe-area-bottom{padding-bottom:env(safe-area-inset-bottom,0)}.safe-area-top{padding-top:env(safe-area-inset-top,0)}.scrollbar-hide{-ms-overflow-style:none;scrollbar-width:none}.scrollbar-hide::-webkit-scrollbar{display:none}@keyframes slide-in-left{0%{transform:translate(-100%)}to{transform:translate(0)}}.animate-slide-in-left{animation:.3s ease-out slide-in-left}.card-shadow{box-shadow:var(--card-shadow)}.calendar-scroll{scrollbar-width:thin;scrollbar-color:var(--text-muted)transparent}@supports (color:color-mix(in lab,red,red)){.calendar-scroll{scrollbar-color:color-mix(in srgb,var(--text-muted)60%,transparent)transparent}}.calendar-scroll::-webkit-scrollbar{width:8px}.calendar-scroll::-webkit-scrollbar-track{background:0 0}.calendar-scroll::-webkit-scrollbar-thumb{background-color:var(--text-muted)}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb{background-color:color-mix(in srgb,var(--text-muted)60%,transparent)}}.calendar-scroll::-webkit-scrollbar-thumb{border:2px solid var(--bg-secondary);border-radius:999px}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb{border:2px solid color-mix(in srgb,var(--bg-secondary)70%,transparent)}}.calendar-scroll::-webkit-scrollbar-thumb:hover{background-color:var(--text-muted)}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb:hover{background-color:color-mix(in srgb,var(--text-muted)80%,transparent)}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@property --tw-content{syntax:"*";inherits:false;initial-value:""}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:""}}}.hg-theme-default{background-color:#ececec;border-radius:5px;box-sizing:border-box;font-family:HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;overflow:hidden;padding:5px;touch-action:manipulation;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}.hg-theme-default .hg-button span,.hg-theme-default .hg-button span svg{pointer-events:none}.hg-theme-default button.hg-button{border-width:0;font-size:inherit}.hg-theme-default .hg-button{display:inline-block;flex-grow:1}.hg-theme-default .hg-row{display:flex}.hg-theme-default .hg-row:not(:last-child){margin-bottom:5px}.hg-theme-default .hg-row .hg-button-container,.hg-theme-default .hg-row .hg-button:not(:last-child){margin-right:5px}.hg-theme-default .hg-row>div:last-child{margin-right:0}.hg-theme-default .hg-row .hg-button-container{display:flex}.hg-theme-default .hg-button{align-items:center;background:#fff;border-bottom:1px solid #b5b5b5;border-radius:5px;box-shadow:0 0 3px -1px #0000004d;box-sizing:border-box;cursor:pointer;display:flex;height:40px;justify-content:center;padding:5px;-webkit-tap-highlight-color:rgba(0,0,0,0)}.hg-theme-default .hg-button.hg-standardBtn{width:20px}.hg-theme-default .hg-button.hg-activeButton{background:#efefef}.hg-theme-default.hg-layout-numeric .hg-button{align-items:center;display:flex;height:60px;justify-content:center;width:33.3%}.hg-theme-default .hg-button.hg-button-numpadadd,.hg-theme-default .hg-button.hg-button-numpadenter{height:85px}.hg-theme-default .hg-button.hg-button-numpad0{width:105px}.hg-theme-default .hg-button.hg-button-com{max-width:85px}.hg-theme-default .hg-button.hg-standardBtn.hg-button-at{max-width:45px}.hg-theme-default .hg-button.hg-selectedButton{background:#05194687;color:#fff}.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=".com"]{max-width:82px}.hg-theme-default .hg-button.hg-standardBtn[data-skbtn="@"]{max-width:60px}.hg-candidate-box{background:#ececec;border-bottom:2px solid #b5b5b5;border-radius:5px;display:inline-flex;margin-top:-10px;position:absolute;transform:translateY(-100%);-webkit-user-select:none;-moz-user-select:none;user-select:none}ul.hg-candidate-box-list{display:flex;flex:1;list-style:none;margin:0;padding:0}li.hg-candidate-box-list-item{align-items:center;display:flex;height:40px;justify-content:center;width:40px}li.hg-candidate-box-list-item:hover{background:#00000008;cursor:pointer}li.hg-candidate-box-list-item:active{background:#0000001a}.hg-candidate-box-prev:before{content:"◄"}.hg-candidate-box-next:before{content:"►"}.hg-candidate-box-next,.hg-candidate-box-prev{align-items:center;color:#969696;cursor:pointer;display:flex;padding:0 10px}.hg-candidate-box-next{border-bottom-right-radius:5px;border-top-right-radius:5px}.hg-candidate-box-prev{border-bottom-left-radius:5px;border-top-left-radius:5px}.hg-candidate-box-btn-active{color:#444}.simple-keyboard.vkb-theme{background:#1a1a1a;border-top:1px solid #333;padding:8px 4px;font-family:inherit}.simple-keyboard.vkb-theme .hg-row{display:flex!important;flex-direction:row!important;flex-wrap:nowrap!important;gap:4px;margin-bottom:4px}.simple-keyboard.vkb-theme .hg-row:last-child{margin-bottom:0}.simple-keyboard.vkb-theme .hg-button{display:inline-flex!important;align-items:center;justify-content:center;flex-grow:1;flex-shrink:1;flex-basis:auto;background:#2d2d2d;color:#e0e0e0;border:none;border-radius:6px;height:44px;font-size:16px;font-weight:500;box-shadow:0 1px 2px #0000004d;transition:background .1s;cursor:pointer;padding:0 2px;min-width:0}.simple-keyboard.vkb-theme .hg-button:active{background:#00ae42;color:#fff}.simple-keyboard.vkb-theme .hg-button-bksp,.simple-keyboard.vkb-theme .hg-button-shift,.simple-keyboard.vkb-theme .hg-button-lock{background:#3a3a3a;color:#aaa;flex-grow:1.5}.simple-keyboard.vkb-theme .hg-button-close{background:#3a3a3a;color:#aaa;flex-grow:2;font-weight:600}.simple-keyboard.vkb-theme .hg-button-close:active{background:#555}.simple-keyboard.vkb-theme .hg-button-space{flex-grow:7}.simple-keyboard.vkb-theme .hg-activeButton{background:#00ae42;color:#fff} diff --git a/static/index.html b/static/index.html index 0ab90e6af..295f65fb1 100644 --- a/static/index.html +++ b/static/index.html @@ -23,8 +23,8 @@ - - + +