diff --git a/static/assets/index-IPXqtJjD.js b/static/assets/index-oRK7m1Je.js similarity index 99% rename from static/assets/index-IPXqtJjD.js rename to static/assets/index-oRK7m1Je.js index d44a39bdc..37df505af 100644 --- a/static/assets/index-IPXqtJjD.js +++ b/static/assets/index-oRK7m1Je.js @@ -8540,8 +8540,8 @@ void main() { transition-colors ${r&&A(`printers:control`)?n?`bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30`:`bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/30`:`bg-bambu-dark text-bambu-gray/50 cursor-not-allowed`} `,title:A(`printers:control`)?E(n?`printers.resume`:`printers.pause`):E(`printers.permission.noControl`),children:[n?(0,G.jsx)(pl,{className:`w-3 h-3`}):(0,G.jsx)(cl,{className:`w-3 h-3`}),E(n?`printers.resume`:`printers.pause`)]})]})]})]})})(),(Vt?.length>0||W.vt_tray.length>0)&&r===`expanded`&&(()=>{let t=Vt.filter(e=>e.tray.length>1),n=Vt.filter(e=>e.tray.length===1),r=e.nozzle_count===2||W?.temperatures?.nozzle_2!==void 0;return(0,G.jsxs)(`div`,{className:`mt-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:E(`printers.filaments`)}),(0,G.jsx)(`div`,{className:`flex-1 h-px bg-bambu-dark-tertiary/30`})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[t.length>0&&(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:t.map(t=>{let n=zt[String(t.id)],i=t.id>=128?t.id-128:t.id,g=n===void 0?i:n,_=g===1,v=g===0;return(0,G.jsxs)(`div`,{className:`p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(uJ,{ams:t,printerId:e.id,label:nJ(t.id,t.tray.length),amsLabels:jt,canEdit:A(`printers:update`),onSaved:Mt,children:(0,G.jsx)(`span`,{className:`text-[10px] text-white font-medium cursor-default select-none`,children:jt?.[t.id]||nJ(t.id,t.tray.length)})}),r&&(_||v)&&(0,G.jsx)(Yq,{side:_?`L`:`R`})]}),(t.humidity!=null||t.temp!=null)&&(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 max-[550px]:flex-col max-[550px]:items-start`,children:[t.humidity!=null&&(0,G.jsx)(eJ,{humidity:t.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>tt({amsId:t.id,amsLabel:nJ(t.id,t.tray.length),mode:`humidity`}),compact:!0}),t.temp!=null&&(0,G.jsx)(tJ,{temp:t.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>tt({amsId:t.id,amsLabel:nJ(t.id,t.tray.length),mode:`temperature`}),compact:!0}),W.supports_drying&&(t.module_type===`n3f`||t.module_type===`n3s`)&&A(`printers:control`)&&(0,G.jsx)(`button`,{disabled:!!(t.dry_sf_reason?.length&&t.dry_time===0),onClick:e=>{if(t.dry_time>0)pn.mutate(t.id);else if(Pe===t.id)Fe(null);else{let n=(t.tray.find(e=>e.tray_type)?.tray_type||`PLA`).split(` `)[0].toUpperCase(),r=x[n]||x.PLA,i=t.module_type;ze(n),Ve(r[i]||r.n3f),Ue(i===`n3s`?r.n3s_hours:r.n3f_hours),Ge(!1),Le(t.module_type),Fe(t.id),qe(Pf({triggerRect:e.currentTarget.getBoundingClientRect(),popoverWidth:Kq,estimatedHeight:qq}))}},className:`flex items-center gap-0.5 px-1 py-0.5 rounded text-[9px] transition-colors ${t.dry_time>0?`bg-amber-500/20 text-amber-400`:t.dry_sf_reason?.length?`bg-bambu-dark-tertiary/30 text-bambu-gray/50 cursor-not-allowed`:`bg-bambu-dark-tertiary/50 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary`}`,title:t.dry_time>0?E(`printers.drying.stop`):t.dry_sf_reason?.length?E(`printers.drying.powerRequired`):E(`printers.drying.start`),children:(0,G.jsx)(ec,{className:`w-3 h-3`})})]})]}),t.dry_time>0&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1 mb-1 bg-amber-500/10 border border-amber-500/20 rounded text-[9px]`,children:[(0,G.jsx)(ec,{className:`w-3 h-3 text-amber-400 shrink-0`}),(0,G.jsx)(`span`,{className:`text-amber-400 font-medium`,children:E(`printers.drying.active`)}),(0,G.jsx)(`span`,{className:`text-amber-300/70`,children:E(`printers.drying.timeRemaining`,{time:t.dry_time>=60?`${Math.floor(t.dry_time/60)}h ${t.dry_time%60}m`:`${t.dry_time}m`})}),(0,G.jsx)(`button`,{onClick:()=>pn.mutate(t.id),disabled:pn.isPending,className:`ml-auto text-amber-400 hover:text-amber-300 transition-colors disabled:opacity-50`,title:E(`printers.drying.stop`),children:(0,G.jsx)(Au,{className:`w-3 h-3`})})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:[0,1,2,3].map(r=>{let i=t.tray[r]||t.tray.find(e=>e.id===r),a=i?.tray_type&&i.remain>=0,g=!i?.tray_type,_=rJ(i),v=t.id*4+r,y=Wt===v,b=i?.tray_info_idx?Et?.[i.tray_info_idx]:null,x=Dt?.[v],S=(i?.tray_uuid||i?.tag_uid||Oq(e.serial_number,t.id,r))?.toUpperCase(),C=S?s?.[S]:void 0,w=Eq(C),T=o&&!m?p?.find(n=>n.printer_id===e.id&&n.ams_id===t.id&&n.tray_id===r):void 0,D=T?f?.find(e=>e.id===T.spoolman_spool_id):void 0,O=D&&(D.label_weight??0)>0?Math.round(Math.max(0,(D.label_weight??0)-D.weight_used)/(D.label_weight??1)*100):null,k=u?.(e.id,t.id,r),j=(()=>{let e=k?.spool;return e&&e.label_weight>0&&e.weight_used!=null?Math.round(Math.max(0,e.label_weight-e.weight_used)/e.label_weight*100):null})(),M=j===0&&a&&i.remain>0?null:j,N=w??O??M??(a?i.remain:null),P=w!==null||O!==null?`spoolman`:M===null?a?`ams`:void 0:`inventory`,F=i?.tray_type?{vendor:jq(i)?`Bambu Lab`:`Generic`,profile:x?.preset_name||(D?[D.brand,D.slicer_filament_name?.split(`@`)[0].trim()||D.material].filter(Boolean).join(` `).trim():null)||k?.spool?.slicer_filament_name||b?.name||i.tray_sub_brands||i.tray_type,colorName:Id(i.tray_color||``),colorHex:i.tray_color||null,kFactor:Jq(i.k),fillLevel:N,trayUuid:i.tray_uuid||null,tagUid:i.tag_uid||null,fillSource:P}:null,I=kn?.amsId===t.id&&kn?.slotId===r,L=(0,G.jsxs)(`div`,{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${g?`opacity-50`:``} ${y?`ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark`:``}`,children:[(0,G.jsx)(Gq,{trayColor:i?.tray_color,trayType:i?.tray_type,isEmpty:g,emptyKind:_,slotNumber:r+1}),(0,G.jsx)(`div`,{className:`text-[9px] text-white font-bold truncate`,children:i?.tray_type||E(_===`reset`?`ams.slotUnconfigured`:`ams.slotEmpty`)}),(0,G.jsx)(`div`,{className:`mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden`,children:N!==null&&N>=0&&!g&&i&&(0,G.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${N}%`,backgroundColor:Tq(N)}})})]});return(0,G.jsxs)(`div`,{className:`relative group`,children:[I&&(0,G.jsx)(`div`,{className:`absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20`,children:(0,G.jsx)(xl,{className:`w-4 h-4 text-bambu-green animate-spin`})}),W?.state!==`RUNNING`&&(0,G.jsx)(`button`,{onClick:e=>{e.stopPropagation(),Qn(Zn?.amsId===t.id&&Zn?.slotId===r?null:{amsId:t.id,slotId:r})},className:`absolute -top-1 -right-1 w-4 h-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:bg-bambu-dark-tertiary`,title:E(`printers.slotOptions`),children:(0,G.jsx)(zs,{className:`w-2.5 h-2.5 text-bambu-gray`})}),W?.state!==`RUNNING`&&Zn?.amsId===t.id&&Zn?.slotId===r&&(0,G.jsxs)(`div`,{className:`absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]`,children:[(0,G.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${A(`printers:ams_rfid`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:e=>{e.stopPropagation(),A(`printers:ams_rfid`)&&(Pn.mutate({amsId:t.id,slotId:r}),Qn(null))},disabled:I||!A(`printers:ams_rfid`),title:A(`printers:ams_rfid`)?void 0:E(`printers.permission.noAmsRfid`),children:[(0,G.jsx)(xl,{className:`w-3 h-3 ${I?`animate-spin`:``}`}),E(`printers.rfid.reread`)]}),(0,G.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${A(`printers:control`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:e=>{e.stopPropagation(),A(`printers:control`)&&(Fn.mutate({trayId:t.id*4+r}),Qn(null))},disabled:!A(`printers:control`),title:A(`printers:control`)?void 0:E(`printers.permission.noControl`),children:[(0,G.jsx)(Uc,{className:`w-3 h-3`}),E(`printers.ams.load`)]}),(0,G.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${A(`printers:control`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:e=>{e.stopPropagation(),A(`printers:control`)&&(In.mutate(),Qn(null))},disabled:!A(`printers:control`),title:A(`printers:control`)?void 0:E(`printers.permission.noControl`),children:[(0,G.jsx)(Wc,{className:`w-3 h-3`}),E(`printers.ams.unload`)]})]}),F?(0,G.jsx)(FK,{data:F,spoolman:{enabled:o,linkedSpoolId:T?.spoolman_spool_id??(S?s?.[S]?.id:void 0),spoolmanUrl:c,syncMode:l,onLinkSpool:o&&!T&&!k?()=>{let n=(F.trayUuid||F.tagUid||Oq(e.serial_number,t.id,r)).toUpperCase();rt({tagUid:F.tagUid||n,trayUuid:F.trayUuid||``,printerId:e.id,amsId:t.id,trayId:r})}:void 0,onUnlinkSpool:C?.id?()=>dn.mutate(C.id):void 0},inventory:(()=>{if(o){if(m)return;let n=T,a=D;return{assignedSpool:a?{id:a.id,material:a.material,brand:a.brand??null,color_name:a.color_name??null,remainingWeightGrams:a.label_weight?Math.max(0,Math.round(a.label_weight-a.weight_used)):void 0}:null,onAssignSpool:()=>at({printerId:e.id,amsId:t.id,trayId:r,trayInfo:{type:i?.tray_type||F.profile,material:i?.tray_type??void 0,profile:F.profile,color:F.colorHex||``,location:`${nJ(t.id,t.tray.length)} Slot ${r+1}`}}),onUnassignSpool:a&&!jq(i)?()=>h?.(a.id):void 0,isAssigned:!!n||jq(i)}}let n=u?.(e.id,t.id,r);return{assignedSpool:n?.spool?{id:n.spool.id,material:n.spool.material,brand:n.spool.brand,color_name:n.spool.color_name,remainingWeightGrams:Math.max(0,Math.round(n.spool.label_weight-n.spool.weight_used))}:null,onAssignSpool:()=>at({printerId:e.id,amsId:t.id,trayId:r,trayInfo:{type:i?.tray_type||F.profile,material:i?.tray_type??void 0,profile:F.profile,color:F.colorHex||``,location:`${nJ(t.id,t.tray.length)} Slot ${r+1}`}}),onUnassignSpool:n&&!jq(i)?()=>d?.(e.id,t.id,r):void 0,isAssigned:!!n||jq(i)}})(),configureSlot:{enabled:A(`printers:control`),onConfigure:()=>st({amsId:t.id,trayId:r,trayCount:t.tray.length,trayType:i?.tray_type||void 0,trayColor:i?.tray_color||void 0,traySubBrands:i?.tray_sub_brands||void 0,trayInfoIdx:i?.tray_info_idx||void 0,extruderId:n,caliIdx:i?.cali_idx,savedPresetId:x?.preset_id})},children:L}):(0,G.jsx)(IK,{kind:_??void 0,configureSlot:{enabled:A(`printers:control`),onConfigure:()=>st({amsId:t.id,trayId:r,trayCount:t.tray.length,extruderId:n})},onAssignSpool:()=>at({printerId:e.id,amsId:t.id,trayId:r,trayInfo:{type:``,material:void 0,profile:``,color:``,location:`${nJ(t.id,t.tray.length)} Slot ${r+1}`}}),children:L})]},r)})})]},t.id)})}),(n.length>0||W.vt_tray.length>0)&&(0,G.jsxs)(`div`,{className:`grid grid-cols-4 gap-3`,children:[n.map(t=>{let n=zt[String(t.id)],i=t.id>=128?t.id-128:t.id,g=n===void 0?i:n,_=g===1,v=g===0,y=t.tray[0],b=y?.tray_type&&y.remain>=0,S=!y?.tray_type,C=rJ(y),w=wq(t.id,y?.id??0,!1),T=Wt===w,D=y?.tray_info_idx?Et?.[y.tray_info_idx]:null,O=Dt?.[w],k=y?.id??0,j=(y?.tray_uuid||y?.tag_uid||Oq(e.serial_number,t.id,k))?.toUpperCase(),M=j?s?.[j]:void 0,N=Eq(M),P=u?.(e.id,t.id,k),F=(()=>{let e=P?.spool;return e&&e.label_weight>0&&e.weight_used!=null?Math.round(Math.max(0,e.label_weight-e.weight_used)/e.label_weight*100):null})(),I=F===0&&b&&y.remain>0?null:F,L=o&&!m?p?.find(n=>n.printer_id===e.id&&n.ams_id===t.id&&n.tray_id===k):void 0,R=L?f?.find(e=>e.id===L.spoolman_spool_id):void 0,z=R&&(R.label_weight??0)>0?Math.round(Math.max(0,(R.label_weight??0)-R.weight_used)/(R.label_weight??1)*100):null,B=N??z??I??(b?y.remain:null),ee=N!==null||z!==null?`spoolman`:I===null?b?`ams`:void 0:`inventory`,V=y?.tray_type?{vendor:jq(y)?`Bambu Lab`:`Generic`,profile:O?.preset_name||(R?[R.brand,R.slicer_filament_name?.split(`@`)[0].trim()||R.material].filter(Boolean).join(` `).trim():null)||P?.spool?.slicer_filament_name||D?.name||y.tray_sub_brands||y.tray_type,colorName:Id(y.tray_color||``),colorHex:y.tray_color||null,kFactor:Jq(y.k),fillLevel:B,trayUuid:y.tray_uuid||null,tagUid:y.tag_uid||null,fillSource:ee}:null,te=kn?.amsId===t.id&&kn?.slotId===k,ne=(0,G.jsxs)(`div`,{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${S?`opacity-50`:``} ${T?`ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark`:``}`,children:[(0,G.jsx)(Gq,{trayColor:y?.tray_color,trayType:y?.tray_type,isEmpty:S,emptyKind:C,slotNumber:1}),(0,G.jsx)(`div`,{className:`text-[9px] text-white font-bold truncate`,children:y?.tray_type||E(C===`reset`?`ams.slotUnconfigured`:`ams.slotEmpty`)}),(0,G.jsx)(`div`,{className:`mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden`,children:B!==null&&B>=0&&!S&&(0,G.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${B}%`,backgroundColor:Tq(B)}})})]});return(0,G.jsxs)(`div`,{className:`p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1 mb-2`,children:[(0,G.jsx)(uJ,{ams:t,printerId:e.id,label:nJ(t.id,t.tray.length),amsLabels:jt,canEdit:A(`printers:update`),onSaved:Mt,children:(0,G.jsx)(`span`,{className:`text-[10px] text-white font-medium cursor-default select-none`,children:jt?.[t.id]||nJ(t.id,t.tray.length)})}),r&&(_||v)&&(0,G.jsx)(Yq,{side:_?`L`:`R`}),W.supports_drying&&(t.module_type===`n3f`||t.module_type===`n3s`)&&A(`printers:control`)&&(0,G.jsx)(`div`,{className:`relative ml-auto`,children:(0,G.jsx)(`button`,{onClick:e=>{if(t.dry_time>0)pn.mutate(t.id);else if(Pe===t.id)Fe(null);else{let n=(t.tray.find(e=>e.tray_type)?.tray_type||`PLA`).split(` `)[0].toUpperCase(),r=x[n]||x.PLA,i=t.module_type;ze(n),Ve(r[i]||r.n3f),Ue(i===`n3s`?r.n3s_hours:r.n3f_hours),Ge(!1),Le(t.module_type),Fe(t.id),qe(Pf({triggerRect:e.currentTarget.getBoundingClientRect(),popoverWidth:Kq,estimatedHeight:qq}))}},className:`flex items-center gap-0.5 px-1 py-0.5 rounded text-[9px] transition-colors ${t.dry_time>0?`bg-amber-500/20 text-amber-400`:`bg-bambu-dark-tertiary/50 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary`}`,title:t.dry_time>0?E(`printers.drying.stop`):E(`printers.drying.start`),children:(0,G.jsx)(ec,{className:`w-3 h-3`})})})]}),t.dry_time>0&&(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 mb-1 bg-amber-500/10 border border-amber-500/20 rounded text-[9px] whitespace-nowrap overflow-hidden`,children:[(0,G.jsx)(ec,{className:`w-3 h-3 text-amber-400 shrink-0`}),(0,G.jsx)(`span`,{className:`text-amber-300/70 text-[8px] truncate`,children:t.dry_time>=60?`${Math.floor(t.dry_time/60)}h ${t.dry_time%60}m`:`${t.dry_time}m`}),(0,G.jsx)(`button`,{onClick:()=>pn.mutate(t.id),disabled:pn.isPending,className:`ml-auto text-amber-400 hover:text-amber-300 transition-colors disabled:opacity-50 shrink-0`,title:E(`printers.drying.stop`),children:(0,G.jsx)(Au,{className:`w-3 h-3`})})]}),(0,G.jsxs)(`div`,{className:`flex gap-1.5 max-[550px]:flex-col max-[550px]:items-start`,children:[(0,G.jsxs)(`div`,{className:`relative group flex-1 max-[550px]:w-full`,children:[te&&(0,G.jsx)(`div`,{className:`absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20`,children:(0,G.jsx)(xl,{className:`w-4 h-4 text-bambu-green animate-spin`})}),W?.state!==`RUNNING`&&(0,G.jsx)(`button`,{onClick:e=>{e.stopPropagation(),Qn(Zn?.amsId===t.id&&Zn?.slotId===k?null:{amsId:t.id,slotId:k})},className:`absolute -top-1 -right-1 w-4 h-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:bg-bambu-dark-tertiary`,title:E(`printers.slotOptions`),children:(0,G.jsx)(zs,{className:`w-2.5 h-2.5 text-bambu-gray`})}),W?.state!==`RUNNING`&&Zn?.amsId===t.id&&Zn?.slotId===k&&(0,G.jsxs)(`div`,{className:`absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]`,children:[(0,G.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${A(`printers:ams_rfid`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:e=>{e.stopPropagation(),A(`printers:ams_rfid`)&&(Pn.mutate({amsId:t.id,slotId:k}),Qn(null))},disabled:te||!A(`printers:ams_rfid`),title:A(`printers:ams_rfid`)?void 0:E(`printers.permission.noAmsRfid`),children:[(0,G.jsx)(xl,{className:`w-3 h-3 ${te?`animate-spin`:``}`}),E(`printers.rfid.reread`)]}),(0,G.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${A(`printers:control`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:e=>{e.stopPropagation(),A(`printers:control`)&&(Fn.mutate({trayId:t.id*4+k}),Qn(null))},disabled:!A(`printers:control`),title:A(`printers:control`)?void 0:E(`printers.permission.noControl`),children:[(0,G.jsx)(Uc,{className:`w-3 h-3`}),E(`printers.ams.load`)]}),(0,G.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${A(`printers:control`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:e=>{e.stopPropagation(),A(`printers:control`)&&(In.mutate(),Qn(null))},disabled:!A(`printers:control`),title:A(`printers:control`)?void 0:E(`printers.permission.noControl`),children:[(0,G.jsx)(Wc,{className:`w-3 h-3`}),E(`printers.ams.unload`)]})]}),V?(0,G.jsx)(FK,{data:V,spoolman:{enabled:o,linkedSpoolId:L?.spoolman_spool_id??(j?s?.[j]?.id:void 0),spoolmanUrl:c,syncMode:l,onLinkSpool:o&&!L&&!P?()=>{let n=(V.trayUuid||V.tagUid||Oq(e.serial_number,t.id,k)).toUpperCase();rt({tagUid:V.tagUid||n,trayUuid:V.trayUuid||``,printerId:e.id,amsId:t.id,trayId:k})}:void 0,onUnlinkSpool:M?.id?()=>dn.mutate(M.id):void 0},inventory:(()=>{if(o){if(m)return;let n=L,r=R;return{assignedSpool:r?{id:r.id,material:r.material,brand:r.brand??null,color_name:r.color_name??null,remainingWeightGrams:r.label_weight?Math.max(0,Math.round(r.label_weight-r.weight_used)):void 0}:null,onAssignSpool:()=>at({printerId:e.id,amsId:t.id,trayId:k,trayInfo:{type:y?.tray_type||V.profile,material:y?.tray_type??void 0,profile:V.profile,color:V.colorHex||``,location:nJ(t.id,t.tray.length)}}),onUnassignSpool:r&&!jq(y)?()=>h?.(r.id):void 0,isAssigned:!!n||jq(y)}}let n=u?.(e.id,t.id,k);return{assignedSpool:n?.spool?{id:n.spool.id,material:n.spool.material,brand:n.spool.brand,color_name:n.spool.color_name,remainingWeightGrams:Math.max(0,Math.round(n.spool.label_weight-n.spool.weight_used))}:null,onAssignSpool:()=>at({printerId:e.id,amsId:t.id,trayId:k,trayInfo:{type:y?.tray_type||V.profile,material:y?.tray_type??void 0,profile:V.profile,color:V.colorHex||``,location:nJ(t.id,t.tray.length)}}),onUnassignSpool:n&&!jq(y)?()=>d?.(e.id,t.id,k):void 0,isAssigned:!!n||jq(y)}})(),configureSlot:{enabled:A(`printers:control`),onConfigure:()=>st({amsId:t.id,trayId:k,trayCount:t.tray.length,trayType:y?.tray_type||void 0,trayColor:y?.tray_color||void 0,traySubBrands:y?.tray_sub_brands||void 0,trayInfoIdx:y?.tray_info_idx||void 0,extruderId:n,caliIdx:y?.cali_idx,savedPresetId:O?.preset_id})},children:ne}):(0,G.jsx)(IK,{kind:C??void 0,configureSlot:{enabled:A(`printers:control`),onConfigure:()=>st({amsId:t.id,trayId:k,trayCount:t.tray.length,extruderId:n})},onAssignSpool:()=>at({printerId:e.id,amsId:t.id,trayId:k,trayInfo:{type:``,material:void 0,profile:``,color:``,location:nJ(t.id,t.tray.length)}}),children:ne})]}),(t.humidity!=null||t.temp!=null)&&(0,G.jsxs)(`div`,{className:`flex flex-col justify-center gap-1 shrink-0 max-[550px]:w-full`,children:[t.temp!=null&&(0,G.jsx)(tJ,{temp:t.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>tt({amsId:t.id,amsLabel:nJ(t.id,t.tray.length),mode:`temperature`}),compact:!0}),t.humidity!=null&&(0,G.jsx)(eJ,{humidity:t.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>tt({amsId:t.id,amsLabel:nJ(t.id,t.tray.length),mode:`humidity`}),compact:!0})]})]})]},t.id)}),W.vt_tray.length>0&&(0,G.jsxs)(`div`,{className:`p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30 ${W.vt_tray.length===1?`max-w-[50%]`:``}`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-1 mb-2`,children:(0,G.jsx)(`span`,{className:`text-[10px] text-white font-medium`,children:E(`printers.external`)})}),(0,G.jsx)(`div`,{className:`grid ${W.vt_tray.length>1?`grid-cols-2`:`grid-cols-1`} gap-1.5`,children:[...W.vt_tray].sort((e,t)=>(e.id??254)-(t.id??254)).map(t=>{let n=t.id??254,i=r&&Wt===254?n===254&&W.active_extruder===1||n===255&&W.active_extruder===0:Wt===n,a=n-254,g=r?E(n===254?`printers.extL`:`printers.extR`):``,_=t.tray_info_idx?Et?.[t.tray_info_idx]:null,v=Dt?.[1020+a],y=(t.tray_uuid||t.tag_uid||Oq(e.serial_number,255,a))?.toUpperCase(),b=y?s?.[y]:void 0,x=Eq(b),S=u?.(e.id,255,a),C=(()=>{let e=S?.spool;return e&&e.label_weight>0&&e.weight_used!=null?Math.round(Math.max(0,e.label_weight-e.weight_used)/e.label_weight*100):null})(),w=t.tray_type&&t.remain>=0,T=C===0&&w&&t.remain>0?null:C,D=o&&!m?p?.find(t=>t.printer_id===e.id&&t.ams_id===255&&t.tray_id===a):void 0,O=D?f?.find(e=>e.id===D.spoolman_spool_id):void 0,k=O&&(O.label_weight??0)>0?Math.round(Math.max(0,(O.label_weight??0)-O.weight_used)/(O.label_weight??1)*100):null,j=x??k??T??(w?t.remain:null),M=x!==null||k!==null?`spoolman`:T===null?w?`ams`:void 0:`inventory`,N={vendor:jq(t)?`Bambu Lab`:`Generic`,profile:v?.preset_name||(O?[O.brand,O.slicer_filament_name?.split(`@`)[0].trim()||O.material].filter(Boolean).join(` `).trim():null)||S?.spool?.slicer_filament_name||_?.name||t.tray_sub_brands||t.tray_type||`Unknown`,colorName:Id(t.tray_color||``),colorHex:t.tray_color||null,kFactor:Jq(t.k),fillLevel:j,trayUuid:t.tray_uuid||null,tagUid:t.tag_uid||null,fillSource:M},P=!t.tray_type,F=rJ(t),I=(0,G.jsxs)(`div`,{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${P?`opacity-50`:``} ${i?`ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark`:``}`,children:[(0,G.jsx)(Gq,{trayColor:t.tray_color,trayType:t.tray_type,isEmpty:P,emptyKind:F,slotNumber:a+1}),(0,G.jsx)(`div`,{className:`text-[9px] font-bold truncate ${P?`text-white/40`:`text-white`}`,children:t.tray_type||E(`ams.slotEmpty`)}),(0,G.jsx)(`div`,{className:`mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden`,children:j!==null&&j>=0&&!P&&(0,G.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${j}%`,backgroundColor:Tq(j)}})}),g&&(0,G.jsx)(`div`,{className:`text-[7px] text-white/40 mt-0.5 truncate`,children:g})]}),L=2550+a,R=Zn?.amsId===255&&Zn?.slotId===L;return(0,G.jsxs)(`div`,{className:`relative group`,children:[W?.state!==`RUNNING`&&(0,G.jsx)(`button`,{onClick:e=>{e.stopPropagation(),Qn(R?null:{amsId:255,slotId:L})},className:`absolute -top-1 -right-1 w-4 h-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:bg-bambu-dark-tertiary`,title:E(`printers.slotOptions`),children:(0,G.jsx)(zs,{className:`w-2.5 h-2.5 text-bambu-gray`})}),W?.state!==`RUNNING`&&R&&(0,G.jsxs)(`div`,{className:`absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]`,children:[(0,G.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${A(`printers:control`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:e=>{e.stopPropagation(),A(`printers:control`)&&(Fn.mutate({trayId:n}),Qn(null))},disabled:!A(`printers:control`),title:A(`printers:control`)?void 0:E(`printers.permission.noControl`),children:[(0,G.jsx)(Uc,{className:`w-3 h-3`}),E(`printers.ams.load`)]}),(0,G.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${A(`printers:control`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:e=>{e.stopPropagation(),A(`printers:control`)&&(In.mutate(),Qn(null))},disabled:!A(`printers:control`),title:A(`printers:control`)?void 0:E(`printers.permission.noControl`),children:[(0,G.jsx)(Wc,{className:`w-3 h-3`}),E(`printers.ams.unload`)]})]}),P?(0,G.jsx)(IK,{kind:F??void 0,configureSlot:{enabled:A(`printers:control`),onConfigure:()=>st({amsId:255,trayId:a,trayCount:1,extruderId:r?+(n===254):void 0})},onAssignSpool:()=>at({printerId:e.id,amsId:255,trayId:a,trayInfo:{type:``,material:void 0,profile:``,color:``,location:`External Slot ${a+1}`}}),children:I}):(0,G.jsx)(FK,{data:N,spoolman:{enabled:o,linkedSpoolId:D?.spoolman_spool_id??(y?s?.[y]?.id:void 0),spoolmanUrl:c,syncMode:l,onLinkSpool:o&&!D&&!S?()=>{let t=(N.trayUuid||N.tagUid||Oq(e.serial_number,255,a)).toUpperCase();rt({tagUid:N.tagUid||t,trayUuid:N.trayUuid||``,printerId:e.id,amsId:255,trayId:a})}:void 0,onUnlinkSpool:b?.id?()=>dn.mutate(b.id):void 0},inventory:(()=>{if(o){if(m)return;let n=D,r=O;return{assignedSpool:r?{id:r.id,material:r.material,brand:r.brand??null,color_name:r.color_name??null,remainingWeightGrams:r.label_weight?Math.max(0,Math.round(r.label_weight-r.weight_used)):void 0}:null,onAssignSpool:()=>at({printerId:e.id,amsId:255,trayId:a,trayInfo:{type:t.tray_type||N.profile,material:t.tray_type??void 0,profile:N.profile,color:N.colorHex||``,location:g||E(`printers.external`)}}),onUnassignSpool:r&&!jq(t)?()=>h?.(r.id):void 0,isAssigned:!!n||jq(t)}}let n=u?.(e.id,255,a);return{assignedSpool:n?.spool?{id:n.spool.id,material:n.spool.material,brand:n.spool.brand,color_name:n.spool.color_name,remainingWeightGrams:Math.max(0,Math.round(n.spool.label_weight-n.spool.weight_used))}:null,onAssignSpool:()=>at({printerId:e.id,amsId:255,trayId:a,trayInfo:{type:t.tray_type||N.profile,material:t.tray_type??void 0,profile:N.profile,color:N.colorHex||``,location:g||E(`printers.external`)}}),onUnassignSpool:n&&!jq(t)?()=>d?.(e.id,255,a):void 0,isAssigned:!!n||jq(t)}})(),configureSlot:{enabled:A(`printers:control`),onConfigure:()=>st({amsId:255,trayId:a,trayCount:1,trayType:t.tray_type||void 0,trayColor:t.tray_color||void 0,traySubBrands:t.tray_sub_brands||void 0,trayInfoIdx:t.tray_info_idx||void 0,extruderId:r?+(n===254):void 0,caliIdx:t.cali_idx,savedPresetId:v?.preset_id})},children:I})]},n)})})]})]})]})]})})()]}),Gt&&r===`expanded`&&(0,G.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(Mu,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,G.jsx)(`span`,{className:`text-sm text-white truncate`,children:Gt.name}),qt&&(0,G.jsxs)(`span`,{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${qt.state===`ON`?`bg-bambu-green/20 text-bambu-green`:qt.state===`OFF`?`bg-red-500/20 text-red-400`:`bg-bambu-gray/20 text-bambu-gray`}`,children:[qt.state||`?`,qt.state===`ON`&&qt.energy?.power!=null&&(0,G.jsxs)(`span`,{className:`text-yellow-400 ml-1.5`,children:[`· `,Math.round(qt.energy.power),`W`]})]})]}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsxs)(`button`,{onClick:()=>ne(!0),disabled:mn.isPending||qt?.state===`ON`||!A(`smart_plugs:control`),className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${A(`smart_plugs:control`)?qt?.state===`ON`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary`:`bg-bambu-dark text-bambu-gray/50 cursor-not-allowed`}`,title:A(`smart_plugs:control`)?void 0:E(`printers.permission.noSmartPlugControl`),children:[(0,G.jsx)(_l,{className:`w-3 h-3`}),`On`]}),(0,G.jsxs)(`button`,{onClick:()=>ie(!0),disabled:mn.isPending||qt?.state===`OFF`||!A(`smart_plugs:control`),className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${A(`smart_plugs:control`)?qt?.state===`OFF`?`bg-red-500/30 text-red-400`:`bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary`:`bg-bambu-dark text-bambu-gray/50 cursor-not-allowed`}`,title:A(`smart_plugs:control`)?void 0:E(`printers.permission.noSmartPlugControl`),children:[(0,G.jsx)(gl,{className:`w-3 h-3`}),`Off`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,G.jsx)(`span`,{className:`text-xs hidden sm:inline ${Gt.auto_off_executed?`text-bambu-green`:`text-bambu-gray`}`,children:Gt.auto_off_executed?`Auto-off done`:`Auto-off`}),(0,G.jsx)(`button`,{onClick:()=>hn.mutate(!Gt.auto_off),disabled:hn.isPending||Gt.auto_off_executed||!A(`smart_plugs:control`),title:A(`smart_plugs:control`)?Gt.auto_off_executed?E(`printers.autoOffExecuted`):E(`printers.autoOffAfterPrint`):E(`printers.permission.noSmartPlugControl`),className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${A(`smart_plugs:control`)?Gt.auto_off_executed?`bg-bambu-green/50 cursor-not-allowed`:Gt.auto_off?`bg-bambu-green`:`bg-bambu-dark-tertiary`:`bg-bambu-dark-tertiary/50 cursor-not-allowed`}`,children:(0,G.jsx)(`span`,{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${Gt.auto_off||Gt.auto_off_executed?`translate-x-4`:`translate-x-0`}`})})]})]}),Kt&&Kt.length>0&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-bambu-dark-tertiary/50`,children:[(0,G.jsx)(Tc,{className:`w-3.5 h-3.5 text-blue-400 flex-shrink-0`}),(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`HA:`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Kt.map(e=>{let t=e.ha_entity_id?.startsWith(`script.`);return(0,G.jsxs)(`button`,{onClick:()=>{t?gn.mutate({id:e.id,action:`on`}):ae(e)},disabled:gn.isPending,title:`${t?`Run`:`Toggle`} ${e.ha_entity_id}`,className:`px-2 py-0.5 text-xs bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 rounded transition-colors flex items-center gap-1`,children:[(0,G.jsx)(pl,{className:`w-2.5 h-2.5`}),e.name]},e.id)})})]})]}),r===`expanded`&&(0,G.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-end gap-2 flex-wrap`,children:[(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>xn.mutate(!W?.chamber_light),disabled:!W?.connected||xn.isPending||!A(`printers:control`),title:A(`printers:control`)?W?.chamber_light?E(`printers.chamberLightOff`):E(`printers.chamberLightOn`):E(`printers.permission.noControl`),className:W?.chamber_light?`!border-yellow-500 !text-yellow-400 hover:!bg-yellow-500/20`:``,children:(0,G.jsx)(DT,{on:W?.chamber_light??!1,className:`w-4 h-4 ${W?.chamber_light?`text-yellow-400`:``}`})}),(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>{if(_===`embedded`&&v)v(e.id,e.name);else{let t=localStorage.getItem(`cameraWindowState`),n=t?JSON.parse(t):{width:640,height:400},r=[`width=${n.width}`,`height=${n.height}`,n.left===void 0?``:`left=${n.left}`,n.top===void 0?``:`top=${n.top}`,`menubar=no,toolbar=no,location=no,status=no`].filter(Boolean).join(`,`);window.open(`/camera/${e.id}`,`camera-${e.id}`,r)}},disabled:!W?.connected||!A(`camera:view`),title:A(`camera:view`)?E(_===`embedded`?`printers.openCameraOverlay`:`printers.openCameraWindow`):E(`printers.permission.noCamera`),children:(0,G.jsx)(xu,{className:`w-4 h-4`})}),(0,G.jsxs)(`div`,{className:`inline-flex rounded-md ${e.plate_detection_enabled?`ring-1 ring-green-500`:``}`,children:[(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:Hn,disabled:!W?.connected||En.isPending||!A(`printers:update`),title:A(`printers:update`)?e.plate_detection_enabled?E(`printers.plateDetection.enabledClick`):E(`printers.plateDetection.disabledClick`):E(`printers.plateDetection.noPermission`),className:`!rounded-r-none !border-r-0 ${e.plate_detection_enabled?`!border-green-500 !text-green-400 hover:!bg-green-500/20`:``}`,children:En.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Ol,{className:`w-4 h-4`})}),(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:Un,disabled:!W?.connected||ft||!A(`printers:update`),title:A(`printers:update`)?E(`printers.plateDetection.manageCalibration`):E(`printers.plateDetection.noPermission`),className:`!rounded-l-none !px-1.5 ${e.plate_detection_enabled?`!border-green-500 !text-green-400 hover:!bg-green-500/20`:``}`,children:ft?(0,G.jsx)(Y,{className:`w-3 h-3 animate-spin`}):(0,G.jsx)(es,{className:`w-3 h-3`})})]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>B(!0),disabled:!Lt||!A(`printers:files`),title:A(`printers:files`)?E(`printers.browseFiles`):E(`printers.permission.noFiles`),children:[(0,G.jsx)(yc,{className:`w-4 h-4`}),E(`printers.files`)]}),Lt&&W?.state!==`RUNNING`&&W?.state!==`PAUSE`&&(0,G.jsxs)(Q,{size:`sm`,onClick:()=>Ee(!0),disabled:!A(`printers:control`),title:A(`printers:control`)?E(`common.print`):E(`printers.permission.noControl`),className:`!bg-bambu-green hover:!bg-bambu-green/80 !text-white`,children:[(0,G.jsx)(vl,{className:`w-4 h-4`}),E(`common.print`)]})]})]}),z&&(0,G.jsx)(Fse,{printerId:e.id,printerName:e.name,onClose:()=>B(!1)}),Te&&(0,G.jsx)(gq,{folderId:null,onClose:()=>Ee(!1),onUploadComplete:()=>{},autoUpload:!0,accept:`.gcode,.3mf`,validateFile:e=>{let t=e.name.toLowerCase();if(!t.endsWith(`.gcode`)&&!t.includes(`.gcode.`))return E(`printers.dropNotPrintable`,`Only .gcode and .gcode.3mf files can be printed`)},onFileUploaded:t=>{let n=t.metadata?.sliced_for_model,r=lJ(e.model);if(n&&r&&n.toLowerCase()!==r.toLowerCase())return Z.deleteLibraryFile(t.id).catch(()=>{}),E(`printers.incompatibleFile`,`This file was sliced for {{slicedFor}}, but this printer is a {{printerModel}}`,{slicedFor:n,printerModel:r});Ne({id:t.id,filename:t.filename})}}),Me&&(0,G.jsx)(Uq,{mode:`reprint`,libraryFileId:Me.id,archiveName:Me.filename,initialSelectedPrinterIds:[e.id],onClose:()=>Ne(null),onSuccess:()=>Ne(null),cleanupLibraryAfterDispatch:!0}),ee&&(0,G.jsx)(Hse,{printerId:e.id,printerName:e.name,onClose:()=>V(!1)}),ke&&(0,G.jsx)(pf,{printerId:e.id,printerName:e.name,onClose:()=>Ae(!1)}),De&&(0,G.jsx)(Lwe,{printer:e,status:W,totalPrintHours:n?.total_print_hours,onClose:je}),ut&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:()=>Wn(),children:(0,G.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ut.needs_calibration?(0,G.jsx)(Ol,{className:`w-5 h-5 text-blue-500`}):ut.is_empty?(0,G.jsx)(ls,{className:`w-5 h-5 text-green-500`}):(0,G.jsx)(ms,{className:`w-5 h-5 text-yellow-500`}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:`Build Plate Check`}),ut.reference_count!==void 0&&ut.max_references&&(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded`,children:[ut.reference_count,`/`,ut.max_references,` refs`]})]}),(0,G.jsx)(`button`,{onClick:()=>Wn(),className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,G.jsx)(Au,{className:`w-5 h-5`})})]}),(0,G.jsxs)(`div`,{className:`p-4 space-y-4`,children:[ut.needs_calibration?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`p-3 rounded-lg bg-blue-500/20 border border-blue-500/50`,children:[(0,G.jsx)(`p`,{className:`font-medium text-blue-400`,children:E(`printers.plateDetection.calibrationRequired`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,dangerouslySetInnerHTML:{__html:E(`printers.plateDetection.calibrationInstructions`)}})]}),(0,G.jsxs)(`div`,{className:`text-sm text-bambu-gray space-y-2`,children:[(0,G.jsx)(`p`,{children:E(`printers.plateDetection.calibrationDescription`)}),(0,G.jsx)(`p`,{dangerouslySetInnerHTML:{__html:E(`printers.plateDetection.calibrationTip`)}})]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`p-3 rounded-lg ${ut.is_empty?`bg-green-500/20 border border-green-500/50`:`bg-yellow-500/20 border border-yellow-500/50`}`,children:[(0,G.jsx)(`p`,{className:`font-medium ${ut.is_empty?`text-green-400`:`text-yellow-400`}`,children:ut.is_empty?E(`printers.plateDetection.plateEmpty`):E(`printers.plateDetection.objectsDetected`)}),(0,G.jsxs)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:[E(`printers.plateDetection.confidence`),`: `,Math.round(ut.confidence*100),`% | `,E(`printers.plateDetection.difference`),`: `,ut.difference_percent.toFixed(1),`%`]})]}),ut.debug_image_url&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mb-2`,children:E(`printers.plateDetection.analysisPreview`)}),(0,G.jsx)(`img`,{src:ut.debug_image_url,alt:E(`printers.plateDetection.analysisPreview`),className:`w-full rounded-lg border border-bambu-dark-tertiary`}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-2`,children:E(`printers.plateDetection.analysisLegend`)})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:ut.message})]}),Ln&&Ln.references.length>0&&(0,G.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-bambu-dark-tertiary`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium text-white mb-2`,children:E(`printers.plateDetection.savedReferences`,{count:Ln.references.length,max:Ln.max_references})}),(0,G.jsx)(`div`,{className:`grid grid-cols-5 gap-2`,children:Ln.references.map(t=>(0,G.jsxs)(`div`,{className:`relative group`,children:[(0,G.jsx)(`img`,{src:Z.getPlateReferenceThumbnailUrl(e.id,t.index),alt:t.label||`Reference ${t.index+1}`,className:`w-full aspect-video object-cover rounded border border-bambu-dark-tertiary`}),(0,G.jsx)(`button`,{onClick:()=>qn(t.index),className:`absolute top-1 right-1 p-0.5 bg-red-500/80 rounded opacity-0 group-hover:opacity-100 transition-opacity`,title:E(`printers.plateDetection.deleteReference`),children:(0,G.jsx)(Au,{className:`w-3 h-3 text-white`})}),zn?.index===t.index?(0,G.jsx)(`input`,{type:`text`,value:zn.label,onChange:e=>Bn({...zn,label:e.target.value}),onBlur:()=>Kn(t.index,zn.label),onKeyDown:e=>{e.key===`Enter`&&Kn(t.index,zn.label),e.key===`Escape`&&Bn(null)},className:`w-full mt-1 px-1 py-0.5 text-xs bg-bambu-dark-tertiary border border-bambu-green rounded text-white`,autoFocus:!0,placeholder:E(`printers.plateDetection.labelPlaceholder`)}):(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1 truncate cursor-pointer hover:text-white`,onClick:()=>Bn({index:t.index,label:t.label}),title:t.label?E(`printers.plateDetection.clickToEdit`,{label:t.label}):E(`printers.plateDetection.clickToAddLabel`),children:t.label||(0,G.jsx)(`span`,{className:`italic opacity-50`,children:E(`printers.noLabel`)})}),(0,G.jsx)(`p`,{className:`text-[10px] text-bambu-gray/60`,children:t.timestamp?$d(t.timestamp)?.toLocaleDateString()??``:``})]},t.index))})]}),!ut.needs_calibration&&(0,G.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium text-white`,children:E(`printers.roi.title`)}),gt?(0,G.jsxs)(`div`,{className:`flex gap-1`,children:[(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>_t(null),disabled:vt,children:E(`common.cancel`)}),(0,G.jsx)(Q,{size:`sm`,onClick:Jn,disabled:vt,children:vt?(0,G.jsx)(Y,{className:`w-3 h-3 animate-spin`}):E(`common.save`)})]}):(0,G.jsxs)(Q,{variant:`ghost`,size:`sm`,onClick:()=>_t(ut.roi||{x:.15,y:.35,w:.7,h:.55}),children:[(0,G.jsx)(dl,{className:`w-3 h-3 mr-1`}),E(`common.edit`)]})]}),gt?(0,G.jsxs)(`div`,{className:`space-y-3 bg-bambu-dark-tertiary/50 p-3 rounded-lg`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:E(`printers.roi.xStart`)}),(0,G.jsx)(`input`,{type:`range`,min:`0`,max:`0.9`,step:`0.01`,value:gt.x,onChange:e=>_t({...gt,x:parseFloat(e.target.value)}),className:`w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500`}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(gt.x*100),`%`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:E(`printers.roi.yStart`)}),(0,G.jsx)(`input`,{type:`range`,min:`0`,max:`0.9`,step:`0.01`,value:gt.y,onChange:e=>_t({...gt,y:parseFloat(e.target.value)}),className:`w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500`}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(gt.y*100),`%`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:E(`printers.width`)}),(0,G.jsx)(`input`,{type:`range`,min:`0.1`,max:`1`,step:`0.01`,value:gt.w,onChange:e=>_t({...gt,w:parseFloat(e.target.value)}),className:`w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500`}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(gt.w*100),`%`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:E(`printers.height`)}),(0,G.jsx)(`input`,{type:`range`,min:`0.1`,max:`1`,step:`0.01`,value:gt.h,onChange:e=>_t({...gt,h:parseFloat(e.target.value)}),className:`w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500`}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(gt.h*100),`%`]})]})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:E(`printers.roi.instruction`)})]}):(0,G.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[`Current: X=`,Math.round((ut.roi?.x||.15)*100),`%, Y=`,Math.round((ut.roi?.y||.35)*100),`%, W=`,Math.round((ut.roi?.w||.7)*100),`%, H=`,Math.round((ut.roi?.h||.55)*100),`%`]})]})]}),(0,G.jsx)(`div`,{className:`flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary`,children:ut.needs_calibration?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Q,{variant:`ghost`,onClick:()=>Wn(),children:E(`common.cancel`)}),(0,G.jsx)(Q,{onClick:()=>Gn(),disabled:mt,children:mt?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 mr-2 animate-spin`}),`Calibrating...`]}):`Calibrate Empty Plate`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Q,{variant:`ghost`,onClick:()=>Gn(),disabled:mt,children:mt?`Adding...`:`Add Reference (${Ln?.references.length||0}/${Ln?.max_references||5})`}),(0,G.jsx)(Q,{onClick:()=>Wn(),children:`Close`})]})})]})}),te&&Gt&&(0,G.jsx)(xd,{title:E(`printers.confirm.powerOnTitle`),message:E(`printers.confirm.powerOnMessage`,{name:e.name}),confirmText:E(`printers.confirm.powerOnButton`),variant:`default`,onConfirm:()=>{mn.mutate(`on`),ne(!1)},onCancel:()=>ne(!1)}),re&&Gt&&(0,G.jsx)(xd,{title:E(`printers.confirm.powerOffTitle`),message:W?.state===`RUNNING`?E(`printers.confirm.powerOffWarning`,{name:e.name}):E(`printers.confirm.powerOffMessage`,{name:e.name}),confirmText:E(`printers.confirm.powerOffButton`),variant:`danger`,onConfirm:()=>{mn.mutate(`off`),ie(!1)},onCancel:()=>ie(!1)}),H&&(0,G.jsx)(xd,{title:E(`printers.confirm.haToggleTitle`,{name:H.name}),message:W?.state===`RUNNING`?E(`printers.confirm.haToggleWarning`,{name:e.name,entity:H.ha_entity_id||H.name}):E(`printers.confirm.haToggleMessage`,{entity:H.ha_entity_id||H.name}),confirmText:E(`printers.confirm.haToggleButton`),variant:W?.state===`RUNNING`?`danger`:`default`,onConfirm:()=>{gn.mutate({id:H.id,action:`toggle`}),ae(null)},onCancel:()=>ae(null)}),se&&(0,G.jsx)(xd,{title:E(`printers.confirm.stopTitle`),message:E(`printers.confirm.stopMessage`,{name:e.name}),confirmText:E(`printers.confirm.stopButton`),variant:`danger`,onConfirm:()=>{_n.mutate(),ce(!1)},onCancel:()=>ce(!1)}),le&&(0,G.jsx)(xd,{title:E(`printers.confirm.pauseTitle`),message:E(`printers.confirm.pauseMessage`,{name:e.name}),confirmText:E(`printers.confirm.pauseButton`),variant:`default`,onConfirm:()=>{vn.mutate(),ue(!1)},onCancel:()=>ue(!1)}),xe&&(0,G.jsx)(xd,{title:E(`printers.confirm.resumeTitle`),message:E(`printers.confirm.resumeMessage`,{name:e.name}),confirmText:E(`printers.confirm.resumeButton`),variant:`default`,onConfirm:()=>{yn.mutate(),Se(!1)},onCancel:()=>Se(!1)}),ye&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,G.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl w-full max-w-sm p-5`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,G.jsx)(hu,{className:`w-5 h-5 text-yellow-400 flex-shrink-0 mt-0.5`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-white mb-1`,children:E(`printers.bedJog.notHomedTitle`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray leading-relaxed`,children:E(`printers.bedJog.notHomedMessage`)})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(`button`,{onClick:()=>{Tn.mutate(`all`),be(null)},className:`w-full px-3 py-2 rounded-lg text-xs font-medium bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 transition-colors`,children:E(`printers.bedJog.homeZ`)}),(0,G.jsx)(`button`,{onClick:()=>{let t=ye.distance;try{sessionStorage.setItem(`bambuddy.bedJog.warned.${e.id}`,`1`)}catch{}wn.mutate({distance:t,force:!0}),be(null)},className:`w-full px-3 py-2 rounded-lg text-xs font-medium bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/30 transition-colors`,children:E(`printers.bedJog.moveAnyway`)}),(0,G.jsx)(`button`,{onClick:()=>be(null),className:`w-full px-3 py-2 rounded-lg text-xs font-medium bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary transition-colors`,children:E(`common.cancel`)})]})]})}),(0,G.jsx)(kT,{printerId:e.id,isOpen:Ce,onClose:()=>we(!1)}),oe&&(0,G.jsx)(Bf,{printerName:e.name,errors:W?.hms_errors||[],onClose:()=>U(!1),printerId:e.id,hasPermission:A}),$e&&(0,G.jsx)(iwe,{isOpen:!!$e,onClose:()=>tt(null),printerId:e.id,printerName:e.name,amsId:$e.amsId,amsLabel:$e.amsLabel,initialMode:$e.mode,thresholds:a}),nt&&(0,G.jsx)(LK,{isOpen:!!nt,onClose:()=>rt(null),tagUid:nt.tagUid,trayUuid:nt.trayUuid,printerId:nt.printerId,amsId:nt.amsId,trayId:nt.trayId}),it&&(0,G.jsx)(zK,{isOpen:!!it,onClose:()=>at(null),printerId:it.printerId,amsId:it.amsId,trayId:it.trayId,trayInfo:it.trayInfo,spoolmanEnabled:!!o}),ot&&(0,G.jsx)(mq,{isOpen:!!ot,onClose:()=>st(null),printerId:e.id,slotInfo:ot,printerModel:lJ(e.model)||void 0,onSuccess:()=>{D.invalidateQueries({queryKey:[`slotPresets`,e.id]}),D.invalidateQueries({queryKey:[`printerStatus`,e.id]})}}),L&&(0,G.jsx)($we,{printer:e,onClose:()=>R(!1)}),ct&&St&&(0,G.jsx)(Qwe,{printer:e,firmwareInfo:St,onClose:()=>lt(!1)}),Zn&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>Qn(null)}),Pe!==null&&Ke&&(()=>{let e=Ie===`n3s`?85:65,t=e+10;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-[100]`,onClick:()=>Fe(null)}),(0,G.jsxs)(`div`,{className:`fixed z-[101] flex flex-col w-[240px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl overflow-hidden`,style:{top:Ke.top,left:Ke.left,maxHeight:`calc(100dvh - ${Ke.top}px - 8px)`},onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-3 py-2.5 border-b border-bambu-dark-tertiary`,children:[(0,G.jsx)(ec,{className:`w-3.5 h-3.5 text-amber-400`}),(0,G.jsx)(`span`,{className:`text-xs text-white font-medium`,children:E(`printers.drying.start`)})]}),(0,G.jsxs)(`div`,{className:`px-3 py-2.5 space-y-2.5 overflow-y-auto min-h-0`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[10px] text-bambu-gray mb-1 block`,children:E(`printers.filaments`)}),(0,G.jsx)(`select`,{value:Re,onChange:e=>{let t=e.target.value;ze(t);let n=x[t];n&&(Ve(n[Ie===`n3s`?`n3s`:`n3f`]),Ue(Ie===`n3s`?n.n3s_hours:n.n3f_hours))},className:`w-full px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs focus:outline-none focus:border-amber-500/50`,children:Object.keys(x).map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,G.jsx)(`label`,{className:`text-[10px] text-bambu-gray`,children:E(`printers.drying.temperature`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`input`,{type:`number`,min:45,max:e,value:Be,onChange:t=>Ve(Math.min(e,Math.max(45,Number(t.target.value)||45))),className:`w-12 px-1 py-0.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-[11px] text-center focus:outline-none focus:border-amber-500/50 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,G.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:`°C`})]})]}),(0,G.jsx)(`input`,{type:`range`,min:35,max:t,value:Be,onChange:t=>Ve(Math.min(e,Math.max(45,Number(t.target.value)))),className:`w-full h-1 accent-amber-500 cursor-pointer`}),(0,G.jsxs)(`div`,{className:`flex justify-between text-[9px] text-bambu-gray/50 mt-0.5`,children:[(0,G.jsx)(`span`,{children:`45°C`}),(0,G.jsxs)(`span`,{children:[e,`°C`]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,G.jsx)(`label`,{className:`text-[10px] text-bambu-gray`,children:E(`printers.drying.duration`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`input`,{type:`number`,min:1,max:24,value:He,onChange:e=>Ue(Math.min(24,Math.max(1,Number(e.target.value)||1))),className:`w-10 px-1 py-0.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-[11px] text-center focus:outline-none focus:border-amber-500/50 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,G.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:E(`printers.drying.hours`)})]})]}),(0,G.jsx)(`input`,{type:`range`,min:1,max:24,value:He,onChange:e=>Ue(Number(e.target.value)),className:`w-full h-1 accent-amber-500 cursor-pointer`}),(0,G.jsxs)(`div`,{className:`flex justify-between text-[9px] text-bambu-gray/50 mt-0.5`,children:[(0,G.jsx)(`span`,{children:`1h`}),(0,G.jsx)(`span`,{children:`24h`})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:We,onChange:e=>Ge(e.target.checked),className:`w-3.5 h-3.5 accent-amber-500 rounded cursor-pointer`}),(0,G.jsx)(`span`,{className:`text-[11px] text-bambu-gray`,children:E(`printers.drying.rotateTray`)})]})]}),(0,G.jsx)(`div`,{className:`shrink-0 px-3 pt-2.5 pb-3`,children:(0,G.jsx)(`button`,{onClick:()=>{Pe!==null&&fn.mutate({amsId:Pe,temp:Be,duration:He,filament:Re,rotateTray:We})},disabled:fn.isPending,className:`w-full py-1.5 bg-amber-500 hover:bg-amber-400 text-white text-xs font-medium rounded-lg transition-colors disabled:opacity-50`,children:fn.isPending?E(`printers.drying.startingDrying`):E(`printers.drying.start`)})})]})]})})()]})}function Zwe({onClose:e,onAdd:t,existingSerials:n}){let{t:r}=et(),[i,a]=(0,y.useState)({name:``,serial_number:``,ip_address:``,access_code:``,model:``,location:``,auto_archive:!0}),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)([]),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(!1),[g,_]=(0,y.useState)([]),[v,b]=(0,y.useState)(``),[x,S]=(0,y.useState)(``),[C,w]=(0,y.useState)(!1),[T,E]=(0,y.useState)({scanned:0,total:0}),[D,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)(!1),[j,M]=(0,y.useState)(null);(0,y.useEffect)(()=>{Ku.getInfo().then(e=>{h(e.is_docker),e.subnets.length>0&&(_(e.subnets),b(e.subnets[0]))}).catch(()=>{});try{let e=localStorage.getItem(`bambuddy.discovery.customSubnet`);e&&S(e)}catch{}},[]);let N=c.filter(e=>!n.includes(e.serial)),P=async e=>{e.preventDefault(),A(!0);try{let e=await Z.diagnoseConnection({ip_address:i.ip_address.trim(),serial_number:i.serial_number.trim()||void 0,access_code:i.access_code||void 0});if(e.checks.some(e=>e.status===`fail`)){M(e);return}}catch{}finally{A(!1)}t(i)},F=async()=>{d(``),l([]),s(!0),p(!1),E({scanned:0,total:0});let e=C?x.trim():v,t=m||C;if(t&&C)try{localStorage.setItem(`bambuddy.discovery.customSubnet`,e)}catch{}try{if(t){await Ku.startSubnetScan(e);let t=setInterval(async()=>{try{let e=await Ku.getScanStatus();E({scanned:e.scanned,total:e.total}),l(await Ku.getDiscoveredPrinters()),e.running||(clearInterval(t),s(!1),p(!0))}catch(e){console.error(`Failed to get scan status:`,e)}},500)}else{await Ku.startDiscovery(10);let e=setInterval(async()=>{try{l(await Ku.getDiscoveredPrinters())}catch(e){console.error(`Failed to get discovered printers:`,e)}},1e3);setTimeout(async()=>{clearInterval(e);try{await Ku.stopDiscovery()}catch{}s(!1),p(!0);try{l(await Ku.getDiscoveredPrinters())}catch(e){console.error(`Failed to get final discovered printers:`,e)}},1e4)}}catch(e){console.error(`Failed to start discovery:`,e),d(e instanceof Error?e.message:r(`printers.discovery.failedToStart`)),s(!1),p(!0)}},I=e=>{let t=e.serial.startsWith(`unknown-`)?``:e.serial;a({...i,name:e.name||``,serial_number:t,ip_address:e.ip_address,model:lJ(e.model)}),l([])};return(0,y.useEffect)(()=>()=>{Ku.stopDiscovery().catch(()=>{}),Ku.stopSubnetScan().catch(()=>{})},[]),(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-start sm:items-center justify-center z-50 p-4 overflow-y-auto`,onClick:e,children:(0,G.jsx)(cd,{className:`w-full max-w-md my-auto max-h-[calc(100vh-2rem)] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:(0,G.jsxs)(ud,{children:[(0,G.jsx)(`h2`,{className:`text-xl font-semibold mb-4`,children:r(`printers.addPrinter`)}),(0,G.jsxs)(`div`,{className:`mb-4 pb-4 border-b border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.discovery.subnetToScan`)}),g.length>0?(0,G.jsxs)(`select`,{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 text-sm`,value:C?`__custom__`:v,onChange:e=>{e.target.value===`__custom__`?w(!0):(w(!1),b(e.target.value))},disabled:o,children:[g.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e)),(0,G.jsx)(`option`,{value:`__custom__`,children:r(`printers.discovery.customSubnetOption`)})]}):(0,G.jsx)(`input`,{type:`text`,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 text-sm`,value:v,onChange:e=>b(e.target.value),placeholder:`192.168.1.0/24`,disabled:o}),C&&(0,G.jsx)(`input`,{type:`text`,"aria-label":r(`printers.discovery.customSubnetLabel`),className:`mt-2 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 text-sm`,value:x,onChange:e=>S(e.target.value),placeholder:`10.1.1.0/24`,disabled:o}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-bambu-gray`,children:r(m?`printers.discovery.dockerNote`:`printers.discovery.customSubnetNote`)})]}),(0,G.jsx)(Q,{type:`button`,variant:`secondary`,onClick:F,disabled:o,className:`w-full`,children:o?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),(m||C)&&T.total>0?r(`printers.discovery.scanProgress`,{scanned:T.scanned,total:T.total}):r(`printers.discovery.scanning`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Al,{className:`w-4 h-4`}),r(m||C?`printers.discovery.scanSubnet`:`printers.discovery.discoverNetwork`)]})}),u&&(0,G.jsx)(`div`,{className:`mt-2 text-sm text-red-400`,children:u}),N.length>0&&(0,G.jsx)(`div`,{className:`mt-3 space-y-2 max-h-40 overflow-y-auto`,children:N.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between p-2 bg-bambu-dark rounded-lg hover:bg-bambu-dark-secondary cursor-pointer transition-colors`,onClick:()=>I(e),children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`font-medium text-white text-sm truncate`,children:e.name||e.serial}),(0,G.jsxs)(`p`,{className:`text-xs text-bambu-gray truncate`,children:[lJ(e.model)||r(`printers.discovery.unknown`),` • `,e.ip_address,e.serial.startsWith(`unknown-`)&&(0,G.jsxs)(`span`,{className:`text-yellow-500`,children:[` • `,r(`printers.discovery.serialRequired`)]})]})]}),(0,G.jsx)(es,{className:`w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2`})]},e.serial))}),o&&(0,G.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray text-center`,children:r(m||C?`printers.discovery.scanningSubnet`:`printers.discovery.scanningNetwork`)}),f&&!o&&c.length===0&&(0,G.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray text-center`,children:r(m||C?`printers.discovery.noPrintersFoundSubnet`:`printers.discovery.noPrintersFoundNetwork`)}),f&&!o&&c.length>0&&N.length===0&&(0,G.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray text-center`,children:r(`printers.discovery.allConfigured`)})]}),(0,G.jsxs)(`form`,{onSubmit:P,className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.name`)}),(0,G.jsx)(`input`,{type:`text`,required:!0,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`,value:i.name,onChange:e=>a({...i,name:e.target.value}),placeholder:r(`printers.modal.myPrinter`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.ipAddress`)}),(0,G.jsx)(`input`,{type:`text`,required:!0,pattern:`(\\d{1,3}(\\.\\d{1,3}){3}|[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?)*)`,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`,value:i.ip_address,onChange:e=>a({...i,ip_address:e.target.value}),placeholder:`192.168.1.100 or printer.local`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.serialNumber`)}),(0,G.jsx)(`input`,{type:`text`,required:!0,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`,value:i.serial_number,onChange:e=>a({...i,serial_number:e.target.value}),placeholder:`01P00A000000000`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.accessCode`)}),(0,G.jsx)(`input`,{type:`password`,required:!0,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`,value:i.access_code,onChange:e=>a({...i,access_code:e.target.value}),placeholder:r(`printers.modal.fromPrinterSettings`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.modal.modelOptional`)}),(0,G.jsxs)(`select`,{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`,value:i.model||``,onChange:e=>a({...i,model:e.target.value}),children:[(0,G.jsx)(`option`,{value:``,children:r(`printers.modal.selectModel`)}),(0,G.jsxs)(`optgroup`,{label:`A1 Series`,children:[(0,G.jsx)(`option`,{value:`A1`,children:`A1`}),(0,G.jsx)(`option`,{value:`A1 Mini`,children:`A1 Mini`})]}),(0,G.jsx)(`optgroup`,{label:`A2 Series`,children:(0,G.jsx)(`option`,{value:`A2L`,children:`A2L`})}),(0,G.jsxs)(`optgroup`,{label:`H2 Series`,children:[(0,G.jsx)(`option`,{value:`H2C`,children:`H2C`}),(0,G.jsx)(`option`,{value:`H2D`,children:`H2D`}),(0,G.jsx)(`option`,{value:`H2D Pro`,children:`H2D Pro`}),(0,G.jsx)(`option`,{value:`H2S`,children:`H2S`})]}),(0,G.jsxs)(`optgroup`,{label:`P Series`,children:[(0,G.jsx)(`option`,{value:`P1P`,children:`P1P`}),(0,G.jsx)(`option`,{value:`P1S`,children:`P1S`}),(0,G.jsx)(`option`,{value:`P2S`,children:`P2S`})]}),(0,G.jsxs)(`optgroup`,{label:`X1 Series`,children:[(0,G.jsx)(`option`,{value:`X1`,children:`X1`}),(0,G.jsx)(`option`,{value:`X1C`,children:`X1 Carbon`}),(0,G.jsx)(`option`,{value:`X1E`,children:`X1E`})]}),(0,G.jsx)(`optgroup`,{label:`X2 Series`,children:(0,G.jsx)(`option`,{value:`X2D`,children:`X2D`})})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.modal.locationGroup`)}),(0,G.jsx)(`input`,{type:`text`,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`,value:i.location||``,onChange:e=>a({...i,location:e.target.value}),placeholder:r(`printers.modal.locationPlaceholder`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:r(`printers.locationHelp`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,id:`auto_archive`,checked:i.auto_archive,onChange:e=>a({...i,auto_archive:e.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,G.jsx)(`label`,{htmlFor:`auto_archive`,className:`text-sm text-bambu-gray`,children:r(`printers.modal.autoArchiveLabel`)})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>O(!0),disabled:!i.ip_address.trim(),className:`w-full flex items-center justify-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white disabled:opacity-40 disabled:cursor-not-allowed border border-bambu-dark-tertiary rounded-lg transition-colors`,children:[(0,G.jsx)(eu,{className:`w-4 h-4`}),r(`diagnostic.runButton`)]}),j?(0,G.jsxs)(`div`,{className:`rounded-lg bg-amber-500/10 border border-amber-500/30 p-3 space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(hu,{className:`w-4 h-4 mt-0.5 flex-shrink-0 text-amber-400`}),(0,G.jsx)(`p`,{className:`text-sm text-amber-300`,children:r(`printers.addPreflight.warning`)})]}),(0,G.jsx)(df,{result:j}),(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(Q,{type:`button`,variant:`secondary`,onClick:()=>M(null),className:`flex-1`,children:r(`printers.addPreflight.back`)}),(0,G.jsx)(Q,{type:`button`,onClick:()=>t(i),className:`flex-1`,children:r(`printers.addPreflight.saveAnyway`)})]})]}):(0,G.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,G.jsx)(Q,{type:`button`,variant:`secondary`,onClick:e,className:`flex-1`,children:r(`common.cancel`)}),(0,G.jsx)(Q,{type:`submit`,disabled:k,className:`flex-1`,children:r(k?`printers.addPreflight.checking`:`printers.addPrinter`)})]})]})]})})}),D&&(0,G.jsx)(pf,{connection:{ip_address:i.ip_address.trim(),serial_number:i.serial_number.trim()||void 0,access_code:i.access_code||void 0},printerName:i.name||null,onClose:()=>O(!1)})]})}function Qwe({printer:e,firmwareInfo:t,onClose:n}){let{t:r}=et(),i=$a(),{showToast:a}=gd(),{hasPermission:o}=nd(),s=o(`firmware:update`),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(t.update_available?t.latest_version:null),{data:g,isLoading:_}=K({queryKey:[`firmwarePrepare`,e.id,m],queryFn:()=>Xu.prepareUpload(e.id,m??void 0),staleTime:3e4,enabled:!!m&&s&&!u}),v=q({mutationFn:()=>Xu.startUpload(e.id,m??void 0),onSuccess:()=>{d(!0);let t=setInterval(async()=>{try{let n=await Xu.getUploadStatus(e.id);l(n),(n.status===`complete`||n.status===`error`)&&(clearInterval(t),p(null),d(!1),n.status===`complete`&&(a(r(`printers.firmwareModal.uploadedToast`),`success`),i.invalidateQueries({queryKey:[`firmwareUpdate`,e.id]})))}catch{}},2e3);p(t)},onError:e=>{a(r(`printers.firmwareModal.uploadFailed`,{error:e.message}),`error`),d(!1)}});return(0,y.useEffect)(()=>()=>{f&&clearInterval(f)},[f]),(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,G.jsx)(cd,{className:`w-full max-w-md mx-4`,children:(0,G.jsxs)(ud,{children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,G.jsx)(`div`,{className:`p-2 rounded-full ${t.update_available?`bg-orange-500/20`:`bg-status-ok/20`}`,children:t.update_available?(0,G.jsx)(Is,{className:`w-5 h-5 text-orange-400`}):(0,G.jsx)(ls,{className:`w-5 h-5 text-status-ok`})}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:t.update_available?r(`printers.firmwareModal.title`):r(`printers.firmwareModal.titleUpToDate`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:e.name})]})]}),(()=>{let e=m?t.available_versions?.find(e=>e.version===m):null,n=m??t.latest_version,i=e?.release_notes??t.release_notes,a=!!n&&n!==t.current_version;return(0,G.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3 mb-4`,children:[(0,G.jsxs)(`div`,{className:`flex justify-between items-center text-sm`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:r(`printers.firmwareModal.currentVersion`)}),(0,G.jsx)(`span`,{className:`font-mono ${a?`text-white`:`text-status-ok`}`,children:t.current_version||r(`common.unknown`)})]}),a&&(0,G.jsxs)(`div`,{className:`flex justify-between items-center text-sm mt-1`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:r(`printers.firmwareModal.latestVersion`)}),(0,G.jsx)(`span`,{className:`text-orange-400 font-mono`,children:n})]}),i&&(0,G.jsxs)(`details`,{className:`mt-3 text-sm`,open:!a,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer hover:underline ${a?`text-orange-400`:`text-status-ok`}`,children:r(`printers.firmwareModal.releaseNotes`)}),(0,G.jsx)(`div`,{className:`mt-2 text-bambu-gray text-xs max-h-40 overflow-y-auto whitespace-pre-wrap`,children:i})]},n??`none`)]})})(),t.available_versions&&t.available_versions.length>0&&!u&&c?.status!==`complete`&&(0,G.jsxs)(`div`,{className:`mb-4`,children:[(0,G.jsx)(`div`,{className:`text-xs text-bambu-gray mb-2`,children:r(`printers.firmwareModal.availableVersions`)}),(0,G.jsx)(`div`,{className:`max-h-56 overflow-y-auto border border-bambu-dark-tertiary rounded-lg divide-y divide-bambu-dark-tertiary`,children:t.available_versions.map(e=>{let n=t.current_version===e.version,i=m===e.version,a=t.current_version?Mf(e.version,t.current_version):0,o=r(n?`printers.firmwareModal.currentBadge`:a>0?`printers.firmwareModal.newerBadge`:`printers.firmwareModal.olderBadge`),c=n?`text-bambu-gray`:a>0?`text-orange-400`:`text-blue-400`;return(0,G.jsxs)(`button`,{type:`button`,disabled:!e.file_available||!s||n,onClick:()=>h(e.version),className:`w-full text-left px-3 py-2 text-sm flex items-center justify-between gap-2 transition-colors ${i?`bg-orange-500/10`:`hover:bg-bambu-dark`} ${!e.file_available||!s||n?`opacity-60 cursor-not-allowed`:`cursor-pointer`}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`span`,{className:`font-mono text-white`,children:e.version}),(0,G.jsx)(`span`,{className:`text-xs ${c}`,children:o})]}),(0,G.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${n?`bg-blue-500/15 text-blue-400 border border-blue-500/30`:e.file_available?`bg-bambu-green/15 text-bambu-green border border-bambu-green/30`:`bg-bambu-gray/10 text-bambu-gray border border-bambu-gray/30`}`,children:n?r(`printers.firmwareModal.installed`):e.file_available?r(`printers.firmwareModal.usable`):r(`printers.firmwareModal.unavailable`)})]},e.version)})})]}),m?_?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-sm mb-4`,children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),r(`printers.firmwareModal.checkingPrereqs`)]}):g&&!u&&!c?(0,G.jsx)(`div`,{className:`mb-4`,children:g.can_proceed?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-green text-sm`,children:[(0,G.jsx)(Vo,{className:`w-4 h-4`}),r(`printers.firmwareModal.sdCardReady`)]}):(0,G.jsx)(`div`,{className:`space-y-1`,children:g.errors.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,G.jsx)(ss,{className:`w-4 h-4 flex-shrink-0`}),e]},t))})}):null:null,(u||c)&&c&&(0,G.jsxs)(`div`,{className:`mb-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-sm mb-1`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray capitalize`,children:c.status}),(0,G.jsxs)(`span`,{className:`text-white`,children:[c.progress,`%`]})]}),(0,G.jsx)(`div`,{className:`w-full bg-bambu-dark-tertiary rounded-full h-2`,children:(0,G.jsx)(`div`,{className:`h-2 rounded-full transition-all ${c.status===`error`?`bg-status-error`:c.status===`complete`?`bg-status-ok`:`bg-orange-500`} ${c.status===`uploading`?`animate-pulse`:``}`,style:{width:`${c.progress}%`}})}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:c.message}),c.error&&(0,G.jsx)(`p`,{className:`text-xs text-red-400 mt-1`,children:c.error})]}),c?.status===`complete`&&(0,G.jsxs)(`div`,{className:`bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-green font-medium mb-2`,children:r(`printers.firmwareModal.uploadedSuccess`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:r(`printers.firmwareModal.applyInstructions`)}),(0,G.jsxs)(`ol`,{className:`text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1`,children:[(0,G.jsx)(`li`,{dangerouslySetInnerHTML:{__html:r(`printers.firmwareModal.step1`)}}),(0,G.jsx)(`li`,{dangerouslySetInnerHTML:{__html:r(`printers.firmwareModal.step2`)}}),(0,G.jsx)(`li`,{dangerouslySetInnerHTML:{__html:r(`printers.firmwareModal.step3`)}}),(0,G.jsx)(`li`,{children:r(`printers.firmwareModal.step4`)})]})]}),(0,G.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:n,children:c?.status===`complete`?r(`printers.firmwareModal.done`):r(`common.cancel`)}),g?.can_proceed&&!u&&c?.status!==`complete`&&s&&(0,G.jsx)(Q,{onClick:()=>{l(null),v.mutate()},disabled:v.isPending,children:v.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin mr-2`}),r(`printers.firmwareModal.starting`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Is,{className:`w-4 h-4 mr-2`}),r(`printers.firmwareModal.uploadFirmware`)]})})]})]})})})}function $we({printer:e,onClose:t}){let{t:n}=et(),r=$a(),{showToast:i}=gd(),[a,o]=(0,y.useState)({name:e.name,ip_address:e.ip_address,access_code:``,model:e.model||``,location:e.location||``,auto_archive:e.auto_archive}),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(null),d=q({mutationFn:t=>Z.updatePrinter(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`printers`]}),r.invalidateQueries({queryKey:[`printerStatus`,e.id]}),t()},onError:e=>i(e.message||n(`printers.toast.failedToUpdate`),`error`)});(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let f=()=>{let e={name:a.name,ip_address:a.ip_address,model:a.model||void 0,location:a.location||void 0,auto_archive:a.auto_archive};a.access_code&&(e.access_code=a.access_code),d.mutate(e)};return(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-start sm:items-center justify-center z-50 p-4 overflow-y-auto`,onClick:t,children:(0,G.jsx)(cd,{className:`w-full max-w-md my-auto max-h-[calc(100vh-2rem)] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:(0,G.jsxs)(ud,{children:[(0,G.jsx)(`h2`,{className:`text-xl font-semibold mb-4`,children:n(`printers.editPrinter`)}),(0,G.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),c(!0);try{let t=await Z.diagnoseConnection({ip_address:a.ip_address.trim(),serial_number:e.serial_number,access_code:a.access_code||void 0});if(t.checks.some(e=>e.status===`fail`)){u(t);return}}catch{}finally{c(!1)}f()},className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.name`)}),(0,G.jsx)(`input`,{type:`text`,required:!0,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`,value:a.name,onChange:e=>o({...a,name:e.target.value}),placeholder:n(`printers.modal.myPrinter`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.ipAddress`)}),(0,G.jsx)(`input`,{type:`text`,required:!0,pattern:`(\\d{1,3}(\\.\\d{1,3}){3}|[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?)*)`,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`,value:a.ip_address,onChange:e=>o({...a,ip_address:e.target.value}),placeholder:`192.168.1.100 or printer.local`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.serialNumber`)}),(0,G.jsx)(`input`,{type:`text`,disabled:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed`,value:e.serial_number}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`printers.serialCannotBeChanged`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.accessCode`)}),(0,G.jsx)(`input`,{type:`password`,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`,value:a.access_code,onChange:e=>o({...a,access_code:e.target.value}),placeholder:n(`printers.accessCodePlaceholder`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.model`)}),(0,G.jsxs)(`select`,{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`,value:a.model,onChange:e=>o({...a,model:e.target.value}),children:[(0,G.jsx)(`option`,{value:``,children:n(`printers.modal.selectModel`)}),(0,G.jsxs)(`optgroup`,{label:`A1 Series`,children:[(0,G.jsx)(`option`,{value:`A1`,children:`A1`}),(0,G.jsx)(`option`,{value:`A1 Mini`,children:`A1 Mini`})]}),(0,G.jsx)(`optgroup`,{label:`A2 Series`,children:(0,G.jsx)(`option`,{value:`A2L`,children:`A2L`})}),(0,G.jsxs)(`optgroup`,{label:`H2 Series`,children:[(0,G.jsx)(`option`,{value:`H2C`,children:`H2C`}),(0,G.jsx)(`option`,{value:`H2D`,children:`H2D`}),(0,G.jsx)(`option`,{value:`H2D Pro`,children:`H2D Pro`}),(0,G.jsx)(`option`,{value:`H2S`,children:`H2S`})]}),(0,G.jsxs)(`optgroup`,{label:`P Series`,children:[(0,G.jsx)(`option`,{value:`P1P`,children:`P1P`}),(0,G.jsx)(`option`,{value:`P1S`,children:`P1S`}),(0,G.jsx)(`option`,{value:`P2S`,children:`P2S`})]}),(0,G.jsxs)(`optgroup`,{label:`X1 Series`,children:[(0,G.jsx)(`option`,{value:`X1`,children:`X1`}),(0,G.jsx)(`option`,{value:`X1C`,children:`X1 Carbon`}),(0,G.jsx)(`option`,{value:`X1E`,children:`X1E`})]}),(0,G.jsx)(`optgroup`,{label:`X2 Series`,children:(0,G.jsx)(`option`,{value:`X2D`,children:`X2D`})})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:`Location / Group`}),(0,G.jsx)(`input`,{type:`text`,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`,value:a.location,onChange:e=>o({...a,location:e.target.value}),placeholder:n(`printers.modal.locationPlaceholder`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`printers.locationHelp`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,id:`edit_auto_archive`,checked:a.auto_archive,onChange:e=>o({...a,auto_archive:e.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,G.jsx)(`label`,{htmlFor:`edit_auto_archive`,className:`text-sm text-bambu-gray`,children:n(`printers.modal.autoArchiveLabel`)})]}),l?(0,G.jsxs)(`div`,{className:`rounded-lg bg-amber-500/10 border border-amber-500/30 p-3 space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(hu,{className:`w-4 h-4 mt-0.5 flex-shrink-0 text-amber-400`}),(0,G.jsx)(`p`,{className:`text-sm text-amber-300`,children:n(`printers.addPreflight.warning`)})]}),(0,G.jsx)(df,{result:l}),(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(Q,{type:`button`,variant:`secondary`,onClick:()=>u(null),className:`flex-1`,children:n(`printers.addPreflight.back`)}),(0,G.jsx)(Q,{type:`button`,onClick:f,className:`flex-1`,disabled:d.isPending,children:n(`printers.addPreflight.saveAnyway`)})]})]}):(0,G.jsxs)(`div`,{className:`flex gap-3 pt-4`,children:[(0,G.jsx)(Q,{type:`button`,variant:`secondary`,onClick:t,className:`flex-1`,children:n(`common.cancel`)}),(0,G.jsx)(Q,{type:`submit`,className:`flex-1`,disabled:d.isPending||s,children:s?n(`printers.addPreflight.checking`):d.isPending?n(`common.saving`):n(`printers.modal.saveChanges`)})]})]})]})})})}function eTe(e){let{data:t}=K({queryKey:[`printerStatus`,e],queryFn:()=>Z.getPrinterStatus(e),refetchInterval:3e4});return!t?.connected}function tTe({printer:e,plug:t,onPowerOn:n,isPowering:r}){let i=eTe(e.id),{data:a}=K({queryKey:[`smartPlugStatus`,t.id],queryFn:()=>Z.getSmartPlugStatus(t.id),refetchInterval:1e4});return i?(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`span`,{className:`text-sm text-gray-900 dark:text-white truncate`,children:e.name}),a&&(0,G.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded ${a.state===`ON`?`bg-bambu-green/20 text-bambu-green`:`bg-red-500/20 text-red-400`}`,children:a.state||`?`})]}),(0,G.jsxs)(`button`,{onClick:()=>n(t.id),disabled:r||a?.state===`ON`,className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${a?.state===`ON`?`bg-bambu-green/20 text-bambu-green cursor-default`:`bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white`}`,children:[(0,G.jsx)(_l,{className:`w-3 h-3`}),r?`...`:`On`]})]}):null}function nTe(){let{t:e}=et(),[t,n]=(0,y.useState)(!1),[r,i]=(0,y.useState)(()=>localStorage.getItem(`hideDisconnectedPrinters`)===`true`),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(()=>localStorage.getItem(`printerSortBy`)||`name`),[d,f]=(0,y.useState)(()=>localStorage.getItem(`printerSortAsc`)!==`false`),[p,m]=(0,y.useState)(()=>{let e=localStorage.getItem(`printerCardSize`);return e?parseInt(e,10):2}),h=p===1?`compact`:`expanded`,[g,_]=(0,y.useState)(``),[v,b]=(0,y.useState)(`all`),[x,S]=(0,y.useState)(`all`),[C,w]=(0,y.useState)(0),[T,E]=(0,y.useState)(()=>{try{let e=localStorage.getItem(`printerCollapsedSections`);return e?JSON.parse(e):{}}catch{return{}}}),D=$a(),{showToast:O}=gd(),{hasPermission:k}=nd(),[A,j]=(0,y.useState)(()=>{let e=localStorage.getItem(`openEmbeddedCameras`);if(e)try{let t=JSON.parse(e);return new Map(t.map(e=>[e.id,e]))}catch{return new Map}return new Map});(0,y.useEffect)(()=>{let e=Array.from(A.values());e.length>0?localStorage.setItem(`openEmbeddedCameras`,JSON.stringify(e)):localStorage.removeItem(`openEmbeddedCameras`)},[A]);let{data:M,isLoading:N}=K({queryKey:[`printers`],queryFn:Z.getPrinters}),{data:P}=K({queryKey:[`ui-preferences`],queryFn:Z.getUiPreferences}),F=(0,y.useMemo)(()=>{if(P?.drying_presets)try{let e=JSON.parse(P.drying_presets);if(typeof e==`object`&&e&&Object.keys(e).length>0)return{...dJ,...e}}catch{}return dJ},[P?.drying_presets]);(0,y.useEffect)(()=>{P?.camera_view_mode===`window`&&A.size>0&&j(new Map)},[P?.camera_view_mode,A.size]);let{data:I}=K({queryKey:[`smart-plugs`],queryFn:Z.getSmartPlugs}),{data:L}=K({queryKey:[`maintenanceOverview`],queryFn:Z.getMaintenanceOverview,staleTime:60*1e3}),{data:R}=K({queryKey:[`spoolman-status`],queryFn:Z.getSpoolmanStatus,staleTime:60*1e3}),z=R?.enabled&&R?.connected,{data:B}=K({queryKey:[`spoolman-settings`],queryFn:Z.getSpoolmanSettings,enabled:!!z,staleTime:60*1e3}),ee=B?.spoolman_sync_mode,{data:V}=K({queryKey:[`unlinked-spools`],queryFn:Z.getUnlinkedSpools,enabled:!!z,staleTime:30*1e3}),te=V&&V.length>0,{data:ne}=K({queryKey:[`linked-spools`],queryFn:Z.getLinkedSpools,enabled:!!z,staleTime:30*1e3}),re=ne?.linked,{data:ie}=K({queryKey:[`spool-assignments`],queryFn:()=>Z.getAssignments(),enabled:k(`inventory:view_assignments`),staleTime:30*1e3}),H=q({mutationFn:({printerId:e,amsId:t,trayId:n})=>Z.unassignSpool(e,t,n),onSuccess:()=>{D.invalidateQueries({queryKey:[`spool-assignments`]})}}),{data:ae,isLoading:oe}=K({queryKey:[`spoolman-inventory-spools`],queryFn:()=>Z.getSpoolmanInventorySpools(!1),enabled:!!z,staleTime:30*1e3}),{data:U,isLoading:se}=K({queryKey:[`spoolman-slot-assignments`],queryFn:()=>Z.getSpoolmanSlotAssignments(),enabled:!!z,staleTime:30*1e3}),ce=q({mutationFn:e=>Z.unassignSpoolmanSlot(e),onSuccess:()=>{D.invalidateQueries({queryKey:[`spoolman-inventory-spools`]}),D.invalidateQueries({queryKey:[`spoolman-slot-assignments`]})}}),le=(e,t,n)=>ie?.find(r=>r.printer_id===e&&r.ams_id===Number(t)&&r.tray_id===Number(n)),ue=L?.reduce((e,t)=>(e[t.printer_id]={due_count:t.due_count,warning_count:t.warning_count,total_print_hours:t.total_print_hours},e),{})||{},de=I?.reduce((e,t)=>(t.printer_id&&(e[t.printer_id]=t),e),{})||{},fe=q({mutationFn:Z.createPrinter,onSuccess:()=>{D.invalidateQueries({queryKey:[`printers`]}),D.invalidateQueries({queryKey:[`maintenanceOverview`]}),n(!1)},onError:t=>{if(t instanceof Fu&&t.code===`printer_connection_failed`){O(e(`printers.toast.connectionFailedNotAdded`),`error`);return}O(t.message||e(`printers.toast.failedToAdd`),`error`)}}),pe=q({mutationFn:e=>Z.controlSmartPlug(e,`on`),onSuccess:()=>{D.invalidateQueries({queryKey:[`smart-plugs`]}),c(null)},onError:()=>{c(null)}}),[me,he]=(0,y.useState)(new Set),[ge,_e]=(0,y.useState)(!1),[ve,ye]=(0,y.useState)(null),[be,xe]=(0,y.useState)(!1),Se=ge||me.size>0,Ce=(0,y.useCallback)(e=>{he(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),we=(0,y.useCallback)(()=>{he(new Set),_e(!1)},[]);(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&Se&&we()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Se,we]);let Te=(0,y.useCallback)(async t=>{xe(!0);let n=Array.from(me).filter(e=>{let n=D.getQueryData([`printerStatus`,e]);if(!n?.connected)return!1;switch(t){case`stop`:return n.state===`RUNNING`||n.state===`PAUSE`;case`pause`:return n.state===`RUNNING`;case`resume`:return n.state===`PAUSE`;case`clearPlate`:return!!n.awaiting_plate_clear;case`clearHMS`:return n.hms_errors&&Rf(n.hms_errors).length>0;default:return!1}});if(n.length===0){O(e(`printers.bulk.noneApplicable`),`error`),xe(!1),ye(null);return}let r={stop:Z.stopPrint,pause:Z.pausePrint,resume:Z.resumePrint,clearPlate:Z.clearPlate,clearHMS:Z.clearHMSErrors}[t],i=await Promise.allSettled(n.map(e=>r(e))),a=i.filter(e=>e.status===`fulfilled`).length,o=i.filter(e=>e.status===`rejected`).length;o===0?O(e(`printers.bulk.success`,{action:e(`printers.bulk.actions.${t}`),count:a})):O(e(`printers.bulk.partial`,{succeeded:a,failed:o}),`error`),n.forEach(e=>{D.invalidateQueries({queryKey:[`printerStatus`,e]})}),xe(!1),ye(null)},[me,D,O,e]),Ee=(0,y.useCallback)(e=>{e===`stop`||e===`pause`||e===`clearPlate`?ye(e):Te(e)},[Te]),De=()=>{let e=!r;i(e),localStorage.setItem(`hideDisconnectedPrinters`,String(e))},Oe=e=>{u(e),localStorage.setItem(`printerSortBy`,e)},ke=()=>{let e=!d;f(e),localStorage.setItem(`printerSortAsc`,String(e))},Ae=()=>{switch(p){case 1:return`grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5`;case 2:return`grid-cols-1 md:grid-cols-2 xl:grid-cols-3`;case 3:return`grid-cols-1 lg:grid-cols-2`;case 4:return`grid-cols-1`;default:return`grid-cols-1 md:grid-cols-2 xl:grid-cols-3`}},je=[`S`,`M`,`L`,`XL`];(0,y.useEffect)(()=>D.getQueryCache().subscribe(e=>{e.type===`updated`&&Array.isArray(e.query.queryKey)&&e.query.queryKey[0]===`printerStatus`&&w(e=>e+1)}),[D]);let Me=(0,y.useMemo)(()=>{if(!M)return[];let e=M;if(g.trim()){let t=g.trim().toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||(e.model||``).toLowerCase().includes(t)||(e.location||``).toLowerCase().includes(t)||(e.serial_number||``).toLowerCase().includes(t))}return x!==`all`&&(e=e.filter(e=>(e.location||``)===x)),v!==`all`&&(e=e.filter(e=>{let t=D.getQueryData([`printerStatus`,e.id]);if(!t?.connected)return v===`offline`;let n=t.hms_errors?Rf(t.hms_errors):[];switch(v){case`printing`:return t.state===`RUNNING`;case`paused`:return t.state===`PAUSE`;case`finished`:return t.state===`FINISH`;case`error`:return t.state===`FAILED`||n.length>0;case`idle`:return t.state!==`RUNNING`&&t.state!==`PAUSE`&&t.state!==`FINISH`&&t.state!==`FAILED`&&n.length===0;case`offline`:return!1;default:return!0}})),e},[M,g,v,x,D,C]),Ne=(0,y.useMemo)(()=>M?[...new Set(M.map(e=>e.location||``).filter(Boolean))].sort():[],[M]),Pe=(0,y.useMemo)(()=>{let e=[...Me];switch(l){case`name`:e.sort((e,t)=>e.name.localeCompare(t.name));break;case`model`:e.sort((e,t)=>(e.model||``).localeCompare(t.model||``));break;case`location`:e.sort((e,t)=>{let n=e.location||``,r=t.location||``;return!n&&r?1:n&&!r?-1:n.localeCompare(r)||e.name.localeCompare(t.name)});break;case`status`:e.sort((e,t)=>{let n=D.getQueryData([`printerStatus`,e.id]),r=D.getQueryData([`printerStatus`,t.id]),i=e=>e?.connected?(e.hms_errors?Rf(e.hms_errors):[]).length>0?0:e.state===`RUNNING`?1:2:3;return i(n)-i(r)});break}return d||e.reverse(),e},[Me,l,d,D]),Fe=(0,y.useCallback)(()=>{he(new Set(Pe.map(e=>e.id))),_e(!0)},[Pe]),Ie=(0,y.useCallback)(e=>{he(t=>{let n=new Set(t);return Pe.forEach(t=>{sJ(D.getQueryData([`printerStatus`,t.id]))===e&&n.add(t.id)}),n}),_e(!0)},[Pe,D]),Le=(0,y.useCallback)(e=>{he(t=>{let n=new Set(t);return Pe.filter(t=>(t.location||``)===e).forEach(e=>n.add(e.id)),n}),_e(!0)},[Pe]),Re=(0,y.useCallback)(e=>{he(t=>{let n=new Set(t);return Pe.filter(t=>(t.model||`Unknown`)===e).forEach(e=>n.add(e.id)),n}),_e(!0)},[Pe]),ze=(0,y.useCallback)(e=>{E(t=>{let n={...t,[e]:!t[e]};try{localStorage.setItem(`printerCollapsedSections`,JSON.stringify(n))}catch{}return n})},[]),Be=(0,y.useMemo)(()=>{if(l===`name`)return null;let e={};return l===`location`?Pe.forEach(t=>{let n=t.location||`Ungrouped`;e[n]||(e[n]=[]),e[n].push(t)}):l===`model`?Pe.forEach(t=>{let n=t.model||`Unknown`;e[n]||(e[n]=[]),e[n].push(t)}):l===`status`&&Pe.forEach(t=>{let n=sJ(D.getQueryData([`printerStatus`,t.id]));e[n]||(e[n]=[]),e[n].push(t)}),e},[l,Pe,D,C]),Ve=(0,y.useRef)(null),He=(0,y.useRef)(null),Ue=(0,y.useRef)(0),[We,Ge]=(0,y.useState)(!1),Ke=(0,y.useCallback)(()=>{let e=Ve.current;if(!e)return;let t=He.current?.offsetWidth;t&&(Ue.current=t);let n=Ue.current>0&&e.clientWidthe===n?e:n)},[]),qe=Object.keys(de).length;(0,y.useLayoutEffect)(()=>{Ke();let e=Ve.current;if(!e)return;if(typeof ResizeObserver>`u`)return window.addEventListener(`resize`,Ke),()=>window.removeEventListener(`resize`,Ke);let t=new ResizeObserver(()=>Ke());return t.observe(e),window.addEventListener(`resize`,Ke),()=>{t.disconnect(),window.removeEventListener(`resize`,Ke)}},[Ke,M?.length,Ne.length,r,qe]);let Je=(t=!1)=>(0,G.jsxs)(G.Fragment,{children:[M&&M.length>0&&(0,G.jsx)(iJ,{value:v,onChange:b,fullWidth:t,options:[{value:`all`,label:e(`printers.filter.allStatuses`)},{value:`printing`,label:e(`printers.status.printing`)},{value:`paused`,label:e(`printers.status.paused`)},{value:`idle`,label:e(`printers.status.idle`)},{value:`finished`,label:e(`printers.status.finished`)},{value:`error`,label:e(`printers.status.error`)},{value:`offline`,label:e(`printers.status.offline`)}]}),M&&M.length>0&&Ne.length>0&&(0,G.jsx)(iJ,{value:x,onChange:S,fullWidth:t,options:[{value:`all`,label:e(`printers.filter.allLocations`)},...Ne.map(e=>({value:e,label:e}))]}),(0,G.jsx)(`button`,{type:`button`,onClick:De,"aria-pressed":r,className:`h-8 px-2 rounded-lg border text-sm font-medium transition-colors ${t?`w-full`:``} ${r?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary`}`,children:e(`printers.hideOffline`)})]}),Ye=(t=!1)=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1 ${t?`w-full`:``}`,children:[(0,G.jsx)(iJ,{value:l,onChange:Oe,fullWidth:t,options:[{value:`name`,label:e(`printers.sort.name`)},{value:`status`,label:e(`printers.sort.status`)},{value:`model`,label:e(`printers.sort.model`)},{value:`location`,label:e(`printers.sort.location`)}]}),(0,G.jsx)(`button`,{onClick:ke,className:`h-8 shrink-0 px-2 rounded-lg border bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center justify-center`,title:e(d?`printers.sort.descending`:`printers.sort.ascending`),children:d?(0,G.jsx)(No,{className:`w-4 h-4 text-white`}):(0,G.jsx)(Do,{className:`w-4 h-4 text-white`})})]}),(0,G.jsx)(`div`,{className:`flex h-8 items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary ${t?`w-full`:``}`,children:je.map((n,r)=>{let i=r+1,a=p===i;return(0,G.jsx)(`button`,{onClick:()=>{m(i),localStorage.setItem(`printerCardSize`,String(i))},className:`h-full px-2 text-xs font-medium transition-colors ${t?`flex-1`:``} ${r===0?`rounded-l-lg`:``} ${r===je.length-1?`rounded-r-lg`:``} ${a?`bg-bambu-green text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,title:e(n===`S`?`printers.cardSize.small`:n===`M`?`printers.cardSize.medium`:n===`L`?`printers.cardSize.large`:`printers.cardSize.extraLarge`),children:n},n)})})]}),Xe=(t=!1)=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{onClick:()=>{Se?we():_e(!0)},className:`h-8 px-2 rounded-lg border transition-colors ${t?`w-full justify-center gap-1.5 text-sm font-medium flex items-center`:``} ${Se?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary`}`,title:e(`printers.bulk.select`),disabled:!k(`printers:control`),children:[(0,G.jsx)(Xl,{className:`w-4 h-4`}),t&&(0,G.jsx)(`span`,{children:e(`printers.bulk.select`)})]}),r&&Object.keys(de).length>0&&(0,G.jsxs)(`div`,{className:`relative ${t?`w-full`:``}`,children:[(0,G.jsxs)(`button`,{onClick:()=>o(!a),className:`h-8 flex items-center gap-1.5 px-2 text-sm rounded-lg border transition-colors ${t?`w-full justify-between bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary hover:text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary`}`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(_l,{className:`w-4 h-4`}),e(`printers.powerOn`)]}),(0,G.jsx)(es,{className:`w-3 h-3 transition-transform ${a?`rotate-180`:``}`})]}),a&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>o(!1)}),(0,G.jsxs)(`div`,{className:`absolute right-0 mt-2 w-56 bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1`,children:[(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary`,children:e(`printers.offlinePrintersWithPlugs`)}),M?.filter(e=>de[e.id]).map(e=>(0,G.jsx)(tTe,{printer:e,plug:de[e.id],onPowerOn:e=>{c(e),pe.mutate(e)},isPowering:s===de[e.id]?.id},e.id)),M?.filter(e=>de[e.id]).length===0&&(0,G.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:`No printers with smart plugs`})]})]})]}),(0,G.jsxs)(Q,{onClick:()=>n(!0),disabled:!k(`printers:create`),title:k(`printers:create`)?void 0:e(`printers.permission.noAdd`),className:`!h-8 !min-h-8 px-2 py-0 ${t?`w-full`:``}`,children:[(0,G.jsx)(hl,{className:`w-4 h-4`}),e(`printers.addPrinter`)]})]});return(0,G.jsxs)(`div`,{className:`p-4 md:p-8`,children:[(0,G.jsxs)(`div`,{className:`space-y-3 mb-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,G.jsx)(vl,{className:`w-7 h-7 text-bambu-green`}),e(`printers.title`)]}),(0,G.jsx)(Ywe,{printers:M})]}),(0,G.jsxs)(`div`,{ref:Ve,className:`relative flex items-center gap-2`,children:[M&&M.length>0&&(0,G.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,G.jsx)(Al,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50`}),(0,G.jsx)(`input`,{type:`search`,name:`printer-search`,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,value:g,onChange:e=>_(e.target.value),placeholder:e(`printers.search`),"aria-label":e(`printers.search`),className:`w-full h-8 pl-9 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`}),g&&(0,G.jsx)(`button`,{type:`button`,"aria-label":e(`common.clear`),onClick:()=>_(``),className:`absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:(0,G.jsx)(Au,{className:`w-4 h-4`})})]}),(0,G.jsxs)(`div`,{ref:He,"aria-hidden":We,inert:We,className:`${We?`absolute -left-[9999px] top-0 flex w-max pointer-events-none opacity-0`:`flex`} ml-auto items-center justify-end gap-2 flex-nowrap [&>*]:shrink-0`,children:[(0,G.jsx)(`div`,{className:`h-6 w-px bg-bambu-dark-tertiary`}),(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:Je()}),(0,G.jsx)(`div`,{className:`h-6 w-px bg-bambu-dark-tertiary`}),(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:Ye()}),(0,G.jsx)(`div`,{className:`h-6 w-px bg-bambu-dark-tertiary`}),(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:Xe()})]}),We&&(0,G.jsxs)(`div`,{className:`ml-auto flex items-center justify-end gap-1`,children:[(0,G.jsx)(aJ,{label:e(`printers.toolbar.filters`,`Filters`),icon:(0,G.jsx)(lc,{className:`w-4 h-4`}),children:(0,G.jsx)(`div`,{className:`flex w-48 flex-col gap-2`,children:Je(!0)})}),(0,G.jsx)(aJ,{label:e(`printers.toolbar.view`,`View`),icon:(0,G.jsx)(Wl,{className:`w-4 h-4`}),children:(0,G.jsx)(`div`,{className:`flex w-48 flex-col gap-2`,children:Ye(!0)})}),(0,G.jsx)(aJ,{label:e(`printers.toolbar.actions`,`Actions`),icon:(0,G.jsx)(Bs,{className:`w-4 h-4`}),children:(0,G.jsx)(`div`,{className:`flex w-48 flex-col gap-2`,children:Xe(!0)})})]})]})]}),N?(0,G.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:e(`common.loading`)}):M?.length===0?(0,G.jsx)(cd,{children:(0,G.jsxs)(ud,{className:`text-center py-12`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:e(`printers.noPrintersConfigured`)}),(0,G.jsxs)(Q,{onClick:()=>n(!0),disabled:!k(`printers:create`),title:k(`printers:create`)?void 0:e(`printers.permission.noAdd`),children:[(0,G.jsx)(hl,{className:`w-4 h-4`}),e(`printers.addPrinter`)]})]})}):Pe.length===0&&(g.trim()||v!==`all`||x!==`all`)?(0,G.jsx)(cd,{children:(0,G.jsx)(ud,{className:`text-center py-12`,children:(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`printers.noSearchResults`)})})}):Be?(0,G.jsx)(`div`,{className:`space-y-6`,children:(()=>{let e=l===`status`?Xwe.filter(e=>Be[e]?.length>0):Object.keys(Be);return d?e:[...e].reverse()})().map(t=>{let n=Be[t],i=`${l}:${t}`,a=!T[i],o=l===`status`&&oJ[t]?.dot||`bg-bambu-green`,s=l===`status`?e(oJ[t]?.labelKey||t):t;return(0,G.jsx)(vf,{open:a,onToggle:()=>ze(i),summaryClassName:`py-1`,summary:(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full ${o}`}),s,(0,G.jsxs)(`span`,{className:`text-sm font-normal text-bambu-gray`,children:[`(`,n.length,`)`]}),Se&&(0,G.jsx)(`button`,{onClick:e=>{e.stopPropagation(),l===`location`?Le(t===`Ungrouped`?``:t):l===`status`?Ie(t):l===`model`&&Re(t)},className:`text-xs text-bambu-green hover:text-bambu-green-light transition-colors ml-1`,children:e(`printers.bulk.selectAll`)})]}),children:(0,G.jsx)(`div`,{className:`grid gap-4 ${p>=3?`gap-6`:``} ${Ae()}`,children:n.map(e=>(0,G.jsx)(fJ,{printer:e,hideIfDisconnected:r,maintenanceInfo:ue[e.id],viewMode:h,cardSize:p,amsThresholds:P?{humidityGood:Number(P.ams_humidity_good)||40,humidityFair:Number(P.ams_humidity_fair)||60,tempGood:Number(P.ams_temp_good)||28,tempFair:Number(P.ams_temp_fair)||35}:void 0,spoolmanEnabled:z,hasUnlinkedSpools:te,linkedSpools:re,spoolmanUrl:R?.url,spoolmanSyncMode:ee,onGetAssignment:le,onUnassignSpool:(e,t,n)=>H.mutate({printerId:e,amsId:t,trayId:n}),spoolmanSpools:ae,spoolmanSlotAssignments:U,spoolmanLoading:oe||se,onUnassignSpoolmanSpool:e=>ce.mutate(e),timeFormat:P?.time_format||`system`,cameraViewMode:P?.camera_view_mode||`window`,onOpenEmbeddedCamera:(e,t)=>j(n=>new Map(n).set(e,{id:e,name:t})),checkPrinterFirmware:P?.check_printer_firmware!==!1,dryingPresets:F,requirePlateClear:P?.require_plate_clear===!0,selectionMode:Se,isSelected:me.has(e.id),onToggleSelect:Ce},e.id))})},t)})}):(0,G.jsx)(`div`,{className:`grid gap-4 ${p>=3?`gap-6`:``} ${Ae()}`,children:Pe.map(e=>(0,G.jsx)(fJ,{printer:e,hideIfDisconnected:r,maintenanceInfo:ue[e.id],viewMode:h,cardSize:p,spoolmanEnabled:z,hasUnlinkedSpools:te,linkedSpools:re,spoolmanUrl:R?.url,spoolmanSyncMode:ee,onGetAssignment:le,onUnassignSpool:(e,t,n)=>H.mutate({printerId:e,amsId:t,trayId:n}),spoolmanSpools:ae,spoolmanSlotAssignments:U,spoolmanLoading:oe||se,onUnassignSpoolmanSpool:e=>ce.mutate(e),amsThresholds:P?{humidityGood:Number(P.ams_humidity_good)||40,humidityFair:Number(P.ams_humidity_fair)||60,tempGood:Number(P.ams_temp_good)||28,tempFair:Number(P.ams_temp_fair)||35}:void 0,timeFormat:P?.time_format||`system`,cameraViewMode:P?.camera_view_mode||`window`,onOpenEmbeddedCamera:(e,t)=>j(n=>new Map(n).set(e,{id:e,name:t})),checkPrinterFirmware:P?.check_printer_firmware!==!1,dryingPresets:F,requirePlateClear:P?.require_plate_clear===!0,selectionMode:Se,isSelected:me.has(e.id),onToggleSelect:Ce},e.id))}),t&&(0,G.jsx)(Zwe,{onClose:()=>n(!1),onAdd:e=>fe.mutate(e),existingSerials:M?.map(e=>e.serial_number)||[]}),Se&&M&&(0,G.jsx)(Hf,{selectedIds:me,printers:M,onClose:we,onSelectAll:Fe,onSelectByLocation:Le,onSelectByState:Ie,onAction:Ee,actionPending:be}),ve===`stop`&&(0,G.jsx)(xd,{title:e(`printers.bulk.confirm.stopTitle`,{count:me.size}),message:e(`printers.bulk.confirm.stopMessage`,{count:me.size}),confirmText:e(`printers.bulk.confirm.stopButton`),variant:`danger`,isLoading:be,onConfirm:()=>Te(`stop`),onCancel:()=>ye(null)}),ve===`pause`&&(0,G.jsx)(xd,{title:e(`printers.bulk.confirm.pauseTitle`,{count:me.size}),message:e(`printers.bulk.confirm.pauseMessage`,{count:me.size}),confirmText:e(`printers.bulk.confirm.pauseButton`),isLoading:be,onConfirm:()=>Te(`pause`),onCancel:()=>ye(null)}),ve===`clearPlate`&&(0,G.jsx)(xd,{title:e(`printers.bulk.confirm.clearPlateTitle`,{count:me.size}),message:e(`printers.bulk.confirm.clearPlateMessage`,{count:me.size}),confirmText:e(`printers.bulk.confirm.clearPlateButton`),isLoading:be,onConfirm:()=>Te(`clearPlate`),onCancel:()=>ye(null)}),Array.from(A.values()).map((e,t)=>(0,G.jsx)(Vse,{printerId:e.id,printerName:e.name,viewerIndex:t,onClose:()=>j(t=>{let n=new Map(t);return n.delete(e.id),n})},e.id))]})}function rTe({title:e,message:t,subtitle:n,closeText:r,variant:i=`error`,onClose:a}){let{t:o}=et(),s=r??o(`common.close`);return(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&a()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-[120]`,onClick:a,children:(0,G.jsx)(cd,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:(0,G.jsxs)(ud,{className:`p-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,G.jsx)(`div`,{className:`p-2 rounded-full bg-bambu-dark ${i===`warning`?`text-yellow-400`:`text-red-400`}`,children:(0,G.jsx)(hu,{className:`w-6 h-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-1`,children:e}),n&&(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2 truncate`,children:n}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-sm whitespace-pre-line break-words`,children:t})]})]}),(0,G.jsx)(`div`,{className:`flex mt-6`,children:(0,G.jsx)(Q,{onClick:a,className:`flex-1`,children:s})})]})})})}var pJ=(0,y.createContext)(null),iTe=1500,aTe=1e3,mJ=e=>`slice-job-${e}`;function hJ(e){try{return decodeURIComponent(e)}catch{return e}}function oTe(e){let t=Math.max(0,Math.floor(e));if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}function sTe({children:e}){let{t}=et(),{showToast:n,showPersistentToast:r,dismissToast:i}=gd(),a=$a(),[o,s]=(0,y.useState)([]),[c,l]=(0,y.useState)(null),u=(0,y.useRef)([]);u.current=o;let d=(0,y.useRef)(new Map),f=(0,y.useRef)(new Map),p=(0,y.useRef)(new Map),m=(0,y.useCallback)(e=>{let n=d.current.get(e.id);if(n==null)return;let i=(Date.now()-n)/1e3,a=f.current.get(e.id)??`pending`,o=oTe(i),s=p.current.get(e.id)??null,c=s&&s.stage&&s.total_percent>0;if(a===`running`&&c){let n=hJ(e.sourceName),i=s.stage,a=Math.min(100,Math.max(0,Math.round(s.total_percent))),c=typeof s.multi_plate_index==`number`&&typeof s.multi_plate_count==`number`&&s.multi_plate_count>1?t(`slice.runningWithProgressMultiPlate`,`Plate {{plateIndex}} of {{plateCount}} • {{name}} — {{stage}} ({{percent}}%) — {{elapsed}}`,{plateIndex:s.multi_plate_index,plateCount:s.multi_plate_count,name:n,stage:i,percent:a,elapsed:o}):t(`slice.runningWithProgress`,`{{name}} — {{stage}} ({{percent}}%) — {{elapsed}}`,{name:n,stage:i,percent:a,elapsed:o});r(mJ(e.id),c,`loading`);return}let l=a===`pending`?`slice.queuedToast`:`slice.runningToast`,u=a===`pending`?`Queued: {{name}} — {{elapsed}}`:`Slicing {{name}} — {{elapsed}}`;r(mJ(e.id),t(l,u,{name:hJ(e.sourceName),elapsed:o}),`loading`)},[r,t]),h=(0,y.useCallback)((e,t,n)=>{s(r=>r.some(t=>t.id===e)?r:[...r,{id:e,kind:t,sourceName:n}]),d.current.set(e,Date.now()),f.current.set(e,`pending`),p.current.set(e,null),m({id:e,kind:t,sourceName:n})},[m]),g=(0,y.useCallback)((e,r)=>{s(t=>t.filter(t=>t.id!==e.id)),d.current.delete(e.id),f.current.delete(e.id),p.current.delete(e.id),i(mJ(e.id)),r.status===`completed`?n(t(`slice.completedToast`,`Sliced {{name}}`,{name:hJ(e.sourceName)}),`success`):r.status===`failed`&&l({name:hJ(e.sourceName),detail:r.error_detail||t(`slice.failed`)}),a.invalidateQueries({queryKey:[`library-files`]}),a.invalidateQueries({queryKey:[`archives`]})},[i,a,n,t]);return(0,y.useEffect)(()=>{if(o.length===0)return;let e=!1,t=setInterval(async()=>{if(e)return;let t=[...u.current];for(let e of t)try{let t=await Z.getSliceJob(e.id);f.current.set(e.id,t.status),t.progress&&p.current.set(e.id,t.progress),(t.status===`completed`||t.status===`failed`)&&g(e,t)}catch{}},iTe);return()=>{e=!0,clearInterval(t)}},[o.length,g]),(0,y.useEffect)(()=>{if(o.length===0)return;let e=setInterval(()=>{for(let e of u.current)m(e)},aTe);return()=>clearInterval(e)},[o.length,m]),(0,G.jsxs)(pJ.Provider,{value:{trackJob:h,activeJobs:o},children:[e,c&&(0,G.jsx)(rTe,{title:t(`slice.failedTitle`),subtitle:c.name,message:c.detail,onClose:()=>l(null)})]})}function cTe(){let e=(0,y.useContext)(pJ);if(!e)throw Error(`useSliceJobTracker must be used inside SliceJobTrackerProvider`);return e}function gJ({plates:e,onSelect:t,onClose:n}){let{t:r}=et();return(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:n,children:(0,G.jsxs)(`div`,{className:`w-full max-w-3xl max-h-[85vh] flex flex-col rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary/60`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`flex-shrink-0 flex items-start justify-between gap-3 px-4 pt-4 pb-3 border-b border-bambu-dark-tertiary/40`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h3`,{className:`text-white font-medium`,children:r(`archives.platePicker.title`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:r(`archives.platePicker.hint`)})]}),(0,G.jsx)(`button`,{onClick:n,className:`flex-shrink-0 text-bambu-gray hover:text-white transition-colors`,"aria-label":r(`common.close`,`Close`),children:(0,G.jsx)(Au,{className:`w-5 h-5`})})]}),(0,G.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:(0,G.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(e.index),className:`flex items-center gap-2 p-2 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray transition-colors text-left`,children:[e.has_thumbnail&&e.thumbnail_url!=null?(0,G.jsx)(`img`,{src:Hu(e.thumbnail_url),alt:`Plate ${e.index}`,className:`w-12 h-12 rounded object-cover bg-bambu-dark-tertiary flex-shrink-0`}):(0,G.jsx)(`div`,{className:`w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center flex-shrink-0`,children:(0,G.jsx)(Nc,{className:`w-5 h-5 text-bambu-gray`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white font-medium truncate`,children:e.name?`${r(`archives.platePicker.plateLabel`,{index:e.index})} — ${e.name}`:r(`archives.platePicker.plateLabel`,{index:e.index})}),(0,G.jsxs)(`p`,{className:`text-xs text-bambu-gray truncate`,children:[e.objects.length>0?e.objects.slice(0,3).join(`, `)+(e.objects.length>3?`…`:``):e.object_count!=null&&e.object_count>0?r(`archives.platePicker.objectCount`,{count:e.object_count}):`${e.filaments.length} filament${e.filaments.length===1?``:`s`}`,e.print_time_seconds==null?``:` • ${af(e.print_time_seconds)}`]})]})]},e.index))})})]})})}var _J=[`local`,`orca_cloud`,`cloud`,`standard`];function vJ(e,t){for(let n of _J){let r=e[n][t];if(r.length>0)return{source:r[0].source,id:r[0].id}}return null}function yJ(e,t,n){return t?e[t.source][n].find(e=>e.id===t.id)??null:null}function bJ(e,t,n){if(!n)return null;for(let r of _J){let i=e[r][t].find(e=>e.name===n);if(i)return{source:i.source,id:i.id}}return null}function lTe(e,t,n,r){let i=bJ(e,`process`,r);if(i){let r=yJ(e,i,`process`);if(r&&GK(r,`process`,t,n)!==`mismatch`)return i}for(let r of[`match`,`unknown`])for(let i of _J)for(let a of e[i].process)if(GK(a,`process`,t,n)===r)return{source:a.source,id:a.id};return vJ(e,`process`)}var uTe={local:1.75,orca_cloud:1.5,cloud:1,standard:.5};function dTe(e,t,n,r){let i=t.type.trim().toUpperCase(),a=vq(t.color),o=null;for(let s of _J)for(let c of e[s].filament){let e=0,l=(c.filament_type??``).trim().toUpperCase(),u=vq(c.filament_colour??``);i&&l&&i===l&&(e+=10),a&&u&&(u===a?e+=5:Sq(c.filament_colour??``,t.color)&&(e+=2)),e+=uTe[s],GK(c,`filament`,n,r)===`mismatch`&&(e-=100),(o==null||e>o.score)&&(o={ref:{source:c.source,id:c.id},score:e})}return o==null?vJ(e,`filament`):o.ref}function fTe(e){return e?`${e.source}:${e.id}`:``}function pTe(e){if(!e)return null;let t=e.indexOf(`:`);if(t<0)return null;let n=e.slice(0,t),r=e.slice(t+1);return n!==`orca_cloud`&&n!==`cloud`&&n!==`local`&&n!==`standard`?null:{source:n,id:r}}function mTe({requestId:e,sourceName:t}){let{t:n}=et(),{showPersistentToast:r,dismissToast:i}=gd(),[a,o]=(0,y.useState)(0),[s,c]=(0,y.useState)(null),l=t;try{l=decodeURIComponent(t)}catch{}(0,y.useEffect)(()=>{let e=Date.now(),t=setInterval(()=>o(Math.floor((Date.now()-e)/1e3)),1e3);return()=>clearInterval(t)},[]),(0,y.useEffect)(()=>{let t=!1,n=setInterval(async()=>{if(t)return;let n=await Z.getPreviewSliceProgress(e);!t&&n&&c(n)},1e3);return()=>{t=!0,clearInterval(n)}},[e]);let u=`slice-preview-${e}`;(0,y.useEffect)(()=>{let e=s&&s.stage&&s.total_percent>0,t=hTe(a);return e?r(u,n(`slice.previewWithProgress`,`Analyzing {{name}} — {{stage}} ({{percent}}%) — {{elapsed}}`,{name:l,stage:s.stage,percent:Math.min(100,Math.max(0,Math.round(s.total_percent))),elapsed:t}),`loading`):r(u,n(`slice.previewToast`,{name:l,elapsed:t}),`loading`),()=>{i(u)}},[a,s,l,r,i,n,u]);let d=s?.stage,f=s?.total_percent,p=d&&typeof f==`number`&&f>0?`${d} (${Math.min(100,Math.max(0,Math.round(f)))}%)`:n(`slice.analyzingPlateFilaments`);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1 text-bambu-gray text-sm py-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),p,(0,G.jsxs)(`span`,{className:`text-xs tabular-nums`,children:[a,`s`]})]}),a>=5&&(0,G.jsx)(`div`,{className:`text-xs text-bambu-gray/70 pl-6`,children:n(`slice.analyzingPlateFilamentsHint`,`Running a preview slice to discover which AMS slots this plate uses. Cached after — re-opening is instant.`)})]})}function hTe(e){let t=Math.max(0,Math.floor(e));if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}function xJ({source:e,onClose:t}){let{t:n}=et(),{trackJob:r}=cTe(),i=$a(),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)([]),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(null),b=K({queryKey:[`slicePlates`,e.kind,e.id],queryFn:async()=>e.kind===`libraryFile`?Z.getLibraryFilePlates(e.id):Z.getArchivePlates(e.id),staleTime:6e4}),x=!!b.data?.is_multi_plate&&(b.data?.plates?.length??0)>1,S=x&&p==null,C=p??1,w=(0,y.useMemo)(()=>{let t=typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`;return`${e.kind}-${e.id}-p${C}-${t}`},[e.kind,e.id,C]),T=K({queryKey:[`sliceFilamentReqs`,e.kind,e.id,C],queryFn:async()=>e.kind===`libraryFile`?Z.getLibraryFileFilamentRequirements(e.id,C,w):Z.getArchiveFilamentRequirements(e.id,C,w),enabled:!S,staleTime:6e4}),E=(0,y.useMemo)(()=>{let e=T.data?.filaments??[],t=e.length>0?e:[{slot_id:1,type:``,color:``,used_grams:0,used_meters:0}];return h?t.map(e=>({...e,used_in_plate:!0})):t},[h,T.data]),D=K({queryKey:[`slicerPresets`],queryFn:()=>Z.getSlicerPresets(),staleTime:6e4,enabled:!b.isLoading&&!S}),[O,k]=(0,y.useState)(!1),A=async()=>{if(!O){k(!0);try{let e=await Z.getSlicerPresets({refresh:!0});i.setQueryData([`slicerPresets`],e)}catch{i.invalidateQueries({queryKey:[`slicerPresets`]})}finally{k(!1)}}},j=K({queryKey:[`slicerPrinterModels`],queryFn:Z.getSlicerPrinterModels,staleTime:1/0}),M=(0,y.useMemo)(()=>!D.data||!a?null:yJ(D.data,a,`printer`)?.name??null,[D.data,a]),N=(0,y.useMemo)(()=>HK(j.data??{}),[j.data]),P=b.data?.embedded_printer??null,F=b.data?.embedded_process??null;(0,y.useEffect)(()=>{let e=D.data;e&&(a??o(bJ(e,`printer`,P)??vJ(e,`printer`)))},[D.data,P]),(0,y.useEffect)(()=>{let e=D.data;e&&c(t=>{if(t){let n=yJ(e,t,`process`);if(n&&GK(n,`process`,M,N)!==`mismatch`)return t}return lTe(e,M,N,F)})},[D.data,M,N,F]),(0,y.useEffect)(()=>{let e=D.data;e&&u(t=>E.map((n,r)=>{let i=t[r]??null;if(i){let t=yJ(e,i,`filament`);if(t&&GK(t,`filament`,M,N)!==`mismatch`)return i}return dTe(e,{type:n.type,color:n.color},M,N)}))},[D.data,E,M,N]);let I=q({mutationFn:async t=>{let n=L(t);return e.kind===`libraryFile`?Z.sliceLibraryFile(e.id,n):Z.sliceArchive(e.id,n)},onSuccess:n=>{r(n.job_id,e.kind,e.filename),t()},onError:e=>{f(e instanceof Error?e.message:String(e))}});function L(e){if(!a||!s||l.length===0||l.some(e=>e==null))throw Error(n(`slice.allPresetsRequired`));return{printer_preset:a,process_preset:s,filament_preset:l[0],filament_presets:l,...e==null?{}:{plate:e},..._==null?{}:{bed_type:_}}}let R=a!=null&&s!=null&&T.isSuccess&&l.length>0&&l.every(e=>e!=null),z=I.isPending,B=b.data?.plates?.length??0,ee=x&&B>1&&!S;return S&&b.data?(0,G.jsx)(gJ,{plates:b.data.plates,onSelect:e=>m(e),onClose:t}):(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:()=>{z||t()},children:(0,G.jsxs)(`div`,{className:`w-full max-w-xl max-h-[85vh] flex flex-col rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary/60`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`flex-shrink-0 flex items-start justify-between gap-3 px-4 pt-4 pb-3 border-b border-bambu-dark-tertiary/40`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`h3`,{className:`text-white font-medium flex items-center gap-2`,children:[(0,G.jsx)(ws,{className:`w-4 h-4`}),n(`slice.title`)]}),(0,G.jsxs)(`p`,{className:`text-xs text-bambu-gray mt-1 truncate`,title:e.filename,children:[e.filename,p==null?``:` • ${n(`archives.platePicker.plateLabel`,{index:p})}`]})]}),(0,G.jsx)(`button`,{onClick:t,disabled:z,className:`flex-shrink-0 text-bambu-gray hover:text-white transition-colors disabled:opacity-50`,"aria-label":n(`common.close`),children:(0,G.jsx)(Au,{className:`w-5 h-5`})})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[(b.isLoading||D.isLoading)&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-sm`,children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),n(`slice.loadingPresets`)]}),D.isError&&(0,G.jsx)(`div`,{className:`text-sm text-red-400`,role:`alert`,children:n(`slice.presetsLoadFailed`,`Failed to load presets. Open Settings → Profiles to import them, or sign in to Bambu Cloud.`)}),D.data&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,G.jsx)(SJ,{status:D.data.cloud_status,cloudName:`bambu`}),(0,G.jsx)(SJ,{status:D.data.orca_cloud_status,cloudName:`orca`})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:A,disabled:O||z,className:`flex-shrink-0 inline-flex items-center gap-1 px-2 py-1 rounded-md text-xs text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary/40 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:n(`slice.refreshPresetsTitle`),"aria-label":n(`slice.refreshPresets`),children:[(0,G.jsx)(xl,{className:`w-3.5 h-3.5 ${O?`animate-spin`:``}`}),n(`slice.refreshPresets`)]})]}),(0,G.jsx)(CJ,{label:n(`slice.printer`),slot:`printer`,data:D.data,value:a,onChange:o,disabled:z}),(0,G.jsx)(CJ,{label:n(`slice.process`),slot:`process`,data:D.data,value:s,onChange:c,disabled:z,selectedPrinterName:M,compatIndex:N}),(0,G.jsx)(_Te,{value:_,onChange:v,disabled:z}),T.isLoading?(0,G.jsx)(mTe,{requestId:w,sourceName:e.filename}):E.map((e,t)=>{let r=e.used_in_plate!==!1,i=E.length>1?n(`slice.filamentSlot`,{index:t+1,type:e.type}):n(`slice.filament`);return(0,G.jsx)(CJ,{label:r?i:`${i} ${n(`slice.notUsedByPlate`)}`,slot:`filament`,data:D.data,value:l[t]??null,onChange:e=>u(n=>{let r=n.length===E.length?[...n]:E.map((e,t)=>n[t]??null);return r[t]=e,r}),disabled:z||!r,swatchColor:E.length>1?e.color:void 0,selectedPrinterName:M,compatIndex:N},`filament-${t}`)})]}),d&&(0,G.jsx)(`div`,{className:`text-sm text-red-400 bg-red-900/20 border border-red-900/40 rounded p-2`,role:`alert`,children:d})]}),(0,G.jsxs)(`div`,{className:`flex-shrink-0 flex justify-end gap-2 px-4 py-3 border-t border-bambu-dark-tertiary/40`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,disabled:z,className:`px-3 py-1.5 text-sm rounded-md border border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray transition-colors disabled:opacity-50`,children:n(`common.cancel`)}),ee&&(0,G.jsxs)(`label`,{className:`flex items-center gap-2 mr-auto text-sm text-bambu-gray cursor-pointer select-none`,title:n(`slice.actionAllTitle`,{count:B}),children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked),disabled:z,className:`cursor-pointer`}),n(`slice.allPlatesToggle`,{count:B})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{f(null);let e=h?0:p;I.mutate(e)},disabled:!R||z,className:`px-3 py-1.5 text-sm rounded-md bg-bambu-green hover:bg-bambu-green/90 text-bambu-dark font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2`,children:z?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),n(`slice.enqueuing`)]}):h?n(`slice.actionAll`,{count:B}):n(`slice.action`)})]})]})})}function SJ({status:e,cloudName:t=`bambu`}){let{t:n}=et();if(e===`ok`||e===`not_authenticated`)return null;let r=t===`orca`?{expired:{key:`slice.orcaCloud.expired`,fallback:`Orca Cloud session expired — sign in again to refresh your Orca presets.`},unreachable:{key:`slice.orcaCloud.unreachable`,fallback:`Orca Cloud is unreachable right now. Other presets still work.`}}:{expired:{key:`slice.cloud.expired`,fallback:`Bambu Cloud session expired — sign in again to refresh your cloud presets.`},unreachable:{key:`slice.cloud.unreachable`,fallback:`Bambu Cloud is unreachable right now. Local and standard presets still work.`}},{tone:i,icon:a}={expired:{tone:`border-amber-700/40 bg-amber-900/20 text-amber-200`,icon:vs},unreachable:{tone:`border-bambu-dark-tertiary/40 bg-bambu-dark text-bambu-gray`,icon:vs}}[e],{key:o,fallback:s}=r[e];return(0,G.jsxs)(`div`,{className:`flex items-start gap-2 text-xs rounded-md border p-2 ${i}`,role:`status`,children:[(0,G.jsx)(a,{className:`w-4 h-4 flex-shrink-0 mt-0.5`}),(0,G.jsx)(`span`,{children:n(o,s)})]})}var gTe=[{value:`Cool Plate`,labelKey:`slice.bedType.coolPlate`,fallback:`Cool Plate`},{value:`Cool Plate (SuperTack)`,labelKey:`slice.bedType.coolPlateSuperTack`,fallback:`Cool Plate SuperTack`},{value:`Engineering Plate`,labelKey:`slice.bedType.engineering`,fallback:`Engineering Plate`},{value:`High Temp Plate`,labelKey:`slice.bedType.highTemp`,fallback:`High Temp Plate`},{value:`Textured PEI Plate`,labelKey:`slice.bedType.texturedPEI`,fallback:`Textured PEI Plate`},{value:`Smooth PEI Plate`,labelKey:`slice.bedType.smoothPEI`,fallback:`Smooth PEI Plate`}];function _Te({value:e,onChange:t,disabled:n}){let{t:r}=et();return(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`span`,{className:`block text-xs text-bambu-gray mb-1`,children:r(`slice.bedType.label`)}),(0,G.jsxs)(`select`,{value:e??``,onChange:e=>t(e.target.value===``?null:e.target.value),disabled:n,className:`w-full px-3 py-2 rounded-md bg-bambu-dark border border-bambu-dark-tertiary text-white text-sm focus:outline-none focus:border-bambu-gray disabled:opacity-50`,children:[(0,G.jsx)(`option`,{value:``,children:r(`slice.bedType.auto`)}),gTe.map(e=>(0,G.jsx)(`option`,{value:e.value,children:r(e.labelKey,e.fallback)},e.value))]})]})}function CJ({label:e,slot:t,data:n,value:r,onChange:i,disabled:a,swatchColor:o,selectedPrinterName:s,compatIndex:c}){let{t:l}=et(),{sections:u,otherEntries:d}=(0,y.useMemo)(()=>{let e=[{key:`local`,label:`slice.tier.local`,fallback:`Imported`},{key:`orca_cloud`,label:`slice.tier.orcaCloud`,fallback:`Orca Cloud`},{key:`cloud`,label:`slice.tier.cloud`,fallback:`Bambu Cloud`},{key:`standard`,label:`slice.tier.standard`,fallback:`Standard`}],r=t!==`printer`,i=[],a=[];for(let{key:o,label:u,fallback:d}of e){let e=n[o][t];if(!r){e.length>0&&i.push({tierLabel:l(u,d),entries:e});continue}let f=[];for(let n of e)GK(n,t,s??null,c??owe)===`mismatch`?a.push(n):f.push(n);f.length>0&&i.push({tierLabel:l(u,d),entries:f})}return{sections:i,otherEntries:a}},[n,t,l,s,c]),f=u.reduce((e,t)=>e+t.entries.length,0)+d.length;return(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-bambu-gray mb-1`,children:[o&&(0,G.jsx)(`span`,{className:`inline-block w-3 h-3 rounded-full border border-bambu-dark-tertiary`,style:{backgroundColor:o||`transparent`},"aria-hidden":!0}),(0,G.jsx)(`span`,{children:e})]}),(0,G.jsxs)(`select`,{value:fTe(r),onChange:e=>i(pTe(e.target.value)),disabled:a||f===0,className:`w-full px-3 py-2 rounded-md bg-bambu-dark border border-bambu-dark-tertiary text-white text-sm focus:outline-none focus:border-bambu-gray disabled:opacity-50`,children:[(0,G.jsx)(`option`,{value:``,children:l(f===0?`slice.noPresetsForSlot`:`slice.selectPreset`)}),u.map(e=>(0,G.jsx)(`optgroup`,{label:e.tierLabel,children:e.entries.map(e=>(0,G.jsx)(`option`,{value:`${e.source}:${e.id}`,children:e.name},`${e.source}:${e.id}`))},e.tierLabel)),d.length>0&&(0,G.jsx)(`optgroup`,{label:l(`slice.otherPrinters`),children:d.map(e=>(0,G.jsx)(`option`,{value:`${e.source}:${e.id}`,children:e.name},`${e.source}:${e.id}`))})]})]})}function vTe(){let e=navigator.userAgent.toLowerCase(),t=navigator.platform?.toLowerCase()||``;return e.includes(`win`)||t.includes(`win`)?`windows`:e.includes(`mac`)||t.includes(`mac`)?`macos`:e.includes(`linux`)||t.includes(`linux`)?`linux`:`unknown`}function wJ(e,t=`bambu_studio`){let n,r=encodeURIComponent(e);n=t===`orcaslicer`?`orcaslicer://open?file=${r}`:vTe()===`macos`?`bambustudioopen://${r}`:`bambustudio://open?file=${r}`;let i=document.createElement(`a`);i.href=n,i.style.display=`none`,document.body.appendChild(i),i.click(),document.body.removeChild(i)}var TJ=768;function EJ(){let[e,t]=(0,y.useState)(()=>typeof window<`u`?window.innerWidth{let e=window.matchMedia(`(max-width: ${TJ-1}px)`),n=e=>{t(e.matches)};return t(e.matches),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function yTe({onClose:e,initialFiles:t}){let{t:n}=et(),r=$a(),{showToast:i}=gd(),a=(0,y.useRef)(null),[o,s]=(0,y.useState)(()=>t?.filter(e=>e.name.endsWith(`.3mf`)).map(e=>({file:e,status:`pending`}))||[]),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(null);(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let f=q({mutationFn:e=>Z.uploadArchivesBulk(e),onSuccess:e=>{d(e),r.invalidateQueries({queryKey:[`archives`]}),r.invalidateQueries({queryKey:[`archiveStats`]}),s(t=>t.map(t=>{let n=e.results.find(e=>e.filename===t.file.name),r=e.errors.find(e=>e.filename===t.file.name);return n?{...t,status:`success`,archiveId:n.id}:r?{...t,status:`error`,error:r.error}:t})),e.failed===0?i(`${e.uploaded} file${e.uploaded===1?``:`s`} uploaded`):e.uploaded===0?i(`Failed to upload ${e.failed} file${e.failed===1?``:`s`}`,`error`):i(`${e.uploaded} uploaded, ${e.failed} failed`,`warning`)},onError:()=>{s(e=>e.map(e=>({...e,status:`error`,error:`Upload failed`}))),i(`Upload failed`,`error`)}}),p=(0,y.useCallback)(e=>{e.preventDefault(),l(!0)},[]),m=(0,y.useCallback)(e=>{e.preventDefault(),l(!1)},[]),h=(0,y.useCallback)(e=>{e.preventDefault(),l(!1);let t=Array.from(e.dataTransfer.files).filter(e=>e.name.endsWith(`.3mf`));t.length>0&&s(e=>[...e,...t.map(e=>({file:e,status:`pending`}))])},[]),g=(0,y.useCallback)(e=>{let t=Array.from(e.target.files||[]).filter(e=>e.name.endsWith(`.3mf`));t.length>0&&s(e=>[...e,...t.map(e=>({file:e,status:`pending`}))]),a.current&&(a.current.value=``)},[]),_=(0,y.useCallback)(e=>{s(t=>t.filter((t,n)=>n!==e))},[]),v=()=>{if(o.length===0)return;let e=o.filter(e=>e.status===`pending`);e.length!==0&&(s(e=>e.map(e=>e.status===`pending`?{...e,status:`uploading`}:e)),f.mutate(e.map(e=>e.file)))},b=o.filter(e=>e.status===`pending`).length,x=f.isPending;return(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,G.jsx)(cd,{className:`w-full max-w-2xl max-h-[90vh] flex flex-col`,children:(0,G.jsxs)(ud,{className:`p-0 flex flex-col h-full`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,G.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:n(`uploadModal.title`)}),(0,G.jsx)(`button`,{onClick:e,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,G.jsx)(Au,{className:`w-5 h-5`})})]}),(0,G.jsx)(`div`,{className:`p-4`,children:(0,G.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${c?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary hover:border-bambu-gray`}`,onDragOver:p,onDragLeave:m,onDrop:h,children:[(0,G.jsx)(vu,{className:`w-12 h-12 mx-auto mb-4 text-bambu-gray`}),(0,G.jsx)(`p`,{className:`text-white mb-2`,children:n(`uploadModal.dragDrop`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-sm mb-4`,children:n(`uploadModal.or`)}),(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>a.current?.click(),disabled:x,children:n(`uploadModal.browseFiles`)}),(0,G.jsx)(`input`,{ref:a,type:`file`,accept:`.3mf`,multiple:!0,className:`hidden`,onChange:g})]})}),(0,G.jsx)(`div`,{className:`px-4 pb-4`,children:(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`uploadModal.extractionInfo`)})}),o.length>0&&(0,G.jsx)(`div`,{className:`px-4 pb-4 max-h-60 overflow-y-auto`,children:(0,G.jsx)(`div`,{className:`space-y-2`,children:o.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-bambu-dark rounded-lg`,children:[(0,G.jsx)(Qs,{className:`w-5 h-5 text-bambu-gray flex-shrink-0`}),(0,G.jsx)(`span`,{className:`flex-1 text-white text-sm truncate`,children:e.file.name}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[(e.file.size/(1024*1024)).toFixed(1),` MB`]}),e.status===`pending`&&(0,G.jsx)(`button`,{onClick:()=>_(t),className:`text-bambu-gray hover:text-red-400 transition-colors`,disabled:x,children:(0,G.jsx)(Au,{className:`w-4 h-4`})}),e.status===`uploading`&&(0,G.jsx)(Y,{className:`w-4 h-4 text-bambu-green animate-spin`}),e.status===`success`&&(0,G.jsx)(ls,{className:`w-4 h-4 text-bambu-green`}),e.status===`error`&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-xs text-red-400`,children:e.error}),(0,G.jsx)(ss,{className:`w-4 h-4 text-red-400`})]})]},`${e.file.name}-${t}`))})}),u&&(0,G.jsx)(`div`,{className:`px-4 pb-4`,children:(0,G.jsx)(`div`,{className:`p-3 bg-bambu-dark rounded-lg`,children:(0,G.jsxs)(`p`,{className:`text-sm text-white`,children:[(0,G.jsx)(`span`,{className:`text-bambu-green`,children:u.uploaded}),` `,n(`uploadModal.uploaded`),u.failed>0&&(0,G.jsxs)(G.Fragment,{children:[`, `,(0,G.jsx)(`span`,{className:`text-red-400`,children:u.failed}),` `,n(`uploadModal.failed`)]})]})})}),(0,G.jsxs)(`div`,{className:`flex gap-3 p-4 border-t border-bambu-dark-tertiary`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:e,className:`flex-1`,children:n(u?`common.close`:`common.cancel`)}),!u&&(0,G.jsx)(Q,{onClick:v,disabled:b===0||x,className:`flex-1`,children:x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),n(`uploadModal.uploading`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(vu,{className:`w-4 h-4`}),n(`uploadModal.upload`),` `,b>0&&`(${b})`]})})]})]})})})}var bTe=365;function xTe({onClose:e,initialDays:t}){let{t:n}=et(),r=$a(),{showToast:i}=gd(),[a,o]=(0,y.useState)(t??bTe),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(a);(0,y.useEffect)(()=>{let e=window.setTimeout(()=>u(a),300);return()=>window.clearTimeout(e)},[a]);let d=K({queryKey:[`archive-purge-preview`,l,s],queryFn:()=>Z.previewArchivePurge(l,s),enabled:l>=1}),f=q({mutationFn:()=>Z.executeArchivePurge(a,s),onSuccess:t=>{i(n(`archivePurge.toast.success`,{count:t.deleted}),`success`),r.invalidateQueries({queryKey:[`archives`]}),r.invalidateQueries({queryKey:[`archive-stats`]}),e()},onError:e=>i(e.message||n(`archivePurge.toast.failed`),`error`)});(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&!f.isPending&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,f.isPending]);let p=d.data,m=p?.count??0,h=p?.total_bytes??0,g=m>0&&!f.isPending;return(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,G.jsxs)(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg shadow-xl max-w-lg w-full`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 flex items-center gap-2`,children:[(0,G.jsx)(fu,{className:`w-5 h-5`}),n(`archivePurge.title`)]}),(0,G.jsx)(`button`,{onClick:e,className:`text-gray-400 hover:text-gray-600 dark:hover:text-gray-200`,"aria-label":n(`common.close`),disabled:f.isPending,children:(0,G.jsx)(Au,{className:`w-5 h-5`})})]}),(0,G.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:n(`archivePurge.description`)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`archive-purge-days`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:n(`archivePurge.ageLabel`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`input`,{id:`archive-purge-days`,type:`number`,min:1,max:3650,value:a,onChange:e=>o(Math.max(1,Math.min(3650,parseInt(e.target.value||`0`,10)||0))),className:`w-24 rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-sm px-2 py-1 text-gray-900 dark:text-gray-100`}),(0,G.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:n(`archivePurge.days`)})]})]}),(0,G.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/30 p-3`,children:[(0,G.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-300 mb-2`,children:n(`archivePurge.effectsTitle`)}),(0,G.jsxs)(`ul`,{className:`text-xs text-gray-700 dark:text-gray-300 space-y-1 list-disc pl-4`,children:[(0,G.jsx)(`li`,{children:n(`archivePurge.effect1`)}),(0,G.jsx)(`li`,{children:n(`archivePurge.effect2`)}),(0,G.jsx)(`li`,{children:n(`archivePurge.effect3`)}),(0,G.jsx)(`li`,{children:n(`archivePurge.effect4`)})]})]}),(0,G.jsx)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50 p-3`,children:d.isLoading||d.isFetching?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400`,children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),` `,n(`archivePurge.previewLoading`)]}):d.isError?(0,G.jsx)(`div`,{className:`text-sm text-red-600 dark:text-red-400`,children:d.error?.message??n(`archivePurge.previewFailed`)}):(0,G.jsxs)(`div`,{className:`text-sm text-gray-900 dark:text-gray-100`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:n(`archivePurge.previewSummary`,{count:m,size:md(h)})}),p?.sample_filenames&&p.sample_filenames.length>0&&(0,G.jsxs)(`ul`,{className:`mt-2 text-xs text-gray-600 dark:text-gray-400 space-y-0.5 list-disc pl-4`,children:[p.sample_filenames.map(e=>(0,G.jsx)(`li`,{className:`truncate`,children:e},e)),m>p.sample_filenames.length&&(0,G.jsx)(`li`,{className:`list-none italic text-gray-500`,children:n(`archivePurge.andMore`,{count:m-p.sample_filenames.length})})]})]})}),(0,G.jsxs)(`label`,{className:`flex gap-2 items-start rounded border border-gray-200 dark:border-gray-700 px-3 py-2 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800/50`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),disabled:f.isPending,className:`mt-0.5 shrink-0`}),(0,G.jsxs)(`span`,{className:`text-xs text-gray-700 dark:text-gray-300`,children:[(0,G.jsx)(`span`,{className:`font-medium block mb-0.5`,children:n(`archivePurge.purgeStatsLabel`)}),(0,G.jsx)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:n(`archivePurge.purgeStatsHint`)})]})]}),(0,G.jsxs)(`div`,{className:`flex gap-2 items-start text-xs text-amber-700 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 rounded px-3 py-2`,children:[(0,G.jsx)(hu,{className:`w-4 h-4 mt-0.5 shrink-0`}),(0,G.jsx)(`span`,{children:n(`archivePurge.warning`)})]})]}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 p-4 border-t border-gray-200 dark:border-gray-700`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:e,disabled:f.isPending,children:n(`common.cancel`)}),(0,G.jsx)(Q,{variant:`danger`,disabled:!g,onClick:()=>f.mutate(),children:f.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin mr-1`}),n(`archivePurge.purging`)]}):n(`archivePurge.confirmCta`,{count:m})})]})]})})}function STe(e){if(!e||e<=0)return`—`;let t=Math.floor(e/3600),n=Math.floor(e%3600/60);return t>0?`${t}h ${n}m`:`${n}m`}function CTe(e){if(!e)return`—`;let t=$d(e);return t?t.toLocaleString():`—`}function DJ({archiveId:e}){let{t}=et(),{data:n,isLoading:r}=K({queryKey:[`archive-runs`,e],queryFn:()=>Z.getArchiveRuns(e)});if(r)return(0,G.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,G.jsx)(Y,{className:`w-5 h-5 text-bambu-gray animate-spin`})});let i=n?.items||[];return i.length===0?(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray italic py-2`,children:t(`archives.runLog.empty`)}):(0,G.jsx)(`div`,{className:`overflow-x-auto`,children:(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`text-bambu-gray border-b border-bambu-dark-tertiary`,children:[(0,G.jsx)(`th`,{className:`text-left py-1.5 pr-2 font-medium`,children:t(`archives.runLog.col.date`)}),(0,G.jsx)(`th`,{className:`text-left py-1.5 pr-2 font-medium`,children:t(`archives.runLog.col.status`)}),(0,G.jsx)(`th`,{className:`text-right py-1.5 pr-2 font-medium`,children:t(`archives.runLog.col.duration`)}),(0,G.jsx)(`th`,{className:`text-right py-1.5 pr-2 font-medium`,children:t(`archives.runLog.col.filament`)}),(0,G.jsx)(`th`,{className:`text-right py-1.5 font-medium`,children:t(`archives.runLog.col.cost`)})]})}),(0,G.jsx)(`tbody`,{children:i.map(e=>{let n=e.status===`completed`?`text-bambu-green`:e.status===`failed`?`text-red-400`:`text-bambu-gray`;return(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/40 last:border-0`,children:[(0,G.jsx)(`td`,{className:`py-1.5 pr-2 text-bambu-gray-light`,children:CTe(e.started_at||e.created_at)}),(0,G.jsxs)(`td`,{className:`py-1.5 pr-2 font-medium ${n}`,children:[t(`archives.runLog.status.${e.status}`,{defaultValue:e.status}),e.failure_reason&&(0,G.jsx)(`span`,{className:`block text-[10px] text-bambu-gray font-normal`,children:t(`editArchive.failureReasons.${e.failure_reason}`,{defaultValue:e.failure_reason})})]}),(0,G.jsx)(`td`,{className:`py-1.5 pr-2 text-right text-bambu-gray-light`,children:STe(e.duration_seconds)}),(0,G.jsx)(`td`,{className:`py-1.5 pr-2 text-right text-bambu-gray-light`,children:e.filament_used_grams==null?`—`:`${e.filament_used_grams.toFixed(1)} g`}),(0,G.jsx)(`td`,{className:`py-1.5 text-right text-bambu-gray-light`,children:e.cost==null?`—`:e.cost.toFixed(2)})]},e.id)})})]})})}var OJ=[`adhesionFailure`,`spaghettiDetached`,`layerShift`,`cloggedNozzle`,`filamentRunout`,`warping`,`stringing`,`underExtrusion`,`powerFailure`,`userCancelled`,`other`],wTe=[`completed`,`failed`,`aborted`,`printing`];function kJ({archive:e,onClose:t,existingTags:n=[]}){let{t:r}=et();(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let i=$a(),[a,o]=(0,y.useState)(e.print_name||``),[s,c]=(0,y.useState)(e.printer_id),[l,u]=(0,y.useState)(e.project_id??null),[d,f]=(0,y.useState)(e.notes||``),[p,m]=(0,y.useState)(e.tags||``),[h,g]=(0,y.useState)(()=>{let t=e.failure_reason||``;return t?OJ.includes(t)?t:OJ.find(e=>r(`editArchive.failureReasons.${e}`)===t)||``:``}),[_,v]=(0,y.useState)(e.status),[b,x]=(0,y.useState)(e.quantity??1),[S,C]=(0,y.useState)(e.photos||[]),[w,T]=(0,y.useState)(e.external_url||``),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(!1),A=(0,y.useRef)(null),j=(0,y.useRef)(null),M=(0,y.useRef)(null),{data:N}=K({queryKey:[`printers`],queryFn:Z.getPrinters}),{data:P}=K({queryKey:[`projects`],queryFn:()=>Z.getProjects(),select:e=>[...e].sort((e,t)=>e.name.localeCompare(t.name))}),{data:F}=K({queryKey:[`tags`],queryFn:Z.getTags,enabled:n.length===0}),I=n.length>0?n:F?.map(e=>e.name)||[],L=p.split(`,`).map(e=>e.trim()).filter(Boolean),R=p.includes(`,`)?p.substring(p.lastIndexOf(`,`)+1).trim().toLowerCase():p.trim().toLowerCase(),z=I.filter(e=>!L.includes(e)&&(R===``||e.toLowerCase().includes(R))),B=e=>{let t;t=R&&!I.includes(R)?p.includes(`,`)?p.substring(0,p.lastIndexOf(`,`)).split(`,`).map(e=>e.trim()).filter(Boolean):[]:L,t.includes(e)||m([...t,e].join(`, `)),M.current!==null&&clearTimeout(M.current),A.current?.focus()},ee=e=>{m(L.filter(t=>t!==e).join(`, `))},V=q({mutationFn:t=>Z.updateArchive(e.id,t),onSuccess:()=>{i.invalidateQueries({queryKey:[`archives`]}),i.invalidateQueries({queryKey:[`projects`]}),t()}}),te=async t=>{let n=t.target.files?.[0];if(n){D(!0);try{C((await Z.uploadArchivePhoto(e.id,n)).photos),i.invalidateQueries({queryKey:[`archives`]})}catch(e){console.error(`Failed to upload photo:`,e)}finally{D(!1),j.current&&(j.current.value=``)}}},ne=async t=>{try{C((await Z.deleteArchivePhoto(e.id,t)).photos||[]),i.invalidateQueries({queryKey:[`archives`]})}catch(e){console.error(`Failed to delete photo:`,e)}};return(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:t,children:(0,G.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:r(`editArchive.title`)}),(0,G.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,G.jsx)(Au,{className:`w-5 h-5`})})]}),(0,G.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n={print_name:a||void 0,printer_id:s,project_id:l,notes:d||void 0,tags:p||void 0,quantity:b,external_url:w||null};_!==e.status&&(n.status=_),_===`failed`||_===`aborted`?n.failure_reason=h||void 0:(e.status===`failed`||e.status===`aborted`)&&(n.failure_reason=null),V.mutate(n)},className:`p-6 space-y-4 overflow-y-auto flex-1`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`archives.runLog.title`)}),(0,G.jsx)(DJ,{archiveId:e.id})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.name`)}),(0,G.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,placeholder:r(`editArchive.namePlaceholder`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.printer`)}),(0,G.jsxs)(`select`,{value:s??``,onChange:e=>c(e.target.value?Number(e.target.value):null),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,G.jsx)(`option`,{value:``,children:r(`editArchive.noPrinter`)}),N?.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[(0,G.jsx)(nc,{className:`w-4 h-4 inline mr-1`}),r(`editArchive.project`)]}),(0,G.jsxs)(`select`,{value:l??``,onChange:e=>u(e.target.value?Number(e.target.value):null),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,G.jsx)(`option`,{value:``,children:r(`editArchive.noProject`)}),P?.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[(0,G.jsx)(bc,{className:`w-4 h-4 inline mr-1`}),r(`editArchive.itemsPrinted`)]}),(0,G.jsx)(`input`,{type:`number`,min:1,value:b,onChange:e=>x(Math.max(1,parseInt(e.target.value)||1)),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,placeholder:`1`}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:r(`editArchive.itemsPrintedHelp`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.notes`)}),(0,G.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),rows:3,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none resize-none`,placeholder:r(`editArchive.notesPlaceholder`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[(0,G.jsx)(Lc,{className:`w-4 h-4 inline mr-1`}),r(`editArchive.externalLink`)]}),(0,G.jsx)(`input`,{type:`url`,value:w,onChange:e=>T(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,placeholder:`https://printables.com/model/...`}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:r(`editArchive.externalLinkHelp`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.tags`)}),L.length>0&&(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-2`,children:L.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white`,children:[(0,G.jsx)(iu,{className:`w-3 h-3`}),e,(0,G.jsx)(`button`,{type:`button`,onClick:()=>ee(e),className:`ml-0.5 text-bambu-gray hover:text-white`,children:(0,G.jsx)(Au,{className:`w-3 h-3`})})]},e))}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{ref:A,type:`text`,value:p,onChange:e=>m(e.target.value),onFocus:()=>{M.current!==null&&clearTimeout(M.current),k(!0)},onBlur:()=>{M.current=window.setTimeout(()=>k(!1),200)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,placeholder:L.length>0?r(`editArchive.addMoreTags`):r(`editArchive.tagsPlaceholder`)}),O&&z.length>0&&(0,G.jsxs)(`div`,{className:`absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10 max-h-40 overflow-y-auto`,children:[(0,G.jsxs)(`div`,{className:`p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary`,children:[R?r(`editArchive.matchingTags`,{query:R}):r(`editArchive.existingTags`),` `,r(`editArchive.clickToAdd`)]}),(0,G.jsx)(`div`,{className:`p-2 flex flex-wrap gap-1.5`,children:z.map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>B(e),className:`px-2 py-0.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded text-sm text-bambu-gray hover:text-white transition-colors`,children:e},e))})]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.status`)}),(0,G.jsx)(`select`,{value:_,onChange:e=>{v(e.target.value),e.target.value===`completed`&&g(``)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:wTe.map(e=>(0,G.jsx)(`option`,{value:e,children:r(`editArchive.statuses.${e}`)},e))})]}),(_===`failed`||_===`aborted`)&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`failure-reason-select`,className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.failureReason`)}),(0,G.jsxs)(`select`,{id:`failure-reason-select`,value:h,onChange:e=>g(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,G.jsx)(`option`,{value:``,children:r(`editArchive.selectReason`)}),OJ.map(e=>(0,G.jsx)(`option`,{value:e,children:r(`editArchive.failureReasons.${e}`)},e))]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[(0,G.jsx)(Yo,{className:`w-4 h-4 inline mr-1`}),r(`editArchive.photos`)]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2 mb-2`,children:[S.map(t=>(0,G.jsxs)(`div`,{className:`relative group`,children:[(0,G.jsx)(`img`,{src:Z.getArchivePhotoUrl(e.id,t),alt:r(`editArchive.printResult`),className:`w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>ne(t),className:`absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,G.jsx)(fu,{className:`w-3 h-3 text-white`})})]},t)),(0,G.jsxs)(`label`,{className:`w-20 h-20 flex items-center justify-center border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green transition-colors`,children:[(0,G.jsx)(`input`,{ref:j,type:`file`,accept:`image/jpeg,image/png,image/webp`,onChange:te,className:`hidden`,disabled:E}),E?(0,G.jsx)(Y,{className:`w-6 h-6 text-bambu-gray animate-spin`}):(0,G.jsx)(hl,{className:`w-6 h-6 text-bambu-gray`})]})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:r(`editArchive.photosHelp`)})]}),(0,G.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,G.jsx)(Q,{type:`button`,variant:`secondary`,onClick:t,className:`flex-1`,children:r(`common.cancel`)}),(0,G.jsxs)(Q,{type:`submit`,disabled:V.isPending,className:`flex-1`,children:[(0,G.jsx)(Tl,{className:`w-4 h-4`}),V.isPending?r(`common.saving`):r(`common.save`)]})]})]})]})})}function AJ({archiveId:e,archiveName:t,onClose:n}){let{t:r}=et();return(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:n,children:(0,G.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-2xl max-h-[85vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(wc,{className:`w-5 h-5 text-bambu-green flex-shrink-0`}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white truncate`,title:t||``,children:r(`archives.runLog.modalTitle`,{name:t||r(`archives.runLog.modalTitleFallback`)})})]}),(0,G.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,title:r(`common.close`),children:(0,G.jsx)(Au,{className:`w-5 h-5`})})]}),(0,G.jsx)(`div`,{className:`p-6 overflow-y-auto flex-1`,children:(0,G.jsx)(DJ,{archiveId:e})})]})})}function TTe({items:e,searchPlaceholder:t,onClose:n,className:r,onMouseEnter:i,onMouseLeave:a}){let[o,s]=(0,y.useState)(``),c=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(t){let e=window.setTimeout(()=>c.current?.focus(),0);return()=>window.clearTimeout(e)}},[t]);let l=o.trim().toLowerCase(),u=t&&l?e.filter(e=>e.label.toLowerCase().includes(l)):e;return(0,G.jsxs)(`div`,{className:r,onMouseEnter:i,onMouseLeave:a,children:[t&&(0,G.jsx)(`div`,{className:`sticky top-0 z-[1] px-2 py-1.5 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary`,children:(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(Al,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-bambu-gray pointer-events-none`}),(0,G.jsx)(`input`,{ref:c,type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{if(e.key===`Enter`){let e=u.find(e=>!e.disabled);e&&(e.onClick(),n())}},placeholder:t,className:`w-full pl-7 pr-2 py-1 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})}),u.map((e,t)=>(0,G.jsxs)(`button`,{onClick:()=>{e.disabled||(e.onClick(),n())},disabled:e.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${e.disabled?`text-bambu-gray cursor-not-allowed`:e.danger?`text-red-400 hover:bg-red-400/10`:`text-white hover:bg-bambu-dark-tertiary`}`,children:[e.icon&&(0,G.jsx)(`span`,{className:`w-4 h-4 flex-shrink-0 flex items-center justify-center`,children:e.icon}),(0,G.jsx)(`span`,{className:`flex-1 truncate`,children:e.label})]},t)),t&&u.length===0&&(0,G.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray text-center italic`,children:`—`})]})}function jJ({x:e,y:t,items:n,onClose:r}){let i=(0,y.useRef)(null),[a,o]=(0,y.useState)(null),s=(0,y.useRef)(null),[c,l]=(0,y.useState)({x:e,y:t,visible:!1}),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)({});(0,y.useEffect)(()=>{let e=e=>{i.current&&!i.current.contains(e.target)&&r()},t=e=>{e.key===`Escape`&&r()},n=e=>{i.current&&i.current.contains(e.target)||r()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),document.addEventListener(`scroll`,n,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t),document.removeEventListener(`scroll`,n,!0),s.current&&clearTimeout(s.current)}},[r]),(0,y.useLayoutEffect)(()=>{if(i.current){i.current.style.visibility=`hidden`,i.current.style.display=`block`;let n=i.current.getBoundingClientRect(),r=window.innerWidth,a=window.innerHeight,o=e,s=t;e+n.width>r-8&&(o=Math.max(8,r-n.width-8)),o<8&&(o=8),t+n.height>a-8&&(s=Math.max(8,a-n.height-8)),s<8&&(s=8),d(r-o-n.width<180&&o>180),l({x:o,y:s,visible:!0})}},[e,t]);let m=(e,t)=>{s.current&&=(clearTimeout(s.current),null);let n=t.getBoundingClientRect(),r=window.innerHeight-n.top-8<300&&n.top>300;p(t=>({...t,[e]:r?`bottom`:`top`})),o(e)},h=()=>{s.current=window.setTimeout(()=>{o(null)},150)};return(0,G.jsx)(`div`,{ref:i,className:`fixed z-50 min-w-[180px] max-w-[280px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1`,style:{left:c.x,top:c.y,visibility:c.visible?`visible`:`hidden`},children:n.map((e,t)=>{if(e.divider)return(0,G.jsx)(`div`,{className:`my-1 border-t border-bambu-dark-tertiary`},t);let n=e.submenu&&e.submenu.length>0;return(0,G.jsxs)(`div`,{className:`relative`,onMouseEnter:e=>n&&m(t,e.currentTarget),onMouseLeave:()=>n&&h(),children:[(0,G.jsxs)(`button`,{onMouseEnter:e=>n&&m(t,e.currentTarget.parentElement),onClick:()=>{n?o(a===t?null:t):e.disabled||(e.onClick(),r())},disabled:e.disabled,title:e.title,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${e.disabled?`text-bambu-gray cursor-not-allowed`:e.danger?`text-red-400 hover:bg-red-400/10`:`text-white hover:bg-bambu-dark-tertiary`} ${n&&a===t?`bg-bambu-dark-tertiary`:``}`,children:[e.icon&&(0,G.jsx)(`span`,{className:`w-4 h-4 flex-shrink-0 flex items-center justify-center`,children:e.icon}),(0,G.jsx)(`span`,{className:`flex-1`,children:e.label}),n&&(0,G.jsx)(ts,{className:`w-4 h-4 text-bambu-gray`})]}),n&&a===t&&(0,G.jsx)(TTe,{items:e.submenu,searchPlaceholder:e.submenuSearchPlaceholder,onClose:r,className:`absolute min-w-[200px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60] ${u?`right-full mr-1`:`left-full ml-1`} ${f[t]===`bottom`?`bottom-0`:`top-0`}`,onMouseEnter:()=>{s.current&&=(clearTimeout(s.current),null)},onMouseLeave:()=>h()})]},t)})})}function ETe({selectedIds:e,existingTags:t,onClose:n}){let r=$a(),{showToast:i}=gd(),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(new Set),[l,u]=(0,y.useState)(`add`);(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let d=q({mutationFn:async()=>{let t=Array.from(s),n=0;for(let r of e)try{let e=await Z.getArchive(r),i=e.tags?e.tags.split(`,`).map(e=>e.trim()).filter(Boolean):[],a;a=l===`add`?[...new Set([...i,...t])]:i.filter(e=>!s.has(e)),await Z.updateArchive(r,{tags:a.join(`, `)}),n++}catch(e){throw console.error(`Failed to update archive ${r}:`,e),Error(`Failed on archive ${r}: ${e instanceof Error?e.message:`Unknown error`}`)}return{count:n,mode:l,tags:t}},onSuccess:({count:e,mode:t,tags:a})=>{r.invalidateQueries({queryKey:[`archives`]}),i(`${t===`add`?`Added`:`Removed`} ${a.length} tag${a.length===1?``:`s`} ${t===`add`?`to`:`from`} ${e} archive${e===1?``:`s`}`),n()},onError:e=>{i(e.message||`Failed to update tags`,`error`)}}),f=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},p=()=>{a.trim()&&!s.has(a.trim())&&(c(e=>new Set([...e,a.trim()])),o(``))};return(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,G.jsx)(cd,{className:`w-full max-w-md`,children:(0,G.jsxs)(ud,{className:`p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(iu,{className:`w-5 h-5 text-bambu-green`}),(0,G.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:l===`add`?`Add Tags`:`Remove Tags`})]}),(0,G.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,G.jsx)(Au,{className:`w-5 h-5`})})]}),(0,G.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,G.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[l===`add`?`Add`:`Remove`,` tags for `,e.length,` selected archive`,e.length===1?``:`s`]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(Q,{size:`sm`,variant:l===`add`?`primary`:`secondary`,onClick:()=>u(`add`),children:`Add Tags`}),(0,G.jsx)(Q,{size:`sm`,variant:l===`remove`?`primary`:`secondary`,onClick:()=>u(`remove`),children:`Remove Tags`})]}),l===`add`&&(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`input`,{type:`text`,placeholder:`Enter new tag...`,className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),p())}}),(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:p,disabled:!a.trim(),children:(0,G.jsx)(hl,{className:`w-4 h-4`})})]}),t.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:`Existing tags:`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>(0,G.jsx)(`button`,{onClick:()=>f(e),className:`px-2 py-1 rounded text-sm transition-colors ${s.has(e)?`bg-bambu-green text-white`:`bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark`}`,children:e},e))})]}),s.size>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:[`Tags to `,l===`add`?`add`:`remove`,`:`]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Array.from(s).map(e=>(0,G.jsxs)(`span`,{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${l===`add`?`bg-green-500/20 text-green-400`:`bg-red-500/20 text-red-400`}`,children:[e,(0,G.jsx)(`button`,{onClick:()=>f(e),className:`hover:opacity-70`,children:(0,G.jsx)(Au,{className:`w-3 h-3`})})]},e))})]})]}),(0,G.jsxs)(`div`,{className:`flex gap-3 p-4 border-t border-bambu-dark-tertiary`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:n,className:`flex-1`,children:`Cancel`}),(0,G.jsx)(Q,{onClick:()=>d.mutate(),disabled:s.size===0||d.isPending,className:`flex-1`,children:d.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),`Processing...`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(iu,{className:`w-4 h-4`}),l===`add`?`Add Tags`:`Remove Tags`]})})]})]})})})}function DTe({selectedIds:e,onClose:t}){let{t:n}=et(),r=$a(),{showToast:i}=gd(),[a,o]=(0,y.useState)(``),{data:s,isLoading:c}=K({queryKey:[`projects`],queryFn:()=>Z.getProjects()}),l=(0,y.useMemo)(()=>s?[...s].sort((e,t)=>e.name.localeCompare(t.name)):void 0,[s]),u=a.trim().toLowerCase(),d=u?l?.filter(e=>e.name.toLowerCase().includes(u)):l,f=(l?.length??0)>5;(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let p=()=>{r.invalidateQueries({queryKey:[`archives`]}),r.invalidateQueries({queryKey:[`projects`]}),r.invalidateQueries({queryKey:[`project`]}),r.invalidateQueries({queryKey:[`project-archives`]})},m=q({mutationFn:async t=>(await Z.addArchivesToProject(t,e),t),onSuccess:n=>{let r=s?.find(e=>e.id===n);p(),i(`Added ${e.length} archive${e.length===1?``:`s`} to "${r?.name}"`),t()},onError:()=>{i(`Failed to assign project`,`error`)}}),h=q({mutationFn:async()=>{for(let t of e)await Z.updateArchive(t,{project_id:null});return e.length},onSuccess:e=>{p(),i(`Removed ${e} archive${e===1?``:`s`} from project`),t()},onError:()=>{i(`Failed to remove from project`,`error`)}}),g=m.isPending||h.isPending;return(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,G.jsx)(cd,{className:`w-full max-w-md max-h-[80vh] flex flex-col`,children:(0,G.jsxs)(ud,{className:`p-0 flex flex-col min-h-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(nc,{className:`w-5 h-5 text-bambu-green`}),(0,G.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:`Assign to Project`})]}),(0,G.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white transition-colors`,disabled:g,children:(0,G.jsx)(Au,{className:`w-5 h-5`})})]}),(0,G.jsxs)(`div`,{className:`p-4 space-y-3 overflow-y-auto min-h-0`,children:[(0,G.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[`Assign `,e.length,` selected archive`,e.length===1?``:`s`,` to a project`]}),c?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(Y,{className:`w-6 h-6 animate-spin text-bambu-gray`})}):(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`button`,{onClick:()=>h.mutate(),disabled:g,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50`,children:[(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-red-500/20 flex items-center justify-center shrink-0`,children:(0,G.jsx)(ms,{className:`w-4 h-4 text-red-400`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`text-white font-medium`,children:`Remove from project`}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray truncate`,children:`Clear project assignment`})]}),h.isPending&&(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin text-bambu-gray shrink-0`})]}),l&&l.length>0&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-2`,children:[(0,G.jsx)(`div`,{className:`flex-1 h-px bg-bambu-dark-tertiary`}),(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`or assign to`}),(0,G.jsx)(`div`,{className:`flex-1 h-px bg-bambu-dark-tertiary`})]}),f&&(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(Al,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`}),(0,G.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:n(`archives.menu.searchProjects`),className:`w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray text-sm focus:border-bambu-green focus:outline-none`})]}),d?.map(e=>(0,G.jsxs)(`button`,{onClick:()=>m.mutate(e.id),disabled:g,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50`,children:[(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-full flex items-center justify-center shrink-0`,style:{backgroundColor:e.color?`${e.color}20`:`rgb(var(--bambu-green) / 0.2)`},children:(0,G.jsx)(nc,{className:`w-4 h-4`,style:{color:e.color||`rgb(var(--bambu-green))`}})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`text-white font-medium truncate`,children:e.name}),(0,G.jsxs)(`p`,{className:`text-sm text-bambu-gray truncate`,children:[e.archive_count,` archive`,e.archive_count===1?``:`s`,e.status&&` • ${e.status}`]})]}),m.isPending&&m.variables===e.id&&(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin text-bambu-gray shrink-0`})]},e.id)),(!l||l.length===0)&&(0,G.jsx)(`p`,{className:`text-center text-bambu-gray py-4`,children:`No projects yet. Create one from the Projects page.`}),l&&l.length>0&&d?.length===0&&(0,G.jsx)(`p`,{className:`text-center text-bambu-gray text-sm py-4`,children:`—`})]})]}),(0,G.jsx)(`div`,{className:`flex gap-3 p-4 border-t border-bambu-dark-tertiary shrink-0`,children:(0,G.jsx)(Q,{variant:`secondary`,onClick:t,className:`flex-1`,disabled:g,children:`Cancel`})})]})})})}function OTe(e,t){return new Date(e,t+1,0).getDate()}function kTe(e,t){return new Date(e,t,1).getDay()}var ATe=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],jTe=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function MTe({archives:e,onArchiveClick:t,highlightedArchiveId:n}){let r=new Date,[i,a]=(0,y.useState)(r.getMonth()),[o,s]=(0,y.useState)(r.getFullYear()),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(null),f=(0,y.useMemo)(()=>{let t=new Map;return e.forEach(e=>{let n=$d(e.completed_at||e.created_at)||new Date,r=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,`0`)}-${String(n.getDate()).padStart(2,`0`)}`,i=t.get(r)||[];i.push(e),t.set(r,i)}),t},[e]),p=OTe(o,i),m=kTe(o,i),h=()=>{i===0?(a(11),s(o-1)):a(i-1)},g=()=>{i===11?(a(0),s(o+1)):a(i+1)},_=()=>{a(r.getMonth()),s(r.getFullYear())},v=[];for(let e=0;e{e!==c&&d(null),l(e)};return(0,G.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-6`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsx)(`button`,{onClick:h,className:`p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,children:(0,G.jsx)(ns,{className:`w-5 h-5 text-bambu-gray`})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white`,children:[ATe[i],` `,o]}),(0,G.jsx)(`button`,{onClick:_,className:`px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors`,children:`Today`})]}),(0,G.jsx)(`button`,{onClick:g,className:`p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,children:(0,G.jsx)(ts,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-7 gap-1 mb-1`,children:jTe.map(e=>(0,G.jsx)(`div`,{className:`text-center text-xs text-bambu-gray py-2`,children:e},e))}),(0,G.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,children:v.map((e,t)=>{if(e===null)return(0,G.jsx)(`div`,{className:`aspect-square`},`empty-${t}`);let n=`${o}-${String(i+1).padStart(2,`0`)}-${String(e).padStart(2,`0`)}`,a=f.get(n)||[],s=a.length>0,l=e===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),u=n===c,d=a.filter(e=>e.status===`completed`).length,p=a.filter(e=>e.status===`failed`).length;return(0,G.jsxs)(`button`,{onClick:()=>x(u?null:n),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${u?`bg-bambu-green text-white`:l?`bg-bambu-green/20 text-white ring-2 ring-bambu-green`:s?`bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white`:`hover:bg-bambu-dark-tertiary/50 text-bambu-gray`}`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium ${l&&!u?`text-bambu-green`:``}`,children:e}),s&&(0,G.jsxs)(`div`,{className:`absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1`,children:[(0,G.jsx)(`div`,{className:`w-2 h-2 rounded-full ${p>0&&d===0?`bg-red-400`:p>0?`bg-yellow-400`:`bg-green-400`}`}),(0,G.jsx)(`span`,{className:`text-xs font-medium`,children:a.length})]})]},e)})}),(0,G.jsx)(`div`,{className:`mt-4 pt-4 border-t border-bambu-dark-tertiary`,children:(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-4 text-center`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-2xl font-bold text-white`,children:e.filter(e=>{let t=$d(e.completed_at||e.created_at)||new Date;return t.getMonth()===i&&t.getFullYear()===o}).length}),(0,G.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:`Prints this month`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-2xl font-bold text-green-400`,children:e.filter(e=>{let t=$d(e.completed_at||e.created_at)||new Date;return t.getMonth()===i&&t.getFullYear()===o&&e.status===`completed`}).length}),(0,G.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:`Successful`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-2xl font-bold text-red-400`,children:e.filter(e=>{let t=$d(e.completed_at||e.created_at)||new Date;return t.getMonth()===i&&t.getFullYear()===o&&e.status===`failed`}).length}),(0,G.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:`Failed`})]})]})})]}),(0,G.jsx)(`div`,{className:`lg:w-80 bg-bambu-dark rounded-xl p-4`,children:c?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray mb-3`,children:new Date(c+`T12:00:00`).toLocaleDateString(`en-US`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})}),b.length>0?(0,G.jsx)(`div`,{className:`calendar-scroll space-y-2 max-h-96 overflow-y-auto`,children:b.map(e=>{let r=e.id===u||e.id===n;return(0,G.jsxs)(`button`,{onClick:()=>{d(e.id),t?.(e)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${r?``:`hover:bg-bambu-dark-tertiary`}`,style:r?{outline:`4px solid #facc15`,outlineOffset:`2px`}:void 0,children:[e.thumbnail_path?(0,G.jsx)(`img`,{src:Z.getArchiveThumbnail(e.id),alt:``,className:`w-12 h-12 rounded object-cover`}):(0,G.jsx)(`div`,{className:`w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center`,children:(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`3MF`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white truncate`,children:e.print_name||e.filename}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,G.jsx)(`span`,{className:e.status===`failed`?`text-red-400`:`text-green-400`,children:e.status===`failed`?`Failed`:`Completed`}),e.filament_color&&(0,G.jsx)(`div`,{className:`flex gap-0.5`,children:e.filament_color.split(`,`).map((e,t)=>(0,G.jsx)(`div`,{className:`w-3 h-3 rounded-full border border-black/20`,style:{backgroundColor:e}},t))})]})]})]},e.id)})}):(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:`No prints on this day`})]}):(0,G.jsx)(`div`,{className:`text-center py-8`,children:(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:`Select a day to see prints`})})})]})}function MJ({archiveId:e,archiveName:t,onClose:n}){let r=Z.getArchiveQRCodeUrl(e,300);return(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:n,children:(0,G.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:`QR Code`}),(0,G.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,G.jsx)(Au,{className:`w-5 h-5`})})]}),(0,G.jsxs)(`div`,{className:`p-6 flex flex-col items-center`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4 text-center truncate max-w-full`,children:t}),(0,G.jsx)(`div`,{className:`bg-white p-4 rounded-lg mb-4`,children:(0,G.jsx)(`img`,{src:r,alt:`QR Code`,className:`w-64 h-64`})}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mb-4 text-center`,children:`Scan to open this archive`}),(0,G.jsxs)(Q,{onClick:()=>{let e=document.createElement(`a`);e.href=r,e.download=`${t}_qrcode.png`,e.click()},className:`w-full`,children:[(0,G.jsx)(Is,{className:`w-4 h-4`}),`Download QR Code`]})]})]})})}function NJ({archiveId:e,archiveName:t,photos:n,onClose:r,onDelete:i}){let[a,o]=(0,y.useState)(0),[s,c]=(0,y.useState)(!1);if((0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r(),e.key===`ArrowLeft`&&o(e=>Math.max(0,e-1)),e.key===`ArrowRight`&&o(e=>Math.min(n.length-1,e+1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,n.length]),(0,y.useEffect)(()=>{a>=n.length&&o(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;let l=n[a],u=Z.getArchivePhotoUrl(e,l);return(0,G.jsxs)(`div`,{className:`fixed inset-0 bg-black/90 flex items-center justify-center z-50`,onClick:r,children:[(0,G.jsxs)(`div`,{className:`relative w-full h-full flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 bg-black/50`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:t}),(0,G.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[`Photo `,a+1,` of `,n.length]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>{let e=document.createElement(`a`);e.href=u,e.download=`${t}_photo_${a+1}.jpg`,e.click()},children:[(0,G.jsx)(Is,{className:`w-4 h-4`}),`Download`]}),i&&(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>{i&&c(!0)},className:`text-red-400 hover:text-red-300`,children:(0,G.jsx)(fu,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:r,className:`p-2 text-bambu-gray hover:text-white transition-colors`,children:(0,G.jsx)(Au,{className:`w-6 h-6`})})]})]}),(0,G.jsxs)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden`,children:[a>0&&(0,G.jsx)(`button`,{onClick:()=>o(e=>e-1),className:`absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors`,children:(0,G.jsx)(ns,{className:`w-8 h-8 text-white`})}),(0,G.jsx)(`img`,{src:u,alt:`Photo ${a+1}`,className:`max-w-full max-h-full object-contain rounded-lg`,style:{maxHeight:`calc(100vh - 200px)`}}),ao(e=>e+1),className:`absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors`,children:(0,G.jsx)(ts,{className:`w-8 h-8 text-white`})})]}),n.length>1&&(0,G.jsx)(`div`,{className:`flex justify-center gap-2 p-4 bg-black/50`,children:n.map((t,n)=>(0,G.jsx)(`button`,{onClick:()=>o(n),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${n===a?`border-bambu-green`:`border-transparent hover:border-bambu-gray`}`,children:(0,G.jsx)(`img`,{src:Z.getArchivePhotoUrl(e,t),alt:`Thumbnail ${n+1}`,className:`w-full h-full object-cover`})},t))})]}),s&&(0,G.jsx)(xd,{title:`Delete Photo`,message:`Delete this photo? This cannot be undone.`,confirmText:`Delete`,variant:`danger`,onConfirm:()=>{i?.(l),c(!1)},onCancel:()=>c(!1)})]})}function PJ(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n`u`?null:iY(BigInt.prototype.toString),$J=typeof Symbol>`u`?null:iY(Symbol.prototype.toString),eY=iY(Object.prototype.hasOwnProperty),tY=iY(Object.prototype.toString),nY=iY(RegExp.prototype.test),rY=KTe(TypeError);function iY(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return VJ(e,t,n)}}function KTe(e){return function(){return HJ(e,[...arguments])}}function aY(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qJ;if(IJ&&IJ(e,null),!KJ(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(RTe(t)||(t[r]=e),i=e)}e[i]=!0}return e}function qTe(e){for(let t=0;t/g),eEe=RJ(/\${[\w\W]*/g),tEe=RJ(/^data-[\-\w.\u00B7-\uFFFF]+$/),nEe=RJ(/^aria-[\-\w]+$/),_Y=RJ(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),rEe=RJ(/^(?:\w+script|data):/i),iEe=RJ(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),aEe=RJ(/^html$/i),oEe=RJ(/^[a-z][.\w]*(-[.\w]+)+$/i),vY=RJ(/<[/\w!]/g),sEe=RJ(/<[/\w]/g),cEe=RJ(/<\/no(script|embed|frames)/i),lEe=RJ(/\/>/i),yY={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},uEe=function(){return typeof window>`u`?null:window},dEe=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},bY=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},xY=function(e,t,n,r){return eY(e,t)&&KJ(e[t])?aY(r.base?oY(r.base):{},e[t],r.transform):n};function SY(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:uEe(),t=e=>SY(e);if(t.version=`3.4.10`,t.removed=[],!e||!e.document||e.document.nodeType!==yY.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=sY(d,`cloneNode`),p=sY(d,`remove`),m=sY(d,`nextSibling`),h=sY(d,`childNodes`),g=sY(d,`parentNode`),_=sY(d,`shadowRoot`),v=sY(d,`attributes`),y=o&&o.prototype?sY(o.prototype,`nodeType`):null,b=o&&o.prototype?sY(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,C,w=!1,T=0,E=function(){if(T>0)throw rY(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},D=function(e){E(),T++;try{return x.createHTML(e)}finally{T--}},O=function(e){E(),T++;try{return x.createScriptURL(e)}finally{T--}},k=function(){return w||=(C=dEe(u,i),!0),C},A=n,j=A.implementation,M=A.createNodeIterator,N=A.createDocumentFragment,P=A.getElementsByTagName,F=r.importNode,I=bY();t.isSupported=typeof FJ==`function`&&typeof g==`function`&&j&&j.createHTMLDocument!==void 0;let L=QTe,R=$Te,z=eEe,B=tEe,ee=nEe,V=rEe,te=iEe,ne=oEe,re=_Y,ie=null,H=aY({},[...cY,...lY,...uY,...dY,...fY]),ae=null,oe=aY({},[...pY,...mY,...hY,...gY]),U=Object.seal(zJ(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),se=null,ce=null,le=Object.seal(zJ(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ue=!0,de=!0,fe=!1,pe=!0,me=!1,he=!0,ge=!1,_e=!1,ve=!1,ye=!1,be=!1,xe=!1,Se=!0,Ce=!1,we=`user-content-`,Te=!0,Ee=!1,De={},Oe=null,ke=aY({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Ae=null,je=aY({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Me=null,Ne=aY({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Pe=`http://www.w3.org/1998/Math/MathML`,Fe=`http://www.w3.org/2000/svg`,Ie=`http://www.w3.org/1999/xhtml`,Le=Ie,Re=!1,ze=null,Be=aY({},[Pe,Fe,Ie],JJ),Ve=LJ([`mi`,`mo`,`mn`,`ms`,`mtext`]),He=aY({},Ve),Ue=LJ([`annotation-xml`]),We=aY({},Ue),Ge=aY({},[`title`,`style`,`font`,`a`,`script`]),Ke=null,qe=[`application/xhtml+xml`,`text/html`],Je=null,Ye=null,Xe=n.createElement(`form`),Ze=function(e){return e instanceof RegExp||e instanceof Function},Qe=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ye&&Ye===e)return;(!e||typeof e!=`object`)&&(e={}),e=oY(e),Ke=qe.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,Je=Ke===`application/xhtml+xml`?JJ:qJ,ie=xY(e,`ALLOWED_TAGS`,H,{transform:Je}),ae=xY(e,`ALLOWED_ATTR`,oe,{transform:Je}),ze=xY(e,`ALLOWED_NAMESPACES`,Be,{transform:JJ}),Me=xY(e,`ADD_URI_SAFE_ATTR`,Ne,{transform:Je,base:Ne}),Ae=xY(e,`ADD_DATA_URI_TAGS`,je,{transform:Je,base:je}),Oe=xY(e,`FORBID_CONTENTS`,ke,{transform:Je}),se=xY(e,`FORBID_TAGS`,oY({}),{transform:Je}),ce=xY(e,`FORBID_ATTR`,oY({}),{transform:Je}),De=eY(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?oY(e.USE_PROFILES):e.USE_PROFILES:!1,ue=e.ALLOW_ARIA_ATTR!==!1,de=e.ALLOW_DATA_ATTR!==!1,fe=e.ALLOW_UNKNOWN_PROTOCOLS||!1,pe=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,me=e.SAFE_FOR_TEMPLATES||!1,he=e.SAFE_FOR_XML!==!1,ge=e.WHOLE_DOCUMENT||!1,ye=e.RETURN_DOM||!1,be=e.RETURN_DOM_FRAGMENT||!1,xe=e.RETURN_TRUSTED_TYPE||!1,ve=e.FORCE_BODY||!1,Se=e.SANITIZE_DOM!==!1,Ce=e.SANITIZE_NAMED_PROPS||!1,Te=e.KEEP_CONTENT!==!1,Ee=e.IN_PLACE||!1,re=YTe(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:_Y,Le=typeof e.NAMESPACE==`string`?e.NAMESPACE:Ie,He=eY(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?oY(e.MATHML_TEXT_INTEGRATION_POINTS):aY({},Ve),We=eY(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?oY(e.HTML_INTEGRATION_POINTS):aY({},Ue);let t=eY(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?oY(e.CUSTOM_ELEMENT_HANDLING):zJ(null);if(U=zJ(null),eY(t,`tagNameCheck`)&&Ze(t.tagNameCheck)&&(U.tagNameCheck=t.tagNameCheck),eY(t,`attributeNameCheck`)&&Ze(t.attributeNameCheck)&&(U.attributeNameCheck=t.attributeNameCheck),eY(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(U.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),RJ(U),me&&(de=!1),be&&(ye=!0),De&&(ie=aY({},fY),ae=zJ(null),De.html===!0&&(aY(ie,cY),aY(ae,pY)),De.svg===!0&&(aY(ie,lY),aY(ae,mY),aY(ae,gY)),De.svgFilters===!0&&(aY(ie,uY),aY(ae,mY),aY(ae,gY)),De.mathMl===!0&&(aY(ie,dY),aY(ae,hY),aY(ae,gY))),le.tagCheck=null,le.attributeCheck=null,eY(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?le.tagCheck=e.ADD_TAGS:KJ(e.ADD_TAGS)&&(ie===H&&(ie=oY(ie)),aY(ie,e.ADD_TAGS,Je))),eY(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?le.attributeCheck=e.ADD_ATTR:KJ(e.ADD_ATTR)&&(ae===oe&&(ae=oY(ae)),aY(ae,e.ADD_ATTR,Je))),eY(e,`ADD_URI_SAFE_ATTR`)&&KJ(e.ADD_URI_SAFE_ATTR)&&aY(Me,e.ADD_URI_SAFE_ATTR,Je),eY(e,`FORBID_CONTENTS`)&&KJ(e.FORBID_CONTENTS)&&(Oe===ke&&(Oe=oY(Oe)),aY(Oe,e.FORBID_CONTENTS,Je)),eY(e,`ADD_FORBID_CONTENTS`)&&KJ(e.ADD_FORBID_CONTENTS)&&(Oe===ke&&(Oe=oY(Oe)),aY(Oe,e.ADD_FORBID_CONTENTS,Je)),Te&&(ie[`#text`]=!0),ge&&aY(ie,[`html`,`head`,`body`]),ie.table&&(aY(ie,[`tbody`]),delete se.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw rY(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw rY(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=D(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=k()),x&&typeof S==`string`&&(S=D(``)));(I.uponSanitizeElement.length>0||I.uponSanitizeAttribute.length>0)&&ie===H&&(ie=oY(ie)),I.uponSanitizeAttribute.length>0&&ae===oe&&(ae=oY(ae)),LJ&&LJ(e),Ye=e},$e=aY({},[...lY,...uY,...XTe]),et=aY({},[...dY,...ZTe]),tt=function(e,t,n){return t.namespaceURI===Ie?e===`svg`:t.namespaceURI===Pe?e===`svg`&&(n===`annotation-xml`||He[n]):!!$e[e]},nt=function(e,t,n){return t.namespaceURI===Ie?e===`math`:t.namespaceURI===Fe?e===`math`&&We[n]:!!et[e]},rt=function(e,t,n){return t.namespaceURI===Fe&&!We[n]||t.namespaceURI===Pe&&!He[n]?!1:!et[e]&&(Ge[e]||!$e[e])},it=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:Le,tagName:`template`});let n=qJ(e.tagName),r=qJ(t.tagName);return ze[e.namespaceURI]?e.namespaceURI===Fe?tt(n,t,r):e.namespaceURI===Pe?nt(n,t,r):e.namespaceURI===Ie?rt(n,t,r):!!(Ke===`application/xhtml+xml`&&ze[e.namespaceURI]):!1},at=function(e){GJ(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw rY(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},ot=function(e){let t=h(e);if(t){let e=[];UJ(t,t=>{GJ(e,t)}),UJ(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},st=function(e,n){try{GJ(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{GJ(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(ye||be)try{at(n)}catch{}else try{n.setAttribute(e,``)}catch{}},ct=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||ae[Je(i)]))try{e.removeAttribute(i)}catch{}}},lt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===yY.element&&ct(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},ut=function(e){let t=null,r=null;if(ve)e=``+e;else{let t=YJ(e,/^[\r\n\t ]+/);r=t&&t[0]}Ke===`application/xhtml+xml`&&Le===Ie&&(e=``+e+``);let i=x?D(e):e;if(Le===Ie)try{t=new l().parseFromString(i,Ke)}catch{}if(!t||!t.documentElement){t=j.createDocument(Le,`template`,null);try{t.documentElement.innerHTML=Re?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Le===Ie?P.call(t,ge?`html`:`body`)[0]:ge?t.documentElement:a},dt=function(e){return M.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ft=function(e){return e=XJ(e,L,` `),e=XJ(e,R,` `),e=XJ(e,z,` `),e},pt=function(e){e.normalize();let t=M.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=ft(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&UJ(r,e=>{ht(e.content)&&pt(e.content)})},mt=function(e){let t=b?b(e):null;return typeof t!=`string`||Je(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},ht=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===yY.documentFragment}catch{return!1}},gt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function _t(e,n,r){e.length!==0&&UJ(e,e=>{e.call(t,n,r,Ye)})}let vt=function(e,t){return!!(he&&e.hasChildNodes()&&!gt(e.firstElementChild)&&nY(vY,e.textContent)&&nY(vY,e.innerHTML)||he&&e.namespaceURI===Ie&&t===`style`&>(e.firstElementChild)||e.nodeType===yY.processingInstruction||he&&e.nodeType===yY.comment&&nY(sEe,e.data))},yt=function(e,t){if(!se[t]&&St(t)&&(U.tagNameCheck instanceof RegExp&&nY(U.tagNameCheck,t)||U.tagNameCheck instanceof Function&&U.tagNameCheck(t)))return!1;if(Te&&!Oe[t]){let t=g(e),n=h(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=Ee?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return at(e),!0},bt=function(e){if(_t(I.beforeSanitizeElements,e,null),mt(e))return at(e),!0;let n=Je(b?b(e):e.nodeName);if(_t(I.uponSanitizeElement,e,{tagName:n,allowedTags:ie}),vt(e,n))return at(e),!0;if(se[n]||!(le.tagCheck instanceof Function&&le.tagCheck(n))&&!ie[n])return yt(e,n);if((y?y(e):e.nodeType)===yY.element&&!it(e)||(n===`noscript`||n===`noembed`||n===`noframes`)&&nY(cEe,e.innerHTML))return at(e),!0;if(me&&e.nodeType===yY.text){let n=ft(e.textContent);e.textContent!==n&&(GJ(t.removed,{element:e.cloneNode()}),e.textContent=n)}return _t(I.afterSanitizeElements,e,null),!1},xt=function(e,t,r){if(ce[t]||Se&&(t===`id`||t===`name`)&&(r in n||r in Xe))return!1;let i=ae[t]||le.attributeCheck instanceof Function&&le.attributeCheck(t,e);if(!(de&&nY(B,t))&&!(ue&&nY(ee,t))){if(!i){if(!(St(e)&&(U.tagNameCheck instanceof RegExp&&nY(U.tagNameCheck,e)||U.tagNameCheck instanceof Function&&U.tagNameCheck(e))&&(U.attributeNameCheck instanceof RegExp&&nY(U.attributeNameCheck,t)||U.attributeNameCheck instanceof Function&&U.attributeNameCheck(t,e))||t===`is`&&U.allowCustomizedBuiltInElements&&(U.tagNameCheck instanceof RegExp&&nY(U.tagNameCheck,r)||U.tagNameCheck instanceof Function&&U.tagNameCheck(r))))return!1}else if(!Me[t]&&!nY(re,XJ(r,te,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&ZJ(r,`data:`)===0&&Ae[e])&&!(fe&&!nY(V,XJ(r,te,``)))&&r)return!1}return!0},W=aY({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),St=function(e){return!W[qJ(e)]&&nY(ne,e)},Ct=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return D(r);case`TrustedScriptURL`:return O(r)}return r},wt=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),mt(e)?at(e):WJ(t.removed)}catch{st(n,e)}},Tt=function(e){_t(I.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||mt(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:ae,forceKeepAttr:void 0},r=t.length,i=Je(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=Je(o),u=c,d=o===`value`?u:UTe(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,_t(I.uponSanitizeAttribute,e,n),d=n.attrValue,Ce&&(l===`id`||l===`name`)&&ZJ(d,we)!==0&&(st(o,e),d=we+d),he&&nY(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){st(o,e);continue}if(l===`attributename`&&YJ(d,`href`)){st(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){st(o,e);continue}if(!pe&&nY(lEe,d)){st(o,e);continue}if(me&&(d=ft(d)),!xt(i,l,d)){st(o,e);continue}d=Ct(i,l,s,d),d!==u&&wt(e,o,s,d)}}_t(I.afterSanitizeAttributes,e,null)},Et=function(e){let t=null,n=dt(e);for(_t(I.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(_t(I.uponSanitizeShadowNode,t,null),bt(t),Tt(t),ht(t.content)&&Et(t.content),(y?y(t):t.nodeType)===yY.element){let e=_(t);ht(e)&&(Dt(e),Et(e))}_t(I.afterSanitizeShadowDOM,e,null)},Dt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Et(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===yY.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&Je(e)===`template`){let e=n.content;ht(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);ht(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Re=!e,Re&&(e=``),typeof e!=`string`&&!gt(e)&&(e=JTe(e),typeof e!=`string`))throw rY(`dirty is not a string, aborting`);if(!t.isSupported)return e;_e||Qe(n),t.removed=[];let c=Ee&&typeof e!=`string`&>(e);if(c){let t=b?b(e):e.nodeName;if(typeof t==`string`){let e=Je(t);if(!ie[e]||se[e])throw rY(`root node is forbidden and cannot be sanitized in-place`)}if(mt(e))throw rY(`root node is clobbered and cannot be sanitized in-place`);try{Dt(e)}catch(t){throw ot(e),t}}else if(gt(e))i=ut(``),a=i.ownerDocument.importNode(e,!0),a.nodeType===yY.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Dt(a);else{if(!ye&&!me&&!ge&&e.indexOf(`<`)===-1)return x&&xe?D(e):e;if(i=ut(e),!i)return ye?null:xe?S:``}i&&ve&&at(i.firstChild);let l=dt(c?e:i);try{for(;o=l.nextNode();)bt(o),Tt(o),ht(o.content)&&Et(o.content)}catch(t){throw c&&ot(e),t}if(c)return UJ(t.removed,e=>{e.element&<(e.element)}),me&&pt(e),e;if(ye){if(me&&pt(i),be)for(s=N.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(ae.shadowroot||ae.shadowrootmode)&&(s=F.call(r,s,!0)),s}let u=ge?i.outerHTML:i.innerHTML;return ge&&ie[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&nY(aEe,i.ownerDocument.doctype.name)&&(u=` -`+u),me&&(u=ft(u)),x&&xe?D(u):u},t.setConfig=function(){Qe(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),_e=!0},t.clearConfig=function(){Ye=null,_e=!1,x=C,S=``},t.isValidAttribute=function(e,t,n){return Ye||Qe({}),xt(Je(e),Je(t),n)},t.addHook=function(e,t){typeof t==`function`&&GJ(I[e],t)},t.removeHook=function(e,t){if(t!==void 0){let n=VTe(I[e],t);return n===-1?void 0:HTe(I[e],n,1)[0]}return WJ(I[e])},t.removeHooks=function(e){I[e]=[]},t.removeAllHooks=function(){I=bY()},t}var CY=SY();function wY(e){this.content=e}wY.prototype={constructor:wY,find:function(e){for(var t=0;t>1}},wY.from=function(e){if(e instanceof wY)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new wY(t)};function TY(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=TY(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function EY(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;ee&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);at)for(let e=0,a=0;at&&((an)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?kY(t+1,i):kY(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;ethis.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;te.type.rank-t.type.rank),n}};jY.none=[];var MY=class extends Error{},NY=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=FY(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(PY(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(DY.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};NY.empty=new NY(DY.empty,0,0);function PY(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(PY(a.content,t-i-1,n-i-1)))}function FY(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=FY(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function fEe(e,t,n){if(n.openStart>e.depth)throw new MY(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new MY(`Inconsistent open depths`);return IY(e,t,n,0)}function IY(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function BY(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(zY(e.nodeAfter,r),a++));for(let e=a;ei&&RY(e,t,i+1),o=r.depth>i&&RY(n,r,i+1),s=[];return BY(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(LY(a,o),zY(VY(a,HY(e,t,n,r,i+1)),s)):(a&&zY(VY(a,UY(e,t,i+1)),s),BY(t,n,i,s),o&&zY(VY(o,UY(n,r,i+1)),s)),BY(r,null,i,s),new DY(s)}function UY(e,t,n){let r=[];return BY(null,e,n,r),e.depth>n&&zY(VY(RY(e,t,n+1),UY(e,t,n+1)),r),BY(t,null,n,r),new DY(r)}function pEe(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(DY.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var WY=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new KY(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=GY.get(t);if(r)for(let e=0;ee&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),JY(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=DY.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;ee.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=DY.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};qY.prototype.text=void 0;var _Ee=class e extends qY{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):JY(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function JY(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var YY=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new vEe(t,n);if(r.next==null)return e.empty;let i=XY(r);r.next&&r.err(`Unexpected trailing text`);let a=TEe(wEe(i));return EEe(a,r),a}matchType(e){for(let t=0;te.createAndFill()));for(let e=0;e=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n`+e.indexOf(t.next[n].next);return r}).join(` +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ITe(e,t){return NTe(e)||PTe(e,t)||LTe(e,t)||FTe()}function LTe(e,t){if(e){if(typeof e==`string`)return PJ(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?PJ(e,t):void 0}}var FJ=Object.entries,IJ=Object.setPrototypeOf,RTe=Object.isFrozen,zTe=Object.getPrototypeOf,BTe=Object.getOwnPropertyDescriptor,LJ=Object.freeze,RJ=Object.seal,zJ=Object.create,BJ=typeof Reflect<`u`&&Reflect,VJ=BJ.apply,HJ=BJ.construct;LJ||=function(e){return e},RJ||=function(e){return e},VJ||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},HJ||=function(e){return new e(...[...arguments].slice(1))};var UJ=iY(Array.prototype.forEach),VTe=iY(Array.prototype.lastIndexOf),WJ=iY(Array.prototype.pop),GJ=iY(Array.prototype.push),HTe=iY(Array.prototype.splice),KJ=Array.isArray,qJ=iY(String.prototype.toLowerCase),JJ=iY(String.prototype.toString),YJ=iY(String.prototype.match),XJ=iY(String.prototype.replace),ZJ=iY(String.prototype.indexOf),UTe=iY(String.prototype.trim),WTe=iY(Number.prototype.toString),GTe=iY(Boolean.prototype.toString),QJ=typeof BigInt>`u`?null:iY(BigInt.prototype.toString),$J=typeof Symbol>`u`?null:iY(Symbol.prototype.toString),eY=iY(Object.prototype.hasOwnProperty),tY=iY(Object.prototype.toString),nY=iY(RegExp.prototype.test),rY=KTe(TypeError);function iY(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return VJ(e,t,n)}}function KTe(e){return function(){return HJ(e,[...arguments])}}function aY(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qJ;if(IJ&&IJ(e,null),!KJ(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(RTe(t)||(t[r]=e),i=e)}e[i]=!0}return e}function qTe(e){for(let t=0;t/g),eEe=RJ(/\${[\w\W]*/g),tEe=RJ(/^data-[\-\w.\u00B7-\uFFFF]+$/),nEe=RJ(/^aria-[\-\w]+$/),_Y=RJ(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),rEe=RJ(/^(?:\w+script|data):/i),iEe=RJ(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),aEe=RJ(/^html$/i),oEe=RJ(/^[a-z][.\w]*(-[.\w]+)+$/i),vY=RJ(/<[/\w!]/g),sEe=RJ(/<[/\w]/g),cEe=RJ(/<\/no(script|embed|frames)/i),lEe=RJ(/\/>/i),yY={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},uEe=function(){return typeof window>`u`?null:window},dEe=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},bY=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},xY=function(e,t,n,r){return eY(e,t)&&KJ(e[t])?aY(r.base?oY(r.base):{},e[t],r.transform):n};function SY(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:uEe(),t=e=>SY(e);if(t.version=`3.4.11`,t.removed=[],!e||!e.document||e.document.nodeType!==yY.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=sY(d,`cloneNode`),p=sY(d,`remove`),m=sY(d,`nextSibling`),h=sY(d,`childNodes`),g=sY(d,`parentNode`),_=sY(d,`shadowRoot`),v=sY(d,`attributes`),y=o&&o.prototype?sY(o.prototype,`nodeType`):null,b=o&&o.prototype?sY(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,C,w=!1,T=0,E=function(){if(T>0)throw rY(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},D=function(e){E(),T++;try{return x.createHTML(e)}finally{T--}},O=function(e){E(),T++;try{return x.createScriptURL(e)}finally{T--}},k=function(){return w||=(C=dEe(u,i),!0),C},A=n,j=A.implementation,M=A.createNodeIterator,N=A.createDocumentFragment,P=A.getElementsByTagName,F=r.importNode,I=bY();t.isSupported=typeof FJ==`function`&&typeof g==`function`&&j&&j.createHTMLDocument!==void 0;let L=QTe,R=$Te,z=eEe,B=tEe,ee=nEe,V=rEe,te=iEe,ne=oEe,re=_Y,ie=null,H=aY({},[...cY,...lY,...uY,...dY,...fY]),ae=null,oe=aY({},[...pY,...mY,...hY,...gY]),U=Object.seal(zJ(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),se=null,ce=null,le=Object.seal(zJ(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ue=!0,de=!0,fe=!1,pe=!0,me=!1,he=!0,ge=!1,_e=!1,ve=null,ye=null,be=!1,xe=!1,Se=!1,Ce=!1,we=!0,Te=!1,Ee=`user-content-`,De=!0,Oe=!1,ke={},Ae=null,je=aY({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Me=null,Ne=aY({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Pe=null,Fe=aY({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ie=`http://www.w3.org/1998/Math/MathML`,Le=`http://www.w3.org/2000/svg`,Re=`http://www.w3.org/1999/xhtml`,ze=Re,Be=!1,Ve=null,He=aY({},[Ie,Le,Re],JJ),Ue=LJ([`mi`,`mo`,`mn`,`ms`,`mtext`]),We=aY({},Ue),Ge=LJ([`annotation-xml`]),Ke=aY({},Ge),qe=aY({},[`title`,`style`,`font`,`a`,`script`]),Je=null,Ye=[`application/xhtml+xml`,`text/html`],Xe=null,Ze=null,Qe=n.createElement(`form`),$e=function(e){return e instanceof RegExp||e instanceof Function},et=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ze&&Ze===e)return;(!e||typeof e!=`object`)&&(e={}),e=oY(e),Je=Ye.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,Xe=Je===`application/xhtml+xml`?JJ:qJ,ie=xY(e,`ALLOWED_TAGS`,H,{transform:Xe}),ae=xY(e,`ALLOWED_ATTR`,oe,{transform:Xe}),Ve=xY(e,`ALLOWED_NAMESPACES`,He,{transform:JJ}),Pe=xY(e,`ADD_URI_SAFE_ATTR`,Fe,{transform:Xe,base:Fe}),Me=xY(e,`ADD_DATA_URI_TAGS`,Ne,{transform:Xe,base:Ne}),Ae=xY(e,`FORBID_CONTENTS`,je,{transform:Xe}),se=xY(e,`FORBID_TAGS`,oY({}),{transform:Xe}),ce=xY(e,`FORBID_ATTR`,oY({}),{transform:Xe}),ke=eY(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?oY(e.USE_PROFILES):e.USE_PROFILES:!1,ue=e.ALLOW_ARIA_ATTR!==!1,de=e.ALLOW_DATA_ATTR!==!1,fe=e.ALLOW_UNKNOWN_PROTOCOLS||!1,pe=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,me=e.SAFE_FOR_TEMPLATES||!1,he=e.SAFE_FOR_XML!==!1,ge=e.WHOLE_DOCUMENT||!1,xe=e.RETURN_DOM||!1,Se=e.RETURN_DOM_FRAGMENT||!1,Ce=e.RETURN_TRUSTED_TYPE||!1,be=e.FORCE_BODY||!1,we=e.SANITIZE_DOM!==!1,Te=e.SANITIZE_NAMED_PROPS||!1,De=e.KEEP_CONTENT!==!1,Oe=e.IN_PLACE||!1,re=YTe(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:_Y,ze=typeof e.NAMESPACE==`string`?e.NAMESPACE:Re,We=eY(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?oY(e.MATHML_TEXT_INTEGRATION_POINTS):aY({},Ue),Ke=eY(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?oY(e.HTML_INTEGRATION_POINTS):aY({},Ge);let t=eY(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?oY(e.CUSTOM_ELEMENT_HANDLING):zJ(null);if(U=zJ(null),eY(t,`tagNameCheck`)&&$e(t.tagNameCheck)&&(U.tagNameCheck=t.tagNameCheck),eY(t,`attributeNameCheck`)&&$e(t.attributeNameCheck)&&(U.attributeNameCheck=t.attributeNameCheck),eY(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(U.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),RJ(U),me&&(de=!1),Se&&(xe=!0),ke&&(ie=aY({},fY),ae=zJ(null),ke.html===!0&&(aY(ie,cY),aY(ae,pY)),ke.svg===!0&&(aY(ie,lY),aY(ae,mY),aY(ae,gY)),ke.svgFilters===!0&&(aY(ie,uY),aY(ae,mY),aY(ae,gY)),ke.mathMl===!0&&(aY(ie,dY),aY(ae,hY),aY(ae,gY))),le.tagCheck=null,le.attributeCheck=null,eY(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?le.tagCheck=e.ADD_TAGS:KJ(e.ADD_TAGS)&&(ie===H&&(ie=oY(ie)),aY(ie,e.ADD_TAGS,Xe))),eY(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?le.attributeCheck=e.ADD_ATTR:KJ(e.ADD_ATTR)&&(ae===oe&&(ae=oY(ae)),aY(ae,e.ADD_ATTR,Xe))),eY(e,`ADD_URI_SAFE_ATTR`)&&KJ(e.ADD_URI_SAFE_ATTR)&&aY(Pe,e.ADD_URI_SAFE_ATTR,Xe),eY(e,`FORBID_CONTENTS`)&&KJ(e.FORBID_CONTENTS)&&(Ae===je&&(Ae=oY(Ae)),aY(Ae,e.FORBID_CONTENTS,Xe)),eY(e,`ADD_FORBID_CONTENTS`)&&KJ(e.ADD_FORBID_CONTENTS)&&(Ae===je&&(Ae=oY(Ae)),aY(Ae,e.ADD_FORBID_CONTENTS,Xe)),De&&(ie[`#text`]=!0),ge&&aY(ie,[`html`,`head`,`body`]),ie.table&&(aY(ie,[`tbody`]),delete se.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw rY(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw rY(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=D(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=k()),x&&typeof S==`string`&&(S=D(``)));LJ&&LJ(e),Ze=e},tt=aY({},[...lY,...uY,...XTe]),nt=aY({},[...dY,...ZTe]),rt=function(e,t,n){return t.namespaceURI===Re?e===`svg`:t.namespaceURI===Ie?e===`svg`&&(n===`annotation-xml`||We[n]):!!tt[e]},it=function(e,t,n){return t.namespaceURI===Re?e===`math`:t.namespaceURI===Le?e===`math`&&Ke[n]:!!nt[e]},at=function(e,t,n){return t.namespaceURI===Le&&!Ke[n]||t.namespaceURI===Ie&&!We[n]?!1:!nt[e]&&(qe[e]||!tt[e])},ot=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:ze,tagName:`template`});let n=qJ(e.tagName),r=qJ(t.tagName);return Ve[e.namespaceURI]?e.namespaceURI===Le?rt(n,t,r):e.namespaceURI===Ie?it(n,t,r):e.namespaceURI===Re?at(n,t,r):!!(Je===`application/xhtml+xml`&&Ve[e.namespaceURI]):!1},st=function(e){GJ(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw rY(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},ct=function(e){let t=h(e);if(t){let e=[];UJ(t,t=>{GJ(e,t)}),UJ(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},lt=function(e,n){try{GJ(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{GJ(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(xe||Se)try{st(n)}catch{}else try{n.setAttribute(e,``)}catch{}},ut=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||ae[Xe(i)]))try{e.removeAttribute(i)}catch{}}},dt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===yY.element&&ut(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},ft=function(e){let t=null,r=null;if(be)e=``+e;else{let t=YJ(e,/^[\r\n\t ]+/);r=t&&t[0]}Je===`application/xhtml+xml`&&ze===Re&&(e=``+e+``);let i=x?D(e):e;if(ze===Re)try{t=new l().parseFromString(i,Je)}catch{}if(!t||!t.documentElement){t=j.createDocument(ze,`template`,null);try{t.documentElement.innerHTML=Be?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),ze===Re?P.call(t,ge?`html`:`body`)[0]:ge?t.documentElement:a},pt=function(e){return M.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},mt=function(e){return e=XJ(e,L,` `),e=XJ(e,R,` `),e=XJ(e,z,` `),e},ht=function(e){e.normalize();let t=M.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=mt(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&UJ(r,e=>{_t(e.content)&&ht(e.content)})},gt=function(e){let t=b?b(e):null;return typeof t!=`string`||Xe(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},_t=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===yY.documentFragment}catch{return!1}},vt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function yt(e,n,r){e.length!==0&&UJ(e,e=>{e.call(t,n,r,Ze)})}let bt=function(e,t){return!!(he&&e.hasChildNodes()&&!vt(e.firstElementChild)&&nY(vY,e.textContent)&&nY(vY,e.innerHTML)||he&&e.namespaceURI===Re&&t===`style`&&vt(e.firstElementChild)||e.nodeType===yY.processingInstruction||he&&e.nodeType===yY.comment&&nY(sEe,e.data))},xt=function(e,t){if(!se[t]&&wt(t)&&(U.tagNameCheck instanceof RegExp&&nY(U.tagNameCheck,t)||U.tagNameCheck instanceof Function&&U.tagNameCheck(t)))return!1;if(De&&!Ae[t]){let t=g(e),n=h(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=Oe?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return st(e),!0},W=function(e){if(yt(I.beforeSanitizeElements,e,null),gt(e))return st(e),!0;let n=Xe(b?b(e):e.nodeName);if(yt(I.uponSanitizeElement,e,{tagName:n,allowedTags:ie}),bt(e,n))return st(e),!0;if(se[n]||!(le.tagCheck instanceof Function&&le.tagCheck(n))&&!ie[n])return xt(e,n);if((y?y(e):e.nodeType)===yY.element&&!ot(e)||(n===`noscript`||n===`noembed`||n===`noframes`)&&nY(cEe,e.innerHTML))return st(e),!0;if(me&&e.nodeType===yY.text){let n=mt(e.textContent);e.textContent!==n&&(GJ(t.removed,{element:e.cloneNode()}),e.textContent=n)}return yt(I.afterSanitizeElements,e,null),!1},St=function(e,t,r){if(ce[t]||we&&(t===`id`||t===`name`)&&(r in n||r in Qe))return!1;let i=ae[t]||le.attributeCheck instanceof Function&&le.attributeCheck(t,e);if(!(de&&nY(B,t))&&!(ue&&nY(ee,t))){if(!i){if(!(wt(e)&&(U.tagNameCheck instanceof RegExp&&nY(U.tagNameCheck,e)||U.tagNameCheck instanceof Function&&U.tagNameCheck(e))&&(U.attributeNameCheck instanceof RegExp&&nY(U.attributeNameCheck,t)||U.attributeNameCheck instanceof Function&&U.attributeNameCheck(t,e))||t===`is`&&U.allowCustomizedBuiltInElements&&(U.tagNameCheck instanceof RegExp&&nY(U.tagNameCheck,r)||U.tagNameCheck instanceof Function&&U.tagNameCheck(r))))return!1}else if(!Pe[t]&&!nY(re,XJ(r,te,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&ZJ(r,`data:`)===0&&Me[e])&&!(fe&&!nY(V,XJ(r,te,``)))&&r)return!1}return!0},Ct=aY({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),wt=function(e){return!Ct[qJ(e)]&&nY(ne,e)},Tt=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return D(r);case`TrustedScriptURL`:return O(r)}return r},Et=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),gt(e)?st(e):WJ(t.removed)}catch{lt(n,e)}},Dt=function(e){yt(I.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||gt(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:ae,forceKeepAttr:void 0},r=t.length,i=Xe(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=Xe(o),u=c,d=o===`value`?u:UTe(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,yt(I.uponSanitizeAttribute,e,n),d=n.attrValue,Te&&(l===`id`||l===`name`)&&ZJ(d,Ee)!==0&&(lt(o,e),d=Ee+d),he&&nY(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){lt(o,e);continue}if(l===`attributename`&&YJ(d,`href`)){lt(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){lt(o,e);continue}if(!pe&&nY(lEe,d)){lt(o,e);continue}if(me&&(d=mt(d)),!St(i,l,d)){lt(o,e);continue}d=Tt(i,l,s,d),d!==u&&Et(e,o,s,d)}}yt(I.afterSanitizeAttributes,e,null)},Ot=function(e){let t=null,n=pt(e);for(yt(I.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(yt(I.uponSanitizeShadowNode,t,null),W(t),Dt(t),_t(t.content)&&Ot(t.content),(y?y(t):t.nodeType)===yY.element){let e=_(t);_t(e)&&(kt(e),Ot(e))}yt(I.afterSanitizeShadowDOM,e,null)},kt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Ot(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===yY.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&Xe(e)===`template`){let e=n.content;_t(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);_t(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Be=!e,Be&&(e=``),typeof e!=`string`&&!vt(e)&&(e=JTe(e),typeof e!=`string`))throw rY(`dirty is not a string, aborting`);if(!t.isSupported)return e;_e?(ie=ve,ae=ye):et(n),(I.uponSanitizeElement.length>0||I.uponSanitizeAttribute.length>0)&&(ie=oY(ie)),I.uponSanitizeAttribute.length>0&&(ae=oY(ae)),t.removed=[];let c=Oe&&typeof e!=`string`&&vt(e);if(c){let t=b?b(e):e.nodeName;if(typeof t==`string`){let e=Xe(t);if(!ie[e]||se[e])throw rY(`root node is forbidden and cannot be sanitized in-place`)}if(gt(e))throw rY(`root node is clobbered and cannot be sanitized in-place`);try{kt(e)}catch(t){throw ct(e),t}}else if(vt(e))i=ft(``),a=i.ownerDocument.importNode(e,!0),a.nodeType===yY.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),kt(a);else{if(!xe&&!me&&!ge&&e.indexOf(`<`)===-1)return x&&Ce?D(e):e;if(i=ft(e),!i)return xe?null:Ce?S:``}i&&be&&st(i.firstChild);let l=pt(c?e:i);try{for(;o=l.nextNode();)W(o),Dt(o),_t(o.content)&&Ot(o.content)}catch(t){throw c&&ct(e),t}if(c)return UJ(t.removed,e=>{e.element&&dt(e.element)}),me&&ht(e),e;if(xe){if(me&&ht(i),Se)for(s=N.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(ae.shadowroot||ae.shadowrootmode)&&(s=F.call(r,s,!0)),s}let u=ge?i.outerHTML:i.innerHTML;return ge&&ie[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&nY(aEe,i.ownerDocument.doctype.name)&&(u=` +`+u),me&&(u=mt(u)),x&&Ce?D(u):u},t.setConfig=function(){et(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),_e=!0,ve=ie,ye=ae},t.clearConfig=function(){Ze=null,_e=!1,ve=null,ye=null,x=C,S=``},t.isValidAttribute=function(e,t,n){return Ze||et({}),St(Xe(e),Xe(t),n)},t.addHook=function(e,t){typeof t==`function`&&eY(I,e)&&GJ(I[e],t)},t.removeHook=function(e,t){if(eY(I,e)){if(t!==void 0){let n=VTe(I[e],t);return n===-1?void 0:HTe(I[e],n,1)[0]}return WJ(I[e])}},t.removeHooks=function(e){eY(I,e)&&(I[e]=[])},t.removeAllHooks=function(){I=bY()},t}var CY=SY();function wY(e){this.content=e}wY.prototype={constructor:wY,find:function(e){for(var t=0;t>1}},wY.from=function(e){if(e instanceof wY)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new wY(t)};function TY(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=TY(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function EY(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;ee&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);at)for(let e=0,a=0;at&&((an)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?kY(t+1,i):kY(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;ethis.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;te.type.rank-t.type.rank),n}};jY.none=[];var MY=class extends Error{},NY=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=FY(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(PY(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(DY.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};NY.empty=new NY(DY.empty,0,0);function PY(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(PY(a.content,t-i-1,n-i-1)))}function FY(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=FY(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function fEe(e,t,n){if(n.openStart>e.depth)throw new MY(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new MY(`Inconsistent open depths`);return IY(e,t,n,0)}function IY(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function BY(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(zY(e.nodeAfter,r),a++));for(let e=a;ei&&RY(e,t,i+1),o=r.depth>i&&RY(n,r,i+1),s=[];return BY(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(LY(a,o),zY(VY(a,HY(e,t,n,r,i+1)),s)):(a&&zY(VY(a,UY(e,t,i+1)),s),BY(t,n,i,s),o&&zY(VY(o,UY(n,r,i+1)),s)),BY(r,null,i,s),new DY(s)}function UY(e,t,n){let r=[];return BY(null,e,n,r),e.depth>n&&zY(VY(RY(e,t,n+1),UY(e,t,n+1)),r),BY(t,null,n,r),new DY(r)}function pEe(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(DY.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var WY=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new KY(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=GY.get(t);if(r)for(let e=0;ee&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),JY(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=DY.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;ee.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=DY.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};qY.prototype.text=void 0;var _Ee=class e extends qY{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):JY(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function JY(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var YY=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new vEe(t,n);if(r.next==null)return e.empty;let i=XY(r);r.next&&r.err(`Unexpected trailing text`);let a=TEe(wEe(i));return EEe(a,r),a}matchType(e){for(let t=0;te.createAndFill()));for(let e=0;e=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n`+e.indexOf(t.next[n].next);return r}).join(` `)}};YY.empty=new YY(!0);var vEe=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function XY(e){let t=[];do t.push(yEe(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function yEe(e){let t=[];do t.push(bEe(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function bEe(e){let t=CEe(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=xEe(e,t);else break;return t}function ZY(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function xEe(e,t){let n=ZY(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:ZY(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function SEe(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function CEe(e){if(e.eat(`(`)){let t=XY(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=SEe(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function wEe(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new YY(r.indexOf(e.length-1)>-1);for(let e=0;e-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:tX(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new qY(this,this.computeAttrs(e),DY.from(t),jY.setFrom(n))}createChecked(e=null,t,n){return t=DY.from(t),this.checkContent(t),new qY(this,this.computeAttrs(e),t,jY.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=DY.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(DY.empty,!0);return i?new qY(this,e,t.append(i),jY.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function DEe(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var OEe=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?DEe(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},aX=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=rX(e,r.attrs),this.excluded=null;let i=eX(this.attrs);this.instance=i?new jY(this,i):null}create(e=null){return!e&&this.instance?this.instance:new jY(this,tX(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t-1}},oX=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=wY.from(e.nodes),t.marks=wY.from(e.marks||{}),this.nodes=iX.compile(this.spec.nodes,this),this.marks=aX.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=YY.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?sX(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:sX(this,n.split(` `))}this.nodeFromJSON=e=>qY.fromJSON(this,e),this.markFromJSON=e=>jY.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof iX))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new _Ee(n,n.defaultAttrs,e,jY.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function sX(e,t){let n=[];for(let r=0;r-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function kEe(e){return e.tag!=null}function AEe(e){return e.style!=null}var cX=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(kEe(e))this.tags.push(e);else if(AEe(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new gX(this,t,!1);return n.addAll(e,jY.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new gX(this,t,!0);return n.addAll(e,jY.none,t.from,t.to),NY.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;re.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r{n(e=_X(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=_X(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},lX={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},jEe={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},uX={ol:!0,ul:!0},dX=1,fX=2,pX=4;function mX(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?dX:0)|(t===`full`?fX:0)}var hX=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=jY.none,this.match=i||(a&pX?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(DY.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&dX)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=DY.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(DY.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!lX.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},gX=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=mX(null,t.preserveWhitespace,0)|(n?pX:0);i=r?new hX(r.type,r.attrs,jY.none,!0,t.topMatch||r.type.contentMatch,a):n?new hX(null,null,jY.none,!0,null,a):new hX(e.schema.topNodeType,null,jY.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&fX?`full`:this.localPreserveWS||(r.options&dX)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,` `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e(a.type?a.type.allowsMarkType(t.type):vX(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new hX(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=dX);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function MEe(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&uX.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function NEe(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function _X(e){let t={};for(let n in e)t[n]=e[n];return t}function vX(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n{if(i.length||e.marks.length){let n=0,a=0;for(;n=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&CX(xX(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return CX(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=bX(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return bX(e.marks)}};function bX(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function xX(e){return e.document||window.document}var SX=new WeakMap;function PEe(e){let t=SX.get(e);return t===void 0&&SX.set(e,t=FEe(e)),t}function FEe(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;iu)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else{let{dom:t,contentDOM:i}=CX(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var wX=65535,TX=2**16;function IEe(e,t){return e+t*TX}function EX(e){return e&wX}function LEe(e){return(e-(e&wX))/TX}var REe=1,zEe=2,DX=4,OX=8,kX=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&OX)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&DX)>0}},AX=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=EX(e);if(!this.inverted)for(let e=0;ee)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:IEe(o/3,e-s),f=e==s?zEe:e==u?REe:DX;return(t<0?e!=s:e!=u)&&(f|=OX),new kX(a,f,d)}r+=l-c}return n?e+r:new kX(e+r,0,null)}touches(e,t){let n=0,r=EX(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;te)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;nn&&t!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return PX.fromReplace(e,this.from,this.to,i)}invert(){return new LX(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};NX.jsonID(`addMark`,IX);var LX=class e extends NX{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new NY(FX(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return PX.fromReplace(e,this.from,this.to,n)}invert(){return new IX(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};NX.jsonID(`removeMark`,LX);var RX=class e extends NX{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return PX.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return PX.fromReplace(e,this.pos,this.pos+1,new NY(DY.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;rr.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,NY.fromJSON(t,n.slice),n.insert,!!n.structure)}};NX.jsonID(`replaceAround`,VX);function HX(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function BEe(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;ee.step(t)),a.forEach(t=>e.step(t))}function VEe(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof aX){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;ee.step(new LX(t.from,t.to,t.style)))}function UX(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t=0;t--)e.step(o[t])}function HEe(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function WX(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(nn;e--)t||r.index(e)>0?(t=!0,u=DY.from(r.node(e).copy(u)),d++):c--;let f=DY.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=DY.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new VX(i,a,i,a,new NY(r,0,0),n.length,!0))}function qEe(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&JEe(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&JX(e,t,n,a),UX(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new VX(c,l,c+1,l-1,new NY(DY.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&qX(e,t,n,a),!1}})}function qX(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function JX(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(` diff --git a/static/img/sponsors/northpole-3d-printing.jpg b/static/img/sponsors/northpole-3d-printing.jpg deleted file mode 100644 index 8a7c6276d..000000000 Binary files a/static/img/sponsors/northpole-3d-printing.jpg and /dev/null differ diff --git a/static/index.html b/static/index.html index 292eaef9c..6be8263ee 100644 --- a/static/index.html +++ b/static/index.html @@ -26,7 +26,7 @@ - +