diff --git a/frontend/src/pages/PrintersPage.tsx b/frontend/src/pages/PrintersPage.tsx index 46bff3571..0d3487d54 100644 --- a/frontend/src/pages/PrintersPage.tsx +++ b/frontend/src/pages/PrintersPage.tsx @@ -1603,7 +1603,7 @@ function PrinterCard({ {showMenu && ( -
.85?"White":c<.15?o<.4?"Dark Gray":o>.6?"Light Gray":"Gray":l>=15&&l<45&&o<.45||l>=45&&l<70&&o<.4?"Brown":l<15||l>=345?"Red":l<45?"Orange":l<70?"Yellow":l<150?"Green":l<200?"Cyan":l<260?"Blue":l<290?"Purple":l<345?"Pink":"Unknown"}function uj(t){return(t??.02).toFixed(3)}function j7({side:t}){const{mode:e}=Ih(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return a.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded",style:{backgroundColor:n,color:"#00ae42"},children:t})}function P7({className:t}){return a.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:a.jsx("path",{d:"M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z",fill:"#C3C2C1"})})}function l8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z",fill:"#C3C2C1"}),a.jsx("path",{d:"M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z",fill:"#1F8FEB"})]})}function c8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z",fill:"#1F8FEB"}),a.jsx("path",{d:"M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z",fill:"#C3C2C1"})]})}function u8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"}),a.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function d8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function h8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function dj({className:t,color:e,isHeating:n}){const i={"text-orange-400":"#fb923c","text-blue-400":"#60a5fa","text-green-400":"#4ade80"}[e]||"#888",s=n?{filter:`drop-shadow(0 0 4px ${i}) drop-shadow(0 0 8px ${i})`}:{};return n?a.jsxs("svg",{className:t,style:s,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"})]}):a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"}),a.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function D7({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r,compact:i}){const s=typeof t=="string"?parseInt(t,10):t,o=typeof e=="number"?e:40,l=typeof n=="number"?n:60;let c,u;isNaN(s)?(c="#C3C2C1",u="Unknown"):s<=o?(c="#22a352",u="Good"):s<=l?(c="#d4a017",u="Fair"):(c="#c62828",u="Bad");let d;return isNaN(s)||s<=o?d=P7:s<=l?d=l8e:d=c8e,a.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${s}% - ${u}${r?" (click for history)":""}`,children:[a.jsx(d,{className:i?"w-2.5 h-3":"w-3 h-4"}),a.jsxs("span",{className:`font-medium tabular-nums ${i?"text-[10px]":"text-xs"}`,style:{color:c},children:[s,"%"]})]})}function R7({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r,compact:i}){const s=typeof e=="number"?e:28,o=typeof n=="number"?n:35;let l,c,u;return t<=s?(l="#22a352",c="Good",u=u8e):t<=o?(l="#d4a017",c="Fair",u=d8e):(l="#c62828",c="Bad",u=h8e),a.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Temperature: ${t}°C - ${c}${r?" (click for history)":""}`,children:[a.jsx(u,{className:i?"w-2.5 h-3":"w-3 h-4"}),a.jsxs("span",{className:`tabular-nums text-right ${i?"text-[10px] w-8":"w-12"}`,style:{color:l},children:[t,"°C"]})]})}function Ud(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,s=r>=128?r-128:r,o=String.fromCharCode(65+s);return i?`HT-${o}`:`AMS-${o}`}function O7(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function f8e(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function m8e(t,e="system"){const n=new Date,r=new Date(n.getTime()+t*60*1e3),i=new Date;i.setHours(0,0,0,0);const s=new Date(r);s.setHours(0,0,0,0);const o={hour:"2-digit",minute:"2-digit"};e==="12h"?o.hour12=!0:e==="24h"&&(o.hour12=!1);const l=r.toLocaleTimeString([],o),c=Math.floor((s.getTime()-i.getTime())/(1e3*60*60*24));return c===0?l:c===1?`Tomorrow ${l}`:r.toLocaleDateString([],{weekday:"short"})+" "+l}function p8e(t){if(!t)return"/img/printers/default.png";const e=t.toLowerCase().replace(/\s+/g,"");return e.includes("x1e")?"/img/printers/x1e.png":e.includes("x1c")||e.includes("x1carbon")||e.includes("x1")?"/img/printers/x1c.png":e.includes("h2d")||e.includes("h2c")||e.includes("h2s")?"/img/printers/h2d.png":e.includes("p2s")||e.includes("p1s")?"/img/printers/p1s.png":e.includes("p1p")?"/img/printers/p1p.png":e.includes("a1mini")?"/img/printers/a1mini.png":e.includes("a1")?"/img/printers/a1.png":"/img/printers/default.png"}function g8e(t){return t==null?{labelKey:"",color:"text-bambu-gray",bars:0}:t>=-50?{labelKey:"printers.wifiSignal.excellent",color:"text-bambu-green",bars:4}:t>=-60?{labelKey:"printers.wifiSignal.good",color:"text-bambu-green",bars:3}:t>=-70?{labelKey:"printers.wifiSignal.fair",color:"text-yellow-400",bars:2}:t>=-80?{labelKey:"printers.wifiSignal.weak",color:"text-orange-400",bars:1}:{labelKey:"printers.wifiSignal.veryWeak",color:"text-red-400",bars:1}}function hj(t){return t?!!(t.tray_info_idx&&t.tray_info_idx.startsWith("GF")||t.tray_uuid&&t.tray_uuid!=="00000000000000000000000000000000"||t.tag_uid&&t.tag_uid!=="0000000000000000"):!1}function x8e({url:t,printName:e}){const{t:n}=Cn(),[r,i]=_.useState(!1),[s,o]=_.useState(!1),[l,c]=_.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${t&&r?"cursor-pointer":""}`,onClick:()=>t&&r&&c(!0),children:t&&!s?a.jsxs(a.Fragment,{children:[a.jsx("img",{src:t,alt:n("printers.printPreview"),className:`w-full h-full object-cover ${r?"block":"hidden"}`,onLoad:()=>i(!0),onError:()=>o(!0)}),!r&&a.jsx(Bi,{className:"w-8 h-8 text-bambu-gray"})]}):a.jsx(Bi,{className:"w-8 h-8 text-bambu-gray"})}),l&&t&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>c(!1),children:a.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[a.jsx("img",{src:t,alt:n("printers.printPreview"),className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&a.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function b8e({printers:t}){const{t:e}=Cn(),n=un(),r=_.useMemo(()=>{let s=0,o=0,l=0,c=0;return t?.forEach(u=>{const d=n.getQueryData(["printerStatus",u.id]);d===void 0?c++:d.connected?d.state==="RUNNING"?s++:o++:l++}),{printing:s,idle:o,offline:l,loading:c,total:t?.length||0}},[t,n]),[,i]=_.useState(0);return _.useEffect(()=>{let s=!1;const o=n.getQueryCache().subscribe(()=>{s||(s=!0,requestAnimationFrame(()=>{i(l=>l+1),s=!1}))});return()=>o()},[n]),t?.length?a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[r.printing>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:r.printing})," ",e("printers.status.printing").toLowerCase()]})]}),r.idle>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:r.idle})," ",e("printers.status.idle").toLowerCase()]})]}),r.offline>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:r.offline})," ",e("printers.status.offline").toLowerCase()]})]})]}):null}function L7(t,e){if(e)return e;switch(t){case"RUNNING":return"Printing";case"PAUSE":return"Paused";case"FINISH":return"Finished";case"FAILED":return"Failed";case"IDLE":return"Idle";default:return t?t.charAt(0)+t.slice(1).toLowerCase():"Idle"}}function F7({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:s,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,linkedSpools:c,spoolmanUrl:u,timeFormat:d="system",cameraViewMode:h="window",onOpenEmbeddedCamera:p,checkPrinterFirmware:m=!0}){const{t:x}=Cn(),b=un(),v=Ac(),{showToast:y}=Gn(),{hasPermission:S}=Pi(),[N,T]=_.useState(!1),[k,C]=_.useState(!1),[E,P]=_.useState(!0),[A,j]=_.useState(!1),[z,L]=_.useState(!1),[B,R]=_.useState(!1),[$,K]=_.useState(!1),[I,X]=_.useState(!1),[Y,se]=_.useState(!1),[H,q]=_.useState(!1),[ne,re]=_.useState(!1),[xe,pe]=_.useState(!1),[de,Ce]=_.useState(!1),[ie,Ee]=_.useState(null),[Le,fe]=_.useState(null),[Xe,G]=_.useState(null),[Q,me]=_.useState(!1),[W,te]=_.useState(null),[V,ge]=_.useState(!1),[Se,ee]=_.useState(!1),[U,O]=_.useState(null),[Z,oe]=_.useState(!1),[we,ye]=_.useState(!1),{data:ae}=at({queryKey:["printerStatus",t.id],queryFn:()=>ce.getPrinterStatus(t.id),refetchInterval:3e4}),{data:Oe}=at({queryKey:["firmwareUpdate",t.id],queryFn:()=>b1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3,enabled:m}),He=_.useMemo(()=>{const nt=new Set;if(ae?.ams)for(const Dt of ae.ams)for(const Xt of Dt.tray||[])Xt.tray_info_idx&&nt.add(Xt.tray_info_idx);return ae?.vt_tray?.tray_info_idx&&nt.add(ae.vt_tray.tray_info_idx),Array.from(nt)},[ae?.ams,ae?.vt_tray]),{data:tt}=at({queryKey:["filamentInfo",He],queryFn:()=>ce.getFilamentInfo(He),enabled:He.length>0,staleTime:300*1e3}),{data:Ie}=at({queryKey:["slotPresets",t.id],queryFn:()=>ce.getSlotPresets(t.id),staleTime:120*1e3}),[be,Ae]=_.useState(null);_.useEffect(()=>{ae?.wifi_signal!=null&&Ae(ae.wifi_signal)},[ae?.wifi_signal]);const Ue=ae?.wifi_signal??be,Me=_.useRef(void 0);_.useEffect(()=>{ae?.connected!==void 0&&(Me.current=ae.connected)},[ae?.connected]);const Ge=ae?.connected??Me.current,Ne=_.useRef({});_.useEffect(()=>{ae?.ams_extruder_map&&Object.keys(ae.ams_extruder_map).length>0&&(Ne.current=ae.ams_extruder_map)},[ae?.ams_extruder_map]);const rt=ae?.ams_extruder_map&&Object.keys(ae.ams_extruder_map).length>0?ae.ams_extruder_map:Ne.current,ke=_.useRef([]);_.useEffect(()=>{ae?.ams&&ae.ams.length>0&&(ke.current=ae.ams)},[ae?.ams]);const Ke=ae?.ams&&ae.ams.length>0?ae.ams:ke.current,Be=_.useRef(255),ue=ae?.tray_now;ue!==void 0&&ue!==255&&(Be.current=ue);const $e=ue===void 0||ue===255?Be.current:ue,{data:it}=at({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>ce.getSmartPlugByPrinter(t.id)}),{data:kt}=at({queryKey:["scriptPlugsByPrinter",t.id],queryFn:()=>ce.getScriptPlugsByPrinter(t.id)}),{data:xt}=at({queryKey:["smartPlugStatus",it?.id],queryFn:()=>it?ce.getSmartPlugStatus(it.id):null,enabled:!!it,refetchInterval:1e4}),{data:Ht}=at({queryKey:["queue",t.id,"pending"],queryFn:()=>ce.getQueue(t.id,"pending")}),Ft=Ht?.length||0,{data:Fe}=at({queryKey:["queue",t.id,"printing"],queryFn:()=>ce.getQueue(t.id,"printing"),enabled:ae?.state==="RUNNING"}),{data:bt}=at({queryKey:["currentPrintUser",t.id],queryFn:()=>ce.getCurrentPrintUser(t.id),enabled:ae?.state==="RUNNING"}),Wt=Fe?.[0]?.created_by_username||bt?.username,{data:Qt}=at({queryKey:["archives",t.id,"last"],queryFn:()=>ce.getArchives(t.id,1,0),enabled:ae?.connected&&ae?.state!=="RUNNING"}),Sn=Qt?.[0],fn=e&&Ge===!1,sr=pt({mutationFn:nt=>ce.deletePrinter(t.id,nt.deleteArchives),onSuccess:()=>{b.invalidateQueries({queryKey:["printers"]}),b.invalidateQueries({queryKey:["archives"]}),b.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:nt=>y(nt.message||x("printers.toast.failedToDelete"),"error")}),Wn=pt({mutationFn:()=>ce.connectPrinter(t.id),onSuccess:()=>{b.invalidateQueries({queryKey:["printerStatus",t.id]})}}),Qn=pt({mutationFn:nt=>it?ce.controlSmartPlug(it.id,nt):Promise.reject("No plug"),onSuccess:()=>{b.invalidateQueries({queryKey:["smartPlugStatus",it?.id]})}}),En=pt({mutationFn:nt=>it?ce.updateSmartPlug(it.id,{auto_off:nt}):Promise.reject("No plug"),onSuccess:()=>{b.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),b.invalidateQueries({queryKey:["smart-plugs"]})}}),hi=pt({mutationFn:nt=>ce.controlSmartPlug(nt,"on"),onSuccess:()=>{y(x("printers.toast.scriptTriggered"))},onError:nt=>y(nt.message||x("printers.toast.failedToRunScript"),"error")}),ai=pt({mutationFn:()=>ce.stopPrint(t.id),onSuccess:()=>{y(x("printers.toast.printStopped")),b.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:nt=>y(nt.message||x("printers.toast.failedToStopPrint"),"error")}),je=pt({mutationFn:()=>ce.pausePrint(t.id),onSuccess:()=>{y(x("printers.toast.printPaused")),b.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:nt=>y(nt.message||x("printers.toast.failedToPausePrint"),"error")}),Je=pt({mutationFn:()=>ce.resumePrint(t.id),onSuccess:()=>{y(x("printers.toast.printResumed")),b.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:nt=>y(nt.message||x("printers.toast.failedToResumePrint"),"error")}),ut=pt({mutationFn:nt=>ce.setChamberLight(t.id,nt),onMutate:async nt=>{await b.cancelQueries({queryKey:["printerStatus",t.id]});const Dt=b.getQueryData(["printerStatus",t.id]);return b.setQueryData(["printerStatus",t.id],Xt=>({...Xt,chamber_light:nt})),{previousStatus:Dt}},onSuccess:(nt,Dt)=>{y(`Chamber light ${Dt?"on":"off"}`)},onError:(nt,Dt,Xt)=>{Xt?.previousStatus&&b.setQueryData(["printerStatus",t.id],Xt.previousStatus),y(nt.message||x("printers.toast.failedToControlChamberLight"),"error")}}),dt=pt({mutationFn:nt=>ce.updatePrinter(t.id,{plate_detection_enabled:nt}),onSuccess:()=>{b.invalidateQueries({queryKey:["printers"]}),y(dt.variables?x("printers.toast.plateCheckEnabled"):x("printers.toast.plateCheckDisabled"))},onError:nt=>y(nt.message||x("printers.toast.failedToUpdateSetting"),"error")}),ct=(ae?.state==="RUNNING"||ae?.state==="PAUSE"||ae?.state==="PAUSED")&&(ae?.printable_objects_count??0)>=2,{data:At,refetch:he}=at({queryKey:["printableObjects",t.id],queryFn:()=>ce.getPrintableObjects(t.id),enabled:de||ct,refetchInterval:de?5e3:ct?3e4:!1}),De=pt({mutationFn:nt=>ce.skipObjects(t.id,nt),onSuccess:nt=>{y(nt.message||x("printers.skipObjects.objectsSkipped")),he()},onError:nt=>y(nt.message||x("printers.toast.failedToSkipObjects"),"error")}),[Ve,_e]=_.useState(null),Re=_.useRef(!1),et=_.useRef(null),Ye=_.useRef(!1),Ct=pt({mutationFn:({amsId:nt,slotId:Dt})=>ce.refreshAmsSlot(t.id,nt,Dt),onMutate:({amsId:nt,slotId:Dt})=>{et.current&&clearTimeout(et.current),Re.current=!1,Ye.current=!1,_e({amsId:nt,slotId:Dt}),setTimeout(()=>{Ye.current=!0},2e3),et.current=setTimeout(()=>{_e(null)},3e4)},onSuccess:nt=>{y(nt.message||x("printers.toast.rfidRereadInitiated"))},onError:nt=>{y(nt.message||x("printers.toast.failedToRereadRfid"),"error"),et.current&&clearTimeout(et.current),_e(null)}}),[jt,Ut]=_.useState(null),[Rt,Et]=_.useState(null),rn=async()=>{try{const nt=await ce.getPlateReferences(t.id);Ut(nt)}catch{}},Vt=()=>{dt.mutate(!t.plate_detection_enabled)},gn=async()=>{ge(!0),te(null);const nt=ae?.chamber_light===!1;ye(nt),nt&&(await ce.setChamberLight(t.id,!0),await new Promise(Dt=>setTimeout(Dt,2500)));try{const Dt=await ce.checkPlateEmpty(t.id,{includeDebugImage:!0});te(Dt),rn()}catch(Dt){y(Dt instanceof Error?Dt.message:x("printers.toast.failedToCheckPlate"),"error"),nt&&(await ce.setChamberLight(t.id,!1),ye(!1))}finally{ge(!1)}},mn=_.useCallback(async()=>{te(null),we&&(await ce.setChamberLight(t.id,!1),ye(!1))},[we,t.id]),Tn=async nt=>{ee(!0);try{const Dt=await ce.calibratePlateDetection(t.id,{label:nt});if(Dt.success){y(Dt.message||x("printers.toast.calibrationSaved"),"success"),rn();const Xt=await ce.checkPlateEmpty(t.id,{includeDebugImage:!0});te(Xt)}else y(Dt.message||x("printers.toast.calibrationFailed"),"error")}catch(Dt){y(Dt instanceof Error?Dt.message:x("printers.toast.calibrationFailed"),"error")}finally{ee(!1)}},Kt=async(nt,Dt)=>{try{await ce.updatePlateReferenceLabel(t.id,nt,Dt),Et(null),rn()}catch(Xt){y(Xt instanceof Error?Xt.message:x("printers.toast.failedToUpdateLabel"),"error")}},dn=async nt=>{try{await ce.deletePlateReference(t.id,nt),y(x("printers.toast.referenceDeleted"),"success"),rn();const Dt=await ce.checkPlateEmpty(t.id,{includeDebugImage:!0});te(Dt)}catch(Dt){y(Dt instanceof Error?Dt.message:x("printers.toast.failedToDeleteReference"),"error")}},pn=async()=>{if(U){oe(!0);try{await ce.updatePrinter(t.id,{plate_detection_roi:U}),y(x("printers.toast.detectionAreaSaved"),"success"),O(null);const nt=await ce.checkPlateEmpty(t.id,{includeDebugImage:!0});te(nt)}catch(nt){y(nt instanceof Error?nt.message:x("printers.toast.failedToSaveDetectionArea"),"error")}finally{oe(!1)}}};_.useEffect(()=>{const nt=Dt=>{Dt.key==="Escape"&&W&&mn()};return window.addEventListener("keydown",nt),()=>window.removeEventListener("keydown",nt)},[W,mn]);const en=_.useRef(null);_.useEffect(()=>{if(!Ve)return;const nt=ae?.ams_status_main??0;return nt!==0&&(Re.current=!0,en.current&&(clearTimeout(en.current),en.current=null)),Re.current&&nt===0&&(Ye.current?(et.current&&clearTimeout(et.current),_e(null)):en.current||(en.current=setTimeout(()=>{et.current&&clearTimeout(et.current),_e(null)},2e3))),()=>{en.current&&clearTimeout(en.current)}},[ae?.ams_status_main,Ve]);const[ir,Ln]=_.useState(null);if(fn)return null;const si=()=>{switch(i){case 1:return"w-10 h-10";case 2:return"w-14 h-14";case 3:return"w-16 h-16";case 4:return"w-20 h-20";default:return"w-14 h-14"}},ar=()=>{switch(i){case 1:return"text-base truncate";case 2:return"text-lg";case 3:return"text-xl";case 4:return"text-2xl";default:return"text-lg"}},dr=()=>{switch(i){case 1:return"mb-2";case 2:return"mb-4";case 3:return"mb-5";case 4:return"mb-6";default:return"mb-4"}};return a.jsxs(Nt,{className:"relative",children:[a.jsxs(Mt,{className:i>=3?"p-5":"",children:[a.jsxs("div",{className:dr(),children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("img",{src:p8e(t.model),alt:t.model||x("common.printer"),className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${si()}`}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:`font-semibold text-white ${ar()}`,children:t.name}),r==="compact"&&a.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${ae?.connected?"bg-status-ok":"bg-status-error"}`,title:ae?.connected?x("printers.connection.connected"):x("printers.connection.offline")})]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&ae?.nozzles&&ae.nozzles[0]?.nozzle_diameter&&a.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:ae.nozzles[0].nozzle_type||"Nozzle",children:["• ",ae.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&a.jsxs("span",{className:"ml-2 text-bambu-gray",children:[a.jsx(nr,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),a.jsxs("div",{className:"relative flex-shrink-0",children:[a.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>T(!N),children:a.jsx(lh,{className:"w-4 h-4"})}),N&&a.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10",children:[a.jsxs("button",{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${S("printers:update")?"hover:bg-bambu-dark-tertiary":"opacity-50 cursor-not-allowed"}`,onClick:()=>{S("printers:update")&&(j(!0),T(!1))},title:S("printers:update")?void 0:x("printers.permission.noEdit"),children:[a.jsx(ta,{className:"w-4 h-4"}),x("common.edit")]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{Wn.mutate(),T(!1)},children:[a.jsx(Rr,{className:"w-4 h-4"}),x("printers.reconnect")]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{R(!0),T(!1)},children:[a.jsx(FW,{className:"w-4 h-4"}),x("printers.mqttDebug")]}),a.jsxs("button",{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${S("printers:delete")?"text-red-400 hover:bg-bambu-dark-tertiary":"text-red-400/50 cursor-not-allowed"}`,onClick:()=>{S("printers:delete")&&(C(!0),T(!1))},title:S("printers:delete")?void 0:x("printers.permission.noDelete"),children:[a.jsx(cn,{className:"w-4 h-4"}),x("common.delete")]})]})]})]}),r==="expanded"&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[a.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${ae?.connected?"bg-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[ae?.connected?a.jsx(Uy,{className:"w-3 h-3"}):a.jsx(zR,{className:"w-3 h-3"}),ae?.connected?x("printers.connection.connected"):x("printers.connection.offline")]}),ae?.connected&&Ue!=null&&a.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${Ue>=-50||Ue>=-60?"bg-status-ok/20 text-status-ok":Ue>=-70?"bg-status-warning/20 text-status-warning":Ue>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${Ue} dBm - ${x(g8e(Ue).labelKey)}`,children:[a.jsx(Ihe,{className:"w-3 h-3"}),Ue,"dBm"]}),ae?.connected&&(()=>{const nt=ae.hms_errors?t2e(ae.hms_errors):[];return a.jsxs("button",{onClick:()=>se(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${nt.length>0?nt.some(Dt=>Dt.severity<=2)?"bg-status-error/20 text-status-error":"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:x("printers.clickToViewHmsErrors"),children:[a.jsx(kn,{className:"w-3 h-3"}),nt.length>0?nt.length:"OK"]})})(),n&&a.jsxs("button",{onClick:()=>v("/maintenance"),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?"bg-status-error/20 text-status-error":n.warning_count>0?"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:""}${n.due_count>0&&n.warning_count>0?", ":""}${n.warning_count>0?`${n.warning_count} due soon`:""} - Click to view`:x("printers.maintenanceUpToDate"),children:[a.jsx(cm,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Ft>0&&a.jsxs("button",{onClick:()=>v("/queue"),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-purple-500/20 text-purple-400 hover:opacity-80 transition-opacity",title:x("printers.queue.inQueue",{count:Ft}),children:[a.jsx(xs,{className:"w-3 h-3"}),Ft]}),Oe?.update_available&&a.jsxs("button",{onClick:()=>me(!0),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-orange-500/20 text-orange-400 hover:opacity-80 transition-opacity",title:x("printers.firmwareUpdateAvailable",{current:Oe.current_version,latest:Oe.latest_version}),children:[a.jsx(_i,{className:"w-3 h-3"}),x("printers.firmwareUpdateButton")]})]})]}),k&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsx(Nt,{className:"w-full max-w-md mx-4",children:a.jsxs(Mt,{children:[a.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[a.jsx("div",{className:"p-2 rounded-full bg-red-500/20",children:a.jsx(kn,{className:"w-5 h-5 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:x("printers.confirm.deleteTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:x("printers.confirm.deleteMessage",{name:t.name})})]})]}),a.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E,onChange:nt=>P(nt.target.checked),className:"mt-0.5 w-4 h-4 rounded border-bambu-gray bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:x("printers.deleteArchives")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:x(E?"printers.confirm.deleteArchivesNote":"printers.confirm.keepArchivesNote")})]})]})}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Te,{variant:"secondary",onClick:()=>{C(!1),P(!0)},children:x("common.cancel")}),a.jsx(Te,{variant:"danger",onClick:()=>{sr.mutate({deleteArchives:E}),C(!1),P(!0)},children:"Delete"})]})]})})}),ae?.connected&&a.jsxs(a.Fragment,{children:[r==="compact"?a.jsx("div",{className:"mt-2",children:ae.state==="RUNNING"?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:a.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${ae.progress||0}%`}})}),a.jsxs("span",{className:"text-xs text-white",children:[Math.round(ae.progress||0),"%"]})]}):a.jsx("p",{className:"text-xs text-bambu-gray",children:L7(ae.state,ae.stg_cur_name)})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg relative",children:[a.jsxs("button",{onClick:()=>Ce(!0),disabled:!(ae.state==="RUNNING"||ae.state==="PAUSE"||ae.state==="PAUSED")||(ae.printable_objects_count??0)<2||!S("printers:control"),className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(ae.state==="RUNNING"||ae.state==="PAUSE"||ae.state==="PAUSED")&&(ae.printable_objects_count??0)>=2&&S("printers:control")?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:S("printers:control")?ae.state==="RUNNING"||ae.state==="PAUSE"||ae.state==="PAUSED"?(ae.printable_objects_count??0)>=2?x("printers.skipObjects.tooltip"):x("printers.skipObjects.requiresMultiple"):x("printers.skipObjects.onlyWhilePrinting"):x("printers.permission.noControl"),children:[a.jsx(A7,{className:"w-4 h-4"}),At&&At.skipped_count>0&&a.jsx("span",{className:"absolute -top-1 -right-1 min-w-[16px] h-4 px-1 flex items-center justify-center text-[10px] font-bold bg-red-500 text-white rounded-full",children:At.skipped_count})]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(x8e,{url:ae.state==="RUNNING"?ae.cover_url:null,printName:ae.state==="RUNNING"&&(ae.subtask_name||ae.current_print)||void 0}),a.jsx("div",{className:"flex-1 min-w-0",children:ae.current_print&&ae.state==="RUNNING"?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:ae.stg_cur_name||"Printing"}),a.jsx("p",{className:"text-white text-sm mb-2 truncate",children:ae.subtask_name||ae.current_print}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${ae.progress||0}%`}})}),a.jsxs("span",{className:"text-white",children:[Math.round(ae.progress||0),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[ae.remaining_time!=null&&ae.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(nr,{className:"w-3 h-3"}),f8e(ae.remaining_time*60)]}),a.jsxs("span",{className:"text-bambu-green font-medium",title:x("printers.estimatedCompletion"),children:["ETA ",m8e(ae.remaining_time,d)]})]}),ae.layer_num!=null&&ae.total_layers!=null&&ae.total_layers>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(xs,{className:"w-3 h-3"}),ae.layer_num,"/",ae.total_layers]}),Wt&&a.jsxs("span",{className:"flex items-center gap-1",title:`Started by ${Wt}`,children:[a.jsx(Uu,{className:"w-3 h-3"}),Wt]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:x("printers.sort.status")}),a.jsx("p",{className:"text-white text-sm mb-2",children:L7(ae.state,ae.stg_cur_name)}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:a.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),a.jsx("span",{className:"text-bambu-gray",children:"—"})]}),Sn?a.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:Sn.print_name||Sn.filename,children:["Last: ",Sn.print_name||Sn.filename,Sn.completed_at&&a.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",$g(Sn.completed_at,{month:"short",day:"numeric"})]})]}):a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:x("printers.readyToPrint")})]})})]})]}),ae.state!=="RUNNING"&&a.jsx(a2e,{printerId:t.id})]}),ae.temperatures&&r==="expanded"&&(()=>{const nt=ae.temperatures.nozzle_heating||ae.temperatures.nozzle_2_heating||!1,Dt=ae.temperatures.bed_heating||!1,Xt=ae.temperatures.chamber_heating||!1,wt=t.nozzle_count===2||ae.temperatures.nozzle_2!==void 0,Nn=ae.active_extruder===1?"L":"R";return a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[a.jsx(dj,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:nt}),ae.temperatures.nozzle_2!==void 0?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:"L / R"}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.nozzle||0),"° / ",Math.round(ae.temperatures.nozzle_2||0),"°"]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.nozzle")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.nozzle||0),"°C"]})]})]}),a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[a.jsx(dj,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-blue-400",isHeating:Dt}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.bed")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.bed||0),"°C"]})]}),ae.temperatures.chamber!==void 0&&a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[a.jsx(dj,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-green-400",isHeating:Xt}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.chamber")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.chamber||0),"°C"]})]}),wt&&a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg",title:x("printers.activeNozzle",{nozzle:x(Nn==="L"?"common.left":"common.right")}),children:[a.jsx("p",{className:`text-[11px] font-bold ${Nn==="L"?"text-amber-400":"text-gray-500"}`,children:"L"}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.nozzle")}),a.jsx("p",{className:`text-[11px] font-bold ${Nn==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const nt=ae.state==="RUNNING",Dt=ae.state==="PAUSED"||ae.state==="PAUSE",Xt=nt||Dt,wt=ai.isPending||je.isPending||Je.isPending,Nn=ae.cooling_fan_speed,Ir=ae.big_fan1_speed,Qr=ae.big_fan2_speed;return a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:x("printers.controls")}),a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Nn&&Nn>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:x("printers.fans.partCooling"),children:[a.jsx(EW,{className:`w-3.5 h-3.5 ${Nn&&Nn>0?"text-cyan-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${Nn&&Nn>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[Nn??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Ir&&Ir>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:x("printers.fans.auxiliary"),children:[a.jsx(UW,{className:`w-3.5 h-3.5 ${Ir&&Ir>0?"text-blue-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${Ir&&Ir>0?"text-blue-400":"text-bambu-gray/50"}`,children:[Ir??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Qr&&Qr>0?"bg-green-500/10":"bg-bambu-dark"}`,title:x("printers.fans.chamber"),children:[a.jsx(pce,{className:`w-3.5 h-3.5 ${Qr&&Qr>0?"text-green-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${Qr&&Qr>0?"text-green-400":"text-bambu-gray/50"}`,children:[Qr??0,"%"]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:()=>q(!0),disabled:!Xt||wt||!S("printers:control"),className:` + `})]})]})}function ZBe({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const{t:i}=Cn(),s=un(),{showToast:o}=Gn(),[l,c]=_.useState(null),{data:u,isLoading:d}=at({queryKey:["unlinked-spools"],queryFn:ce.getUnlinkedSpools,enabled:t}),h=pt({mutationFn:m=>ce.linkSpool(m,n),onSuccess:()=>{s.invalidateQueries({queryKey:["unlinked-spools"]}),s.invalidateQueries({queryKey:["linked-spools"]}),s.invalidateQueries({queryKey:["spoolman-status"]}),o(i("spoolman.linkSuccess"),"success"),e()},onError:m=>{o(`${i("spoolman.linkFailed")}: ${m.message}`,"error")}});if(!t)return null;const p=()=>{l&&h.mutate(l)};return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.jsxs("div",{className:"relative w-full max-w-md mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(fc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("spoolman.linkToSpoolman")})]}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[r&&a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Linking AMS tray:"}),a.jsxs("div",{className:"flex items-center gap-2",children:[r.color&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.color}`}}),a.jsx("span",{className:"text-white font-medium",children:r.type}),a.jsxs("span",{className:"text-bambu-gray",children:["(",r.location,")"]})]})]}),a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-xs text-bambu-gray mb-1",children:[i("spoolman.spoolId"),":"]}),a.jsx("code",{className:"text-xs text-bambu-green font-mono break-all",children:n})]}),a.jsxs("div",{children:[a.jsxs("p",{className:"text-sm text-bambu-gray mb-2",children:[i("spoolman.selectSpool"),":"]}),d?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(mt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2",children:u.map(m=>a.jsx("button",{onClick:()=>c(m.id),className:`w-full p-3 rounded-lg border text-left transition-colors ${l===m.id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[m.filament_color_hex&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:`#${m.filament_color_hex}`}}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-white font-medium truncate",children:m.filament_name||"Unknown filament"}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[m.filament_material||"Unknown",m.remaining_weight!==null&&` - ${Math.round(m.remaining_weight)}g`,m.location&&` - ${m.location}`]})]}),l===m.id&&a.jsx(Ci,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},m.id))}):a.jsx("div",{className:"text-center py-8 text-bambu-gray",children:a.jsx("p",{children:i("spoolman.noUnlinkedSpools")})})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Te,{variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Te,{onClick:p,disabled:!l||h.isPending,children:h.isPending?a.jsxs(a.Fragment,{children:[a.jsx(mt,{className:"w-4 h-4 animate-spin"}),i("spoolman.syncing")]}):a.jsxs(a.Fragment,{children:[a.jsx(fc,{className:"w-4 h-4"}),i("spoolman.linkToSpoolman")]})})]}),h.isError&&a.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:h.error.message})]})]})}function JBe(t,e){if(t===255)return"External";let n,r=!1;t>=128&&t<=135?(n=t-128,r=!0):t>=0&&t<=3?(n=t,r=e===1):n=0,n=Math.max(0,Math.min(n,7));const i=String.fromCharCode(65+n);return r?`HT-${i}`:`AMS-${i}`}function E7(t){const e=t.includes("_")?t.split("_")[0]:t;return e.startsWith("GFS")?"GF"+e.slice(3):(e.startsWith("PFUS")||e.startsWith("PFSP"),e)}const e8e=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function T7(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of e8e){const s=new RegExp(`\\b${i}\\b`,"i");if(s.test(n)){const o=e.split(s),l=o[0]?.trim()||"",c=o[1]?.trim()||"";return{material:i,brand:l,variant:c}}}const r=e.split(/\s+/);return r.length>=2?{material:r[1],brand:r[0],variant:r.slice(2).join(" ")}:{material:e,brand:"",variant:""}}function oj(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const t8e={white:"FFFFFF",black:"000000",red:"FF0000",green:"00FF00",blue:"0000FF",yellow:"FFFF00",cyan:"00FFFF",magenta:"FF00FF",orange:"FFA500",purple:"800080",pink:"FFC0CB",brown:"8B4513",gray:"808080",grey:"808080","jade white":"FFFEF2",ivory:"FFFFF0",beige:"F5F5DC",cream:"FFFDD0",silver:"C0C0C0",gold:"FFD700",bronze:"CD7F32",copper:"B87333",navy:"000080",teal:"008080",olive:"808000",maroon:"800000",coral:"FF7F50",salmon:"FA8072",lime:"32CD32",mint:"98FF98","forest green":"228B22","sky blue":"87CEEB","royal blue":"4169E1",turquoise:"40E0D0",lavender:"E6E6FA",violet:"EE82EE",plum:"DDA0DD",tan:"D2B48C",chocolate:"D2691E",charcoal:"36454F",slate:"708090",transparent:"000000",natural:"F5F5DC",wood:"DEB887"},n8e=[{name:"White",hex:"FFFFFF"},{name:"Black",hex:"000000"},{name:"Red",hex:"FF0000"},{name:"Blue",hex:"0000FF"},{name:"Green",hex:"00AA00"},{name:"Yellow",hex:"FFFF00"},{name:"Orange",hex:"FFA500"},{name:"Gray",hex:"808080"}],r8e=[{name:"Cyan",hex:"00FFFF"},{name:"Magenta",hex:"FF00FF"},{name:"Purple",hex:"800080"},{name:"Pink",hex:"FFC0CB"},{name:"Brown",hex:"8B4513"},{name:"Beige",hex:"F5F5DC"},{name:"Navy",hex:"000080"},{name:"Teal",hex:"008080"},{name:"Lime",hex:"32CD32"},{name:"Gold",hex:"FFD700"},{name:"Silver",hex:"C0C0C0"},{name:"Maroon",hex:"800000"},{name:"Olive",hex:"808000"},{name:"Coral",hex:"FF7F50"},{name:"Salmon",hex:"FA8072"},{name:"Turquoise",hex:"40E0D0"},{name:"Violet",hex:"EE82EE"},{name:"Indigo",hex:"4B0082"},{name:"Chocolate",hex:"D2691E"},{name:"Tan",hex:"D2B48C"},{name:"Slate",hex:"708090"},{name:"Charcoal",hex:"36454F"},{name:"Ivory",hex:"FFFFF0"},{name:"Cream",hex:"FFFDD0"}];function i8e(t){const e=t.toLowerCase().trim();return t8e[e]||null}function a8e({isOpen:t,onClose:e,printerId:n,slotInfo:r,nozzleDiameter:i="0.4",onSuccess:s}){const[o,l]=_.useState(""),[c,u]=_.useState(null),[d,h]=_.useState(""),[p,m]=_.useState(""),[x,b]=_.useState(""),[v,y]=_.useState(!1),[S,N]=_.useState(!1),{data:T,isLoading:k}=at({queryKey:["cloudSettings"],queryFn:()=>ce.getCloudSettings(),enabled:t}),{data:C,isLoading:E}=at({queryKey:["kprofiles",n,i],queryFn:()=>ce.getKProfiles(n,i),enabled:t&&!!n}),P=pt({mutationFn:async()=>{if(!o)throw new Error("No filament preset selected");const X=T?.filament.find(ie=>ie.setting_id===o);if(!X)throw new Error("Selected preset not found");const Y=T7(X.name),se=c?.slot_id??-1,H=d||r.trayColor?.slice(0,6)||"FFFFFF",q=X.name.replace(/@.+$/,"").trim();let ne=E7(o);if(!o.startsWith("GFS"))try{const ie=await ce.getCloudSettingDetail(o);ie.filament_id?ne=ie.filament_id:ie.base_id&&(ne=E7(ie.base_id),console.log(`Derived tray_info_idx from base_id: ${ie.base_id} -> ${ne}`))}catch(ie){console.warn("Failed to fetch preset detail for filament_id:",ie)}let re=190,xe=230;const pe=Y.material.toUpperCase();pe.includes("PLA")?(re=190,xe=230):pe.includes("PETG")?(re=220,xe=260):pe.includes("ABS")||pe.includes("ASA")?(re=240,xe=280):pe.includes("TPU")?(re=200,xe=240):pe.includes("PC")?(re=260,xe=300):(pe.includes("PA")||pe.includes("NYLON"))&&(re=250,xe=290);const de=c?.k_value?parseFloat(c.k_value):0,Ce=await ce.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:ne,tray_type:Y.material||"PLA",tray_sub_brands:q,tray_color:H+"FF",nozzle_temp_min:re,nozzle_temp_max:xe,cali_idx:se,nozzle_diameter:i,setting_id:o,kprofile_filament_id:c?.filament_id,kprofile_setting_id:c?.setting_id||void 0,k_value:de});try{await ce.saveSlotPreset(n,r.amsId,r.trayId,o,q)}catch(ie){console.warn("Failed to save slot preset mapping:",ie)}return Ce},onSuccess:()=>{y(!0),s?.(),setTimeout(()=>{y(!1),e()},1500)}}),A=pt({mutationFn:async()=>ce.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{y(!0),s?.(),setTimeout(()=>{y(!1),e()},1500)}}),j=_.useMemo(()=>{if(!T?.filament)return[];const X=x.toLowerCase();return T.filament.filter(Y=>X?Y.name.toLowerCase().includes(X):!0).sort((Y,se)=>{const H=oj(Y.setting_id),q=oj(se.setting_id);return H&&!q?-1:!H&&q?1:Y.name.localeCompare(se.name)})},[T?.filament,x]),z=_.useMemo(()=>{if(!o||!T?.filament)return null;const X=T.filament.find(H=>H.setting_id===o);if(!X)return null;let Y=X.name.replace(/@.+$/,"").trim();Y.startsWith("# ")&&(Y=Y.slice(2).trim());const se=T7(Y);return{fullName:Y,material:se.material,brand:se.brand}},[o,T?.filament]),L=z?.fullName||"",B=_.useMemo(()=>{if(!C?.profiles||!z)return[];const{fullName:X,material:Y,brand:se}=z,H=X.toUpperCase(),q=Y.toUpperCase(),ne=se.toUpperCase();if(!q||q.length<2)return[];const re=C.profiles.filter(pe=>{const de=pe.name.toUpperCase();if(ne)return!(!de.includes(ne)||!de.includes(q));if(de.includes(H)||de.includes(q))return!0;const ie={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[q]||[];for(const Ee of ie)if(de.includes(Ee))return!0;return!1}),xe=new Map;for(const pe of re){const de=`${pe.name}|${pe.k_value}`,Ce=xe.get(de);Ce?pe.extruder_id===1&&Ce.extruder_id===0&&xe.set(de,pe):xe.set(de,pe)}return Array.from(xe.values())},[C?.profiles,z]);_.useEffect(()=>{if(t&&T?.filament){if(r.trayInfoIdx){const X=T.filament.find(Y=>Y.setting_id===r.trayInfoIdx);X&&l(X.setting_id)}}else t||(l(""),u(null),h(""),m(""),b(""),y(!1))},[t,T?.filament,r.trayInfoIdx]),_.useEffect(()=>{B.length>0?u(B[0]):u(null)},[o,B]);const R=_.useCallback(X=>{X.key==="Escape"&&e()},[e]);if(_.useEffect(()=>{if(t)return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[t,R]),!t)return null;const $=k||E,K=o&&!P.isPending,I=d||r.trayColor?.slice(0,6)||"FFFFFF";return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Sh,{className:"w-5 h-5 text-bambu-blue"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Configure AMS Slot"})]}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4 max-h-[60vh] overflow-y-auto",children:[v&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-secondary/95 z-10 flex items-center justify-center rounded-xl",children:a.jsxs("div",{className:"text-center space-y-3",children:[a.jsx(cM,{className:"w-16 h-16 text-bambu-green mx-auto"}),a.jsx("p",{className:"text-lg font-semibold text-white",children:"Slot Configured!"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Settings sent to printer"})]})}),a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Configuring slot:"}),a.jsxs("div",{className:"flex items-center gap-2",children:[r.trayColor&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.trayColor.slice(0,6)}`}}),a.jsxs("span",{className:"text-white font-medium",children:[JBe(r.amsId,r.trayCount)," Slot ",r.trayId+1]}),r.traySubBrands&&a.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),$?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(mt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["Filament Profile ",a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",placeholder:"Search presets...",value:x,onChange:X=>b(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none mb-2"}),a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:j.length===0?a.jsx("p",{className:"text-center py-4 text-bambu-gray",children:T?.filament?.length===0?"No cloud presets. Login to Bambu Cloud to sync.":"No matching presets found."}):j.map(X=>a.jsx("button",{onClick:()=>l(X.setting_id),className:`w-full p-2 rounded-lg border text-left transition-colors ${o===X.setting_id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-white text-sm truncate",children:X.name}),oj(X.setting_id)&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:"Custom"})]})},X.setting_id))})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["K Profile (Pressure Advance)",L&&a.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",L]})]}),B.length>0?a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:c?.name||"",onChange:X=>{const Y=B.find(se=>se.name===X.target.value);u(Y||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 appearance-none pr-10",children:[a.jsx("option",{value:"",children:"No K profile (use default 0.020)"}),B.map(X=>a.jsxs("option",{value:X.name,children:[X.name," (K=",X.k_value,")"]},`${X.name}-${X.extruder_id}`))]}),a.jsx(zr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}):o?a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:"No matching K profiles found. Default K=0.020 will be used."}):a.jsx("span",{className:"inline-block text-xs px-2 py-1 rounded bg-amber-500/20 text-amber-400 border border-amber-500/30",children:"Select a filament profile first"}),c&&a.jsxs("p",{className:"text-xs text-bambu-green mt-1",children:["K=",c.k_value," from printer calibration"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Custom Color (optional)"}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[n8e.map(X=>a.jsx("button",{onClick:()=>{h(X.hex),m(X.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===X.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${X.hex}`},title:X.name},X.hex)),a.jsx("button",{onClick:()=>N(!S),className:"w-7 h-7 rounded-md border-2 border-white/20 hover:border-white/40 flex items-center justify-center text-white/60 hover:text-white/80 transition-all text-xs",title:S?"Show less colors":"Show more colors",children:S?"−":"+"})]}),S&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:r8e.map(X=>a.jsx("button",{onClick:()=>{h(X.hex),m(X.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===X.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${X.hex}`},title:X.name},X.hex))}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg border-2 border-white/20 flex-shrink-0",style:{backgroundColor:`#${I}`}}),a.jsx("input",{type:"text",placeholder:"Color name or hex (e.g., brown, FF8800)",value:p,onChange:X=>{const Y=X.target.value;m(Y);const se=i8e(Y);if(se)h(se);else{const H=Y.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();H.length===6?h(H):H.length===3&&h(H.split("").map(q=>q+q).join(""))}},className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none text-sm"}),d&&a.jsx("button",{onClick:()=>{h(""),m("")},className:"px-2 py-1 text-xs text-bambu-gray hover:text-white bg-bambu-dark-tertiary rounded",title:"Clear custom color",children:"Clear"})]}),d&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5",children:["Hex: #",d]})]})]})]}),a.jsxs("div",{className:"flex justify-between p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Te,{variant:"secondary",onClick:()=>A.mutate(),disabled:A.isPending||P.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:A.isPending?a.jsxs(a.Fragment,{children:[a.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Fh,{className:"w-4 h-4"}),"Reset Slot"]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Te,{variant:"secondary",onClick:e,children:"Cancel"}),a.jsx(Te,{onClick:()=>P.mutate(),disabled:!K,children:P.isPending?a.jsxs(a.Fragment,{children:[a.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Sh,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(P.isError||A.isError)&&a.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:P.error?.message||A.error?.message})]})]})}function s8e({on:t,className:e="w-5 h-5"}){const n=t?"#facc15":"none",r=t?"#78350f":"currentColor",i=t?1:0;return a.jsxs("svg",{viewBox:"0 0 32 32",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[a.jsxs("g",{stroke:r,opacity:i,children:[a.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),a.jsx("line",{x1:"6.1",y1:"6.1",x2:"8.9",y2:"8.9"}),a.jsx("line",{x1:"25.9",y1:"6.1",x2:"23.1",y2:"8.9"}),a.jsx("line",{x1:"2",y1:"16",x2:"6",y2:"16"}),a.jsx("line",{x1:"30",y1:"16",x2:"26",y2:"16"})]}),a.jsx("path",{d:"M12 24v-2.3c0-.9-.4-1.7-1-2.3C9.2 17.6 8 15.4 8 13c0-4.4 3.6-8 8-8s8 3.6 8 8c0 2.4-1.2 4.6-3 6.4-.6.6-1 1.4-1 2.3V24",fill:n,stroke:r}),a.jsx("path",{d:"M12 24h8",stroke:r}),a.jsx("path",{d:"M12 27h8",stroke:r}),a.jsx("path",{d:"M13 30h6",stroke:r})]})}const A7=({className:t})=>a.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[a.jsx("rect",{x:"2",y:"15",width:"5",height:"5",rx:"0.5"}),a.jsx("rect",{x:"9.5",y:"15",width:"5",height:"5",rx:"0.5",fill:"currentColor",opacity:"0.3"}),a.jsx("rect",{x:"17",y:"15",width:"5",height:"5",rx:"0.5"}),a.jsx("path",{d:"M4 12 C4 6, 14 6, 14 12"}),a.jsx("polyline",{points:"12,10 14,12 12,14"})]}),C7={"A00-W1":"Jade White","A00-P0":"Beige","A00-D2":"Light Gray","A00-Y0":"Yellow","A00-Y2":"Sunflower Yellow","A00-A1":"Pumpkin Orange","A00-A0":"Orange","A00-Y4":"Gold","A00-G3":"Bright Green","A00-G1":"Bambu Green","A00-G2":"Mistletoe Green","A00-R3":"Hot Pink","A00-P6":"Magenta","A00-R0":"Red","A00-R2":"Maroon Red","A00-P5":"Purple","A00-P2":"Indigo Purple","A00-B5":"Turquoise","A00-B8":"Cyan","A00-B3":"Cobalt Blue","A00-N0":"Brown","A00-N1":"Cocoa Brown","A00-Y3":"Bronze","A00-D0":"Gray","A00-D1":"Silver","A00-B1":"Blue Grey","A00-D3":"Dark Gray","A00-K0":"Black","A00-M3":"Pink Citrus","A00-M6":"Dusk Glare","A00-M0":"Arctic Whisper","A00-M1":"Solar Breeze","A00-M5":"Blueberry Bubblegum","A00-M4":"Mint Lime","A00-M2":"Ocean to Meadow","A00-M7":"Cotton Candy Cloud","A18-K0":"Black","A18-D0":"Gray","A18-W0":"White","A18-R0":"Red","A18-Y0":"Yellow","A18-B0":"Cyan","A18-B1":"Blue","A18-P0":"Matte Beige","A01-W2":"Ivory White","A01-W3":"Bone White","A01-Y2":"Lemon Yellow","A01-A2":"Mandarin Orange","A01-P3":"Sakura Pink","A01-P4":"Lilac Purple","A01-R3":"Plum","A01-R1":"Scarlet Red","A01-R4":"Dark Red","A01-G0":"Apple Green","A01-G1":"Grass Green","A01-G7":"Dark Green","A01-B4":"Ice Blue","A01-B0":"Sky Blue","A01-B3":"Marine Blue","A01-B6":"Dark Blue","A01-Y3":"Desert Tan","A01-N1":"Latte Brown","A01-N3":"Caramel","A01-R2":"Terracotta","A01-N2":"Dark Brown","A01-N0":"Dark Chocolate","A01-D3":"Ash Gray","A01-D0":"Nardo Gray","A01-K1":"Charcoal","A12-G0":"Green","A12-R0":"Pink","A12-A0":"Orange","A12-Y0":"Yellow","A12-B0":"Blue","A07-R5":"Red Granite","A07-D4":"White Marble","A11-W0":"White","A11-K0":"Black","A08-G3":"Alpine Green Sparkle","A08-D5":"Slate Gray Sparkle","A08-B7":"Royal Purple Sparkle","A08-R2":"Crimson Red Sparkle","A08-K2":"Onyx Black Sparkle","A08-Y1":"Classic Gold Sparkle","A02-B2":"Cobalt Blue Metallic","A02-G2":"Oxide Green Metallic","A02-Y1":"Iridium Gold Metallic","A02-D2":"Iron Gray Metallic","A17-B1":"Blue","A17-A0":"Orange","A17-P0":"Purple","A06-Y1":"Gold","A06-D0":"Titan Gray","A06-D1":"Silver","A06-W0":"White","A06-R0":"Candy Red","A06-G0":"Candy Green","A06-G1":"Mint","A06-B1":"Blue","A06-B0":"Baby Blue","A06-P0":"Purple","A06-R1":"Rose Gold","A06-R2":"Pink","A06-Y0":"Champagne","A05-M8":"Dawn Radiance","A05-M4":"Aurora Purple","A05-M1":"South Beach","A05-T3":"Neon City","A05-T2":"Midnight Blaze","A05-T1":"Gilded Rose","A05-T4":"Blue Hawaii","A05-T5":"Velvet Eclipse","A15-B0":"Purple","A15-G0":"Green","A15-G1":"Nebulae","A15-R0":"Brown","A16-K0":"Black Walnut","A16-R0":"Rosewood","A16-N0":"Clay Brown","A16-G0":"Classic Birch","A16-W0":"White Oak","A16-Y0":"Ochre Yellow","A50-D6":"Lava Gray","A50-K0":"Black","A50-B6":"Royal Blue","A10-W0":"White","A10-D0":"Gray","A09-B5":"Lavender Blue","A09-B4":"Light Blue","A09-A0":"Orange","A09-D1":"Silver","A09-R3":"Vermilion Red","A09-Y0":"Yellow","G02-K0":"Black","G02-W0":"White","G02-R0":"Red","G02-D0":"Gray","G02-D1":"Dark Gray","G02-Y1":"Cream","G02-Y0":"Yellow","G02-A0":"Orange","G02-N1":"Peanut Brown","G02-G1":"Lime Green","G02-G0":"Green","G02-G2":"Forest Green","G02-B1":"Lake Blue","G02-B0":"Blue","G01-G1":"Translucent Teal","G01-B0":"Translucent Light Blue","G01-C0":"Clear","G01-D0":"Translucent Gray","G01-G0":"Translucent Olive","G01-N0":"Translucent Brown","G01-A0":"Translucent Orange","G01-P1":"Translucent Pink","G01-P0":"Translucent Purple","G50-P7":"Violet Purple","G50-K0":"Black","B00-D1":"Silver","B00-K0":"Black","B00-W0":"White","B00-G6":"Bambu Green","B00-G7":"Olive","B00-Y1":"Tangerine Yellow","B00-A0":"Orange","B00-R0":"Red","B00-B4":"Azure","B00-B0":"Blue","B00-B6":"Navy Blue","B50-A0":"Orange","B50-K0":"Black","B01-W0":"White","B01-K0":"Black","B01-D0":"Gray","B02-W0":"White","C00-C1":"Transparent","C00-C0":"Clear Black","C00-K0":"Black","C00-W0":"White","C01-K0":"Black","U02-B0":"Blue","U02-D0":"Gray","U02-K0":"Black","N04-K0":"Black","N08-K0":"Black","S02-W0":"Nature","S02-W1":"White","S05-C0":"Black","S06-W0":"White","S03-G1":"Green","S04-Y0":"Clear"},o8e={W0:"White",W1:"Jade White",W2:"Ivory White",W3:"Bone White",Y0:"Yellow",Y1:"Gold",Y2:"Sunflower Yellow",Y3:"Bronze",Y4:"Gold",A0:"Orange",A1:"Pumpkin Orange",A2:"Mandarin Orange",R0:"Red",R1:"Scarlet Red",R2:"Maroon Red",R3:"Hot Pink",R4:"Dark Red",R5:"Red Granite",P0:"Beige",P1:"Pink",P2:"Indigo Purple",P3:"Sakura Pink",P4:"Lilac Purple",P5:"Purple",P6:"Magenta",P7:"Violet Purple",B0:"Blue",B1:"Blue Grey",B2:"Cobalt Blue",B3:"Cobalt Blue",B4:"Ice Blue",B5:"Turquoise",B6:"Navy Blue",B7:"Royal Purple",B8:"Cyan",G0:"Green",G1:"Grass Green",G2:"Mistletoe Green",G3:"Bright Green",G6:"Bambu Green",G7:"Dark Green",N0:"Brown",N1:"Peanut Brown",N2:"Dark Brown",N3:"Caramel",D0:"Gray",D1:"Silver",D2:"Light Gray",D3:"Dark Gray",D4:"White Marble",D5:"Slate Gray",D6:"Lava Gray",K0:"Black",K1:"Charcoal",K2:"Onyx Black",C0:"Clear Black",C1:"Transparent",M0:"Arctic Whisper",M1:"Solar Breeze",M2:"Ocean to Meadow",M3:"Pink Citrus",M4:"Aurora Purple",M5:"Blueberry Bubblegum",M6:"Dusk Glare",M7:"Cotton Candy Cloud",M8:"Dawn Radiance",T1:"Gilded Rose",T2:"Midnight Blaze",T3:"Neon City",T4:"Blue Hawaii",T5:"Velvet Eclipse"};function lj(t){if(!t)return null;if(C7[t])return C7[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return o8e[n]||null}function cj(t){if(!t||t.length<6)return"Unknown";const e=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16),i=Math.max(e,n,r)/255,s=Math.min(e,n,r)/255,o=(i+s)/2;let l=0,c=0;if(i!==s){const u=i-s;c=o>.5?u/(2-i-s):u/(i+s);const d=e/255,h=n/255,p=r/255;i===d?l=((h-p)/u+(h
.85?"White":c<.15?o<.4?"Dark Gray":o>.6?"Light Gray":"Gray":l>=15&&l<45&&o<.45||l>=45&&l<70&&o<.4?"Brown":l<15||l>=345?"Red":l<45?"Orange":l<70?"Yellow":l<150?"Green":l<200?"Cyan":l<260?"Blue":l<290?"Purple":l<345?"Pink":"Unknown"}function uj(t){return(t??.02).toFixed(3)}function j7({side:t}){const{mode:e}=Ih(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return a.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded",style:{backgroundColor:n,color:"#00ae42"},children:t})}function P7({className:t}){return a.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:a.jsx("path",{d:"M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z",fill:"#C3C2C1"})})}function l8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z",fill:"#C3C2C1"}),a.jsx("path",{d:"M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z",fill:"#1F8FEB"})]})}function c8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z",fill:"#1F8FEB"}),a.jsx("path",{d:"M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z",fill:"#C3C2C1"})]})}function u8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"}),a.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function d8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function h8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function dj({className:t,color:e,isHeating:n}){const i={"text-orange-400":"#fb923c","text-blue-400":"#60a5fa","text-green-400":"#4ade80"}[e]||"#888",s=n?{filter:`drop-shadow(0 0 4px ${i}) drop-shadow(0 0 8px ${i})`}:{};return n?a.jsxs("svg",{className:t,style:s,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"})]}):a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"}),a.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function D7({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r,compact:i}){const s=typeof t=="string"?parseInt(t,10):t,o=typeof e=="number"?e:40,l=typeof n=="number"?n:60;let c,u;isNaN(s)?(c="#C3C2C1",u="Unknown"):s<=o?(c="#22a352",u="Good"):s<=l?(c="#d4a017",u="Fair"):(c="#c62828",u="Bad");let d;return isNaN(s)||s<=o?d=P7:s<=l?d=l8e:d=c8e,a.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${s}% - ${u}${r?" (click for history)":""}`,children:[a.jsx(d,{className:i?"w-2.5 h-3":"w-3 h-4"}),a.jsxs("span",{className:`font-medium tabular-nums ${i?"text-[10px]":"text-xs"}`,style:{color:c},children:[s,"%"]})]})}function R7({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r,compact:i}){const s=typeof e=="number"?e:28,o=typeof n=="number"?n:35;let l,c,u;return t<=s?(l="#22a352",c="Good",u=u8e):t<=o?(l="#d4a017",c="Fair",u=d8e):(l="#c62828",c="Bad",u=h8e),a.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Temperature: ${t}°C - ${c}${r?" (click for history)":""}`,children:[a.jsx(u,{className:i?"w-2.5 h-3":"w-3 h-4"}),a.jsxs("span",{className:`tabular-nums text-right ${i?"text-[10px] w-8":"w-12"}`,style:{color:l},children:[t,"°C"]})]})}function Ud(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,s=r>=128?r-128:r,o=String.fromCharCode(65+s);return i?`HT-${o}`:`AMS-${o}`}function O7(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function f8e(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function m8e(t,e="system"){const n=new Date,r=new Date(n.getTime()+t*60*1e3),i=new Date;i.setHours(0,0,0,0);const s=new Date(r);s.setHours(0,0,0,0);const o={hour:"2-digit",minute:"2-digit"};e==="12h"?o.hour12=!0:e==="24h"&&(o.hour12=!1);const l=r.toLocaleTimeString([],o),c=Math.floor((s.getTime()-i.getTime())/(1e3*60*60*24));return c===0?l:c===1?`Tomorrow ${l}`:r.toLocaleDateString([],{weekday:"short"})+" "+l}function p8e(t){if(!t)return"/img/printers/default.png";const e=t.toLowerCase().replace(/\s+/g,"");return e.includes("x1e")?"/img/printers/x1e.png":e.includes("x1c")||e.includes("x1carbon")||e.includes("x1")?"/img/printers/x1c.png":e.includes("h2d")||e.includes("h2c")||e.includes("h2s")?"/img/printers/h2d.png":e.includes("p2s")||e.includes("p1s")?"/img/printers/p1s.png":e.includes("p1p")?"/img/printers/p1p.png":e.includes("a1mini")?"/img/printers/a1mini.png":e.includes("a1")?"/img/printers/a1.png":"/img/printers/default.png"}function g8e(t){return t==null?{labelKey:"",color:"text-bambu-gray",bars:0}:t>=-50?{labelKey:"printers.wifiSignal.excellent",color:"text-bambu-green",bars:4}:t>=-60?{labelKey:"printers.wifiSignal.good",color:"text-bambu-green",bars:3}:t>=-70?{labelKey:"printers.wifiSignal.fair",color:"text-yellow-400",bars:2}:t>=-80?{labelKey:"printers.wifiSignal.weak",color:"text-orange-400",bars:1}:{labelKey:"printers.wifiSignal.veryWeak",color:"text-red-400",bars:1}}function hj(t){return t?!!(t.tray_info_idx&&t.tray_info_idx.startsWith("GF")||t.tray_uuid&&t.tray_uuid!=="00000000000000000000000000000000"||t.tag_uid&&t.tag_uid!=="0000000000000000"):!1}function x8e({url:t,printName:e}){const{t:n}=Cn(),[r,i]=_.useState(!1),[s,o]=_.useState(!1),[l,c]=_.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${t&&r?"cursor-pointer":""}`,onClick:()=>t&&r&&c(!0),children:t&&!s?a.jsxs(a.Fragment,{children:[a.jsx("img",{src:t,alt:n("printers.printPreview"),className:`w-full h-full object-cover ${r?"block":"hidden"}`,onLoad:()=>i(!0),onError:()=>o(!0)}),!r&&a.jsx(Bi,{className:"w-8 h-8 text-bambu-gray"})]}):a.jsx(Bi,{className:"w-8 h-8 text-bambu-gray"})}),l&&t&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>c(!1),children:a.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[a.jsx("img",{src:t,alt:n("printers.printPreview"),className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&a.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function b8e({printers:t}){const{t:e}=Cn(),n=un(),r=_.useMemo(()=>{let s=0,o=0,l=0,c=0;return t?.forEach(u=>{const d=n.getQueryData(["printerStatus",u.id]);d===void 0?c++:d.connected?d.state==="RUNNING"?s++:o++:l++}),{printing:s,idle:o,offline:l,loading:c,total:t?.length||0}},[t,n]),[,i]=_.useState(0);return _.useEffect(()=>{let s=!1;const o=n.getQueryCache().subscribe(()=>{s||(s=!0,requestAnimationFrame(()=>{i(l=>l+1),s=!1}))});return()=>o()},[n]),t?.length?a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[r.printing>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:r.printing})," ",e("printers.status.printing").toLowerCase()]})]}),r.idle>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:r.idle})," ",e("printers.status.idle").toLowerCase()]})]}),r.offline>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:r.offline})," ",e("printers.status.offline").toLowerCase()]})]})]}):null}function L7(t,e){if(e)return e;switch(t){case"RUNNING":return"Printing";case"PAUSE":return"Paused";case"FINISH":return"Finished";case"FAILED":return"Failed";case"IDLE":return"Idle";default:return t?t.charAt(0)+t.slice(1).toLowerCase():"Idle"}}function F7({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:s,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,linkedSpools:c,spoolmanUrl:u,timeFormat:d="system",cameraViewMode:h="window",onOpenEmbeddedCamera:p,checkPrinterFirmware:m=!0}){const{t:x}=Cn(),b=un(),v=Ac(),{showToast:y}=Gn(),{hasPermission:S}=Pi(),[N,T]=_.useState(!1),[k,C]=_.useState(!1),[E,P]=_.useState(!0),[A,j]=_.useState(!1),[z,L]=_.useState(!1),[B,R]=_.useState(!1),[$,K]=_.useState(!1),[I,X]=_.useState(!1),[Y,se]=_.useState(!1),[H,q]=_.useState(!1),[ne,re]=_.useState(!1),[xe,pe]=_.useState(!1),[de,Ce]=_.useState(!1),[ie,Ee]=_.useState(null),[Le,fe]=_.useState(null),[Xe,G]=_.useState(null),[Q,me]=_.useState(!1),[W,te]=_.useState(null),[V,ge]=_.useState(!1),[Se,ee]=_.useState(!1),[U,O]=_.useState(null),[Z,oe]=_.useState(!1),[we,ye]=_.useState(!1),{data:ae}=at({queryKey:["printerStatus",t.id],queryFn:()=>ce.getPrinterStatus(t.id),refetchInterval:3e4}),{data:Oe}=at({queryKey:["firmwareUpdate",t.id],queryFn:()=>b1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3,enabled:m}),He=_.useMemo(()=>{const nt=new Set;if(ae?.ams)for(const Dt of ae.ams)for(const Xt of Dt.tray||[])Xt.tray_info_idx&&nt.add(Xt.tray_info_idx);return ae?.vt_tray?.tray_info_idx&&nt.add(ae.vt_tray.tray_info_idx),Array.from(nt)},[ae?.ams,ae?.vt_tray]),{data:tt}=at({queryKey:["filamentInfo",He],queryFn:()=>ce.getFilamentInfo(He),enabled:He.length>0,staleTime:300*1e3}),{data:Ie}=at({queryKey:["slotPresets",t.id],queryFn:()=>ce.getSlotPresets(t.id),staleTime:120*1e3}),[be,Ae]=_.useState(null);_.useEffect(()=>{ae?.wifi_signal!=null&&Ae(ae.wifi_signal)},[ae?.wifi_signal]);const Ue=ae?.wifi_signal??be,Me=_.useRef(void 0);_.useEffect(()=>{ae?.connected!==void 0&&(Me.current=ae.connected)},[ae?.connected]);const Ge=ae?.connected??Me.current,Ne=_.useRef({});_.useEffect(()=>{ae?.ams_extruder_map&&Object.keys(ae.ams_extruder_map).length>0&&(Ne.current=ae.ams_extruder_map)},[ae?.ams_extruder_map]);const rt=ae?.ams_extruder_map&&Object.keys(ae.ams_extruder_map).length>0?ae.ams_extruder_map:Ne.current,ke=_.useRef([]);_.useEffect(()=>{ae?.ams&&ae.ams.length>0&&(ke.current=ae.ams)},[ae?.ams]);const Ke=ae?.ams&&ae.ams.length>0?ae.ams:ke.current,Be=_.useRef(255),ue=ae?.tray_now;ue!==void 0&&ue!==255&&(Be.current=ue);const $e=ue===void 0||ue===255?Be.current:ue,{data:it}=at({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>ce.getSmartPlugByPrinter(t.id)}),{data:kt}=at({queryKey:["scriptPlugsByPrinter",t.id],queryFn:()=>ce.getScriptPlugsByPrinter(t.id)}),{data:xt}=at({queryKey:["smartPlugStatus",it?.id],queryFn:()=>it?ce.getSmartPlugStatus(it.id):null,enabled:!!it,refetchInterval:1e4}),{data:Ht}=at({queryKey:["queue",t.id,"pending"],queryFn:()=>ce.getQueue(t.id,"pending")}),Ft=Ht?.length||0,{data:Fe}=at({queryKey:["queue",t.id,"printing"],queryFn:()=>ce.getQueue(t.id,"printing"),enabled:ae?.state==="RUNNING"}),{data:bt}=at({queryKey:["currentPrintUser",t.id],queryFn:()=>ce.getCurrentPrintUser(t.id),enabled:ae?.state==="RUNNING"}),Wt=Fe?.[0]?.created_by_username||bt?.username,{data:Qt}=at({queryKey:["archives",t.id,"last"],queryFn:()=>ce.getArchives(t.id,1,0),enabled:ae?.connected&&ae?.state!=="RUNNING"}),Sn=Qt?.[0],fn=e&&Ge===!1,sr=pt({mutationFn:nt=>ce.deletePrinter(t.id,nt.deleteArchives),onSuccess:()=>{b.invalidateQueries({queryKey:["printers"]}),b.invalidateQueries({queryKey:["archives"]}),b.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:nt=>y(nt.message||x("printers.toast.failedToDelete"),"error")}),Wn=pt({mutationFn:()=>ce.connectPrinter(t.id),onSuccess:()=>{b.invalidateQueries({queryKey:["printerStatus",t.id]})}}),Qn=pt({mutationFn:nt=>it?ce.controlSmartPlug(it.id,nt):Promise.reject("No plug"),onSuccess:()=>{b.invalidateQueries({queryKey:["smartPlugStatus",it?.id]})}}),En=pt({mutationFn:nt=>it?ce.updateSmartPlug(it.id,{auto_off:nt}):Promise.reject("No plug"),onSuccess:()=>{b.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),b.invalidateQueries({queryKey:["smart-plugs"]})}}),hi=pt({mutationFn:nt=>ce.controlSmartPlug(nt,"on"),onSuccess:()=>{y(x("printers.toast.scriptTriggered"))},onError:nt=>y(nt.message||x("printers.toast.failedToRunScript"),"error")}),ai=pt({mutationFn:()=>ce.stopPrint(t.id),onSuccess:()=>{y(x("printers.toast.printStopped")),b.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:nt=>y(nt.message||x("printers.toast.failedToStopPrint"),"error")}),je=pt({mutationFn:()=>ce.pausePrint(t.id),onSuccess:()=>{y(x("printers.toast.printPaused")),b.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:nt=>y(nt.message||x("printers.toast.failedToPausePrint"),"error")}),Je=pt({mutationFn:()=>ce.resumePrint(t.id),onSuccess:()=>{y(x("printers.toast.printResumed")),b.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:nt=>y(nt.message||x("printers.toast.failedToResumePrint"),"error")}),ut=pt({mutationFn:nt=>ce.setChamberLight(t.id,nt),onMutate:async nt=>{await b.cancelQueries({queryKey:["printerStatus",t.id]});const Dt=b.getQueryData(["printerStatus",t.id]);return b.setQueryData(["printerStatus",t.id],Xt=>({...Xt,chamber_light:nt})),{previousStatus:Dt}},onSuccess:(nt,Dt)=>{y(`Chamber light ${Dt?"on":"off"}`)},onError:(nt,Dt,Xt)=>{Xt?.previousStatus&&b.setQueryData(["printerStatus",t.id],Xt.previousStatus),y(nt.message||x("printers.toast.failedToControlChamberLight"),"error")}}),dt=pt({mutationFn:nt=>ce.updatePrinter(t.id,{plate_detection_enabled:nt}),onSuccess:()=>{b.invalidateQueries({queryKey:["printers"]}),y(dt.variables?x("printers.toast.plateCheckEnabled"):x("printers.toast.plateCheckDisabled"))},onError:nt=>y(nt.message||x("printers.toast.failedToUpdateSetting"),"error")}),ct=(ae?.state==="RUNNING"||ae?.state==="PAUSE"||ae?.state==="PAUSED")&&(ae?.printable_objects_count??0)>=2,{data:At,refetch:he}=at({queryKey:["printableObjects",t.id],queryFn:()=>ce.getPrintableObjects(t.id),enabled:de||ct,refetchInterval:de?5e3:ct?3e4:!1}),De=pt({mutationFn:nt=>ce.skipObjects(t.id,nt),onSuccess:nt=>{y(nt.message||x("printers.skipObjects.objectsSkipped")),he()},onError:nt=>y(nt.message||x("printers.toast.failedToSkipObjects"),"error")}),[Ve,_e]=_.useState(null),Re=_.useRef(!1),et=_.useRef(null),Ye=_.useRef(!1),Ct=pt({mutationFn:({amsId:nt,slotId:Dt})=>ce.refreshAmsSlot(t.id,nt,Dt),onMutate:({amsId:nt,slotId:Dt})=>{et.current&&clearTimeout(et.current),Re.current=!1,Ye.current=!1,_e({amsId:nt,slotId:Dt}),setTimeout(()=>{Ye.current=!0},2e3),et.current=setTimeout(()=>{_e(null)},3e4)},onSuccess:nt=>{y(nt.message||x("printers.toast.rfidRereadInitiated"))},onError:nt=>{y(nt.message||x("printers.toast.failedToRereadRfid"),"error"),et.current&&clearTimeout(et.current),_e(null)}}),[jt,Ut]=_.useState(null),[Rt,Et]=_.useState(null),rn=async()=>{try{const nt=await ce.getPlateReferences(t.id);Ut(nt)}catch{}},Vt=()=>{dt.mutate(!t.plate_detection_enabled)},gn=async()=>{ge(!0),te(null);const nt=ae?.chamber_light===!1;ye(nt),nt&&(await ce.setChamberLight(t.id,!0),await new Promise(Dt=>setTimeout(Dt,2500)));try{const Dt=await ce.checkPlateEmpty(t.id,{includeDebugImage:!0});te(Dt),rn()}catch(Dt){y(Dt instanceof Error?Dt.message:x("printers.toast.failedToCheckPlate"),"error"),nt&&(await ce.setChamberLight(t.id,!1),ye(!1))}finally{ge(!1)}},mn=_.useCallback(async()=>{te(null),we&&(await ce.setChamberLight(t.id,!1),ye(!1))},[we,t.id]),Tn=async nt=>{ee(!0);try{const Dt=await ce.calibratePlateDetection(t.id,{label:nt});if(Dt.success){y(Dt.message||x("printers.toast.calibrationSaved"),"success"),rn();const Xt=await ce.checkPlateEmpty(t.id,{includeDebugImage:!0});te(Xt)}else y(Dt.message||x("printers.toast.calibrationFailed"),"error")}catch(Dt){y(Dt instanceof Error?Dt.message:x("printers.toast.calibrationFailed"),"error")}finally{ee(!1)}},Kt=async(nt,Dt)=>{try{await ce.updatePlateReferenceLabel(t.id,nt,Dt),Et(null),rn()}catch(Xt){y(Xt instanceof Error?Xt.message:x("printers.toast.failedToUpdateLabel"),"error")}},dn=async nt=>{try{await ce.deletePlateReference(t.id,nt),y(x("printers.toast.referenceDeleted"),"success"),rn();const Dt=await ce.checkPlateEmpty(t.id,{includeDebugImage:!0});te(Dt)}catch(Dt){y(Dt instanceof Error?Dt.message:x("printers.toast.failedToDeleteReference"),"error")}},pn=async()=>{if(U){oe(!0);try{await ce.updatePrinter(t.id,{plate_detection_roi:U}),y(x("printers.toast.detectionAreaSaved"),"success"),O(null);const nt=await ce.checkPlateEmpty(t.id,{includeDebugImage:!0});te(nt)}catch(nt){y(nt instanceof Error?nt.message:x("printers.toast.failedToSaveDetectionArea"),"error")}finally{oe(!1)}}};_.useEffect(()=>{const nt=Dt=>{Dt.key==="Escape"&&W&&mn()};return window.addEventListener("keydown",nt),()=>window.removeEventListener("keydown",nt)},[W,mn]);const en=_.useRef(null);_.useEffect(()=>{if(!Ve)return;const nt=ae?.ams_status_main??0;return nt!==0&&(Re.current=!0,en.current&&(clearTimeout(en.current),en.current=null)),Re.current&&nt===0&&(Ye.current?(et.current&&clearTimeout(et.current),_e(null)):en.current||(en.current=setTimeout(()=>{et.current&&clearTimeout(et.current),_e(null)},2e3))),()=>{en.current&&clearTimeout(en.current)}},[ae?.ams_status_main,Ve]);const[ir,Ln]=_.useState(null);if(fn)return null;const si=()=>{switch(i){case 1:return"w-10 h-10";case 2:return"w-14 h-14";case 3:return"w-16 h-16";case 4:return"w-20 h-20";default:return"w-14 h-14"}},ar=()=>{switch(i){case 1:return"text-base truncate";case 2:return"text-lg";case 3:return"text-xl";case 4:return"text-2xl";default:return"text-lg"}},dr=()=>{switch(i){case 1:return"mb-2";case 2:return"mb-4";case 3:return"mb-5";case 4:return"mb-6";default:return"mb-4"}};return a.jsxs(Nt,{className:"relative",children:[a.jsxs(Mt,{className:i>=3?"p-5":"",children:[a.jsxs("div",{className:dr(),children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("img",{src:p8e(t.model),alt:t.model||x("common.printer"),className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${si()}`}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:`font-semibold text-white ${ar()}`,children:t.name}),r==="compact"&&a.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${ae?.connected?"bg-status-ok":"bg-status-error"}`,title:ae?.connected?x("printers.connection.connected"):x("printers.connection.offline")})]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&ae?.nozzles&&ae.nozzles[0]?.nozzle_diameter&&a.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:ae.nozzles[0].nozzle_type||"Nozzle",children:["• ",ae.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&a.jsxs("span",{className:"ml-2 text-bambu-gray",children:[a.jsx(nr,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),a.jsxs("div",{className:"relative flex-shrink-0",children:[a.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>T(!N),children:a.jsx(lh,{className:"w-4 h-4"})}),N&&a.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-20",children:[a.jsxs("button",{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${S("printers:update")?"hover:bg-bambu-dark-tertiary":"opacity-50 cursor-not-allowed"}`,onClick:()=>{S("printers:update")&&(j(!0),T(!1))},title:S("printers:update")?void 0:x("printers.permission.noEdit"),children:[a.jsx(ta,{className:"w-4 h-4"}),x("common.edit")]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{Wn.mutate(),T(!1)},children:[a.jsx(Rr,{className:"w-4 h-4"}),x("printers.reconnect")]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{R(!0),T(!1)},children:[a.jsx(FW,{className:"w-4 h-4"}),x("printers.mqttDebug")]}),a.jsxs("button",{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${S("printers:delete")?"text-red-400 hover:bg-bambu-dark-tertiary":"text-red-400/50 cursor-not-allowed"}`,onClick:()=>{S("printers:delete")&&(C(!0),T(!1))},title:S("printers:delete")?void 0:x("printers.permission.noDelete"),children:[a.jsx(cn,{className:"w-4 h-4"}),x("common.delete")]})]})]})]}),r==="expanded"&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[a.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${ae?.connected?"bg-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[ae?.connected?a.jsx(Uy,{className:"w-3 h-3"}):a.jsx(zR,{className:"w-3 h-3"}),ae?.connected?x("printers.connection.connected"):x("printers.connection.offline")]}),ae?.connected&&Ue!=null&&a.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${Ue>=-50||Ue>=-60?"bg-status-ok/20 text-status-ok":Ue>=-70?"bg-status-warning/20 text-status-warning":Ue>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${Ue} dBm - ${x(g8e(Ue).labelKey)}`,children:[a.jsx(Ihe,{className:"w-3 h-3"}),Ue,"dBm"]}),ae?.connected&&(()=>{const nt=ae.hms_errors?t2e(ae.hms_errors):[];return a.jsxs("button",{onClick:()=>se(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${nt.length>0?nt.some(Dt=>Dt.severity<=2)?"bg-status-error/20 text-status-error":"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:x("printers.clickToViewHmsErrors"),children:[a.jsx(kn,{className:"w-3 h-3"}),nt.length>0?nt.length:"OK"]})})(),n&&a.jsxs("button",{onClick:()=>v("/maintenance"),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?"bg-status-error/20 text-status-error":n.warning_count>0?"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:""}${n.due_count>0&&n.warning_count>0?", ":""}${n.warning_count>0?`${n.warning_count} due soon`:""} - Click to view`:x("printers.maintenanceUpToDate"),children:[a.jsx(cm,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Ft>0&&a.jsxs("button",{onClick:()=>v("/queue"),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-purple-500/20 text-purple-400 hover:opacity-80 transition-opacity",title:x("printers.queue.inQueue",{count:Ft}),children:[a.jsx(xs,{className:"w-3 h-3"}),Ft]}),Oe?.update_available&&a.jsxs("button",{onClick:()=>me(!0),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-orange-500/20 text-orange-400 hover:opacity-80 transition-opacity",title:x("printers.firmwareUpdateAvailable",{current:Oe.current_version,latest:Oe.latest_version}),children:[a.jsx(_i,{className:"w-3 h-3"}),x("printers.firmwareUpdateButton")]})]})]}),k&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsx(Nt,{className:"w-full max-w-md mx-4",children:a.jsxs(Mt,{children:[a.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[a.jsx("div",{className:"p-2 rounded-full bg-red-500/20",children:a.jsx(kn,{className:"w-5 h-5 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:x("printers.confirm.deleteTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:x("printers.confirm.deleteMessage",{name:t.name})})]})]}),a.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E,onChange:nt=>P(nt.target.checked),className:"mt-0.5 w-4 h-4 rounded border-bambu-gray bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:x("printers.deleteArchives")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:x(E?"printers.confirm.deleteArchivesNote":"printers.confirm.keepArchivesNote")})]})]})}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Te,{variant:"secondary",onClick:()=>{C(!1),P(!0)},children:x("common.cancel")}),a.jsx(Te,{variant:"danger",onClick:()=>{sr.mutate({deleteArchives:E}),C(!1),P(!0)},children:"Delete"})]})]})})}),ae?.connected&&a.jsxs(a.Fragment,{children:[r==="compact"?a.jsx("div",{className:"mt-2",children:ae.state==="RUNNING"?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:a.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${ae.progress||0}%`}})}),a.jsxs("span",{className:"text-xs text-white",children:[Math.round(ae.progress||0),"%"]})]}):a.jsx("p",{className:"text-xs text-bambu-gray",children:L7(ae.state,ae.stg_cur_name)})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg relative",children:[a.jsxs("button",{onClick:()=>Ce(!0),disabled:!(ae.state==="RUNNING"||ae.state==="PAUSE"||ae.state==="PAUSED")||(ae.printable_objects_count??0)<2||!S("printers:control"),className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(ae.state==="RUNNING"||ae.state==="PAUSE"||ae.state==="PAUSED")&&(ae.printable_objects_count??0)>=2&&S("printers:control")?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:S("printers:control")?ae.state==="RUNNING"||ae.state==="PAUSE"||ae.state==="PAUSED"?(ae.printable_objects_count??0)>=2?x("printers.skipObjects.tooltip"):x("printers.skipObjects.requiresMultiple"):x("printers.skipObjects.onlyWhilePrinting"):x("printers.permission.noControl"),children:[a.jsx(A7,{className:"w-4 h-4"}),At&&At.skipped_count>0&&a.jsx("span",{className:"absolute -top-1 -right-1 min-w-[16px] h-4 px-1 flex items-center justify-center text-[10px] font-bold bg-red-500 text-white rounded-full",children:At.skipped_count})]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(x8e,{url:ae.state==="RUNNING"?ae.cover_url:null,printName:ae.state==="RUNNING"&&(ae.subtask_name||ae.current_print)||void 0}),a.jsx("div",{className:"flex-1 min-w-0",children:ae.current_print&&ae.state==="RUNNING"?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:ae.stg_cur_name||"Printing"}),a.jsx("p",{className:"text-white text-sm mb-2 truncate",children:ae.subtask_name||ae.current_print}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${ae.progress||0}%`}})}),a.jsxs("span",{className:"text-white",children:[Math.round(ae.progress||0),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[ae.remaining_time!=null&&ae.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(nr,{className:"w-3 h-3"}),f8e(ae.remaining_time*60)]}),a.jsxs("span",{className:"text-bambu-green font-medium",title:x("printers.estimatedCompletion"),children:["ETA ",m8e(ae.remaining_time,d)]})]}),ae.layer_num!=null&&ae.total_layers!=null&&ae.total_layers>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(xs,{className:"w-3 h-3"}),ae.layer_num,"/",ae.total_layers]}),Wt&&a.jsxs("span",{className:"flex items-center gap-1",title:`Started by ${Wt}`,children:[a.jsx(Uu,{className:"w-3 h-3"}),Wt]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:x("printers.sort.status")}),a.jsx("p",{className:"text-white text-sm mb-2",children:L7(ae.state,ae.stg_cur_name)}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:a.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),a.jsx("span",{className:"text-bambu-gray",children:"—"})]}),Sn?a.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:Sn.print_name||Sn.filename,children:["Last: ",Sn.print_name||Sn.filename,Sn.completed_at&&a.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",$g(Sn.completed_at,{month:"short",day:"numeric"})]})]}):a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:x("printers.readyToPrint")})]})})]})]}),ae.state!=="RUNNING"&&a.jsx(a2e,{printerId:t.id})]}),ae.temperatures&&r==="expanded"&&(()=>{const nt=ae.temperatures.nozzle_heating||ae.temperatures.nozzle_2_heating||!1,Dt=ae.temperatures.bed_heating||!1,Xt=ae.temperatures.chamber_heating||!1,wt=t.nozzle_count===2||ae.temperatures.nozzle_2!==void 0,Nn=ae.active_extruder===1?"L":"R";return a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[a.jsx(dj,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:nt}),ae.temperatures.nozzle_2!==void 0?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:"L / R"}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.nozzle||0),"° / ",Math.round(ae.temperatures.nozzle_2||0),"°"]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.nozzle")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.nozzle||0),"°C"]})]})]}),a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[a.jsx(dj,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-blue-400",isHeating:Dt}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.bed")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.bed||0),"°C"]})]}),ae.temperatures.chamber!==void 0&&a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[a.jsx(dj,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-green-400",isHeating:Xt}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.chamber")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.chamber||0),"°C"]})]}),wt&&a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg",title:x("printers.activeNozzle",{nozzle:x(Nn==="L"?"common.left":"common.right")}),children:[a.jsx("p",{className:`text-[11px] font-bold ${Nn==="L"?"text-amber-400":"text-gray-500"}`,children:"L"}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.nozzle")}),a.jsx("p",{className:`text-[11px] font-bold ${Nn==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const nt=ae.state==="RUNNING",Dt=ae.state==="PAUSED"||ae.state==="PAUSE",Xt=nt||Dt,wt=ai.isPending||je.isPending||Je.isPending,Nn=ae.cooling_fan_speed,Ir=ae.big_fan1_speed,Qr=ae.big_fan2_speed;return a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:x("printers.controls")}),a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Nn&&Nn>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:x("printers.fans.partCooling"),children:[a.jsx(EW,{className:`w-3.5 h-3.5 ${Nn&&Nn>0?"text-cyan-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${Nn&&Nn>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[Nn??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Ir&&Ir>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:x("printers.fans.auxiliary"),children:[a.jsx(UW,{className:`w-3.5 h-3.5 ${Ir&&Ir>0?"text-blue-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${Ir&&Ir>0?"text-blue-400":"text-bambu-gray/50"}`,children:[Ir??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Qr&&Qr>0?"bg-green-500/10":"bg-bambu-dark"}`,title:x("printers.fans.chamber"),children:[a.jsx(pce,{className:`w-3.5 h-3.5 ${Qr&&Qr>0?"text-green-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${Qr&&Qr>0?"text-green-400":"text-bambu-gray/50"}`,children:[Qr??0,"%"]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:()=>q(!0),disabled:!Xt||wt||!S("printers:control"),className:` flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium transition-colors ${Xt&&S("printers:control")?"bg-red-500/20 text-red-400 hover:bg-red-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"} diff --git a/static/index.html b/static/index.html index 2d9d5f160..17b66ca5b 100644 --- a/static/index.html +++ b/static/index.html @@ -23,7 +23,7 @@ - +