diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ed5aa275..25aab9d8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ All notable changes to Bambuddy will be documented in this file. ### Improved - **Queue API Returns More Print Metadata** ([#524](https://github.com/maziggy/bambuddy/issues/524)) — The `GET /api/v1/queue` and `GET /api/v1/queue/{id}` endpoints now include `filament_type`, `filament_color`, `layer_height`, `nozzle_diameter`, and `sliced_for_model` from the archive or library file. Previously these fields were only available via the archive endpoints, requiring an extra API call. +- **Spool Form Profile Dropdown Truncates Long Names** ([#534](https://github.com/maziggy/bambuddy/issues/534)) — Long filament profile names (e.g., "Polymaker Panchroma Matte PLA 0.4 nozzle P1S") were truncated in the spool creation form's preset dropdown because filament ID codes displayed alongside each name consumed horizontal space. Removed the inline filament codes from dropdown items (the selected code is still shown below the input after selection) and widened the modal from `max-w-lg` to `max-w-xl` to give profile names more room. ## [0.2.1b3] - 2026-02-23 diff --git a/frontend/src/components/SpoolFormModal.tsx b/frontend/src/components/SpoolFormModal.tsx index 98c5c7079..f3427ce9d 100644 --- a/frontend/src/components/SpoolFormModal.tsx +++ b/frontend/src/components/SpoolFormModal.tsx @@ -473,7 +473,7 @@ export function SpoolFormModal({ isOpen, onClose, spool, printersWithCalibration onClick={onClose} /> -
+
{/* Header */}

diff --git a/frontend/src/components/spool-form/FilamentSection.tsx b/frontend/src/components/spool-form/FilamentSection.tsx index dd3fd5945..1ee7fb966 100644 --- a/frontend/src/components/spool-form/FilamentSection.tsx +++ b/frontend/src/components/spool-form/FilamentSection.tsx @@ -166,15 +166,14 @@ export function FilamentSection({ )) )} diff --git a/static/assets/index-1Ts9jjQl.css b/static/assets/index-1Ts9jjQl.css deleted file mode 100644 index 2039f6a04..000000000 --- a/static/assets/index-1Ts9jjQl.css +++ /dev/null @@ -1 +0,0 @@ -@import"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap";@layer properties,theme,base,components,utilities;@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-950:oklch(25.8% .092 26.042);--color-orange-200:oklch(90.1% .076 70.697);--color-orange-300:oklch(83.7% .128 66.29);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-600:oklch(64.6% .222 41.116);--color-orange-700:oklch(55.3% .195 38.402);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-yellow-200:oklch(94.5% .129 101.54);--color-yellow-300:oklch(90.5% .182 98.111);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-yellow-600:oklch(68.1% .162 75.834);--color-yellow-700:oklch(55.4% .135 66.442);--color-lime-500:oklch(76.8% .233 130.85);--color-green-100:oklch(96.2% .044 156.743);--color-green-200:oklch(92.5% .084 155.995);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-green-900:oklch(39.3% .095 152.535);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-700:oklch(50.8% .118 165.612);--color-teal-400:oklch(77.7% .152 181.912);--color-teal-500:oklch(70.4% .14 182.503);--color-cyan-300:oklch(86.5% .127 207.078);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-500:oklch(71.5% .143 215.221);--color-cyan-600:oklch(60.9% .126 221.723);--color-sky-400:oklch(74.6% .16 232.661);--color-sky-500:oklch(68.5% .169 237.323);--color-blue-50:oklch(97% .014 254.604);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-indigo-400:oklch(67.3% .182 276.935);--color-indigo-500:oklch(58.5% .233 277.117);--color-violet-500:oklch(60.6% .25 292.717);--color-purple-300:oklch(82.7% .119 306.383);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-500:oklch(62.7% .265 303.9);--color-purple-700:oklch(49.6% .265 301.924);--color-fuchsia-500:oklch(66.7% .295 322.15);--color-rose-300:oklch(81% .117 11.638);--color-rose-400:oklch(71.2% .194 13.428);--color-rose-500:oklch(64.5% .246 16.439);--color-rose-600:oklch(58.6% .253 17.585);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-500:oklch(55.4% .046 257.417);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-gray-900:oklch(21% .034 264.665);--color-zinc-100:oklch(96.7% .001 286.375);--color-zinc-200:oklch(92% .004 286.32);--color-zinc-300:oklch(87.1% .006 286.286);--color-zinc-400:oklch(70.5% .015 286.067);--color-zinc-500:oklch(55.2% .016 285.938);--color-zinc-600:oklch(44.2% .017 285.786);--color-zinc-700:oklch(37% .013 285.805);--color-zinc-800:oklch(27.4% .006 286.033);--color-zinc-900:oklch(21% .006 285.885);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-xl:36rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--container-5xl:64rem;--container-6xl:72rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--text-3xl:1.875rem;--text-3xl--line-height: 1.2 ;--text-4xl:2.25rem;--text-4xl--line-height:calc(2.5/2.25);--text-5xl:3rem;--text-5xl--line-height:1;--font-weight-light:300;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--tracking-wider:.05em;--tracking-widest:.1em;--leading-tight:1.25;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--drop-shadow-md:0 3px 3px #0000001f;--drop-shadow-lg:0 4px 4px #00000026;--ease-out:cubic-bezier(0,0,.2,1);--ease-in-out:cubic-bezier(.4,0,.2,1);--animate-spin:spin 1s linear infinite;--animate-ping:ping 1s cubic-bezier(0,0,.2,1)infinite;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--blur-sm:8px;--blur-2xl:40px;--aspect-video:16/9;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-bambu-green:var(--accent);--color-bambu-green-light:var(--accent-light);--color-bambu-green-dark:var(--accent-dark);--color-status-ok:var(--status-ok);--color-status-error:var(--status-error);--color-status-warning:var(--status-warning);--color-bambu-dark:var(--bg-primary);--color-bambu-dark-secondary:var(--bg-secondary);--color-bambu-dark-tertiary:var(--bg-tertiary);--color-bambu-gray:var(--text-muted);--color-bambu-gray-light:var(--text-secondary);--color-bambu-gray-dark:var(--text-tertiary)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.-inset-4{inset:calc(var(--spacing)*-4)}.inset-0{inset:calc(var(--spacing)*0)}.inset-x-0{inset-inline:calc(var(--spacing)*0)}.inset-y-0{inset-block:calc(var(--spacing)*0)}.-top-0\.5{top:calc(var(--spacing)*-.5)}.-top-1{top:calc(var(--spacing)*-1)}.-top-1\.5{top:calc(var(--spacing)*-1.5)}.top-0{top:calc(var(--spacing)*0)}.top-0\.5{top:calc(var(--spacing)*.5)}.top-1{top:calc(var(--spacing)*1)}.top-1\.5{top:calc(var(--spacing)*1.5)}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing)*2)}.top-2\.5{top:calc(var(--spacing)*2.5)}.top-3{top:calc(var(--spacing)*3)}.top-4{top:calc(var(--spacing)*4)}.top-8{top:calc(var(--spacing)*8)}.top-\[2px\]{top:2px}.top-\[3px\]{top:3px}.top-\[52px\]{top:52px}.top-full{top:100%}.-right-0\.5{right:calc(var(--spacing)*-.5)}.-right-1{right:calc(var(--spacing)*-1)}.-right-1\.5{right:calc(var(--spacing)*-1.5)}.-right-2{right:calc(var(--spacing)*-2)}.right-0{right:calc(var(--spacing)*0)}.right-1{right:calc(var(--spacing)*1)}.right-1\.5{right:calc(var(--spacing)*1.5)}.right-2{right:calc(var(--spacing)*2)}.right-3{right:calc(var(--spacing)*3)}.right-4{right:calc(var(--spacing)*4)}.right-6{right:calc(var(--spacing)*6)}.right-12{right:calc(var(--spacing)*12)}.right-\[5\.5rem\]{right:5.5rem}.right-full{right:100%}.-bottom-1{bottom:calc(var(--spacing)*-1)}.-bottom-2{bottom:calc(var(--spacing)*-2)}.-bottom-7{bottom:calc(var(--spacing)*-7)}.bottom-0{bottom:calc(var(--spacing)*0)}.bottom-1{bottom:calc(var(--spacing)*1)}.bottom-2{bottom:calc(var(--spacing)*2)}.bottom-3{bottom:calc(var(--spacing)*3)}.bottom-4{bottom:calc(var(--spacing)*4)}.bottom-6{bottom:calc(var(--spacing)*6)}.bottom-8{bottom:calc(var(--spacing)*8)}.bottom-full{bottom:100%}.-left-2{left:calc(var(--spacing)*-2)}.left-0{left:calc(var(--spacing)*0)}.left-0\.5{left:calc(var(--spacing)*.5)}.left-1{left:calc(var(--spacing)*1)}.left-1\/2{left:50%}.left-2{left:calc(var(--spacing)*2)}.left-2\.5{left:calc(var(--spacing)*2.5)}.left-3{left:calc(var(--spacing)*3)}.left-4{left:calc(var(--spacing)*4)}.left-10{left:calc(var(--spacing)*10)}.left-12{left:calc(var(--spacing)*12)}.left-\[2px\]{left:2px}.left-\[3px\]{left:3px}.left-full{left:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-60,.z-\[60\]{z-index:60}.z-\[100\]{z-index:100}.col-span-1{grid-column:span 1/span 1}.col-span-2{grid-column:span 2/span 2}.col-span-3{grid-column:span 3/span 3}.col-span-4{grid-column:span 4/span 4}.col-span-full{grid-column:1/-1}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.-m-4{margin:calc(var(--spacing)*-4)}.-mx-4{margin-inline:calc(var(--spacing)*-4)}.mx-1{margin-inline:calc(var(--spacing)*1)}.mx-2{margin-inline:calc(var(--spacing)*2)}.mx-4{margin-inline:calc(var(--spacing)*4)}.mx-auto{margin-inline:auto}.my-1{margin-block:calc(var(--spacing)*1)}.my-8{margin-block:calc(var(--spacing)*8)}.-mt-0\.5{margin-top:calc(var(--spacing)*-.5)}.-mt-2{margin-top:calc(var(--spacing)*-2)}.mt-0\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-1\.5{margin-top:calc(var(--spacing)*1.5)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-6{margin-top:calc(var(--spacing)*6)}.mt-8{margin-top:calc(var(--spacing)*8)}.mt-14{margin-top:calc(var(--spacing)*14)}.mt-auto{margin-top:auto}.mr-1{margin-right:calc(var(--spacing)*1)}.mr-1\.5{margin-right:calc(var(--spacing)*1.5)}.mr-2{margin-right:calc(var(--spacing)*2)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-4{margin-right:calc(var(--spacing)*4)}.mr-auto{margin-right:auto}.-mb-px{margin-bottom:-1px}.mb-0\.5{margin-bottom:calc(var(--spacing)*.5)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-1\.5{margin-bottom:calc(var(--spacing)*1.5)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.mb-5{margin-bottom:calc(var(--spacing)*5)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.-ml-1{margin-left:calc(var(--spacing)*-1)}.-ml-2{margin-left:calc(var(--spacing)*-2)}.ml-0\.5{margin-left:calc(var(--spacing)*.5)}.ml-1{margin-left:calc(var(--spacing)*1)}.ml-1\.5{margin-left:calc(var(--spacing)*1.5)}.ml-2{margin-left:calc(var(--spacing)*2)}.ml-3{margin-left:calc(var(--spacing)*3)}.ml-4{margin-left:calc(var(--spacing)*4)}.ml-6{margin-left:calc(var(--spacing)*6)}.ml-7{margin-left:calc(var(--spacing)*7)}.ml-9{margin-left:calc(var(--spacing)*9)}.ml-14{margin-left:calc(var(--spacing)*14)}.ml-16{margin-left:calc(var(--spacing)*16)}.ml-64{margin-left:calc(var(--spacing)*64)}.ml-auto{margin-left:auto}.line-clamp-1{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.aspect-square{aspect-ratio:1}.aspect-video{aspect-ratio:var(--aspect-video)}.h-0{height:calc(var(--spacing)*0)}.h-0\.5{height:calc(var(--spacing)*.5)}.h-1{height:calc(var(--spacing)*1)}.h-1\.5{height:calc(var(--spacing)*1.5)}.h-2{height:calc(var(--spacing)*2)}.h-2\.5{height:calc(var(--spacing)*2.5)}.h-3{height:calc(var(--spacing)*3)}.h-3\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-10{height:calc(var(--spacing)*10)}.h-11{height:calc(var(--spacing)*11)}.h-12{height:calc(var(--spacing)*12)}.h-14{height:calc(var(--spacing)*14)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-24{height:calc(var(--spacing)*24)}.h-32{height:calc(var(--spacing)*32)}.h-40{height:calc(var(--spacing)*40)}.h-48{height:calc(var(--spacing)*48)}.h-64{height:calc(var(--spacing)*64)}.h-80{height:calc(var(--spacing)*80)}.h-\[18px\]{height:18px}.h-\[38px\]{height:38px}.h-\[80vh\]{height:80vh}.h-\[160px\]{height:160px}.h-\[300px\]{height:300px}.h-\[calc\(100\%-40px\)\]{height:calc(100% - 40px)}.h-full{height:100%}.h-px{height:1px}.h-screen{height:100vh}.max-h-40{max-height:calc(var(--spacing)*40)}.max-h-48{max-height:calc(var(--spacing)*48)}.max-h-60{max-height:calc(var(--spacing)*60)}.max-h-64{max-height:calc(var(--spacing)*64)}.max-h-80{max-height:calc(var(--spacing)*80)}.max-h-96{max-height:calc(var(--spacing)*96)}.max-h-\[60vh\]{max-height:60vh}.max-h-\[80vh\]{max-height:80vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[300px\]{max-height:300px}.max-h-\[400px\]{max-height:400px}.max-h-\[500px\]{max-height:500px}.max-h-\[600px\]{max-height:600px}.max-h-\[calc\(90vh-80px\)\]{max-height:calc(90vh - 80px)}.max-h-\[calc\(100vh-320px\)\]{max-height:calc(100vh - 320px)}.max-h-full{max-height:100%}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-\[40px\]{min-height:40px}.min-h-\[44px\]{min-height:44px}.min-h-\[48px\]{min-height:48px}.min-h-\[80px\]{min-height:80px}.min-h-\[120px\]{min-height:120px}.min-h-\[300px\]{min-height:300px}.min-h-\[400px\]{min-height:400px}.min-h-\[calc\(100vh-64px\)\]{min-height:calc(100vh - 64px)}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-0{width:calc(var(--spacing)*0)}.w-0\.5{width:calc(var(--spacing)*.5)}.w-1{width:calc(var(--spacing)*1)}.w-1\.5{width:calc(var(--spacing)*1.5)}.w-1\/3{width:33.3333%}.w-2{width:calc(var(--spacing)*2)}.w-2\.5{width:calc(var(--spacing)*2.5)}.w-2\/3{width:66.6667%}.w-3{width:calc(var(--spacing)*3)}.w-3\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-4\.5{width:calc(var(--spacing)*4.5)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-8{width:calc(var(--spacing)*8)}.w-9{width:calc(var(--spacing)*9)}.w-10{width:calc(var(--spacing)*10)}.w-11{width:calc(var(--spacing)*11)}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.w-16{width:calc(var(--spacing)*16)}.w-20{width:calc(var(--spacing)*20)}.w-24{width:calc(var(--spacing)*24)}.w-32{width:calc(var(--spacing)*32)}.w-36{width:calc(var(--spacing)*36)}.w-40{width:calc(var(--spacing)*40)}.w-44{width:calc(var(--spacing)*44)}.w-48{width:calc(var(--spacing)*48)}.w-52{width:calc(var(--spacing)*52)}.w-56{width:calc(var(--spacing)*56)}.w-64{width:calc(var(--spacing)*64)}.w-72{width:calc(var(--spacing)*72)}.w-96{width:calc(var(--spacing)*96)}.w-\[420px\]{width:420px}.w-\[560px\]{width:560px}.w-auto{width:auto}.w-fit{width:fit-content}.w-full{width:100%}.w-px{width:1px}.w-screen{width:100vw}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-5xl{max-width:var(--container-5xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-32{max-width:calc(var(--spacing)*32)}.max-w-\[40\%\]{max-width:40%}.max-w-\[50\%\]{max-width:50%}.max-w-\[80px\]{max-width:80px}.max-w-\[90vw\]{max-width:90vw}.max-w-\[100px\]{max-width:100px}.max-w-\[120px\]{max-width:120px}.max-w-\[150px\]{max-width:150px}.max-w-\[160px\]{max-width:160px}.max-w-\[200px\]{max-width:200px}.max-w-\[280px\]{max-width:280px}.max-w-\[600px\]{max-width:600px}.max-w-full{max-width:100%}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-48{min-width:calc(var(--spacing)*48)}.min-w-\[16px\]{min-width:16px}.min-w-\[18px\]{min-width:18px}.min-w-\[32px\]{min-width:32px}.min-w-\[40px\]{min-width:40px}.min-w-\[48px\]{min-width:48px}.min-w-\[50px\]{min-width:50px}.min-w-\[80px\]{min-width:80px}.min-w-\[100px\]{min-width:100px}.min-w-\[120px\]{min-width:120px}.min-w-\[140px\]{min-width:140px}.min-w-\[150px\]{min-width:150px}.min-w-\[160px\]{min-width:160px}.min-w-\[180px\]{min-width:180px}.min-w-\[200px\]{min-width:200px}.min-w-full{min-width:100%}.flex-1{flex:1}.flex-\[2_1_190px\]{flex:2 190px}.flex-shrink{flex-shrink:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-x-full{--tw-translate-x:-100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0\.5{--tw-translate-x:calc(var(--spacing)*.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-1{--tw-translate-x:calc(var(--spacing)*1);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-3\.5{--tw-translate-x:calc(var(--spacing)*3.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-4{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-5{--tw-translate-x:calc(var(--spacing)*5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-6{--tw-translate-x:calc(var(--spacing)*6);translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.scale-105{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-\[1\.02\]{scale:1.02}.-rotate-90{rotate:-90deg}.rotate-90{rotate:90deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-col-resize{cursor:col-resize}.cursor-default{cursor:default}.cursor-ew-resize{cursor:ew-resize}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-row-resize{cursor:row-resize}.cursor-se-resize{cursor:se-resize}.touch-manipulation{touch-action:manipulation}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.appearance-none{appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}.grid-cols-\[auto_1fr_100px_100px_100px_80px\]{grid-template-columns:auto 1fr 100px 100px 100px 80px}.grid-cols-\[auto_1fr_120px_100px_100px_100px_80px\]{grid-template-columns:auto 1fr 120px 100px 100px 100px 80px}.flex-col{flex-direction:column}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0{gap:calc(var(--spacing)*0)}.gap-0\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-6{gap:calc(var(--spacing)*6)}.gap-8{gap:calc(var(--spacing)*8)}.gap-\[3px\]{gap:3px}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*4)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*4)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*6)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*6)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}.gap-x-3{column-gap:calc(var(--spacing)*3)}.gap-x-4{column-gap:calc(var(--spacing)*4)}.gap-x-6{column-gap:calc(var(--spacing)*6)}.gap-y-1{row-gap:calc(var(--spacing)*1)}.gap-y-2{row-gap:calc(var(--spacing)*2)}.gap-y-3{row-gap:calc(var(--spacing)*3)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px*var(--tw-divide-y-reverse));border-bottom-width:calc(1px*calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-bambu-dark-tertiary>:not(:last-child)),:where(.divide-bambu-dark-tertiary\/30>:not(:last-child)){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){:where(.divide-bambu-dark-tertiary\/30>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}:where(.divide-bambu-gray\/20>:not(:last-child)){border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){:where(.divide-bambu-gray\/20>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-none{border-radius:0}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-t-lg{border-top-left-radius:var(--radius-lg);border-top-right-radius:var(--radius-lg)}.rounded-t-xl{border-top-left-radius:var(--radius-xl);border-top-right-radius:var(--radius-xl)}.\!rounded-l-none{border-top-left-radius:0!important;border-bottom-left-radius:0!important}.rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-l-lg{border-top-left-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.rounded-tl{border-top-left-radius:.25rem}.\!rounded-r-none{border-top-right-radius:0!important;border-bottom-right-radius:0!important}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.rounded-r-lg{border-top-right-radius:var(--radius-lg);border-bottom-right-radius:var(--radius-lg)}.rounded-b-lg{border-bottom-right-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-4{border-style:var(--tw-border-style);border-width:4px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-2{border-top-style:var(--tw-border-style);border-top-width:2px}.border-t-\[5px\]{border-top-style:var(--tw-border-style);border-top-width:5px}.border-t-\[6px\]{border-top-style:var(--tw-border-style);border-top-width:6px}.\!border-r-0{border-right-style:var(--tw-border-style)!important;border-right-width:0!important}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-\[5px\]{border-right-style:var(--tw-border-style);border-right-width:5px}.border-r-\[6px\]{border-right-style:var(--tw-border-style);border-right-width:6px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-b-\[6px\]{border-bottom-style:var(--tw-border-style);border-bottom-width:6px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-l-\[5px\]{border-left-style:var(--tw-border-style);border-left-width:5px}.border-l-\[6px\]{border-left-style:var(--tw-border-style);border-left-width:6px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.\!border-green-500{border-color:var(--color-green-500)!important}.border-amber-500{border-color:var(--color-amber-500)}.border-amber-500\/20{border-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/20{border-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.border-amber-500\/30{border-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/30{border-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.border-bambu-dark-secondary{border-color:var(--color-bambu-dark-secondary)}.border-bambu-dark-tertiary,.border-bambu-dark-tertiary\/20{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/20{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)20%,transparent)}}.border-bambu-dark-tertiary\/30{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/30{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.border-bambu-dark-tertiary\/40{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/40{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.border-bambu-dark-tertiary\/50{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/50{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.border-bambu-gray,.border-bambu-gray\/20{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/20{border-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.border-bambu-gray\/30{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/30{border-color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.border-bambu-gray\/50{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/50{border-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.border-bambu-green,.border-bambu-green\/20{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/20{border-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.border-bambu-green\/30{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/30{border-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.border-bambu-green\/40{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/40{border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.border-bambu-green\/50{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/50{border-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.border-blue-400\/20{border-color:#54a2ff33}@supports (color:color-mix(in lab,red,red)){.border-blue-400\/20{border-color:color-mix(in oklab,var(--color-blue-400)20%,transparent)}}.border-blue-400\/50{border-color:#54a2ff80}@supports (color:color-mix(in lab,red,red)){.border-blue-400\/50{border-color:color-mix(in oklab,var(--color-blue-400)50%,transparent)}}.border-blue-500{border-color:var(--color-blue-500)}.border-blue-500\/20{border-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/20{border-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.border-blue-500\/30{border-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/30{border-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.border-blue-500\/50{border-color:#3080ff80}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/50{border-color:color-mix(in oklab,var(--color-blue-500)50%,transparent)}}.border-gray-200{border-color:var(--color-gray-200)}.border-gray-300{border-color:var(--color-gray-300)}.border-gray-400\/20{border-color:#99a1af33}@supports (color:color-mix(in lab,red,red)){.border-gray-400\/20{border-color:color-mix(in oklab,var(--color-gray-400)20%,transparent)}}.border-gray-500{border-color:var(--color-gray-500)}.border-gray-500\/20{border-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.border-gray-500\/20{border-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.border-gray-700{border-color:var(--color-gray-700)}.border-green-300{border-color:var(--color-green-300)}.border-green-500{border-color:var(--color-green-500)}.border-green-500\/10{border-color:#00c7581a}@supports (color:color-mix(in lab,red,red)){.border-green-500\/10{border-color:color-mix(in oklab,var(--color-green-500)10%,transparent)}}.border-green-500\/20{border-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.border-green-500\/20{border-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500)30%,transparent)}}.border-green-500\/50{border-color:#00c75880}@supports (color:color-mix(in lab,red,red)){.border-green-500\/50{border-color:color-mix(in oklab,var(--color-green-500)50%,transparent)}}.border-orange-400\/20{border-color:#ff8b1a33}@supports (color:color-mix(in lab,red,red)){.border-orange-400\/20{border-color:color-mix(in oklab,var(--color-orange-400)20%,transparent)}}.border-orange-400\/50{border-color:#ff8b1a80}@supports (color:color-mix(in lab,red,red)){.border-orange-400\/50{border-color:color-mix(in oklab,var(--color-orange-400)50%,transparent)}}.border-orange-500\/20{border-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/20{border-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.border-orange-500\/30{border-color:#fe6e004d}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/30{border-color:color-mix(in oklab,var(--color-orange-500)30%,transparent)}}.border-purple-400\/20{border-color:#c07eff33}@supports (color:color-mix(in lab,red,red)){.border-purple-400\/20{border-color:color-mix(in oklab,var(--color-purple-400)20%,transparent)}}.border-purple-500\/20{border-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/20{border-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.border-purple-500\/30{border-color:#ac4bff4d}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/30{border-color:color-mix(in oklab,var(--color-purple-500)30%,transparent)}}.border-red-300{border-color:var(--color-red-300)}.border-red-500{border-color:var(--color-red-500)}.border-red-500\/20{border-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.border-red-500\/20{border-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.border-red-500\/50{border-color:#fb2c3680}@supports (color:color-mix(in lab,red,red)){.border-red-500\/50{border-color:color-mix(in oklab,var(--color-red-500)50%,transparent)}}.border-red-800\/70{border-color:#9f0712b3}@supports (color:color-mix(in lab,red,red)){.border-red-800\/70{border-color:color-mix(in oklab,var(--color-red-800)70%,transparent)}}.border-slate-500{border-color:var(--color-slate-500)}.border-status-error\/20{border-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.border-status-error\/20{border-color:color-mix(in oklab,var(--color-status-error)20%,transparent)}}.border-status-ok,.border-status-ok\/20{border-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.border-status-ok\/20{border-color:color-mix(in oklab,var(--color-status-ok)20%,transparent)}}.border-status-warning\/20{border-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.border-status-warning\/20{border-color:color-mix(in oklab,var(--color-status-warning)20%,transparent)}}.border-transparent{border-color:#0000}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.border-white\/20{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.border-white\/20{border-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.border-white\/30{border-color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.border-white\/30{border-color:color-mix(in oklab,var(--color-white)30%,transparent)}}.border-yellow-400\/20{border-color:#fac80033}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/20{border-color:color-mix(in oklab,var(--color-yellow-400)20%,transparent)}}.border-yellow-400\/30{border-color:#fac8004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/30{border-color:color-mix(in oklab,var(--color-yellow-400)30%,transparent)}}.border-yellow-400\/50{border-color:#fac80080}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/50{border-color:color-mix(in oklab,var(--color-yellow-400)50%,transparent)}}.border-yellow-500{border-color:var(--color-yellow-500)}.border-yellow-500\/20{border-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/20{border-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.border-yellow-500\/30{border-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/30{border-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.border-yellow-500\/50{border-color:#edb20080}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/50{border-color:color-mix(in oklab,var(--color-yellow-500)50%,transparent)}}.border-zinc-500{border-color:var(--color-zinc-500)}.border-zinc-600{border-color:var(--color-zinc-600)}.border-zinc-700{border-color:var(--color-zinc-700)}.border-t-bambu-dark-tertiary{border-top-color:var(--color-bambu-dark-tertiary)}.border-t-transparent{border-top-color:#0000}.border-r-transparent{border-right-color:#0000}.border-b-bambu-dark-tertiary{border-bottom-color:var(--color-bambu-dark-tertiary)}.border-l-transparent{border-left-color:#0000}.border-l-yellow-500{border-left-color:var(--color-yellow-500)}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-500\/5{background-color:#f99c000d}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/5{background-color:color-mix(in oklab,var(--color-amber-500)5%,transparent)}}.bg-amber-500\/10{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/10{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.bg-amber-500\/20{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/20{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.bg-amber-600\/20{background-color:#dd740033}@supports (color:color-mix(in lab,red,red)){.bg-amber-600\/20{background-color:color-mix(in oklab,var(--color-amber-600)20%,transparent)}}.bg-bambu-dark{background-color:var(--color-bambu-dark)}.bg-bambu-dark-secondary,.bg-bambu-dark-secondary\/30{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/30{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)30%,transparent)}}.bg-bambu-dark-secondary\/50{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/50{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)50%,transparent)}}.bg-bambu-dark-secondary\/60{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/60{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)60%,transparent)}}.bg-bambu-dark-secondary\/90{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/90{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)90%,transparent)}}.bg-bambu-dark-secondary\/95{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/95{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)95%,transparent)}}.bg-bambu-dark-tertiary,.bg-bambu-dark-tertiary\/20{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/20{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)20%,transparent)}}.bg-bambu-dark-tertiary\/30{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/30{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.bg-bambu-dark-tertiary\/40{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/40{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.bg-bambu-dark-tertiary\/50{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/50{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.bg-bambu-dark-tertiary\/70{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/70{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)70%,transparent)}}.bg-bambu-dark-tertiary\/80{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/80{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.bg-bambu-dark\/20{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/20{background-color:color-mix(in oklab,var(--color-bambu-dark)20%,transparent)}}.bg-bambu-dark\/30{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/30{background-color:color-mix(in oklab,var(--color-bambu-dark)30%,transparent)}}.bg-bambu-dark\/50{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/50{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.bg-bambu-dark\/80{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/80{background-color:color-mix(in oklab,var(--color-bambu-dark)80%,transparent)}}.bg-bambu-dark\/90{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/90{background-color:color-mix(in oklab,var(--color-bambu-dark)90%,transparent)}}.bg-bambu-gray,.bg-bambu-gray\/10{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/10{background-color:color-mix(in oklab,var(--color-bambu-gray)10%,transparent)}}.bg-bambu-gray\/20{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/20{background-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.bg-bambu-gray\/30{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/30{background-color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.bg-bambu-gray\/50{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/50{background-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.bg-bambu-gray\/60{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/60{background-color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.bg-bambu-gray\/90{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/90{background-color:color-mix(in oklab,var(--color-bambu-gray)90%,transparent)}}.bg-bambu-green,.bg-bambu-green\/5{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/5{background-color:color-mix(in oklab,var(--color-bambu-green)5%,transparent)}}.bg-bambu-green\/10{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/10{background-color:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.bg-bambu-green\/20{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/20{background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.bg-bambu-green\/30{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/30{background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.bg-bambu-green\/50{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/50{background-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.bg-bambu-green\/75{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/75{background-color:color-mix(in oklab,var(--color-bambu-green)75%,transparent)}}.bg-bambu-green\/90{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/90{background-color:color-mix(in oklab,var(--color-bambu-green)90%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/15{background-color:#00000026}@supports (color:color-mix(in lab,red,red)){.bg-black\/15{background-color:color-mix(in oklab,var(--color-black)15%,transparent)}}.bg-black\/30{background-color:#0000004d}@supports (color:color-mix(in lab,red,red)){.bg-black\/30{background-color:color-mix(in oklab,var(--color-black)30%,transparent)}}.bg-black\/40{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.bg-black\/40{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black)60%,transparent)}}.bg-black\/70{background-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.bg-black\/70{background-color:color-mix(in oklab,var(--color-black)70%,transparent)}}.bg-black\/80{background-color:#000c}@supports (color:color-mix(in lab,red,red)){.bg-black\/80{background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.bg-black\/90{background-color:#000000e6}@supports (color:color-mix(in lab,red,red)){.bg-black\/90{background-color:color-mix(in oklab,var(--color-black)90%,transparent)}}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-blue-400{background-color:var(--color-blue-400)}.bg-blue-400\/10{background-color:#54a2ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-400\/10{background-color:color-mix(in oklab,var(--color-blue-400)10%,transparent)}}.bg-blue-500{background-color:var(--color-blue-500)}.bg-blue-500\/5{background-color:#3080ff0d}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/5{background-color:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.bg-blue-500\/10{background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/10{background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.bg-blue-500\/20{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/20{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.bg-blue-500\/30{background-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/30{background-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.bg-blue-500\/90{background-color:#3080ffe6}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/90{background-color:color-mix(in oklab,var(--color-blue-500)90%,transparent)}}.bg-blue-600{background-color:var(--color-blue-600)}.bg-blue-600\/20{background-color:#155dfc33}@supports (color:color-mix(in lab,red,red)){.bg-blue-600\/20{background-color:color-mix(in oklab,var(--color-blue-600)20%,transparent)}}.bg-cyan-500{background-color:var(--color-cyan-500)}.bg-cyan-500\/10{background-color:#00b7d71a}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/10{background-color:color-mix(in oklab,var(--color-cyan-500)10%,transparent)}}.bg-cyan-500\/20{background-color:#00b7d733}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/20{background-color:color-mix(in oklab,var(--color-cyan-500)20%,transparent)}}.bg-cyan-600\/20{background-color:#0092b533}@supports (color:color-mix(in lab,red,red)){.bg-cyan-600\/20{background-color:color-mix(in oklab,var(--color-cyan-600)20%,transparent)}}.bg-emerald-500\/20{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/20{background-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.bg-emerald-700{background-color:var(--color-emerald-700)}.bg-fuchsia-500{background-color:var(--color-fuchsia-500)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-100{background-color:var(--color-gray-100)}.bg-gray-400{background-color:var(--color-gray-400)}.bg-gray-400\/10{background-color:#99a1af1a}@supports (color:color-mix(in lab,red,red)){.bg-gray-400\/10{background-color:color-mix(in oklab,var(--color-gray-400)10%,transparent)}}.bg-gray-500{background-color:var(--color-gray-500)}.bg-gray-500\/20{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.bg-gray-500\/20{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.bg-gray-600{background-color:var(--color-gray-600)}.bg-gray-800{background-color:var(--color-gray-800)}.bg-gray-900{background-color:var(--color-gray-900)}.bg-green-100{background-color:var(--color-green-100)}.bg-green-400{background-color:var(--color-green-400)}.bg-green-500{background-color:var(--color-green-500)}.bg-green-500\/10{background-color:#00c7581a}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/10{background-color:color-mix(in oklab,var(--color-green-500)10%,transparent)}}.bg-green-500\/15{background-color:#00c75826}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/15{background-color:color-mix(in oklab,var(--color-green-500)15%,transparent)}}.bg-green-500\/20{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/20{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.bg-green-600{background-color:var(--color-green-600)}.bg-green-600\/20{background-color:#00a54433}@supports (color:color-mix(in lab,red,red)){.bg-green-600\/20{background-color:color-mix(in oklab,var(--color-green-600)20%,transparent)}}.bg-green-900\/50{background-color:#0d542b80}@supports (color:color-mix(in lab,red,red)){.bg-green-900\/50{background-color:color-mix(in oklab,var(--color-green-900)50%,transparent)}}.bg-indigo-500\/20{background-color:#625fff33}@supports (color:color-mix(in lab,red,red)){.bg-indigo-500\/20{background-color:color-mix(in oklab,var(--color-indigo-500)20%,transparent)}}.bg-lime-500{background-color:var(--color-lime-500)}.bg-orange-400\/10{background-color:#ff8b1a1a}@supports (color:color-mix(in lab,red,red)){.bg-orange-400\/10{background-color:color-mix(in oklab,var(--color-orange-400)10%,transparent)}}.bg-orange-500{background-color:var(--color-orange-500)}.bg-orange-500\/10{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/10{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.bg-orange-500\/20{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/20{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.bg-orange-600{background-color:var(--color-orange-600)}.bg-orange-600\/20{background-color:#f0510033}@supports (color:color-mix(in lab,red,red)){.bg-orange-600\/20{background-color:color-mix(in oklab,var(--color-orange-600)20%,transparent)}}.bg-purple-400\/10{background-color:#c07eff1a}@supports (color:color-mix(in lab,red,red)){.bg-purple-400\/10{background-color:color-mix(in oklab,var(--color-purple-400)10%,transparent)}}.bg-purple-500{background-color:var(--color-purple-500)}.bg-purple-500\/10{background-color:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/10{background-color:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.bg-purple-500\/20{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/20{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.bg-purple-500\/80{background-color:#ac4bffcc}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/80{background-color:color-mix(in oklab,var(--color-purple-500)80%,transparent)}}.bg-purple-500\/90{background-color:#ac4bffe6}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/90{background-color:color-mix(in oklab,var(--color-purple-500)90%,transparent)}}.bg-purple-700{background-color:var(--color-purple-700)}.bg-red-50{background-color:var(--color-red-50)}.bg-red-100{background-color:var(--color-red-100)}.bg-red-400{background-color:var(--color-red-400)}.bg-red-500{background-color:var(--color-red-500)}.bg-red-500\/5{background-color:#fb2c360d}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/5{background-color:color-mix(in oklab,var(--color-red-500)5%,transparent)}}.bg-red-500\/10{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/10{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.bg-red-500\/15{background-color:#fb2c3626}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/15{background-color:color-mix(in oklab,var(--color-red-500)15%,transparent)}}.bg-red-500\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.bg-red-500\/30{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/30{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.bg-red-500\/40{background-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/40{background-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.bg-red-500\/80{background-color:#fb2c36cc}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/80{background-color:color-mix(in oklab,var(--color-red-500)80%,transparent)}}.bg-red-600{background-color:var(--color-red-600)}.bg-red-950\/70{background-color:#460809b3}@supports (color:color-mix(in lab,red,red)){.bg-red-950\/70{background-color:color-mix(in oklab,var(--color-red-950)70%,transparent)}}.bg-rose-500\/20{background-color:#ff235733}@supports (color:color-mix(in lab,red,red)){.bg-rose-500\/20{background-color:color-mix(in oklab,var(--color-rose-500)20%,transparent)}}.bg-rose-600\/20{background-color:#e7004433}@supports (color:color-mix(in lab,red,red)){.bg-rose-600\/20{background-color:color-mix(in oklab,var(--color-rose-600)20%,transparent)}}.bg-sky-500{background-color:var(--color-sky-500)}.bg-sky-500\/20{background-color:#00a5ef33}@supports (color:color-mix(in lab,red,red)){.bg-sky-500\/20{background-color:color-mix(in oklab,var(--color-sky-500)20%,transparent)}}.bg-status-error,.bg-status-error\/10{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/10{background-color:color-mix(in oklab,var(--color-status-error)10%,transparent)}}.bg-status-error\/20{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/20{background-color:color-mix(in oklab,var(--color-status-error)20%,transparent)}}.bg-status-error\/80{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/80{background-color:color-mix(in oklab,var(--color-status-error)80%,transparent)}}.bg-status-ok,.bg-status-ok\/10{background-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.bg-status-ok\/10{background-color:color-mix(in oklab,var(--color-status-ok)10%,transparent)}}.bg-status-ok\/20{background-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.bg-status-ok\/20{background-color:color-mix(in oklab,var(--color-status-ok)20%,transparent)}}.bg-status-warning\/10{background-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.bg-status-warning\/10{background-color:color-mix(in oklab,var(--color-status-warning)10%,transparent)}}.bg-status-warning\/20{background-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.bg-status-warning\/20{background-color:color-mix(in oklab,var(--color-status-warning)20%,transparent)}}.bg-teal-500{background-color:var(--color-teal-500)}.bg-teal-500\/20{background-color:#00baa733}@supports (color:color-mix(in lab,red,red)){.bg-teal-500\/20{background-color:color-mix(in oklab,var(--color-teal-500)20%,transparent)}}.bg-transparent{background-color:#0000}.bg-violet-500{background-color:var(--color-violet-500)}.bg-white{background-color:var(--color-white)}.bg-white\/10{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.bg-white\/10{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.bg-white\/20{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.bg-white\/20{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.bg-white\/50{background-color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.bg-white\/50{background-color:color-mix(in oklab,var(--color-white)50%,transparent)}}.bg-white\/70{background-color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.bg-white\/70{background-color:color-mix(in oklab,var(--color-white)70%,transparent)}}.bg-white\/90{background-color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.bg-white\/90{background-color:color-mix(in oklab,var(--color-white)90%,transparent)}}.bg-yellow-400{background-color:var(--color-yellow-400)}.bg-yellow-400\/10{background-color:#fac8001a}@supports (color:color-mix(in lab,red,red)){.bg-yellow-400\/10{background-color:color-mix(in oklab,var(--color-yellow-400)10%,transparent)}}.bg-yellow-400\/20{background-color:#fac80033}@supports (color:color-mix(in lab,red,red)){.bg-yellow-400\/20{background-color:color-mix(in oklab,var(--color-yellow-400)20%,transparent)}}.bg-yellow-500{background-color:var(--color-yellow-500)}.bg-yellow-500\/5{background-color:#edb2000d}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/5{background-color:color-mix(in oklab,var(--color-yellow-500)5%,transparent)}}.bg-yellow-500\/10{background-color:#edb2001a}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/10{background-color:color-mix(in oklab,var(--color-yellow-500)10%,transparent)}}.bg-yellow-500\/20{background-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/20{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.bg-zinc-600{background-color:var(--color-zinc-600)}.bg-zinc-700{background-color:var(--color-zinc-700)}.bg-zinc-800{background-color:var(--color-zinc-800)}.bg-zinc-900{background-color:var(--color-zinc-900)}.bg-gradient-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-r{--tw-gradient-position:to right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-t{--tw-gradient-position:to top in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-bambu-dark-secondary{--tw-gradient-from:var(--color-bambu-dark-secondary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-bambu-green\/10{--tw-gradient-from:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.from-bambu-green\/10{--tw-gradient-from:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.from-bambu-green\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-black\/80{--tw-gradient-from:#000c}@supports (color:color-mix(in lab,red,red)){.from-black\/80{--tw-gradient-from:color-mix(in oklab,var(--color-black)80%,transparent)}}.from-black\/80{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/5{--tw-gradient-from:#3080ff0d}@supports (color:color-mix(in lab,red,red)){.from-blue-500\/5{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.from-blue-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/10{--tw-gradient-from:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.from-blue-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.from-blue-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-gray-500\/10{--tw-gradient-from:#6a72821a}@supports (color:color-mix(in lab,red,red)){.from-gray-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-gray-500)10%,transparent)}}.from-gray-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-purple-500\/10{--tw-gradient-from:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.from-purple-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.from-purple-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-white\/10{--tw-gradient-from:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.from-white\/10{--tw-gradient-from:color-mix(in oklab,var(--color-white)10%,transparent)}}.from-white\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-yellow-500\/10{--tw-gradient-from:#edb2001a}@supports (color:color-mix(in lab,red,red)){.from-yellow-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-yellow-500)10%,transparent)}}.from-yellow-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.via-black\/60{--tw-gradient-via:#0009}@supports (color:color-mix(in lab,red,red)){.via-black\/60{--tw-gradient-via:color-mix(in oklab,var(--color-black)60%,transparent)}}.via-black\/60{--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-via)var(--tw-gradient-via-position),var(--tw-gradient-to)var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-bambu-dark-secondary{--tw-gradient-to:var(--color-bambu-dark-secondary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-bambu-dark-tertiary{--tw-gradient-to:var(--color-bambu-dark-tertiary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-transparent{--tw-gradient-to:transparent;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.bg-cover{background-size:cover}.bg-center{background-position:50%}.fill-yellow-400{fill:var(--color-yellow-400)}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.object-left{object-position:left}.p-0{padding:calc(var(--spacing)*0)}.p-0\.5{padding:calc(var(--spacing)*.5)}.p-1{padding:calc(var(--spacing)*1)}.p-1\.5{padding:calc(var(--spacing)*1.5)}.p-2{padding:calc(var(--spacing)*2)}.p-2\.5{padding:calc(var(--spacing)*2.5)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.p-8{padding:calc(var(--spacing)*8)}.p-12{padding:calc(var(--spacing)*12)}.\!px-1\.5{padding-inline:calc(var(--spacing)*1.5)!important}.\!px-3{padding-inline:calc(var(--spacing)*3)!important}.px-1{padding-inline:calc(var(--spacing)*1)}.px-1\.5{padding-inline:calc(var(--spacing)*1.5)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-2\.5{padding-inline:calc(var(--spacing)*2.5)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-5{padding-inline:calc(var(--spacing)*5)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-0\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-6{padding-block:calc(var(--spacing)*6)}.py-8{padding-block:calc(var(--spacing)*8)}.py-12{padding-block:calc(var(--spacing)*12)}.py-16{padding-block:calc(var(--spacing)*16)}.py-20{padding-block:calc(var(--spacing)*20)}.py-24{padding-block:calc(var(--spacing)*24)}.pt-0{padding-top:calc(var(--spacing)*0)}.pt-1{padding-top:calc(var(--spacing)*1)}.pt-2{padding-top:calc(var(--spacing)*2)}.pt-3{padding-top:calc(var(--spacing)*3)}.pt-4{padding-top:calc(var(--spacing)*4)}.pr-1{padding-right:calc(var(--spacing)*1)}.pr-2{padding-right:calc(var(--spacing)*2)}.pr-3{padding-right:calc(var(--spacing)*3)}.pr-4{padding-right:calc(var(--spacing)*4)}.pr-6{padding-right:calc(var(--spacing)*6)}.pr-7{padding-right:calc(var(--spacing)*7)}.pr-8{padding-right:calc(var(--spacing)*8)}.pr-10{padding-right:calc(var(--spacing)*10)}.pb-1{padding-bottom:calc(var(--spacing)*1)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pl-2{padding-left:calc(var(--spacing)*2)}.pl-4{padding-left:calc(var(--spacing)*4)}.pl-6{padding-left:calc(var(--spacing)*6)}.pl-7{padding-left:calc(var(--spacing)*7)}.pl-8{padding-left:calc(var(--spacing)*8)}.pl-9{padding-left:calc(var(--spacing)*9)}.pl-10{padding-left:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.text-5xl{font-size:var(--text-5xl);line-height:var(--tw-leading,var(--text-5xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[7px\]{font-size:7px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-none{--tw-leading:1;line-height:1}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-light{--tw-font-weight:var(--font-weight-light);font-weight:var(--font-weight-light)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.\!text-green-400{color:var(--color-green-400)!important}.text-amber-200{color:var(--color-amber-200)}.text-amber-300{color:var(--color-amber-300)}.text-amber-300\/60{color:#ffd23699}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/60{color:color-mix(in oklab,var(--color-amber-300)60%,transparent)}}.text-amber-300\/70{color:#ffd236b3}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/70{color:color-mix(in oklab,var(--color-amber-300)70%,transparent)}}.text-amber-300\/80{color:#ffd236cc}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/80{color:color-mix(in oklab,var(--color-amber-300)80%,transparent)}}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/70{color:#fcbb00b3}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/70{color:color-mix(in oklab,var(--color-amber-400)70%,transparent)}}.text-amber-500{color:var(--color-amber-500)}.text-amber-500\/80{color:#f99c00cc}@supports (color:color-mix(in lab,red,red)){.text-amber-500\/80{color:color-mix(in oklab,var(--color-amber-500)80%,transparent)}}.text-amber-600{color:var(--color-amber-600)}.text-bambu-dark-tertiary{color:var(--color-bambu-dark-tertiary)}.text-bambu-gray{color:var(--color-bambu-gray)}.text-bambu-gray-dark{color:var(--color-bambu-gray-dark)}.text-bambu-gray-light{color:var(--color-bambu-gray-light)}.text-bambu-gray\/30{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/30{color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.text-bambu-gray\/40{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/40{color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.text-bambu-gray\/50{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/50{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.text-bambu-gray\/60{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/60{color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.text-bambu-gray\/70{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/70{color:color-mix(in oklab,var(--color-bambu-gray)70%,transparent)}}.text-bambu-gray\/80{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/80{color:color-mix(in oklab,var(--color-bambu-gray)80%,transparent)}}.text-bambu-green,.text-bambu-green\/70{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.text-bambu-green\/70{color:color-mix(in oklab,var(--color-bambu-green)70%,transparent)}}.text-black{color:var(--color-black)}.text-black\/80{color:#000c}@supports (color:color-mix(in lab,red,red)){.text-black\/80{color:color-mix(in oklab,var(--color-black)80%,transparent)}}.text-blue-300{color:var(--color-blue-300)}.text-blue-300\/70{color:#90c5ffb3}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/70{color:color-mix(in oklab,var(--color-blue-300)70%,transparent)}}.text-blue-300\/80{color:#90c5ffcc}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/80{color:color-mix(in oklab,var(--color-blue-300)80%,transparent)}}.text-blue-400{color:var(--color-blue-400)}.text-blue-500{color:var(--color-blue-500)}.text-blue-500\/70{color:#3080ffb3}@supports (color:color-mix(in lab,red,red)){.text-blue-500\/70{color:color-mix(in oklab,var(--color-blue-500)70%,transparent)}}.text-blue-600{color:var(--color-blue-600)}.text-blue-700{color:var(--color-blue-700)}.text-cyan-300{color:var(--color-cyan-300)}.text-cyan-400{color:var(--color-cyan-400)}.text-emerald-400{color:var(--color-emerald-400)}.text-gray-300{color:var(--color-gray-300)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-gray-800{color:var(--color-gray-800)}.text-gray-900{color:var(--color-gray-900)}.text-green-200{color:var(--color-green-200)}.text-green-300{color:var(--color-green-300)}.text-green-400{color:var(--color-green-400)}.text-green-500{color:var(--color-green-500)}.text-green-500\/60{color:#00c75899}@supports (color:color-mix(in lab,red,red)){.text-green-500\/60{color:color-mix(in oklab,var(--color-green-500)60%,transparent)}}.text-green-600{color:var(--color-green-600)}.text-indigo-400{color:var(--color-indigo-400)}.text-orange-200{color:var(--color-orange-200)}.text-orange-300{color:var(--color-orange-300)}.text-orange-400{color:var(--color-orange-400)}.text-orange-500{color:var(--color-orange-500)}.text-orange-600{color:var(--color-orange-600)}.text-orange-700{color:var(--color-orange-700)}.text-purple-300{color:var(--color-purple-300)}.text-purple-300\/70{color:#d9b3ffb3}@supports (color:color-mix(in lab,red,red)){.text-purple-300\/70{color:color-mix(in oklab,var(--color-purple-300)70%,transparent)}}.text-purple-400{color:var(--color-purple-400)}.text-purple-400\/80{color:#c07effcc}@supports (color:color-mix(in lab,red,red)){.text-purple-400\/80{color:color-mix(in oklab,var(--color-purple-400)80%,transparent)}}.text-purple-500{color:var(--color-purple-500)}.text-red-200{color:var(--color-red-200)}.text-red-300{color:var(--color-red-300)}.text-red-300\/80{color:#ffa3a3cc}@supports (color:color-mix(in lab,red,red)){.text-red-300\/80{color:color-mix(in oklab,var(--color-red-300)80%,transparent)}}.text-red-400{color:var(--color-red-400)}.text-red-400\/50{color:#ff656880}@supports (color:color-mix(in lab,red,red)){.text-red-400\/50{color:color-mix(in oklab,var(--color-red-400)50%,transparent)}}.text-red-400\/60{color:#ff656899}@supports (color:color-mix(in lab,red,red)){.text-red-400\/60{color:color-mix(in oklab,var(--color-red-400)60%,transparent)}}.text-red-400\/70{color:#ff6568b3}@supports (color:color-mix(in lab,red,red)){.text-red-400\/70{color:color-mix(in oklab,var(--color-red-400)70%,transparent)}}.text-red-500{color:var(--color-red-500)}.text-red-600{color:var(--color-red-600)}.text-rose-300{color:var(--color-rose-300)}.text-rose-400{color:var(--color-rose-400)}.text-sky-400{color:var(--color-sky-400)}.text-slate-300{color:var(--color-slate-300)}.text-status-error{color:var(--color-status-error)}.text-status-ok{color:var(--color-status-ok)}.text-status-warning{color:var(--color-status-warning)}.text-teal-400{color:var(--color-teal-400)}.text-white{color:var(--color-white)}.text-white\/30{color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.text-white\/30{color:color-mix(in oklab,var(--color-white)30%,transparent)}}.text-white\/40{color:#fff6}@supports (color:color-mix(in lab,red,red)){.text-white\/40{color:color-mix(in oklab,var(--color-white)40%,transparent)}}.text-white\/50{color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.text-white\/50{color:color-mix(in oklab,var(--color-white)50%,transparent)}}.text-white\/60{color:#fff9}@supports (color:color-mix(in lab,red,red)){.text-white\/60{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.text-white\/70{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.text-white\/80{color:#fffc}@supports (color:color-mix(in lab,red,red)){.text-white\/80{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.text-white\/90{color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.text-white\/90{color:color-mix(in oklab,var(--color-white)90%,transparent)}}.text-yellow-200{color:var(--color-yellow-200)}.text-yellow-200\/70{color:#fff085b3}@supports (color:color-mix(in lab,red,red)){.text-yellow-200\/70{color:color-mix(in oklab,var(--color-yellow-200)70%,transparent)}}.text-yellow-300{color:var(--color-yellow-300)}.text-yellow-400{color:var(--color-yellow-400)}.text-yellow-500{color:var(--color-yellow-500)}.text-yellow-500\/70{color:#edb200b3}@supports (color:color-mix(in lab,red,red)){.text-yellow-500\/70{color:color-mix(in oklab,var(--color-yellow-500)70%,transparent)}}.text-yellow-600{color:var(--color-yellow-600)}.text-yellow-700{color:var(--color-yellow-700)}.text-zinc-100{color:var(--color-zinc-100)}.text-zinc-200{color:var(--color-zinc-200)}.text-zinc-300{color:var(--color-zinc-300)}.text-zinc-400{color:var(--color-zinc-400)}.text-zinc-500{color:var(--color-zinc-500)}.text-zinc-600{color:var(--color-zinc-600)}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.line-through{text-decoration-line:line-through}.underline{text-decoration-line:underline}.placeholder-bambu-gray::placeholder{color:var(--color-bambu-gray)}.placeholder-bambu-gray-dark::placeholder{color:var(--color-bambu-gray-dark)}.placeholder-bambu-gray\/40::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder-bambu-gray\/40::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.placeholder-bambu-gray\/50::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder-bambu-gray\/50::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.placeholder-zinc-500::placeholder{color:var(--color-zinc-500)}.accent-bambu-green{accent-color:var(--color-bambu-green)}.accent-green-500{accent-color:var(--color-green-500)}.opacity-0{opacity:0}.opacity-20{opacity:.2}.opacity-25{opacity:.25}.opacity-30{opacity:.3}.opacity-40{opacity:.4}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-80{opacity:.8}.opacity-100{opacity:1}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_6px_rgba\(34\,197\,94\,0\.5\)\]{--tw-shadow:0 0 6px var(--tw-shadow-color,#22c55e80);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow\/depth{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring,.ring-1{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-bambu-green\/20{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.shadow-bambu-green\/20{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)20%,transparent)var(--tw-shadow-alpha),transparent)}}.shadow-bambu-green\/25{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.shadow-bambu-green\/25{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)25%,transparent)var(--tw-shadow-alpha),transparent)}}.ring-bambu-green,.ring-bambu-green\/30{--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.ring-bambu-green\/30{--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.ring-blue-400\/50{--tw-ring-color:#54a2ff80}@supports (color:color-mix(in lab,red,red)){.ring-blue-400\/50{--tw-ring-color:color-mix(in oklab,var(--color-blue-400)50%,transparent)}}.ring-green-500{--tw-ring-color:var(--color-green-500)}.ring-white{--tw-ring-color:var(--color-white)}.ring-offset-1{--tw-ring-offset-width:1px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-2{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-bambu-dark{--tw-ring-offset-color:var(--color-bambu-dark)}.ring-offset-bambu-dark-secondary{--tw-ring-offset-color:var(--color-bambu-dark-secondary)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.blur-2xl{--tw-blur:blur(var(--blur-2xl));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow-lg{--tw-drop-shadow-size:drop-shadow(0 4px 4px var(--tw-drop-shadow-color,#00000026));--tw-drop-shadow:drop-shadow(var(--drop-shadow-lg));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow-md{--tw-drop-shadow-size:drop-shadow(0 3px 3px var(--tw-drop-shadow-color,#0000001f));--tw-drop-shadow:drop-shadow(var(--drop-shadow-md));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-500{--tw-duration:.5s;transition-duration:.5s}.duration-1000{--tw-duration:1s;transition-duration:1s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.select-none{-webkit-user-select:none;user-select:none}@media(hover:hover){.group-hover\:bg-bambu-green\/20:is(:where(.group):hover *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.group-hover\:bg-bambu-green\/20:is(:where(.group):hover *){background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.group-hover\:text-bambu-gray:is(:where(.group):hover *){color:var(--color-bambu-gray)}.group-hover\:text-bambu-green:is(:where(.group):hover *){color:var(--color-bambu-green)}.group-hover\:opacity-50:is(:where(.group):hover *){opacity:.5}.group-hover\:opacity-100:is(:where(.group):hover *),.group-hover\/resize\:opacity-100:is(:where(.group\/resize):hover *){opacity:1}.group-hover\/thumb\:block:is(:where(.group\/thumb):hover *){display:block}}.peer-checked\:bg-bambu-green:is(:where(.peer):checked~*){background-color:var(--color-bambu-green)}.peer-focus\:outline-none:is(:where(.peer):focus~*){--tw-outline-style:none;outline-style:none}.placeholder\:text-bambu-gray::placeholder,.placeholder\:text-bambu-gray\/50::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-bambu-gray\/50::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:top-0:before{content:var(--tw-content);top:calc(var(--spacing)*0)}.before\:right-0:before{content:var(--tw-content);right:calc(var(--spacing)*0)}.before\:left-0:before{content:var(--tw-content);left:calc(var(--spacing)*0)}.before\:h-0\.5:before{content:var(--tw-content);height:calc(var(--spacing)*.5)}.before\:bg-bambu-green:before{content:var(--tw-content);background-color:var(--color-bambu-green)}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:top-\[2px\]:after{content:var(--tw-content);top:2px}.after\:left-\[2px\]:after{content:var(--tw-content);left:2px}.after\:h-4:after{content:var(--tw-content);height:calc(var(--spacing)*4)}.after\:h-5:after{content:var(--tw-content);height:calc(var(--spacing)*5)}.after\:w-4:after{content:var(--tw-content);width:calc(var(--spacing)*4)}.after\:w-5:after{content:var(--tw-content);width:calc(var(--spacing)*5)}.after\:rounded-full:after{content:var(--tw-content);border-radius:3.40282e38px}.after\:border:after{content:var(--tw-content);border-style:var(--tw-border-style);border-width:1px}.after\:border-gray-300:after{content:var(--tw-content);border-color:var(--color-gray-300)}.after\:bg-white:after{content:var(--tw-content);background-color:var(--color-white)}.after\:transition-all:after{content:var(--tw-content);transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.after\:content-\[\'\'\]:after{--tw-content:"";content:var(--tw-content)}.peer-checked\:after\:translate-x-full:is(:where(.peer):checked~*):after{content:var(--tw-content);--tw-translate-x:100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.peer-checked\:after\:border-white:is(:where(.peer):checked~*):after{content:var(--tw-content);border-color:var(--color-white)}.last\:border-0:last-child{border-style:var(--tw-border-style);border-width:0}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media(hover:hover){.hover\:z-20:hover{z-index:20}.hover\:scale-105:hover{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\:border-bambu-dark-tertiary\/80:hover{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-dark-tertiary\/80:hover{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.hover\:border-bambu-gray:hover{border-color:var(--color-bambu-gray)}.hover\:border-bambu-gray-dark:hover{border-color:var(--color-bambu-gray-dark)}.hover\:border-bambu-gray\/50:hover{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-gray\/50:hover{border-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.hover\:border-bambu-green:hover,.hover\:border-bambu-green\/50:hover{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-green\/50:hover{border-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.hover\:border-green-500\/50:hover{border-color:#00c75880}@supports (color:color-mix(in lab,red,red)){.hover\:border-green-500\/50:hover{border-color:color-mix(in oklab,var(--color-green-500)50%,transparent)}}.hover\:border-white:hover{border-color:var(--color-white)}.hover\:border-white\/40:hover{border-color:#fff6}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/40:hover{border-color:color-mix(in oklab,var(--color-white)40%,transparent)}}.hover\:\!bg-green-500\/20:hover{background-color:#00c75833!important}@supports (color:color-mix(in lab,red,red)){.hover\:\!bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)!important}}.hover\:bg-amber-500\/30:hover{background-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/30:hover{background-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.hover\:bg-bambu-dark:hover{background-color:var(--color-bambu-dark)}.hover\:bg-bambu-dark-secondary:hover,.hover\:bg-bambu-dark-secondary\/50:hover{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-secondary\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)50%,transparent)}}.hover\:bg-bambu-dark-tertiary:hover,.hover\:bg-bambu-dark-tertiary\/30:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.hover\:bg-bambu-dark-tertiary\/50:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.hover\:bg-bambu-dark-tertiary\/70:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/70:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)70%,transparent)}}.hover\:bg-bambu-dark-tertiary\/80:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.hover\:bg-bambu-dark\/50:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.hover\:bg-bambu-dark\/80:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)80%,transparent)}}.hover\:bg-bambu-gray-dark:hover{background-color:var(--color-bambu-gray-dark)}.hover\:bg-bambu-green:hover{background-color:var(--color-bambu-green)}.hover\:bg-bambu-green-dark:hover{background-color:var(--color-bambu-green-dark)}.hover\:bg-bambu-green-light:hover{background-color:var(--color-bambu-green-light)}.hover\:bg-bambu-green\/10:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/10:hover{background-color:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.hover\:bg-bambu-green\/20:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/20:hover{background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.hover\:bg-bambu-green\/30:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.hover\:bg-bambu-green\/50:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.hover\:bg-bambu-green\/80:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)}}.hover\:bg-black\/40:hover{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/40:hover{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.hover\:bg-black\/70:hover{background-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/70:hover{background-color:color-mix(in oklab,var(--color-black)70%,transparent)}}.hover\:bg-black\/80:hover{background-color:#000c}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/80:hover{background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.hover\:bg-blue-500\/30:hover{background-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-500\/30:hover{background-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.hover\:bg-gray-50:hover{background-color:var(--color-gray-50)}.hover\:bg-gray-100:hover{background-color:var(--color-gray-100)}.hover\:bg-gray-700:hover{background-color:var(--color-gray-700)}.hover\:bg-green-500\/20:hover{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.hover\:bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.hover\:bg-green-700:hover{background-color:var(--color-green-700)}.hover\:bg-orange-400\/20:hover{background-color:#ff8b1a33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-orange-400\/20:hover{background-color:color-mix(in oklab,var(--color-orange-400)20%,transparent)}}.hover\:bg-red-200:hover{background-color:var(--color-red-200)}.hover\:bg-red-400\/10:hover{background-color:#ff65681a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-400\/10:hover{background-color:color-mix(in oklab,var(--color-red-400)10%,transparent)}}.hover\:bg-red-500\/10:hover{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/10:hover{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.hover\:bg-red-500\/30:hover{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/30:hover{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.hover\:bg-red-600:hover{background-color:var(--color-red-600)}.hover\:bg-red-700:hover{background-color:var(--color-red-700)}.hover\:bg-white\/5:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/5:hover{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.hover\:bg-white\/10:hover{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/10:hover{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.hover\:bg-white\/80:hover{background-color:#fffc}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/80:hover{background-color:color-mix(in oklab,var(--color-white)80%,transparent)}}.hover\:bg-yellow-500\/30:hover{background-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-yellow-500\/30:hover{background-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.hover\:bg-yellow-600:hover{background-color:var(--color-yellow-600)}.hover\:bg-zinc-600:hover{background-color:var(--color-zinc-600)}.hover\:bg-zinc-700:hover{background-color:var(--color-zinc-700)}.hover\:bg-zinc-700\/50:hover{background-color:#3f3f4680}@supports (color:color-mix(in lab,red,red)){.hover\:bg-zinc-700\/50:hover{background-color:color-mix(in oklab,var(--color-zinc-700)50%,transparent)}}.hover\:text-amber-300:hover{color:var(--color-amber-300)}.hover\:text-bambu-gray:hover{color:var(--color-bambu-gray)}.hover\:text-bambu-green:hover{color:var(--color-bambu-green)}.hover\:text-bambu-green-light:hover{color:var(--color-bambu-green-light)}.hover\:text-bambu-green\/70:hover{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:text-bambu-green\/70:hover{color:color-mix(in oklab,var(--color-bambu-green)70%,transparent)}}.hover\:text-bambu-green\/80:hover{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:text-bambu-green\/80:hover{color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)}}.hover\:text-blue-300:hover{color:var(--color-blue-300)}.hover\:text-gray-900:hover{color:var(--color-gray-900)}.hover\:text-orange-300:hover{color:var(--color-orange-300)}.hover\:text-red-200:hover{color:var(--color-red-200)}.hover\:text-red-300:hover{color:var(--color-red-300)}.hover\:text-red-400:hover{color:var(--color-red-400)}.hover\:text-white:hover{color:var(--color-white)}.hover\:text-white\/70:hover{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/70:hover{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.hover\:text-white\/80:hover{color:#fffc}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/80:hover{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.hover\:text-yellow-400:hover{color:var(--color-yellow-400)}.hover\:text-zinc-300:hover{color:var(--color-zinc-300)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-70:hover{opacity:.7}.hover\:opacity-80:hover{opacity:.8}.hover\:shadow-lg:hover{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:shadow-bambu-green\/5:hover{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:shadow-bambu-green\/5:hover{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)5%,transparent)var(--tw-shadow-alpha),transparent)}}.hover\:shadow-bambu-green\/30:hover{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:shadow-bambu-green\/30:hover{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)30%,transparent)var(--tw-shadow-alpha),transparent)}}}.focus\:border-bambu-green:focus{border-color:var(--color-bambu-green)}.focus\:border-green-500:focus{border-color:var(--color-green-500)}.focus\:border-red-500:focus{border-color:var(--color-red-500)}.focus\:ring-1:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-bambu-gray:focus{--tw-ring-color:var(--color-bambu-gray)}.focus\:ring-bambu-green:focus,.focus\:ring-bambu-green\/50:focus{--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.focus\:ring-bambu-green\/50:focus{--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.focus\:ring-red-500:focus{--tw-ring-color:var(--color-red-500)}.focus\:ring-offset-0:focus{--tw-ring-offset-width:0px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:ring-offset-bambu-dark:focus{--tw-ring-offset-color:var(--color-bambu-dark)}.focus\:ring-offset-bambu-dark-secondary:focus{--tw-ring-offset-color:var(--color-bambu-dark-secondary)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.active\:cursor-grabbing:active{cursor:grabbing}.active\:bg-zinc-700:active{background-color:var(--color-zinc-700)}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}@media(hover:hover){.disabled\:hover\:bg-bambu-green:disabled:hover{background-color:var(--color-bambu-green)}}@media not all and (min-width:640px){.max-\[640px\]\:hidden{display:none}.max-\[640px\]\:w-full{width:100%}.max-\[640px\]\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.max-\[640px\]\:flex-col{flex-direction:column}.max-\[640px\]\:flex-wrap{flex-wrap:wrap}.max-\[640px\]\:items-center{align-items:center}.max-\[640px\]\:items-start{align-items:flex-start}}@media not all and (min-width:550px){.max-\[550px\]\:order-1{order:1}.max-\[550px\]\:order-2{order:2}.max-\[550px\]\:order-3{order:3}.max-\[550px\]\:order-4{order:4}.max-\[550px\]\:mt-1{margin-top:calc(var(--spacing)*1)}.max-\[550px\]\:w-full{width:100%}.max-\[550px\]\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.max-\[550px\]\:flex-col{flex-direction:column}.max-\[550px\]\:flex-wrap{flex-wrap:wrap}.max-\[550px\]\:items-center{align-items:center}.max-\[550px\]\:items-start{align-items:flex-start}.max-\[550px\]\:justify-end{justify-content:flex-end}.max-\[550px\]\:gap-1\.5{gap:calc(var(--spacing)*1.5)}.max-\[550px\]\:gap-2{gap:calc(var(--spacing)*2)}.max-\[550px\]\:gap-3{gap:calc(var(--spacing)*3)}.max-\[550px\]\:self-start{align-self:flex-start}}@media(min-width:40rem){.sm\:col-span-1{grid-column:span 1/span 1}.sm\:mt-0{margin-top:calc(var(--spacing)*0)}.sm\:mt-2{margin-top:calc(var(--spacing)*2)}.sm\:mt-3{margin-top:calc(var(--spacing)*3)}.sm\:mr-1{margin-right:calc(var(--spacing)*1)}.sm\:mb-4{margin-bottom:calc(var(--spacing)*4)}.sm\:ml-auto{margin-left:auto}.sm\:block{display:block}.sm\:flex{display:flex}.sm\:grid{display:grid}.sm\:hidden{display:none}.sm\:inline{display:inline}.sm\:h-2{height:calc(var(--spacing)*2)}.sm\:h-3{height:calc(var(--spacing)*3)}.sm\:h-3\.5{height:calc(var(--spacing)*3.5)}.sm\:h-4{height:calc(var(--spacing)*4)}.sm\:h-5{height:calc(var(--spacing)*5)}.sm\:h-6{height:calc(var(--spacing)*6)}.sm\:h-10{height:calc(var(--spacing)*10)}.sm\:h-14{height:calc(var(--spacing)*14)}.sm\:w-3{width:calc(var(--spacing)*3)}.sm\:w-3\.5{width:calc(var(--spacing)*3.5)}.sm\:w-4{width:calc(var(--spacing)*4)}.sm\:w-5{width:calc(var(--spacing)*5)}.sm\:w-6{width:calc(var(--spacing)*6)}.sm\:w-10{width:calc(var(--spacing)*10)}.sm\:w-14{width:calc(var(--spacing)*14)}.sm\:w-16{width:calc(var(--spacing)*16)}.sm\:w-40{width:calc(var(--spacing)*40)}.sm\:w-auto{width:auto}.sm\:max-w-none{max-width:none}.sm\:max-w-xs{max-width:var(--container-xs)}.sm\:flex-1{flex:1}.sm\:flex-none{flex:none}.sm\:cursor-default{cursor:default}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:gap-1{gap:calc(var(--spacing)*1)}.sm\:gap-1\.5{gap:calc(var(--spacing)*1.5)}.sm\:gap-2{gap:calc(var(--spacing)*2)}.sm\:gap-3{gap:calc(var(--spacing)*3)}.sm\:gap-4{gap:calc(var(--spacing)*4)}.sm\:gap-6{gap:calc(var(--spacing)*6)}:where(.sm\:space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.sm\:space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}.sm\:border-bambu-dark-tertiary{border-color:var(--color-bambu-dark-tertiary)}.sm\:p-1\.5{padding:calc(var(--spacing)*1.5)}.sm\:p-2{padding:calc(var(--spacing)*2)}.sm\:p-3{padding:calc(var(--spacing)*3)}.sm\:p-4{padding:calc(var(--spacing)*4)}.sm\:px-2{padding-inline:calc(var(--spacing)*2)}.sm\:px-3{padding-inline:calc(var(--spacing)*3)}.sm\:text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.sm\:text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.sm\:text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.sm\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.sm\:text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}}@media(min-width:48rem){.md\:top-\[2px\]{top:2px}.md\:left-\[2px\]{left:2px}.md\:mx-0{margin-inline:calc(var(--spacing)*0)}.md\:block{display:block}.md\:inline{display:inline}.md\:h-4{height:calc(var(--spacing)*4)}.md\:h-5{height:calc(var(--spacing)*5)}.md\:min-h-0{min-height:calc(var(--spacing)*0)}.md\:w-4{width:calc(var(--spacing)*4)}.md\:w-9{width:calc(var(--spacing)*9)}.md\:min-w-\[200px\]{min-width:200px}.md\:flex-1{flex:1}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.md\:flex-row{flex-direction:row}.md\:flex-wrap{flex-wrap:wrap}.md\:items-center{align-items:center}.md\:gap-4{gap:calc(var(--spacing)*4)}.md\:p-6{padding:calc(var(--spacing)*6)}.md\:p-8{padding:calc(var(--spacing)*8)}.md\:px-0{padding-inline:calc(var(--spacing)*0)}.md\:py-2{padding-block:calc(var(--spacing)*2)}.md\:pb-0{padding-bottom:calc(var(--spacing)*0)}}@media(min-width:64rem){.lg\:static{position:static}.lg\:col-span-2{grid-column:span 2/span 2}.lg\:col-span-3{grid-column:span 3/span 3}.lg\:flex{display:flex}.lg\:hidden{display:none}.lg\:h-\[calc\(100vh-64px\)\]{height:calc(100vh - 64px)}.lg\:w-1\/3{width:33.3333%}.lg\:w-2\/3{width:66.6667%}.lg\:w-80{width:calc(var(--spacing)*80)}.lg\:w-\[480px\]{width:480px}.lg\:max-w-md{max-width:var(--container-md)}.lg\:max-w-sm{max-width:var(--container-sm)}.lg\:max-w-xl{max-width:var(--container-xl)}.lg\:flex-shrink-0{flex-shrink:0}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.lg\:flex-row{flex-direction:row}.lg\:gap-4{gap:calc(var(--spacing)*4)}.lg\:gap-6{gap:calc(var(--spacing)*6)}.lg\:gap-8{gap:calc(var(--spacing)*8)}.lg\:overflow-y-auto{overflow-y:auto}.lg\:p-8{padding:calc(var(--spacing)*8)}}@media(min-width:80rem){.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}@media(min-width:96rem){.\32xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}.dark\:border-bambu-dark-tertiary:where(.dark,.dark *),.dark\:border-bambu-dark-tertiary\/50:where(.dark,.dark *){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.dark\:border-bambu-dark-tertiary\/50:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.dark\:border-bambu-green\/40:where(.dark,.dark *){border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:border-bambu-green\/40:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.dark\:border-gray-600:where(.dark,.dark *){border-color:var(--color-gray-600)}.dark\:border-red-500\/30:where(.dark,.dark *){border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.dark\:border-red-500\/30:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.dark\:border-red-500\/40:where(.dark,.dark *){border-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.dark\:border-red-500\/40:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.dark\:bg-amber-500\/10:where(.dark,.dark *){background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-amber-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.dark\:bg-bambu-dark:where(.dark,.dark *){background-color:var(--color-bambu-dark)}.dark\:bg-bambu-dark-secondary:where(.dark,.dark *){background-color:var(--color-bambu-dark-secondary)}.dark\:bg-bambu-green\/20:where(.dark,.dark *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:bg-bambu-green\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.dark\:bg-black\/80:where(.dark,.dark *){background-color:#000c}@supports (color:color-mix(in lab,red,red)){.dark\:bg-black\/80:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.dark\:bg-blue-500\/10:where(.dark,.dark *){background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-blue-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.dark\:bg-blue-500\/20:where(.dark,.dark *){background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.dark\:bg-blue-500\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.dark\:bg-gray-900:where(.dark,.dark *){background-color:var(--color-gray-900)}.dark\:bg-red-500\/10:where(.dark,.dark *){background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-red-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.dark\:bg-red-500\/20:where(.dark,.dark *){background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.dark\:bg-red-500\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.dark\:text-amber-400:where(.dark,.dark *){color:var(--color-amber-400)}.dark\:text-bambu-gray:where(.dark,.dark *),.dark\:text-bambu-gray\/30:where(.dark,.dark *){color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-gray\/30:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.dark\:text-bambu-gray\/50:where(.dark,.dark *){color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-gray\/50:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.dark\:text-bambu-green:where(.dark,.dark *),.dark\:text-bambu-green\/60:where(.dark,.dark *){color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-green\/60:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-green)60%,transparent)}}.dark\:text-blue-200:where(.dark,.dark *){color:var(--color-blue-200)}.dark\:text-blue-200\/80:where(.dark,.dark *){color:#bedbffcc}@supports (color:color-mix(in lab,red,red)){.dark\:text-blue-200\/80:where(.dark,.dark *){color:color-mix(in oklab,var(--color-blue-200)80%,transparent)}}.dark\:text-blue-300:where(.dark,.dark *){color:var(--color-blue-300)}.dark\:text-blue-300\/60:where(.dark,.dark *){color:#90c5ff99}@supports (color:color-mix(in lab,red,red)){.dark\:text-blue-300\/60:where(.dark,.dark *){color:color-mix(in oklab,var(--color-blue-300)60%,transparent)}}.dark\:text-blue-400:where(.dark,.dark *){color:var(--color-blue-400)}.dark\:text-orange-200:where(.dark,.dark *){color:var(--color-orange-200)}.dark\:text-orange-400:where(.dark,.dark *){color:var(--color-orange-400)}.dark\:text-red-400:where(.dark,.dark *){color:var(--color-red-400)}.dark\:text-red-400\/70:where(.dark,.dark *){color:#ff6568b3}@supports (color:color-mix(in lab,red,red)){.dark\:text-red-400\/70:where(.dark,.dark *){color:color-mix(in oklab,var(--color-red-400)70%,transparent)}}.dark\:text-white:where(.dark,.dark *){color:var(--color-white)}.dark\:text-yellow-200:where(.dark,.dark *){color:var(--color-yellow-200)}.dark\:text-yellow-200\/70:where(.dark,.dark *){color:#fff085b3}@supports (color:color-mix(in lab,red,red)){.dark\:text-yellow-200\/70:where(.dark,.dark *){color:color-mix(in oklab,var(--color-yellow-200)70%,transparent)}}@media(hover:hover){.dark\:hover\:bg-bambu-dark-tertiary:where(.dark,.dark *):hover{background-color:var(--color-bambu-dark-tertiary)}.dark\:hover\:bg-bambu-dark\/50:where(.dark,.dark *):hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.dark\:hover\:bg-bambu-dark\/50:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.dark\:hover\:bg-red-500\/30:where(.dark,.dark *):hover{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.dark\:hover\:bg-red-500\/30:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.dark\:hover\:text-white:where(.dark,.dark *):hover{color:var(--color-white)}}.\[\&\:\:-webkit-slider-thumb\]\:h-3::-webkit-slider-thumb{height:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:w-3::-webkit-slider-thumb{width:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:cursor-pointer::-webkit-slider-thumb{cursor:pointer}.\[\&\:\:-webkit-slider-thumb\]\:appearance-none::-webkit-slider-thumb{appearance:none}.\[\&\:\:-webkit-slider-thumb\]\:rounded-full::-webkit-slider-thumb{border-radius:3.40282e38px}.\[\&\:\:-webkit-slider-thumb\]\:bg-bambu-green::-webkit-slider-thumb{background-color:var(--color-bambu-green)}}:root{--accent:#00ae42;--accent-light:#00c64d;--accent-dark:#009438;--status-ok:#22c55e;--status-error:#ef4444;--status-warning:#f59e0b;--bg-primary:#f5f5f5;--bg-secondary:#fff;--bg-tertiary:#e5e5e5;--text-primary:#1a1a1a;--text-secondary:#4a4a4a;--text-muted:#6b6b6b;--text-tertiary:gray;--border-color:#d4d4d4;--card-shadow:0 2px 8px #00000014;--glow-color:transparent;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,system-ui,sans-serif;font-weight:400;line-height:1.5}.dark{--bg-primary:#1a1a1a;--bg-secondary:#2d2d2d;--bg-tertiary:#3d3d3d;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:gray;--text-tertiary:#4a4a4a;--border-color:#3d3d3d;--card-shadow:0 4px 16px #0006}.bg-warm{--bg-primary:#faf8f5;--bg-secondary:#fffefa;--bg-tertiary:#e8e4dd;--text-primary:#2d2a26;--text-secondary:#5c5750;--text-muted:#7a756c;--text-tertiary:#9a9590;--border-color:#d8d4cc}.bg-cool{--bg-primary:#f0f4f8;--bg-secondary:#fff;--bg-tertiary:#dce4ec;--text-primary:#1a2530;--text-secondary:#4a5568;--text-muted:#6b7a8a;--text-tertiary:#8a9aaa;--border-color:#c8d4e0}.dark.bg-neutral{--bg-primary:#1a1a1a;--bg-secondary:#2d2d2d;--bg-tertiary:#3d3d3d;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:gray;--text-tertiary:#4a4a4a;--border-color:#3d3d3d}.dark.bg-warm{--bg-primary:#1c1a18;--bg-secondary:#2e2a26;--bg-tertiary:#3e3a36;--text-primary:#f5f0ea;--text-secondary:#b0a898;--text-muted:#8a8278;--text-tertiary:#5a5248;--border-color:#3e3a36}.dark.bg-cool{--bg-primary:#181c20;--bg-secondary:#262c32;--bg-tertiary:#363e46;--text-primary:#f0f4f8;--text-secondary:#98a8b8;--text-muted:#788898;--text-tertiary:#4a5a6a;--border-color:#363e46}.dark.bg-oled{--bg-primary:#000;--bg-secondary:#141414;--bg-tertiary:#1f1f1f;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:#707070;--text-tertiary:#404040;--border-color:#2a2a2a}.dark.bg-slate{--bg-primary:#0f172a;--bg-secondary:#1e293b;--bg-tertiary:#334155;--text-primary:#f1f5f9;--text-secondary:#94a3b8;--text-muted:#64748b;--text-tertiary:#475569;--border-color:#334155}.dark.bg-forest{--bg-primary:#121a16;--bg-secondary:#1c2a22;--bg-tertiary:#2a3d30;--text-primary:#e8f5ec;--text-secondary:#8aa894;--text-muted:#6a8874;--text-tertiary:#4a6854;--border-color:#2a3d30}.printer-control-buttons-container{container-type:inline-size}@container (max-width:220px){.printer-control-buttons{flex-direction:column;align-items:stretch}.printer-control-buttons>button{width:100%}}.style-glow{--card-shadow:0 2px 8px #00000014,0 0 25px var(--accent)}@supports (color:color-mix(in lab,red,red)){.style-glow{--card-shadow:0 2px 8px #00000014,0 0 25px color-mix(in srgb,var(--accent)12%,transparent)}}.dark.style-glow{--card-shadow:0 4px 20px #00000080,0 0 40px var(--accent)}@supports (color:color-mix(in lab,red,red)){.dark.style-glow{--card-shadow:0 4px 20px #00000080,0 0 40px color-mix(in srgb,var(--accent)15%,transparent)}}.style-vibrant{--card-shadow:0 8px 30px #00000026,0 2px 8px #0000001a}.dark.style-vibrant{--card-shadow:0 10px 40px #0009,0 4px 12px #0006}.accent-green{--accent:#00ae42;--accent-light:#00c64d;--accent-dark:#009438}.accent-teal{--accent:#14b8a6;--accent-light:#2dd4bf;--accent-dark:#0d9488}.accent-blue{--accent:#3b82f6;--accent-light:#60a5fa;--accent-dark:#2563eb}.accent-orange{--accent:#f97316;--accent-light:#fb923c;--accent-dark:#ea580c}.accent-purple{--accent:#8b5cf6;--accent-light:#a78bfa;--accent-dark:#7c3aed}.accent-red{--accent:#ef4444;--accent-light:#f87171;--accent-dark:#dc2626}body{background-color:var(--bg-primary);color:var(--text-primary);min-height:100vh;margin:0;transition:background-color .2s,color .2s}#root{min-height:100vh}.text-white{color:var(--text-primary)}.bg-bambu-dark,.bg-bambu-dark-secondary,.bg-bambu-dark-tertiary,.border-bambu-dark-tertiary{transition:background-color .2s,border-color .2s}@keyframes slide-in{0%{opacity:0;transform:translate(100%)}to{opacity:1;transform:translate(0)}}.animate-slide-in{animation:.2s ease-out slide-in}.icon-theme{opacity:.5}.dark .icon-theme{filter:invert();opacity:.4}.icon-green{filter:invert(48%)sepia(89%)saturate(459%)hue-rotate(93deg)brightness(95%)contrast(92%);opacity:1}.icon-heating{filter:invert(50%)sepia()saturate(1000%)hue-rotate(360deg)brightness()contrast();opacity:1}.dark .jogpad-theme{filter:brightness(.35)contrast(1.2)}.ams-empty-slot{background:repeating-linear-gradient(45deg,#444,#444 2px,#222 2px 4px)}.dark .ams-empty-slot{background:repeating-linear-gradient(45deg,#555,#555 2px,#333 2px 4px)}.touch-manipulation{touch-action:manipulation}.safe-area-bottom{padding-bottom:env(safe-area-inset-bottom,0)}.safe-area-top{padding-top:env(safe-area-inset-top,0)}.scrollbar-hide{-ms-overflow-style:none;scrollbar-width:none}.scrollbar-hide::-webkit-scrollbar{display:none}@keyframes slide-in-left{0%{transform:translate(-100%)}to{transform:translate(0)}}.animate-slide-in-left{animation:.3s ease-out slide-in-left}.card-shadow{box-shadow:var(--card-shadow)}.calendar-scroll{scrollbar-width:thin;scrollbar-color:var(--text-muted)transparent}@supports (color:color-mix(in lab,red,red)){.calendar-scroll{scrollbar-color:color-mix(in srgb,var(--text-muted)60%,transparent)transparent}}.calendar-scroll::-webkit-scrollbar{width:8px}.calendar-scroll::-webkit-scrollbar-track{background:0 0}.calendar-scroll::-webkit-scrollbar-thumb{background-color:var(--text-muted)}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb{background-color:color-mix(in srgb,var(--text-muted)60%,transparent)}}.calendar-scroll::-webkit-scrollbar-thumb{border:2px solid var(--bg-secondary);border-radius:999px}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb{border:2px solid color-mix(in srgb,var(--bg-secondary)70%,transparent)}}.calendar-scroll::-webkit-scrollbar-thumb:hover{background-color:var(--text-muted)}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb:hover{background-color:color-mix(in srgb,var(--text-muted)80%,transparent)}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@property --tw-content{syntax:"*";inherits:false;initial-value:""}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:""}}} diff --git a/static/assets/index-BXXkRrQK.js b/static/assets/index-BzejadyD.js similarity index 98% rename from static/assets/index-BXXkRrQK.js rename to static/assets/index-BzejadyD.js index 7707a8c7c..dba145217 100644 --- a/static/assets/index-BXXkRrQK.js +++ b/static/assets/index-BzejadyD.js @@ -8681,6 +8681,6 @@ Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Qs(t. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{ `+r.map(([s,o])=>n+" "+JSON.stringify(s)+": "+rF(o,e+1)).join(`, `)+` -`+n+"}"}return String(t)}function XZe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i,hasPermission:s,t:o}){const{showToast:l}=ln(),c=Jt(),[d,u]=w.useState(!1),{data:h,isLoading:f}=Je({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>ne.getCloudSettingDetail(t.setting_id)}),p=st({mutationFn:()=>ne.deleteCloudSetting(t.setting_id),onSuccess:()=>{l(o("profiles.presets.toast.deleted")),c.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:g=>l(g.message,"error")}),x=i0(t.setting_id),v=uI(t.name,h?.setting?.inherits);return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(wt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:a.jsxs(Nt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),x&&a.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:o("profiles.presets.editable")})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[a.jsx("span",{className:"capitalize",children:o(`profiles.presets.types.${t.type}`)}),v.printer&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"•"}),a.jsx("span",{children:v.printer})]})]})]}),a.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:f?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h?a.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full",children:rF(h)}):a.jsx("div",{className:"text-center py-16 text-bambu-gray",children:o("profiles.presets.failedToLoadDetails")})}),d?a.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[a.jsx(An,{className:"w-5 h-5"}),a.jsx("span",{className:"font-medium",children:o("profiles.presets.deleteConfirm")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:o("profiles.presets.deleteWarning",{name:t.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:()=>u(!1),disabled:p.isPending,className:"flex-1",children:o("common.cancel")}),a.jsxs(Me,{variant:"danger",onClick:()=>p.mutate(),disabled:p.isPending,className:"flex-1",children:[p.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Xt,{className:"w-4 h-4"}),o("common.delete")]})]})]}):a.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:e,className:"flex-1",children:o("common.close")}),a.jsxs(Me,{variant:"secondary",onClick:r,disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDuplicatePermission"),children:[a.jsx(Yl,{className:"w-4 h-4"}),o("profiles.presets.duplicate")]}),x&&a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"secondary",onClick:i,disabled:f||!h||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noEditPermission"),children:[a.jsx(Ya,{className:"w-4 h-4"}),o("common.edit")]}),a.jsx(Me,{variant:"danger",onClick:()=>u(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDeletePermission"),children:a.jsx(Xt,{className:"w-4 h-4"})})]})]})})]})})})}function Kie(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Yie(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function QZe({onClose:t,onApply:e,t:n}){const{showToast:r}=ln(),[i,s]=w.useState(Kie),[o,l]=w.useState("all"),[c,d]=w.useState(null),[u,h]=w.useState(""),[f,p]=w.useState(""),[x,v]=w.useState("{}"),[g,y]=w.useState(null),[_,N]=w.useState(null),T=o==="all"?i:i.filter(z=>z.type===o),k=z=>{s(z),Yie(z)},M=z=>{const D=i.filter($=>$.id!==z);k(D),N(null),r(n("profiles.templates.toast.deleted"))},C=z=>{d(z.id),h(z.name),p(z.description),v(JSON.stringify(z.settings,null,2)),y(null)},j=()=>{if(!(!c||!u.trim()))try{const z=JSON.parse(x),D=i.map($=>$.id===c?{...$,name:u.trim(),description:f.trim(),settings:z}:$);k(D),d(null),r(n("profiles.templates.toast.updated"))}catch(z){y(z.message)}},P=()=>{d(null),h(""),p(""),v("{}"),y(null)},E=z=>{const D=i.map($=>$.id===z?{...$,showInModal:!$.showInModal}:$);k(D)},B={filament:{label:n("profiles.presets.types.filament"),icon:BC,color:"text-amber-400"},print:{label:n("profiles.presets.types.process"),icon:eu,color:"text-blue-400"},printer:{label:n("profiles.presets.types.printer"),icon:Sr,color:"text-purple-400"}},O=_?i.find(z=>z.id===_):null;return w.useEffect(()=>{const z=D=>{D.key==="Escape"&&(_?N(null):c?P():t())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[_,c,t]),a.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[O&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:a.jsx(wt,{className:"w-full max-w-md",children:a.jsxs(Nt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:a.jsx(An,{className:"w-6 h-6 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:n("profiles.templates.deleteTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("profiles.templates.deleteWarning")})]})]}),a.jsx("p",{className:"text-white mb-6",children:n("profiles.templates.deleteConfirm",{name:O.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:()=>N(null),className:"flex-1",children:n("common.cancel")}),a.jsxs(Me,{onClick:()=>M(_),className:"flex-1 bg-red-500 hover:bg-red-600",children:[a.jsx(Xt,{className:"w-4 h-4"}),n("common.delete")]})]})]})})}),a.jsx(wt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:a.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(ub,{className:"w-5 h-5 text-amber-400"}),n("profiles.templates.title")]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("profiles.templates.typeFilter")}),["all","filament","print","printer"].map(z=>a.jsx("button",{onClick:()=>l(z),className:`px-3 py-1 text-sm rounded-lg transition-colors ${o===z?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:z==="all"?n("common.all"):B[z].label},z))]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:T.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(ub,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:n("profiles.templates.noTemplates")}),a.jsx("p",{className:"text-sm mt-1",children:n("profiles.templates.createFirst")})]}):a.jsx("div",{className:"space-y-2",children:T.map(z=>{const D=B[z.type],$=D.icon;return c===z.id?a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[a.jsx("input",{type:"text",value:u,onChange:G=>h(G.target.value),placeholder:n("profiles.templates.namePlaceholder"),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx("input",{type:"text",value:f,onChange:G=>p(G.target.value),placeholder:n("profiles.templates.descriptionPlaceholder"),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:n("profiles.templates.settingsJson")}),a.jsx("textarea",{value:x,onChange:G=>{v(G.target.value),y(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${g?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),g&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:g})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{size:"sm",onClick:j,disabled:!u.trim(),children:[a.jsx(bs,{className:"w-4 h-4"}),"Save"]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:P,children:"Cancel"})]})]},z.id):a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[a.jsx($,{className:`w-5 h-5 ${D.color} flex-shrink-0`}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:z.name}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:z.description})]}),a.jsx("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:n("profiles.templates.fieldsCount",{count:Object.keys(z.settings).length})}),a.jsx("button",{onClick:()=>E(z.id),className:`p-1 transition-colors ${z.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:z.showInModal?n("profiles.templates.shownInModals"):n("profiles.templates.hiddenInModals"),children:z.showInModal?a.jsx(Xl,{className:"w-4 h-4"}):a.jsx(c0,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>e(z),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:n("profiles.templates.apply")}),a.jsx("button",{onClick:()=>C(z),className:"p-1 text-bambu-gray hover:text-white",title:n("common.edit"),children:a.jsx(Ya,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>N(z.id),className:"p-1 text-bambu-gray hover:text-red-400",title:n("common.delete"),children:a.jsx(Xt,{className:"w-4 h-4"})})]},z.id)})})})]})})]})}function Xie({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i,t:s}){const[o,l]=w.useState("changes"),[c,d]=w.useState(""),u=w.useMemo(()=>{const x=new Set([...Object.keys(e),...Object.keys(n)]),v=[];for(const g of x){if(g==="inherits"||g==="version")continue;const y=e[g],_=n[g],N=g in e,T=g in n;let k;!N&&T?k="added":N&&!T?k="removed":JSON.stringify(y)!==JSON.stringify(_)?k="changed":k="same",v.push({key:g,left:y,right:_,status:k})}return v.sort((g,y)=>{const _={changed:0,added:1,removed:2,same:3};return _[g.status]!==_[y.status]?_[g.status]-_[y.status]:g.key.localeCompare(y.key)})},[e,n]),h=w.useMemo(()=>{let x=[...u];if(o==="changes"&&(x=x.filter(v=>v.status!=="same")),c){const v=c.toLowerCase();x=x.filter(g=>g.key.toLowerCase().includes(v)||String(g.left).toLowerCase().includes(v)||String(g.right).toLowerCase().includes(v))}return x},[u,o,c]),f=w.useMemo(()=>({added:u.filter(x=>x.status==="added").length,removed:u.filter(x=>x.status==="removed").length,changed:u.filter(x=>x.status==="changed").length,same:u.filter(x=>x.status==="same").length}),[u]),p=x=>{if(x===void 0)return"—";if(x===null)return"null";if(Array.isArray(x))return x.length===0?"[]":x.length===1?String(x[0]):x.join(", ");if(typeof x=="object")return JSON.stringify(x);const v=String(x);if(v.includes("\\n")||v.length>100){const g=v.split("\\n").length;if(g>1)return`[${g} lines of G-code/script]`;if(v.length>100)return v.substring(0,100)+"…"}return v};return w.useEffect(()=>{const x=v=>{v.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsx(wt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:a.jsxs(Nt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(qg,{className:"w-5 h-5 text-blue-400"}),s("profiles.diff.title")]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:s("profiles.diff.left")}),a.jsx("p",{className:"text-white font-medium truncate",children:r})]}),a.jsxs("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:s("profiles.diff.right")}),a.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(Xn,{className:"w-3.5 h-3.5"}),f.added," ",s("profiles.diff.added")]}),a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(w1,{className:"w-3.5 h-3.5"}),f.removed," ",s("profiles.diff.removed")]}),a.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[a.jsx(t3,{className:"w-3.5 h-3.5"}),f.changed," ",s("profiles.diff.changed")]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[a.jsx(UM,{className:"w-3.5 h-3.5"}),f.same," ",s("profiles.diff.same")]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"relative",children:[a.jsx(Mr,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c,onChange:x=>d(x.target.value),placeholder:s("profiles.diff.searchFields"),className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),f.same>0&&a.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>l("changes"),className:`px-3 py-1.5 text-sm transition-colors ${o==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s("profiles.diff.changes")}),a.jsx("button",{onClick:()=>l("all"),className:`px-3 py-1.5 text-sm transition-colors ${o==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s("common.all")})]})]})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:h.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(UM,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:s(o==="changes"?"profiles.diff.noDifferences":"profiles.diff.noFieldsMatch")})]}):a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:a.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[a.jsx("th",{className:"text-left p-3 w-1/3",children:s("profiles.diff.field")}),a.jsx("th",{className:"text-left p-3 w-1/3",children:r}),a.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),a.jsx("tbody",{children:h.map(x=>{const v={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[x.status],g={added:a.jsx(Xn,{className:"w-3.5 h-3.5 text-green-400"}),removed:a.jsx(w1,{className:"w-3.5 h-3.5 text-red-400"}),changed:a.jsx(t3,{className:"w-3.5 h-3.5 text-amber-400"}),same:a.jsx(UM,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[x.status];return a.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${v}`,children:[a.jsx("td",{className:"p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[g,a.jsx("span",{className:"text-sm text-white font-mono",children:x.key})]})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${x.status==="removed"?"text-red-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:p(x.left)})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${x.status==="added"?"text-green-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:p(x.right)})})]},x.key)})})]})})]})})})}function ZZe({onClose:t,initialData:e,allPresets:n,t:r}){const{showToast:i}=ln(),s=Jt(),o=!!e?.setting_id,[l,c]=w.useState("common"),[d,u]=w.useState(e?.type||"filament"),[h,f]=w.useState(e?.name?o?e.name:`${e.name} (Copy)`:""),[p,x]=w.useState(e?.base_id||""),[v,g]=w.useState(""),[y,_]=w.useState(e?.setting||{inherits:""}),[N,T]=w.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[k,M]=w.useState(null),[C,j]=w.useState(""),[P,E]=w.useState(!1),[B,O]=w.useState(""),[z,D]=w.useState(!1),[$,G]=w.useState(Kie),[U,W]=w.useState(!1),[Y,re]=w.useState(""),[H,K]=w.useState(""),[ee,Z]=w.useState(!0),[we,oe]=w.useState(null),[J,je]=w.useState(!1),de=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[d]||[],[n,d]),le=w.useMemo(()=>de.filter(Ne=>i0(Ne.setting_id)),[de]),{data:_e}=Je({queryKey:["cloudFields",d],queryFn:()=>ne.getCloudFields(d==="print"?"process":d),staleTime:1e3*60*60}),{data:se}=Je({queryKey:["allPresetDetails",d,le.map(Ne=>Ne.setting_id).join(",")],queryFn:async()=>{const Ne={};for(let ve=0;ve{try{const De=await ne.getCloudSettingDetail(nt.setting_id);return{id:nt.setting_id,detail:De}}catch{return null}}))).forEach(nt=>{nt&&(Ne[nt.id]=nt.detail)})}return Ne},enabled:le.length>0,staleTime:1e3*60*10}),{data:ze,isLoading:V}=Je({queryKey:["cloudSettingDetail",p],queryFn:()=>ne.getCloudSettingDetail(p),enabled:!!p});w.useEffect(()=>{l!=="json"&&T(JSON.stringify(y,null,2))},[y,l]);const X=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[d]||[]).filter(ye=>!i0(ye.setting_id)).sort((ye,ve)=>ye.name.localeCompare(ve.name)),[n,d]);w.useEffect(()=>{if(!p)return;const Ne=X.find(ye=>ye.setting_id===p);Ne&&(g(Ne.name),o||(_({inherits:Ne.name}),T(JSON.stringify({inherits:Ne.name},null,2))))},[p,X,o]);const me=w.useMemo(()=>{const Ne=_e?.fields||[],ye=new Set(Ne.map(nt=>nt.key)),ve=new Set,Ge=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);se&&Object.values(se).forEach(nt=>{nt?.setting&&Object.keys(nt.setting).forEach(De=>{!ye.has(De)&&!Ge.has(De)&&ve.add(De)})}),Object.keys(y).forEach(nt=>{!ye.has(nt)&&!Ge.has(nt)&&ve.add(nt)});const Te=Array.from(ve).sort().map(nt=>({key:nt,label:nt.replace(/_/g," ").replace(/\b\w/g,De=>De.toUpperCase()),type:"text",category:"discovered",description:r("profiles.presets.discoveredFromPresets")}));return[...Ne,...Te]},[_e,se,y,r]),Q=me.filter(Ne=>Ne.label.toLowerCase().includes(C.toLowerCase())||Ne.key.toLowerCase().includes(C.toLowerCase())),ie=()=>{if(B.trim()){const Ne=B.trim().toLowerCase().replace(/\s+/g,"_");ue(Ne,""),O(""),D(!1),i(r("profiles.presets.toast.fieldAdded",{key:Ne}))}},ue=(Ne,ye)=>{_(ve=>{const Ge={...ve};return ye===""||ye===void 0?delete Ge[Ne]:Ge[Ne]=ye,Ge})},Le=Ne=>{_(ye=>({...ye,...Ne.settings})),oe(Ne.name),i(r("profiles.templates.toast.applied"))},Ce=()=>{if(!Y.trim())return;const Ne={...y};if(delete Ne.inherits,Object.keys(Ne).length===0){i(r("profiles.presets.noOverridesToSave"),"error");return}const ye={id:Date.now().toString(),name:Y.trim(),description:H.trim()||r("profiles.presets.customTemplate"),type:d,settings:Ne,showInModal:ee},ve=[...$,ye];G(ve),Yie(ve),W(!1),re(""),K(""),Z(!0),i(r("profiles.templates.toast.created"))},ge=w.useMemo(()=>$.filter(Ne=>Ne.type===d&&Ne.showInModal),[d,$]),L=Ne=>{T(Ne);try{const ye=JSON.parse(Ne);_(ye),M(null)}catch(ye){M(ye.message)}},R=Ne=>{Ne.preventDefault(),E(!1);const ye=Ne.dataTransfer.files[0];if(ye&&ye.name.endsWith(".json")){const ve=new FileReader;ve.onload=Ge=>{try{const Te=Ge.target?.result,nt=JSON.parse(Te),De=nt.setting||nt;_(Ke=>({...Ke,...De})),T(JSON.stringify({...y,...De},null,2)),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJsonFile"),"error")}},ve.readAsText(ye)}},q=st({mutationFn:()=>{const Ne={...y},ye=d==="filament"?"filament_settings_id":d==="print"?"print_settings_id":"printer_settings_id";Ne[ye]=`"${h}"`;const ve={type:d,name:h,base_id:p,setting:Ne};return ne.createCloudSetting(ve)},onSuccess:async()=>{i(r("profiles.presets.toast.created")),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:Ne=>i(Ne.message,"error")}),ce=st({mutationFn:()=>{if(!e?.setting_id)throw new Error(r("profiles.presets.noSettingId"));return ne.updateCloudSetting(e.setting_id,{name:h,setting:y})},onSuccess:async()=>{i(r("profiles.presets.toast.updated")),s.removeQueries({queryKey:["cloudSettingDetail"]}),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:Ne=>i(Ne.message,"error")}),pe=o?ce:q,te=ze?.setting?.inherits,Be=te?X.find(Ne=>Ne.name===te):void 0,{data:Ie}=Je({queryKey:["cloudSettingDetail",Be?.setting_id],queryFn:()=>ne.getCloudSettingDetail(Be.setting_id),enabled:!!Be?.setting_id}),$e=w.useMemo(()=>{const Ne=Ie?.setting||{},ye=ze?.setting||{},ve=p&&se?.[p]?.setting?se[p].setting:{};return{...Ne,...ye,...ve}},[p,ze,Ie,se]),Re=Ne=>{if(Ne==null)return"";if(Array.isArray(Ne)){const ye=[...new Set(Ne.map(ve=>String(ve)))];return ye.length===1?ye[0]:Ne.join(", ")}return String(Ne)},fe=Ne=>{const ye=y[Ne.key],ve=$e[Ne.key],Ge=Re(ve),Te=V?r("common.loading"):Ge||"",nt="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(Ne.type==="boolean"){const De=ye==="1"||ye===void 0&&ve==="1";return a.jsx("button",{type:"button",onClick:()=>ue(Ne.key,ye==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${De?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${De?"translate-x-3.5":"translate-x-0.5"}`})})}return Ne.type==="select"?a.jsxs("select",{value:ye||"",onChange:De=>ue(Ne.key,De.target.value),className:nt,children:[a.jsx("option",{value:"",children:Te}),Ne.options?.map(De=>a.jsx("option",{value:De.value,children:De.label},De.value))]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:Ne.type==="number"?"number":"text",value:ye!==void 0?String(ye):"",onChange:De=>ue(Ne.key,De.target.value),step:Ne.step,min:Ne.min,max:Ne.max,placeholder:Te,className:nt}),Ne.unit&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:Ne.unit})]})},xe=w.useMemo(()=>ze?.setting?ze.setting:{},[ze]);return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:Ne=>{Ne.preventDefault(),E(!0)},onDragLeave:()=>E(!1),onDrop:R,children:[J&&p&&a.jsx(Xie,{onClose:()=>je(!1),leftPreset:xe,rightPreset:y,leftLabel:r("profiles.presets.baseLabel",{name:v||p}),rightLabel:r("profiles.presets.currentLabel",{name:h||r("profiles.presets.newPreset")}),t:r}),a.jsx(wt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col overflow-y-auto",children:a.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:r(o?"profiles.presets.editPreset":e?"profiles.presets.duplicatePreset":"profiles.presets.createNewPreset")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("profiles.presets.customizeSettings")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[p&&a.jsxs("button",{onClick:()=>je(!0),className:"flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:r("profiles.presets.compareWithBase"),children:[a.jsx(qg,{className:"w-4 h-4"}),r("profiles.presets.compare")]}),a.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]})]}),P&&a.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:a.jsxs("div",{className:"text-center",children:[a.jsx(La,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),a.jsx("p",{className:"text-bambu-green font-medium",children:r("profiles.presets.dropJsonToImport")})]})}),a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-3 gap-4 max-[640px]:grid-cols-1",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("common.type")}),a.jsxs("select",{value:d,onChange:Ne=>{u(Ne.target.value),x("")},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:[a.jsx("option",{value:"filament",children:r("profiles.presets.types.filament")}),a.jsx("option",{value:"print",children:r("profiles.presets.types.process")}),a.jsx("option",{value:"printer",children:r("profiles.presets.types.printer")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.basePreset")}),a.jsxs("select",{value:p,onChange:Ne=>x(Ne.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:r("profiles.presets.selectBasePreset")}),X.map(Ne=>a.jsx("option",{value:Ne.setting_id,children:Ne.name},Ne.setting_id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.presetName")}),a.jsx("input",{type:"text",value:h,onChange:Ne=>f(Ne.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:r("profiles.presets.myCustomPreset")})]})]}),v&&a.jsx("div",{className:"text-xs text-bambu-gray",children:a.jsxs("p",{className:"flex items-center gap-1",children:[a.jsx(Jr,{className:"w-3 h-3 text-bambu-green"}),r("profiles.presets.inheritsFrom")," ",a.jsx("span",{className:"text-white",children:v}),V&&a.jsx(at,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary max-[640px]:flex-wrap max-[640px]:items-center",children:[a.jsxs("button",{onClick:()=>c("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(OB,{className:"w-4 h-4"}),r("profiles.presets.tabs.common")]}),a.jsxs("button",{onClick:()=>c("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(qC,{className:"w-4 h-4"}),r("profiles.presets.tabs.allFields")]}),a.jsxs("button",{onClick:()=>c("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(fY,{className:"w-4 h-4"}),"JSON",k&&a.jsx(Wa,{className:"w-3 h-3 text-red-400"})]}),a.jsx("div",{className:"flex-1 max-[640px]:hidden"}),a.jsxs("button",{onClick:()=>{const Ne={name:h,type:d,base_id:p,setting:y},ye=new Blob([JSON.stringify(Ne,null,2)],{type:"application/json"}),ve=URL.createObjectURL(ye),Ge=document.createElement("a");Ge.href=ve,Ge.download=`${h||"preset"}.json`,document.body.appendChild(Ge),Ge.click(),document.body.removeChild(Ge),URL.revokeObjectURL(ve),i(r("profiles.presets.toast.exported"))},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.exportToJson"),children:[a.jsx(ha,{className:"w-4 h-4"}),r("common.download")]}),a.jsxs("button",{onClick:()=>document.getElementById("file-import")?.click(),className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.importFromJson"),children:[a.jsx(La,{className:"w-4 h-4"}),r("common.upload")]}),a.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:Ne=>{const ye=Ne.target.files?.[0];if(ye){const ve=new FileReader;ve.onload=Ge=>{try{const Te=JSON.parse(Ge.target?.result),nt=Te.setting||Te;_(De=>({...De,...nt})),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJson"),"error")}},ve.readAsText(ye)}}})]}),a.jsxs("div",{className:"flex-1 p-4",children:[l==="common"&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a.jsx(ub,{className:"w-4 h-4 text-amber-400"}),r("profiles.templates.title")]}),Object.keys(y).filter(Ne=>Ne!=="inherits").length>0&&a.jsxs("button",{onClick:()=>W(!U),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[a.jsx(bs,{className:"w-3 h-3"}),r("profiles.presets.saveAsTemplate")]})]}),U&&a.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[a.jsx("input",{type:"text",value:Y,onChange:Ne=>re(Ne.target.value),placeholder:r("profiles.templates.namePlaceholder"),className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx("input",{type:"text",value:H,onChange:Ne=>K(Ne.target.value),placeholder:r("profiles.templates.descriptionPlaceholder"),className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{size:"sm",onClick:Ce,disabled:!Y.trim(),children:[a.jsx(bs,{className:"w-3 h-3"}),r("common.save")]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>W(!1),children:r("common.cancel")})]}),a.jsxs("button",{onClick:()=>Z(!ee),className:`flex items-center gap-1.5 text-xs transition-colors ${ee?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[ee?a.jsx(Xl,{className:"w-3.5 h-3.5"}):a.jsx(c0,{className:"w-3.5 h-3.5"}),r(ee?"profiles.templates.shownInModals":"profiles.templates.hiddenInModals")]})]})]}),we&&a.jsxs("div",{className:"mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2",children:[a.jsx(Jr,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("span",{className:"text-sm text-bambu-green",children:[r("profiles.presets.templateApplied")," ",a.jsx("span",{className:"font-medium",children:we})]}),a.jsx("button",{onClick:()=>oe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[ge.map(Ne=>a.jsxs("button",{onClick:()=>Le(Ne),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:Ne.name}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:Ne.description})]},Ne.id)),ge.length===0&&a.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:r("profiles.presets.noTemplatesSelected")})]}),a.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:r("profiles.presets.manageTemplatesHint")})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.commonSettings")}),a.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:me.slice(0,10).map(Ne=>a.jsxs("div",{className:"flex items-center justify-between gap-4 max-[640px]:flex-col max-[640px]:items-start",children:[a.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:Ne.label}),a.jsx("div",{className:"w-48 max-[640px]:w-full",children:fe(Ne)})]},Ne.key))})]}),Object.keys(y).length>1&&a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.currentOverrides")}),a.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(y).filter(([Ne])=>Ne!=="inherits").map(([Ne,ye])=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[Ne,": ",String(ye).slice(0,20),a.jsx("button",{onClick:()=>ue(Ne,void 0),className:"hover:text-white",children:a.jsx(Rt,{className:"w-3 h-3"})})]},Ne))})]})]}),l==="fields"&&a.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[a.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.availableFields")}),a.jsx("span",{className:"text-xs text-bambu-gray",children:se?r("profiles.templates.fieldsCount",{count:me.length}):r("common.loading")})]}),a.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[a.jsx(Mr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:C,onChange:Ne=>j(Ne.target.value),placeholder:r("profiles.presets.searchFieldsPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[Q.filter(Ne=>!(Ne.key in y)).map(Ne=>{const ye=$e[Ne.key],ve=Re(ye);return a.jsxs("div",{onClick:()=>{_(Ge=>({...Ge,[Ne.key]:ve||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white truncate",children:Ne.label}),a.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:Ne.key})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[ve&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:ve,children:[ve.slice(0,20),ve.length>20?"...":""]}),a.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:a.jsx(Xn,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},Ne.key)}),Q.filter(Ne=>!(Ne.key in y)).length===0&&a.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:r(C?"profiles.presets.noMatchingFields":"profiles.presets.allFieldsAdded")})]}),a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:z?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:B,onChange:Ne=>O(Ne.target.value),onKeyDown:Ne=>Ne.key==="Enter"&&ie(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx(Me,{size:"sm",onClick:ie,disabled:!B.trim(),children:a.jsx(Xn,{className:"w-4 h-4"})}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>{D(!1),O("")},children:a.jsx(Rt,{className:"w-4 h-4"})})]}):a.jsxs("button",{onClick:()=>D(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[a.jsx(Xn,{className:"w-4 h-4"}),r("profiles.presets.addCustomField")]})})]}),a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[a.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.yourOverrides")}),a.jsx("span",{className:"text-xs text-bambu-gray",children:r("profiles.templates.fieldsCount",{count:Object.keys(y).filter(Ne=>Ne!=="inherits").length})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(y).filter(([Ne])=>Ne!=="inherits").map(([Ne,ye])=>{const ve=me.find(Ge=>Ge.key===Ne);return a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-white",children:ve?.label||Ne}),a.jsx("p",{className:"text-xs text-bambu-gray-dark",children:Ne})]}),a.jsx("button",{onClick:()=>ue(Ne,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),ve?fe(ve):a.jsx("input",{type:"text",value:String(ye),onChange:Ge=>ue(Ne,Ge.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},Ne)}),Object.keys(y).filter(Ne=>Ne!=="inherits").length===0&&a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(OB,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:r("profiles.presets.noOverridesYet")}),a.jsx("p",{className:"text-xs mt-1",children:r("profiles.presets.clickFieldsToAdd")})]})]}),Object.keys(y).filter(Ne=>Ne!=="inherits").length>0&&a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:a.jsxs("button",{onClick:()=>{W(!0),c("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[a.jsx(bs,{className:"w-4 h-4"}),r("profiles.presets.saveAsTemplate")]})})]})]}),l==="json"&&a.jsxs("div",{className:"space-y-2",children:[k&&a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(Wa,{className:"w-4 h-4"}),k]}),a.jsx("textarea",{value:N,onChange:Ne=>L(Ne.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${k?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),a.jsx("p",{className:"text-xs text-bambu-gray",children:r("profiles.presets.jsonTip")})]})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),a.jsxs(Me,{onClick:()=>pe.mutate(),disabled:pe.isPending||!h.trim()||!o&&!p||!!k,className:"flex-1",children:[pe.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):o?a.jsx(bs,{className:"w-4 h-4"}):a.jsx(Xn,{className:"w-4 h-4"}),r(o?"common.save":e?"common.duplicate":"common.create")]})]})]})})]})}function JZe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i,hasPermission:s,t:o}){const[l,c]=w.useState(""),[d,u]=w.useState("all"),[h,f]=w.useState("all"),[p,x]=w.useState("all"),[v,g]=w.useState("all"),[y,_]=w.useState("all"),[N,T]=w.useState("all"),[k,M]=w.useState(null),[C,j]=w.useState(!1),[P,E]=w.useState(!1),[B,O]=w.useState(null),[z,D]=w.useState(null),[$,G]=w.useState(null),[U,W]=w.useState(!1),[Y,re]=w.useState([null,null]),[H,K]=w.useState(!1),[ee,Z]=w.useState(null),we=Jt(),oe=w.useMemo(()=>[...t.filament.map(ie=>({...ie,type:"filament"})),...t.printer.map(ie=>({...ie,type:"printer"})),...t.process.map(ie=>({...ie,type:"process"}))].map(ie=>({...ie,meta:uI(ie.name)})),[t]),J=w.useMemo(()=>{const Q=new Set,ie=new Set,ue=new Set;return oe.forEach(Le=>{Le.meta.nozzle&&Q.add(Le.meta.nozzle),Le.meta.filamentType&&ie.add(Le.meta.filamentType),Le.meta.layerHeight&&ue.add(Le.meta.layerHeight)}),{printers:i.map(Le=>({id:Le.id.toString(),name:Le.name})),nozzles:Array.from(Q).sort((Le,Ce)=>parseFloat(Le)-parseFloat(Ce)),filaments:Array.from(ie).sort(),layerHeights:Array.from(ue).sort((Le,Ce)=>parseFloat(Le)-parseFloat(Ce))}},[oe,i]),je=w.useMemo(()=>p==="all"?null:i.find(ie=>ie.id.toString()===p)?.model||null,[p,i]),de=w.useMemo(()=>oe.filter(Q=>d==="all"||Q.type===d).filter(Q=>{if(h==="all")return!0;const ie=i0(Q.setting_id);return h==="custom"?ie:!ie}).filter(Q=>{if(p==="all"||!je)return!0;const ie=Q.meta.printer?.toLowerCase()||"",ue=je.toLowerCase();return ie.includes(ue)||ue.includes(ie)}).filter(Q=>v==="all"||Q.meta.nozzle===v).filter(Q=>y==="all"||Q.meta.filamentType===y).filter(Q=>N==="all"||Q.meta.layerHeight===N).filter(Q=>l===""||Q.name.toLowerCase().includes(l.toLowerCase())).sort((Q,ie)=>Q.name.localeCompare(ie.name)),[oe,d,h,p,je,v,y,N,l]),le=Q=>{if(U){const ie=Y[0]?.setting_id===Q.setting_id,ue=Y[1]?.setting_id===Q.setting_id;if(ie)re([Y[1],null]);else if(ue)re([Y[0],null]);else if(!Y[0])re([Q,null]);else if(Y[1]){if(Y[0].type!==Q.type)return;re([Y[0],Q])}else{if(Y[0].type!==Q.type)return;re([Y[0],Q])}}else M(Q)},_e=Q=>{if(Y[0]?.setting_id===Q.setting_id)return 0;if(Y[1]?.setting_id===Q.setting_id)return 1},se=async Q=>{try{const ie=await ne.getCloudSettingDetail(Q.setting_id),ue=Q.type==="process"?"print":Q.type;O({type:ue,name:Q.name,base_id:ie.base_id||"GFSA00",setting:ie.setting||{}}),M(null)}catch(ie){console.error("Failed to fetch preset details for duplication:",ie)}},ze=async Q=>{try{we.removeQueries({queryKey:["cloudSettingDetail",Q.setting_id]});const ie=await ne.getCloudSettingDetail(Q.setting_id),ue=Q.type==="process"?"print":Q.type;D({type:ue,name:Q.name,base_id:ie.base_id||"GFSA00",setting:ie.setting||{},setting_id:Q.setting_id}),M(null)}catch(ie){console.error("Failed to fetch preset details for editing:",ie)}},V=()=>{u("all"),f("all"),x("all"),g("all"),_("all"),T("all"),c("")},X=d!=="all"||h!=="all"||p!=="all"||v!=="all"||y!=="all"||N!=="all"||l!=="",me=t.filament.length+t.printer.length+t.process.length;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-4 mb-6",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(Mr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:l,onChange:Q=>c(Q.target.value),placeholder:o("profiles.cloudView.searchPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex gap-2 max-[550px]:flex-wrap max-[550px]:items-center",children:[a.jsxs(Me,{variant:U?"primary":"secondary",onClick:()=>{U?(W(!1),re([null,null])):W(!0)},children:[a.jsx(qg,{className:"w-4 h-4"}),o(U?"common.cancel":"profiles.presets.compare")]}),a.jsxs(Me,{variant:"secondary",onClick:()=>E(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noTemplatesPermission"),children:[a.jsx(ub,{className:"w-4 h-4"}),o("profiles.cloudView.templates")]}),a.jsxs(Me,{variant:"secondary",onClick:n,disabled:r||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noRefreshPermission"),children:[a.jsx(vr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),o("profiles.cloudView.refresh")]}),a.jsxs(Me,{onClick:()=>j(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noCreatePermission"),children:[a.jsx(Xn,{className:"w-4 h-4"}),o("profiles.cloudView.newPreset")]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx($C,{className:"w-4 h-4 text-bambu-gray"}),a.jsx(Tg,{label:o("profiles.cloudView.filters.type"),value:d,options:[{value:"all",label:o("profiles.cloudView.filters.all"),count:me},{value:"filament",label:o("profiles.cloudView.filters.filament"),count:t.filament.length},{value:"printer",label:o("profiles.cloudView.filters.printer"),count:t.printer.length},{value:"process",label:o("profiles.cloudView.filters.process"),count:t.process.length}],onChange:Q=>u(Q)}),a.jsx(Tg,{label:o("profiles.cloudView.filters.owner"),value:h,options:[{value:"all",label:o("profiles.cloudView.filters.all")},{value:"custom",label:o("profiles.cloudView.filters.myPresets")},{value:"builtin",label:o("profiles.cloudView.filters.builtIn")}],onChange:Q=>f(Q)}),J.printers.length>0&&a.jsx(Tg,{label:o("profiles.cloudView.filters.printer"),value:p,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...J.printers.map(Q=>({value:Q.id,label:Q.name}))],onChange:x}),J.nozzles.length>0&&a.jsx(Tg,{label:o("profiles.cloudView.filters.nozzle"),value:v,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...J.nozzles.map(Q=>({value:Q,label:Q}))],onChange:g}),J.filaments.length>0&&(d==="all"||d==="filament")&&a.jsx(Tg,{label:o("profiles.cloudView.filters.filament"),value:y,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...J.filaments.map(Q=>({value:Q,label:Q}))],onChange:_}),J.layerHeights.length>0&&(d==="all"||d==="process")&&a.jsx(Tg,{label:o("profiles.cloudView.filters.layer"),value:N,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...J.layerHeights.map(Q=>({value:Q,label:Q}))],onChange:T}),X&&a.jsx("button",{onClick:V,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:o("profiles.cloudView.clearFilters")})]})]}),U&&a.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(qg,{className:"w-5 h-5 text-blue-400"}),a.jsx("span",{className:"text-white font-medium",children:o("profiles.cloudView.compareMode")}),a.jsx("span",{className:"text-bambu-gray",children:Y[0]?o("profiles.cloudView.selectAnotherPreset",{type:Y[0].type}):o("profiles.cloudView.clickTwoPresets")})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Y[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Y[0]?Y[0].name:o("profiles.cloudView.selectFirst")}),a.jsx(t3,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Y[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Y[1]?Y[1].name:o("profiles.cloudView.selectSecond")})]}),Y[0]&&Y[1]&&a.jsxs(Me,{size:"sm",onClick:async()=>{try{const[Q,ie]=await Promise.all([ne.getCloudSettingDetail(Y[0].setting_id),ne.getCloudSettingDetail(Y[1].setting_id)]);Z([Q.setting||{},ie.setting||{}]),K(!0)}catch{}},children:[a.jsx(qg,{className:"w-4 h-4"}),o("profiles.cloudView.compareNow")]})]})]})}),a.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Vn,{className:"w-3 h-3"}),o("profiles.cloudView.lastSynced")," ",bv(e.toISOString(),"system",o)]}),a.jsx("span",{children:o("profiles.cloudView.showingCount",{showing:de.length,total:me})}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),a.jsxs("span",{children:["= ",o("profiles.presets.myPreset")]})]})]}),de.length===0?a.jsxs("div",{className:"text-center py-16",children:[a.jsx(oi,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),a.jsx("p",{className:"text-bambu-gray",children:o("profiles.cloudView.noPresetsFound")}),X&&a.jsx("button",{onClick:V,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:o("profiles.cloudView.clearFilters")})]}):a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(BC,{className:"w-4 h-4 text-amber-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.filament")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",de.filter(Q=>Q.type==="filament").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[de.filter(Q=>Q.type==="filament").map(Q=>a.jsx(Ej,{setting:Q,onClick:()=>le(Q),onDuplicate:()=>se(Q),compareMode:U,isCompareSelected:_e(Q)!==void 0,compareIndex:_e(Q),compareDisabled:U&&!!Y[0]&&Y[0].type!==Q.type,t:o},Q.setting_id)),de.filter(Q=>Q.type==="filament").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noFilamentPresets")})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(eu,{className:"w-4 h-4 text-blue-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.process")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",de.filter(Q=>Q.type==="process").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[de.filter(Q=>Q.type==="process").map(Q=>a.jsx(Ej,{setting:Q,onClick:()=>le(Q),onDuplicate:()=>se(Q),compareMode:U,isCompareSelected:_e(Q)!==void 0,compareIndex:_e(Q),compareDisabled:U&&!!Y[0]&&Y[0].type!==Q.type,t:o},Q.setting_id)),de.filter(Q=>Q.type==="process").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noProcessPresets")})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(Sr,{className:"w-4 h-4 text-purple-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.printer")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",de.filter(Q=>Q.type==="printer").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[de.filter(Q=>Q.type==="printer").map(Q=>a.jsx(Ej,{setting:Q,onClick:()=>le(Q),onDuplicate:()=>se(Q),compareMode:U,isCompareSelected:_e(Q)!==void 0,compareIndex:_e(Q),compareDisabled:U&&!!Y[0]&&Y[0].type!==Q.type,t:o},Q.setting_id)),de.filter(Q=>Q.type==="printer").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noPrinterPresets")})]})]})]}),k&&a.jsx(XZe,{setting:k,onClose:()=>M(null),onDeleted:()=>M(null),onDuplicate:()=>se(k),onEdit:()=>ze(k),hasPermission:s,t:o}),(C||B||z||$)&&a.jsx(ZZe,{onClose:()=>{j(!1),O(null),D(null),G(null)},initialData:z||B||($?{type:$.type,name:"",base_id:"",setting:$.setting}:void 0),allPresets:t,t:o}),P&&a.jsx(QZe,{onClose:()=>E(!1),onApply:Q=>{G({type:Q.type,setting:Q.settings}),E(!1)},t:o}),H&&ee&&Y[0]&&Y[1]&&a.jsx(Xie,{onClose:()=>{K(!1),Z(null)},leftPreset:ee[0],rightPreset:ee[1],leftLabel:Y[0].name,rightLabel:Y[1].name,t:o})]})}function eJe(){const{t}=Dt(),e=Jt(),{showToast:n}=ln(),{hasPermission:r}=Pr(),[i,s]=w.useState("cloud"),[o,l]=w.useState(),{data:c,isLoading:d}=Je({queryKey:["cloudStatus"],queryFn:ne.getCloudStatus}),{data:u=[]}=Je({queryKey:["printers"],queryFn:ne.getPrinters}),{data:h,isLoading:f,refetch:p,dataUpdatedAt:x}=Je({queryKey:["cloudSettings"],queryFn:()=>ne.getCloudSettings(),enabled:!!c?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{x&&l(new Date(x))},[x]);const v=st({mutationFn:ne.cloudLogout,onSuccess:()=>{e.invalidateQueries({queryKey:["cloudStatus"]}),e.removeQueries({queryKey:["cloudSettings"]}),n(t("profiles.toast.loggedOut"))}}),g=()=>{e.invalidateQueries({queryKey:["cloudStatus"]})};return d?a.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"p-6 lg:p-8",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("profiles.title")}),a.jsx("p",{className:"text-bambu-gray",children:t("profiles.subtitle")})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[a.jsxs("button",{onClick:()=>s("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(Hb,{className:"w-4 h-4"}),t("profiles.tabs.cloud")]}),a.jsxs("button",{onClick:()=>s("local"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="local"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx($b,{className:"w-4 h-4"}),t("profiles.tabs.local")]}),a.jsxs("button",{onClick:()=>s("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(VC,{className:"w-4 h-4"}),t("profiles.tabs.kprofiles")]})]}),i==="cloud"&&a.jsxs(a.Fragment,{children:[c?.is_authenticated&&a.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("profiles.connectedAs")," ",a.jsx("span",{className:"text-white",children:c.email})]})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>v.mutate(),disabled:v.isPending||!r("cloud:auth"),title:r("cloud:auth")?void 0:t("profiles.noLogoutPermission"),children:[a.jsx(s3,{className:"w-4 h-4"}),t("profiles.logout")]})]}),c?.is_authenticated?f?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h?a.jsx(JZe,{settings:h,lastSyncTime:o,onRefresh:()=>p(),isRefreshing:f,printers:u,hasPermission:r,t}):a.jsxs("div",{className:"text-center py-16",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:t("profiles.failedToLoad")}),a.jsx(Me,{onClick:()=>p(),children:t("profiles.retry")})]}):a.jsx(KZe,{onSuccess:g,t})]}),i==="local"&&a.jsx(WZe,{}),i==="kprofiles"&&a.jsx($Ze,{}),a.jsx(YZe,{})]})}const zy={Droplet:BC,Flame:bme,Ruler:Qfe,Sparkles:ub,Square:vl,Cable:ehe,Wrench:jf,Calendar:sa,Timer:Ld,Cog:Uhe,Fan:pY,Zap:nu,Wind:kY,Thermometer:ZC,Layers:oi,Box:ai,Target:_Y,RefreshCw:vr,Settings:QC,Filter:$C,CircleDot:whe};function cv(t){return t&&zy[t]||jf}function Mg(t,e,n){if(e==="days"){if(t<1)return n?n("common.today"):"Today";if(t===1)return n?n("maintenance.day"):"1 day";if(t<7){const i=Math.round(t);return n?n("maintenance.days",{count:i}):`${i} days`}if(t<180){const i=Math.round(t/7);return i===1?n?n("maintenance.week"):"1 week":n?n("maintenance.weeks",{count:i}):`${i} weeks`}const r=Math.round(t/30);return r===1?n?n("maintenance.month"):"1 month":n?n("maintenance.months",{count:r}):`${r} months`}else{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const r=t/24;if(r<7)return`${r<2?r.toFixed(1):Math.round(r)}d`;const i=r/7;return i<12?`${i<2?i.toFixed(1):Math.round(i)}w`:`${Math.round(i/4)}mo`}}function jj(t,e,n){return e==="days"?t===1?n?n("maintenance.day"):"1 day":t===7?n?n("maintenance.week"):"1 week":t===14?n?n("maintenance.weeks",{count:2}):"2 weeks":t===30?n?n("maintenance.month"):"1 month":t===60?n?n("maintenance.months",{count:2}):"2 months":t===90?n?n("maintenance.months",{count:3}):"3 months":t===180?n?n("maintenance.months",{count:6}):"6 months":t===365?n?n("maintenance.year"):"1 year":n?n("maintenance.days",{count:t}):`${t} days`:`${t}h`}function tJe(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),i=n.includes("P1"),s=n.includes("A1MINI"),o=n.includes("A1")&&!s,l=n.includes("H2D"),c=n.includes("H2C"),d=n.includes("H2S"),u=l||c||d,h=n.includes("P2S");switch(t){case"Lubricate Carbon Rods":return r?"https://wiki.bambulab.com/en/x1/maintenance/basic-maintenance":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":h?"https://wiki.bambulab.com/en/p2s/maintenance/lubricate-x-y-z-axis":null;case"Lubricate Linear Rails":return s?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":u?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;case"Clean Nozzle/Hotend":return r||i?"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog":s||o?"https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog":u?"https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning":h?"https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend":"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog";case"Check Belt Tension":return r?"https://wiki.bambulab.com/en/x1/maintenance/belt-tension":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":s?"https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension":o?"https://wiki.bambulab.com/en/a1/maintenance/belt_tension":l?"https://wiki.bambulab.com/en/h2/maintenance/belt-tension":c?"https://wiki.bambulab.com/en/h2c/maintenance/belt-tension":d?"https://wiki.bambulab.com/en/h2s/maintenance/belt-tension":h?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/x1/maintenance/belt-tension";case"Clean Carbon Rods":return r||i||h?"https://wiki.bambulab.com/en/general/carbon-rods-clearance":null;case"Clean Linear Rails":return s?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":u?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;case"Clean Build Plate":return"https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide";case"Check PTFE Tube":return r||i?"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube":s||o?"https://wiki.bambulab.com/en/a1-mini/maintenance/ptfe-tube":l?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":d?"https://wiki.bambulab.com/en/h2s/maintenance/replace-ptfe-tube-on-h2s-printer":c?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube";case"Replace HEPA Filter":case"HEPA Filter":case"Replace Carbon Filter":case"Carbon Filter":return u?"https://wiki.bambulab.com/en/h2/maintenance/replace-smoke-purifier-air-filte":"https://wiki.bambulab.com/en/x1/maintenance/replace-carbon-filter";case"Lubricate Left Nozzle Rail":case"Left Nozzle Rail":return u?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;default:return null}}function nJe({item:t,onPerform:e,onToggle:n,hasPermission:r,t:i}){const s=cv(t.maintenance_type_icon),o=t.interval_type||"hours",c=(()=>{if(o==="days"){const p=t.days_since_maintenance??0;return Math.max(0,Math.min(100,p/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),d=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",u=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",h=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",f=()=>{if(!t.enabled)return i("common.disabled");if(o==="days"){const p=t.days_until_due??0;return t.is_due?i("maintenance.overdueBy",{duration:Mg(Math.abs(p),"days",i)}):t.is_warning?i("maintenance.dueIn",{duration:Mg(p,"days",i)}):i("maintenance.timeLeft",{duration:Mg(p,"days",i)})}else return t.is_due?i("maintenance.overdueBy",{duration:Mg(Math.abs(t.hours_until_due),"hours",i)}):t.is_warning?i("maintenance.dueIn",{duration:Mg(t.hours_until_due,"hours",i)}):i("maintenance.timeLeft",{duration:Mg(t.hours_until_due,"hours",i)})};return a.jsx("div",{className:`rounded-xl border p-4 transition-all ${h()}`,children:a.jsxs("div",{className:"flex items-start gap-3 max-[550px]:flex-wrap",children:[a.jsxs("div",{className:`relative p-2.5 rounded-lg shrink-0 ${t.is_due?"bg-red-500/20":t.is_warning?"bg-amber-500/20":t.enabled?"bg-bambu-dark":"bg-bambu-dark/50"}`,children:[a.jsx(s,{className:`w-5 h-5 ${d()}`}),t.enabled&&(t.is_due||t.is_warning)&&a.jsx("span",{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${t.is_due?"bg-red-500":"bg-amber-500"} animate-pulse`})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),o==="days"&&a.jsx("span",{title:i("maintenance.timeBasedInterval"),children:a.jsx(sa,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const p=t.maintenance_type_wiki_url||tJe(t.maintenance_type_name,t.printer_model);return p?a.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:i("maintenance.viewDocumentation"),onClick:x=>x.stopPropagation(),children:a.jsx(Zr,{className:"w-3.5 h-3.5"})}):null})()]}),a.jsx("div",{className:"mt-2 mb-1.5",children:a.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${u()}`,style:{width:`${c}%`}})})}),a.jsxs("div",{className:`text-xs flex items-center gap-1 ${d()}`,children:[t.is_due&&a.jsx(An,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&a.jsx(Vn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&a.jsx(Jr,{className:"w-3 h-3"}),f()]})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0 max-[550px]:w-full max-[550px]:justify-end max-[550px]:mt-1",children:[a.jsx("span",{title:r("maintenance:update")?void 0:i("maintenance.noPermissionUpdate"),children:a.jsx(Ln,{checked:t.enabled,onChange:p=>n(t.id,p),disabled:!r("maintenance:update")})}),a.jsxs(Me,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled||!r("maintenance:update"),title:r("maintenance:update")?void 0:i("maintenance.noPermissionPerform"),className:"!px-3",children:[a.jsx(so,{className:"w-3.5 h-3.5"}),i("common.reset")]})]})]})})}function rJe({overview:t,onPerform:e,onToggle:n,onSetHours:r,hasPermission:i,t:s}){const[o,l]=w.useState(!1),[c,d]=w.useState(!1),[u,h]=w.useState(t.total_print_hours.toFixed(1)),f=[...t.maintenance_items].sort((v,g)=>v.is_due&&!g.is_due?-1:!v.is_due&&g.is_due?1:v.is_warning&&!g.is_warning?-1:!v.is_warning&&g.is_warning?1:v.maintenance_type_id-g.maintenance_type_id),p=f.find(v=>v.enabled&&(v.is_due||v.is_warning)),x=()=>{const v=parseFloat(u);!isNaN(v)&&v>=0&&(r(t.printer_id,v),d(!1))};return a.jsxs(wt,{className:"overflow-hidden",children:[a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),a.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&a.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(An,{className:"w-3 h-3"}),s("maintenance.overdueCount",{count:t.due_count})]}),t.warning_count>0&&a.jsxs("span",{className:"px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(Vn,{className:"w-3 h-3"}),s("maintenance.dueSoonCount",{count:t.warning_count})]}),t.due_count===0&&t.warning_count===0&&a.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(Jr,{className:"w-3 h-3"}),s("maintenance.allGood")]})]})]}),a.jsxs("button",{onClick:()=>l(!o),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[o?a.jsx(yl,{className:"w-4 h-4"}):a.jsx(Pn,{className:"w-4 h-4"}),s(o?"common.collapse":"common.expand")]})]}),a.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:a.jsx(Ld,{className:"w-4 h-4 text-bambu-gray"})}),c?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",value:u,onChange:v=>h(v.target.value),onKeyDown:v=>{v.key==="Enter"&&x(),v.key==="Escape"&&d(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),a.jsx("span",{className:"text-xs text-bambu-gray",children:s("common.hours")}),a.jsx(Me,{size:"sm",onClick:x,children:s("common.save")}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>d(!1),children:s("common.cancel")})]}):a.jsxs("button",{onClick:()=>{i("maintenance:update")&&(h(Math.round(t.total_print_hours).toString()),d(!0))},className:`group ${i("maintenance:update")?"":"cursor-not-allowed opacity-60"}`,title:i("maintenance:update")?void 0:s("maintenance.noPermissionEditHours"),children:[a.jsxs("div",{className:`text-sm font-medium text-white ${i("maintenance:update")?"group-hover:text-bambu-green":""} transition-colors flex items-center gap-1`,children:[Math.round(t.total_print_hours)," ",s("common.hours"),a.jsx(Pf,{className:`w-3 h-3 text-bambu-gray ${i("maintenance:update")?"group-hover:text-bambu-green":""}`})]}),a.jsx("div",{className:"text-xs text-bambu-gray",children:s("maintenance.totalPrintTime")})]})]}),a.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),p&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${p.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const v=cv(p.maintenance_type_icon);return a.jsx(v,{className:`w-4 h-4 ${p.is_due?"text-red-400":"text-amber-400"}`})})()}),a.jsxs("div",{children:[a.jsx("div",{className:`text-sm font-medium ${p.is_due?"text-red-400":"text-amber-400"}`,children:p.maintenance_type_name}),a.jsx("div",{className:`text-xs ${p.is_due?"text-red-400/70":"text-amber-400/70"}`,children:p.is_due?s("common.overdue"):s("maintenance.dueSoon")})]})]})]})]}),o&&a.jsx(Nt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:a.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:f.map(v=>a.jsx(nJe,{item:v,onPerform:e,onToggle:n,hasPermission:i,t:s},v.id))})})]})}function aJe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:s,onRestoreDefaults:o,isRestoringDefaults:l,onAssignType:c,onRemoveItem:d,hasPermission:u,t:h}){const[f,p]=w.useState(null),[x,v]=w.useState(""),[g,y]=w.useState("hours"),[_,N]=w.useState(!1),[T,k]=w.useState(""),[M,C]=w.useState("100"),[j,P]=w.useState("hours"),[E,B]=w.useState("Wrench"),[O,z]=w.useState(""),[D,$]=w.useState(new Set),[G,U]=w.useState(null),[W,Y]=w.useState(null),re=w.useMemo(()=>t?t.map(L=>({id:L.printer_id,name:L.printer_name})):[],[t]),H=L=>t?t.filter(R=>R.maintenance_items.some(q=>q.maintenance_type_id===L)).map(R=>({printerId:R.printer_id,printerName:R.printer_name,itemId:R.maintenance_items.find(q=>q.maintenance_type_id===L)?.id})):[],K=L=>{if(!t)return[];const R=new Set(H(L).map(q=>q.printerId));return re.filter(q=>!R.has(q.id))},[ee,Z]=w.useState(null),[we,oe]=w.useState(""),[J,je]=w.useState(""),[de,le]=w.useState("hours"),[_e,se]=w.useState("Wrench"),[ze,V]=w.useState(""),X=L=>{Z(L),oe(L.name),je(L.default_interval_hours.toString()),le(L.interval_type||"hours"),se(L.icon||"Wrench"),V(L.wiki_url||"")},me=()=>{ee&&we.trim()&&parseFloat(J)>0&&(i(ee.id,{name:we.trim(),default_interval_hours:parseFloat(J),interval_type:de,icon:_e,wiki_url:ze.trim()||null}),Z(null))},Q=(L,R,q)=>{const ce=parseFloat(x);if(!isNaN(ce)&&ce>0){const pe=Math.abs(ce-R)<.01?null:ce;n(L,{custom_interval_hours:pe,custom_interval_type:g!==q?g:null})}p(null)},ie=L=>{L.preventDefault(),T.trim()&&parseFloat(M)>0&&D.size>0&&(r({name:T.trim(),default_interval_hours:parseFloat(M),interval_type:j,icon:E,wiki_url:O.trim()||null},Array.from(D)),k(""),C("100"),P("hours"),z(""),$(new Set),N(!1))},ue=L=>{$(R=>{const q=new Set(R);return q.has(L)?q.delete(L):q.add(L),q})},Le=t?.map(L=>({printerId:L.printer_id,printerName:L.printer_name,items:L.maintenance_items.sort((R,q)=>R.maintenance_type_id-q.maintenance_type_id)})).sort((L,R)=>L.printerName.localeCompare(R.printerName))||[],Ce=e.filter(L=>L.is_system),ge=e.filter(L=>!L.is_system);return a.jsxs("div",{className:"space-y-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:h("maintenance.maintenanceTypes")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:h("maintenance.maintenanceTypesDescription")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:o,disabled:!u("maintenance:delete")||l,title:u("maintenance:delete")?void 0:h("maintenance.noPermissionDeleteTypes"),children:h("maintenance.restoreDefaults")}),a.jsxs(Me,{onClick:()=>N(!_),disabled:!u("maintenance:create"),title:u("maintenance:create")?void 0:h("maintenance.noPermissionEditTypes"),children:[a.jsx(Xn,{className:"w-4 h-4"}),h("maintenance.addCustomType")]})]})]}),_&&a.jsx(wt,{className:"mb-6",children:a.jsx(Nt,{className:"py-4",children:a.jsxs("form",{onSubmit:ie,children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[a.jsxs("div",{className:"lg:col-span-2",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("common.name")}),a.jsx("input",{type:"text",value:T,onChange:L=>k(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:h("maintenance.exampleName"),autoFocus:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.intervalType")}),a.jsxs("select",{value:j,onChange:L=>{P(L.target.value),L.target.value==="days"?C("30"):C("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"hours",children:h("maintenance.printHours")}),a.jsx("option",{value:"days",children:h("maintenance.calendarDays")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.intervalValue",{type:j==="days"?h("maintenance.calendarDays").toLowerCase():h("common.hours")})}),a.jsx("input",{type:"number",value:M,onChange:L=>C(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),a.jsx("div",{className:"mt-4 flex items-end justify-between",children:a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.icon")}),a.jsx("div",{className:"flex gap-1",children:Object.keys(zy).map(L=>{const R=zy[L];return a.jsx("button",{type:"button",onClick:()=>B(L),className:`p-2 rounded-lg transition-colors ${E===L?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:a.jsx(R,{className:"w-4 h-4"})},L)})})]})}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.documentationLink")}),a.jsx("input",{type:"url",value:O,onChange:L=>z(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"https://wiki.bambulab.com/..."})]}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.assignToPrinters")}),a.jsx("div",{className:"flex flex-wrap gap-2",children:re.map(L=>a.jsx("button",{type:"button",onClick:()=>ue(L.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${D.has(L.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:L.name},L.id))}),D.size===0&&a.jsx("p",{className:"text-xs text-orange-400 mt-1",children:h("maintenance.selectAtLeastOnePrinter")})]}),a.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:()=>{N(!1),$(new Set)},children:h("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!T.trim()||D.size===0,children:h("maintenance.addType")})]})]})})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[Ce.map(L=>{const R=cv(L.icon),q=L.interval_type||"hours";return a.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:a.jsx(R,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-sm font-medium text-white truncate",children:L.name}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[q==="days"?a.jsx(sa,{className:"w-3 h-3"}):a.jsx(Ld,{className:"w-3 h-3"}),jj(L.default_interval_hours,q,h)]})]}),a.jsx("button",{onClick:()=>{u("maintenance:delete")&&Y(L)},disabled:!u("maintenance:delete"),title:u("maintenance:delete")?void 0:h("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${u("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Xt,{className:"w-4 h-4"})})]})},L.id)}),ge.map(L=>{const R=cv(L.icon),q=L.interval_type||"hours";if(ee?.id===L.id)return a.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:a.jsxs("div",{className:"space-y-3",children:[a.jsx("input",{type:"text",value:we,onChange:Ie=>oe(Ie.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:h("common.name"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("select",{value:de,onChange:Ie=>le(Ie.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"hours",children:h("maintenance.printHours")}),a.jsx("option",{value:"days",children:h("maintenance.calendarDays")})]}),a.jsx("input",{type:"number",value:J,onChange:Ie=>je(Ie.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),a.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(zy).map(Ie=>{const $e=zy[Ie];return a.jsx("button",{type:"button",onClick:()=>se(Ie),className:`p-1.5 rounded transition-colors ${_e===Ie?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:a.jsx($e,{className:"w-3.5 h-3.5"})},Ie)})}),a.jsx("input",{type:"url",value:ze,onChange:Ie=>V(Ie.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:h("maintenance.documentationLink")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{size:"sm",onClick:me,disabled:!we.trim(),children:h("common.save")}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>Z(null),children:h("common.cancel")})]})]})},L.id);const pe=H(L.id),te=K(L.id),Be=G===L.id;return a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:a.jsx(R,{className:"w-5 h-5 text-bambu-green"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium text-white truncate",children:L.name}),a.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:h("maintenance.custom")})]}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[q==="days"?a.jsx(sa,{className:"w-3 h-3"}):a.jsx(Ld,{className:"w-3 h-3"}),jj(L.default_interval_hours,q,h)]})]}),a.jsxs("button",{onClick:()=>U(Be?null:L.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${pe.length>0?"border-bambu-green/50 bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20":"border-orange-400/50 bg-orange-400/10 text-orange-400 hover:bg-orange-400/20"}`,title:h("maintenance.printersAssignedClick",{count:pe.length}),children:[a.jsx(Sr,{className:"w-3 h-3"}),a.jsx("span",{className:"text-xs font-medium",children:pe.length}),a.jsx(Pn,{className:`w-3 h-3 transition-transform ${Be?"rotate-180":""}`})]}),a.jsx("button",{onClick:()=>X(L),disabled:!u("maintenance:update"),title:u("maintenance:update")?void 0:h("maintenance.noPermissionEditTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors ${u("maintenance:update")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Pf,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{confirm(h("maintenance.deleteTypeConfirm",{name:L.name}))&&s(L.id)},disabled:!u("maintenance:delete"),title:u("maintenance:delete")?void 0:h("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${u("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Xt,{className:"w-4 h-4"})})]}),Be&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:h("maintenance.assignedToPrinters")}),pe.length===0?a.jsx("p",{className:"text-xs text-orange-400",children:h("maintenance.noPrintersAssigned")}):a.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:pe.map(Ie=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[Ie.printerName,a.jsx("button",{onClick:()=>Ie.itemId&&d(Ie.itemId),disabled:!u("maintenance:delete"),title:u("maintenance:delete")?h("maintenance.removeFromPrinter"):h("maintenance.noPermissionRemovePrinter"),className:`ml-1 ${u("maintenance:delete")?"hover:text-red-400":"opacity-50 cursor-not-allowed"}`,children:"×"})]},Ie.printerId))}),te.length>0&&a.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:h("maintenance.addPrinterShort")}),te.map(Ie=>a.jsxs("button",{onClick:()=>c(Ie.id,L.id),disabled:!u("maintenance:create"),title:u("maintenance:create")?void 0:h("maintenance.noPermissionAssignPrinter"),className:`px-2 py-1 bg-bambu-dark rounded text-xs transition-colors ${u("maintenance:create")?"hover:bg-bambu-green/20 text-bambu-gray hover:text-bambu-green":"opacity-50 cursor-not-allowed text-bambu-gray"}`,children:["+ ",Ie.name]},Ie.id))]})]})]},L.id)})]})]}),Le.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"mb-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:h("maintenance.intervalOverrides")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:h("maintenance.intervalOverridesDescription")})]}),a.jsx("div",{className:"space-y-4",children:Le.map(L=>a.jsx(wt,{children:a.jsxs(Nt,{className:"py-4",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:L.printerName}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:L.items.map(R=>{const q=cv(R.maintenance_type_icon),ce=e.find($e=>$e.id===R.maintenance_type_id),pe=ce?.default_interval_hours||R.interval_hours,te=ce?.interval_type||"hours",Be=R.interval_type||"hours",Ie=f===R.id;return a.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[a.jsx(q,{className:"w-4 h-4 text-bambu-gray shrink-0"}),a.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:R.maintenance_type_name}),Ie?a.jsxs("div",{className:"flex items-center gap-1",children:[g==="days"?a.jsx(sa,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):a.jsx(Ld,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),a.jsxs("select",{value:g,onChange:$e=>y($e.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[a.jsx("option",{value:"hours",children:h("maintenance.printHours")}),a.jsx("option",{value:"days",children:h("maintenance.calendarDays")})]}),a.jsx("input",{type:"number",value:x,onChange:$e=>v($e.target.value),onKeyDown:$e=>{$e.key==="Enter"&&Q(R.id,pe,te),$e.key==="Escape"&&p(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),a.jsx(Me,{size:"sm",onClick:()=>Q(R.id,pe,te),children:"OK"})]}):a.jsxs("button",{onClick:()=>{u("maintenance:update")&&(p(R.id),v(R.interval_hours.toString()),y(Be))},disabled:!u("maintenance:update"),title:u("maintenance:update")?void 0:h("maintenance.noPermissionEditIntervals"),className:`px-2 py-1 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs font-medium text-white transition-colors flex items-center gap-1 ${u("maintenance:update")?"hover:bg-bambu-dark-secondary hover:border-bambu-green":"opacity-50 cursor-not-allowed"}`,children:[Be==="days"?a.jsx(sa,{className:"w-3 h-3"}):a.jsx(Ld,{className:"w-3 h-3"}),jj(R.interval_hours,Be,h),a.jsx(Pf,{className:"w-3 h-3 text-bambu-gray"})]})]},R.id)})})]})},L.printerId))})]}),Le.length===0&&a.jsx(wt,{children:a.jsxs(Nt,{className:"text-center py-12",children:[a.jsx(Vn,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-bambu-gray",children:h("common.noPrinters")}),a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:h("maintenance.intervalOverridesDescription")})]})}),W&&a.jsx(xn,{title:h("maintenance.deleteSystemTypeTitle"),message:h("maintenance.deleteSystemTypeMessage",{name:W.name}),confirmText:h("common.delete"),cancelText:h("common.cancel"),variant:"danger",cancelVariant:"primary",cardClassName:"bg-red-950/70 border border-red-800/70",onConfirm:()=>{s(W.id),Y(null)},onCancel:()=>Y(null)})]})}function iJe(){const{t}=Dt(),e=Jt(),{showToast:n}=ln(),{hasPermission:r}=Pr(),[i,s]=w.useState("status"),{data:o,isLoading:l}=Je({queryKey:["maintenanceOverview"],queryFn:ne.getMaintenanceOverview}),{data:c}=Je({queryKey:["maintenanceTypes"],queryFn:ne.getMaintenanceTypes}),d=st({mutationFn:({id:M,notes:C})=>ne.performMaintenance(M,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.maintenanceComplete"))},onError:M=>{n(M.message,"error")}}),u=st({mutationFn:({id:M,data:C})=>ne.updateMaintenanceItem(M,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:M=>{n(M.message,"error")}}),h=st({mutationFn:({id:M,data:C})=>ne.updateMaintenanceType(M,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onError:M=>{n(M.message,"error")}}),f=st({mutationFn:ne.deleteMaintenanceType,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeDeleted"))},onError:M=>{n(M.message,"error")}}),p=st({mutationFn:ne.restoreDefaultMaintenanceTypes,onSuccess:M=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.defaultsRestored",{count:M.restored}))},onError:M=>{n(M.message,"error")}}),x=st({mutationFn:({printerId:M,hours:C})=>ne.setPrinterHours(M,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.printHoursUpdated"))},onError:M=>{n(M.message,"error")}}),v=st({mutationFn:({printerId:M,typeId:C})=>ne.assignMaintenanceType(M,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerAssigned"))},onError:M=>{n(M.message,"error")}}),g=st({mutationFn:ne.removeMaintenanceItem,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerRemoved"))},onError:M=>{n(M.message,"error")}}),y=M=>{d.mutate({id:M})},_=(M,C)=>{u.mutate({id:M,data:{enabled:C}})},N=(M,C)=>{x.mutate({printerId:M,hours:C})};if(l)return a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})});const T=o?.reduce((M,C)=>M+C.due_count,0)||0,k=o?.reduce((M,C)=>M+C.warning_count,0)||0;return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("maintenance.title")}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:i==="status"?a.jsxs(a.Fragment,{children:[T>0&&a.jsx("span",{className:"text-red-400",children:t("maintenance.dueCount",{count:T})}),T>0&&k>0&&" · ",k>0&&a.jsx("span",{className:"text-amber-400",children:t("maintenance.warningCount",{count:k})}),T===0&&k===0&&a.jsx("span",{className:"text-bambu-green",children:t("maintenance.allOk")})]}):t("maintenance.configureSettings")})]}),a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>s("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.statusTab")}),a.jsx("button",{onClick:()=>s("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.settingsTab")})]}),i==="status"?a.jsx("div",{className:"space-y-6",children:o&&o.length>0?[...o].sort((M,C)=>{const j=M.due_count*10+M.warning_count,P=C.due_count*10+C.warning_count;return j!==P?P-j:M.printer_name.localeCompare(C.printer_name)}).map(M=>a.jsx(rJe,{overview:M,onPerform:y,onToggle:_,onSetHours:N,hasPermission:r,t},M.printer_id)):a.jsx(wt,{children:a.jsxs(Nt,{className:"text-center py-16",children:[a.jsx(jf,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:t("common.noPrinters")}),a.jsx("p",{className:"text-bambu-gray",children:t("maintenance.configureSettings")})]})})}):a.jsx(aJe,{overview:o,types:c||[],onUpdateInterval:(M,C)=>u.mutate({id:M,data:C}),onAddType:async(M,C)=>{const j=await ne.createMaintenanceType(M);for(const P of C)await ne.assignMaintenanceType(P,j.id);e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onUpdateType:(M,C)=>h.mutate({id:M,data:C}),onDeleteType:M=>f.mutate(M),onRestoreDefaults:()=>p.mutate(),isRestoringDefaults:p.isPending,onAssignType:(M,C)=>v.mutate({printerId:M,typeId:C}),onRemoveItem:M=>g.mutate(M),hasPermission:r,t})]})}const aK=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Qie({project:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=w.useState(t?.name||""),[l,c]=w.useState(t?.description||""),[d,u]=w.useState(t?.color||aK[0]),[h,f]=w.useState(t?.target_count?.toString()||""),[p,x]=w.useState(t?.target_parts_count?.toString()||""),[v,g]=w.useState(t?.status||"active"),[y,_]=w.useState(t?.tags||""),[N,T]=w.useState(t?.due_date?.split("T")[0]||""),[k,M]=w.useState(t?.priority||"normal"),C=j=>{j.preventDefault(),n({name:s.trim(),description:l.trim()||void 0,color:d,target_count:h?parseInt(h,10):void 0,target_parts_count:p?parseInt(p,10):void 0,tags:y.trim()||void 0,due_date:N||void 0,priority:k,...t&&{status:v}})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i(t?"projects.editProject":"projects.newProject")})}),a.jsxs("form",{onSubmit:C,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.name")}),a.jsx("input",{type:"text",value:s,onChange:j=>o(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.namePlaceholder"),required:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.description")}),a.jsx("textarea",{value:l,onChange:j=>c(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green resize-none",placeholder:i("projects.descriptionPlaceholder"),rows:2})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.color")}),a.jsx("div",{className:"flex gap-2 flex-wrap",children:aK.map(j=>a.jsx("button",{type:"button",onClick:()=>u(j),className:`w-8 h-8 rounded-full transition-transform ${d===j?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:j}},j))})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetPlates")}),a.jsx("input",{type:"number",value:h,onChange:j=>f(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.targetPlatesPlaceholder"),min:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPlatesHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetParts")}),a.jsx("input",{type:"number",value:p,onChange:j=>x(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.targetPartsPlaceholder"),min:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPartsHelp")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.tagsLabel")}),a.jsx("input",{type:"text",value:y,onChange:j=>_(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.tagsPlaceholder")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.dueDate")}),a.jsx("input",{type:"date",value:N,onChange:j=>T(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.priority")}),a.jsxs("select",{value:k,onChange:j=>M(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"low",children:i("projects.priorityLow")}),a.jsx("option",{value:"normal",children:i("projects.priorityNormal")}),a.jsx("option",{value:"high",children:i("projects.priorityHigh")}),a.jsx("option",{value:"urgent",children:i("projects.priorityUrgent")})]})]})]}),t&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.status")}),a.jsxs("select",{value:v,onChange:j=>g(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"active",children:i("projects.statusActive")}),a.jsx("option",{value:"completed",children:i("projects.statusCompleted")}),a.jsx("option",{value:"archived",children:i("projects.statusArchived")})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(at,{className:"w-4 h-4 animate-spin"}):i(t?"common.save":"projects.create")})]})]})]})})}function sJe({project:t,onClick:e,onEdit:n,onDelete:r,hasPermission:i,t:s}){const o=t.target_count?Math.round(t.archive_count/t.target_count*100):0,l=t.target_parts_count?Math.round(t.completed_count/t.target_parts_count*100):0,c=t.status==="completed",d=t.status==="archived",[u,h]=w.useState(!1),p=c?{icon:db,color:"text-bambu-green",bg:"bg-bambu-green/10"}:d?{icon:Ds,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:Vn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:xs,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return a.jsxs("div",{className:"group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden",onClick:e,children:[a.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full",style:{backgroundColor:t.color||"#6b7280",boxShadow:`0 0 12px ${t.color||"#6b7280"}40`}}),a.jsxs("div",{className:"p-5 pl-6",children:[a.jsxs("div",{className:"flex items-start justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("div",{className:`p-2 rounded-lg ${p.bg} flex-shrink-0`,children:a.jsx(p.icon,{className:`w-5 h-5 ${p.color}`})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_parts_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${l>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," ",s("projects.parts")]}):t.target_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${o>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.archive_count,"/",t.target_count," ",s("projects.plates")]}):t.completed_count>0?a.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium bg-bambu-dark text-bambu-gray",children:[t.completed_count," ",s("projects.parts")]}):null,c&&a.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.done")}),d&&a.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.statusArchived")})]}),t.description&&a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const x=t.archives.map(_=>_.filament_type).filter(Boolean).flatMap(_=>_.split(",").map(N=>N.trim())).filter(Boolean),v=[...new Set(x)],g=t.archives.map(_=>_.filament_color).filter(Boolean).flatMap(_=>_.split(",").map(N=>N.trim())).filter(_=>_.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(_)),y=[...new Set(g)];return v.length===0&&y.length===0?null:a.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[v.slice(0,3).map(_=>a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:_},_)),y.length>0&&a.jsxs("div",{className:"flex items-center gap-0.5",children:[y.slice(0,5).map(_=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:_.startsWith("#")?_:`#${_}`},title:_},_)),y.length>5&&a.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",y.length-5]})]})]})})()]})]}),a.jsxs("div",{className:"relative",onClick:x=>x.stopPropagation(),children:[a.jsx("button",{className:"p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100",onClick:()=>h(!u),children:a.jsx(Th,{className:"w-4 h-4"})}),u&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>h(!1)}),a.jsxs("div",{className:"absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[a.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:update")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:update")&&(n(),h(!1))},disabled:!i("projects:update"),title:i("projects:update")?void 0:s("projects.noEditPermission"),children:[a.jsx(Pf,{className:"w-4 h-4"}),s("common.edit")]}),a.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:delete")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:delete")&&(r(),h(!1))},disabled:!i("projects:delete"),title:i("projects:delete")?void 0:s("projects.noDeletePermission"),children:[a.jsx(Xt,{className:"w-4 h-4"}),s("common.delete")]})]})]})]})]}),a.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?a.jsxs("div",{className:"space-y-3",children:[t.target_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:s("projects.plates")}),a.jsxs("span",{className:o>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:a.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(o,100)}%`,background:o>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${o>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.target_parts_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:s("projects.parts")}),a.jsxs("span",{className:l>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:a.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(l,100)}%`,background:l>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${l>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&a.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," ",s("projects.failed")]})]}):t.completed_count>0||t.failed_count>0?a.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(Ds,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.completed_count," ",s("projects.completed")]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[a.jsx(An,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.failed_count," ",s("projects.failed")]})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[a.jsx(Vn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.queue_count," ",s("projects.inQueue")]})]})]}):a.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:s("projects.noPrintsYet")})}),t.archives&&t.archives.length>0&&a.jsxs("div",{className:"mb-4",children:[a.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(x=>a.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:x.print_name||"Unknown",children:[x.thumbnail_path?a.jsx("img",{src:ne.getArchiveThumbnail(x.id),alt:x.print_name||"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:a.jsx(xi,{className:"w-6 h-6"})}),x.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:a.jsx(An,{className:"w-4 h-4 text-white"})})]},x.id))}),t.archive_count>4&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:s("common.more",{count:t.archive_count-4})})]}),a.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[a.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.printJobs"),children:[a.jsx(oi,{className:"w-3.5 h-3.5 text-blue-400"}),a.jsxs("span",{children:[t.archive_count," ",s("projects.plates")]})]}),a.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.partsPrinted"),children:[a.jsx(xi,{className:"w-3.5 h-3.5 text-bambu-green"}),a.jsxs("span",{children:[t.completed_count," ",s("projects.parts")]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:s("projects.failedParts"),children:[a.jsx(An,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:s("projects.inQueue"),children:[a.jsx(i3,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.queue_count})]})]}),a.jsx(yi,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function oJe(){const{t}=Dt(),e=nc(),n=Jt(),{showToast:r}=ln(),{hasPermission:i}=Pr(),[s,o]=w.useState(!1),[l,c]=w.useState(),[d,u]=w.useState("active"),[h,f]=w.useState(null),{data:p,isLoading:x}=Je({queryKey:["projects",d==="all"?void 0:d],queryFn:()=>ne.getProjects(d==="all"?void 0:d)}),v=st({mutationFn:z=>ne.createProject(z),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),r(t("projects.toast.created"),"success")},onError:z=>{r(z.message,"error")}}),g=st({mutationFn:({id:z,data:D})=>ne.updateProject(z,D),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),c(void 0),r(t("projects.toast.updated"),"success")},onError:z=>{r(z.message,"error")}}),y=st({mutationFn:z=>ne.deleteProject(z),onSuccess:()=>{f(null),r(t("projects.toast.deleted"),"success"),setTimeout(()=>window.location.reload(),100)},onError:z=>{f(null),r(z.message,"error")}}),_=st({mutationFn:z=>ne.importProject(z),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success")},onError:z=>{r(z.message,"error")}}),N=w.useRef(null),T=async()=>{try{const z=await ne.getProjects(),D=await Promise.all(z.map(async W=>await ne.exportProjectJson(W.id))),$=new Blob([JSON.stringify(D,null,2)],{type:"application/json"}),G=URL.createObjectURL($),U=document.createElement("a");U.href=G,U.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,U.click(),URL.revokeObjectURL(G),r(t("projects.toast.exported"),"success")}catch(z){r(z.message,"error")}},k=()=>{N.current?.click()},M=async z=>{const D=z.target.files?.[0];if(D){try{if(D.name.toLowerCase().endsWith(".zip"))await ne.importProjectFile(D),n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success");else{const G=await D.text(),U=JSON.parse(G),W=Array.isArray(U)?U:[U];for(const Y of W)await _.mutateAsync(Y);W.length>1&&r(t("projects.toast.multipleImported",{count:W.length}),"success")}}catch($){r(`${t("projects.toast.importFailed")}: ${$.message}`,"error")}z.target.value=""}},C=z=>{l?g.mutate({id:l.id,data:z}):v.mutate(z)},j=z=>{c(z),o(!0)},P=z=>{e(`/projects/${z.id}`)},E=z=>{f(z)},B=()=>{h!==null&&y.mutate(h)},O=p?.reduce((z,D)=>(z[D.status]=(z[D.status]||0)+1,z.all=(z.all||0)+1,z),{})||{};return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsx("input",{ref:N,type:"file",accept:".json,.zip",onChange:M,className:"hidden"}),a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:a.jsx(xs,{className:"w-6 h-6 text-bambu-green"})}),t("projects.title")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("projects.subtitle")})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{variant:"secondary",onClick:k,disabled:!i("projects:create"),title:i("projects:create")?t("projects.importProject"):t("projects.noImportPermission"),children:[a.jsx(La,{className:"w-4 h-4 mr-2"}),t("projects.import")]}),a.jsxs(Me,{variant:"secondary",onClick:T,disabled:!i("projects:read"),title:i("projects:read")?t("projects.exportAll"):t("projects.noExportPermission"),children:[a.jsx(ha,{className:"w-4 h-4 mr-2"}),t("projects.export")]}),a.jsxs(Me,{onClick:()=>o(!0),className:"sm:w-auto w-full",disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(Xn,{className:"w-4 h-4 mr-2"}),t("projects.newProject")]})]})]}),a.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:t("projects.statusActive"),icon:Vn},{key:"completed",label:t("projects.statusCompleted"),icon:db},{key:"archived",label:t("projects.statusArchived"),icon:Ds},{key:"all",label:t("common.all"),icon:xs}].map(({key:z,label:D,icon:$})=>a.jsxs("button",{onClick:()=>u(z),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${d===z?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[a.jsx($,{className:"w-4 h-4"}),a.jsx("span",{children:D}),O[z]>0&&a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${d===z?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:O[z]})]},z))}),x?a.jsx("div",{className:"flex items-center justify-center py-20",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(at,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("projects.loading")})]})}):p?.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(xs,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:d==="all"?t("projects.noProjects"):t("projects.noProjectsFiltered",{status:d})}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:d==="all"?t("projects.createFirst"):t("projects.noProjectsFilteredHelp",{status:d})}),d==="all"&&a.jsxs(Me,{onClick:()=>o(!0),disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(Xn,{className:"w-4 h-4 mr-2"}),t("projects.createFirstButton")]})]}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:p?.map(z=>a.jsx(sJe,{project:z,onClick:()=>P(z),onEdit:()=>j(z),onDelete:()=>E(z.id),hasPermission:i,t},z.id))}),h!==null&&a.jsx(xn,{title:t("projects.deleteProject"),message:t("projects.deleteConfirm"),confirmText:t("projects.deleteProject"),variant:"danger",onConfirm:B,onCancel:()=>f(null)}),s&&a.jsx(Qie,{project:l,onClose:()=>{o(!1),c(void 0)},onSave:C,isLoading:v.isPending||g.isPending,t})]})}function lJe(t){if(t<1)return`${Math.round(t*60)}m`;const e=Math.floor(t),n=Math.round((t-e)*60);return n>0?`${e}h ${n}m`:`${e}h`}function cJe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function dJe({status:t,t:e}){const n={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},r=n[t]||n.active,i={active:e("projectDetail.status.active"),completed:e("projectDetail.status.completed"),archived:e("projectDetail.status.archived")};return a.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${r}`,children:i[t]||t.charAt(0).toUpperCase()+t.slice(1)})}function iK({icon:t,label:e,value:n,subValue:r,hint:i,color:s="text-bambu-gray"}){return a.jsx(wt,{children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",title:i,children:[a.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${s}`,children:a.jsx(t,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:e}),a.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&a.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function uJe({archives:t,t:e}){return t.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(xi,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:e("projectDetail.noPrints")})]}):a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:t.map(n=>a.jsxs(Ks,{to:`/archives?search=${encodeURIComponent(n.print_name||"")}`,className:"group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors",children:[n.thumbnail_path?a.jsx("img",{src:ne.getArchiveThumbnail(n.id),alt:n.print_name||"Print",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:a.jsx(xi,{className:"w-8 h-8"})}),n.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:a.jsx(bi,{className:"w-8 h-8 text-white"})}),n.status==="completed"&&a.jsx("div",{className:"absolute top-1 right-1",children:a.jsx(br,{className:"w-4 h-4 text-bambu-green"})}),a.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx("p",{className:"text-xs text-white truncate",children:n.print_name||"Unknown"})})]},n.id))})}function hJe({priority:t,t:e}){const n={low:{color:"bg-gray-500/20 text-gray-400",label:e("projectDetail.priority.low")},normal:{color:"bg-blue-500/20 text-blue-400",label:e("projectDetail.priority.normal")},high:{color:"bg-orange-500/20 text-orange-400",label:e("projectDetail.priority.high")},urgent:{color:"bg-red-500/20 text-red-400",label:e("projectDetail.priority.urgent")}},{color:r,label:i}=n[t]||n.normal;return a.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${r}`,children:[t==="urgent"&&a.jsx(An,{className:"w-3 h-3"}),i]})}function mJe(t){return t?hb(t,{year:"numeric",month:"short",day:"numeric"}):""}function Dj(t,e){if(!t)return null;const n=er(t);if(!n)return null;const r=new Date,i=Math.ceil((n.getTime()-r.getTime())/(1e3*60*60*24));return i<0?{color:"text-red-400",label:e("projectDetail.dueDate.overdue")}:i===0?{color:"text-orange-400",label:e("projectDetail.dueDate.today")}:i<=3?{color:"text-yellow-400",label:e("projectDetail.dueDate.daysLeft",{count:i})}:{color:"text-bambu-gray",label:e("projectDetail.dueDate.daysLeft",{count:i})}}function fJe(){const{id:t}=o0(),e=nc(),{t:n}=Dt(),r=Jt(),{showToast:i}=ln(),{hasPermission:s}=Pr(),[o,l]=w.useState(!1),[c,d]=w.useState(!1),[u,h]=w.useState(""),f=parseInt(t||"0",10),{data:p,isLoading:x,error:v}=Je({queryKey:["project",f],queryFn:()=>ne.getProject(f),enabled:f>0}),{data:g,isLoading:y}=Je({queryKey:["project-archives",f],queryFn:()=>ne.getProjectArchives(f),enabled:f>0}),{data:_,isLoading:N}=Je({queryKey:["project-bom",f],queryFn:()=>ne.getProjectBOM(f),enabled:f>0}),{data:T,isLoading:k}=Je({queryKey:["project-timeline",f],queryFn:()=>ne.getProjectTimeline(f,20),enabled:f>0}),{data:M}=Je({queryKey:["settings"],queryFn:ne.getSettings}),{data:C}=Je({queryKey:["project-folders",f],queryFn:()=>ne.getLibraryFoldersByProject(f),enabled:f>0}),j=rl(M?.currency||"USD"),P=M?.time_format||"system",E=st({mutationFn:ve=>ne.updateProject(f,ve),onSuccess:()=>{r.invalidateQueries({queryKey:["project",f]}),r.invalidateQueries({queryKey:["projects"]}),l(!1),d(!1),i(n("projectDetail.toast.projectUpdated"),"success")},onError:ve=>{i(ve.message,"error")}}),B=()=>{h(p?.notes||""),d(!0)},O=()=>{E.mutate({notes:u})},z=()=>{d(!1),h("")},[D,$]=w.useState(""),[G,U]=w.useState(1),[W,Y]=w.useState(""),[re,H]=w.useState(""),[K,ee]=w.useState(""),[Z,we]=w.useState(!1),[oe,J]=w.useState(!1),[je,de]=w.useState(null),[le,_e]=w.useState(""),[se,ze]=w.useState(1),[V,X]=w.useState(""),[me,Q]=w.useState(""),[ie,ue]=w.useState(""),[Le,Ce]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),ge=st({mutationFn:ve=>ne.createBOMItem(f,ve),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),$(""),U(1),Y(""),H(""),ee(""),we(!1),i(n("projectDetail.toast.partAdded"),"success")},onError:ve=>i(ve.message,"error")}),L=st({mutationFn:({itemId:ve,data:Ge})=>ne.updateBOMItem(f,ve,Ge),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),de(null)},onError:ve=>i(ve.message,"error")}),R=st({mutationFn:ve=>ne.deleteBOMItem(f,ve),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),i(n("projectDetail.toast.partRemoved"),"success")},onError:ve=>i(ve.message,"error")}),q=ve=>{ve.preventDefault(),D.trim()&&ge.mutate({name:D.trim(),quantity_needed:G,unit_price:W?parseFloat(W):void 0,sourcing_url:re.trim()||void 0,remarks:K.trim()||void 0})},ce=ve=>{const Ge=ve.is_complete?0:ve.quantity_needed;L.mutate({itemId:ve.id,data:{quantity_acquired:Ge}})},pe=(ve,Ge)=>{Ce({isOpen:!0,title:n("projectDetail.bom.deletePart"),message:n("projectDetail.bom.deleteConfirm",{name:Ge}),onConfirm:()=>{Ce(Te=>({...Te,isOpen:!1})),R.mutate(ve)}})},te=ve=>{de(ve),_e(ve.name),ze(ve.quantity_needed),X(ve.unit_price?.toString()||""),Q(ve.sourcing_url||""),ue(ve.remarks||"")},Be=ve=>{ve.preventDefault(),!(!je||!le.trim())&&L.mutate({itemId:je.id,data:{name:le.trim(),quantity_needed:se,unit_price:V?parseFloat(V):void 0,sourcing_url:me.trim()||void 0,remarks:ie.trim()||void 0}})},Ie=()=>{de(null)},$e=async()=>{try{const{blob:ve,filename:Ge}=await ne.exportProjectZip(Number(f)),Te=URL.createObjectURL(ve),nt=document.createElement("a");nt.href=Te,nt.download=Ge||`${p?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,nt.click(),URL.revokeObjectURL(Te),i(n("projectDetail.toast.projectExported"),"success")}catch(ve){i(ve.message,"error")}},Re=st({mutationFn:()=>ne.createTemplateFromProject(f),onSuccess:()=>{r.invalidateQueries({queryKey:["projects"]}),i(n("projectDetail.toast.templateCreated"),"success")},onError:ve=>i(ve.message,"error")}),fe=ve=>Df(ve,P,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(x)return a.jsx("div",{className:"flex items-center justify-center py-24",children:a.jsx(at,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(v||!p)return a.jsxs("div",{className:"text-center py-24",children:[a.jsx("p",{className:"text-bambu-gray",children:v?`${n("common.error")}: ${v.message}`:n("projectDetail.notFound")}),a.jsx(Me,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:n("projectDetail.backToProjects")})]});const xe=p.stats,Ne=xe?.progress_percent??0,ye=xe?.parts_progress_percent??0;return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(Ks,{to:"/projects",className:"hover:text-white transition-colors",children:n("navigation.projects")}),a.jsx(yi,{className:"w-4 h-4"}),a.jsx("span",{className:"text-white",children:p.name})]}),a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:a.jsx(dY,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:p.color||"#6b7280"}}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:p.name}),p.description&&a.jsx("p",{className:"text-bambu-gray mt-1",children:p.description})]})]}),a.jsx(dJe,{status:p.status,t:n})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{variant:"secondary",onClick:$e,disabled:!s("projects:read"),title:s("projects:read")?n("projectDetail.exportProject"):n("projectDetail.noExportPermission"),children:[a.jsx(ha,{className:"w-4 h-4 mr-2"}),n("projectDetail.export")]}),a.jsxs(Me,{onClick:()=>l(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.noEditPermission"),children:[a.jsx(Pf,{className:"w-4 h-4 mr-2"}),n("common.edit")]})]})]}),(p.target_count||p.target_parts_count)&&a.jsx(wt,{children:a.jsxs(Nt,{className:"p-4 space-y-4",children:[p.target_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.platesProgress")}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[xe?.total_archives||0," / ",p.target_count," ",n("projectDetail.progress.printJobs")]})]}),a.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Ne,100)}%`,backgroundColor:Ne>=100?"#22c55e":p.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:Ne.toFixed(0)})}),xe?.remaining_prints!=null&&xe.remaining_prints>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:xe.remaining_prints})})]})]}),p.target_parts_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.partsProgress")}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[xe?.completed_prints||0," / ",p.target_parts_count," ",n("projectDetail.progress.parts")]})]}),a.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(ye,100)}%`,backgroundColor:ye>=100?"#22c55e":p.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:ye.toFixed(0)})}),xe?.remaining_parts!=null&&xe.remaining_parts>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:xe.remaining_parts})})]})]})]})}),xe&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(wt,{children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:a.jsx(xi,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.printJobs")}),a.jsxs("p",{className:"text-xl font-semibold text-white",children:[xe.total_archives," ",a.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:n("projectDetail.stats.total")})]}),xe.failed_prints>0&&a.jsx("p",{className:"text-sm text-status-error",children:n("projectDetail.stats.failed",{count:xe.failed_prints})}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.partsPrinted",{count:xe.completed_prints})})]})]})})}),a.jsx(iK,{icon:Vn,label:n("projectDetail.stats.printTime"),value:lJe(xe.total_print_time_hours),color:"text-yellow-400"}),a.jsx(iK,{icon:Sr,label:n("projectDetail.stats.filamentUsed"),value:cJe(xe.total_filament_grams),color:"text-purple-400"})]}),xe&&(xe.estimated_cost>0||p.budget)&&a.jsx(wt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:n("projectDetail.cost.title")}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.filamentCost")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[j,xe.estimated_cost.toFixed(2)]})]}),xe.total_energy_kwh>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.energy")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[xe.total_energy_kwh.toFixed(3)," kWh",xe.total_energy_cost>0&&a.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",j,xe.total_energy_cost.toFixed(2),")"]})]})]}),p.budget&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.budget")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[j,p.budget.toFixed(2)]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.remaining")}),a.jsxs("p",{className:`text-lg font-semibold ${p.budget-xe.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[j,(p.budget-xe.estimated_cost).toFixed(2)]})]})]})]})]})}),p.children&&p.children.length>0&&a.jsx(wt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[a.jsx(_me,{className:"w-5 h-5"}),n("projectDetail.subProjects.title",{count:p.children.length})]}),a.jsx("div",{className:"space-y-2",children:p.children.map(ve=>a.jsxs(Ks,{to:`/projects/${ve.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:ve.color||"#6b7280"}}),a.jsx("span",{className:"text-white",children:ve.name}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${ve.status==="completed"?"bg-status-ok/20 text-status-ok":ve.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:ve.status})]}),ve.progress_percent!==null&&a.jsxs("span",{className:"text-sm text-bambu-gray",children:[ve.progress_percent.toFixed(0),"%"]})]},ve.id))})]})}),p.parent_id&&p.parent_name&&a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(oi,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.partOf")}),a.jsx(Ks,{to:`/projects/${p.parent_id}`,className:"text-bambu-green hover:underline",children:p.parent_name})]}),(p.tags||p.due_date||p.priority!=="normal")&&a.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[p.priority&&p.priority!=="normal"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.priorityLabel")}),a.jsx(hJe,{priority:p.priority,t:n})]}),p.due_date&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(sa,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-white",children:mJe(p.due_date)}),Dj(p.due_date,n)&&a.jsxs("span",{className:`text-xs ${Dj(p.due_date,n).color}`,children:["(",Dj(p.due_date,n).label,")"]})]}),p.tags&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Vh,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:p.tags.split(",").map((ve,Ge)=>a.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:ve.trim()},Ge))})]})]}),a.jsx(wt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ps,{className:"w-5 h-5"}),n("projectDetail.notes.title")]}),c?a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{variant:"secondary",size:"sm",onClick:z,disabled:E.isPending,children:[a.jsx(Rt,{className:"w-4 h-4 mr-1"}),n("common.cancel")]}),a.jsxs(Me,{size:"sm",onClick:O,disabled:E.isPending,children:[E.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin mr-1"}):a.jsx(bs,{className:"w-4 h-4 mr-1"}),n("common.save")]})]}):a.jsxs(Me,{variant:"secondary",size:"sm",onClick:B,disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.notes.noEditPermission"),children:[a.jsx(Pf,{className:"w-4 h-4 mr-1"}),n("common.edit")]})]}),c?a.jsx(QR,{content:u,onChange:h,placeholder:n("projectDetail.notes.placeholder")}):p.notes?a.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:p.notes}}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.notes.empty")})]})}),a.jsx(wt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ql,{className:"w-5 h-5"}),n("projectDetail.files.title")]})}),a.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[a.jsx(Ks,{to:"/files",className:"text-bambu-green hover:underline",children:n("projectDetail.files.linkFolders")})," ",n("projectDetail.files.forQuickAccess")]}),C&&C.length>0?a.jsx("div",{className:"space-y-2",children:C.map(ve=>a.jsxs(Ks,{to:`/files?folder=${ve.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsx(Ql,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:ve.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:n("projectDetail.files.fileCount",{count:ve.file_count})})]})]}),a.jsx(yi,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},ve.id))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.files.empty")})]})}),a.jsx(wt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(wY,{className:"w-5 h-5"}),n("projectDetail.bom.title"),xe&&xe.bom_total_items>0&&a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",n("projectDetail.bom.acquired",{completed:xe.bom_completed_items,total:xe.bom_total_items}),")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[_&&_.some(ve=>ve.is_complete)&&a.jsx("button",{onClick:()=>J(!oe),className:`text-xs px-2 py-1 rounded transition-colors ${oe?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:n(oe?"projectDetail.bom.showAll":"projectDetail.bom.hideDone")}),!Z&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>we(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noAddPermission"),children:[a.jsx(Xn,{className:"w-4 h-4 mr-1"}),n("projectDetail.bom.addPart")]})]})]}),Z&&a.jsxs("form",{onSubmit:q,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:D,onChange:ve=>$(ve.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.partNamePlaceholder"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:G,onChange:ve=>U(parseInt(ve.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:n("projectDetail.bom.qty")}),a.jsx("input",{type:"number",step:"0.01",value:W,onChange:ve=>Y(ve.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.price",{currency:j})})]})]}),a.jsx("input",{type:"url",value:re,onChange:ve=>H(ve.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.sourcingUrlPlaceholder")}),a.jsx("input",{type:"text",value:K,onChange:ve=>ee(ve.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.remarksPlaceholder")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",size:"sm",onClick:()=>we(!1),children:n("common.cancel")}),a.jsx(Me,{type:"submit",size:"sm",disabled:!D.trim()||ge.isPending,children:ge.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):n("projectDetail.bom.addPart")})]})]}),N?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(at,{className:"w-6 h-6 animate-spin text-bambu-green"})}):_&&_.length>0?a.jsxs("div",{className:"space-y-2",children:[_.filter(ve=>!oe||!ve.is_complete).map(ve=>a.jsx("div",{className:`p-3 rounded-lg transition-colors ${ve.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:je?.id===ve.id?a.jsxs("form",{onSubmit:Be,className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:le,onChange:Ge=>_e(Ge.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.partName"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:se,onChange:Ge=>ze(parseInt(Ge.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:n("projectDetail.bom.qty")}),a.jsx("input",{type:"number",step:"0.01",value:V,onChange:Ge=>X(Ge.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.price",{currency:j})})]})]}),a.jsx("input",{type:"url",value:me,onChange:Ge=>Q(Ge.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.sourcingUrlPlaceholder")}),a.jsx("input",{type:"text",value:ie,onChange:Ge=>ue(Ge.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.remarksPlaceholder")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",size:"sm",onClick:Ie,children:n("common.cancel")}),a.jsx(Me,{type:"submit",size:"sm",disabled:!le.trim()||L.isPending,children:L.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):n("common.save")})]})]}):a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("button",{onClick:()=>s("projects:update")&&ce(ve),disabled:L.isPending||!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noUpdatePermission"),className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${ve.is_complete?"bg-status-ok border-status-ok text-white":s("projects:update")?"border-bambu-gray hover:border-bambu-green":"border-bambu-gray/50 cursor-not-allowed"}`,children:ve.is_complete&&a.jsx(br,{className:"w-3 h-3"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsxs("p",{className:`text-sm font-medium ${ve.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[ve.name,a.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",ve.quantity_needed]})]}),ve.unit_price!==null&&a.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[j,(ve.unit_price*ve.quantity_needed).toFixed(2)]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>s("projects:update")&&te(ve),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.edit"):n("projectDetail.bom.noEditPermission"),children:a.jsx(Ya,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("projects:update")&&pe(ve.id,ve.name),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.delete"):n("projectDetail.bom.noDeletePermission"),children:a.jsx(Xt,{className:"w-4 h-4"})})]})]}),ve.sourcing_url&&a.jsxs("a",{href:ve.sourcing_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-1 text-xs text-blue-400 hover:text-blue-300 transition-colors",onClick:Ge=>Ge.stopPropagation(),children:[a.jsx(Zr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"truncate",children:(()=>{try{return new URL(ve.sourcing_url).hostname.replace("www.","")}catch{return ve.sourcing_url}})()})]}),ve.remarks&&a.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:ve.remarks})]})]})},ve.id)),_.some(ve=>ve.unit_price!==null)&&a.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.bom.totalCost")}),a.jsxs("span",{className:"text-white font-medium",children:[j,_.reduce((ve,Ge)=>ve+(Ge.unit_price||0)*Ge.quantity_needed,0).toFixed(2)]})]})]}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.bom.empty")})]})}),a.jsx(wt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(pv,{className:"w-5 h-5"}),n("projectDetail.timeline.title")]})}),k?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(at,{className:"w-6 h-6 animate-spin text-bambu-green"})}):T&&T.length>0?a.jsx("div",{className:"space-y-3",children:T.slice(0,10).map((ve,Ge)=>a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${ve.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":ve.event_type==="print_failed"?"bg-status-error/20 text-status-error":ve.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[ve.event_type==="print_completed"&&a.jsx(br,{className:"w-4 h-4"}),ve.event_type==="print_failed"&&a.jsx(bi,{className:"w-4 h-4"}),ve.event_type==="print_started"&&a.jsx(Sr,{className:"w-4 h-4"}),ve.event_type==="queued"&&a.jsx(i3,{className:"w-4 h-4"}),ve.event_type==="project_created"&&a.jsx(Xn,{className:"w-4 h-4"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white",children:ve.title}),ve.description&&a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:ve.description}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:fe(ve.timestamp)})]})]},Ge))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.timeline.empty")})]})}),!p.is_template&&a.jsx("div",{className:"flex justify-end",children:a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>Re.mutate(),disabled:Re.isPending||!s("projects:create"),title:s("projects:create")?void 0:n("projectDetail.template.noCreatePermission"),children:[Re.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(Yl,{className:"w-4 h-4 mr-2"}),n("projectDetail.template.saveAsTemplate")]})}),xe&&(xe.queued_prints>0||xe.in_progress_prints>0)&&a.jsx(wt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(i3,{className:"w-5 h-5"}),n("projectDetail.queue.title")]}),a.jsx(Ks,{to:`/queue?project=${f}`,className:"text-sm text-bambu-green hover:underline",children:n("projectDetail.queue.viewAll")})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[xe.in_progress_prints>0&&a.jsx("span",{className:"text-yellow-400",children:n("projectDetail.queue.printing",{count:xe.in_progress_prints})}),xe.queued_prints>0&&a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.queue.queued",{count:xe.queued_prints})})]})]})}),a.jsxs("div",{children:[a.jsx("div",{className:"flex items-center justify-between mb-4",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(xi,{className:"w-5 h-5"}),n("projectDetail.prints.title",{count:g?.length||0})]})}),y?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(at,{className:"w-6 h-6 animate-spin text-bambu-green"})}):a.jsx(uJe,{archives:g||[],t:n})]}),o&&a.jsx(Qie,{t:n,project:{...p,archive_count:xe?.total_archives||0,total_items:xe?.total_items||0,completed_count:xe?.completed_prints||0,failed_count:xe?.failed_prints||0,queue_count:xe?.queued_prints||0,progress_percent:xe?.progress_percent||null,archives:[]},onClose:()=>l(!1),onSave:ve=>E.mutate(ve),isLoading:E.isPending}),Le.isOpen&&a.jsx(xn,{title:Le.title,message:Le.message,confirmText:n("common.delete"),variant:"danger",onConfirm:Le.onConfirm,onCancel:()=>Ce(ve=>({...ve,isOpen:!1}))})]})}function pJe({parentId:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=w.useState(""),l=c=>{c.preventDefault(),n({name:s.trim(),parent_id:t})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("fileManager.newFolder")})}),a.jsxs("form",{onSubmit:l,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("fileManager.folderName")}),a.jsx("input",{type:"text",value:s,onChange:c=>o(c.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("fileManager.folderNamePlaceholder"),autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(at,{className:"w-4 h-4 animate-spin"}):i("common.create")})]})]})]})})}function gJe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i,t:s}){const[o,l]=w.useState(e),c=d=>{d.preventDefault(),o.trim()&&o.trim()!==e&&r(o.trim())};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:s(t==="file"?"fileManager.renameFile":"fileManager.renameFolder")})}),a.jsxs("form",{onSubmit:c,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("common.name")}),a.jsx("input",{type:"text",value:o,onChange:d=>l(d.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:n,children:s("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!o.trim()||o.trim()===e||i,children:i?a.jsx(at,{className:"w-4 h-4 animate-spin"}):s("common.rename")})]})]})]})})}function bJe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:s,t:o}){const[l,c]=w.useState(null),d=(h,f=0)=>{const p=[];for(const x of h)p.push({id:x.id,name:x.name,depth:f}),x.children.length>0&&p.push(...d(x.children,f+1));return p},u=[{id:null,name:o("fileManager.rootNoFolder"),depth:0},...d(t)];return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:o("fileManager.moveFiles",{count:e.length})})}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:u.map(h=>a.jsxs("button",{onClick:()=>c(h.id),disabled:h.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===h.id?"bg-bambu-green/20 text-bambu-green":h.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+h.depth*16}px`},children:[a.jsx(Ql,{className:"w-4 h-4"}),h.name,h.id===n&&a.jsxs("span",{className:"text-xs text-bambu-gray ml-auto",children:["(",o("fileManager.current"),")"]})]},h.id??"root"))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:r,children:o("common.cancel")}),a.jsx(Me,{onClick:()=>i(l),disabled:s,children:s?a.jsx(at,{className:"w-4 h-4 animate-spin"}):o("common.move")})]})]})]})})}function xJe({folder:t,onClose:e,onLink:n,isLoading:r,t:i}){const[s,o]=w.useState("project"),[l,c]=w.useState(t.project_id||t.archive_id||null);w.useState(()=>{t.archive_id&&o("archive")});const{data:d}=Je({queryKey:["projects"],queryFn:()=>ne.getProjects()}),{data:u}=Je({queryKey:["archives-for-link"],queryFn:()=>ne.getArchives(void 0,void 0,100)}),h=()=>{n(s==="project"?{project_id:l,archive_id:0}:{project_id:0,archive_id:l})},f=()=>{n({project_id:0,archive_id:0})},p=t.project_id||t.archive_id;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(jh,{className:"w-5 h-5 text-bambu-green"}),i("fileManager.linkFolder")]}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:i("fileManager.linkFolderDescription",{name:t.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>{o("project"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${s==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(uY,{className:"w-4 h-4"}),i("fileManager.project")]}),a.jsxs("button",{onClick:()=>{o("archive"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${s==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(Ds,{className:"w-4 h-4"}),i("fileManager.archive")]})]}),a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:s==="project"?d&&d.length>0?d.map(x=>a.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:x.color||"#00ae42"}}),a.jsx("span",{className:"truncate",children:x.name})]},x.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noProjectsFound")}):u&&u.length>0?u.map(x=>a.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx(hf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"truncate",children:x.print_name||x.filename})]},x.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noArchivesFound")})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[p&&a.jsxs(Me,{variant:"danger",onClick:f,disabled:r,children:[a.jsx(JC,{className:"w-4 h-4 mr-2"}),i("fileManager.unlink")]}),a.jsxs("div",{className:`flex gap-2 ${p?"":"ml-auto"}`,children:[a.jsx(Me,{variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{onClick:h,disabled:!l||r,children:r?a.jsx(at,{className:"w-4 h-4 animate-spin"}):i("fileManager.link")})]})]})]})})}function yJe({folderId:t,onClose:e,onUploadComplete:n,t:r}){const[i,s]=w.useState([]),[o,l]=w.useState(!1),[c,d]=w.useState(!1),[u,h]=w.useState(!0),[f,p]=w.useState(!1),[x,v]=w.useState(!0),g=w.useRef(null),y=$=>{$.preventDefault(),l(!0)},_=$=>{$.preventDefault(),l(!1)},N=$=>{$.preventDefault(),l(!1);const G=Array.from($.dataTransfer.files);k(G)},T=$=>{$.target.files&&k(Array.from($.target.files))},k=$=>{const G=$.map(U=>({file:U,status:"pending",isZip:U.name.toLowerCase().endsWith(".zip"),is3mf:U.name.toLowerCase().endsWith(".3mf")}));s(U=>[...U,...G])},M=$=>{s(G=>G.filter((U,W)=>W!==$))},C=i.some($=>$.isZip&&$.status==="pending"),j=i.some($=>$.file.name.toLowerCase().endsWith(".stl")&&$.status==="pending"),P=i.some($=>$.is3mf&&$.status==="pending"),E=async()=>{if(i.length!==0){d(!0);for(let $=0;$G.map((U,W)=>W===$?{...U,status:"uploading"}:U));try{if(i[$].isZip){const G=await ne.extractZipFile(i[$].file,t,u,f,x);s(U=>U.map((W,Y)=>Y===$?{...W,status:G.errors.length>0&&G.extracted===0?"error":"success",extractedCount:G.extracted,error:G.errors.length>0?`${G.errors.length} files failed`:void 0}:W))}else await ne.uploadLibraryFile(i[$].file,t,x),s(G=>G.map((U,W)=>W===$?{...U,status:"success"}:U))}catch(G){s(U=>U.map((W,Y)=>Y===$?{...W,status:"error",error:G instanceof Error?G.message:"Upload failed"}:W))}}d(!1),n(),e()}},B=i.filter($=>$.status==="pending").length,O=i.filter($=>$.status==="success").length,z=i.filter($=>$.status==="error").length,D=i.length>0&&B===0&&!c;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("fileManager.uploadFiles")}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("div",{onDragOver:y,onDragLeave:_,onDrop:N,onClick:()=>g.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,children:[a.jsx(La,{className:`w-10 h-10 mx-auto mb-3 ${o?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("p",{className:"text-white font-medium",children:r(o?"fileManager.dropFilesHere":"fileManager.dragDropFiles")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("fileManager.orClickToBrowse")}),a.jsx("p",{className:"text-xs text-bambu-gray/70 mt-2",children:r("fileManager.allFileTypesSupported")})]}),a.jsx("input",{ref:g,type:"file",multiple:!0,className:"hidden",onChange:T}),C&&a.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Ds,{className:"w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-blue-300 font-medium",children:r("fileManager.zipFilesDetected")}),a.jsx("p",{className:"text-xs text-blue-300/70 mt-1",children:r("fileManager.zipExtractOptions")}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:u,onChange:$=>h($.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.preserveZipStructure")})]}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:f,onChange:$=>p($.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.createFolderFromZip")})]})]})]})}),P&&a.jsx("div",{className:"p-3 bg-purple-500/10 border border-purple-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Sr,{className:"w-5 h-5 text-purple-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-purple-300 font-medium",children:r("fileManager.threemfDetected")}),a.jsx("p",{className:"text-xs text-purple-300/70 mt-1",children:r("fileManager.threemfExtractionInfo")})]})]})}),(j||C)&&a.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Jd,{className:"w-5 h-5 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-bambu-green font-medium",children:r("fileManager.stlThumbnailGeneration")}),a.jsx("p",{className:"text-xs text-bambu-green/70 mt-1",children:r(C&&!j?"fileManager.zipMayContainStl":"fileManager.thumbnailsCanBeGenerated")}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:x,onChange:$=>v($.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.generateThumbnailsForStl")})]})]})]})}),i.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:i.map(($,G)=>a.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[$.isZip?a.jsx(Ds,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):a.jsx(HC,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:$.file.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[($.file.size/1024/1024).toFixed(2)," MB",$.isZip&&$.status==="pending"&&a.jsxs("span",{className:"text-blue-400 ml-2",children:["• ",r("fileManager.willBeExtracted")]}),$.extractedCount!==void 0&&a.jsxs("span",{className:"text-green-400 ml-2",children:["• ",r("fileManager.filesExtracted",{count:$.extractedCount})]})]})]}),$.status==="pending"&&a.jsx("button",{onClick:()=>M(G),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Rt,{className:"w-4 h-4 text-bambu-gray"})}),$.status==="uploading"&&a.jsx(at,{className:"w-4 h-4 text-bambu-green animate-spin"}),$.status==="success"&&a.jsx(br,{className:"w-4 h-4 text-green-500"}),$.status==="error"&&a.jsx("span",{title:$.error,children:a.jsx(bi,{className:"w-4 h-4 text-red-500"})})]},G))}),D&&a.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[r("fileManager.uploadComplete",{succeeded:O}),z>0&&a.jsxs("span",{className:"text-red-400",children:[", ",r("fileManager.uploadFailed",{count:z})]})]})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:e,children:r(D?"common.close":"common.cancel")}),!D&&a.jsx(Me,{onClick:E,disabled:B===0||c,children:c?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 mr-2 animate-spin"}),r("fileManager.uploading")]}):a.jsxs(a.Fragment,{children:[a.jsx(La,{className:"w-4 h-4 mr-2"}),r("common.upload")," ",B>0?`(${B})`:""]})})]})]})})}function Zie({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o=0,wrapNames:l=!1,hasPermission:c,t:d}){const[u,h]=w.useState(!0),[f,p]=w.useState(!1),x=t.children.length>0,v=t.project_id||t.archive_id;return a.jsxs("div",{children:[a.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${e===t.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${8+o*12}px`},onClick:()=>n(t.id),children:[x?a.jsx("button",{onClick:g=>{g.stopPropagation(),h(!u)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(yi,{className:`w-3.5 h-3.5 transition-transform ${u?"rotate-90":""}`})}):a.jsx("div",{className:"w-4.5"}),a.jsx(Ql,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),a.jsx("span",{className:`text-sm flex-1 min-w-0 ${l?"break-all":"truncate"}`,title:t.name,children:t.name}),v&&a.jsxs("button",{onClick:g=>{g.stopPropagation(),i(t)},className:"flex-shrink-0 flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",title:`${t.project_name?`Project: ${t.project_name}`:`Archive: ${t.archive_name}`} (click to change)`,children:[a.jsx(jh,{className:"w-3 h-3"}),t.project_name?a.jsx(uY,{className:"w-3 h-3"}):a.jsx(Ds,{className:"w-3 h-3"})]}),t.file_count>0&&a.jsx("span",{className:"flex-shrink-0 text-xs text-bambu-gray",children:t.file_count}),!v&&a.jsx("button",{onClick:g=>{g.stopPropagation(),i(t)},className:"flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary",title:d("fileManager.linkToProjectOrArchive"),children:a.jsx(jh,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),a.jsx("div",{className:`flex-shrink-0 flex items-center gap-0.5 transition-opacity ${l?"":"opacity-0 group-hover:opacity-100"}`,onClick:g=>g.stopPropagation(),children:a.jsxs("div",{className:"relative",children:[a.jsx("button",{onClick:()=>p(!f),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:a.jsx(Th,{className:"w-3.5 h-3.5 text-bambu-gray"})}),f&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>p(!1)}),a.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(s(t),p(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:d("fileManager.noPermissionRenameFolder"),children:[a.jsx(Ya,{className:"w-3.5 h-3.5"}),d("common.rename")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(i(t),p(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:d("fileManager.noPermissionLinkFolder"),children:[a.jsx(jh,{className:"w-3.5 h-3.5"}),d(v?"fileManager.changeLink":"fileManager.linkTo")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:delete_all")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:delete_all")&&(r(t.id),p(!1))},disabled:!c("library:delete_all"),title:c("library:delete_all")?void 0:d("fileManager.noPermissionDeleteFolder"),children:[a.jsx(Xt,{className:"w-3.5 h-3.5"}),d("common.delete")]})]})]})]})})]}),x&&u&&a.jsx("div",{children:t.children.map(g=>a.jsx(Zie,{folder:g,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o+1,wrapNames:l,hasPermission:c,t:d},g.id))})]})}function aF(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function vJe({file:t,isSelected:e,isMobile:n,onSelect:r,onDelete:i,onDownload:s,onAddToQueue:o,onPrint:l,onPreview3d:c,onRename:d,onGenerateThumbnail:u,thumbnailVersion:h,hasPermission:f,canModify:p,authEnabled:x,t:v}){const[g,y]=w.useState(!1);return a.jsxs("div",{className:`group relative bg-bambu-dark-secondary rounded-lg border transition-all cursor-pointer overflow-hidden ${e?"border-bambu-green ring-1 ring-bambu-green":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,onClick:()=>r(t.id),children:[a.jsxs("div",{className:"aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden",children:[t.thumbnail_path?a.jsx("img",{src:`${ne.getLibraryFileThumbnailUrl(t.id)}${h?`?v=${h}`:""}`,alt:t.filename,className:"w-full h-full object-cover"}):a.jsx(hf,{className:"w-12 h-12 text-bambu-gray/30"}),a.jsx("div",{className:`absolute top-2 right-2 text-xs px-1.5 py-0.5 rounded font-medium ${t.file_type==="3mf"?"bg-bambu-green/90 text-white":t.file_type==="gcode"?"bg-blue-500/90 text-white":t.file_type==="stl"?"bg-purple-500/90 text-white":"bg-bambu-gray/90 text-white"}`,children:t.file_type.toUpperCase()})]}),a.jsxs("div",{className:"p-3",children:[a.jsx("h3",{className:"text-sm font-medium text-white truncate",title:t.print_name||t.filename,children:t.print_name||t.filename}),a.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-bambu-gray",children:[a.jsx("span",{children:dl(t.file_size)}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Vn,{className:"w-3 h-3"}),Qs(t.print_time_seconds)]})]}),t.sliced_for_model&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(Sr,{className:"w-3 h-3"}),t.sliced_for_model]}),t.print_count>0&&a.jsx("div",{className:"mt-1 text-xs text-bambu-green",children:v("fileManager.printedCount",{count:t.print_count})}),x&&t.created_by_username&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(tu,{className:"w-3 h-3"}),t.created_by_username]})]}),a.jsxs("div",{className:`absolute bottom-2 right-2 transition-opacity ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:_=>_.stopPropagation(),children:[a.jsx("button",{onClick:()=>y(!g),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:a.jsx(Th,{className:"w-4 h-4 text-bambu-gray"})}),g&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>y(!1)}),a.jsxs("div",{className:"absolute right-0 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]",children:[l&&aF(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("printers:control")?"text-bambu-green hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("printers:control")&&(l(t),y(!1))},disabled:!f("printers:control"),title:f("printers:control")?void 0:v("fileManager.noPermissionPrint"),children:[a.jsx(Sr,{className:"w-3.5 h-3.5"}),v("common.print")]}),o&&aF(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("queue:create")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("queue:create")&&(o(t.id),y(!1))},disabled:!f("queue:create"),title:f("queue:create")?void 0:v("fileManager.noPermissionAddToQueue"),children:[a.jsx(Vn,{className:"w-3.5 h-3.5"}),v("fileManager.schedulePrint")]}),c&&(t.file_type==="3mf"||t.file_type==="gcode"||t.file_type==="stl")&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library:read")&&(c(t),y(!1))},disabled:!f("library:read"),title:f("library:read")?void 0:"You do not have permission to preview files",children:[a.jsx(ai,{className:"w-3.5 h-3.5"}),"3D Preview"]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library:read")&&(s(t.id),y(!1))},disabled:!f("library:read"),title:f("library:read")?void 0:v("fileManager.noPermissionDownload"),children:[a.jsx(ha,{className:"w-3.5 h-3.5"}),v("common.download")]}),d&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","update",t.created_by_id)&&(d(t),y(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:v("fileManager.noPermissionRenameFile"),children:[a.jsx(Ya,{className:"w-3.5 h-3.5"}),v("common.rename")]}),u&&t.file_type==="stl"&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","update",t.created_by_id)&&(u(t),y(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:v("fileManager.noPermissionGenerateThumbnail"),children:[a.jsx(Jd,{className:"w-3.5 h-3.5"}),v("fileManager.generateThumbnail")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","delete",t.created_by_id)?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","delete",t.created_by_id)&&(i(t.id),y(!1))},disabled:!p("library","delete",t.created_by_id),title:p("library","delete",t.created_by_id)?void 0:v("fileManager.noPermissionDeleteFile"),children:[a.jsx(Xt,{className:"w-3.5 h-3.5"}),v("common.delete")]})]})]})]}),a.jsx("div",{className:`absolute top-2 left-2 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${e?"bg-bambu-green border-bambu-green":`border-white/30 bg-black/30 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}`,children:e&&a.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function wJe(){const{t}=Dt(),e=Jt(),{showToast:n}=ln(),{hasPermission:r,hasAnyPermission:i,canModify:s,authEnabled:o}=Pr(),[l]=gF(),c=l.get("folder"),d=c?parseInt(c,10):null,[u,h]=w.useState(d),[f,p]=w.useState([]),[x,v]=w.useState(!1),[g,y]=w.useState(!1),[_,N]=w.useState(!1),[T,k]=w.useState(null),[M,C]=w.useState(null),[j,P]=w.useState(null),[E,B]=w.useState(null),[O,z]=w.useState(null),[D,$]=w.useState(null),[G,U]=w.useState({}),[W,Y]=w.useState(null),[re,H]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[K,ee]=w.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[Z,we]=w.useState(()=>{const Ue=localStorage.getItem("library-sidebar-width");return Ue?parseInt(Ue,10):256}),[oe,J]=w.useState(!1),je=w.useRef(null);w.useEffect(()=>{if(!oe)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Ue=xt=>{if(!je.current)return;const Vt=je.current.parentElement?.getBoundingClientRect();if(!Vt)return;const yn=xt.clientX-Vt.left,_r=Math.min(500,Math.max(200,yn));we(_r)},yt=()=>{J(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(Z))};return document.addEventListener("mousemove",Ue),document.addEventListener("mouseup",yt),()=>{document.removeEventListener("mousemove",Ue),document.removeEventListener("mouseup",yt),document.body.style.userSelect="",document.body.style.cursor=""}},[oe,Z]);const[de,le]=w.useState(""),[_e,se]=w.useState("all"),[ze,V]=w.useState(""),[X,me]=w.useState(()=>localStorage.getItem("library-sort-field")||"name"),[Q,ie]=w.useState(()=>localStorage.getItem("library-sort-direction")||"asc"),ue=xne();w.useEffect(()=>{const Ue=l.get("folder");if(Ue){const yt=parseInt(Ue,10);h(yt)}},[l]);const{data:Le}=Je({queryKey:["settings"],queryFn:()=>ne.getSettings()}),{data:Ce,isLoading:ge}=Je({queryKey:["library-folders"],queryFn:()=>ne.getLibraryFolders()}),{data:L,isLoading:R}=Je({queryKey:["library-files",u],queryFn:()=>ne.getLibraryFiles(u,u===null)}),{data:q}=Je({queryKey:["library-stats"],queryFn:()=>ne.getLibraryStats()}),{data:ce}=Je({queryKey:["users"],queryFn:()=>ne.getUsers()}),pe=w.useMemo(()=>{if(!L)return[];const Ue=new Set(L.map(yt=>yt.file_type));return Array.from(Ue).sort()},[L]),te=w.useMemo(()=>{if(!L)return[];let Ue=[...L];if(de.trim()){const yt=de.toLowerCase();Ue=Ue.filter(xt=>xt.filename.toLowerCase().includes(yt)||xt.print_name&&xt.print_name.toLowerCase().includes(yt))}if(_e!=="all"&&(Ue=Ue.filter(yt=>yt.file_type===_e)),ze.trim()){const yt=ze.toLowerCase();Ue=Ue.filter(xt=>xt.created_by_username&&xt.created_by_username.toLowerCase().includes(yt))}return Ue.sort((yt,xt)=>{let Vt=0;switch(X){case"name":Vt=(yt.print_name||yt.filename).localeCompare(xt.print_name||xt.filename);break;case"date":Vt=(er(yt.created_at)?.getTime()??0)-(er(xt.created_at)?.getTime()??0);break;case"size":Vt=yt.file_size-xt.file_size;break;case"type":Vt=yt.file_type.localeCompare(xt.file_type);break;case"prints":Vt=yt.print_count-xt.print_count;break}return Q==="asc"?Vt:-Vt}),Ue},[L,de,_e,ze,X,Q]),Be=w.useMemo(()=>{if(!q||!Le)return!1;const Ue=(Le.library_disk_warning_gb||5)*1024*1024*1024;return q.disk_free_bytesne.createLibraryFolder(Ue),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),v(!1),n(t("fileManager.toast.folderCreated"),"success")},onError:Ue=>n(Ue.message,"error")}),$e=st({mutationFn:Ue=>ne.deleteLibraryFolder(Ue),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-stats"]}),u===M?.id&&h(null),C(null),n(t("fileManager.toast.folderDeleted"),"success")},onError:Ue=>{C(null),n(Ue.message,"error")}}),Re=st({mutationFn:Ue=>ne.deleteLibraryFile(Ue),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),p(Ue=>Ue.filter(yt=>yt!==M?.id)),C(null),n(t("fileManager.toast.fileDeleted"),"success")},onError:Ue=>{C(null),n(Ue.message,"error")}}),fe=st({mutationFn:Ue=>ne.bulkDeleteLibrary(Ue,[]),onSuccess:(Ue,yt)=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),n(t("fileManager.toast.filesDeleted",{count:yt.length}),"success"),p([]),C(null)},onError:Ue=>{C(null),n(Ue.message,"error")}}),xe=st({mutationFn:({fileIds:Ue,folderId:yt})=>ne.moveLibraryFiles(Ue,yt),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),p([]),y(!1),n(t("fileManager.toast.filesMoved"),"success")},onError:Ue=>n(Ue.message,"error")}),Ne=st({mutationFn:({id:Ue,data:yt})=>ne.updateLibraryFolder(Ue,yt),onSuccess:(Ue,yt)=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["project-folders"]}),e.invalidateQueries({queryKey:["archive-folders"]}),k(null);const xt=yt.data.project_id===0&&yt.data.archive_id===0;n(t(xt?"fileManager.toast.folderUnlinked":"fileManager.toast.folderLinked"),"success")},onError:Ue=>n(Ue.message,"error")}),ye=st({mutationFn:({id:Ue,filename:yt})=>ne.updateLibraryFile(Ue,{filename:yt}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),$(null),n(t("fileManager.toast.fileRenamed"),"success")},onError:Ue=>{$(null),n(Ue.message,"error")}}),ve=st({mutationFn:({id:Ue,name:yt})=>ne.updateLibraryFolder(Ue,{name:yt}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),$(null),n(t("fileManager.toast.folderRenamed"),"success")},onError:Ue=>{$(null),n(Ue.message,"error")}}),Ge=st({mutationFn:()=>ne.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:Ue=>{if(e.invalidateQueries({queryKey:["library-files"]}),Ue.succeeded>0){const yt=Date.now(),xt={};Ue.results.forEach(Vt=>{Vt.success&&(xt[Vt.file_id]=yt)}),U(Vt=>({...Vt,...xt}))}Ue.succeeded>0&&Ue.failed===0?n(t("fileManager.toast.thumbnailsGenerated",{count:Ue.succeeded}),"success"):Ue.succeeded>0&&Ue.failed>0?n(t("fileManager.toast.thumbnailsGeneratedPartial",{succeeded:Ue.succeeded,failed:Ue.failed}),"success"):Ue.processed===0?n(t("fileManager.toast.noStlMissingThumbnails"),"info"):n(t("fileManager.toast.failedToGenerateThumbnails",{error:Ue.results[0]?.error||"Unknown error"}),"error")},onError:Ue=>n(Ue.message,"error")}),Te=st({mutationFn:Ue=>ne.batchGenerateStlThumbnails({file_ids:[Ue]}),onSuccess:Ue=>{if(e.invalidateQueries({queryKey:["library-files"]}),Ue.succeeded>0){const yt=Ue.results[0]?.file_id;yt&&U(xt=>({...xt,[yt]:Date.now()})),n(t("fileManager.toast.thumbnailGenerated"),"success")}else n(t("fileManager.toast.failedToGenerateThumbnail",{error:Ue.results[0]?.error||"Unknown error"}),"error")},onError:Ue=>n(Ue.message,"error")}),nt=w.useCallback(Ue=>{const yt=Ue.toLowerCase();return yt.endsWith(".gcode")||yt.includes(".gcode.")},[]),De=w.useMemo(()=>L?L.filter(Ue=>f.includes(Ue.id)&&nt(Ue.filename)):[],[L,f,nt]),Ke=w.useCallback(Ue=>{p(yt=>yt.includes(Ue)?yt.filter(xt=>xt!==Ue):[...yt,Ue])},[]),Oe=w.useCallback(()=>{te.length>0&&p(te.map(Ue=>Ue.id))},[te]),Ee=w.useCallback(()=>{p([])},[]),Ve=()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]})},ot=Ue=>{ne.downloadLibraryFile(Ue).catch(yt=>{console.error("Library file download failed:",yt)})},Ct=()=>{M&&(M.type==="file"?Re.mutate(M.id):M.type==="folder"?$e.mutate(M.id):M.type==="bulk"&&fe.mutate(f))},Lt=$e.isPending||Re.isPending||fe.isPending,Bt=Ue=>{H(Ue),localStorage.setItem("library-view-mode",Ue)},Mt=ge||R;return a.jsxs("div",{className:"p-4 md:p-8 min-h-[calc(100vh-64px)] lg:h-[calc(100vh-64px)] flex flex-col",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:a.jsx(Ql,{className:"w-6 h-6 text-bambu-green"})}),t("fileManager.title")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("fileManager.subtitle")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex items-center bg-bambu-dark rounded-lg p-1",children:[a.jsx("button",{onClick:()=>Bt("grid"),className:`p-1.5 rounded transition-colors ${re==="grid"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.gridView"),children:a.jsx(u0,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>Bt("list"),className:`p-1.5 rounded transition-colors ${re==="list"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.listView"),children:a.jsx(qC,{className:"w-4 h-4"})})]}),a.jsxs(Me,{variant:"secondary",onClick:()=>Ge.mutate(),disabled:Ge.isPending||!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?t("fileManager.generateThumbnailsForMissing"):t("fileManager.noPermissionGenerateThumbnail"),children:[Ge.isPending?a.jsx(at,{className:"w-4 h-4 mr-2 animate-spin"}):a.jsx(Jd,{className:"w-4 h-4 mr-2"}),t("fileManager.generateThumbnails")]}),a.jsxs(Me,{variant:"secondary",onClick:()=>v(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionCreateFolder"),children:[a.jsx(wme,{className:"w-4 h-4 mr-2"}),t("fileManager.newFolder")]}),a.jsxs(Me,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(La,{className:"w-4 h-4 mr-2"}),t("common.upload")]})]})]}),Be&&q&&Le&&a.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[a.jsx(An,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-amber-500 font-medium",children:t("fileManager.lowDiskSpaceWarning")}),a.jsx("p",{className:"text-xs text-amber-500/80",children:t("fileManager.lowDiskSpaceDetails",{free:dl(q.disk_free_bytes),total:dl(q.disk_total_bytes),threshold:Le.library_disk_warning_gb})})]})]}),q&&a.jsxs("div",{className:"flex flex-wrap items-center gap-3 sm:gap-6 mb-6 p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(HC,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.files"),":"]}),a.jsx("span",{className:"text-white font-medium",children:q.total_files})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Ql,{className:"w-4 h-4 text-blue-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.folders"),":"]}),a.jsx("span",{className:"text-white font-medium",children:q.total_folders})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx($b,{className:"w-4 h-4 text-amber-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.size"),":"]}),a.jsx("span",{className:"text-white font-medium",children:dl(q.total_size_bytes)})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm sm:ml-auto",children:[a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.free"),":"]}),a.jsx("span",{className:`font-medium ${Be?"text-amber-500":"text-white"}`,children:dl(q.disk_free_bytes)})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-4 lg:gap-6 min-h-0",children:[a.jsx("div",{className:"lg:hidden",children:a.jsxs("select",{value:u??"",onChange:Ue=>h(Ue.target.value?parseInt(Ue.target.value,10):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg px-3 py-2.5 text-white focus:outline-none focus:border-bambu-green",children:[a.jsxs("option",{value:"",children:["📁 ",t("fileManager.allFiles")]}),Ce&&(()=>{const Ue=(yt,xt=0)=>{const Vt=[];for(const yn of yt)Vt.push({id:yn.id,name:yn.name,fileCount:yn.file_count,depth:xt}),yn.children.length>0&&Vt.push(...Ue(yn.children,xt+1));return Vt};return Ue(Ce).map(yt=>a.jsxs("option",{value:yt.id,children:["│ ".repeat(yt.depth),"📂 ",yt.name," ",yt.fileCount>0?`(${yt.fileCount})`:""]},yt.id))})()]})}),a.jsxs("div",{ref:je,className:"hidden lg:flex flex-shrink-0 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden flex-col relative",style:{width:`${Z}px`},children:[a.jsx("div",{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 group/resize flex items-center justify-center transition-colors ${oe?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:Ue=>{Ue.preventDefault(),J(!0)},onDoubleClick:()=>{we(256),localStorage.setItem("library-sidebar-width","256")},title:t("fileManager.dragToResizeTooltip"),children:a.jsxs("div",{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${oe?"opacity-100":""}`,children:[a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"})]})}),a.jsxs("div",{className:"p-3 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsx("h2",{className:"text-sm font-medium text-white",children:t("fileManager.folders")}),a.jsx("button",{onClick:()=>{const Ue=!K;ee(Ue),localStorage.setItem("library-wrap-folders",String(Ue))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${K?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:t(K?"fileManager.disableTextWrapping":"fileManager.enableTextWrapping"),children:t("fileManager.wrap")})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[a.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${u===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>h(null),children:[a.jsx(hf,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:t("fileManager.allFiles")})]}),Ce?.map(Ue=>a.jsx(Zie,{folder:Ue,selectedFolderId:u,onSelect:h,onDelete:yt=>C({type:"folder",id:yt}),onLink:k,onRename:yt=>$({type:"folder",id:yt.id,name:yt.name}),wrapNames:K,hasPermission:r,t},Ue.id))]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[L&&L.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mb-4 p-2 sm:p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-0 z-10 lg:static",children:[a.jsxs("div",{className:"relative w-full sm:w-auto sm:flex-1 sm:max-w-xs",children:[a.jsx(Mr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:t("fileManager.searchFiles"),value:de,onChange:Ue=>le(Ue.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx($C,{className:"w-4 h-4 text-bambu-gray hidden sm:block"}),a.jsxs("select",{value:_e,onChange:Ue=>se(Ue.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"all",children:t("fileManager.allTypes")}),pe.map(Ue=>a.jsx("option",{value:Ue,children:Ue.toUpperCase()},Ue))]})]}),o&&a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",placeholder:t("fileManager.filterByUser",{defaultValue:"Filter by user"}),value:ze,onChange:Ue=>V(Ue.target.value),list:"usernames-list",className:`w-32 sm:w-40 px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green ${ze?"pr-7":""}`,style:ze?{WebkitAppearance:"none",MozAppearance:"textfield"}:void 0}),ze&&a.jsx("button",{onClick:()=>V(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white z-10",children:a.jsx(Rt,{className:"w-3 h-3"})}),a.jsx("datalist",{id:"usernames-list",children:ce?.map(Ue=>a.jsx("option",{value:Ue.username},Ue.id))})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{value:X,onChange:Ue=>{const yt=Ue.target.value;me(yt),localStorage.setItem("library-sort-field",yt)},className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"name",children:t("common.name")}),a.jsx("option",{value:"date",children:t("common.date")}),a.jsx("option",{value:"size",children:t("fileManager.size")}),a.jsx("option",{value:"type",children:t("common.type")}),a.jsx("option",{value:"prints",children:t("fileManager.prints")})]}),a.jsx("button",{onClick:()=>ie(Ue=>{const yt=Ue==="asc"?"desc":"asc";return localStorage.setItem("library-sort-direction",yt),yt}),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:t(Q==="asc"?"fileManager.ascending":"fileManager.descending"),children:Q==="asc"?a.jsx(zue,{className:"w-4 h-4 text-white"}):a.jsx(jue,{className:"w-4 h-4 text-white"})})]}),(de||_e!=="all"||ze)&&a.jsx("span",{className:"text-sm text-bambu-gray hidden sm:inline",children:t("fileManager.resultsCount",{showing:te.length,total:L.length})})]}),te.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4 p-2 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-[52px] z-10 lg:static",children:[f.length===te.length&&f.length>0?a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Ee,children:[a.jsx(vl,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.deselectAll")})]}):a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Oe,children:[a.jsx(oo,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.selectAll")})]}),f.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-bambu-gray ml-2",children:t("fileManager.selected",{count:f.length})}),a.jsx("div",{className:"hidden sm:block flex-1"}),a.jsxs("div",{className:"w-full sm:w-auto flex flex-wrap items-center gap-2 mt-2 sm:mt-0",children:[De.length===1&&a.jsxs(Me,{variant:"primary",size:"sm",onClick:()=>B(De[0]),disabled:!r("printers:control"),title:r("printers:control")?void 0:t("fileManager.noPermissionPrint"),children:[a.jsx(io,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.print")})]}),De.length===1&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>z(De[0]),disabled:!r("queue:create"),title:r("queue:create")?void 0:t("fileManager.noPermissionAddToQueue"),children:[a.jsx(Vn,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.schedulePrint")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>y(!0),disabled:!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?void 0:t("fileManager.noPermissionMoveFiles"),children:[a.jsx(Pfe,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.move")})]}),a.jsxs(Me,{variant:"danger",size:"sm",onClick:()=>{f.length===1?C({type:"file",id:f[0]}):C({type:"bulk",id:0,count:f.length})},disabled:!i("library:delete_own","library:delete_all"),title:i("library:delete_own","library:delete_all")?void 0:t("fileManager.noPermissionDeleteFiles"),children:[a.jsx(Xt,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.delete")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Ee,children:[a.jsx(Rt,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.clear")})]})]})]})]}),Mt?a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(at,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("fileManager.loadingFiles")})]})}):L?.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(hf,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t(u!==null?"fileManager.folderIsEmpty":"fileManager.noFilesYet")}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t(u!==null?"fileManager.folderEmptyDescription":"fileManager.noFilesDescription")}),a.jsxs(Me,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(Xn,{className:"w-4 h-4 mr-2"}),t("fileManager.uploadFiles")]})]}):te.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(Mr,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t("fileManager.noMatchingFiles")}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t("fileManager.noMatchingFilesDescription")}),a.jsx(Me,{variant:"secondary",onClick:()=>{le(""),se("all")},children:t("fileManager.clearFilters")})]}):re==="grid"?a.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4",children:te.map(Ue=>a.jsx(vJe,{file:Ue,isSelected:f.includes(Ue.id),isMobile:ue,t,onSelect:Ke,onDelete:yt=>C({type:"file",id:yt}),onDownload:ot,onAddToQueue:yt=>{const xt=L?.find(Vt=>Vt.id===yt);xt&&z(xt)},onPrint:P,onPreview3d:Y,onRename:yt=>$({type:"file",id:yt.id,name:yt.filename}),onGenerateThumbnail:yt=>Te.mutate(yt.id),thumbnailVersion:G[Ue.id],hasPermission:r,canModify:s,authEnabled:o},Ue.id))})}):a.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsxs("div",{className:`hidden sm:grid ${o?"grid-cols-[auto_1fr_120px_100px_100px_100px_80px]":"grid-cols-[auto_1fr_100px_100px_100px_80px]"} gap-4 px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary text-xs text-bambu-gray font-medium`,children:[a.jsx("div",{className:"w-6"}),a.jsx("div",{children:t("common.name")}),o&&a.jsx("div",{children:t("fileManager.uploadedBy",{defaultValue:"Uploaded By"})}),a.jsx("div",{children:t("common.type")}),a.jsx("div",{children:t("fileManager.size")}),a.jsx("div",{children:t("fileManager.prints")}),a.jsx("div",{})]}),te.map(Ue=>a.jsxs("div",{className:`grid ${o?"grid-cols-[auto_1fr_120px_100px_100px_100px_80px]":"grid-cols-[auto_1fr_100px_100px_100px_80px]"} gap-4 px-4 py-3 items-center border-b border-bambu-dark-tertiary last:border-b-0 cursor-pointer hover:bg-bambu-dark/50 transition-colors ${f.includes(Ue.id)?"bg-bambu-green/10":""}`,onClick:()=>Ke(Ue.id),children:[a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${f.includes(Ue.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:f.includes(Ue.id)&&a.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})}),a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsxs("div",{className:"relative group/thumb",children:[a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden",children:Ue.thumbnail_path?a.jsx("img",{src:`${ne.getLibraryFileThumbnailUrl(Ue.id)}${G[Ue.id]?`?v=${G[Ue.id]}`:""}`,alt:"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx(hf,{className:"w-5 h-5 text-bambu-gray/50"})})}),Ue.thumbnail_path&&a.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:a.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:a.jsx("img",{src:`${ne.getLibraryFileThumbnailUrl(Ue.id)}${G[Ue.id]?`?v=${G[Ue.id]}`:""}`,alt:Ue.filename,className:"w-full h-full object-contain"})})})]}),a.jsx("div",{className:"min-w-0",children:a.jsx("div",{className:"text-sm text-white truncate",children:Ue.print_name||Ue.filename})})]}),o&&a.jsx("div",{className:"text-sm text-bambu-gray flex items-center gap-1",children:Ue.created_by_username?a.jsxs(a.Fragment,{children:[a.jsx(tu,{className:"w-3 h-3"}),a.jsx("span",{className:"truncate",children:Ue.created_by_username})]}):"-"}),a.jsx("div",{children:a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${Ue.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":Ue.file_type==="gcode"?"bg-blue-500/20 text-blue-400":Ue.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:Ue.file_type.toUpperCase()})}),a.jsx("div",{className:"text-sm text-bambu-gray",children:dl(Ue.file_size)}),a.jsx("div",{className:"text-sm text-bambu-gray",children:Ue.print_count>0?`${Ue.print_count}x`:"-"}),a.jsxs("div",{className:"flex items-center gap-1",onClick:yt=>yt.stopPropagation(),children:[aF(Ue.filename)&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>r("printers:control")&&P(Ue),className:`p-1.5 rounded transition-colors ${r("printers:control")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("printers:control")?t("common.print"):t("fileManager.noPermissionPrint"),disabled:!r("printers:control"),children:a.jsx(Sr,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{r("queue:create")&&z(Ue)},className:`p-1.5 rounded transition-colors ${r("queue:create")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("queue:create")?t("fileManager.schedulePrint"):t("fileManager.noPermissionAddToQueue"),disabled:!r("queue:create"),children:a.jsx(Vn,{className:"w-4 h-4"})})]}),(Ue.file_type==="3mf"||Ue.file_type==="gcode"||Ue.file_type==="stl")&&a.jsx("button",{onClick:()=>r("library:read")&&Y(Ue),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?"3D Preview":"You do not have permission to preview files",disabled:!r("library:read"),children:a.jsx(ai,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>r("library:read")&&ot(Ue.id),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?t("common.download"):t("fileManager.noPermissionDownload"),disabled:!r("library:read"),children:a.jsx(ha,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","update",Ue.created_by_id)&&$({type:"file",id:Ue.id,name:Ue.filename}),className:`p-1.5 rounded transition-colors ${s("library","update",Ue.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",Ue.created_by_id)?t("common.rename"):t("fileManager.noPermissionRenameFile"),disabled:!s("library","update",Ue.created_by_id),children:a.jsx(Ya,{className:"w-4 h-4"})}),Ue.file_type==="stl"&&a.jsx("button",{onClick:()=>s("library","update",Ue.created_by_id)&&Te.mutate(Ue.id),className:`p-1.5 rounded transition-colors ${s("library","update",Ue.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",Ue.created_by_id)?t("fileManager.generateThumbnail"):t("fileManager.noPermissionGenerateThumbnail"),disabled:Te.isPending||!s("library","update",Ue.created_by_id),children:a.jsx(Jd,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","delete",Ue.created_by_id)&&C({type:"file",id:Ue.id}),className:`p-1.5 rounded transition-colors ${s("library","delete",Ue.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","delete",Ue.created_by_id)?t("common.delete"):t("fileManager.noPermissionDeleteFile"),disabled:!s("library","delete",Ue.created_by_id),children:a.jsx(Xt,{className:"w-4 h-4"})})]})]},Ue.id))]})})]})]}),x&&a.jsx(pJe,{parentId:u,onClose:()=>v(!1),onSave:Ue=>Ie.mutate(Ue),isLoading:Ie.isPending,t}),g&&Ce&&a.jsx(bJe,{folders:Ce,selectedFiles:f,currentFolderId:u,onClose:()=>y(!1),onMove:Ue=>xe.mutate({fileIds:f,folderId:Ue}),isLoading:xe.isPending,t}),_&&a.jsx(yJe,{folderId:u,onClose:()=>N(!1),onUploadComplete:Ve,t}),T&&a.jsx(xJe,{folder:T,onClose:()=>k(null),onLink:Ue=>Ne.mutate({id:T.id,data:Ue}),isLoading:Ne.isPending,t}),M&&a.jsx(xn,{title:M.type==="folder"?t("fileManager.deleteFolder"):M.type==="bulk"?t("fileManager.deleteFilesCount",{count:M.count}):t("fileManager.deleteFile"),message:M.type==="folder"?t("fileManager.deleteFolderConfirm"):M.type==="bulk"?t("fileManager.deleteFilesConfirm",{count:M.count}):t("fileManager.deleteFileConfirm"),confirmText:t("common.delete"),variant:"danger",isLoading:Lt,loadingText:t("fileManager.deleting"),onConfirm:Ct,onCancel:()=>C(null)}),j&&a.jsx(Yd,{mode:"reprint",libraryFileId:j.id,archiveName:j.print_name||j.filename,onClose:()=>P(null),onSuccess:()=>{P(null),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),E&&a.jsx(Yd,{mode:"reprint",libraryFileId:E.id,archiveName:E.print_name||E.filename,onClose:()=>B(null),onSuccess:()=>{B(null),p([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),O&&a.jsx(Yd,{mode:"add-to-queue",libraryFileId:O.id,archiveName:O.print_name||O.filename,onClose:()=>z(null),onSuccess:()=>{z(null),p([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["queue"]}),e.invalidateQueries({queryKey:["archives"]})}}),W&&a.jsx(g4,{libraryFileId:W.id,title:W.print_name||W.filename,fileType:W.file_type,onClose:()=>Y(null)}),D&&a.jsx(gJe,{type:D.type,currentName:D.name,onClose:()=>$(null),onSave:Ue=>{D.type==="file"?ye.mutate({id:D.id,filename:Ue}):ve.mutate({id:D.id,name:Ue})},isLoading:ye.isPending||ve.isPending,t})]})}const Rj=5,SJe=2e3,_Je=3e4,NJe=5e3;function CJe(){const{t}=Dt(),e=Jt(),{showToast:n}=ln(),{hasPermission:r}=Pr(),{printerId:i}=o0(),s=parseInt(i||"0",10),[o,l]=w.useState("stream"),[c,d]=w.useState(!1),[u,h]=w.useState(!1),[f,p]=w.useState(!0),[x,v]=w.useState(Date.now()),[g,y]=w.useState(!1),[_,N]=w.useState(!1),[T,k]=w.useState(0),[M,C]=w.useState(!1),[j,P]=w.useState(0),[E,B]=w.useState(1),[O,z]=w.useState({x:0,y:0}),[D,$]=w.useState(!1),[G,U]=w.useState({x:0,y:0}),[W,Y]=w.useState(null),[re,H]=w.useState(null),K=w.useRef(null),ee=w.useRef(null),Z=w.useRef(null),we=w.useRef(null),oe=w.useRef(null),{data:J}=Je({queryKey:["printer",s],queryFn:()=>ne.getPrinter(s),enabled:s>0}),{data:je}=Je({queryKey:["printerStatus",s],queryFn:()=>ne.getPrinterStatus(s),refetchInterval:3e4,enabled:s>0}),de=st({mutationFn:xe=>ne.setChamberLight(s,xe),onMutate:async xe=>{await e.cancelQueries({queryKey:["printerStatus",s]});const Ne=e.getQueryData(["printerStatus",s]);return e.setQueryData(["printerStatus",s],ye=>({...ye,chamber_light:xe})),{previousStatus:Ne}},onSuccess:(xe,Ne)=>{n(`Chamber light ${Ne?"on":"off"}`)},onError:(xe,Ne,ye)=>{ye?.previousStatus&&e.setQueryData(["printerStatus",s],ye.previousStatus),n(xe.message||t("printers.toast.failedToControlChamberLight"),"error")}}),le=(je?.state==="RUNNING"||je?.state==="PAUSE")&&(je?.printable_objects_count??0)>=2;w.useEffect(()=>(J&&(document.title=`${J.name} - Camera`),()=>{document.title="Bambuddy"}),[J]);const _e=w.useRef(!1);w.useEffect(()=>{const xe=`/api/v1/printers/${s}/camera/stop`;_e.current=!1;const Ne=()=>{if(s>0&&!_e.current){_e.current=!0;const Ge={},Te=ru();Te&&(Ge.Authorization=`Bearer ${Te}`),fetch(xe,{method:"POST",keepalive:!0,headers:Ge}).catch(()=>{})}},ye=()=>{Ne()};window.addEventListener("beforeunload",ye);const ve=K.current;return()=>{window.removeEventListener("beforeunload",ye),ve&&(ve.src=""),Ne()}},[s]),w.useEffect(()=>{if(f&&!g){const Ne=setTimeout(()=>{p(!1)},o==="stream"?3e3:2e4);return()=>clearTimeout(Ne)}},[o,f,x,g]),w.useEffect(()=>{const xe=()=>{const Ne=!!document.fullscreenElement;N(Ne),B(1),z({x:0,y:0}),o==="stream"&&!g&&(K.current&&(K.current.src=""),setTimeout(()=>{p(!0),v(Date.now())},200))};return document.addEventListener("fullscreenchange",xe),()=>document.removeEventListener("fullscreenchange",xe)},[o,g]),w.useEffect(()=>{let xe;const Ne=()=>{clearTimeout(xe),xe=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",Ne),()=>{clearTimeout(xe),window.removeEventListener("resize",Ne)}},[]),w.useEffect(()=>()=>{Z.current&&clearTimeout(Z.current),we.current&&clearInterval(we.current),oe.current&&clearInterval(oe.current)},[]);const se=w.useCallback(()=>{if(T>=Rj){C(!1),h(!0);return}const xe=Math.min(SJe*Math.pow(2,T),_Je);C(!0),P(Math.ceil(xe/1e3)),we.current=setInterval(()=>{P(Ne=>Ne<=1?(we.current&&clearInterval(we.current),0):Ne-1)},1e3),Z.current=setTimeout(()=>{k(Ne=>Ne+1),C(!1),p(!0),h(!1),K.current&&(K.current.src=""),v(Date.now())},xe)},[T]);w.useEffect(()=>{if(o!=="stream"||f||M||g){oe.current&&(clearInterval(oe.current),oe.current=null);return}return oe.current=setInterval(async()=>{try{const xe=await ne.getCameraStatus(s);(xe.stalled||!xe.active&&!u)&&(console.log(`Stream issue detected: stalled=${xe.stalled}, active=${xe.active}, reconnecting...`),oe.current&&(clearInterval(oe.current),oe.current=null),p(!1),se())}catch{}},NJe),()=>{oe.current&&(clearInterval(oe.current),oe.current=null)}},[o,f,u,M,g,s,se]);const ze=()=>{p(!1),o==="stream"&&T{if(p(!1),h(!1),k(0),C(!1),Z.current&&clearTimeout(Z.current),we.current&&clearInterval(we.current),K.current&&!localStorage.getItem("cameraWindowState")){const xe=K.current,Ne=xe.naturalWidth,ye=xe.naturalHeight;if(Ne>0&&ye>0){const Te=window.outerWidth-window.innerWidth,nt=window.outerHeight-window.innerHeight,De=Ne+16+Te,Ke=ye+45+16+nt;try{window.resizeTo(De,Ke)}catch{}}}},X=()=>{if(s>0){const xe={},Ne=ru();Ne&&(xe.Authorization=`Bearer ${Ne}`),fetch(`/api/v1/printers/${s}/camera/stop`,{method:"POST",headers:xe}).catch(()=>{})}},me=xe=>{o===xe||g||(y(!0),p(!0),h(!1),k(0),C(!1),B(1),z({x:0,y:0}),Z.current&&clearTimeout(Z.current),we.current&&clearInterval(we.current),K.current&&(K.current.src=""),o==="stream"&&X(),setTimeout(()=>{l(xe),v(Date.now()),y(!1)},100))},Q=()=>{g||(y(!0),p(!0),h(!1),k(0),C(!1),Z.current&&clearTimeout(Z.current),we.current&&clearInterval(we.current),K.current&&(K.current.src=""),o==="stream"&&X(),setTimeout(()=>{v(Date.now()),y(!1)},100))},ie=()=>{ee.current&&(document.fullscreenElement?document.exitFullscreen():ee.current.requestFullscreen())},ue=()=>{B(xe=>Math.min(xe+.5,4))},Le=()=>{B(xe=>{const Ne=Math.max(xe-.5,1);return Ne===1&&z({x:0,y:0}),Ne})},Ce=xe=>{xe.preventDefault(),xe.deltaY<0?ue():Le()},ge=xe=>{E>1&&(xe.preventDefault(),$(!0),U({x:xe.clientX-O.x,y:xe.clientY-O.y}))},L=w.useCallback(()=>{if(!ee.current)return{x:300,y:200};const xe=ee.current.getBoundingClientRect(),Ne=xe.width*(E-1)/2,ye=xe.height*(E-1)/2;return{x:Math.max(50,Ne),y:Math.max(50,ye)}},[E]),R=xe=>{if(D&&E>1){const Ne=xe.clientX-G.x,ye=xe.clientY-G.y,ve=L();z({x:Math.max(-ve.x,Math.min(ve.x,Ne)),y:Math.max(-ve.y,Math.min(ve.y,ye))})}},q=()=>{$(!1)},ce=xe=>{if(xe.length<2)return 0;const Ne=xe[0].clientX-xe[1].clientX,ye=xe[0].clientY-xe[1].clientY;return Math.sqrt(Ne*Ne+ye*ye)},pe=xe=>xe.length<2?{x:xe[0].clientX,y:xe[0].clientY}:{x:(xe[0].clientX+xe[1].clientX)/2,y:(xe[0].clientY+xe[1].clientY)/2},te=xe=>{xe.touches.length===2?(xe.preventDefault(),Y(ce(xe.touches)),H(pe(xe.touches))):xe.touches.length===1&&E>1&&(xe.preventDefault(),$(!0),U({x:xe.touches[0].clientX-O.x,y:xe.touches[0].clientY-O.y}))},Be=xe=>{if(xe.touches.length===2&&W!==null){xe.preventDefault();const Ne=ce(xe.touches),ye=Ne/W;B(Ge=>{const Te=Math.max(1,Math.min(4,Ge*ye));return Te===1&&z({x:0,y:0}),Te}),Y(Ne);const ve=pe(xe.touches);if(re){const Ge=L();z(Te=>({x:Math.max(-Ge.x,Math.min(Ge.x,Te.x+(ve.x-re.x))),y:Math.max(-Ge.y,Math.min(Ge.y,Te.y+(ve.y-re.y)))}))}H(ve)}else if(xe.touches.length===1&&D&&E>1){xe.preventDefault();const Ne=xe.touches[0].clientX-G.x,ye=xe.touches[0].clientY-G.y,ve=L();z({x:Math.max(-ve.x,Math.min(ve.x,Ne)),y:Math.max(-ve.y,Math.min(ve.y,ye))})}},Ie=xe=>{xe.touches.length<2&&(Y(null),H(null)),xe.touches.length===0&&$(!1)},$e=()=>{B(1),z({x:0,y:0})},Re=g?"":o==="stream"?`/api/v1/printers/${s}/camera/stream?fps=15&t=${x}`:`/api/v1/printers/${s}/camera/snapshot?t=${x}`,fe=f||g||M;return s?a.jsxs("div",{ref:ee,className:"min-h-screen bg-black flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[a.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a.jsx(cb,{className:"w-4 h-4"}),J?.name||`Printer ${s}`]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[a.jsx("button",{onClick:()=>me("stream"),disabled:fe,className:`px-3 py-1 text-xs rounded transition-colors ${o==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.live")}),a.jsx("button",{onClick:()=>me("snapshot"),disabled:fe,className:`px-3 py-1 text-xs rounded transition-colors ${o==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.snapshot")})]}),a.jsx("button",{onClick:()=>de.mutate(!je?.chamber_light),disabled:!je?.connected||de.isPending||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${je?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30":"hover:bg-bambu-dark-tertiary"}`,title:r("printers:control")?t("camera.chamberLight"):t("printers.permission.noControl"),children:a.jsx(lL,{on:je?.chamber_light??!1,className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>d(!0),disabled:!le||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${le&&r("printers:control")?"hover:bg-bambu-dark-tertiary":""}`,title:r("printers:control")?t(le?"printers.skipObjects.tooltip":"printers.skipObjects.onlyWhilePrinting"):t("printers.permission.noControl"),children:a.jsx(uk,{className:"w-4 h-4 text-bambu-gray"})}),a.jsx("button",{onClick:Q,disabled:fe,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:t(o==="stream"?"camera.restartStream":"camera.refreshSnapshot"),children:a.jsx(vr,{className:`w-4 h-4 text-bambu-gray ${fe?"animate-spin":""}`})}),a.jsx("button",{onClick:ie,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:t(_?"camera.exitFullscreen":"camera.fullscreen"),children:_?a.jsx(yY,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(xfe,{className:"w-4 h-4 text-bambu-gray"})})]})]}),a.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:Ce,onMouseMove:R,onMouseUp:q,onMouseLeave:q,onTouchStart:te,onTouchMove:Be,onTouchEnd:Ie,style:{touchAction:"none"},children:a.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(f||g)&&!M&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:a.jsxs("div",{className:"text-center",children:[a.jsx(vr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t(o==="stream"?"camera.connectingToCamera":"camera.capturingSnapshot")})]})}),M&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:a.jsxs("div",{className:"text-center p-4",children:[a.jsx(qh,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:t("camera.connectionLost")}),a.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:t("camera.reconnecting",{countdown:j,attempt:T+1,max:Rj})}),a.jsx("button",{onClick:Q,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.reconnectNow")})]})}),u&&!M&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:a.jsxs("div",{className:"text-center p-4",children:[a.jsx(An,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:t("camera.cameraUnavailable")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:t("camera.cameraUnavailableDesc")}),a.jsx("button",{onClick:Q,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.retry")})]})}),a.jsx("img",{ref:K,src:Re,alt:t("camera.cameraStream"),className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${E}) translate(${O.x/E}px, ${O.y/E}px)`,cursor:E>1?D?"grabbing":"grab":"default"},onError:Re?ze:void 0,onLoad:Re?V:void 0,onMouseDown:ge,draggable:!1},x),a.jsxs("div",{className:"absolute bottom-4 left-4 flex items-center gap-1.5 bg-black/60 rounded-lg px-2 py-1.5",children:[a.jsx("button",{onClick:Le,disabled:E<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomOut"),children:a.jsx(jF,{className:"w-4 h-4 text-white"})}),a.jsxs("button",{onClick:$e,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:t("camera.resetZoom"),children:[Math.round(E*100),"%"]}),a.jsx("button",{onClick:ue,disabled:E>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomIn"),children:a.jsx(EF,{className:"w-4 h-4 text-white"})})]})]})}),a.jsx(cL,{printerId:s,isOpen:c,onClose:()=>d(!1)})]}):a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-white",children:t("camera.invalidPrinterId")})})}function kJe(t){const e=t.get("show")?.split(",")||["progress","layers","eta","filename","status"],n=parseInt(t.get("fps")||"15",10),r=Math.min(Math.max(isNaN(n)?15:n,1),30),i=t.get("camera"),s=i!=="false"&&i!=="0";return{size:t.get("size")||"medium",fps:r,showCamera:s,showProgress:e.includes("progress"),showLayers:e.includes("layers"),showEta:e.includes("eta"),showFilename:e.includes("filename"),showStatus:e.includes("status"),showPrinter:e.includes("printer")}}function AJe(t,e){if(t.stg_cur_name)return t.stg_cur_name;switch(t.state){case"RUNNING":return e("streamOverlay.status.printing");case"PAUSE":return e("streamOverlay.status.paused");case"FINISH":return e("streamOverlay.status.finished");case"FAILED":return e("streamOverlay.status.failed");case"IDLE":return e("streamOverlay.status.idle");default:return t.state||e("streamOverlay.status.unknown")}}function TJe(t){switch(t){case"small":return{container:"p-3",text:"text-sm",textLarge:"text-lg",progressHeight:"h-2",icon:"w-3 h-3",gap:"gap-2",logoHeight:"h-12"};case"large":return{container:"p-6",text:"text-xl",textLarge:"text-3xl",progressHeight:"h-4",icon:"w-6 h-6",gap:"gap-4",logoHeight:"h-24"};default:return{container:"p-4",text:"text-base",textLarge:"text-xl",progressHeight:"h-3",icon:"w-4 h-4",gap:"gap-3",logoHeight:"h-16"}}}function MJe(){const{printerId:t}=o0(),[e]=gF(),{t:n}=Dt(),r=Jt(),i=parseInt(t||"0",10),[s,o]=w.useState(Date.now()),l=w.useMemo(()=>kJe(e),[e]),c=TJe(l.size),{data:d}=Je({queryKey:["printer",i],queryFn:()=>ne.getPrinter(i),enabled:i>0}),{data:u}=Je({queryKey:["printerStatus",i],queryFn:()=>ne.getPrinterStatus(i),enabled:i>0,refetchInterval:2e3}),{data:h}=Je({queryKey:["settings"],queryFn:ne.getSettings}),f=h?.time_format||"system";w.useEffect(()=>{if(!i)return;const _=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,N=new WebSocket(_);return N.onmessage=T=>{try{const k=JSON.parse(T.data);k.type==="printer_status"&&k.printer_id===i&&r.setQueryData(["printerStatus",i],k.status)}catch{}},N.onerror=()=>{},()=>{N.close()}},[i,r]),w.useEffect(()=>(document.title=d?`${d.name} - ${n("streamOverlay.title")}`:n("streamOverlay.title"),()=>{document.title="Bambuddy"}),[d,n]);const p=()=>{setTimeout(()=>{o(Date.now())},3e3)};if(!i)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-white",children:n("streamOverlay.invalidPrinterId")})});if(!u)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-gray-400",children:n("common.loading")})});const x=u.state==="RUNNING"||u.state==="PAUSE",v=u.progress||0,g=`/api/v1/printers/${i}/camera/stream?fps=${l.fps}&t=${s}`;return a.jsxs("div",{className:"min-h-screen bg-black relative overflow-hidden",children:[l.showCamera&&a.jsx("img",{src:g,alt:n("streamOverlay.cameraStream"),className:"absolute inset-0 w-full h-full object-contain",onError:p},s),a.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"absolute top-4 right-4 z-10",children:a.jsx("img",{src:"/img/bambuddy_logo_dark_transparent.png",alt:"Bambuddy",className:`${c.logoHeight} object-contain drop-shadow-lg hover:scale-105 transition-transform`})}),a.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-10 bg-gradient-to-t from-black/80 via-black/60 to-transparent",children:a.jsxs("div",{className:`${c.container}`,children:[l.showPrinter&&d&&a.jsxs("div",{className:`flex items-center ${c.gap} mb-2`,children:[a.jsx(Sr,{className:`${c.icon} text-white/70`}),a.jsx("span",{className:`${c.text} text-white font-medium`,children:d.name})]}),l.showFilename&&u.current_print&&a.jsx("div",{className:`${c.textLarge} text-white font-semibold mb-2 truncate drop-shadow-md`,children:u.current_print.replace(/\.gcode\.3mf$|\.3mf$|\.gcode$/i,"")}),l.showStatus&&a.jsx("div",{className:`${c.text} text-white/70 mb-2`,children:AJe(u,n)}),l.showProgress&&x&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:`flex items-center justify-between mb-1 ${c.text}`,children:[a.jsx("span",{className:"text-white/70",children:n("streamOverlay.progress")}),a.jsxs("span",{className:"text-white font-bold",children:[Math.round(v),"%"]})]}),a.jsx("div",{className:`w-full bg-white/20 rounded-full ${c.progressHeight}`,children:a.jsx("div",{className:`bg-bambu-green ${c.progressHeight} rounded-full transition-all duration-500`,style:{width:`${v}%`}})})]}),x&&(l.showLayers||l.showEta)&&a.jsxs("div",{className:`flex items-center ${c.gap} flex-wrap`,children:[l.showLayers&&u.layer_num!=null&&u.total_layers!=null&&u.total_layers>0&&a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(oi,{className:c.icon}),a.jsxs("span",{className:c.text,children:[a.jsx("span",{className:"text-white",children:u.layer_num}),a.jsx("span",{className:"mx-1",children:"/"}),a.jsx("span",{children:u.total_layers})]})]}),l.showEta&&u.remaining_time!=null&&u.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(Ld,{className:c.icon}),a.jsx("span",{className:`${c.text} text-white`,children:Qs(u.remaining_time*60)})]}),a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(Vn,{className:c.icon}),a.jsxs("span",{className:`${c.text} text-white`,children:[n("streamOverlay.eta")," ",DF(u.remaining_time,f,n)]})]})]})]}),!x&&a.jsx("div",{className:`${c.text} text-white/70 py-2`,children:u.connected?n("streamOverlay.printerIdle"):n("streamOverlay.printerOffline")})]})})]})}function PJe(){const{t}=Dt(),{id:e}=o0(),{mode:n}=ep(),{data:r,isLoading:i,error:s}=Je({queryKey:["external-link",e],queryFn:()=>ne.getExternalLink(Number(e)),enabled:!!e});return i?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s||!r?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[a.jsx(An,{className:"w-12 h-12"}),a.jsx("p",{children:t("common.linkNotFound")})]}):a.jsx("iframe",{src:r.url,className:"h-full w-full border-0",style:{colorScheme:n},title:r.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}function sK(){const{id:t}=o0(),e=nc(),n=Jt(),{t:r}=Dt(),{showToast:i}=ln(),s=!!t,[o,l]=w.useState(""),[c,d]=w.useState(""),[u,h]=w.useState([]),[f,p]=w.useState(""),[x,v]=w.useState(!1),{data:g,isLoading:y}=Je({queryKey:["group",t],queryFn:()=>ne.getGroup(Number(t)),enabled:s}),{data:_,isLoading:N}=Je({queryKey:["permissions"],queryFn:()=>ne.getPermissions()});s&&g&&!x&&(l(g.name),d(g.description||""),h(g.permissions),v(!0));const T=st({mutationFn:U=>ne.createGroup(U),onSuccess:()=>{n.invalidateQueries({queryKey:["groups"]}),i(r("groups.toast.created")),e("/settings?tab=users")},onError:U=>{i(U.message,"error")}}),k=st({mutationFn:U=>ne.updateGroup(Number(t),U),onSuccess:()=>{n.invalidateQueries({queryKey:["groups"]}),i(r("groups.toast.updated")),e("/settings?tab=users")},onError:U=>{i(U.message,"error")}}),M=T.isPending||k.isPending,C=()=>{if(!o.trim()){i(r("groups.toast.enterGroupName"),"error");return}s?k.mutate({name:o!==g?.name?o:void 0,description:c,permissions:u}):T.mutate({name:o,description:c||void 0,permissions:u})},j=U=>{h(W=>W.includes(U)?W.filter(Y=>Y!==U):[...W,U])},P=(U,W)=>{const Y=U.permissions.map(re=>re.value);h(re=>{const H=re.filter(K=>!Y.includes(K));return W?[...H,...Y]:H})},E=U=>U.permissions.every(W=>u.includes(W.value)),B=U=>{const W=U.permissions.filter(Y=>u.includes(Y.value)).length;return W>0&&W{_&&h(_.all_permissions)},z=()=>{h([])},D=f.toLowerCase(),$=w.useMemo(()=>_?D?_.categories.map(U=>({...U,permissions:U.permissions.filter(W=>W.label.toLowerCase().includes(D))})).filter(U=>U.permissions.length>0):_.categories:[],[_,D]),G=_?.all_permissions.length??0;return y||N?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:()=>e("/settings?tab=users"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",children:a.jsx(dY,{className:"w-5 h-5"})}),a.jsx("h1",{className:"text-xl font-bold text-white",children:r(s?"groups.editor.title":"groups.editor.createTitle")})]}),s&&g?.is_system&&a.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-lg bg-yellow-500/10 border border-yellow-500/20 text-yellow-400 text-sm",children:[a.jsx(An,{className:"w-4 h-4 shrink-0"}),r("groups.form.systemGroupWarning")]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:r("groups.form.groupName")}),a.jsx("input",{type:"text",value:o,onChange:U=>l(U.target.value),disabled:s&&g?.is_system,className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors disabled:opacity-50",placeholder:r("groups.form.groupNamePlaceholder")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:r("groups.form.description")}),a.jsx("input",{type:"text",value:c,onChange:U=>d(U.target.value),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:r("groups.form.descriptionPlaceholder")})]})]}),a.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("span",{className:"text-sm text-bambu-gray",children:[r("groups.editor.permissionsSelected",{count:u.length})," / ",G]}),a.jsx(Me,{size:"sm",variant:"ghost",onClick:O,children:r("groups.editor.selectAll")}),a.jsx(Me,{size:"sm",variant:"ghost",onClick:z,children:r("groups.editor.clearAll")})]}),a.jsxs("div",{className:"relative",children:[a.jsx(Mr,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray"}),a.jsx("input",{type:"text",value:f,onChange:U=>p(U.target.value),placeholder:r("groups.editor.search"),className:"pl-9 pr-4 py-2 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors w-64"})]})]}),$.length===0?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:r("groups.editor.noResults")}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:$.map(U=>{const W=_.categories.find(ee=>ee.name===U.name),Y=W.permissions.filter(ee=>u.includes(ee.value)).length,re=W.permissions.length,H=E(W),K=B(W);return a.jsxs(wt,{children:[a.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between px-4 py-3 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary rounded-t-xl",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("button",{type:"button",onClick:()=>P(W,!H),className:`w-5 h-5 rounded border flex items-center justify-center transition-colors shrink-0 ${H?"bg-bambu-green border-bambu-green":K?"bg-bambu-green/50 border-bambu-green":"border-bambu-gray hover:border-white"}`,children:[H&&a.jsx(Jr,{className:"w-3 h-3 text-white"}),K&&!H&&a.jsx(w1,{className:"w-3 h-3 text-white"})]}),a.jsx(l3,{className:"w-4 h-4 text-bambu-gray shrink-0"}),a.jsx("span",{className:"text-white font-medium text-sm",children:U.name})]}),a.jsxs("span",{className:"text-xs text-bambu-gray tabular-nums",children:[Y,"/",re]})]}),a.jsx("div",{className:"p-3 space-y-1",children:U.permissions.map(ee=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-secondary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:u.includes(ee.value),onChange:()=>j(ee.value),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark-secondary"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:ee.label})]},ee.value))})]},U.name)})}),a.jsx("div",{className:"h-16"}),a.jsxs("div",{className:"fixed bottom-0 left-0 right-0 z-20 px-6 py-3 bg-bambu-dark-secondary border-t border-bambu-dark-tertiary flex items-center justify-center gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>e("/settings?tab=users"),children:r("common.cancel")}),a.jsx(Me,{onClick:C,disabled:M||!o.trim(),children:M?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),r("common.saving")]}):a.jsxs(a.Fragment,{children:[a.jsx(bs,{className:"w-4 h-4"}),r("common.save")]})})]})]})}const oK={material:"",subtype:"",brand:"",color_name:"",rgba:"808080FF",label_weight:1e3,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:"",note:"",cost_per_kg:null};function EJe(t,e=!1){const n={};return e?(t.material||(n.material="Material is required"),{isValid:Object.keys(n).length===0,errors:n}):(t.slicer_filament||(n.slicer_filament="Slicer preset is required"),t.material||(n.material="Material is required"),t.brand||(n.brand="Brand is required"),t.subtype||(n.subtype="Subtype is required"),{isValid:Object.keys(n).length===0,errors:n})}const jJe=["PLA","PETG","ABS","TPU","ASA","PC","PA","PVA","HIPS","PA-CF","PETG-CF","PLA-CF"],DJe=["Bambu","PolyLite","PolyTerra","eSUN","Overture","Fiberon","SUNLU","Inland","Hatchbox","Generic"],dv=["Basic","Matte","Silk","Tough","HF","High Flow","Engineering","Galaxy","Glow","Marble","Metal","Rainbow","Sparkle","Wood","Translucent","Transparent","Clear","Lite","Pro","Plus","Max","Super","Ultra","Flex","Soft","Hard","Strong","Impact","Heat Resistant","UV Resistant","ESD","Conductive","Magnetic","Gradient","Dual Color","Tri Color","Multicolor"],Jie=[{name:"Black",hex:"000000"},{name:"White",hex:"FFFFFF"},{name:"Gray",hex:"808080"},{name:"Red",hex:"FF0000"},{name:"Orange",hex:"FFA500"},{name:"Yellow",hex:"FFFF00"},{name:"Green",hex:"00AE42"},{name:"Blue",hex:"0066FF"},{name:"Purple",hex:"8B00FF"},{name:"Pink",hex:"FF69B4"},{name:"Brown",hex:"8B4513"},{name:"Silver",hex:"C0C0C0"}],RJe=[{name:"Dark Red",hex:"8B0000"},{name:"Crimson",hex:"DC143C"},{name:"Coral",hex:"FF7F50"},{name:"Salmon",hex:"FA8072"},{name:"Dark Orange",hex:"FF8C00"},{name:"Peach",hex:"FFDAB9"},{name:"Gold",hex:"FFD700"},{name:"Khaki",hex:"F0E68C"},{name:"Lemon",hex:"FFF44F"},{name:"Lime",hex:"32CD32"},{name:"Forest Green",hex:"228B22"},{name:"Olive",hex:"808000"},{name:"Mint",hex:"98FF98"},{name:"Teal",hex:"008080"},{name:"Navy",hex:"000080"},{name:"Sky Blue",hex:"87CEEB"},{name:"Royal Blue",hex:"4169E1"},{name:"Cyan",hex:"00FFFF"},{name:"Turquoise",hex:"40E0D0"},{name:"Violet",hex:"EE82EE"},{name:"Magenta",hex:"FF00FF"},{name:"Indigo",hex:"4B0082"},{name:"Lavender",hex:"E6E6FA"},{name:"Plum",hex:"DDA0DD"},{name:"Hot Pink",hex:"FF69B4"},{name:"Rose",hex:"FF007F"},{name:"Blush",hex:"FFB6C1"},{name:"Chocolate",hex:"D2691E"},{name:"Tan",hex:"D2B48C"},{name:"Beige",hex:"F5F5DC"},{name:"Maroon",hex:"800000"},{name:"Dark Gray",hex:"404040"},{name:"Light Gray",hex:"D3D3D3"},{name:"Charcoal",hex:"36454F"},{name:"Ivory",hex:"FFFFF0"},{name:"Bambu Green",hex:"00AE42"},{name:"Jade White",hex:"E8E8E8"},{name:"Titan Gray",hex:"5A5A5A"}],lK=[...Jie,...RJe],ese="bambuddy-recent-colors",FJe=8,LJe=[{code:"GFL00",name:"Bambu PLA Basic",displayName:"Bambu PLA Basic",isCustom:!1,allCodes:["GFL00"]},{code:"GFL01",name:"Bambu PLA Matte",displayName:"Bambu PLA Matte",isCustom:!1,allCodes:["GFL01"]},{code:"GFL05",name:"Generic PLA",displayName:"Generic PLA",isCustom:!1,allCodes:["GFL05"]},{code:"GFG00",name:"Bambu PETG Basic",displayName:"Bambu PETG Basic",isCustom:!1,allCodes:["GFG00"]},{code:"GFG05",name:"Generic PETG",displayName:"Generic PETG",isCustom:!1,allCodes:["GFG05"]},{code:"GFB00",name:"Bambu ABS Basic",displayName:"Bambu ABS Basic",isCustom:!1,allCodes:["GFB00"]},{code:"GFB05",name:"Generic ABS",displayName:"Generic ABS",isCustom:!1,allCodes:["GFB05"]},{code:"GFA00",name:"Bambu ASA Basic",displayName:"Bambu ASA Basic",isCustom:!1,allCodes:["GFA00"]},{code:"GFU00",name:"Bambu TPU 95A",displayName:"Bambu TPU 95A",isCustom:!1,allCodes:["GFU00"]},{code:"GFU05",name:"Generic TPU",displayName:"Generic TPU",isCustom:!1,allCodes:["GFU05"]},{code:"GFC00",name:"Bambu PC Basic",displayName:"Bambu PC Basic",isCustom:!1,allCodes:["GFC00"]},{code:"GFN00",name:"Bambu PA Basic",displayName:"Bambu PA Basic",isCustom:!1,allCodes:["GFN00"]},{code:"GFN05",name:"Generic PA",displayName:"Generic PA",isCustom:!1,allCodes:["GFN05"]},{code:"GFS00",name:"Bambu PLA-CF",displayName:"Bambu PLA-CF",isCustom:!1,allCodes:["GFS00"]},{code:"GFT00",name:"Bambu PETG-CF",displayName:"Bambu PETG-CF",isCustom:!1,allCodes:["GFT00"]},{code:"GFNC0",name:"Bambu PA-CF",displayName:"Bambu PA-CF",isCustom:!1,allCodes:["GFNC0"]},{code:"GFV00",name:"Bambu PVA",displayName:"Bambu PVA",isCustom:!1,allCodes:["GFV00"]}];function Ob(t){let e=t.replace(/@.*$/,"").trim();e=e.replace(/\(Custom\)/i,"").trim(),e=e.replace(/^[#*]+\s*/,"").trim();const n=["PLA-CF","PETG-CF","ABS-GF","ASA-CF","PA-CF","PAHT-CF","PA6-CF","PA6-GF","PPA-CF","PPA-GF","PET-CF","PPS-CF","PC-CF","PC-ABS","ABS-GF","PCTG","PETG","PLA","ABS","ASA","PC","PA","TPU","PVA","HIPS","BVOH","PPS","PEEK","PEI"];let r="",i=-1;for(const c of n){const d=e.toUpperCase().indexOf(c.toUpperCase());if(d!==-1){r=c,i=d;break}}let s="";i>0&&(s=e.substring(0,i).trim(),s=s.replace(/[-_\s]+$/,""));let o="";i!==-1&&r&&(o=e.substring(i+r.length).trim(),o=o.replace(/^[-_\s]+/,""));let l="";for(const c of dv)if(o.toLowerCase().includes(c.toLowerCase())){l=c;break}if(!l&&s)for(const c of dv){const d=new RegExp(`\\s+${c}$`,"i");if(d.test(s)){l=c,s=s.replace(d,"").trim();break}}return{brand:s,material:r,variant:l}}function OJe(t,e){const n=new Set(DJe);for(const r of t){const{brand:i}=Ob(r.name);i&&i.length>1&&n.add(i)}if(e)for(const r of e)if(r.filament_vendor&&r.filament_vendor.length>1)n.add(r.filament_vendor);else{const{brand:i}=Ob(r.name);i&&i.length>1&&n.add(i)}return Array.from(n).sort((r,i)=>r.localeCompare(i))}function IJe(t){const e=t.filter(r=>r.preset_type==="filament");if(e.length===0)return[];const n=new Map;for(const r of e){const i=r.name.replace(/@.*$/,"").trim(),s=n.get(i);if(s)s.allCodes.push(String(r.id));else{const o=r.filament_type||String(r.id);n.set(i,{code:o,name:i,displayName:i,isCustom:!1,allCodes:[o]})}}return Array.from(n.values()).sort((r,i)=>r.displayName.localeCompare(i.displayName))}function zJe(t,e,n){if(t.length>0){const r=[],i=new Map;for(const s of t)if(s.is_custom){const o=s.name.toUpperCase();(e.size===0||Array.from(e).some(c=>o.includes(c))||!o.includes("@"))&&r.push({code:s.setting_id,name:s.name,displayName:`${s.name} (Custom)`,isCustom:!0,allCodes:[s.setting_id]})}else{const o=s.name.replace(/@.*$/,"").trim(),l=i.get(o);l?l.allCodes.push(s.setting_id):i.set(o,{code:s.setting_id,name:o,displayName:o,isCustom:!1,allCodes:[s.setting_id]})}return[...r,...Array.from(i.values())].sort((s,o)=>s.displayName.localeCompare(o.displayName))}if(n&&n.length>0){const r=IJe(n);if(r.length>0)return r}return LJe}function UJe(t,e){if(!t)return;let n=e.find(r=>r.code===t);if(n||(n=e.find(r=>r.allCodes.includes(t))),!n){const r=t.toLowerCase();n=e.find(i=>i.code.toLowerCase()===r||i.allCodes.some(s=>s.toLowerCase()===r))}return n}function BJe(){try{const t=localStorage.getItem(ese);if(t)return JSON.parse(t)}catch{}return[]}function HJe(t,e){const n=e.filter(i=>i.hex.toUpperCase()!==t.hex.toUpperCase()),r=[t,...n].slice(0,FJe);try{localStorage.setItem(ese,JSON.stringify(r))}catch{}return r}function Fj(t,e){if(!e.material)return!1;const r=(t.name||"").replace(/^High Flow[_\s]+/i,"").replace(/^Standard[_\s]+/i,"").replace(/^HF[_\s]+/i,"").replace(/^S[_\s]+/i,"").trim(),i=Ob(r);return!(!(i.material.toUpperCase()===e.material.toUpperCase())||e.brand&&!(i.brand.toLowerCase().includes(e.brand.toLowerCase())||e.brand.toLowerCase().includes(i.brand.toLowerCase()))||e.subtype&&!(i.variant.toLowerCase().includes(e.subtype.toLowerCase())||e.subtype.toLowerCase().includes(i.variant.toLowerCase())||r.toLowerCase().includes(e.subtype.toLowerCase())))}function $Je({formData:t,updateField:e,cloudAuthenticated:n,loadingCloudPresets:r,presetInputValue:i,setPresetInputValue:s,selectedPresetOption:o,filamentOptions:l,availableBrands:c,availableMaterials:d,quickAdd:u,quantity:h,onQuantityChange:f,errors:p}){const{t:x}=Dt(),[v,g]=w.useState(!1),[y,_]=w.useState(!1),[N,T]=w.useState(!1),[k,M]=w.useState(!1),[C,j]=w.useState(""),[P,E]=w.useState(""),[B,O]=w.useState(""),[z,D]=w.useState(String(t.label_weight)),[$,G]=w.useState(!1),U=w.useRef(null),W=w.useRef(null),Y=w.useRef(null),re=w.useRef(null);w.useEffect(()=>{const oe=J=>{U.current&&!U.current.contains(J.target)&&g(!1),re.current&&!re.current.contains(J.target)&&M(!1),W.current&&!W.current.contains(J.target)&&_(!1),Y.current&&!Y.current.contains(J.target)&&T(!1)};return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[]);const H=w.useMemo(()=>{if(!i)return l;const oe=i.toLowerCase();return l.filter(J=>J.displayName.toLowerCase().includes(oe)||J.code.toLowerCase().includes(oe))},[l,i]),K=w.useMemo(()=>{if(!C)return c;const oe=C.toLowerCase();return c.filter(je=>je.toLowerCase().includes(oe)).sort((je,de)=>{const le=je.toLowerCase()===oe,_e=de.toLowerCase()===oe;return le&&!_e?-1:!le&&_e?1:je.localeCompare(de)})},[c,C]),ee=w.useMemo(()=>{if(!P)return dv;const oe=P.toLowerCase();return dv.filter(J=>J.toLowerCase().includes(oe))},[P]),Z=w.useMemo(()=>{if(!B)return d;const oe=B.toLowerCase();return d.filter(je=>je.toLowerCase().includes(oe)).sort((je,de)=>{const le=je.toLowerCase()===oe,_e=de.toLowerCase()===oe;return le&&!_e?-1:!le&&_e?1:je.localeCompare(de)})},[B,d]);w.useEffect(()=>{$||D(String(t.label_weight))},[t.label_weight,$]);const we=oe=>{e("slicer_filament",oe.code),s(oe.displayName),g(!1);const J=Ob(oe.name);J.material&&e("material",J.material),J.brand&&e("brand",J.brand),J.variant&&e("subtype",J.variant)};return a.jsxs("div",{className:"space-y-4",children:[!u&&a.jsx("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:r?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-3 h-3 animate-spin"})," ",x("inventory.loadingPresets")]}):n?a.jsxs(a.Fragment,{children:[a.jsx(Hb,{className:"w-3 h-3 text-bambu-green"})," ",x("inventory.cloudConnected")]}):a.jsxs(a.Fragment,{children:[a.jsx(Phe,{className:"w-3 h-3"})," ",x("inventory.cloudNotConnected")]})}),!u&&a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[x("inventory.slicerPreset")," *"]}),a.jsxs("div",{className:"relative",ref:U,children:[a.jsx(Mr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),a.jsx("input",{type:"text",className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:x("inventory.searchPresets"),value:i,onChange:oe=>{s(oe.target.value),g(!0)},onFocus:()=>{g(!0),s("")}}),v&&a.jsx("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto",children:H.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:x("inventory.noPresetsFound")}):H.map(oe=>a.jsxs("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex justify-between items-center ${o?.code===oe.code?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>we(oe),children:[a.jsx("span",{className:"truncate",children:oe.displayName}),a.jsx("span",{className:"font-mono text-xs text-bambu-gray ml-2 shrink-0",children:oe.code})]},oe.code))})]}),o&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray",children:[x("inventory.selectedPreset"),": ",a.jsx("span",{className:"font-mono text-bambu-green",children:o.code})]}),p?.slicer_filament&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:p.slicer_filament})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[x("inventory.material")," *"]}),a.jsxs("div",{className:"relative",ref:re,children:[a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:x("inventory.selectMaterial"),value:k?B:t.material,onChange:oe=>{O(oe.target.value),M(!0)},onFocus:()=>{M(!0),O("")}}),a.jsx(Pn,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),k&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[Z.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:x("inventory.noResults")}):Z.map(oe=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.material===oe?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("material",oe),M(!1),O("")},children:oe},oe)),B&&!Z.includes(B)&&a.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary",onClick:()=>{e("material",B),M(!1),O("")},children:x("inventory.useCustomMaterial",{material:B})})]})]}),p?.material&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:p.material})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[x("inventory.brand"),!u&&" *"]}),a.jsxs("div",{className:"relative",ref:W,children:[a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:x("inventory.searchBrand"),value:y?C:t.brand,onChange:oe=>{j(oe.target.value),_(!0)},onFocus:()=>{_(!0),j("")}}),a.jsx(Pn,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),y&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[K.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:x("inventory.noResults")}):K.map(oe=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.brand===oe?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("brand",oe),_(!1),j("")},children:oe},oe)),C&&!K.includes(C)&&a.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary",onClick:()=>{e("brand",C),_(!1),j("")},children:x("inventory.useCustomBrand",{brand:C})})]})]}),p?.brand&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:p.brand})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[x("inventory.subtype"),!u&&" *"]}),a.jsxs("div",{className:"relative",ref:Y,children:[a.jsx("input",{type:"text",value:N?P:t.subtype,onChange:oe=>{E(oe.target.value),T(!0)},onFocus:()=>{T(!0),E("")},placeholder:"Basic, Matte, Silk...",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green"}),a.jsx(Pn,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),N&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[ee.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:x("inventory.noResults")}):ee.map(oe=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.subtype===oe?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("subtype",oe),T(!1),E("")},children:oe},oe)),P&&!dv.some(oe=>oe.toLowerCase()===P.toLowerCase().trim())&&a.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary",onClick:()=>{e("subtype",P),T(!1),E("")},children:x("inventory.useCustomBrand",{brand:P})})]})]}),p?.subtype&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:p.subtype})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:x("inventory.labelWeight")}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"number",className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green",value:z,min:0,onFocus:()=>G(!0),onChange:oe=>D(oe.target.value),onBlur:()=>{G(!1);const oe=z.trim(),J=Number(oe);if(!oe||!Number.isFinite(J)||J<0){D(String(t.label_weight));return}const je=Math.round(J);e("label_weight",je),D(String(je))}}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]})]}),u&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:x("inventory.quantity")}),a.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green",value:h,min:1,max:100,onChange:oe=>{const J=Math.max(1,Math.min(100,parseInt(oe.target.value)||1));f(J)}})]})]})}function VJe({formData:t,updateField:e,recentColors:n,onColorUsed:r,catalogColors:i}){const{t:s}=Dt(),[o,l]=w.useState(!1),[c,d]=w.useState(""),u=t.rgba.replace("#","").substring(0,6),h=y=>u.toUpperCase()===y.toUpperCase(),f=(y,_)=>{e("rgba",y.toUpperCase()+"FF"),e("color_name",_),r({name:_,hex:y})},p=w.useMemo(()=>{if(i.length===0)return[];const y=t.brand?.trim(),_=t.material?.toLowerCase().trim(),N=t.subtype?.toLowerCase().trim();if(!y&&!_)return[];const T=y?y.toLowerCase().split(/[\s\-_]+/).filter(C=>C.length>=2):[],k=C=>{if(T.length===0)return!0;const j=C.toLowerCase();return T.some(P=>j.includes(P))};if(y&&!_){const C=i.filter(j=>k(j.manufacturer));if(C.length>0)return C.map(j=>({name:j.color_name,hex:j.hex_color.replace("#","").substring(0,6),manufacturer:j.manufacturer,material:typeof j.material=="string"?j.material:void 0}))}const M=_&&N?`${_} ${N}`:"";if(M){const C=i.filter(P=>k(P.manufacturer)&&P.material?.toLowerCase()===M);if(C.length>0)return C.map(P=>({name:P.color_name,hex:P.hex_color.replace("#","").substring(0,6),manufacturer:P.manufacturer,material:typeof P.material=="string"?P.material:void 0}));const j=M.replace(/\+$/,"");if(j!==M){const P=i.filter(E=>k(E.manufacturer)&&E.material?.toLowerCase()===j);if(P.length>0)return P.map(E=>({name:E.color_name,hex:E.hex_color.replace("#","").substring(0,6),manufacturer:E.manufacturer,material:typeof E.material=="string"?E.material:void 0}))}}if(_){const C=i.filter(j=>k(j.manufacturer)&&(!j.material||j.material.toLowerCase().startsWith(_)));if(C.length>0)return C.map(j=>({name:j.color_name,hex:j.hex_color.replace("#","").substring(0,6),manufacturer:j.manufacturer,material:typeof j.material=="string"?j.material:void 0}))}return[]},[i,t.brand,t.material,t.subtype]),x=w.useMemo(()=>{if(!c)return p;if(p.length===0)return[];const y=c.toLowerCase();return p.filter(N=>N.name.toLowerCase().includes(y)||(N.manufacturer?.toLowerCase().includes(y)??!1)||(N.material?.toLowerCase().includes(y)??!1))},[c,p]),v=p.length>0,g=w.useMemo(()=>c?lK.filter(y=>y.name.toLowerCase().includes(c.toLowerCase())):o?lK:Jie,[c,o]);return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"h-10 rounded-lg border border-bambu-dark-tertiary",style:{backgroundColor:`#${u}`}}),n.length>0&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-bambu-gray shrink-0",children:[a.jsx(Vn,{className:"w-3 h-3"}),a.jsx("span",{children:s("inventory.recentColors")})]}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.map(y=>a.jsx("button",{type:"button",onClick:()=>f(y.hex,y.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 ${h(y.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${y.hex}`},title:y.name},y.hex))})]}),a.jsxs("div",{className:"relative",children:[a.jsx(Mr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),a.jsx("input",{type:"text",className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.searchColors"),value:c,onChange:y=>d(y.target.value)})]}),v?a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:c?s("inventory.searchResults"):`${t.brand}${t.material?` ${t.material}`:""}`}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[x.map(y=>a.jsx("button",{type:"button",onClick:()=>f(y.hex,y.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${h(y.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${y.hex}`},title:y.manufacturer&&y.material?`${y.name} (${y.manufacturer} — ${y.material})`:y.manufacturer?`${y.name} (${y.manufacturer})`:y.name,children:a.jsx("span",{className:"absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white",children:y.manufacturer&&y.material?`${y.name} (${y.manufacturer} — ${y.material})`:y.manufacturer?`${y.name} (${y.manufacturer})`:y.name})},`${y.hex}-${y.name}-${y.manufacturer??""}`)),x.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray py-1",children:s("inventory.noColorsFound")})]})]}):a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray",children:[a.jsx("span",{children:s(c?"inventory.searchResults":o?"inventory.allColors":"inventory.commonColors")}),!c&&a.jsx("button",{type:"button",onClick:()=>l(!o),className:"flex items-center gap-1 hover:text-white transition-colors",children:o?a.jsxs(a.Fragment,{children:[s("inventory.showLess")," ",a.jsx(yl,{className:"w-3 h-3"})]}):a.jsxs(a.Fragment,{children:[s("inventory.showAll")," ",a.jsx(Pn,{className:"w-3 h-3"})]})})]}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[g.map(y=>a.jsx("button",{type:"button",onClick:()=>f(y.hex,y.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${h(y.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${y.hex}`},title:y.name,children:a.jsx("span",{className:"absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white",children:y.name})},y.hex)),g.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray py-1",children:s("inventory.noColorsFound")})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:s("inventory.colorName")}),a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.colorNamePlaceholder"),value:t.color_name,onChange:y=>e("color_name",y.target.value)})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:s("inventory.hexColor")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray",children:"#"}),a.jsx("input",{type:"text",className:"w-full pl-7 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono uppercase focus:outline-none focus:border-bambu-green",placeholder:"RRGGBB",value:u.toUpperCase(),onChange:y=>{const _=y.target.value.replace("#","").replace(/[^0-9A-Fa-f]/g,"");_.length<=8&&e("rgba",_.toUpperCase()+(_.length<=6?"FF":""))}})]}),a.jsx("input",{type:"color",className:"w-11 h-[38px] rounded-lg cursor-pointer border border-bambu-dark-tertiary shrink-0 bg-transparent",value:`#${u}`,onChange:y=>{const _=y.target.value.replace("#","").toUpperCase();e("rgba",_+"FF")},title:s("inventory.pickColor")})]})]})]})]})}function qJe({catalog:t,value:e,onChange:n,catalogId:r,onCatalogIdChange:i}){const{t:s}=Dt(),[o,l]=w.useState(!1),[c,d]=w.useState(""),u=w.useRef(null),h=w.useRef(null);w.useEffect(()=>{const v=g=>{u.current&&!u.current.contains(g.target)&&l(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]),w.useEffect(()=>{if(t.length===0)return;const v=t.filter(g=>g.weight===e);if(r){const g=t.find(y=>y.id===r);if(g&&g.weight===e)return}v.length===1?i(v[0].id):v.length===0&&r!==null&&i(null)},[e,t,r,i]);const f=w.useMemo(()=>{if(!c)return t;const v=c.toLowerCase();return t.filter(g=>g.name.toLowerCase().includes(v)||g.weight.toString().includes(v))},[t,c]),p=w.useMemo(()=>t.filter(v=>v.weight===e),[t,e]),x=w.useMemo(()=>{if(o)return c;if(r){const v=t.find(g=>g.id===r);if(v)return v.name}return p.length>0?p[0].name:""},[o,c,r,t,p]);return a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(epe,{className:"w-3.5 h-3.5 text-bambu-gray"}),s("inventory.coreWeight")]})}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsxs("div",{className:"flex-1 min-w-0 relative",ref:u,children:[a.jsx("input",{ref:h,type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.searchSpoolWeight"),value:x,onFocus:()=>{l(!0),d("")},onChange:v=>{d(v.target.value),l(!0)}}),o&&a.jsx("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto",children:f.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:s("inventory.noResults")}):f.map(v=>a.jsxs("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex justify-between items-center ${(r?v.id===r:v.weight===e)?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{i(v.id),n(v.weight),l(!1),d("")},children:[a.jsx("span",{className:"truncate",children:v.name}),a.jsxs("span",{className:"font-mono text-xs text-bambu-gray ml-2 shrink-0",children:[v.weight,"g"]})]},v.id))})]}),a.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[a.jsx("input",{type:"number",className:"w-16 px-2 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm text-center font-mono focus:outline-none focus:border-bambu-green",value:e,min:0,max:2e3,onChange:v=>{const g=parseInt(v.target.value);!isNaN(g)&&g>=0&&n(g)}}),a.jsx("span",{className:"text-bambu-gray text-sm",children:"g"})]})]})]})}function GJe({formData:t,updateField:e,spoolCatalog:n,currencySymbol:r}){const{t:i}=Dt(),{showToast:s}=ln(),[o,l]=w.useState(""),[c,d]=w.useState(!1),[u,h]=w.useState(""),[f,p]=w.useState(!1),x=Math.max(0,t.label_weight-t.weight_used),v=t.core_weight+x;return w.useEffect(()=>{c||l(String(v))},[c,v]),w.useEffect(()=>{f||h(String(x))},[f,x]),a.jsxs("div",{className:"space-y-4",children:[a.jsx(qJe,{catalog:n,value:t.core_weight,onChange:g=>e("core_weight",g),catalogId:t.core_weight_catalog_id,onCatalogIdChange:g=>e("core_weight_catalog_id",g)}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:i("inventory.currentWeight")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:"number",value:u,min:0,max:t.label_weight,onFocus:()=>p(!0),onChange:g=>{h(g.target.value)},onBlur:()=>{p(!1);const g=u.trim(),y=Number(g);if(!g||!Number.isFinite(y)||y<0||y>t.label_weight){h(String(x));return}const _=Math.round(y);e("weight_used",Math.max(0,t.label_weight-_)),h(String(_))},className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]}),a.jsxs("span",{className:"text-xs text-bambu-gray shrink-0",children:["/ ",t.label_weight,"g"]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:i("inventory.measuredWeight")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:"number",value:o,min:0,onFocus:()=>d(!0),onChange:g=>{l(g.target.value)},onBlur:()=>{d(!1);const g=o.trim(),y=Number(g),_=t.core_weight,N=t.core_weight+t.label_weight;if(!g||!Number.isFinite(y)||y<_||y>N){s(i("inventory.measuredWeightError",{min:_,max:N}),"error"),l(String(v));return}const T=Math.round(y),k=Math.max(0,Math.min(t.label_weight,T-t.core_weight));e("weight_used",Math.max(0,t.label_weight-k)),l(String(T))},className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]}),a.jsxs("span",{className:"text-xs text-bambu-gray shrink-0",children:["/ ",t.core_weight+t.label_weight,"g"]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:i("inventory.costPerKg","Cost per kg")}),a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none",children:r}),a.jsx("input",{type:"number",value:t.cost_per_kg??"",min:0,step:.01,placeholder:"0.00",onChange:g=>{const y=g.target.value===""?null:parseFloat(g.target.value);e("cost_per_kg",y)},style:{paddingLeft:`${Math.max(2,r.length*.6+1)}rem`},className:"w-full py-2 pr-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"})]})})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:i("inventory.note")}),a.jsx("textarea",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green resize-none min-h-[80px]",placeholder:i("inventory.notePlaceholder"),value:t.note,onChange:g=>e("note",g.target.value)})]})]})}function WJe({formData:t,printersWithCalibrations:e,selectedProfiles:n,setSelectedProfiles:r,expandedPrinters:i,setExpandedPrinters:s}){const{t:o}=Dt(),l=f=>{s(p=>{const x=new Set(p);return x.has(f)?x.delete(f):x.add(f),x})},c=(f,p,x)=>{const v=`${f}:${p}:${x??"null"}`,g=`${f}:${x??"null"}`;r(y=>{const _=new Set(y);if(_.has(v))_.delete(v);else{for(const N of Array.from(_)){const T=N.split(":");`${T[0]}:${T[2]}`===g&&_.delete(N)}_.add(v)}return _})},d=()=>{const f=new Set;for(const{printer:p,calibrations:x}of e){if(!p.connected)continue;const v=x.filter(y=>Fj(y,t)),g=new Map;for(const y of v){const _=`${y.extruder_id??"null"}`;g.has(_)||g.set(_,[]),g.get(_).push(y)}for(const[y,_]of g)if(_.length>0){const T=[..._].sort((k,M)=>M.k_value-k.k_value)[0];f.add(`${p.id}:${T.cali_idx}:${y}`)}}r(f)};if(!t.material)return a.jsx("div",{className:"p-6 bg-bambu-dark rounded-lg text-center",children:a.jsx("p",{className:"text-bambu-gray",children:o("inventory.selectMaterialFirst")})});if(e.length===0)return a.jsx("div",{className:"p-6 bg-bambu-dark rounded-lg text-center",children:a.jsx("p",{className:"text-bambu-gray",children:o("inventory.noPrintersConfigured")})});const u=e.reduce((f,{printer:p,calibrations:x})=>p.connected?f+x.filter(v=>Fj(v,t)).length:f,0),h=(f,p)=>{const x=`${f.id}:${p.cali_idx}:${p.extruder_id??"null"}`,v=n.has(x);return a.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-all border ${v?"bg-bambu-green/10 border-bambu-green/30":"bg-bambu-dark border-transparent hover:bg-bambu-dark/80"}`,children:[a.jsx("input",{type:"checkbox",checked:v,onChange:()=>c(String(f.id),p.cali_idx,p.extruder_id),className:"w-4 h-4 rounded border-bambu-dark-tertiary text-bambu-green focus:ring-bambu-green"}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("span",{className:`text-sm font-medium ${v?"text-bambu-green":"text-white"}`,children:p.name||p.filament_id})}),a.jsx("div",{className:"flex items-center gap-2 shrink-0",children:a.jsxs("span",{className:"text-xs font-mono px-2 py-0.5 rounded bg-bambu-dark text-bambu-gray",children:["K=",p.k_value.toFixed(3)]})})]},`${p.cali_idx}-${p.extruder_id}`)};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("p",{className:"text-xs text-bambu-gray",children:[o("inventory.matchingFilter"),": ",t.brand||o("inventory.anyBrand")," / ",t.material," / ",t.subtype||o("inventory.anyVariant")]}),u>0&&a.jsxs("button",{type:"button",onClick:d,className:"flex items-center gap-1.5 px-2 py-1 text-xs bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white hover:border-bambu-green transition-colors",children:[a.jsx(ub,{className:"w-3.5 h-3.5"}),o("inventory.autoSelect")," (",u,")"]})]}),a.jsx("div",{className:"space-y-3",children:e.map(({printer:f,calibrations:p})=>{const x=i.has(String(f.id)),v=p.filter(T=>Fj(T,t)),g=v.length,y=v.some(T=>T.extruder_id!==void 0&&T.extruder_id!==null&&T.extruder_id>0),_=v.filter(T=>T.extruder_id===1),N=v.filter(T=>T.extruder_id===0||T.extruder_id===void 0||T.extruder_id===null);return a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{type:"button",onClick:()=>l(String(f.id)),className:"w-full px-4 py-3 flex items-center justify-between bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[x?a.jsx(Pn,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(yi,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"font-medium text-white",children:f.name}),g>0?a.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:[g," ",o(g!==1?"inventory.matches":"inventory.match")]}):a.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray",children:o("inventory.noMatches")})]}),a.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${f.connected?"bg-green-500/20 text-green-500":"bg-bambu-gray/20 text-bambu-gray"}`,children:f.connected?o("inventory.connected"):o("inventory.offline")})]}),x&&a.jsx("div",{className:"px-4 py-3 space-y-3 bg-bambu-dark border-t border-bambu-dark-tertiary",children:f.connected?g===0?a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:o("inventory.noKProfilesMatch")}):y?a.jsxs(a.Fragment,{children:[_.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wide",children:o("inventory.leftNozzle")}),a.jsx("div",{className:"space-y-2",children:_.map(T=>h(f,T))})]}),N.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wide",children:o("inventory.rightNozzle")}),a.jsx("div",{className:"space-y-2",children:N.map(T=>h(f,T))})]})]}):a.jsx("div",{className:"space-y-2",children:v.map(T=>h(f,T))}):a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:o("inventory.printerOffline")})})]},f.id)})}),n.size>0&&a.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[a.jsx("span",{className:"font-semibold",children:n.size})," ",o("inventory.profilesSelected")]})})]})}function KJe(t){const e=new Date(t);return e.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"})+" "+e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})}const YJe={completed:"text-bambu-green",failed:"text-red-400",aborted:"text-yellow-400"};function XJe({spoolId:t}){const{t:e}=Dt(),n=Jt(),{showToast:r}=ln(),{data:i,isLoading:s}=Je({queryKey:["spool-usage",t],queryFn:()=>ne.getSpoolUsageHistory(t)}),o=st({mutationFn:()=>ne.clearSpoolUsageHistory(t),onSuccess:()=>{n.invalidateQueries({queryKey:["spool-usage",t]}),r(e("inventory.historyCleared"),"success")}});return s?a.jsx("div",{className:"flex justify-center py-4",children:a.jsx(at,{className:"w-5 h-5 animate-spin text-bambu-green"})}):!i||i.length===0?a.jsxs("div",{className:"text-center py-4 text-bambu-gray text-sm",children:[a.jsx(Vn,{className:"w-5 h-5 mx-auto mb-2 opacity-50"}),e("inventory.noUsageHistory")]}):a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:e("inventory.usageHistory")}),a.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>o.mutate(),disabled:o.isPending,className:"text-xs text-bambu-gray hover:text-red-400",children:[a.jsx(Xt,{className:"w-3 h-3 mr-1"}),e("inventory.clearHistory")]})]}),a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:i.map(l=>a.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-bambu-dark/50 text-xs",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:"text-bambu-gray",children:KJe(l.created_at)}),l.print_name&&a.jsx("span",{className:"text-white ml-2 truncate",title:l.print_name,children:l.print_name})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-2",children:[a.jsxs("span",{className:"text-white font-medium",children:[l.weight_used.toFixed(1),"g"]}),a.jsxs("span",{className:"text-bambu-gray",children:["(",l.percent_used,"%)"]}),a.jsx("span",{className:YJe[l.status]||"text-bambu-gray",children:l.status})]})]},l.id))})]})}function QJe({isOpen:t,onClose:e,spool:n,printersWithCalibrations:r=[],currencySymbol:i}){const{t:s}=Dt(),o=Jt(),{showToast:l}=ln(),c=!!n,[d,u]=w.useState(oK),[h,f]=w.useState({}),[p,x]=w.useState("filament"),[v,g]=w.useState(!1),[y,_]=w.useState(!1),[N,T]=w.useState(1),[k,M]=w.useState(!1),[C,j]=w.useState(!1),[P,E]=w.useState([]),[B,O]=w.useState(""),[z,D]=w.useState([]),[$,G]=w.useState([]),[U,W]=w.useState([]),[Y,re]=w.useState([]),[H,K]=w.useState([]),[ee,Z]=w.useState(new Set),[we,oe]=w.useState(new Set),J=r.length>0?r:H,je=w.useMemo(()=>ee.size,[ee]);w.useEffect(()=>{re(BJe())},[]),w.useEffect(()=>{t&&((async()=>{j(!0);try{const pe=await ne.getCloudStatus();if(M(pe.is_authenticated),pe.is_authenticated){const te=await ne.getFilamentPresets();E(te)}}catch(pe){console.error("Failed to fetch cloud presets:",pe),M(!1)}finally{j(!1)}})(),ne.getSpoolCatalog().then(D).catch(console.error),ne.getColorCatalog().then(W).catch(console.error),ne.getLocalPresets().then(pe=>G(pe.filament)).catch(console.error),r.length===0&&(async()=>{try{const pe=await ne.getPrinters(),te=await Promise.all(pe.map(Ie=>ne.getPrinterStatus(Ie.id).catch(()=>null))),Be=[];for(let Ie=0;Ie({cali_idx:ye.slot_id,filament_id:ye.filament_id,setting_id:ye.setting_id||"",name:ye.name,k_value:parseFloat(ye.k_value)||0,n_coef:parseFloat(ye.n_coef)||0,extruder_id:ye.extruder_id,nozzle_diameter:ye.nozzle_diameter}))}catch{}Be.push({printer:{...$e,connected:fe},calibrations:xe})}K(Be)}catch(pe){console.error("Failed to fetch printer calibrations:",pe)}})())},[t,r.length]);const de=w.useMemo(()=>zJe(P,new Set,$),[P,$]),le=w.useMemo(()=>{const ce=OJe(P,$),pe=U.map(Be=>Be.manufacturer?.trim()).filter(Be=>!!Be),te=new Set([...ce,...pe]);return Array.from(te).sort((Be,Ie)=>Be.localeCompare(Ie))},[P,$,U]),_e=w.useMemo(()=>{const ce=U.map(te=>te.material?.trim()).filter(te=>!!te),pe=new Set([...jJe,...ce]);return Array.from(pe).sort((te,Be)=>te.localeCompare(Be))},[U]),se=w.useMemo(()=>{const ce=[];for(const pe of U){const te=pe.manufacturer?.trim(),Be=pe.material?.trim();te&&Be&&ce.push({brand:te,material:Be})}for(const pe of P){const te=Ob(pe.name);te.brand&&te.material&&ce.push({brand:te.brand,material:te.material})}for(const pe of $){const te=Ob(pe.name),Be=pe.filament_vendor?.trim()||te.brand,Ie=te.material;Be&&Ie&&ce.push({brand:Be,material:Ie})}return ce},[P,U,$]),ze=w.useMemo(()=>{const ce=new Map;for(const pe of se){const te=pe.brand.toLowerCase(),Be=pe.material.toLowerCase();ce.has(te)||ce.set(te,new Set),ce.get(te).add(Be)}return ce},[se]),V=w.useMemo(()=>{const ce=new Map;for(const pe of se){const te=pe.brand.toLowerCase(),Be=pe.material.toLowerCase();ce.has(Be)||ce.set(Be,new Set),ce.get(Be).add(te)}return ce},[se]),X=w.useMemo(()=>{if(!d.material)return le;const ce=d.material.toLowerCase(),pe=V.get(ce);return!pe||pe.size===0?le:le.filter(te=>pe.has(te.toLowerCase()))},[le,d.material,V]),me=w.useMemo(()=>{if(!d.brand)return _e;const ce=d.brand.toLowerCase(),pe=ze.get(ce);return!pe||pe.size===0?_e:_e.filter(te=>pe.has(te.toLowerCase()))},[_e,d.brand,ze]),Q=w.useMemo(()=>UJe(d.slicer_filament,de),[d.slicer_filament,de]);w.useEffect(()=>{if(t){if(n)if(u({material:n.material||"",subtype:n.subtype||"",brand:n.brand||"",color_name:n.color_name||"",rgba:n.rgba||"808080FF",label_weight:n.label_weight||1e3,core_weight:n.core_weight||250,core_weight_catalog_id:n.core_weight_catalog_id??null,weight_used:n.weight_used||0,slicer_filament:n.slicer_filament||"",note:n.note||"",cost_per_kg:n.cost_per_kg??null}),O(n.slicer_filament_name||n.slicer_filament||""),n.k_profiles&&n.k_profiles.length>0){const ce=new Set;for(const pe of n.k_profiles)pe.cali_idx!==null&&pe.cali_idx!==void 0&&ce.add(`${pe.printer_id}:${pe.cali_idx}:${pe.extruder??"null"}`);Z(ce)}else Z(new Set);else u(oK),O(""),Z(new Set),_(!1),T(1);f({}),x("filament"),g(!1)}},[t,n]),w.useEffect(()=>{t&&J.length>0&&oe(new Set(J.map(ce=>String(ce.printer.id))))},[t,J]);const ie=(ce,pe)=>{u(te=>({...te,[ce]:pe})),ce==="weight_used"&&g(!0),h[ce]&&f(te=>({...te,[ce]:void 0}))},ue=ce=>{re(pe=>HJe(ce,pe))},Le=st({mutationFn:ce=>ne.createSpool(ce),onSuccess:async ce=>{ee.size>0&&ce?.id&&await L(ce.id),await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolCreated"),"success"),e()},onError:ce=>{l(ce.message,"error")}}),Ce=st({mutationFn:({data:ce,qty:pe})=>ne.bulkCreateSpools(ce,pe),onSuccess:async ce=>{if(ee.size>0)for(const pe of ce)await L(pe.id);await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolsCreated",{count:ce.length}),"success"),e()},onError:ce=>{l(ce.message,"error")}}),ge=st({mutationFn:ce=>ne.updateSpool(n.id,ce),onSuccess:async()=>{n?.id&&await L(n.id),await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolUpdated"),"success"),e()},onError:ce=>{l(ce.message,"error")}}),L=async ce=>{if(ee.size===0){try{await ne.saveSpoolKProfiles(ce,[])}catch{}return}const pe=[];for(const te of ee){const[Be,Ie,$e]=te.split(":"),Re=parseInt(Be),fe=parseInt(Ie),xe=$e==="null"?0:parseInt($e),Ne=J.find(ye=>ye.printer.id===Re);if(Ne){const ye=Ne.calibrations.find(ve=>ve.cali_idx===fe);ye&&pe.push({printer_id:Re,extruder:xe,nozzle_diameter:ye.nozzle_diameter||"0.4",k_value:ye.k_value,name:ye.name||null,cali_idx:ye.cali_idx,setting_id:ye.setting_id||null})}}if(pe.length>0)try{await ne.saveSpoolKProfiles(ce,pe)}catch(te){console.error("Failed to save K-profiles:",te)}};if(w.useEffect(()=>{if(!t)return;const ce=pe=>{pe.key==="Escape"&&e()};return document.addEventListener("keydown",ce),()=>document.removeEventListener("keydown",ce)},[t,e]),!t)return null;const R=()=>{const ce=EJe(d,y);if(!ce.isValid){f(ce.errors),(ce.errors.slicer_filament||ce.errors.material||ce.errors.brand||ce.errors.subtype)&&x("filament");return}const pe=Q?.displayName||B||null,te={material:d.material,subtype:d.subtype||null,brand:d.brand||null,color_name:d.color_name||null,rgba:d.rgba||null,label_weight:d.label_weight,core_weight:d.core_weight,core_weight_catalog_id:d.core_weight_catalog_id,slicer_filament:d.slicer_filament||null,slicer_filament_name:pe,nozzle_temp_min:null,nozzle_temp_max:null,note:d.note||null,cost_per_kg:d.cost_per_kg};(!c||v)&&(te.weight_used=d.weight_used),c?ge.mutate(te):N>1?Ce.mutate({data:te,qty:N}):Le.mutate(te)},q=Le.isPending||Ce.isPending||ge.isPending;return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:s(c?"inventory.editSpool":"inventory.addSpool")}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),!c&&a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(nu,{className:"w-4 h-4 text-amber-400"}),a.jsx("span",{className:"text-sm text-white",children:s("inventory.quickAdd")})]}),a.jsx("button",{type:"button",onClick:()=>{_(!y),y||x("filament")},className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${y?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${y?"translate-x-4":"translate-x-0.5"}`})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("button",{onClick:()=>x("filament"),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${p==="filament"?"text-bambu-green border-b-2 border-bambu-green":"text-bambu-gray hover:text-white"}`,children:[a.jsx(WC,{className:"w-4 h-4"}),s("inventory.filamentInfoTab")]}),!y&&a.jsxs("button",{onClick:()=>x("pa-profile"),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${p==="pa-profile"?"text-bambu-green border-b-2 border-bambu-green":"text-bambu-gray hover:text-white"}`,children:[a.jsx(Hue,{className:"w-4 h-4"}),s("inventory.paProfileTab"),je>0&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:je})]})]}),a.jsx("div",{className:"p-4 overflow-y-auto flex-1",style:{scrollbarGutter:"stable"},children:p==="filament"?a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:s("inventory.filamentInfo")}),a.jsx($Je,{formData:d,updateField:ie,cloudAuthenticated:k,loadingCloudPresets:C,presetInputValue:B,setPresetInputValue:O,selectedPresetOption:Q,filamentOptions:de,availableBrands:X,availableMaterials:me,quickAdd:y,quantity:N,onQuantityChange:T,errors:h})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:s("inventory.color")}),a.jsx(VJe,{formData:d,updateField:ie,recentColors:Y,onColorUsed:ue,catalogColors:U})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:s("inventory.additional")}),a.jsx(GJe,{formData:d,updateField:ie,spoolCatalog:z,currencySymbol:i})]}),c&&n&&a.jsx("div",{children:a.jsx(XJe,{spoolId:n.id})})]}):a.jsx(WJe,{formData:d,updateField:ie,printersWithCalibrations:J,selectedProfiles:ee,setSelectedProfiles:Z,expandedPrinters:we,setExpandedPrinters:oe})}),a.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx(Me,{variant:"secondary",onClick:e,children:s("common.cancel")}),a.jsx(Me,{onClick:R,disabled:q,children:q?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),s("common.saving")]}):a.jsxs(a.Fragment,{children:[a.jsx(bs,{className:"w-4 h-4"}),s(c?"common.save":"inventory.addSpool")]})})]})]})]})}function ZJe({isOpen:t,onClose:e,columns:n,defaultColumns:r,onSave:i}){const{t:s}=Dt(),[o,l]=w.useState(n),[c,d]=w.useState(null),u=w.useRef(null);if(w.useEffect(()=>{t&&l(n.map(T=>({...T})))},[t,n]),w.useEffect(()=>{if(!t)return;const T=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t,e]),!t)return null;const h=T=>{l(k=>k.map((M,C)=>C===T?{...M,visible:!M.visible}:M))},f=(T,k)=>{k<0||k>=o.length||l(M=>{const C=[...M],[j]=C.splice(T,1);return C.splice(k,0,j),C})},p=(T,k)=>{u.current=k,d(k),T.dataTransfer.effectAllowed="move"},x=(T,k)=>{T.preventDefault(),T.dataTransfer.dropEffect="move";const M=u.current;M!==null&&M!==k&&(f(M,k),u.current=k,d(k))},v=T=>{T.preventDefault()},g=()=>{u.current=null,d(null)},y=()=>{l(r.map(T=>({...T})))},_=()=>{i(o),e()},N=o.filter(T=>T.visible).length;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsx(wt,{className:"w-full max-w-md max-h-[80vh] flex flex-col",onClick:T=>T.stopPropagation(),children:a.jsxs(Nt,{className:"p-6 flex flex-col min-h-0",children:[a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:s("inventory.configureColumns")}),a.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:[s("inventory.configureColumnsDesc"),a.jsxs("span",{className:"ml-2 text-bambu-gray/60",children:["(",N," ",s("inventory.of")," ",o.length," ",s("inventory.visible"),")"]})]}),a.jsx("div",{className:"space-y-1 overflow-y-auto flex-1 min-h-0 pr-1",children:o.map((T,k)=>a.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg border transition-colors ${c===k?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-tertiary/50"} ${T.visible?"":"opacity-50"}`,draggable:!0,onDragStart:M=>p(M,k),onDragOver:M=>x(M,k),onDrop:v,onDragEnd:g,children:[a.jsx("div",{className:"cursor-grab text-bambu-gray/50 hover:text-bambu-gray",children:a.jsx(Eh,{className:"w-4 h-4"})}),a.jsx("span",{className:"flex-1 font-medium text-sm text-white",children:T.label}),a.jsxs("div",{className:"flex items-center gap-0.5",children:[a.jsx("button",{onClick:()=>f(k,k-1),disabled:k===0,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed",title:s("inventory.moveUp"),children:a.jsx(yl,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>f(k,k+1),disabled:k===o.length-1,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed",title:s("inventory.moveDown"),children:a.jsx(Pn,{className:"w-4 h-4"})})]}),a.jsx("button",{onClick:()=>h(k),className:`p-1.5 rounded transition-colors ${T.visible?"text-bambu-green hover:bg-bambu-green/10":"text-bambu-gray/50 hover:bg-bambu-dark-secondary"}`,title:T.visible?s("inventory.hideColumn"):s("inventory.showColumn"),children:T.visible?a.jsx(Xl,{className:"w-4 h-4"}):a.jsx(c0,{className:"w-4 h-4"})})]},T.id))}),a.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs(Me,{variant:"secondary",onClick:y,className:"mr-auto",children:[a.jsx(so,{className:"w-4 h-4"}),s("inventory.reset")]}),a.jsx(Me,{variant:"secondary",onClick:e,children:s("inventory.cancel")}),a.jsx(Me,{onClick:_,children:s("inventory.applyChanges")})]})]})})})}function cK(t){return`${t.material}|${t.subtype||""}|${t.brand||""}|${t.color_name||""}|${t.rgba||""}|${t.label_weight}`}const tse="bambuddy-inventory-columns",u1=[{id:"id",label:"#",visible:!0},{id:"added_time",label:"Added",visible:!0},{id:"encode_time",label:"Encoded",visible:!1},{id:"last_used_time",label:"Last Used",visible:!1},{id:"rgba",label:"Color",visible:!0},{id:"material",label:"Material",visible:!0},{id:"subtype",label:"Subtype",visible:!0},{id:"color_name",label:"Color Name",visible:!1},{id:"brand",label:"Brand",visible:!0},{id:"slicer_filament",label:"Slicer Filament",visible:!1},{id:"location",label:"Location",visible:!0},{id:"label_weight",label:"Label",visible:!0},{id:"net",label:"Net",visible:!0},{id:"gross",label:"Gross",visible:!1},{id:"added_full",label:"Full",visible:!1},{id:"used",label:"Used",visible:!1},{id:"printed_total",label:"Printed Total",visible:!1},{id:"printed_since_weight",label:"Printed Since Weight",visible:!1},{id:"note",label:"Note",visible:!1},{id:"pa_k",label:"PA(K)",visible:!0},{id:"tag_id",label:"Tag ID",visible:!1},{id:"data_origin",label:"Data Origin",visible:!1},{id:"tag_type",label:"Linked Tag Type",visible:!1},{id:"stock",label:"Stock",visible:!1},{id:"remaining",label:"Remaining",visible:!0},{id:"cost_per_kg",label:"Cost/kg",visible:!1}];function JJe(){try{const t=localStorage.getItem(tse);if(t){const e=JSON.parse(t),n=new Set(u1.map(o=>o.id)),r=new Set(e.map(o=>o.id)),i=e.filter(o=>n.has(o.id)),s=u1.filter(o=>!r.has(o.id));return[...i,...s]}}catch{}return u1.map(t=>({...t}))}function eet(t){try{localStorage.setItem(tse,JSON.stringify(t))}catch{}}function Mc(t,e=!1){return e&&t>=1e3?`${(t/1e3).toFixed(1)}kg`:`${Math.round(t)}g`}const tet={PLA:"bg-green-500/20 text-green-400",ABS:"bg-red-500/20 text-red-400",PETG:"bg-blue-500/20 text-blue-400",TPU:"bg-purple-500/20 text-purple-400",ASA:"bg-orange-500/20 text-orange-400",PA:"bg-yellow-500/20 text-yellow-400",PC:"bg-cyan-500/20 text-cyan-400",PET:"bg-sky-500/20 text-sky-400"};function Lj(t,e="system"){if(!t)return"-";const n=er(t);return n?d3(n,e):"-"}const net={id:()=>"#",added_time:()=>"Added",encode_time:()=>"Encoded",last_used_time:()=>"Last Used",rgba:t=>t("inventory.color"),material:t=>t("inventory.material"),subtype:t=>t("inventory.subtype"),color_name:t=>t("inventory.colorName"),brand:t=>t("inventory.brand"),slicer_filament:t=>t("inventory.slicerFilament"),location:()=>"Location",label_weight:t=>t("inventory.labelWeight"),net:t=>t("inventory.net"),gross:()=>"Gross",added_full:()=>"Full",used:t=>t("inventory.weightUsed"),printed_total:()=>"Printed Total",printed_since_weight:()=>"Printed Since Weight",note:t=>t("inventory.note"),pa_k:()=>"PA(K)",tag_id:()=>"Tag ID",data_origin:()=>"Data Origin",tag_type:()=>"Linked Tag Type",stock:t=>t("inventory.stock"),remaining:t=>t("inventory.remaining"),cost_per_kg:t=>t("inventory.costPerKg")},iF={id:({spool:t})=>a.jsx("span",{className:"text-sm font-medium text-white",children:t.id}),added_time:({spool:t,dateFormat:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:Lj(t.created_at,e)}),encode_time:({spool:t,dateFormat:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:Lj(t.encode_time,e)}),last_used_time:({spool:t,dateFormat:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.last_used?Lj(t.last_used,e):"Never"}),rgba:({spool:t})=>a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("span",{className:"w-5 h-5 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:t.rgba?`#${t.rgba.substring(0,6)}`:"#808080"},title:t.rgba?`#${t.rgba.substring(0,6)}`:void 0})}),material:({spool:t})=>a.jsx("span",{className:"text-sm text-white",children:t.material}),subtype:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.subtype||"-"}),color_name:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:b4(t.color_name,t.rgba)||"-"}),brand:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.brand||"-"}),slicer_filament:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",title:t.slicer_filament||void 0,children:t.slicer_filament_name||t.slicer_filament||"-"}),location:({spool:t,assignmentMap:e})=>{const n=e[t.id];if(!n)return a.jsx("span",{className:"text-sm text-bambu-gray",children:"-"});const r=n.printer_name||`Printer ${n.printer_id}`,i=n.ams_id===254||n.ams_id===255,s=!i&&n.ams_id>=128,o=m4(n.ams_id,n.tray_id,s,i);return a.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-purple-500/20 text-purple-400",children:[r," ",o]})},label_weight:({spool:t})=>a.jsx("span",{className:"text-sm text-white",children:Mc(t.label_weight)}),net:({remaining:t})=>a.jsx("span",{className:"text-sm text-white",children:Mc(t)}),gross:({spool:t,remaining:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:Mc(e+t.core_weight)}),added_full:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.added_full==null?"-":t.added_full?"Yes":"No"}),used:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.weight_used>0?Mc(t.weight_used):"-"}),printed_total:()=>a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"}),printed_since_weight:()=>a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"}),note:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray max-w-[150px] truncate block",title:t.note||void 0,children:t.note||"-"}),pa_k:({spool:t})=>(t.k_profiles?.length??0)===0?a.jsx("span",{className:"text-sm text-bambu-gray",children:"-"}):a.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-bambu-green/20 text-bambu-green",children:"K"}),tag_id:({spool:t})=>{const e=t.tag_uid||t.tray_uuid;return e?a.jsx("span",{className:"text-sm text-bambu-gray font-mono",title:e,children:e.length>12?`${e.slice(0,6)}...${e.slice(-4)}`:e}):a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"})},data_origin:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.data_origin||"-"}),tag_type:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.tag_type||"-"}),stock:({spool:t,t:e})=>t.slicer_filament?a.jsx("span",{className:"text-sm text-bambu-gray",children:"-"}):a.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-amber-500/20 text-amber-400",children:e("inventory.stock")}),remaining:({remaining:t,pct:e})=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full ${e>50?"bg-bambu-green":e>20?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(e,100)}%`}})}),a.jsxs("span",{className:"text-xs text-bambu-gray min-w-[40px] text-right",children:[Math.round(t),"g"]})]}),cost_per_kg:({spool:t,currencySymbol:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.cost_per_kg!=null?`${e}${t.cost_per_kg.toFixed(2)}`:"-"})},Oj={id:t=>t.id,added_time:t=>t.created_at||"",encode_time:t=>t.encode_time||"",last_used_time:t=>t.last_used||"",material:t=>(t.material||"").toLowerCase(),subtype:t=>(t.subtype||"").toLowerCase(),color_name:t=>(t.color_name||"").toLowerCase(),brand:t=>(t.brand||"").toLowerCase(),slicer_filament:t=>(t.slicer_filament_name||t.slicer_filament||"").toLowerCase(),location:(t,e)=>{const n=e[t.id];if(!n)return"";const r=n.ams_id===254||n.ams_id===255,i=!r&&n.ams_id>=128;return`${n.printer_name||""} ${m4(n.ams_id,n.tray_id,i,r)}`},label_weight:t=>t.label_weight,net:t=>Math.max(0,t.label_weight-t.weight_used),gross:t=>Math.max(0,t.label_weight-t.weight_used)+t.core_weight,used:t=>t.weight_used,remaining:t=>t.label_weight>0?Math.max(0,t.label_weight-t.weight_used)/t.label_weight:0,note:t=>(t.note||"").toLowerCase(),data_origin:t=>(t.data_origin||"").toLowerCase(),tag_type:t=>(t.tag_type||"").toLowerCase(),stock:t=>t.slicer_filament?1:0,cost_per_kg:t=>t.cost_per_kg??0},sF="bambuddy-inventory-sort";function ret(){try{const t=localStorage.getItem(sF);if(t)return JSON.parse(t)}catch{}return null}function aet(t){try{t?localStorage.setItem(sF,JSON.stringify(t)):localStorage.removeItem(sF)}catch{}}function iet(){const{data:t}=Je({queryKey:["spoolman-settings"],queryFn:ne.getSpoolmanSettings,staleTime:3e5});return t?.spoolman_enabled==="true"&&t?.spoolman_url?a.jsx("iframe",{src:t.spoolman_url,className:"h-full w-full border-0",title:"Spoolman",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"}):a.jsx(set,{})}function set(){const{t}=Dt(),e=Jt(),{showToast:n}=ln(),[r,i]=w.useState(null),[s,o]=w.useState(null),[l,c]=w.useState("active"),[d,u]=w.useState("all"),[h,f]=w.useState(""),[p,x]=w.useState(""),[v,g]=w.useState("all"),[y,_]=w.useState(""),[N,T]=w.useState("table"),[k,M]=w.useState(ret),[C,j]=w.useState(JJe),[P,E]=w.useState(!1),[B,O]=w.useState(()=>{try{return localStorage.getItem("bambuddy-inventory-group")==="true"}catch{return!1}}),[z,D]=w.useState(new Set),[$,G]=w.useState(0),[U,W]=w.useState(()=>{try{const Re=localStorage.getItem("bambuddy-inventory-pageSize");if(Re){const fe=Number(Re);if([15,30,50,100,-1].includes(fe))return fe}}catch{}return 15}),{data:Y}=Je({queryKey:["settings"],queryFn:ne.getSettings}),re=Y?.date_format||"system",{data:H,isLoading:K}=Je({queryKey:["inventory-spools"],queryFn:()=>ne.getSpools(!0),refetchInterval:3e4}),{data:ee}=Je({queryKey:["spool-assignments"],queryFn:()=>ne.getAssignments(),refetchInterval:3e4}),Z=st({mutationFn:Re=>ne.deleteSpool(Re),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolDeleted"),"success")}}),we=st({mutationFn:Re=>ne.archiveSpool(Re),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolArchived"),"success")}}),oe=st({mutationFn:Re=>ne.restoreSpool(Re),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolRestored"),"success")}}),J=w.useMemo(()=>{if(!H)return null;let Re=0,fe=0,xe=0,Ne=0;const ye={};for(const ve of H){if(ve.archived_at)continue;Ne++;const Ge=Math.max(0,ve.label_weight-ve.weight_used);Re+=Ge,fe+=ve.weight_used,(ve.label_weight>0?Ge/ve.label_weight*100:0)<20&&xe++;const nt=ve.material||"Unknown";ye[nt]||(ye[nt]={count:0,weight:0}),ye[nt].count++,ye[nt].weight+=Ge}return{totalWeight:Re,totalConsumed:fe,lowStock:xe,byMaterial:ye,totalSpools:Ne}},[H]),je=ee?.length??0,de=rl(Y?.currency||"USD"),le=w.useMemo(()=>{const Re={};for(const fe of ee||[])Re[fe.spool_id]=fe;return Re},[ee]),_e=w.useMemo(()=>J?Object.entries(J.byMaterial).sort((Re,fe)=>fe[1].weight-Re[1].weight).slice(0,4):[],[J]),se=w.useMemo(()=>{let Re=H||[];if(l==="active"?Re=Re.filter(fe=>!fe.archived_at):Re=Re.filter(fe=>!!fe.archived_at),d==="used"?Re=Re.filter(fe=>fe.weight_used>0):d==="new"&&(Re=Re.filter(fe=>fe.weight_used===0)),h&&(Re=Re.filter(fe=>fe.material===h)),p&&(Re=Re.filter(fe=>fe.brand===p)),v==="stock"?Re=Re.filter(fe=>!fe.slicer_filament):v==="configured"&&(Re=Re.filter(fe=>!!fe.slicer_filament)),y){const fe=y.toLowerCase();Re=Re.filter(xe=>xe.brand?.toLowerCase().includes(fe)||xe.material.toLowerCase().includes(fe)||xe.color_name?.toLowerCase().includes(fe)||xe.subtype?.toLowerCase().includes(fe)||xe.note?.toLowerCase().includes(fe)||xe.slicer_filament_name?.toLowerCase().includes(fe))}return Re},[H,l,d,h,p,v,y]),ze=()=>G(0),V=[...new Set(H?.map(Re=>Re.material)||[])].sort(),X=[...new Set(H?.map(Re=>Re.brand).filter(Boolean)||[])].sort(),me=l!=="active"||d!=="all"||!!h||!!p||v!=="all"||!!y,Q=Re=>{j(Re),eet(Re)},ie=w.useMemo(()=>C.filter(Re=>Re.visible).map(Re=>Re.id),[C]),ue=Re=>{Oj[Re]&&(M(fe=>{let xe;return fe?.column===Re?xe=fe.direction==="asc"?{column:Re,direction:"desc"}:null:xe={column:Re,direction:"asc"},aet(xe),xe}),ze())},Le=w.useMemo(()=>{if(!k)return se;const Re=Oj[k.column];return Re?[...se].sort((xe,Ne)=>{const ye=Re(xe,le),ve=Re(Ne,le);return yeve?k.direction==="asc"?1:-1:0}):se},[se,k,le]),Ce=w.useMemo(()=>{if(!B)return Le.map(Ne=>({type:"single",spool:Ne}));const Re=new Map;for(const Ne of Le)if(!(Ne.weight_used>0||le[Ne.id])){const ye=cK(Ne),ve=Re.get(ye);ve?ve.push(Ne):Re.set(ye,[Ne])}const fe=[],xe=new Set;for(const Ne of Le){if(Ne.weight_used>0||le[Ne.id]){fe.push({type:"single",spool:Ne});continue}const ye=cK(Ne);if(xe.has(ye))continue;xe.add(ye);const ve=Re.get(ye);ve.length===1?fe.push({type:"single",spool:ve[0]}):fe.push({type:"group",key:ye,spools:ve,representative:ve[0]})}return fe},[Le,B,le]),ge=U===-1,L=Ce.length,R=ge?L||1:U,q=Math.max(1,Math.ceil(L/R)),ce=ge?0:Math.min($,q-1),pe=ge?Ce:Ce.slice(ce*R,(ce+1)*R),te=()=>{const Re=!B;O(Re),D(new Set),ze();try{localStorage.setItem("bambuddy-inventory-group",String(Re))}catch{}},Be=Re=>{D(fe=>{const xe=new Set(fe);return xe.has(Re)?xe.delete(Re):xe.add(Re),xe})},Ie=Re=>{W(Re),G(0);try{localStorage.setItem("bambuddy-inventory-pageSize",String(Re))}catch{}},$e=()=>{c("active"),u("all"),f(""),x(""),g("all"),_(""),ze()};return a.jsxs("div",{className:"p-4 md:p-6 space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(xi,{className:"w-6 h-6 text-bambu-green"}),a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("inventory.title")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-9",children:(t("inventory.noSpools").split(".")[0],"")})]}),a.jsxs(Me,{onClick:()=>i({spool:null}),children:[a.jsx(Xn,{className:"w-4 h-4"}),t("inventory.addSpool")]})]}),J&&!K&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-3",children:[a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(xi,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.totalInventory")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:Mc(J.totalWeight,!0)}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[J.totalSpools," ",J.totalSpools!==1?t("inventory.spools"):t("inventory.spool")]})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(MF,{className:"w-4 h-4 text-blue-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.totalConsumed")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:Mc(J.totalConsumed,!0)}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.sinceTracking")})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(oi,{className:"w-4 h-4 text-green-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.byMaterial")})]}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:_e.map(([Re,fe])=>a.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${tet[Re]||"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Re," ",a.jsx("span",{className:"opacity-70",children:Mc(fe.weight,!0)})]},Re))})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(Sr,{className:"w-4 h-4 text-purple-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.inPrinter")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:je}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.loadedInAms")})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(An,{className:"w-4 h-4 text-yellow-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.lowStock")})]}),a.jsx("div",{className:`text-xl font-bold ${J.lowStock>0?"text-yellow-400":"text-white"}`,children:J.lowStock}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.lowStockThreshold")})]})]}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 items-start sm:items-center justify-between",children:[a.jsxs("div",{className:"relative flex-1 max-w-md",children:[a.jsx(Mr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50"}),a.jsx("input",{type:"text",value:y,onChange:Re=>{_(Re.target.value),ze()},placeholder:t("inventory.search"),className:"w-full pl-10 pr-8 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green"}),y&&a.jsx("button",{onClick:()=>{_(""),ze()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[N==="table"&&a.jsxs("button",{onClick:()=>E(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-bambu-gray border border-bambu-dark-tertiary rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:t("inventory.configureColumns"),children:[a.jsx(Hhe,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.columns")})]}),a.jsxs("button",{onClick:te,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium border rounded-lg transition-colors ${B?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,title:t("inventory.groupSimilar"),children:[a.jsx(Lme,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.groupSimilar")})]}),a.jsxs("div",{className:"flex bg-bambu-dark-primary border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>T("table"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${N==="table"?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(Tpe,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.table")})]}),a.jsxs("button",{onClick:()=>T("cards"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${N==="cards"?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(u0,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.cards")})]})]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsxs("button",{onClick:()=>{c("active"),ze()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${l==="active"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(xi,{className:"w-3.5 h-3.5"}),t("inventory.active")]}),a.jsxs("button",{onClick:()=>{c("archived"),ze()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${l==="archived"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(Ds,{className:"w-3.5 h-3.5"}),t("inventory.archived")]})]}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsx("button",{onClick:()=>{u("all"),ze()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${d==="all"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.all")}),a.jsxs("button",{onClick:()=>{u("used"),ze()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${d==="used"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(Vn,{className:"w-3.5 h-3.5"}),t("inventory.used")]}),a.jsx("button",{onClick:()=>{u("new"),ze()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${d==="new"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.new")})]}),a.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsx("button",{onClick:()=>{g("all"),ze()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${v==="all"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.all")}),a.jsx("button",{onClick:()=>{g("stock"),ze()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${v==="stock"?"bg-amber-500/20 text-amber-400":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.stock")}),a.jsx("button",{onClick:()=>{g("configured"),ze()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${v==="configured"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.configured")})]}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("select",{value:h,onChange:Re=>{f(Re.target.value),ze()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${h?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,children:[a.jsx("option",{value:"",children:t("inventory.material")}),V.map(Re=>a.jsx("option",{value:Re,children:Re},Re))]}),a.jsxs("select",{value:p,onChange:Re=>{x(Re.target.value),ze()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${p?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,children:[a.jsx("option",{value:"",children:t("inventory.brand")}),X.map(Re=>a.jsx("option",{value:Re,children:Re},Re))]}),me&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("button",{onClick:$e,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:[a.jsx(Rt,{className:"w-3.5 h-3.5"}),t("inventory.clearFilters")]})]}),a.jsxs("span",{className:"ml-auto text-xs text-bambu-gray",children:[Le.length," ",Le.length!==1?t("inventory.spools"):t("inventory.spool"),B&&L0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:pe.map(Re=>{if(Re.type==="group"){const{key:ve,spools:Ge,representative:Te}=Re,nt=Te.rgba?`#${Te.rgba.substring(0,6)}`:"#808080",De=z.has(ve);return a.jsxs("div",{className:"col-span-full",children:[a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-green/30 hover:border-bambu-green transition-colors cursor-pointer",onClick:()=>Be(ve),children:[a.jsx("div",{className:"h-10 flex items-center px-4 gap-3",style:{backgroundColor:nt},children:a.jsx("span",{className:"bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium",children:b4(Te.color_name,Te.rgba)||"-"})}),a.jsxs("div",{className:"px-4 py-3 flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Pn,{className:`w-4 h-4 text-bambu-gray transition-transform ${De?"":"-rotate-90"}`}),a.jsxs("div",{children:[a.jsxs("h3",{className:"font-semibold text-white",children:[Te.material,Te.subtype?` ${Te.subtype}`:""]}),a.jsx("p",{className:"text-sm text-bambu-gray",children:Te.brand||"-"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:Mc(Te.label_weight)}),a.jsx("span",{className:"text-xs font-medium bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full",children:t("inventory.groupedSpools",{count:Ge.length})})]})]})]}),De&&a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 mt-2 ml-4",children:Ge.map(Ke=>{const Oe=Math.max(0,Ke.label_weight-Ke.weight_used),Ee=Ke.label_weight>0?Oe/Ke.label_weight*100:0,Ve=Ke.rgba?`#${Ke.rgba.substring(0,6)}`:"#808080";return a.jsx(dK,{spool:Ke,remaining:Oe,pct:Ee,colorStyle:Ve,onClick:()=>i({spool:Ke}),t},Ke.id)})})]},`group-${ve}`)}const fe=Re.spool,xe=Math.max(0,fe.label_weight-fe.weight_used),Ne=fe.label_weight>0?xe/fe.label_weight*100:0,ye=fe.rgba?`#${fe.rgba.substring(0,6)}`:"#808080";return a.jsx(dK,{spool:fe,remaining:xe,pct:Ne,colorStyle:ye,onClick:()=>i({spool:fe}),t},fe.id)})}),a.jsx(oet,{pageIndex:ce,pageSize:U,totalRows:L,totalPages:q,onPageChange:G,onPageSizeChange:Ie,t})]}):a.jsx(uK,{hasFilters:me,onAddSpool:()=>i({spool:null}),t}):pe.length>0?a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/30",children:[ie.map(Re=>{const fe=!!Oj[Re],xe=k?.column===Re;return a.jsx("th",{className:`text-left py-3 px-4 text-xs font-medium uppercase tracking-wide select-none ${Re==="remaining"?"min-w-[150px]":""} ${fe?"cursor-pointer hover:text-bambu-green transition-colors":""} ${xe?"text-bambu-green":"text-bambu-gray"}`,onClick:fe?()=>ue(Re):void 0,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[net[Re]?.(t)??Re,fe&&(xe?k.direction==="asc"?a.jsx(Mf,{className:"w-3 h-3"}):a.jsx(lb,{className:"w-3 h-3"}):a.jsx(NF,{className:"w-3 h-3 opacity-30"}))]})},Re)}),a.jsx("th",{className:"text-right py-3 px-4 text-xs font-medium text-bambu-gray uppercase tracking-wide",children:t("common.actions")})]})}),a.jsx("tbody",{children:pe.map(Re=>{if(Re.type==="group"){const{key:ye,spools:ve,representative:Ge}=Re,Te=z.has(ye),nt=Math.max(0,Ge.label_weight-Ge.weight_used),De=Ge.label_weight>0?nt/Ge.label_weight*100:0;return a.jsx(cet,{spools:ve,representative:Ge,remaining:nt,pct:De,isExpanded:Te,onToggle:()=>Be(ye),onEdit:Ke=>i({spool:Ke}),onArchive:Ke=>o({type:"archive",spoolId:Ke}),onDelete:Ke=>o({type:"delete",spoolId:Ke}),visibleColumns:ie,assignmentMap:le,currencySymbol:de,dateFormat:re,t},`group-${ye}`)}const fe=Re.spool,xe=Math.max(0,fe.label_weight-fe.weight_used),Ne=fe.label_weight>0?xe/fe.label_weight*100:0;return a.jsx(nse,{spool:fe,remaining:xe,pct:Ne,onEdit:()=>i({spool:fe}),onRestore:()=>oe.mutate(fe.id),onArchive:()=>o({type:"archive",spoolId:fe.id}),onDelete:()=>o({type:"delete",spoolId:fe.id}),visibleColumns:ie,assignmentMap:le,currencySymbol:de,dateFormat:re,t},fe.id)})})]})}),a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-bambu-dark-tertiary/50 border-t border-bambu-dark-tertiary text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:ge?`${L} ${t(L!==1?"inventory.spools":"inventory.spool")}`:a.jsxs(a.Fragment,{children:[t("inventory.showing")," ",ce*R+1," ",t("inventory.to")," ",Math.min((ce+1)*R,L)," ",t("inventory.of")," ",L," ",t("inventory.spools")]})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-gray",children:t("inventory.show")}),a.jsxs("select",{value:U,onChange:Re=>Ie(Number(Re.target.value)),className:"px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green",children:[[15,30,50,100].map(Re=>a.jsx("option",{value:Re,children:Re},Re)),a.jsx("option",{value:-1,children:t("inventory.all")})]}),!ge&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>G(0),disabled:ce===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"First page",children:a.jsx(hY,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>G(Re=>Math.max(0,Re-1)),disabled:ce===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(Kl,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-bambu-gray px-2 whitespace-nowrap",children:[t("inventory.page")," ",ce+1," ",t("inventory.of")," ",q]}),a.jsx("button",{onClick:()=>G(Re=>Math.min(q-1,Re+1)),disabled:ce>=q-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(yi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>G(q-1),disabled:ce>=q-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"Last page",children:a.jsx(mY,{className:"w-4 h-4"})})]})]})]})]}):a.jsx(uK,{hasFilters:me,onAddSpool:()=>i({spool:null}),t}),r!==null&&a.jsx(QJe,{isOpen:!0,onClose:()=>i(null),spool:r.spool,currencySymbol:de}),s&&a.jsx(xn,{title:s.type==="delete"?t("common.delete"):t("inventory.archive"),message:s.type==="delete"?t("inventory.deleteConfirm"):t("inventory.archiveConfirm"),confirmText:s.type==="delete"?t("common.delete"):t("inventory.archive"),variant:s.type==="delete"?"danger":"warning",onConfirm:()=>{s.type==="delete"?Z.mutate(s.spoolId):we.mutate(s.spoolId),o(null)},onCancel:()=>o(null)}),a.jsx(ZJe,{isOpen:P,onClose:()=>E(!1),columns:C,defaultColumns:u1,onSave:Q})]})}function oet({pageIndex:t,pageSize:e,totalRows:n,totalPages:r,onPageChange:i,onPageSizeChange:s,t:o}){const l=e===-1;if(r<=1&&!l)return null;const c=l?n||1:e;return a.jsxs("div",{className:"flex items-center justify-between pt-2 text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:l?`${n} ${o(n!==1?"inventory.spools":"inventory.spool")}`:a.jsxs(a.Fragment,{children:[o("inventory.showing")," ",t*c+1," ",o("inventory.to")," ",Math.min((t+1)*c,n)," ",o("inventory.of")," ",n," ",o("inventory.spools")]})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-gray",children:o("inventory.show")}),a.jsxs("select",{value:e,onChange:d=>s(Number(d.target.value)),className:"px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green",children:[[15,30,50,100].map(d=>a.jsx("option",{value:d,children:d},d)),a.jsx("option",{value:-1,children:o("inventory.all")})]}),!l&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>i(0),disabled:t===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(hY,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>i(Math.max(0,t-1)),disabled:t===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(Kl,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-bambu-gray px-2 whitespace-nowrap",children:[o("inventory.page")," ",t+1," ",o("inventory.of")," ",r]}),a.jsx("button",{onClick:()=>i(Math.min(r-1,t+1)),disabled:t>=r-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(yi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>i(r-1),disabled:t>=r-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(mY,{className:"w-4 h-4"})})]})]})]})}function dK({spool:t,remaining:e,pct:n,colorStyle:r,onClick:i,t:s}){return a.jsxs("div",{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors cursor-pointer ${t.archived_at?"opacity-50":""}`,onClick:i,children:[a.jsx("div",{className:"h-14 flex items-center justify-center",style:{backgroundColor:r},children:a.jsx("span",{className:"bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium",children:b4(t.color_name,t.rgba)||"-"})}),a.jsxs("div",{className:"p-4 space-y-3",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{children:[a.jsxs("h3",{className:"font-semibold text-white",children:[t.material,t.subtype?` ${t.subtype}`:""]}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t.brand||"-"})]}),a.jsxs("span",{className:"text-xs font-mono text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:["#",t.id]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray mb-1",children:[a.jsx("span",{children:s("inventory.remaining")}),a.jsxs("span",{children:[Math.round(n),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full ${n>50?"bg-bambu-green":n>20?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(n,100)}%`}})}),a.jsxs("span",{className:"text-xs text-bambu-gray min-w-[40px] text-right",children:[Math.round(e),"g"]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[a.jsxs("div",{children:[a.jsxs("span",{className:"text-bambu-gray/60",children:[s("inventory.labelWeight"),": "]}),a.jsx("span",{className:"text-bambu-gray",children:Mc(t.label_weight)})]}),a.jsxs("div",{children:[a.jsxs("span",{className:"text-bambu-gray/60",children:[s("inventory.weightUsed"),": "]}),a.jsx("span",{className:"text-bambu-gray",children:t.weight_used>0?Mc(t.weight_used):"-"})]})]}),t.note&&a.jsx("div",{className:"text-xs text-bambu-gray/60 pt-2 border-t border-bambu-dark-tertiary truncate",title:t.note,children:t.note})]})]})}function nse({spool:t,remaining:e,pct:n,onEdit:r,onRestore:i,onArchive:s,onDelete:o,visibleColumns:l,assignmentMap:c,currencySymbol:d,dateFormat:u,t:h}){return a.jsxs("tr",{className:`border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-tertiary/30 transition-colors cursor-pointer ${t.archived_at?"opacity-50":""}`,onClick:r,children:[l.map(f=>a.jsx("td",{className:"py-3 px-4",children:iF[f]?.({spool:t,remaining:e,pct:n,assignmentMap:c,currencySymbol:d,dateFormat:u,t:h})},f)),a.jsx("td",{className:"py-3 px-4",children:a.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:f=>f.stopPropagation(),children:[a.jsx("button",{onClick:r,className:"p-1.5 text-bambu-gray hover:text-white rounded transition-colors",title:h("inventory.editSpool"),children:a.jsx(ef,{className:"w-4 h-4"})}),t.archived_at?a.jsx("button",{onClick:i,className:"p-1.5 text-bambu-gray hover:text-bambu-green rounded transition-colors",title:h("inventory.restore"),children:a.jsx(so,{className:"w-4 h-4"})}):a.jsx("button",{onClick:s,className:"p-1.5 text-bambu-gray hover:text-yellow-400 rounded transition-colors",title:h("inventory.archive"),children:a.jsx(Ds,{className:"w-4 h-4"})}),a.jsx("button",{onClick:o,className:"p-1.5 text-bambu-gray hover:text-red-400 rounded transition-colors",title:h("common.delete"),children:a.jsx(Xt,{className:"w-4 h-4"})})]})})]})}function cet({spools:t,representative:e,remaining:n,pct:r,isExpanded:i,onToggle:s,onEdit:o,onArchive:l,onDelete:c,visibleColumns:d,assignmentMap:u,currencySymbol:h,dateFormat:f,t:p}){return a.jsxs(a.Fragment,{children:[a.jsxs("tr",{className:"border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-tertiary/30 transition-colors cursor-pointer bg-bambu-green/5",onClick:s,children:[d.map((x,v)=>a.jsx("td",{className:"py-3 px-4",children:v===0?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Pn,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"":"-rotate-90"}`}),iF[x]?.({spool:e,remaining:n,pct:r,assignmentMap:u,currencySymbol:h,dateFormat:f,t:p})]}):x==="id"?a.jsx("span",{className:"text-xs font-medium bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full",children:p("inventory.groupedSpools",{count:t.length})}):iF[x]?.({spool:e,remaining:n,pct:r,assignmentMap:u,currencySymbol:h,dateFormat:f,t:p})},x)),a.jsx("td",{className:"py-3 px-4",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:t.map(x=>`#${x.id}`).join(", ")})})]}),i&&t.map(x=>{const v=Math.max(0,x.label_weight-x.weight_used),g=x.label_weight>0?v/x.label_weight*100:0;return a.jsx(nse,{spool:x,remaining:v,pct:g,onEdit:()=>o(x),onRestore:()=>{},onArchive:()=>l(x.id),onDelete:()=>c(x.id),visibleColumns:d,assignmentMap:u,currencySymbol:h,dateFormat:f,t:p},x.id)})]})}function uK({hasFilters:t,onAddSpool:e,t:n}){return a.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-4",children:[a.jsxs("div",{className:"relative mb-6",children:[a.jsx("div",{className:"absolute inset-0 -m-4 bg-bambu-green/5 rounded-full blur-2xl"}),a.jsxs("div",{className:"relative flex items-center justify-center w-24 h-24 rounded-2xl bg-gradient-to-br from-bambu-dark-secondary to-bambu-dark-tertiary border border-bambu-dark-tertiary shadow-lg",children:[a.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 rounded-full bg-bambu-green/30"}),a.jsx("div",{className:"absolute -bottom-2 -left-2 w-2 h-2 rounded-full bg-bambu-green/20"}),t?a.jsx(Mr,{className:"w-10 h-10 text-bambu-gray/40",strokeWidth:1.5}):a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"w-14 h-14 rounded-full border-4 border-bambu-gray/20 flex items-center justify-center",children:a.jsx("div",{className:"w-6 h-6 rounded-full bg-bambu-gray/10 border-2 border-bambu-gray/20"})}),a.jsx("div",{className:"absolute -bottom-1 -right-1 w-6 h-6 rounded-full bg-bambu-green flex items-center justify-center shadow-md",children:a.jsx("span",{className:"text-white text-lg font-bold leading-none",children:"+"})})]})]})]}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2 text-center",children:t?n("inventory.noSpoolsMatch"):n("inventory.noSpools").split(".")[0]}),a.jsx("p",{className:"text-sm text-bambu-gray text-center max-w-sm mb-6",children:n(t?"inventory.noSpoolsMatchDesc":"inventory.noSpools")}),!t&&a.jsxs(Me,{onClick:e,children:[a.jsx(xi,{className:"w-4 h-4"}),n("inventory.addSpool")]})]})}const hK=["DEBUG","INFO","WARNING","ERROR"],Ij={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},det={DEBUG:UC,INFO:Zs,WARNING:An,ERROR:Wa};function uet(){const t=Jt(),[e,n]=w.useState(!0),[r,i]=w.useState(new Set),[s,o]=w.useState(""),[l,c]=w.useState("ALL"),[d,u]=w.useState(!1),[h,f]=w.useState(!1),p=w.useRef(null),{data:x,isLoading:v,refetch:g}=Je({queryKey:["application-logs",l,s],queryFn:()=>Wg.getLogs({limit:200,level:l==="ALL"?void 0:l,search:s||void 0}),refetchInterval:h?2e3:!1,enabled:d});w.useEffect(()=>{d||f(!1)},[d]);const y=st({mutationFn:()=>Wg.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});w.useEffect(()=>{e&&p.current&&x?.entries&&(p.current.scrollTop=p.current.scrollHeight)},[x?.entries,e]);const _=C=>{i(j=>{const P=new Set(j);return P.has(C)?P.delete(C):P.add(C),P})},N=C=>{const j=C.split(" ");return j.length>=2?j[1]:C},T=w.useMemo(()=>x?.entries??[],[x?.entries]),k=w.useMemo(()=>[...T].reverse(),[T]),M=({level:C})=>{const j=det[C]||Zs;return a.jsx(j,{className:`w-3.5 h-3.5 ${Ij[C]||"text-gray-400"}`})};return a.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>u(!d),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${h?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(UC,{className:"w-5 h-5"})}),a.jsxs("div",{className:"text-left",children:[a.jsx("p",{className:"font-medium text-white",children:"Application Logs"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:h?`Live streaming - ${x?.filtered_count??0} entries`:"View and filter application logs"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[h&&a.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs",children:[a.jsx("span",{className:"w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse"}),"Live"]}),d?a.jsx(yl,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(Pn,{className:"w-5 h-5 text-bambu-gray"})]})]}),d&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h?a.jsxs("button",{onClick:C=>{C.stopPropagation(),f(!1)},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded transition-colors",children:[a.jsx(vl,{className:"w-4 h-4"}),"Stop"]}):a.jsxs("button",{onClick:C=>{C.stopPropagation(),f(!0),g()},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 rounded transition-colors",children:[a.jsx(io,{className:"w-4 h-4"}),"Start"]}),a.jsxs("button",{onClick:()=>y.mutate(),disabled:y.isPending||T.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:[a.jsx(Xt,{className:"w-4 h-4"}),"Clear"]}),a.jsx("button",{onClick:()=>g(),disabled:v,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:a.jsx(vr,{className:`w-4 h-4 ${v?"animate-spin":""}`})}),a.jsx("div",{className:"flex-1"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:C=>n(C.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary"}),"Auto-scroll"]}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[x?.filtered_count??0,"/",x?.total_in_file??0]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(Mr,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Search message or logger name...",value:s,onChange:C=>o(C.target.value),className:"w-full pl-8 pr-8 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),s&&a.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>c("ALL"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${l==="ALL"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),hK.map((C,j)=>a.jsx("button",{onClick:()=>c(C),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${j===hK.length-1?"rounded-r":""} ${l===C?`${Ij[C]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:C},C))]})]})]}),a.jsx("div",{ref:p,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:T.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-[300px] text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:"No log entries found"}),a.jsx("p",{className:"text-sm",children:"Log file may be empty or cleared"})]}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary/30",children:k.map((C,j)=>{const P=r.has(j),E=C.message.includes(` +`+n+"}"}return String(t)}function XZe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i,hasPermission:s,t:o}){const{showToast:l}=ln(),c=Jt(),[d,u]=w.useState(!1),{data:h,isLoading:f}=Je({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>ne.getCloudSettingDetail(t.setting_id)}),p=st({mutationFn:()=>ne.deleteCloudSetting(t.setting_id),onSuccess:()=>{l(o("profiles.presets.toast.deleted")),c.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:g=>l(g.message,"error")}),x=i0(t.setting_id),v=uI(t.name,h?.setting?.inherits);return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(wt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:a.jsxs(Nt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),x&&a.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:o("profiles.presets.editable")})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[a.jsx("span",{className:"capitalize",children:o(`profiles.presets.types.${t.type}`)}),v.printer&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"•"}),a.jsx("span",{children:v.printer})]})]})]}),a.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:f?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h?a.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full",children:rF(h)}):a.jsx("div",{className:"text-center py-16 text-bambu-gray",children:o("profiles.presets.failedToLoadDetails")})}),d?a.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[a.jsx(An,{className:"w-5 h-5"}),a.jsx("span",{className:"font-medium",children:o("profiles.presets.deleteConfirm")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:o("profiles.presets.deleteWarning",{name:t.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:()=>u(!1),disabled:p.isPending,className:"flex-1",children:o("common.cancel")}),a.jsxs(Me,{variant:"danger",onClick:()=>p.mutate(),disabled:p.isPending,className:"flex-1",children:[p.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Xt,{className:"w-4 h-4"}),o("common.delete")]})]})]}):a.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:e,className:"flex-1",children:o("common.close")}),a.jsxs(Me,{variant:"secondary",onClick:r,disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDuplicatePermission"),children:[a.jsx(Yl,{className:"w-4 h-4"}),o("profiles.presets.duplicate")]}),x&&a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"secondary",onClick:i,disabled:f||!h||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noEditPermission"),children:[a.jsx(Ya,{className:"w-4 h-4"}),o("common.edit")]}),a.jsx(Me,{variant:"danger",onClick:()=>u(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDeletePermission"),children:a.jsx(Xt,{className:"w-4 h-4"})})]})]})})]})})})}function Kie(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Yie(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function QZe({onClose:t,onApply:e,t:n}){const{showToast:r}=ln(),[i,s]=w.useState(Kie),[o,l]=w.useState("all"),[c,d]=w.useState(null),[u,h]=w.useState(""),[f,p]=w.useState(""),[x,v]=w.useState("{}"),[g,y]=w.useState(null),[_,N]=w.useState(null),T=o==="all"?i:i.filter(z=>z.type===o),k=z=>{s(z),Yie(z)},M=z=>{const D=i.filter($=>$.id!==z);k(D),N(null),r(n("profiles.templates.toast.deleted"))},C=z=>{d(z.id),h(z.name),p(z.description),v(JSON.stringify(z.settings,null,2)),y(null)},j=()=>{if(!(!c||!u.trim()))try{const z=JSON.parse(x),D=i.map($=>$.id===c?{...$,name:u.trim(),description:f.trim(),settings:z}:$);k(D),d(null),r(n("profiles.templates.toast.updated"))}catch(z){y(z.message)}},P=()=>{d(null),h(""),p(""),v("{}"),y(null)},E=z=>{const D=i.map($=>$.id===z?{...$,showInModal:!$.showInModal}:$);k(D)},B={filament:{label:n("profiles.presets.types.filament"),icon:BC,color:"text-amber-400"},print:{label:n("profiles.presets.types.process"),icon:eu,color:"text-blue-400"},printer:{label:n("profiles.presets.types.printer"),icon:Sr,color:"text-purple-400"}},O=_?i.find(z=>z.id===_):null;return w.useEffect(()=>{const z=D=>{D.key==="Escape"&&(_?N(null):c?P():t())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[_,c,t]),a.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[O&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:a.jsx(wt,{className:"w-full max-w-md",children:a.jsxs(Nt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:a.jsx(An,{className:"w-6 h-6 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:n("profiles.templates.deleteTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("profiles.templates.deleteWarning")})]})]}),a.jsx("p",{className:"text-white mb-6",children:n("profiles.templates.deleteConfirm",{name:O.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:()=>N(null),className:"flex-1",children:n("common.cancel")}),a.jsxs(Me,{onClick:()=>M(_),className:"flex-1 bg-red-500 hover:bg-red-600",children:[a.jsx(Xt,{className:"w-4 h-4"}),n("common.delete")]})]})]})})}),a.jsx(wt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:a.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(ub,{className:"w-5 h-5 text-amber-400"}),n("profiles.templates.title")]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("profiles.templates.typeFilter")}),["all","filament","print","printer"].map(z=>a.jsx("button",{onClick:()=>l(z),className:`px-3 py-1 text-sm rounded-lg transition-colors ${o===z?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:z==="all"?n("common.all"):B[z].label},z))]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:T.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(ub,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:n("profiles.templates.noTemplates")}),a.jsx("p",{className:"text-sm mt-1",children:n("profiles.templates.createFirst")})]}):a.jsx("div",{className:"space-y-2",children:T.map(z=>{const D=B[z.type],$=D.icon;return c===z.id?a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[a.jsx("input",{type:"text",value:u,onChange:G=>h(G.target.value),placeholder:n("profiles.templates.namePlaceholder"),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx("input",{type:"text",value:f,onChange:G=>p(G.target.value),placeholder:n("profiles.templates.descriptionPlaceholder"),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:n("profiles.templates.settingsJson")}),a.jsx("textarea",{value:x,onChange:G=>{v(G.target.value),y(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${g?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),g&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:g})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{size:"sm",onClick:j,disabled:!u.trim(),children:[a.jsx(bs,{className:"w-4 h-4"}),"Save"]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:P,children:"Cancel"})]})]},z.id):a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[a.jsx($,{className:`w-5 h-5 ${D.color} flex-shrink-0`}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:z.name}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:z.description})]}),a.jsx("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:n("profiles.templates.fieldsCount",{count:Object.keys(z.settings).length})}),a.jsx("button",{onClick:()=>E(z.id),className:`p-1 transition-colors ${z.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:z.showInModal?n("profiles.templates.shownInModals"):n("profiles.templates.hiddenInModals"),children:z.showInModal?a.jsx(Xl,{className:"w-4 h-4"}):a.jsx(c0,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>e(z),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:n("profiles.templates.apply")}),a.jsx("button",{onClick:()=>C(z),className:"p-1 text-bambu-gray hover:text-white",title:n("common.edit"),children:a.jsx(Ya,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>N(z.id),className:"p-1 text-bambu-gray hover:text-red-400",title:n("common.delete"),children:a.jsx(Xt,{className:"w-4 h-4"})})]},z.id)})})})]})})]})}function Xie({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i,t:s}){const[o,l]=w.useState("changes"),[c,d]=w.useState(""),u=w.useMemo(()=>{const x=new Set([...Object.keys(e),...Object.keys(n)]),v=[];for(const g of x){if(g==="inherits"||g==="version")continue;const y=e[g],_=n[g],N=g in e,T=g in n;let k;!N&&T?k="added":N&&!T?k="removed":JSON.stringify(y)!==JSON.stringify(_)?k="changed":k="same",v.push({key:g,left:y,right:_,status:k})}return v.sort((g,y)=>{const _={changed:0,added:1,removed:2,same:3};return _[g.status]!==_[y.status]?_[g.status]-_[y.status]:g.key.localeCompare(y.key)})},[e,n]),h=w.useMemo(()=>{let x=[...u];if(o==="changes"&&(x=x.filter(v=>v.status!=="same")),c){const v=c.toLowerCase();x=x.filter(g=>g.key.toLowerCase().includes(v)||String(g.left).toLowerCase().includes(v)||String(g.right).toLowerCase().includes(v))}return x},[u,o,c]),f=w.useMemo(()=>({added:u.filter(x=>x.status==="added").length,removed:u.filter(x=>x.status==="removed").length,changed:u.filter(x=>x.status==="changed").length,same:u.filter(x=>x.status==="same").length}),[u]),p=x=>{if(x===void 0)return"—";if(x===null)return"null";if(Array.isArray(x))return x.length===0?"[]":x.length===1?String(x[0]):x.join(", ");if(typeof x=="object")return JSON.stringify(x);const v=String(x);if(v.includes("\\n")||v.length>100){const g=v.split("\\n").length;if(g>1)return`[${g} lines of G-code/script]`;if(v.length>100)return v.substring(0,100)+"…"}return v};return w.useEffect(()=>{const x=v=>{v.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsx(wt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:a.jsxs(Nt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(qg,{className:"w-5 h-5 text-blue-400"}),s("profiles.diff.title")]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:s("profiles.diff.left")}),a.jsx("p",{className:"text-white font-medium truncate",children:r})]}),a.jsxs("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:s("profiles.diff.right")}),a.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(Xn,{className:"w-3.5 h-3.5"}),f.added," ",s("profiles.diff.added")]}),a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(w1,{className:"w-3.5 h-3.5"}),f.removed," ",s("profiles.diff.removed")]}),a.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[a.jsx(t3,{className:"w-3.5 h-3.5"}),f.changed," ",s("profiles.diff.changed")]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[a.jsx(UM,{className:"w-3.5 h-3.5"}),f.same," ",s("profiles.diff.same")]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"relative",children:[a.jsx(Mr,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c,onChange:x=>d(x.target.value),placeholder:s("profiles.diff.searchFields"),className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),f.same>0&&a.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>l("changes"),className:`px-3 py-1.5 text-sm transition-colors ${o==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s("profiles.diff.changes")}),a.jsx("button",{onClick:()=>l("all"),className:`px-3 py-1.5 text-sm transition-colors ${o==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s("common.all")})]})]})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:h.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(UM,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:s(o==="changes"?"profiles.diff.noDifferences":"profiles.diff.noFieldsMatch")})]}):a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:a.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[a.jsx("th",{className:"text-left p-3 w-1/3",children:s("profiles.diff.field")}),a.jsx("th",{className:"text-left p-3 w-1/3",children:r}),a.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),a.jsx("tbody",{children:h.map(x=>{const v={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[x.status],g={added:a.jsx(Xn,{className:"w-3.5 h-3.5 text-green-400"}),removed:a.jsx(w1,{className:"w-3.5 h-3.5 text-red-400"}),changed:a.jsx(t3,{className:"w-3.5 h-3.5 text-amber-400"}),same:a.jsx(UM,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[x.status];return a.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${v}`,children:[a.jsx("td",{className:"p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[g,a.jsx("span",{className:"text-sm text-white font-mono",children:x.key})]})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${x.status==="removed"?"text-red-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:p(x.left)})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${x.status==="added"?"text-green-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:p(x.right)})})]},x.key)})})]})})]})})})}function ZZe({onClose:t,initialData:e,allPresets:n,t:r}){const{showToast:i}=ln(),s=Jt(),o=!!e?.setting_id,[l,c]=w.useState("common"),[d,u]=w.useState(e?.type||"filament"),[h,f]=w.useState(e?.name?o?e.name:`${e.name} (Copy)`:""),[p,x]=w.useState(e?.base_id||""),[v,g]=w.useState(""),[y,_]=w.useState(e?.setting||{inherits:""}),[N,T]=w.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[k,M]=w.useState(null),[C,j]=w.useState(""),[P,E]=w.useState(!1),[B,O]=w.useState(""),[z,D]=w.useState(!1),[$,G]=w.useState(Kie),[U,W]=w.useState(!1),[Y,re]=w.useState(""),[H,K]=w.useState(""),[ee,Z]=w.useState(!0),[we,oe]=w.useState(null),[J,je]=w.useState(!1),de=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[d]||[],[n,d]),le=w.useMemo(()=>de.filter(Ne=>i0(Ne.setting_id)),[de]),{data:_e}=Je({queryKey:["cloudFields",d],queryFn:()=>ne.getCloudFields(d==="print"?"process":d),staleTime:1e3*60*60}),{data:se}=Je({queryKey:["allPresetDetails",d,le.map(Ne=>Ne.setting_id).join(",")],queryFn:async()=>{const Ne={};for(let ve=0;ve{try{const De=await ne.getCloudSettingDetail(nt.setting_id);return{id:nt.setting_id,detail:De}}catch{return null}}))).forEach(nt=>{nt&&(Ne[nt.id]=nt.detail)})}return Ne},enabled:le.length>0,staleTime:1e3*60*10}),{data:ze,isLoading:V}=Je({queryKey:["cloudSettingDetail",p],queryFn:()=>ne.getCloudSettingDetail(p),enabled:!!p});w.useEffect(()=>{l!=="json"&&T(JSON.stringify(y,null,2))},[y,l]);const X=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[d]||[]).filter(ye=>!i0(ye.setting_id)).sort((ye,ve)=>ye.name.localeCompare(ve.name)),[n,d]);w.useEffect(()=>{if(!p)return;const Ne=X.find(ye=>ye.setting_id===p);Ne&&(g(Ne.name),o||(_({inherits:Ne.name}),T(JSON.stringify({inherits:Ne.name},null,2))))},[p,X,o]);const me=w.useMemo(()=>{const Ne=_e?.fields||[],ye=new Set(Ne.map(nt=>nt.key)),ve=new Set,Ge=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);se&&Object.values(se).forEach(nt=>{nt?.setting&&Object.keys(nt.setting).forEach(De=>{!ye.has(De)&&!Ge.has(De)&&ve.add(De)})}),Object.keys(y).forEach(nt=>{!ye.has(nt)&&!Ge.has(nt)&&ve.add(nt)});const Te=Array.from(ve).sort().map(nt=>({key:nt,label:nt.replace(/_/g," ").replace(/\b\w/g,De=>De.toUpperCase()),type:"text",category:"discovered",description:r("profiles.presets.discoveredFromPresets")}));return[...Ne,...Te]},[_e,se,y,r]),Q=me.filter(Ne=>Ne.label.toLowerCase().includes(C.toLowerCase())||Ne.key.toLowerCase().includes(C.toLowerCase())),ie=()=>{if(B.trim()){const Ne=B.trim().toLowerCase().replace(/\s+/g,"_");ue(Ne,""),O(""),D(!1),i(r("profiles.presets.toast.fieldAdded",{key:Ne}))}},ue=(Ne,ye)=>{_(ve=>{const Ge={...ve};return ye===""||ye===void 0?delete Ge[Ne]:Ge[Ne]=ye,Ge})},Le=Ne=>{_(ye=>({...ye,...Ne.settings})),oe(Ne.name),i(r("profiles.templates.toast.applied"))},Ce=()=>{if(!Y.trim())return;const Ne={...y};if(delete Ne.inherits,Object.keys(Ne).length===0){i(r("profiles.presets.noOverridesToSave"),"error");return}const ye={id:Date.now().toString(),name:Y.trim(),description:H.trim()||r("profiles.presets.customTemplate"),type:d,settings:Ne,showInModal:ee},ve=[...$,ye];G(ve),Yie(ve),W(!1),re(""),K(""),Z(!0),i(r("profiles.templates.toast.created"))},ge=w.useMemo(()=>$.filter(Ne=>Ne.type===d&&Ne.showInModal),[d,$]),L=Ne=>{T(Ne);try{const ye=JSON.parse(Ne);_(ye),M(null)}catch(ye){M(ye.message)}},R=Ne=>{Ne.preventDefault(),E(!1);const ye=Ne.dataTransfer.files[0];if(ye&&ye.name.endsWith(".json")){const ve=new FileReader;ve.onload=Ge=>{try{const Te=Ge.target?.result,nt=JSON.parse(Te),De=nt.setting||nt;_(Ke=>({...Ke,...De})),T(JSON.stringify({...y,...De},null,2)),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJsonFile"),"error")}},ve.readAsText(ye)}},q=st({mutationFn:()=>{const Ne={...y},ye=d==="filament"?"filament_settings_id":d==="print"?"print_settings_id":"printer_settings_id";Ne[ye]=`"${h}"`;const ve={type:d,name:h,base_id:p,setting:Ne};return ne.createCloudSetting(ve)},onSuccess:async()=>{i(r("profiles.presets.toast.created")),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:Ne=>i(Ne.message,"error")}),ce=st({mutationFn:()=>{if(!e?.setting_id)throw new Error(r("profiles.presets.noSettingId"));return ne.updateCloudSetting(e.setting_id,{name:h,setting:y})},onSuccess:async()=>{i(r("profiles.presets.toast.updated")),s.removeQueries({queryKey:["cloudSettingDetail"]}),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:Ne=>i(Ne.message,"error")}),pe=o?ce:q,te=ze?.setting?.inherits,Be=te?X.find(Ne=>Ne.name===te):void 0,{data:Ie}=Je({queryKey:["cloudSettingDetail",Be?.setting_id],queryFn:()=>ne.getCloudSettingDetail(Be.setting_id),enabled:!!Be?.setting_id}),$e=w.useMemo(()=>{const Ne=Ie?.setting||{},ye=ze?.setting||{},ve=p&&se?.[p]?.setting?se[p].setting:{};return{...Ne,...ye,...ve}},[p,ze,Ie,se]),Re=Ne=>{if(Ne==null)return"";if(Array.isArray(Ne)){const ye=[...new Set(Ne.map(ve=>String(ve)))];return ye.length===1?ye[0]:Ne.join(", ")}return String(Ne)},fe=Ne=>{const ye=y[Ne.key],ve=$e[Ne.key],Ge=Re(ve),Te=V?r("common.loading"):Ge||"",nt="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(Ne.type==="boolean"){const De=ye==="1"||ye===void 0&&ve==="1";return a.jsx("button",{type:"button",onClick:()=>ue(Ne.key,ye==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${De?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${De?"translate-x-3.5":"translate-x-0.5"}`})})}return Ne.type==="select"?a.jsxs("select",{value:ye||"",onChange:De=>ue(Ne.key,De.target.value),className:nt,children:[a.jsx("option",{value:"",children:Te}),Ne.options?.map(De=>a.jsx("option",{value:De.value,children:De.label},De.value))]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:Ne.type==="number"?"number":"text",value:ye!==void 0?String(ye):"",onChange:De=>ue(Ne.key,De.target.value),step:Ne.step,min:Ne.min,max:Ne.max,placeholder:Te,className:nt}),Ne.unit&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:Ne.unit})]})},xe=w.useMemo(()=>ze?.setting?ze.setting:{},[ze]);return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:Ne=>{Ne.preventDefault(),E(!0)},onDragLeave:()=>E(!1),onDrop:R,children:[J&&p&&a.jsx(Xie,{onClose:()=>je(!1),leftPreset:xe,rightPreset:y,leftLabel:r("profiles.presets.baseLabel",{name:v||p}),rightLabel:r("profiles.presets.currentLabel",{name:h||r("profiles.presets.newPreset")}),t:r}),a.jsx(wt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col overflow-y-auto",children:a.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:r(o?"profiles.presets.editPreset":e?"profiles.presets.duplicatePreset":"profiles.presets.createNewPreset")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("profiles.presets.customizeSettings")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[p&&a.jsxs("button",{onClick:()=>je(!0),className:"flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:r("profiles.presets.compareWithBase"),children:[a.jsx(qg,{className:"w-4 h-4"}),r("profiles.presets.compare")]}),a.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]})]}),P&&a.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:a.jsxs("div",{className:"text-center",children:[a.jsx(La,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),a.jsx("p",{className:"text-bambu-green font-medium",children:r("profiles.presets.dropJsonToImport")})]})}),a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-3 gap-4 max-[640px]:grid-cols-1",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("common.type")}),a.jsxs("select",{value:d,onChange:Ne=>{u(Ne.target.value),x("")},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:[a.jsx("option",{value:"filament",children:r("profiles.presets.types.filament")}),a.jsx("option",{value:"print",children:r("profiles.presets.types.process")}),a.jsx("option",{value:"printer",children:r("profiles.presets.types.printer")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.basePreset")}),a.jsxs("select",{value:p,onChange:Ne=>x(Ne.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:r("profiles.presets.selectBasePreset")}),X.map(Ne=>a.jsx("option",{value:Ne.setting_id,children:Ne.name},Ne.setting_id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.presetName")}),a.jsx("input",{type:"text",value:h,onChange:Ne=>f(Ne.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:r("profiles.presets.myCustomPreset")})]})]}),v&&a.jsx("div",{className:"text-xs text-bambu-gray",children:a.jsxs("p",{className:"flex items-center gap-1",children:[a.jsx(Jr,{className:"w-3 h-3 text-bambu-green"}),r("profiles.presets.inheritsFrom")," ",a.jsx("span",{className:"text-white",children:v}),V&&a.jsx(at,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary max-[640px]:flex-wrap max-[640px]:items-center",children:[a.jsxs("button",{onClick:()=>c("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(OB,{className:"w-4 h-4"}),r("profiles.presets.tabs.common")]}),a.jsxs("button",{onClick:()=>c("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(qC,{className:"w-4 h-4"}),r("profiles.presets.tabs.allFields")]}),a.jsxs("button",{onClick:()=>c("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(fY,{className:"w-4 h-4"}),"JSON",k&&a.jsx(Wa,{className:"w-3 h-3 text-red-400"})]}),a.jsx("div",{className:"flex-1 max-[640px]:hidden"}),a.jsxs("button",{onClick:()=>{const Ne={name:h,type:d,base_id:p,setting:y},ye=new Blob([JSON.stringify(Ne,null,2)],{type:"application/json"}),ve=URL.createObjectURL(ye),Ge=document.createElement("a");Ge.href=ve,Ge.download=`${h||"preset"}.json`,document.body.appendChild(Ge),Ge.click(),document.body.removeChild(Ge),URL.revokeObjectURL(ve),i(r("profiles.presets.toast.exported"))},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.exportToJson"),children:[a.jsx(ha,{className:"w-4 h-4"}),r("common.download")]}),a.jsxs("button",{onClick:()=>document.getElementById("file-import")?.click(),className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.importFromJson"),children:[a.jsx(La,{className:"w-4 h-4"}),r("common.upload")]}),a.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:Ne=>{const ye=Ne.target.files?.[0];if(ye){const ve=new FileReader;ve.onload=Ge=>{try{const Te=JSON.parse(Ge.target?.result),nt=Te.setting||Te;_(De=>({...De,...nt})),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJson"),"error")}},ve.readAsText(ye)}}})]}),a.jsxs("div",{className:"flex-1 p-4",children:[l==="common"&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a.jsx(ub,{className:"w-4 h-4 text-amber-400"}),r("profiles.templates.title")]}),Object.keys(y).filter(Ne=>Ne!=="inherits").length>0&&a.jsxs("button",{onClick:()=>W(!U),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[a.jsx(bs,{className:"w-3 h-3"}),r("profiles.presets.saveAsTemplate")]})]}),U&&a.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[a.jsx("input",{type:"text",value:Y,onChange:Ne=>re(Ne.target.value),placeholder:r("profiles.templates.namePlaceholder"),className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx("input",{type:"text",value:H,onChange:Ne=>K(Ne.target.value),placeholder:r("profiles.templates.descriptionPlaceholder"),className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{size:"sm",onClick:Ce,disabled:!Y.trim(),children:[a.jsx(bs,{className:"w-3 h-3"}),r("common.save")]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>W(!1),children:r("common.cancel")})]}),a.jsxs("button",{onClick:()=>Z(!ee),className:`flex items-center gap-1.5 text-xs transition-colors ${ee?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[ee?a.jsx(Xl,{className:"w-3.5 h-3.5"}):a.jsx(c0,{className:"w-3.5 h-3.5"}),r(ee?"profiles.templates.shownInModals":"profiles.templates.hiddenInModals")]})]})]}),we&&a.jsxs("div",{className:"mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2",children:[a.jsx(Jr,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("span",{className:"text-sm text-bambu-green",children:[r("profiles.presets.templateApplied")," ",a.jsx("span",{className:"font-medium",children:we})]}),a.jsx("button",{onClick:()=>oe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[ge.map(Ne=>a.jsxs("button",{onClick:()=>Le(Ne),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:Ne.name}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:Ne.description})]},Ne.id)),ge.length===0&&a.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:r("profiles.presets.noTemplatesSelected")})]}),a.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:r("profiles.presets.manageTemplatesHint")})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.commonSettings")}),a.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:me.slice(0,10).map(Ne=>a.jsxs("div",{className:"flex items-center justify-between gap-4 max-[640px]:flex-col max-[640px]:items-start",children:[a.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:Ne.label}),a.jsx("div",{className:"w-48 max-[640px]:w-full",children:fe(Ne)})]},Ne.key))})]}),Object.keys(y).length>1&&a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.currentOverrides")}),a.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(y).filter(([Ne])=>Ne!=="inherits").map(([Ne,ye])=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[Ne,": ",String(ye).slice(0,20),a.jsx("button",{onClick:()=>ue(Ne,void 0),className:"hover:text-white",children:a.jsx(Rt,{className:"w-3 h-3"})})]},Ne))})]})]}),l==="fields"&&a.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[a.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.availableFields")}),a.jsx("span",{className:"text-xs text-bambu-gray",children:se?r("profiles.templates.fieldsCount",{count:me.length}):r("common.loading")})]}),a.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[a.jsx(Mr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:C,onChange:Ne=>j(Ne.target.value),placeholder:r("profiles.presets.searchFieldsPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[Q.filter(Ne=>!(Ne.key in y)).map(Ne=>{const ye=$e[Ne.key],ve=Re(ye);return a.jsxs("div",{onClick:()=>{_(Ge=>({...Ge,[Ne.key]:ve||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white truncate",children:Ne.label}),a.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:Ne.key})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[ve&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:ve,children:[ve.slice(0,20),ve.length>20?"...":""]}),a.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:a.jsx(Xn,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},Ne.key)}),Q.filter(Ne=>!(Ne.key in y)).length===0&&a.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:r(C?"profiles.presets.noMatchingFields":"profiles.presets.allFieldsAdded")})]}),a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:z?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:B,onChange:Ne=>O(Ne.target.value),onKeyDown:Ne=>Ne.key==="Enter"&&ie(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx(Me,{size:"sm",onClick:ie,disabled:!B.trim(),children:a.jsx(Xn,{className:"w-4 h-4"})}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>{D(!1),O("")},children:a.jsx(Rt,{className:"w-4 h-4"})})]}):a.jsxs("button",{onClick:()=>D(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[a.jsx(Xn,{className:"w-4 h-4"}),r("profiles.presets.addCustomField")]})})]}),a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[a.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.yourOverrides")}),a.jsx("span",{className:"text-xs text-bambu-gray",children:r("profiles.templates.fieldsCount",{count:Object.keys(y).filter(Ne=>Ne!=="inherits").length})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(y).filter(([Ne])=>Ne!=="inherits").map(([Ne,ye])=>{const ve=me.find(Ge=>Ge.key===Ne);return a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-white",children:ve?.label||Ne}),a.jsx("p",{className:"text-xs text-bambu-gray-dark",children:Ne})]}),a.jsx("button",{onClick:()=>ue(Ne,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),ve?fe(ve):a.jsx("input",{type:"text",value:String(ye),onChange:Ge=>ue(Ne,Ge.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},Ne)}),Object.keys(y).filter(Ne=>Ne!=="inherits").length===0&&a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(OB,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:r("profiles.presets.noOverridesYet")}),a.jsx("p",{className:"text-xs mt-1",children:r("profiles.presets.clickFieldsToAdd")})]})]}),Object.keys(y).filter(Ne=>Ne!=="inherits").length>0&&a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:a.jsxs("button",{onClick:()=>{W(!0),c("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[a.jsx(bs,{className:"w-4 h-4"}),r("profiles.presets.saveAsTemplate")]})})]})]}),l==="json"&&a.jsxs("div",{className:"space-y-2",children:[k&&a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(Wa,{className:"w-4 h-4"}),k]}),a.jsx("textarea",{value:N,onChange:Ne=>L(Ne.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${k?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),a.jsx("p",{className:"text-xs text-bambu-gray",children:r("profiles.presets.jsonTip")})]})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),a.jsxs(Me,{onClick:()=>pe.mutate(),disabled:pe.isPending||!h.trim()||!o&&!p||!!k,className:"flex-1",children:[pe.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):o?a.jsx(bs,{className:"w-4 h-4"}):a.jsx(Xn,{className:"w-4 h-4"}),r(o?"common.save":e?"common.duplicate":"common.create")]})]})]})})]})}function JZe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i,hasPermission:s,t:o}){const[l,c]=w.useState(""),[d,u]=w.useState("all"),[h,f]=w.useState("all"),[p,x]=w.useState("all"),[v,g]=w.useState("all"),[y,_]=w.useState("all"),[N,T]=w.useState("all"),[k,M]=w.useState(null),[C,j]=w.useState(!1),[P,E]=w.useState(!1),[B,O]=w.useState(null),[z,D]=w.useState(null),[$,G]=w.useState(null),[U,W]=w.useState(!1),[Y,re]=w.useState([null,null]),[H,K]=w.useState(!1),[ee,Z]=w.useState(null),we=Jt(),oe=w.useMemo(()=>[...t.filament.map(ie=>({...ie,type:"filament"})),...t.printer.map(ie=>({...ie,type:"printer"})),...t.process.map(ie=>({...ie,type:"process"}))].map(ie=>({...ie,meta:uI(ie.name)})),[t]),J=w.useMemo(()=>{const Q=new Set,ie=new Set,ue=new Set;return oe.forEach(Le=>{Le.meta.nozzle&&Q.add(Le.meta.nozzle),Le.meta.filamentType&&ie.add(Le.meta.filamentType),Le.meta.layerHeight&&ue.add(Le.meta.layerHeight)}),{printers:i.map(Le=>({id:Le.id.toString(),name:Le.name})),nozzles:Array.from(Q).sort((Le,Ce)=>parseFloat(Le)-parseFloat(Ce)),filaments:Array.from(ie).sort(),layerHeights:Array.from(ue).sort((Le,Ce)=>parseFloat(Le)-parseFloat(Ce))}},[oe,i]),je=w.useMemo(()=>p==="all"?null:i.find(ie=>ie.id.toString()===p)?.model||null,[p,i]),de=w.useMemo(()=>oe.filter(Q=>d==="all"||Q.type===d).filter(Q=>{if(h==="all")return!0;const ie=i0(Q.setting_id);return h==="custom"?ie:!ie}).filter(Q=>{if(p==="all"||!je)return!0;const ie=Q.meta.printer?.toLowerCase()||"",ue=je.toLowerCase();return ie.includes(ue)||ue.includes(ie)}).filter(Q=>v==="all"||Q.meta.nozzle===v).filter(Q=>y==="all"||Q.meta.filamentType===y).filter(Q=>N==="all"||Q.meta.layerHeight===N).filter(Q=>l===""||Q.name.toLowerCase().includes(l.toLowerCase())).sort((Q,ie)=>Q.name.localeCompare(ie.name)),[oe,d,h,p,je,v,y,N,l]),le=Q=>{if(U){const ie=Y[0]?.setting_id===Q.setting_id,ue=Y[1]?.setting_id===Q.setting_id;if(ie)re([Y[1],null]);else if(ue)re([Y[0],null]);else if(!Y[0])re([Q,null]);else if(Y[1]){if(Y[0].type!==Q.type)return;re([Y[0],Q])}else{if(Y[0].type!==Q.type)return;re([Y[0],Q])}}else M(Q)},_e=Q=>{if(Y[0]?.setting_id===Q.setting_id)return 0;if(Y[1]?.setting_id===Q.setting_id)return 1},se=async Q=>{try{const ie=await ne.getCloudSettingDetail(Q.setting_id),ue=Q.type==="process"?"print":Q.type;O({type:ue,name:Q.name,base_id:ie.base_id||"GFSA00",setting:ie.setting||{}}),M(null)}catch(ie){console.error("Failed to fetch preset details for duplication:",ie)}},ze=async Q=>{try{we.removeQueries({queryKey:["cloudSettingDetail",Q.setting_id]});const ie=await ne.getCloudSettingDetail(Q.setting_id),ue=Q.type==="process"?"print":Q.type;D({type:ue,name:Q.name,base_id:ie.base_id||"GFSA00",setting:ie.setting||{},setting_id:Q.setting_id}),M(null)}catch(ie){console.error("Failed to fetch preset details for editing:",ie)}},V=()=>{u("all"),f("all"),x("all"),g("all"),_("all"),T("all"),c("")},X=d!=="all"||h!=="all"||p!=="all"||v!=="all"||y!=="all"||N!=="all"||l!=="",me=t.filament.length+t.printer.length+t.process.length;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-4 mb-6",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(Mr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:l,onChange:Q=>c(Q.target.value),placeholder:o("profiles.cloudView.searchPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex gap-2 max-[550px]:flex-wrap max-[550px]:items-center",children:[a.jsxs(Me,{variant:U?"primary":"secondary",onClick:()=>{U?(W(!1),re([null,null])):W(!0)},children:[a.jsx(qg,{className:"w-4 h-4"}),o(U?"common.cancel":"profiles.presets.compare")]}),a.jsxs(Me,{variant:"secondary",onClick:()=>E(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noTemplatesPermission"),children:[a.jsx(ub,{className:"w-4 h-4"}),o("profiles.cloudView.templates")]}),a.jsxs(Me,{variant:"secondary",onClick:n,disabled:r||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noRefreshPermission"),children:[a.jsx(vr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),o("profiles.cloudView.refresh")]}),a.jsxs(Me,{onClick:()=>j(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noCreatePermission"),children:[a.jsx(Xn,{className:"w-4 h-4"}),o("profiles.cloudView.newPreset")]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx($C,{className:"w-4 h-4 text-bambu-gray"}),a.jsx(Tg,{label:o("profiles.cloudView.filters.type"),value:d,options:[{value:"all",label:o("profiles.cloudView.filters.all"),count:me},{value:"filament",label:o("profiles.cloudView.filters.filament"),count:t.filament.length},{value:"printer",label:o("profiles.cloudView.filters.printer"),count:t.printer.length},{value:"process",label:o("profiles.cloudView.filters.process"),count:t.process.length}],onChange:Q=>u(Q)}),a.jsx(Tg,{label:o("profiles.cloudView.filters.owner"),value:h,options:[{value:"all",label:o("profiles.cloudView.filters.all")},{value:"custom",label:o("profiles.cloudView.filters.myPresets")},{value:"builtin",label:o("profiles.cloudView.filters.builtIn")}],onChange:Q=>f(Q)}),J.printers.length>0&&a.jsx(Tg,{label:o("profiles.cloudView.filters.printer"),value:p,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...J.printers.map(Q=>({value:Q.id,label:Q.name}))],onChange:x}),J.nozzles.length>0&&a.jsx(Tg,{label:o("profiles.cloudView.filters.nozzle"),value:v,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...J.nozzles.map(Q=>({value:Q,label:Q}))],onChange:g}),J.filaments.length>0&&(d==="all"||d==="filament")&&a.jsx(Tg,{label:o("profiles.cloudView.filters.filament"),value:y,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...J.filaments.map(Q=>({value:Q,label:Q}))],onChange:_}),J.layerHeights.length>0&&(d==="all"||d==="process")&&a.jsx(Tg,{label:o("profiles.cloudView.filters.layer"),value:N,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...J.layerHeights.map(Q=>({value:Q,label:Q}))],onChange:T}),X&&a.jsx("button",{onClick:V,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:o("profiles.cloudView.clearFilters")})]})]}),U&&a.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(qg,{className:"w-5 h-5 text-blue-400"}),a.jsx("span",{className:"text-white font-medium",children:o("profiles.cloudView.compareMode")}),a.jsx("span",{className:"text-bambu-gray",children:Y[0]?o("profiles.cloudView.selectAnotherPreset",{type:Y[0].type}):o("profiles.cloudView.clickTwoPresets")})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Y[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Y[0]?Y[0].name:o("profiles.cloudView.selectFirst")}),a.jsx(t3,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Y[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Y[1]?Y[1].name:o("profiles.cloudView.selectSecond")})]}),Y[0]&&Y[1]&&a.jsxs(Me,{size:"sm",onClick:async()=>{try{const[Q,ie]=await Promise.all([ne.getCloudSettingDetail(Y[0].setting_id),ne.getCloudSettingDetail(Y[1].setting_id)]);Z([Q.setting||{},ie.setting||{}]),K(!0)}catch{}},children:[a.jsx(qg,{className:"w-4 h-4"}),o("profiles.cloudView.compareNow")]})]})]})}),a.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Vn,{className:"w-3 h-3"}),o("profiles.cloudView.lastSynced")," ",bv(e.toISOString(),"system",o)]}),a.jsx("span",{children:o("profiles.cloudView.showingCount",{showing:de.length,total:me})}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),a.jsxs("span",{children:["= ",o("profiles.presets.myPreset")]})]})]}),de.length===0?a.jsxs("div",{className:"text-center py-16",children:[a.jsx(oi,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),a.jsx("p",{className:"text-bambu-gray",children:o("profiles.cloudView.noPresetsFound")}),X&&a.jsx("button",{onClick:V,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:o("profiles.cloudView.clearFilters")})]}):a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(BC,{className:"w-4 h-4 text-amber-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.filament")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",de.filter(Q=>Q.type==="filament").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[de.filter(Q=>Q.type==="filament").map(Q=>a.jsx(Ej,{setting:Q,onClick:()=>le(Q),onDuplicate:()=>se(Q),compareMode:U,isCompareSelected:_e(Q)!==void 0,compareIndex:_e(Q),compareDisabled:U&&!!Y[0]&&Y[0].type!==Q.type,t:o},Q.setting_id)),de.filter(Q=>Q.type==="filament").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noFilamentPresets")})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(eu,{className:"w-4 h-4 text-blue-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.process")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",de.filter(Q=>Q.type==="process").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[de.filter(Q=>Q.type==="process").map(Q=>a.jsx(Ej,{setting:Q,onClick:()=>le(Q),onDuplicate:()=>se(Q),compareMode:U,isCompareSelected:_e(Q)!==void 0,compareIndex:_e(Q),compareDisabled:U&&!!Y[0]&&Y[0].type!==Q.type,t:o},Q.setting_id)),de.filter(Q=>Q.type==="process").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noProcessPresets")})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(Sr,{className:"w-4 h-4 text-purple-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.printer")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",de.filter(Q=>Q.type==="printer").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[de.filter(Q=>Q.type==="printer").map(Q=>a.jsx(Ej,{setting:Q,onClick:()=>le(Q),onDuplicate:()=>se(Q),compareMode:U,isCompareSelected:_e(Q)!==void 0,compareIndex:_e(Q),compareDisabled:U&&!!Y[0]&&Y[0].type!==Q.type,t:o},Q.setting_id)),de.filter(Q=>Q.type==="printer").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noPrinterPresets")})]})]})]}),k&&a.jsx(XZe,{setting:k,onClose:()=>M(null),onDeleted:()=>M(null),onDuplicate:()=>se(k),onEdit:()=>ze(k),hasPermission:s,t:o}),(C||B||z||$)&&a.jsx(ZZe,{onClose:()=>{j(!1),O(null),D(null),G(null)},initialData:z||B||($?{type:$.type,name:"",base_id:"",setting:$.setting}:void 0),allPresets:t,t:o}),P&&a.jsx(QZe,{onClose:()=>E(!1),onApply:Q=>{G({type:Q.type,setting:Q.settings}),E(!1)},t:o}),H&&ee&&Y[0]&&Y[1]&&a.jsx(Xie,{onClose:()=>{K(!1),Z(null)},leftPreset:ee[0],rightPreset:ee[1],leftLabel:Y[0].name,rightLabel:Y[1].name,t:o})]})}function eJe(){const{t}=Dt(),e=Jt(),{showToast:n}=ln(),{hasPermission:r}=Pr(),[i,s]=w.useState("cloud"),[o,l]=w.useState(),{data:c,isLoading:d}=Je({queryKey:["cloudStatus"],queryFn:ne.getCloudStatus}),{data:u=[]}=Je({queryKey:["printers"],queryFn:ne.getPrinters}),{data:h,isLoading:f,refetch:p,dataUpdatedAt:x}=Je({queryKey:["cloudSettings"],queryFn:()=>ne.getCloudSettings(),enabled:!!c?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{x&&l(new Date(x))},[x]);const v=st({mutationFn:ne.cloudLogout,onSuccess:()=>{e.invalidateQueries({queryKey:["cloudStatus"]}),e.removeQueries({queryKey:["cloudSettings"]}),n(t("profiles.toast.loggedOut"))}}),g=()=>{e.invalidateQueries({queryKey:["cloudStatus"]})};return d?a.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"p-6 lg:p-8",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("profiles.title")}),a.jsx("p",{className:"text-bambu-gray",children:t("profiles.subtitle")})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[a.jsxs("button",{onClick:()=>s("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(Hb,{className:"w-4 h-4"}),t("profiles.tabs.cloud")]}),a.jsxs("button",{onClick:()=>s("local"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="local"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx($b,{className:"w-4 h-4"}),t("profiles.tabs.local")]}),a.jsxs("button",{onClick:()=>s("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(VC,{className:"w-4 h-4"}),t("profiles.tabs.kprofiles")]})]}),i==="cloud"&&a.jsxs(a.Fragment,{children:[c?.is_authenticated&&a.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("profiles.connectedAs")," ",a.jsx("span",{className:"text-white",children:c.email})]})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>v.mutate(),disabled:v.isPending||!r("cloud:auth"),title:r("cloud:auth")?void 0:t("profiles.noLogoutPermission"),children:[a.jsx(s3,{className:"w-4 h-4"}),t("profiles.logout")]})]}),c?.is_authenticated?f?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h?a.jsx(JZe,{settings:h,lastSyncTime:o,onRefresh:()=>p(),isRefreshing:f,printers:u,hasPermission:r,t}):a.jsxs("div",{className:"text-center py-16",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:t("profiles.failedToLoad")}),a.jsx(Me,{onClick:()=>p(),children:t("profiles.retry")})]}):a.jsx(KZe,{onSuccess:g,t})]}),i==="local"&&a.jsx(WZe,{}),i==="kprofiles"&&a.jsx($Ze,{}),a.jsx(YZe,{})]})}const zy={Droplet:BC,Flame:bme,Ruler:Qfe,Sparkles:ub,Square:vl,Cable:ehe,Wrench:jf,Calendar:sa,Timer:Ld,Cog:Uhe,Fan:pY,Zap:nu,Wind:kY,Thermometer:ZC,Layers:oi,Box:ai,Target:_Y,RefreshCw:vr,Settings:QC,Filter:$C,CircleDot:whe};function cv(t){return t&&zy[t]||jf}function Mg(t,e,n){if(e==="days"){if(t<1)return n?n("common.today"):"Today";if(t===1)return n?n("maintenance.day"):"1 day";if(t<7){const i=Math.round(t);return n?n("maintenance.days",{count:i}):`${i} days`}if(t<180){const i=Math.round(t/7);return i===1?n?n("maintenance.week"):"1 week":n?n("maintenance.weeks",{count:i}):`${i} weeks`}const r=Math.round(t/30);return r===1?n?n("maintenance.month"):"1 month":n?n("maintenance.months",{count:r}):`${r} months`}else{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const r=t/24;if(r<7)return`${r<2?r.toFixed(1):Math.round(r)}d`;const i=r/7;return i<12?`${i<2?i.toFixed(1):Math.round(i)}w`:`${Math.round(i/4)}mo`}}function jj(t,e,n){return e==="days"?t===1?n?n("maintenance.day"):"1 day":t===7?n?n("maintenance.week"):"1 week":t===14?n?n("maintenance.weeks",{count:2}):"2 weeks":t===30?n?n("maintenance.month"):"1 month":t===60?n?n("maintenance.months",{count:2}):"2 months":t===90?n?n("maintenance.months",{count:3}):"3 months":t===180?n?n("maintenance.months",{count:6}):"6 months":t===365?n?n("maintenance.year"):"1 year":n?n("maintenance.days",{count:t}):`${t} days`:`${t}h`}function tJe(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),i=n.includes("P1"),s=n.includes("A1MINI"),o=n.includes("A1")&&!s,l=n.includes("H2D"),c=n.includes("H2C"),d=n.includes("H2S"),u=l||c||d,h=n.includes("P2S");switch(t){case"Lubricate Carbon Rods":return r?"https://wiki.bambulab.com/en/x1/maintenance/basic-maintenance":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":h?"https://wiki.bambulab.com/en/p2s/maintenance/lubricate-x-y-z-axis":null;case"Lubricate Linear Rails":return s?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":u?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;case"Clean Nozzle/Hotend":return r||i?"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog":s||o?"https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog":u?"https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning":h?"https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend":"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog";case"Check Belt Tension":return r?"https://wiki.bambulab.com/en/x1/maintenance/belt-tension":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":s?"https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension":o?"https://wiki.bambulab.com/en/a1/maintenance/belt_tension":l?"https://wiki.bambulab.com/en/h2/maintenance/belt-tension":c?"https://wiki.bambulab.com/en/h2c/maintenance/belt-tension":d?"https://wiki.bambulab.com/en/h2s/maintenance/belt-tension":h?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/x1/maintenance/belt-tension";case"Clean Carbon Rods":return r||i||h?"https://wiki.bambulab.com/en/general/carbon-rods-clearance":null;case"Clean Linear Rails":return s?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":u?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;case"Clean Build Plate":return"https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide";case"Check PTFE Tube":return r||i?"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube":s||o?"https://wiki.bambulab.com/en/a1-mini/maintenance/ptfe-tube":l?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":d?"https://wiki.bambulab.com/en/h2s/maintenance/replace-ptfe-tube-on-h2s-printer":c?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube";case"Replace HEPA Filter":case"HEPA Filter":case"Replace Carbon Filter":case"Carbon Filter":return u?"https://wiki.bambulab.com/en/h2/maintenance/replace-smoke-purifier-air-filte":"https://wiki.bambulab.com/en/x1/maintenance/replace-carbon-filter";case"Lubricate Left Nozzle Rail":case"Left Nozzle Rail":return u?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;default:return null}}function nJe({item:t,onPerform:e,onToggle:n,hasPermission:r,t:i}){const s=cv(t.maintenance_type_icon),o=t.interval_type||"hours",c=(()=>{if(o==="days"){const p=t.days_since_maintenance??0;return Math.max(0,Math.min(100,p/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),d=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",u=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",h=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",f=()=>{if(!t.enabled)return i("common.disabled");if(o==="days"){const p=t.days_until_due??0;return t.is_due?i("maintenance.overdueBy",{duration:Mg(Math.abs(p),"days",i)}):t.is_warning?i("maintenance.dueIn",{duration:Mg(p,"days",i)}):i("maintenance.timeLeft",{duration:Mg(p,"days",i)})}else return t.is_due?i("maintenance.overdueBy",{duration:Mg(Math.abs(t.hours_until_due),"hours",i)}):t.is_warning?i("maintenance.dueIn",{duration:Mg(t.hours_until_due,"hours",i)}):i("maintenance.timeLeft",{duration:Mg(t.hours_until_due,"hours",i)})};return a.jsx("div",{className:`rounded-xl border p-4 transition-all ${h()}`,children:a.jsxs("div",{className:"flex items-start gap-3 max-[550px]:flex-wrap",children:[a.jsxs("div",{className:`relative p-2.5 rounded-lg shrink-0 ${t.is_due?"bg-red-500/20":t.is_warning?"bg-amber-500/20":t.enabled?"bg-bambu-dark":"bg-bambu-dark/50"}`,children:[a.jsx(s,{className:`w-5 h-5 ${d()}`}),t.enabled&&(t.is_due||t.is_warning)&&a.jsx("span",{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${t.is_due?"bg-red-500":"bg-amber-500"} animate-pulse`})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),o==="days"&&a.jsx("span",{title:i("maintenance.timeBasedInterval"),children:a.jsx(sa,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const p=t.maintenance_type_wiki_url||tJe(t.maintenance_type_name,t.printer_model);return p?a.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:i("maintenance.viewDocumentation"),onClick:x=>x.stopPropagation(),children:a.jsx(Zr,{className:"w-3.5 h-3.5"})}):null})()]}),a.jsx("div",{className:"mt-2 mb-1.5",children:a.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${u()}`,style:{width:`${c}%`}})})}),a.jsxs("div",{className:`text-xs flex items-center gap-1 ${d()}`,children:[t.is_due&&a.jsx(An,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&a.jsx(Vn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&a.jsx(Jr,{className:"w-3 h-3"}),f()]})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0 max-[550px]:w-full max-[550px]:justify-end max-[550px]:mt-1",children:[a.jsx("span",{title:r("maintenance:update")?void 0:i("maintenance.noPermissionUpdate"),children:a.jsx(Ln,{checked:t.enabled,onChange:p=>n(t.id,p),disabled:!r("maintenance:update")})}),a.jsxs(Me,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled||!r("maintenance:update"),title:r("maintenance:update")?void 0:i("maintenance.noPermissionPerform"),className:"!px-3",children:[a.jsx(so,{className:"w-3.5 h-3.5"}),i("common.reset")]})]})]})})}function rJe({overview:t,onPerform:e,onToggle:n,onSetHours:r,hasPermission:i,t:s}){const[o,l]=w.useState(!1),[c,d]=w.useState(!1),[u,h]=w.useState(t.total_print_hours.toFixed(1)),f=[...t.maintenance_items].sort((v,g)=>v.is_due&&!g.is_due?-1:!v.is_due&&g.is_due?1:v.is_warning&&!g.is_warning?-1:!v.is_warning&&g.is_warning?1:v.maintenance_type_id-g.maintenance_type_id),p=f.find(v=>v.enabled&&(v.is_due||v.is_warning)),x=()=>{const v=parseFloat(u);!isNaN(v)&&v>=0&&(r(t.printer_id,v),d(!1))};return a.jsxs(wt,{className:"overflow-hidden",children:[a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),a.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&a.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(An,{className:"w-3 h-3"}),s("maintenance.overdueCount",{count:t.due_count})]}),t.warning_count>0&&a.jsxs("span",{className:"px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(Vn,{className:"w-3 h-3"}),s("maintenance.dueSoonCount",{count:t.warning_count})]}),t.due_count===0&&t.warning_count===0&&a.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(Jr,{className:"w-3 h-3"}),s("maintenance.allGood")]})]})]}),a.jsxs("button",{onClick:()=>l(!o),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[o?a.jsx(yl,{className:"w-4 h-4"}):a.jsx(Pn,{className:"w-4 h-4"}),s(o?"common.collapse":"common.expand")]})]}),a.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:a.jsx(Ld,{className:"w-4 h-4 text-bambu-gray"})}),c?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",value:u,onChange:v=>h(v.target.value),onKeyDown:v=>{v.key==="Enter"&&x(),v.key==="Escape"&&d(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),a.jsx("span",{className:"text-xs text-bambu-gray",children:s("common.hours")}),a.jsx(Me,{size:"sm",onClick:x,children:s("common.save")}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>d(!1),children:s("common.cancel")})]}):a.jsxs("button",{onClick:()=>{i("maintenance:update")&&(h(Math.round(t.total_print_hours).toString()),d(!0))},className:`group ${i("maintenance:update")?"":"cursor-not-allowed opacity-60"}`,title:i("maintenance:update")?void 0:s("maintenance.noPermissionEditHours"),children:[a.jsxs("div",{className:`text-sm font-medium text-white ${i("maintenance:update")?"group-hover:text-bambu-green":""} transition-colors flex items-center gap-1`,children:[Math.round(t.total_print_hours)," ",s("common.hours"),a.jsx(Pf,{className:`w-3 h-3 text-bambu-gray ${i("maintenance:update")?"group-hover:text-bambu-green":""}`})]}),a.jsx("div",{className:"text-xs text-bambu-gray",children:s("maintenance.totalPrintTime")})]})]}),a.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),p&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${p.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const v=cv(p.maintenance_type_icon);return a.jsx(v,{className:`w-4 h-4 ${p.is_due?"text-red-400":"text-amber-400"}`})})()}),a.jsxs("div",{children:[a.jsx("div",{className:`text-sm font-medium ${p.is_due?"text-red-400":"text-amber-400"}`,children:p.maintenance_type_name}),a.jsx("div",{className:`text-xs ${p.is_due?"text-red-400/70":"text-amber-400/70"}`,children:p.is_due?s("common.overdue"):s("maintenance.dueSoon")})]})]})]})]}),o&&a.jsx(Nt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:a.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:f.map(v=>a.jsx(nJe,{item:v,onPerform:e,onToggle:n,hasPermission:i,t:s},v.id))})})]})}function aJe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:s,onRestoreDefaults:o,isRestoringDefaults:l,onAssignType:c,onRemoveItem:d,hasPermission:u,t:h}){const[f,p]=w.useState(null),[x,v]=w.useState(""),[g,y]=w.useState("hours"),[_,N]=w.useState(!1),[T,k]=w.useState(""),[M,C]=w.useState("100"),[j,P]=w.useState("hours"),[E,B]=w.useState("Wrench"),[O,z]=w.useState(""),[D,$]=w.useState(new Set),[G,U]=w.useState(null),[W,Y]=w.useState(null),re=w.useMemo(()=>t?t.map(L=>({id:L.printer_id,name:L.printer_name})):[],[t]),H=L=>t?t.filter(R=>R.maintenance_items.some(q=>q.maintenance_type_id===L)).map(R=>({printerId:R.printer_id,printerName:R.printer_name,itemId:R.maintenance_items.find(q=>q.maintenance_type_id===L)?.id})):[],K=L=>{if(!t)return[];const R=new Set(H(L).map(q=>q.printerId));return re.filter(q=>!R.has(q.id))},[ee,Z]=w.useState(null),[we,oe]=w.useState(""),[J,je]=w.useState(""),[de,le]=w.useState("hours"),[_e,se]=w.useState("Wrench"),[ze,V]=w.useState(""),X=L=>{Z(L),oe(L.name),je(L.default_interval_hours.toString()),le(L.interval_type||"hours"),se(L.icon||"Wrench"),V(L.wiki_url||"")},me=()=>{ee&&we.trim()&&parseFloat(J)>0&&(i(ee.id,{name:we.trim(),default_interval_hours:parseFloat(J),interval_type:de,icon:_e,wiki_url:ze.trim()||null}),Z(null))},Q=(L,R,q)=>{const ce=parseFloat(x);if(!isNaN(ce)&&ce>0){const pe=Math.abs(ce-R)<.01?null:ce;n(L,{custom_interval_hours:pe,custom_interval_type:g!==q?g:null})}p(null)},ie=L=>{L.preventDefault(),T.trim()&&parseFloat(M)>0&&D.size>0&&(r({name:T.trim(),default_interval_hours:parseFloat(M),interval_type:j,icon:E,wiki_url:O.trim()||null},Array.from(D)),k(""),C("100"),P("hours"),z(""),$(new Set),N(!1))},ue=L=>{$(R=>{const q=new Set(R);return q.has(L)?q.delete(L):q.add(L),q})},Le=t?.map(L=>({printerId:L.printer_id,printerName:L.printer_name,items:L.maintenance_items.sort((R,q)=>R.maintenance_type_id-q.maintenance_type_id)})).sort((L,R)=>L.printerName.localeCompare(R.printerName))||[],Ce=e.filter(L=>L.is_system),ge=e.filter(L=>!L.is_system);return a.jsxs("div",{className:"space-y-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:h("maintenance.maintenanceTypes")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:h("maintenance.maintenanceTypesDescription")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:o,disabled:!u("maintenance:delete")||l,title:u("maintenance:delete")?void 0:h("maintenance.noPermissionDeleteTypes"),children:h("maintenance.restoreDefaults")}),a.jsxs(Me,{onClick:()=>N(!_),disabled:!u("maintenance:create"),title:u("maintenance:create")?void 0:h("maintenance.noPermissionEditTypes"),children:[a.jsx(Xn,{className:"w-4 h-4"}),h("maintenance.addCustomType")]})]})]}),_&&a.jsx(wt,{className:"mb-6",children:a.jsx(Nt,{className:"py-4",children:a.jsxs("form",{onSubmit:ie,children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[a.jsxs("div",{className:"lg:col-span-2",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("common.name")}),a.jsx("input",{type:"text",value:T,onChange:L=>k(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:h("maintenance.exampleName"),autoFocus:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.intervalType")}),a.jsxs("select",{value:j,onChange:L=>{P(L.target.value),L.target.value==="days"?C("30"):C("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"hours",children:h("maintenance.printHours")}),a.jsx("option",{value:"days",children:h("maintenance.calendarDays")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.intervalValue",{type:j==="days"?h("maintenance.calendarDays").toLowerCase():h("common.hours")})}),a.jsx("input",{type:"number",value:M,onChange:L=>C(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),a.jsx("div",{className:"mt-4 flex items-end justify-between",children:a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.icon")}),a.jsx("div",{className:"flex gap-1",children:Object.keys(zy).map(L=>{const R=zy[L];return a.jsx("button",{type:"button",onClick:()=>B(L),className:`p-2 rounded-lg transition-colors ${E===L?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:a.jsx(R,{className:"w-4 h-4"})},L)})})]})}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.documentationLink")}),a.jsx("input",{type:"url",value:O,onChange:L=>z(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"https://wiki.bambulab.com/..."})]}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.assignToPrinters")}),a.jsx("div",{className:"flex flex-wrap gap-2",children:re.map(L=>a.jsx("button",{type:"button",onClick:()=>ue(L.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${D.has(L.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:L.name},L.id))}),D.size===0&&a.jsx("p",{className:"text-xs text-orange-400 mt-1",children:h("maintenance.selectAtLeastOnePrinter")})]}),a.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:()=>{N(!1),$(new Set)},children:h("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!T.trim()||D.size===0,children:h("maintenance.addType")})]})]})})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[Ce.map(L=>{const R=cv(L.icon),q=L.interval_type||"hours";return a.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:a.jsx(R,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-sm font-medium text-white truncate",children:L.name}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[q==="days"?a.jsx(sa,{className:"w-3 h-3"}):a.jsx(Ld,{className:"w-3 h-3"}),jj(L.default_interval_hours,q,h)]})]}),a.jsx("button",{onClick:()=>{u("maintenance:delete")&&Y(L)},disabled:!u("maintenance:delete"),title:u("maintenance:delete")?void 0:h("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${u("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Xt,{className:"w-4 h-4"})})]})},L.id)}),ge.map(L=>{const R=cv(L.icon),q=L.interval_type||"hours";if(ee?.id===L.id)return a.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:a.jsxs("div",{className:"space-y-3",children:[a.jsx("input",{type:"text",value:we,onChange:Ie=>oe(Ie.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:h("common.name"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("select",{value:de,onChange:Ie=>le(Ie.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"hours",children:h("maintenance.printHours")}),a.jsx("option",{value:"days",children:h("maintenance.calendarDays")})]}),a.jsx("input",{type:"number",value:J,onChange:Ie=>je(Ie.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),a.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(zy).map(Ie=>{const $e=zy[Ie];return a.jsx("button",{type:"button",onClick:()=>se(Ie),className:`p-1.5 rounded transition-colors ${_e===Ie?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:a.jsx($e,{className:"w-3.5 h-3.5"})},Ie)})}),a.jsx("input",{type:"url",value:ze,onChange:Ie=>V(Ie.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:h("maintenance.documentationLink")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{size:"sm",onClick:me,disabled:!we.trim(),children:h("common.save")}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>Z(null),children:h("common.cancel")})]})]})},L.id);const pe=H(L.id),te=K(L.id),Be=G===L.id;return a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:a.jsx(R,{className:"w-5 h-5 text-bambu-green"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium text-white truncate",children:L.name}),a.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:h("maintenance.custom")})]}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[q==="days"?a.jsx(sa,{className:"w-3 h-3"}):a.jsx(Ld,{className:"w-3 h-3"}),jj(L.default_interval_hours,q,h)]})]}),a.jsxs("button",{onClick:()=>U(Be?null:L.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${pe.length>0?"border-bambu-green/50 bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20":"border-orange-400/50 bg-orange-400/10 text-orange-400 hover:bg-orange-400/20"}`,title:h("maintenance.printersAssignedClick",{count:pe.length}),children:[a.jsx(Sr,{className:"w-3 h-3"}),a.jsx("span",{className:"text-xs font-medium",children:pe.length}),a.jsx(Pn,{className:`w-3 h-3 transition-transform ${Be?"rotate-180":""}`})]}),a.jsx("button",{onClick:()=>X(L),disabled:!u("maintenance:update"),title:u("maintenance:update")?void 0:h("maintenance.noPermissionEditTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors ${u("maintenance:update")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Pf,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{confirm(h("maintenance.deleteTypeConfirm",{name:L.name}))&&s(L.id)},disabled:!u("maintenance:delete"),title:u("maintenance:delete")?void 0:h("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${u("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Xt,{className:"w-4 h-4"})})]}),Be&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:h("maintenance.assignedToPrinters")}),pe.length===0?a.jsx("p",{className:"text-xs text-orange-400",children:h("maintenance.noPrintersAssigned")}):a.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:pe.map(Ie=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[Ie.printerName,a.jsx("button",{onClick:()=>Ie.itemId&&d(Ie.itemId),disabled:!u("maintenance:delete"),title:u("maintenance:delete")?h("maintenance.removeFromPrinter"):h("maintenance.noPermissionRemovePrinter"),className:`ml-1 ${u("maintenance:delete")?"hover:text-red-400":"opacity-50 cursor-not-allowed"}`,children:"×"})]},Ie.printerId))}),te.length>0&&a.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:h("maintenance.addPrinterShort")}),te.map(Ie=>a.jsxs("button",{onClick:()=>c(Ie.id,L.id),disabled:!u("maintenance:create"),title:u("maintenance:create")?void 0:h("maintenance.noPermissionAssignPrinter"),className:`px-2 py-1 bg-bambu-dark rounded text-xs transition-colors ${u("maintenance:create")?"hover:bg-bambu-green/20 text-bambu-gray hover:text-bambu-green":"opacity-50 cursor-not-allowed text-bambu-gray"}`,children:["+ ",Ie.name]},Ie.id))]})]})]},L.id)})]})]}),Le.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"mb-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:h("maintenance.intervalOverrides")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:h("maintenance.intervalOverridesDescription")})]}),a.jsx("div",{className:"space-y-4",children:Le.map(L=>a.jsx(wt,{children:a.jsxs(Nt,{className:"py-4",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:L.printerName}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:L.items.map(R=>{const q=cv(R.maintenance_type_icon),ce=e.find($e=>$e.id===R.maintenance_type_id),pe=ce?.default_interval_hours||R.interval_hours,te=ce?.interval_type||"hours",Be=R.interval_type||"hours",Ie=f===R.id;return a.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[a.jsx(q,{className:"w-4 h-4 text-bambu-gray shrink-0"}),a.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:R.maintenance_type_name}),Ie?a.jsxs("div",{className:"flex items-center gap-1",children:[g==="days"?a.jsx(sa,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):a.jsx(Ld,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),a.jsxs("select",{value:g,onChange:$e=>y($e.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[a.jsx("option",{value:"hours",children:h("maintenance.printHours")}),a.jsx("option",{value:"days",children:h("maintenance.calendarDays")})]}),a.jsx("input",{type:"number",value:x,onChange:$e=>v($e.target.value),onKeyDown:$e=>{$e.key==="Enter"&&Q(R.id,pe,te),$e.key==="Escape"&&p(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),a.jsx(Me,{size:"sm",onClick:()=>Q(R.id,pe,te),children:"OK"})]}):a.jsxs("button",{onClick:()=>{u("maintenance:update")&&(p(R.id),v(R.interval_hours.toString()),y(Be))},disabled:!u("maintenance:update"),title:u("maintenance:update")?void 0:h("maintenance.noPermissionEditIntervals"),className:`px-2 py-1 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs font-medium text-white transition-colors flex items-center gap-1 ${u("maintenance:update")?"hover:bg-bambu-dark-secondary hover:border-bambu-green":"opacity-50 cursor-not-allowed"}`,children:[Be==="days"?a.jsx(sa,{className:"w-3 h-3"}):a.jsx(Ld,{className:"w-3 h-3"}),jj(R.interval_hours,Be,h),a.jsx(Pf,{className:"w-3 h-3 text-bambu-gray"})]})]},R.id)})})]})},L.printerId))})]}),Le.length===0&&a.jsx(wt,{children:a.jsxs(Nt,{className:"text-center py-12",children:[a.jsx(Vn,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-bambu-gray",children:h("common.noPrinters")}),a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:h("maintenance.intervalOverridesDescription")})]})}),W&&a.jsx(xn,{title:h("maintenance.deleteSystemTypeTitle"),message:h("maintenance.deleteSystemTypeMessage",{name:W.name}),confirmText:h("common.delete"),cancelText:h("common.cancel"),variant:"danger",cancelVariant:"primary",cardClassName:"bg-red-950/70 border border-red-800/70",onConfirm:()=>{s(W.id),Y(null)},onCancel:()=>Y(null)})]})}function iJe(){const{t}=Dt(),e=Jt(),{showToast:n}=ln(),{hasPermission:r}=Pr(),[i,s]=w.useState("status"),{data:o,isLoading:l}=Je({queryKey:["maintenanceOverview"],queryFn:ne.getMaintenanceOverview}),{data:c}=Je({queryKey:["maintenanceTypes"],queryFn:ne.getMaintenanceTypes}),d=st({mutationFn:({id:M,notes:C})=>ne.performMaintenance(M,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.maintenanceComplete"))},onError:M=>{n(M.message,"error")}}),u=st({mutationFn:({id:M,data:C})=>ne.updateMaintenanceItem(M,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:M=>{n(M.message,"error")}}),h=st({mutationFn:({id:M,data:C})=>ne.updateMaintenanceType(M,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onError:M=>{n(M.message,"error")}}),f=st({mutationFn:ne.deleteMaintenanceType,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeDeleted"))},onError:M=>{n(M.message,"error")}}),p=st({mutationFn:ne.restoreDefaultMaintenanceTypes,onSuccess:M=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.defaultsRestored",{count:M.restored}))},onError:M=>{n(M.message,"error")}}),x=st({mutationFn:({printerId:M,hours:C})=>ne.setPrinterHours(M,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.printHoursUpdated"))},onError:M=>{n(M.message,"error")}}),v=st({mutationFn:({printerId:M,typeId:C})=>ne.assignMaintenanceType(M,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerAssigned"))},onError:M=>{n(M.message,"error")}}),g=st({mutationFn:ne.removeMaintenanceItem,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerRemoved"))},onError:M=>{n(M.message,"error")}}),y=M=>{d.mutate({id:M})},_=(M,C)=>{u.mutate({id:M,data:{enabled:C}})},N=(M,C)=>{x.mutate({printerId:M,hours:C})};if(l)return a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})});const T=o?.reduce((M,C)=>M+C.due_count,0)||0,k=o?.reduce((M,C)=>M+C.warning_count,0)||0;return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("maintenance.title")}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:i==="status"?a.jsxs(a.Fragment,{children:[T>0&&a.jsx("span",{className:"text-red-400",children:t("maintenance.dueCount",{count:T})}),T>0&&k>0&&" · ",k>0&&a.jsx("span",{className:"text-amber-400",children:t("maintenance.warningCount",{count:k})}),T===0&&k===0&&a.jsx("span",{className:"text-bambu-green",children:t("maintenance.allOk")})]}):t("maintenance.configureSettings")})]}),a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>s("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.statusTab")}),a.jsx("button",{onClick:()=>s("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.settingsTab")})]}),i==="status"?a.jsx("div",{className:"space-y-6",children:o&&o.length>0?[...o].sort((M,C)=>{const j=M.due_count*10+M.warning_count,P=C.due_count*10+C.warning_count;return j!==P?P-j:M.printer_name.localeCompare(C.printer_name)}).map(M=>a.jsx(rJe,{overview:M,onPerform:y,onToggle:_,onSetHours:N,hasPermission:r,t},M.printer_id)):a.jsx(wt,{children:a.jsxs(Nt,{className:"text-center py-16",children:[a.jsx(jf,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:t("common.noPrinters")}),a.jsx("p",{className:"text-bambu-gray",children:t("maintenance.configureSettings")})]})})}):a.jsx(aJe,{overview:o,types:c||[],onUpdateInterval:(M,C)=>u.mutate({id:M,data:C}),onAddType:async(M,C)=>{const j=await ne.createMaintenanceType(M);for(const P of C)await ne.assignMaintenanceType(P,j.id);e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onUpdateType:(M,C)=>h.mutate({id:M,data:C}),onDeleteType:M=>f.mutate(M),onRestoreDefaults:()=>p.mutate(),isRestoringDefaults:p.isPending,onAssignType:(M,C)=>v.mutate({printerId:M,typeId:C}),onRemoveItem:M=>g.mutate(M),hasPermission:r,t})]})}const aK=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Qie({project:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=w.useState(t?.name||""),[l,c]=w.useState(t?.description||""),[d,u]=w.useState(t?.color||aK[0]),[h,f]=w.useState(t?.target_count?.toString()||""),[p,x]=w.useState(t?.target_parts_count?.toString()||""),[v,g]=w.useState(t?.status||"active"),[y,_]=w.useState(t?.tags||""),[N,T]=w.useState(t?.due_date?.split("T")[0]||""),[k,M]=w.useState(t?.priority||"normal"),C=j=>{j.preventDefault(),n({name:s.trim(),description:l.trim()||void 0,color:d,target_count:h?parseInt(h,10):void 0,target_parts_count:p?parseInt(p,10):void 0,tags:y.trim()||void 0,due_date:N||void 0,priority:k,...t&&{status:v}})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i(t?"projects.editProject":"projects.newProject")})}),a.jsxs("form",{onSubmit:C,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.name")}),a.jsx("input",{type:"text",value:s,onChange:j=>o(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.namePlaceholder"),required:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.description")}),a.jsx("textarea",{value:l,onChange:j=>c(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green resize-none",placeholder:i("projects.descriptionPlaceholder"),rows:2})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.color")}),a.jsx("div",{className:"flex gap-2 flex-wrap",children:aK.map(j=>a.jsx("button",{type:"button",onClick:()=>u(j),className:`w-8 h-8 rounded-full transition-transform ${d===j?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:j}},j))})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetPlates")}),a.jsx("input",{type:"number",value:h,onChange:j=>f(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.targetPlatesPlaceholder"),min:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPlatesHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetParts")}),a.jsx("input",{type:"number",value:p,onChange:j=>x(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.targetPartsPlaceholder"),min:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPartsHelp")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.tagsLabel")}),a.jsx("input",{type:"text",value:y,onChange:j=>_(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.tagsPlaceholder")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.dueDate")}),a.jsx("input",{type:"date",value:N,onChange:j=>T(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.priority")}),a.jsxs("select",{value:k,onChange:j=>M(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"low",children:i("projects.priorityLow")}),a.jsx("option",{value:"normal",children:i("projects.priorityNormal")}),a.jsx("option",{value:"high",children:i("projects.priorityHigh")}),a.jsx("option",{value:"urgent",children:i("projects.priorityUrgent")})]})]})]}),t&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.status")}),a.jsxs("select",{value:v,onChange:j=>g(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"active",children:i("projects.statusActive")}),a.jsx("option",{value:"completed",children:i("projects.statusCompleted")}),a.jsx("option",{value:"archived",children:i("projects.statusArchived")})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(at,{className:"w-4 h-4 animate-spin"}):i(t?"common.save":"projects.create")})]})]})]})})}function sJe({project:t,onClick:e,onEdit:n,onDelete:r,hasPermission:i,t:s}){const o=t.target_count?Math.round(t.archive_count/t.target_count*100):0,l=t.target_parts_count?Math.round(t.completed_count/t.target_parts_count*100):0,c=t.status==="completed",d=t.status==="archived",[u,h]=w.useState(!1),p=c?{icon:db,color:"text-bambu-green",bg:"bg-bambu-green/10"}:d?{icon:Ds,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:Vn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:xs,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return a.jsxs("div",{className:"group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden",onClick:e,children:[a.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full",style:{backgroundColor:t.color||"#6b7280",boxShadow:`0 0 12px ${t.color||"#6b7280"}40`}}),a.jsxs("div",{className:"p-5 pl-6",children:[a.jsxs("div",{className:"flex items-start justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("div",{className:`p-2 rounded-lg ${p.bg} flex-shrink-0`,children:a.jsx(p.icon,{className:`w-5 h-5 ${p.color}`})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_parts_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${l>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," ",s("projects.parts")]}):t.target_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${o>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.archive_count,"/",t.target_count," ",s("projects.plates")]}):t.completed_count>0?a.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium bg-bambu-dark text-bambu-gray",children:[t.completed_count," ",s("projects.parts")]}):null,c&&a.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.done")}),d&&a.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.statusArchived")})]}),t.description&&a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const x=t.archives.map(_=>_.filament_type).filter(Boolean).flatMap(_=>_.split(",").map(N=>N.trim())).filter(Boolean),v=[...new Set(x)],g=t.archives.map(_=>_.filament_color).filter(Boolean).flatMap(_=>_.split(",").map(N=>N.trim())).filter(_=>_.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(_)),y=[...new Set(g)];return v.length===0&&y.length===0?null:a.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[v.slice(0,3).map(_=>a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:_},_)),y.length>0&&a.jsxs("div",{className:"flex items-center gap-0.5",children:[y.slice(0,5).map(_=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:_.startsWith("#")?_:`#${_}`},title:_},_)),y.length>5&&a.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",y.length-5]})]})]})})()]})]}),a.jsxs("div",{className:"relative",onClick:x=>x.stopPropagation(),children:[a.jsx("button",{className:"p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100",onClick:()=>h(!u),children:a.jsx(Th,{className:"w-4 h-4"})}),u&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>h(!1)}),a.jsxs("div",{className:"absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[a.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:update")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:update")&&(n(),h(!1))},disabled:!i("projects:update"),title:i("projects:update")?void 0:s("projects.noEditPermission"),children:[a.jsx(Pf,{className:"w-4 h-4"}),s("common.edit")]}),a.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:delete")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:delete")&&(r(),h(!1))},disabled:!i("projects:delete"),title:i("projects:delete")?void 0:s("projects.noDeletePermission"),children:[a.jsx(Xt,{className:"w-4 h-4"}),s("common.delete")]})]})]})]})]}),a.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?a.jsxs("div",{className:"space-y-3",children:[t.target_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:s("projects.plates")}),a.jsxs("span",{className:o>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:a.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(o,100)}%`,background:o>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${o>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.target_parts_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:s("projects.parts")}),a.jsxs("span",{className:l>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:a.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(l,100)}%`,background:l>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${l>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&a.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," ",s("projects.failed")]})]}):t.completed_count>0||t.failed_count>0?a.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(Ds,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.completed_count," ",s("projects.completed")]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[a.jsx(An,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.failed_count," ",s("projects.failed")]})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[a.jsx(Vn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.queue_count," ",s("projects.inQueue")]})]})]}):a.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:s("projects.noPrintsYet")})}),t.archives&&t.archives.length>0&&a.jsxs("div",{className:"mb-4",children:[a.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(x=>a.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:x.print_name||"Unknown",children:[x.thumbnail_path?a.jsx("img",{src:ne.getArchiveThumbnail(x.id),alt:x.print_name||"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:a.jsx(xi,{className:"w-6 h-6"})}),x.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:a.jsx(An,{className:"w-4 h-4 text-white"})})]},x.id))}),t.archive_count>4&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:s("common.more",{count:t.archive_count-4})})]}),a.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[a.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.printJobs"),children:[a.jsx(oi,{className:"w-3.5 h-3.5 text-blue-400"}),a.jsxs("span",{children:[t.archive_count," ",s("projects.plates")]})]}),a.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.partsPrinted"),children:[a.jsx(xi,{className:"w-3.5 h-3.5 text-bambu-green"}),a.jsxs("span",{children:[t.completed_count," ",s("projects.parts")]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:s("projects.failedParts"),children:[a.jsx(An,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:s("projects.inQueue"),children:[a.jsx(i3,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.queue_count})]})]}),a.jsx(yi,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function oJe(){const{t}=Dt(),e=nc(),n=Jt(),{showToast:r}=ln(),{hasPermission:i}=Pr(),[s,o]=w.useState(!1),[l,c]=w.useState(),[d,u]=w.useState("active"),[h,f]=w.useState(null),{data:p,isLoading:x}=Je({queryKey:["projects",d==="all"?void 0:d],queryFn:()=>ne.getProjects(d==="all"?void 0:d)}),v=st({mutationFn:z=>ne.createProject(z),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),r(t("projects.toast.created"),"success")},onError:z=>{r(z.message,"error")}}),g=st({mutationFn:({id:z,data:D})=>ne.updateProject(z,D),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),c(void 0),r(t("projects.toast.updated"),"success")},onError:z=>{r(z.message,"error")}}),y=st({mutationFn:z=>ne.deleteProject(z),onSuccess:()=>{f(null),r(t("projects.toast.deleted"),"success"),setTimeout(()=>window.location.reload(),100)},onError:z=>{f(null),r(z.message,"error")}}),_=st({mutationFn:z=>ne.importProject(z),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success")},onError:z=>{r(z.message,"error")}}),N=w.useRef(null),T=async()=>{try{const z=await ne.getProjects(),D=await Promise.all(z.map(async W=>await ne.exportProjectJson(W.id))),$=new Blob([JSON.stringify(D,null,2)],{type:"application/json"}),G=URL.createObjectURL($),U=document.createElement("a");U.href=G,U.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,U.click(),URL.revokeObjectURL(G),r(t("projects.toast.exported"),"success")}catch(z){r(z.message,"error")}},k=()=>{N.current?.click()},M=async z=>{const D=z.target.files?.[0];if(D){try{if(D.name.toLowerCase().endsWith(".zip"))await ne.importProjectFile(D),n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success");else{const G=await D.text(),U=JSON.parse(G),W=Array.isArray(U)?U:[U];for(const Y of W)await _.mutateAsync(Y);W.length>1&&r(t("projects.toast.multipleImported",{count:W.length}),"success")}}catch($){r(`${t("projects.toast.importFailed")}: ${$.message}`,"error")}z.target.value=""}},C=z=>{l?g.mutate({id:l.id,data:z}):v.mutate(z)},j=z=>{c(z),o(!0)},P=z=>{e(`/projects/${z.id}`)},E=z=>{f(z)},B=()=>{h!==null&&y.mutate(h)},O=p?.reduce((z,D)=>(z[D.status]=(z[D.status]||0)+1,z.all=(z.all||0)+1,z),{})||{};return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsx("input",{ref:N,type:"file",accept:".json,.zip",onChange:M,className:"hidden"}),a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:a.jsx(xs,{className:"w-6 h-6 text-bambu-green"})}),t("projects.title")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("projects.subtitle")})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{variant:"secondary",onClick:k,disabled:!i("projects:create"),title:i("projects:create")?t("projects.importProject"):t("projects.noImportPermission"),children:[a.jsx(La,{className:"w-4 h-4 mr-2"}),t("projects.import")]}),a.jsxs(Me,{variant:"secondary",onClick:T,disabled:!i("projects:read"),title:i("projects:read")?t("projects.exportAll"):t("projects.noExportPermission"),children:[a.jsx(ha,{className:"w-4 h-4 mr-2"}),t("projects.export")]}),a.jsxs(Me,{onClick:()=>o(!0),className:"sm:w-auto w-full",disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(Xn,{className:"w-4 h-4 mr-2"}),t("projects.newProject")]})]})]}),a.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:t("projects.statusActive"),icon:Vn},{key:"completed",label:t("projects.statusCompleted"),icon:db},{key:"archived",label:t("projects.statusArchived"),icon:Ds},{key:"all",label:t("common.all"),icon:xs}].map(({key:z,label:D,icon:$})=>a.jsxs("button",{onClick:()=>u(z),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${d===z?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[a.jsx($,{className:"w-4 h-4"}),a.jsx("span",{children:D}),O[z]>0&&a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${d===z?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:O[z]})]},z))}),x?a.jsx("div",{className:"flex items-center justify-center py-20",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(at,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("projects.loading")})]})}):p?.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(xs,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:d==="all"?t("projects.noProjects"):t("projects.noProjectsFiltered",{status:d})}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:d==="all"?t("projects.createFirst"):t("projects.noProjectsFilteredHelp",{status:d})}),d==="all"&&a.jsxs(Me,{onClick:()=>o(!0),disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(Xn,{className:"w-4 h-4 mr-2"}),t("projects.createFirstButton")]})]}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:p?.map(z=>a.jsx(sJe,{project:z,onClick:()=>P(z),onEdit:()=>j(z),onDelete:()=>E(z.id),hasPermission:i,t},z.id))}),h!==null&&a.jsx(xn,{title:t("projects.deleteProject"),message:t("projects.deleteConfirm"),confirmText:t("projects.deleteProject"),variant:"danger",onConfirm:B,onCancel:()=>f(null)}),s&&a.jsx(Qie,{project:l,onClose:()=>{o(!1),c(void 0)},onSave:C,isLoading:v.isPending||g.isPending,t})]})}function lJe(t){if(t<1)return`${Math.round(t*60)}m`;const e=Math.floor(t),n=Math.round((t-e)*60);return n>0?`${e}h ${n}m`:`${e}h`}function cJe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function dJe({status:t,t:e}){const n={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},r=n[t]||n.active,i={active:e("projectDetail.status.active"),completed:e("projectDetail.status.completed"),archived:e("projectDetail.status.archived")};return a.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${r}`,children:i[t]||t.charAt(0).toUpperCase()+t.slice(1)})}function iK({icon:t,label:e,value:n,subValue:r,hint:i,color:s="text-bambu-gray"}){return a.jsx(wt,{children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",title:i,children:[a.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${s}`,children:a.jsx(t,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:e}),a.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&a.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function uJe({archives:t,t:e}){return t.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(xi,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:e("projectDetail.noPrints")})]}):a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:t.map(n=>a.jsxs(Ks,{to:`/archives?search=${encodeURIComponent(n.print_name||"")}`,className:"group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors",children:[n.thumbnail_path?a.jsx("img",{src:ne.getArchiveThumbnail(n.id),alt:n.print_name||"Print",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:a.jsx(xi,{className:"w-8 h-8"})}),n.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:a.jsx(bi,{className:"w-8 h-8 text-white"})}),n.status==="completed"&&a.jsx("div",{className:"absolute top-1 right-1",children:a.jsx(br,{className:"w-4 h-4 text-bambu-green"})}),a.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx("p",{className:"text-xs text-white truncate",children:n.print_name||"Unknown"})})]},n.id))})}function hJe({priority:t,t:e}){const n={low:{color:"bg-gray-500/20 text-gray-400",label:e("projectDetail.priority.low")},normal:{color:"bg-blue-500/20 text-blue-400",label:e("projectDetail.priority.normal")},high:{color:"bg-orange-500/20 text-orange-400",label:e("projectDetail.priority.high")},urgent:{color:"bg-red-500/20 text-red-400",label:e("projectDetail.priority.urgent")}},{color:r,label:i}=n[t]||n.normal;return a.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${r}`,children:[t==="urgent"&&a.jsx(An,{className:"w-3 h-3"}),i]})}function mJe(t){return t?hb(t,{year:"numeric",month:"short",day:"numeric"}):""}function Dj(t,e){if(!t)return null;const n=er(t);if(!n)return null;const r=new Date,i=Math.ceil((n.getTime()-r.getTime())/(1e3*60*60*24));return i<0?{color:"text-red-400",label:e("projectDetail.dueDate.overdue")}:i===0?{color:"text-orange-400",label:e("projectDetail.dueDate.today")}:i<=3?{color:"text-yellow-400",label:e("projectDetail.dueDate.daysLeft",{count:i})}:{color:"text-bambu-gray",label:e("projectDetail.dueDate.daysLeft",{count:i})}}function fJe(){const{id:t}=o0(),e=nc(),{t:n}=Dt(),r=Jt(),{showToast:i}=ln(),{hasPermission:s}=Pr(),[o,l]=w.useState(!1),[c,d]=w.useState(!1),[u,h]=w.useState(""),f=parseInt(t||"0",10),{data:p,isLoading:x,error:v}=Je({queryKey:["project",f],queryFn:()=>ne.getProject(f),enabled:f>0}),{data:g,isLoading:y}=Je({queryKey:["project-archives",f],queryFn:()=>ne.getProjectArchives(f),enabled:f>0}),{data:_,isLoading:N}=Je({queryKey:["project-bom",f],queryFn:()=>ne.getProjectBOM(f),enabled:f>0}),{data:T,isLoading:k}=Je({queryKey:["project-timeline",f],queryFn:()=>ne.getProjectTimeline(f,20),enabled:f>0}),{data:M}=Je({queryKey:["settings"],queryFn:ne.getSettings}),{data:C}=Je({queryKey:["project-folders",f],queryFn:()=>ne.getLibraryFoldersByProject(f),enabled:f>0}),j=rl(M?.currency||"USD"),P=M?.time_format||"system",E=st({mutationFn:ve=>ne.updateProject(f,ve),onSuccess:()=>{r.invalidateQueries({queryKey:["project",f]}),r.invalidateQueries({queryKey:["projects"]}),l(!1),d(!1),i(n("projectDetail.toast.projectUpdated"),"success")},onError:ve=>{i(ve.message,"error")}}),B=()=>{h(p?.notes||""),d(!0)},O=()=>{E.mutate({notes:u})},z=()=>{d(!1),h("")},[D,$]=w.useState(""),[G,U]=w.useState(1),[W,Y]=w.useState(""),[re,H]=w.useState(""),[K,ee]=w.useState(""),[Z,we]=w.useState(!1),[oe,J]=w.useState(!1),[je,de]=w.useState(null),[le,_e]=w.useState(""),[se,ze]=w.useState(1),[V,X]=w.useState(""),[me,Q]=w.useState(""),[ie,ue]=w.useState(""),[Le,Ce]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),ge=st({mutationFn:ve=>ne.createBOMItem(f,ve),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),$(""),U(1),Y(""),H(""),ee(""),we(!1),i(n("projectDetail.toast.partAdded"),"success")},onError:ve=>i(ve.message,"error")}),L=st({mutationFn:({itemId:ve,data:Ge})=>ne.updateBOMItem(f,ve,Ge),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),de(null)},onError:ve=>i(ve.message,"error")}),R=st({mutationFn:ve=>ne.deleteBOMItem(f,ve),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),i(n("projectDetail.toast.partRemoved"),"success")},onError:ve=>i(ve.message,"error")}),q=ve=>{ve.preventDefault(),D.trim()&&ge.mutate({name:D.trim(),quantity_needed:G,unit_price:W?parseFloat(W):void 0,sourcing_url:re.trim()||void 0,remarks:K.trim()||void 0})},ce=ve=>{const Ge=ve.is_complete?0:ve.quantity_needed;L.mutate({itemId:ve.id,data:{quantity_acquired:Ge}})},pe=(ve,Ge)=>{Ce({isOpen:!0,title:n("projectDetail.bom.deletePart"),message:n("projectDetail.bom.deleteConfirm",{name:Ge}),onConfirm:()=>{Ce(Te=>({...Te,isOpen:!1})),R.mutate(ve)}})},te=ve=>{de(ve),_e(ve.name),ze(ve.quantity_needed),X(ve.unit_price?.toString()||""),Q(ve.sourcing_url||""),ue(ve.remarks||"")},Be=ve=>{ve.preventDefault(),!(!je||!le.trim())&&L.mutate({itemId:je.id,data:{name:le.trim(),quantity_needed:se,unit_price:V?parseFloat(V):void 0,sourcing_url:me.trim()||void 0,remarks:ie.trim()||void 0}})},Ie=()=>{de(null)},$e=async()=>{try{const{blob:ve,filename:Ge}=await ne.exportProjectZip(Number(f)),Te=URL.createObjectURL(ve),nt=document.createElement("a");nt.href=Te,nt.download=Ge||`${p?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,nt.click(),URL.revokeObjectURL(Te),i(n("projectDetail.toast.projectExported"),"success")}catch(ve){i(ve.message,"error")}},Re=st({mutationFn:()=>ne.createTemplateFromProject(f),onSuccess:()=>{r.invalidateQueries({queryKey:["projects"]}),i(n("projectDetail.toast.templateCreated"),"success")},onError:ve=>i(ve.message,"error")}),fe=ve=>Df(ve,P,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(x)return a.jsx("div",{className:"flex items-center justify-center py-24",children:a.jsx(at,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(v||!p)return a.jsxs("div",{className:"text-center py-24",children:[a.jsx("p",{className:"text-bambu-gray",children:v?`${n("common.error")}: ${v.message}`:n("projectDetail.notFound")}),a.jsx(Me,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:n("projectDetail.backToProjects")})]});const xe=p.stats,Ne=xe?.progress_percent??0,ye=xe?.parts_progress_percent??0;return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(Ks,{to:"/projects",className:"hover:text-white transition-colors",children:n("navigation.projects")}),a.jsx(yi,{className:"w-4 h-4"}),a.jsx("span",{className:"text-white",children:p.name})]}),a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:a.jsx(dY,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:p.color||"#6b7280"}}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:p.name}),p.description&&a.jsx("p",{className:"text-bambu-gray mt-1",children:p.description})]})]}),a.jsx(dJe,{status:p.status,t:n})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{variant:"secondary",onClick:$e,disabled:!s("projects:read"),title:s("projects:read")?n("projectDetail.exportProject"):n("projectDetail.noExportPermission"),children:[a.jsx(ha,{className:"w-4 h-4 mr-2"}),n("projectDetail.export")]}),a.jsxs(Me,{onClick:()=>l(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.noEditPermission"),children:[a.jsx(Pf,{className:"w-4 h-4 mr-2"}),n("common.edit")]})]})]}),(p.target_count||p.target_parts_count)&&a.jsx(wt,{children:a.jsxs(Nt,{className:"p-4 space-y-4",children:[p.target_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.platesProgress")}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[xe?.total_archives||0," / ",p.target_count," ",n("projectDetail.progress.printJobs")]})]}),a.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Ne,100)}%`,backgroundColor:Ne>=100?"#22c55e":p.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:Ne.toFixed(0)})}),xe?.remaining_prints!=null&&xe.remaining_prints>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:xe.remaining_prints})})]})]}),p.target_parts_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.partsProgress")}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[xe?.completed_prints||0," / ",p.target_parts_count," ",n("projectDetail.progress.parts")]})]}),a.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(ye,100)}%`,backgroundColor:ye>=100?"#22c55e":p.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:ye.toFixed(0)})}),xe?.remaining_parts!=null&&xe.remaining_parts>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:xe.remaining_parts})})]})]})]})}),xe&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(wt,{children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:a.jsx(xi,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.printJobs")}),a.jsxs("p",{className:"text-xl font-semibold text-white",children:[xe.total_archives," ",a.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:n("projectDetail.stats.total")})]}),xe.failed_prints>0&&a.jsx("p",{className:"text-sm text-status-error",children:n("projectDetail.stats.failed",{count:xe.failed_prints})}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.partsPrinted",{count:xe.completed_prints})})]})]})})}),a.jsx(iK,{icon:Vn,label:n("projectDetail.stats.printTime"),value:lJe(xe.total_print_time_hours),color:"text-yellow-400"}),a.jsx(iK,{icon:Sr,label:n("projectDetail.stats.filamentUsed"),value:cJe(xe.total_filament_grams),color:"text-purple-400"})]}),xe&&(xe.estimated_cost>0||p.budget)&&a.jsx(wt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:n("projectDetail.cost.title")}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.filamentCost")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[j,xe.estimated_cost.toFixed(2)]})]}),xe.total_energy_kwh>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.energy")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[xe.total_energy_kwh.toFixed(3)," kWh",xe.total_energy_cost>0&&a.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",j,xe.total_energy_cost.toFixed(2),")"]})]})]}),p.budget&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.budget")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[j,p.budget.toFixed(2)]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.remaining")}),a.jsxs("p",{className:`text-lg font-semibold ${p.budget-xe.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[j,(p.budget-xe.estimated_cost).toFixed(2)]})]})]})]})]})}),p.children&&p.children.length>0&&a.jsx(wt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[a.jsx(_me,{className:"w-5 h-5"}),n("projectDetail.subProjects.title",{count:p.children.length})]}),a.jsx("div",{className:"space-y-2",children:p.children.map(ve=>a.jsxs(Ks,{to:`/projects/${ve.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:ve.color||"#6b7280"}}),a.jsx("span",{className:"text-white",children:ve.name}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${ve.status==="completed"?"bg-status-ok/20 text-status-ok":ve.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:ve.status})]}),ve.progress_percent!==null&&a.jsxs("span",{className:"text-sm text-bambu-gray",children:[ve.progress_percent.toFixed(0),"%"]})]},ve.id))})]})}),p.parent_id&&p.parent_name&&a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(oi,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.partOf")}),a.jsx(Ks,{to:`/projects/${p.parent_id}`,className:"text-bambu-green hover:underline",children:p.parent_name})]}),(p.tags||p.due_date||p.priority!=="normal")&&a.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[p.priority&&p.priority!=="normal"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.priorityLabel")}),a.jsx(hJe,{priority:p.priority,t:n})]}),p.due_date&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(sa,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-white",children:mJe(p.due_date)}),Dj(p.due_date,n)&&a.jsxs("span",{className:`text-xs ${Dj(p.due_date,n).color}`,children:["(",Dj(p.due_date,n).label,")"]})]}),p.tags&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Vh,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:p.tags.split(",").map((ve,Ge)=>a.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:ve.trim()},Ge))})]})]}),a.jsx(wt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ps,{className:"w-5 h-5"}),n("projectDetail.notes.title")]}),c?a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{variant:"secondary",size:"sm",onClick:z,disabled:E.isPending,children:[a.jsx(Rt,{className:"w-4 h-4 mr-1"}),n("common.cancel")]}),a.jsxs(Me,{size:"sm",onClick:O,disabled:E.isPending,children:[E.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin mr-1"}):a.jsx(bs,{className:"w-4 h-4 mr-1"}),n("common.save")]})]}):a.jsxs(Me,{variant:"secondary",size:"sm",onClick:B,disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.notes.noEditPermission"),children:[a.jsx(Pf,{className:"w-4 h-4 mr-1"}),n("common.edit")]})]}),c?a.jsx(QR,{content:u,onChange:h,placeholder:n("projectDetail.notes.placeholder")}):p.notes?a.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:p.notes}}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.notes.empty")})]})}),a.jsx(wt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ql,{className:"w-5 h-5"}),n("projectDetail.files.title")]})}),a.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[a.jsx(Ks,{to:"/files",className:"text-bambu-green hover:underline",children:n("projectDetail.files.linkFolders")})," ",n("projectDetail.files.forQuickAccess")]}),C&&C.length>0?a.jsx("div",{className:"space-y-2",children:C.map(ve=>a.jsxs(Ks,{to:`/files?folder=${ve.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsx(Ql,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:ve.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:n("projectDetail.files.fileCount",{count:ve.file_count})})]})]}),a.jsx(yi,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},ve.id))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.files.empty")})]})}),a.jsx(wt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(wY,{className:"w-5 h-5"}),n("projectDetail.bom.title"),xe&&xe.bom_total_items>0&&a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",n("projectDetail.bom.acquired",{completed:xe.bom_completed_items,total:xe.bom_total_items}),")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[_&&_.some(ve=>ve.is_complete)&&a.jsx("button",{onClick:()=>J(!oe),className:`text-xs px-2 py-1 rounded transition-colors ${oe?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:n(oe?"projectDetail.bom.showAll":"projectDetail.bom.hideDone")}),!Z&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>we(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noAddPermission"),children:[a.jsx(Xn,{className:"w-4 h-4 mr-1"}),n("projectDetail.bom.addPart")]})]})]}),Z&&a.jsxs("form",{onSubmit:q,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:D,onChange:ve=>$(ve.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.partNamePlaceholder"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:G,onChange:ve=>U(parseInt(ve.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:n("projectDetail.bom.qty")}),a.jsx("input",{type:"number",step:"0.01",value:W,onChange:ve=>Y(ve.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.price",{currency:j})})]})]}),a.jsx("input",{type:"url",value:re,onChange:ve=>H(ve.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.sourcingUrlPlaceholder")}),a.jsx("input",{type:"text",value:K,onChange:ve=>ee(ve.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.remarksPlaceholder")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",size:"sm",onClick:()=>we(!1),children:n("common.cancel")}),a.jsx(Me,{type:"submit",size:"sm",disabled:!D.trim()||ge.isPending,children:ge.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):n("projectDetail.bom.addPart")})]})]}),N?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(at,{className:"w-6 h-6 animate-spin text-bambu-green"})}):_&&_.length>0?a.jsxs("div",{className:"space-y-2",children:[_.filter(ve=>!oe||!ve.is_complete).map(ve=>a.jsx("div",{className:`p-3 rounded-lg transition-colors ${ve.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:je?.id===ve.id?a.jsxs("form",{onSubmit:Be,className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:le,onChange:Ge=>_e(Ge.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.partName"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:se,onChange:Ge=>ze(parseInt(Ge.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:n("projectDetail.bom.qty")}),a.jsx("input",{type:"number",step:"0.01",value:V,onChange:Ge=>X(Ge.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.price",{currency:j})})]})]}),a.jsx("input",{type:"url",value:me,onChange:Ge=>Q(Ge.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.sourcingUrlPlaceholder")}),a.jsx("input",{type:"text",value:ie,onChange:Ge=>ue(Ge.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.remarksPlaceholder")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",size:"sm",onClick:Ie,children:n("common.cancel")}),a.jsx(Me,{type:"submit",size:"sm",disabled:!le.trim()||L.isPending,children:L.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):n("common.save")})]})]}):a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("button",{onClick:()=>s("projects:update")&&ce(ve),disabled:L.isPending||!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noUpdatePermission"),className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${ve.is_complete?"bg-status-ok border-status-ok text-white":s("projects:update")?"border-bambu-gray hover:border-bambu-green":"border-bambu-gray/50 cursor-not-allowed"}`,children:ve.is_complete&&a.jsx(br,{className:"w-3 h-3"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsxs("p",{className:`text-sm font-medium ${ve.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[ve.name,a.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",ve.quantity_needed]})]}),ve.unit_price!==null&&a.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[j,(ve.unit_price*ve.quantity_needed).toFixed(2)]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>s("projects:update")&&te(ve),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.edit"):n("projectDetail.bom.noEditPermission"),children:a.jsx(Ya,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("projects:update")&&pe(ve.id,ve.name),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.delete"):n("projectDetail.bom.noDeletePermission"),children:a.jsx(Xt,{className:"w-4 h-4"})})]})]}),ve.sourcing_url&&a.jsxs("a",{href:ve.sourcing_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-1 text-xs text-blue-400 hover:text-blue-300 transition-colors",onClick:Ge=>Ge.stopPropagation(),children:[a.jsx(Zr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"truncate",children:(()=>{try{return new URL(ve.sourcing_url).hostname.replace("www.","")}catch{return ve.sourcing_url}})()})]}),ve.remarks&&a.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:ve.remarks})]})]})},ve.id)),_.some(ve=>ve.unit_price!==null)&&a.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.bom.totalCost")}),a.jsxs("span",{className:"text-white font-medium",children:[j,_.reduce((ve,Ge)=>ve+(Ge.unit_price||0)*Ge.quantity_needed,0).toFixed(2)]})]})]}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.bom.empty")})]})}),a.jsx(wt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(pv,{className:"w-5 h-5"}),n("projectDetail.timeline.title")]})}),k?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(at,{className:"w-6 h-6 animate-spin text-bambu-green"})}):T&&T.length>0?a.jsx("div",{className:"space-y-3",children:T.slice(0,10).map((ve,Ge)=>a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${ve.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":ve.event_type==="print_failed"?"bg-status-error/20 text-status-error":ve.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[ve.event_type==="print_completed"&&a.jsx(br,{className:"w-4 h-4"}),ve.event_type==="print_failed"&&a.jsx(bi,{className:"w-4 h-4"}),ve.event_type==="print_started"&&a.jsx(Sr,{className:"w-4 h-4"}),ve.event_type==="queued"&&a.jsx(i3,{className:"w-4 h-4"}),ve.event_type==="project_created"&&a.jsx(Xn,{className:"w-4 h-4"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white",children:ve.title}),ve.description&&a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:ve.description}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:fe(ve.timestamp)})]})]},Ge))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.timeline.empty")})]})}),!p.is_template&&a.jsx("div",{className:"flex justify-end",children:a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>Re.mutate(),disabled:Re.isPending||!s("projects:create"),title:s("projects:create")?void 0:n("projectDetail.template.noCreatePermission"),children:[Re.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(Yl,{className:"w-4 h-4 mr-2"}),n("projectDetail.template.saveAsTemplate")]})}),xe&&(xe.queued_prints>0||xe.in_progress_prints>0)&&a.jsx(wt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(i3,{className:"w-5 h-5"}),n("projectDetail.queue.title")]}),a.jsx(Ks,{to:`/queue?project=${f}`,className:"text-sm text-bambu-green hover:underline",children:n("projectDetail.queue.viewAll")})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[xe.in_progress_prints>0&&a.jsx("span",{className:"text-yellow-400",children:n("projectDetail.queue.printing",{count:xe.in_progress_prints})}),xe.queued_prints>0&&a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.queue.queued",{count:xe.queued_prints})})]})]})}),a.jsxs("div",{children:[a.jsx("div",{className:"flex items-center justify-between mb-4",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(xi,{className:"w-5 h-5"}),n("projectDetail.prints.title",{count:g?.length||0})]})}),y?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(at,{className:"w-6 h-6 animate-spin text-bambu-green"})}):a.jsx(uJe,{archives:g||[],t:n})]}),o&&a.jsx(Qie,{t:n,project:{...p,archive_count:xe?.total_archives||0,total_items:xe?.total_items||0,completed_count:xe?.completed_prints||0,failed_count:xe?.failed_prints||0,queue_count:xe?.queued_prints||0,progress_percent:xe?.progress_percent||null,archives:[]},onClose:()=>l(!1),onSave:ve=>E.mutate(ve),isLoading:E.isPending}),Le.isOpen&&a.jsx(xn,{title:Le.title,message:Le.message,confirmText:n("common.delete"),variant:"danger",onConfirm:Le.onConfirm,onCancel:()=>Ce(ve=>({...ve,isOpen:!1}))})]})}function pJe({parentId:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=w.useState(""),l=c=>{c.preventDefault(),n({name:s.trim(),parent_id:t})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("fileManager.newFolder")})}),a.jsxs("form",{onSubmit:l,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("fileManager.folderName")}),a.jsx("input",{type:"text",value:s,onChange:c=>o(c.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("fileManager.folderNamePlaceholder"),autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(at,{className:"w-4 h-4 animate-spin"}):i("common.create")})]})]})]})})}function gJe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i,t:s}){const[o,l]=w.useState(e),c=d=>{d.preventDefault(),o.trim()&&o.trim()!==e&&r(o.trim())};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:s(t==="file"?"fileManager.renameFile":"fileManager.renameFolder")})}),a.jsxs("form",{onSubmit:c,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("common.name")}),a.jsx("input",{type:"text",value:o,onChange:d=>l(d.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:n,children:s("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!o.trim()||o.trim()===e||i,children:i?a.jsx(at,{className:"w-4 h-4 animate-spin"}):s("common.rename")})]})]})]})})}function bJe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:s,t:o}){const[l,c]=w.useState(null),d=(h,f=0)=>{const p=[];for(const x of h)p.push({id:x.id,name:x.name,depth:f}),x.children.length>0&&p.push(...d(x.children,f+1));return p},u=[{id:null,name:o("fileManager.rootNoFolder"),depth:0},...d(t)];return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:o("fileManager.moveFiles",{count:e.length})})}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:u.map(h=>a.jsxs("button",{onClick:()=>c(h.id),disabled:h.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===h.id?"bg-bambu-green/20 text-bambu-green":h.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+h.depth*16}px`},children:[a.jsx(Ql,{className:"w-4 h-4"}),h.name,h.id===n&&a.jsxs("span",{className:"text-xs text-bambu-gray ml-auto",children:["(",o("fileManager.current"),")"]})]},h.id??"root"))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:r,children:o("common.cancel")}),a.jsx(Me,{onClick:()=>i(l),disabled:s,children:s?a.jsx(at,{className:"w-4 h-4 animate-spin"}):o("common.move")})]})]})]})})}function xJe({folder:t,onClose:e,onLink:n,isLoading:r,t:i}){const[s,o]=w.useState("project"),[l,c]=w.useState(t.project_id||t.archive_id||null);w.useState(()=>{t.archive_id&&o("archive")});const{data:d}=Je({queryKey:["projects"],queryFn:()=>ne.getProjects()}),{data:u}=Je({queryKey:["archives-for-link"],queryFn:()=>ne.getArchives(void 0,void 0,100)}),h=()=>{n(s==="project"?{project_id:l,archive_id:0}:{project_id:0,archive_id:l})},f=()=>{n({project_id:0,archive_id:0})},p=t.project_id||t.archive_id;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(jh,{className:"w-5 h-5 text-bambu-green"}),i("fileManager.linkFolder")]}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:i("fileManager.linkFolderDescription",{name:t.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>{o("project"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${s==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(uY,{className:"w-4 h-4"}),i("fileManager.project")]}),a.jsxs("button",{onClick:()=>{o("archive"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${s==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(Ds,{className:"w-4 h-4"}),i("fileManager.archive")]})]}),a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:s==="project"?d&&d.length>0?d.map(x=>a.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:x.color||"#00ae42"}}),a.jsx("span",{className:"truncate",children:x.name})]},x.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noProjectsFound")}):u&&u.length>0?u.map(x=>a.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx(hf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"truncate",children:x.print_name||x.filename})]},x.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noArchivesFound")})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[p&&a.jsxs(Me,{variant:"danger",onClick:f,disabled:r,children:[a.jsx(JC,{className:"w-4 h-4 mr-2"}),i("fileManager.unlink")]}),a.jsxs("div",{className:`flex gap-2 ${p?"":"ml-auto"}`,children:[a.jsx(Me,{variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{onClick:h,disabled:!l||r,children:r?a.jsx(at,{className:"w-4 h-4 animate-spin"}):i("fileManager.link")})]})]})]})})}function yJe({folderId:t,onClose:e,onUploadComplete:n,t:r}){const[i,s]=w.useState([]),[o,l]=w.useState(!1),[c,d]=w.useState(!1),[u,h]=w.useState(!0),[f,p]=w.useState(!1),[x,v]=w.useState(!0),g=w.useRef(null),y=$=>{$.preventDefault(),l(!0)},_=$=>{$.preventDefault(),l(!1)},N=$=>{$.preventDefault(),l(!1);const G=Array.from($.dataTransfer.files);k(G)},T=$=>{$.target.files&&k(Array.from($.target.files))},k=$=>{const G=$.map(U=>({file:U,status:"pending",isZip:U.name.toLowerCase().endsWith(".zip"),is3mf:U.name.toLowerCase().endsWith(".3mf")}));s(U=>[...U,...G])},M=$=>{s(G=>G.filter((U,W)=>W!==$))},C=i.some($=>$.isZip&&$.status==="pending"),j=i.some($=>$.file.name.toLowerCase().endsWith(".stl")&&$.status==="pending"),P=i.some($=>$.is3mf&&$.status==="pending"),E=async()=>{if(i.length!==0){d(!0);for(let $=0;$G.map((U,W)=>W===$?{...U,status:"uploading"}:U));try{if(i[$].isZip){const G=await ne.extractZipFile(i[$].file,t,u,f,x);s(U=>U.map((W,Y)=>Y===$?{...W,status:G.errors.length>0&&G.extracted===0?"error":"success",extractedCount:G.extracted,error:G.errors.length>0?`${G.errors.length} files failed`:void 0}:W))}else await ne.uploadLibraryFile(i[$].file,t,x),s(G=>G.map((U,W)=>W===$?{...U,status:"success"}:U))}catch(G){s(U=>U.map((W,Y)=>Y===$?{...W,status:"error",error:G instanceof Error?G.message:"Upload failed"}:W))}}d(!1),n(),e()}},B=i.filter($=>$.status==="pending").length,O=i.filter($=>$.status==="success").length,z=i.filter($=>$.status==="error").length,D=i.length>0&&B===0&&!c;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("fileManager.uploadFiles")}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("div",{onDragOver:y,onDragLeave:_,onDrop:N,onClick:()=>g.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,children:[a.jsx(La,{className:`w-10 h-10 mx-auto mb-3 ${o?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("p",{className:"text-white font-medium",children:r(o?"fileManager.dropFilesHere":"fileManager.dragDropFiles")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("fileManager.orClickToBrowse")}),a.jsx("p",{className:"text-xs text-bambu-gray/70 mt-2",children:r("fileManager.allFileTypesSupported")})]}),a.jsx("input",{ref:g,type:"file",multiple:!0,className:"hidden",onChange:T}),C&&a.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Ds,{className:"w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-blue-300 font-medium",children:r("fileManager.zipFilesDetected")}),a.jsx("p",{className:"text-xs text-blue-300/70 mt-1",children:r("fileManager.zipExtractOptions")}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:u,onChange:$=>h($.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.preserveZipStructure")})]}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:f,onChange:$=>p($.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.createFolderFromZip")})]})]})]})}),P&&a.jsx("div",{className:"p-3 bg-purple-500/10 border border-purple-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Sr,{className:"w-5 h-5 text-purple-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-purple-300 font-medium",children:r("fileManager.threemfDetected")}),a.jsx("p",{className:"text-xs text-purple-300/70 mt-1",children:r("fileManager.threemfExtractionInfo")})]})]})}),(j||C)&&a.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Jd,{className:"w-5 h-5 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-bambu-green font-medium",children:r("fileManager.stlThumbnailGeneration")}),a.jsx("p",{className:"text-xs text-bambu-green/70 mt-1",children:r(C&&!j?"fileManager.zipMayContainStl":"fileManager.thumbnailsCanBeGenerated")}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:x,onChange:$=>v($.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.generateThumbnailsForStl")})]})]})]})}),i.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:i.map(($,G)=>a.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[$.isZip?a.jsx(Ds,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):a.jsx(HC,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:$.file.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[($.file.size/1024/1024).toFixed(2)," MB",$.isZip&&$.status==="pending"&&a.jsxs("span",{className:"text-blue-400 ml-2",children:["• ",r("fileManager.willBeExtracted")]}),$.extractedCount!==void 0&&a.jsxs("span",{className:"text-green-400 ml-2",children:["• ",r("fileManager.filesExtracted",{count:$.extractedCount})]})]})]}),$.status==="pending"&&a.jsx("button",{onClick:()=>M(G),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Rt,{className:"w-4 h-4 text-bambu-gray"})}),$.status==="uploading"&&a.jsx(at,{className:"w-4 h-4 text-bambu-green animate-spin"}),$.status==="success"&&a.jsx(br,{className:"w-4 h-4 text-green-500"}),$.status==="error"&&a.jsx("span",{title:$.error,children:a.jsx(bi,{className:"w-4 h-4 text-red-500"})})]},G))}),D&&a.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[r("fileManager.uploadComplete",{succeeded:O}),z>0&&a.jsxs("span",{className:"text-red-400",children:[", ",r("fileManager.uploadFailed",{count:z})]})]})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:e,children:r(D?"common.close":"common.cancel")}),!D&&a.jsx(Me,{onClick:E,disabled:B===0||c,children:c?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 mr-2 animate-spin"}),r("fileManager.uploading")]}):a.jsxs(a.Fragment,{children:[a.jsx(La,{className:"w-4 h-4 mr-2"}),r("common.upload")," ",B>0?`(${B})`:""]})})]})]})})}function Zie({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o=0,wrapNames:l=!1,hasPermission:c,t:d}){const[u,h]=w.useState(!0),[f,p]=w.useState(!1),x=t.children.length>0,v=t.project_id||t.archive_id;return a.jsxs("div",{children:[a.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${e===t.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${8+o*12}px`},onClick:()=>n(t.id),children:[x?a.jsx("button",{onClick:g=>{g.stopPropagation(),h(!u)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(yi,{className:`w-3.5 h-3.5 transition-transform ${u?"rotate-90":""}`})}):a.jsx("div",{className:"w-4.5"}),a.jsx(Ql,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),a.jsx("span",{className:`text-sm flex-1 min-w-0 ${l?"break-all":"truncate"}`,title:t.name,children:t.name}),v&&a.jsxs("button",{onClick:g=>{g.stopPropagation(),i(t)},className:"flex-shrink-0 flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",title:`${t.project_name?`Project: ${t.project_name}`:`Archive: ${t.archive_name}`} (click to change)`,children:[a.jsx(jh,{className:"w-3 h-3"}),t.project_name?a.jsx(uY,{className:"w-3 h-3"}):a.jsx(Ds,{className:"w-3 h-3"})]}),t.file_count>0&&a.jsx("span",{className:"flex-shrink-0 text-xs text-bambu-gray",children:t.file_count}),!v&&a.jsx("button",{onClick:g=>{g.stopPropagation(),i(t)},className:"flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary",title:d("fileManager.linkToProjectOrArchive"),children:a.jsx(jh,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),a.jsx("div",{className:`flex-shrink-0 flex items-center gap-0.5 transition-opacity ${l?"":"opacity-0 group-hover:opacity-100"}`,onClick:g=>g.stopPropagation(),children:a.jsxs("div",{className:"relative",children:[a.jsx("button",{onClick:()=>p(!f),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:a.jsx(Th,{className:"w-3.5 h-3.5 text-bambu-gray"})}),f&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>p(!1)}),a.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(s(t),p(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:d("fileManager.noPermissionRenameFolder"),children:[a.jsx(Ya,{className:"w-3.5 h-3.5"}),d("common.rename")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(i(t),p(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:d("fileManager.noPermissionLinkFolder"),children:[a.jsx(jh,{className:"w-3.5 h-3.5"}),d(v?"fileManager.changeLink":"fileManager.linkTo")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:delete_all")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:delete_all")&&(r(t.id),p(!1))},disabled:!c("library:delete_all"),title:c("library:delete_all")?void 0:d("fileManager.noPermissionDeleteFolder"),children:[a.jsx(Xt,{className:"w-3.5 h-3.5"}),d("common.delete")]})]})]})]})})]}),x&&u&&a.jsx("div",{children:t.children.map(g=>a.jsx(Zie,{folder:g,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o+1,wrapNames:l,hasPermission:c,t:d},g.id))})]})}function aF(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function vJe({file:t,isSelected:e,isMobile:n,onSelect:r,onDelete:i,onDownload:s,onAddToQueue:o,onPrint:l,onPreview3d:c,onRename:d,onGenerateThumbnail:u,thumbnailVersion:h,hasPermission:f,canModify:p,authEnabled:x,t:v}){const[g,y]=w.useState(!1);return a.jsxs("div",{className:`group relative bg-bambu-dark-secondary rounded-lg border transition-all cursor-pointer overflow-hidden ${e?"border-bambu-green ring-1 ring-bambu-green":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,onClick:()=>r(t.id),children:[a.jsxs("div",{className:"aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden",children:[t.thumbnail_path?a.jsx("img",{src:`${ne.getLibraryFileThumbnailUrl(t.id)}${h?`?v=${h}`:""}`,alt:t.filename,className:"w-full h-full object-cover"}):a.jsx(hf,{className:"w-12 h-12 text-bambu-gray/30"}),a.jsx("div",{className:`absolute top-2 right-2 text-xs px-1.5 py-0.5 rounded font-medium ${t.file_type==="3mf"?"bg-bambu-green/90 text-white":t.file_type==="gcode"?"bg-blue-500/90 text-white":t.file_type==="stl"?"bg-purple-500/90 text-white":"bg-bambu-gray/90 text-white"}`,children:t.file_type.toUpperCase()})]}),a.jsxs("div",{className:"p-3",children:[a.jsx("h3",{className:"text-sm font-medium text-white truncate",title:t.print_name||t.filename,children:t.print_name||t.filename}),a.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-bambu-gray",children:[a.jsx("span",{children:dl(t.file_size)}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Vn,{className:"w-3 h-3"}),Qs(t.print_time_seconds)]})]}),t.sliced_for_model&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(Sr,{className:"w-3 h-3"}),t.sliced_for_model]}),t.print_count>0&&a.jsx("div",{className:"mt-1 text-xs text-bambu-green",children:v("fileManager.printedCount",{count:t.print_count})}),x&&t.created_by_username&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(tu,{className:"w-3 h-3"}),t.created_by_username]})]}),a.jsxs("div",{className:`absolute bottom-2 right-2 transition-opacity ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:_=>_.stopPropagation(),children:[a.jsx("button",{onClick:()=>y(!g),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:a.jsx(Th,{className:"w-4 h-4 text-bambu-gray"})}),g&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>y(!1)}),a.jsxs("div",{className:"absolute right-0 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]",children:[l&&aF(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("printers:control")?"text-bambu-green hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("printers:control")&&(l(t),y(!1))},disabled:!f("printers:control"),title:f("printers:control")?void 0:v("fileManager.noPermissionPrint"),children:[a.jsx(Sr,{className:"w-3.5 h-3.5"}),v("common.print")]}),o&&aF(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("queue:create")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("queue:create")&&(o(t.id),y(!1))},disabled:!f("queue:create"),title:f("queue:create")?void 0:v("fileManager.noPermissionAddToQueue"),children:[a.jsx(Vn,{className:"w-3.5 h-3.5"}),v("fileManager.schedulePrint")]}),c&&(t.file_type==="3mf"||t.file_type==="gcode"||t.file_type==="stl")&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library:read")&&(c(t),y(!1))},disabled:!f("library:read"),title:f("library:read")?void 0:"You do not have permission to preview files",children:[a.jsx(ai,{className:"w-3.5 h-3.5"}),"3D Preview"]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library:read")&&(s(t.id),y(!1))},disabled:!f("library:read"),title:f("library:read")?void 0:v("fileManager.noPermissionDownload"),children:[a.jsx(ha,{className:"w-3.5 h-3.5"}),v("common.download")]}),d&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","update",t.created_by_id)&&(d(t),y(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:v("fileManager.noPermissionRenameFile"),children:[a.jsx(Ya,{className:"w-3.5 h-3.5"}),v("common.rename")]}),u&&t.file_type==="stl"&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","update",t.created_by_id)&&(u(t),y(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:v("fileManager.noPermissionGenerateThumbnail"),children:[a.jsx(Jd,{className:"w-3.5 h-3.5"}),v("fileManager.generateThumbnail")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","delete",t.created_by_id)?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","delete",t.created_by_id)&&(i(t.id),y(!1))},disabled:!p("library","delete",t.created_by_id),title:p("library","delete",t.created_by_id)?void 0:v("fileManager.noPermissionDeleteFile"),children:[a.jsx(Xt,{className:"w-3.5 h-3.5"}),v("common.delete")]})]})]})]}),a.jsx("div",{className:`absolute top-2 left-2 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${e?"bg-bambu-green border-bambu-green":`border-white/30 bg-black/30 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}`,children:e&&a.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function wJe(){const{t}=Dt(),e=Jt(),{showToast:n}=ln(),{hasPermission:r,hasAnyPermission:i,canModify:s,authEnabled:o}=Pr(),[l]=gF(),c=l.get("folder"),d=c?parseInt(c,10):null,[u,h]=w.useState(d),[f,p]=w.useState([]),[x,v]=w.useState(!1),[g,y]=w.useState(!1),[_,N]=w.useState(!1),[T,k]=w.useState(null),[M,C]=w.useState(null),[j,P]=w.useState(null),[E,B]=w.useState(null),[O,z]=w.useState(null),[D,$]=w.useState(null),[G,U]=w.useState({}),[W,Y]=w.useState(null),[re,H]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[K,ee]=w.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[Z,we]=w.useState(()=>{const Ue=localStorage.getItem("library-sidebar-width");return Ue?parseInt(Ue,10):256}),[oe,J]=w.useState(!1),je=w.useRef(null);w.useEffect(()=>{if(!oe)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Ue=xt=>{if(!je.current)return;const Vt=je.current.parentElement?.getBoundingClientRect();if(!Vt)return;const yn=xt.clientX-Vt.left,_r=Math.min(500,Math.max(200,yn));we(_r)},yt=()=>{J(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(Z))};return document.addEventListener("mousemove",Ue),document.addEventListener("mouseup",yt),()=>{document.removeEventListener("mousemove",Ue),document.removeEventListener("mouseup",yt),document.body.style.userSelect="",document.body.style.cursor=""}},[oe,Z]);const[de,le]=w.useState(""),[_e,se]=w.useState("all"),[ze,V]=w.useState(""),[X,me]=w.useState(()=>localStorage.getItem("library-sort-field")||"name"),[Q,ie]=w.useState(()=>localStorage.getItem("library-sort-direction")||"asc"),ue=xne();w.useEffect(()=>{const Ue=l.get("folder");if(Ue){const yt=parseInt(Ue,10);h(yt)}},[l]);const{data:Le}=Je({queryKey:["settings"],queryFn:()=>ne.getSettings()}),{data:Ce,isLoading:ge}=Je({queryKey:["library-folders"],queryFn:()=>ne.getLibraryFolders()}),{data:L,isLoading:R}=Je({queryKey:["library-files",u],queryFn:()=>ne.getLibraryFiles(u,u===null)}),{data:q}=Je({queryKey:["library-stats"],queryFn:()=>ne.getLibraryStats()}),{data:ce}=Je({queryKey:["users"],queryFn:()=>ne.getUsers()}),pe=w.useMemo(()=>{if(!L)return[];const Ue=new Set(L.map(yt=>yt.file_type));return Array.from(Ue).sort()},[L]),te=w.useMemo(()=>{if(!L)return[];let Ue=[...L];if(de.trim()){const yt=de.toLowerCase();Ue=Ue.filter(xt=>xt.filename.toLowerCase().includes(yt)||xt.print_name&&xt.print_name.toLowerCase().includes(yt))}if(_e!=="all"&&(Ue=Ue.filter(yt=>yt.file_type===_e)),ze.trim()){const yt=ze.toLowerCase();Ue=Ue.filter(xt=>xt.created_by_username&&xt.created_by_username.toLowerCase().includes(yt))}return Ue.sort((yt,xt)=>{let Vt=0;switch(X){case"name":Vt=(yt.print_name||yt.filename).localeCompare(xt.print_name||xt.filename);break;case"date":Vt=(er(yt.created_at)?.getTime()??0)-(er(xt.created_at)?.getTime()??0);break;case"size":Vt=yt.file_size-xt.file_size;break;case"type":Vt=yt.file_type.localeCompare(xt.file_type);break;case"prints":Vt=yt.print_count-xt.print_count;break}return Q==="asc"?Vt:-Vt}),Ue},[L,de,_e,ze,X,Q]),Be=w.useMemo(()=>{if(!q||!Le)return!1;const Ue=(Le.library_disk_warning_gb||5)*1024*1024*1024;return q.disk_free_bytesne.createLibraryFolder(Ue),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),v(!1),n(t("fileManager.toast.folderCreated"),"success")},onError:Ue=>n(Ue.message,"error")}),$e=st({mutationFn:Ue=>ne.deleteLibraryFolder(Ue),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-stats"]}),u===M?.id&&h(null),C(null),n(t("fileManager.toast.folderDeleted"),"success")},onError:Ue=>{C(null),n(Ue.message,"error")}}),Re=st({mutationFn:Ue=>ne.deleteLibraryFile(Ue),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),p(Ue=>Ue.filter(yt=>yt!==M?.id)),C(null),n(t("fileManager.toast.fileDeleted"),"success")},onError:Ue=>{C(null),n(Ue.message,"error")}}),fe=st({mutationFn:Ue=>ne.bulkDeleteLibrary(Ue,[]),onSuccess:(Ue,yt)=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),n(t("fileManager.toast.filesDeleted",{count:yt.length}),"success"),p([]),C(null)},onError:Ue=>{C(null),n(Ue.message,"error")}}),xe=st({mutationFn:({fileIds:Ue,folderId:yt})=>ne.moveLibraryFiles(Ue,yt),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),p([]),y(!1),n(t("fileManager.toast.filesMoved"),"success")},onError:Ue=>n(Ue.message,"error")}),Ne=st({mutationFn:({id:Ue,data:yt})=>ne.updateLibraryFolder(Ue,yt),onSuccess:(Ue,yt)=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["project-folders"]}),e.invalidateQueries({queryKey:["archive-folders"]}),k(null);const xt=yt.data.project_id===0&&yt.data.archive_id===0;n(t(xt?"fileManager.toast.folderUnlinked":"fileManager.toast.folderLinked"),"success")},onError:Ue=>n(Ue.message,"error")}),ye=st({mutationFn:({id:Ue,filename:yt})=>ne.updateLibraryFile(Ue,{filename:yt}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),$(null),n(t("fileManager.toast.fileRenamed"),"success")},onError:Ue=>{$(null),n(Ue.message,"error")}}),ve=st({mutationFn:({id:Ue,name:yt})=>ne.updateLibraryFolder(Ue,{name:yt}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),$(null),n(t("fileManager.toast.folderRenamed"),"success")},onError:Ue=>{$(null),n(Ue.message,"error")}}),Ge=st({mutationFn:()=>ne.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:Ue=>{if(e.invalidateQueries({queryKey:["library-files"]}),Ue.succeeded>0){const yt=Date.now(),xt={};Ue.results.forEach(Vt=>{Vt.success&&(xt[Vt.file_id]=yt)}),U(Vt=>({...Vt,...xt}))}Ue.succeeded>0&&Ue.failed===0?n(t("fileManager.toast.thumbnailsGenerated",{count:Ue.succeeded}),"success"):Ue.succeeded>0&&Ue.failed>0?n(t("fileManager.toast.thumbnailsGeneratedPartial",{succeeded:Ue.succeeded,failed:Ue.failed}),"success"):Ue.processed===0?n(t("fileManager.toast.noStlMissingThumbnails"),"info"):n(t("fileManager.toast.failedToGenerateThumbnails",{error:Ue.results[0]?.error||"Unknown error"}),"error")},onError:Ue=>n(Ue.message,"error")}),Te=st({mutationFn:Ue=>ne.batchGenerateStlThumbnails({file_ids:[Ue]}),onSuccess:Ue=>{if(e.invalidateQueries({queryKey:["library-files"]}),Ue.succeeded>0){const yt=Ue.results[0]?.file_id;yt&&U(xt=>({...xt,[yt]:Date.now()})),n(t("fileManager.toast.thumbnailGenerated"),"success")}else n(t("fileManager.toast.failedToGenerateThumbnail",{error:Ue.results[0]?.error||"Unknown error"}),"error")},onError:Ue=>n(Ue.message,"error")}),nt=w.useCallback(Ue=>{const yt=Ue.toLowerCase();return yt.endsWith(".gcode")||yt.includes(".gcode.")},[]),De=w.useMemo(()=>L?L.filter(Ue=>f.includes(Ue.id)&&nt(Ue.filename)):[],[L,f,nt]),Ke=w.useCallback(Ue=>{p(yt=>yt.includes(Ue)?yt.filter(xt=>xt!==Ue):[...yt,Ue])},[]),Oe=w.useCallback(()=>{te.length>0&&p(te.map(Ue=>Ue.id))},[te]),Ee=w.useCallback(()=>{p([])},[]),Ve=()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]})},ot=Ue=>{ne.downloadLibraryFile(Ue).catch(yt=>{console.error("Library file download failed:",yt)})},Ct=()=>{M&&(M.type==="file"?Re.mutate(M.id):M.type==="folder"?$e.mutate(M.id):M.type==="bulk"&&fe.mutate(f))},Lt=$e.isPending||Re.isPending||fe.isPending,Bt=Ue=>{H(Ue),localStorage.setItem("library-view-mode",Ue)},Mt=ge||R;return a.jsxs("div",{className:"p-4 md:p-8 min-h-[calc(100vh-64px)] lg:h-[calc(100vh-64px)] flex flex-col",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:a.jsx(Ql,{className:"w-6 h-6 text-bambu-green"})}),t("fileManager.title")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("fileManager.subtitle")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex items-center bg-bambu-dark rounded-lg p-1",children:[a.jsx("button",{onClick:()=>Bt("grid"),className:`p-1.5 rounded transition-colors ${re==="grid"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.gridView"),children:a.jsx(u0,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>Bt("list"),className:`p-1.5 rounded transition-colors ${re==="list"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.listView"),children:a.jsx(qC,{className:"w-4 h-4"})})]}),a.jsxs(Me,{variant:"secondary",onClick:()=>Ge.mutate(),disabled:Ge.isPending||!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?t("fileManager.generateThumbnailsForMissing"):t("fileManager.noPermissionGenerateThumbnail"),children:[Ge.isPending?a.jsx(at,{className:"w-4 h-4 mr-2 animate-spin"}):a.jsx(Jd,{className:"w-4 h-4 mr-2"}),t("fileManager.generateThumbnails")]}),a.jsxs(Me,{variant:"secondary",onClick:()=>v(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionCreateFolder"),children:[a.jsx(wme,{className:"w-4 h-4 mr-2"}),t("fileManager.newFolder")]}),a.jsxs(Me,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(La,{className:"w-4 h-4 mr-2"}),t("common.upload")]})]})]}),Be&&q&&Le&&a.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[a.jsx(An,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-amber-500 font-medium",children:t("fileManager.lowDiskSpaceWarning")}),a.jsx("p",{className:"text-xs text-amber-500/80",children:t("fileManager.lowDiskSpaceDetails",{free:dl(q.disk_free_bytes),total:dl(q.disk_total_bytes),threshold:Le.library_disk_warning_gb})})]})]}),q&&a.jsxs("div",{className:"flex flex-wrap items-center gap-3 sm:gap-6 mb-6 p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(HC,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.files"),":"]}),a.jsx("span",{className:"text-white font-medium",children:q.total_files})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Ql,{className:"w-4 h-4 text-blue-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.folders"),":"]}),a.jsx("span",{className:"text-white font-medium",children:q.total_folders})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx($b,{className:"w-4 h-4 text-amber-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.size"),":"]}),a.jsx("span",{className:"text-white font-medium",children:dl(q.total_size_bytes)})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm sm:ml-auto",children:[a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.free"),":"]}),a.jsx("span",{className:`font-medium ${Be?"text-amber-500":"text-white"}`,children:dl(q.disk_free_bytes)})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-4 lg:gap-6 min-h-0",children:[a.jsx("div",{className:"lg:hidden",children:a.jsxs("select",{value:u??"",onChange:Ue=>h(Ue.target.value?parseInt(Ue.target.value,10):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg px-3 py-2.5 text-white focus:outline-none focus:border-bambu-green",children:[a.jsxs("option",{value:"",children:["📁 ",t("fileManager.allFiles")]}),Ce&&(()=>{const Ue=(yt,xt=0)=>{const Vt=[];for(const yn of yt)Vt.push({id:yn.id,name:yn.name,fileCount:yn.file_count,depth:xt}),yn.children.length>0&&Vt.push(...Ue(yn.children,xt+1));return Vt};return Ue(Ce).map(yt=>a.jsxs("option",{value:yt.id,children:["│ ".repeat(yt.depth),"📂 ",yt.name," ",yt.fileCount>0?`(${yt.fileCount})`:""]},yt.id))})()]})}),a.jsxs("div",{ref:je,className:"hidden lg:flex flex-shrink-0 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden flex-col relative",style:{width:`${Z}px`},children:[a.jsx("div",{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 group/resize flex items-center justify-center transition-colors ${oe?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:Ue=>{Ue.preventDefault(),J(!0)},onDoubleClick:()=>{we(256),localStorage.setItem("library-sidebar-width","256")},title:t("fileManager.dragToResizeTooltip"),children:a.jsxs("div",{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${oe?"opacity-100":""}`,children:[a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"})]})}),a.jsxs("div",{className:"p-3 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsx("h2",{className:"text-sm font-medium text-white",children:t("fileManager.folders")}),a.jsx("button",{onClick:()=>{const Ue=!K;ee(Ue),localStorage.setItem("library-wrap-folders",String(Ue))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${K?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:t(K?"fileManager.disableTextWrapping":"fileManager.enableTextWrapping"),children:t("fileManager.wrap")})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[a.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${u===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>h(null),children:[a.jsx(hf,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:t("fileManager.allFiles")})]}),Ce?.map(Ue=>a.jsx(Zie,{folder:Ue,selectedFolderId:u,onSelect:h,onDelete:yt=>C({type:"folder",id:yt}),onLink:k,onRename:yt=>$({type:"folder",id:yt.id,name:yt.name}),wrapNames:K,hasPermission:r,t},Ue.id))]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[L&&L.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mb-4 p-2 sm:p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-0 z-10 lg:static",children:[a.jsxs("div",{className:"relative w-full sm:w-auto sm:flex-1 sm:max-w-xs",children:[a.jsx(Mr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:t("fileManager.searchFiles"),value:de,onChange:Ue=>le(Ue.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx($C,{className:"w-4 h-4 text-bambu-gray hidden sm:block"}),a.jsxs("select",{value:_e,onChange:Ue=>se(Ue.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"all",children:t("fileManager.allTypes")}),pe.map(Ue=>a.jsx("option",{value:Ue,children:Ue.toUpperCase()},Ue))]})]}),o&&a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",placeholder:t("fileManager.filterByUser",{defaultValue:"Filter by user"}),value:ze,onChange:Ue=>V(Ue.target.value),list:"usernames-list",className:`w-32 sm:w-40 px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green ${ze?"pr-7":""}`,style:ze?{WebkitAppearance:"none",MozAppearance:"textfield"}:void 0}),ze&&a.jsx("button",{onClick:()=>V(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white z-10",children:a.jsx(Rt,{className:"w-3 h-3"})}),a.jsx("datalist",{id:"usernames-list",children:ce?.map(Ue=>a.jsx("option",{value:Ue.username},Ue.id))})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{value:X,onChange:Ue=>{const yt=Ue.target.value;me(yt),localStorage.setItem("library-sort-field",yt)},className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"name",children:t("common.name")}),a.jsx("option",{value:"date",children:t("common.date")}),a.jsx("option",{value:"size",children:t("fileManager.size")}),a.jsx("option",{value:"type",children:t("common.type")}),a.jsx("option",{value:"prints",children:t("fileManager.prints")})]}),a.jsx("button",{onClick:()=>ie(Ue=>{const yt=Ue==="asc"?"desc":"asc";return localStorage.setItem("library-sort-direction",yt),yt}),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:t(Q==="asc"?"fileManager.ascending":"fileManager.descending"),children:Q==="asc"?a.jsx(zue,{className:"w-4 h-4 text-white"}):a.jsx(jue,{className:"w-4 h-4 text-white"})})]}),(de||_e!=="all"||ze)&&a.jsx("span",{className:"text-sm text-bambu-gray hidden sm:inline",children:t("fileManager.resultsCount",{showing:te.length,total:L.length})})]}),te.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4 p-2 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-[52px] z-10 lg:static",children:[f.length===te.length&&f.length>0?a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Ee,children:[a.jsx(vl,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.deselectAll")})]}):a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Oe,children:[a.jsx(oo,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.selectAll")})]}),f.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-bambu-gray ml-2",children:t("fileManager.selected",{count:f.length})}),a.jsx("div",{className:"hidden sm:block flex-1"}),a.jsxs("div",{className:"w-full sm:w-auto flex flex-wrap items-center gap-2 mt-2 sm:mt-0",children:[De.length===1&&a.jsxs(Me,{variant:"primary",size:"sm",onClick:()=>B(De[0]),disabled:!r("printers:control"),title:r("printers:control")?void 0:t("fileManager.noPermissionPrint"),children:[a.jsx(io,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.print")})]}),De.length===1&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>z(De[0]),disabled:!r("queue:create"),title:r("queue:create")?void 0:t("fileManager.noPermissionAddToQueue"),children:[a.jsx(Vn,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.schedulePrint")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>y(!0),disabled:!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?void 0:t("fileManager.noPermissionMoveFiles"),children:[a.jsx(Pfe,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.move")})]}),a.jsxs(Me,{variant:"danger",size:"sm",onClick:()=>{f.length===1?C({type:"file",id:f[0]}):C({type:"bulk",id:0,count:f.length})},disabled:!i("library:delete_own","library:delete_all"),title:i("library:delete_own","library:delete_all")?void 0:t("fileManager.noPermissionDeleteFiles"),children:[a.jsx(Xt,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.delete")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Ee,children:[a.jsx(Rt,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.clear")})]})]})]})]}),Mt?a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(at,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("fileManager.loadingFiles")})]})}):L?.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(hf,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t(u!==null?"fileManager.folderIsEmpty":"fileManager.noFilesYet")}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t(u!==null?"fileManager.folderEmptyDescription":"fileManager.noFilesDescription")}),a.jsxs(Me,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(Xn,{className:"w-4 h-4 mr-2"}),t("fileManager.uploadFiles")]})]}):te.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(Mr,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t("fileManager.noMatchingFiles")}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t("fileManager.noMatchingFilesDescription")}),a.jsx(Me,{variant:"secondary",onClick:()=>{le(""),se("all")},children:t("fileManager.clearFilters")})]}):re==="grid"?a.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4",children:te.map(Ue=>a.jsx(vJe,{file:Ue,isSelected:f.includes(Ue.id),isMobile:ue,t,onSelect:Ke,onDelete:yt=>C({type:"file",id:yt}),onDownload:ot,onAddToQueue:yt=>{const xt=L?.find(Vt=>Vt.id===yt);xt&&z(xt)},onPrint:P,onPreview3d:Y,onRename:yt=>$({type:"file",id:yt.id,name:yt.filename}),onGenerateThumbnail:yt=>Te.mutate(yt.id),thumbnailVersion:G[Ue.id],hasPermission:r,canModify:s,authEnabled:o},Ue.id))})}):a.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsxs("div",{className:`hidden sm:grid ${o?"grid-cols-[auto_1fr_120px_100px_100px_100px_80px]":"grid-cols-[auto_1fr_100px_100px_100px_80px]"} gap-4 px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary text-xs text-bambu-gray font-medium`,children:[a.jsx("div",{className:"w-6"}),a.jsx("div",{children:t("common.name")}),o&&a.jsx("div",{children:t("fileManager.uploadedBy",{defaultValue:"Uploaded By"})}),a.jsx("div",{children:t("common.type")}),a.jsx("div",{children:t("fileManager.size")}),a.jsx("div",{children:t("fileManager.prints")}),a.jsx("div",{})]}),te.map(Ue=>a.jsxs("div",{className:`grid ${o?"grid-cols-[auto_1fr_120px_100px_100px_100px_80px]":"grid-cols-[auto_1fr_100px_100px_100px_80px]"} gap-4 px-4 py-3 items-center border-b border-bambu-dark-tertiary last:border-b-0 cursor-pointer hover:bg-bambu-dark/50 transition-colors ${f.includes(Ue.id)?"bg-bambu-green/10":""}`,onClick:()=>Ke(Ue.id),children:[a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${f.includes(Ue.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:f.includes(Ue.id)&&a.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})}),a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsxs("div",{className:"relative group/thumb",children:[a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden",children:Ue.thumbnail_path?a.jsx("img",{src:`${ne.getLibraryFileThumbnailUrl(Ue.id)}${G[Ue.id]?`?v=${G[Ue.id]}`:""}`,alt:"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx(hf,{className:"w-5 h-5 text-bambu-gray/50"})})}),Ue.thumbnail_path&&a.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:a.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:a.jsx("img",{src:`${ne.getLibraryFileThumbnailUrl(Ue.id)}${G[Ue.id]?`?v=${G[Ue.id]}`:""}`,alt:Ue.filename,className:"w-full h-full object-contain"})})})]}),a.jsx("div",{className:"min-w-0",children:a.jsx("div",{className:"text-sm text-white truncate",children:Ue.print_name||Ue.filename})})]}),o&&a.jsx("div",{className:"text-sm text-bambu-gray flex items-center gap-1",children:Ue.created_by_username?a.jsxs(a.Fragment,{children:[a.jsx(tu,{className:"w-3 h-3"}),a.jsx("span",{className:"truncate",children:Ue.created_by_username})]}):"-"}),a.jsx("div",{children:a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${Ue.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":Ue.file_type==="gcode"?"bg-blue-500/20 text-blue-400":Ue.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:Ue.file_type.toUpperCase()})}),a.jsx("div",{className:"text-sm text-bambu-gray",children:dl(Ue.file_size)}),a.jsx("div",{className:"text-sm text-bambu-gray",children:Ue.print_count>0?`${Ue.print_count}x`:"-"}),a.jsxs("div",{className:"flex items-center gap-1",onClick:yt=>yt.stopPropagation(),children:[aF(Ue.filename)&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>r("printers:control")&&P(Ue),className:`p-1.5 rounded transition-colors ${r("printers:control")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("printers:control")?t("common.print"):t("fileManager.noPermissionPrint"),disabled:!r("printers:control"),children:a.jsx(Sr,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{r("queue:create")&&z(Ue)},className:`p-1.5 rounded transition-colors ${r("queue:create")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("queue:create")?t("fileManager.schedulePrint"):t("fileManager.noPermissionAddToQueue"),disabled:!r("queue:create"),children:a.jsx(Vn,{className:"w-4 h-4"})})]}),(Ue.file_type==="3mf"||Ue.file_type==="gcode"||Ue.file_type==="stl")&&a.jsx("button",{onClick:()=>r("library:read")&&Y(Ue),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?"3D Preview":"You do not have permission to preview files",disabled:!r("library:read"),children:a.jsx(ai,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>r("library:read")&&ot(Ue.id),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?t("common.download"):t("fileManager.noPermissionDownload"),disabled:!r("library:read"),children:a.jsx(ha,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","update",Ue.created_by_id)&&$({type:"file",id:Ue.id,name:Ue.filename}),className:`p-1.5 rounded transition-colors ${s("library","update",Ue.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",Ue.created_by_id)?t("common.rename"):t("fileManager.noPermissionRenameFile"),disabled:!s("library","update",Ue.created_by_id),children:a.jsx(Ya,{className:"w-4 h-4"})}),Ue.file_type==="stl"&&a.jsx("button",{onClick:()=>s("library","update",Ue.created_by_id)&&Te.mutate(Ue.id),className:`p-1.5 rounded transition-colors ${s("library","update",Ue.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",Ue.created_by_id)?t("fileManager.generateThumbnail"):t("fileManager.noPermissionGenerateThumbnail"),disabled:Te.isPending||!s("library","update",Ue.created_by_id),children:a.jsx(Jd,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","delete",Ue.created_by_id)&&C({type:"file",id:Ue.id}),className:`p-1.5 rounded transition-colors ${s("library","delete",Ue.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","delete",Ue.created_by_id)?t("common.delete"):t("fileManager.noPermissionDeleteFile"),disabled:!s("library","delete",Ue.created_by_id),children:a.jsx(Xt,{className:"w-4 h-4"})})]})]},Ue.id))]})})]})]}),x&&a.jsx(pJe,{parentId:u,onClose:()=>v(!1),onSave:Ue=>Ie.mutate(Ue),isLoading:Ie.isPending,t}),g&&Ce&&a.jsx(bJe,{folders:Ce,selectedFiles:f,currentFolderId:u,onClose:()=>y(!1),onMove:Ue=>xe.mutate({fileIds:f,folderId:Ue}),isLoading:xe.isPending,t}),_&&a.jsx(yJe,{folderId:u,onClose:()=>N(!1),onUploadComplete:Ve,t}),T&&a.jsx(xJe,{folder:T,onClose:()=>k(null),onLink:Ue=>Ne.mutate({id:T.id,data:Ue}),isLoading:Ne.isPending,t}),M&&a.jsx(xn,{title:M.type==="folder"?t("fileManager.deleteFolder"):M.type==="bulk"?t("fileManager.deleteFilesCount",{count:M.count}):t("fileManager.deleteFile"),message:M.type==="folder"?t("fileManager.deleteFolderConfirm"):M.type==="bulk"?t("fileManager.deleteFilesConfirm",{count:M.count}):t("fileManager.deleteFileConfirm"),confirmText:t("common.delete"),variant:"danger",isLoading:Lt,loadingText:t("fileManager.deleting"),onConfirm:Ct,onCancel:()=>C(null)}),j&&a.jsx(Yd,{mode:"reprint",libraryFileId:j.id,archiveName:j.print_name||j.filename,onClose:()=>P(null),onSuccess:()=>{P(null),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),E&&a.jsx(Yd,{mode:"reprint",libraryFileId:E.id,archiveName:E.print_name||E.filename,onClose:()=>B(null),onSuccess:()=>{B(null),p([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),O&&a.jsx(Yd,{mode:"add-to-queue",libraryFileId:O.id,archiveName:O.print_name||O.filename,onClose:()=>z(null),onSuccess:()=>{z(null),p([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["queue"]}),e.invalidateQueries({queryKey:["archives"]})}}),W&&a.jsx(g4,{libraryFileId:W.id,title:W.print_name||W.filename,fileType:W.file_type,onClose:()=>Y(null)}),D&&a.jsx(gJe,{type:D.type,currentName:D.name,onClose:()=>$(null),onSave:Ue=>{D.type==="file"?ye.mutate({id:D.id,filename:Ue}):ve.mutate({id:D.id,name:Ue})},isLoading:ye.isPending||ve.isPending,t})]})}const Rj=5,SJe=2e3,_Je=3e4,NJe=5e3;function CJe(){const{t}=Dt(),e=Jt(),{showToast:n}=ln(),{hasPermission:r}=Pr(),{printerId:i}=o0(),s=parseInt(i||"0",10),[o,l]=w.useState("stream"),[c,d]=w.useState(!1),[u,h]=w.useState(!1),[f,p]=w.useState(!0),[x,v]=w.useState(Date.now()),[g,y]=w.useState(!1),[_,N]=w.useState(!1),[T,k]=w.useState(0),[M,C]=w.useState(!1),[j,P]=w.useState(0),[E,B]=w.useState(1),[O,z]=w.useState({x:0,y:0}),[D,$]=w.useState(!1),[G,U]=w.useState({x:0,y:0}),[W,Y]=w.useState(null),[re,H]=w.useState(null),K=w.useRef(null),ee=w.useRef(null),Z=w.useRef(null),we=w.useRef(null),oe=w.useRef(null),{data:J}=Je({queryKey:["printer",s],queryFn:()=>ne.getPrinter(s),enabled:s>0}),{data:je}=Je({queryKey:["printerStatus",s],queryFn:()=>ne.getPrinterStatus(s),refetchInterval:3e4,enabled:s>0}),de=st({mutationFn:xe=>ne.setChamberLight(s,xe),onMutate:async xe=>{await e.cancelQueries({queryKey:["printerStatus",s]});const Ne=e.getQueryData(["printerStatus",s]);return e.setQueryData(["printerStatus",s],ye=>({...ye,chamber_light:xe})),{previousStatus:Ne}},onSuccess:(xe,Ne)=>{n(`Chamber light ${Ne?"on":"off"}`)},onError:(xe,Ne,ye)=>{ye?.previousStatus&&e.setQueryData(["printerStatus",s],ye.previousStatus),n(xe.message||t("printers.toast.failedToControlChamberLight"),"error")}}),le=(je?.state==="RUNNING"||je?.state==="PAUSE")&&(je?.printable_objects_count??0)>=2;w.useEffect(()=>(J&&(document.title=`${J.name} - Camera`),()=>{document.title="Bambuddy"}),[J]);const _e=w.useRef(!1);w.useEffect(()=>{const xe=`/api/v1/printers/${s}/camera/stop`;_e.current=!1;const Ne=()=>{if(s>0&&!_e.current){_e.current=!0;const Ge={},Te=ru();Te&&(Ge.Authorization=`Bearer ${Te}`),fetch(xe,{method:"POST",keepalive:!0,headers:Ge}).catch(()=>{})}},ye=()=>{Ne()};window.addEventListener("beforeunload",ye);const ve=K.current;return()=>{window.removeEventListener("beforeunload",ye),ve&&(ve.src=""),Ne()}},[s]),w.useEffect(()=>{if(f&&!g){const Ne=setTimeout(()=>{p(!1)},o==="stream"?3e3:2e4);return()=>clearTimeout(Ne)}},[o,f,x,g]),w.useEffect(()=>{const xe=()=>{const Ne=!!document.fullscreenElement;N(Ne),B(1),z({x:0,y:0}),o==="stream"&&!g&&(K.current&&(K.current.src=""),setTimeout(()=>{p(!0),v(Date.now())},200))};return document.addEventListener("fullscreenchange",xe),()=>document.removeEventListener("fullscreenchange",xe)},[o,g]),w.useEffect(()=>{let xe;const Ne=()=>{clearTimeout(xe),xe=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",Ne),()=>{clearTimeout(xe),window.removeEventListener("resize",Ne)}},[]),w.useEffect(()=>()=>{Z.current&&clearTimeout(Z.current),we.current&&clearInterval(we.current),oe.current&&clearInterval(oe.current)},[]);const se=w.useCallback(()=>{if(T>=Rj){C(!1),h(!0);return}const xe=Math.min(SJe*Math.pow(2,T),_Je);C(!0),P(Math.ceil(xe/1e3)),we.current=setInterval(()=>{P(Ne=>Ne<=1?(we.current&&clearInterval(we.current),0):Ne-1)},1e3),Z.current=setTimeout(()=>{k(Ne=>Ne+1),C(!1),p(!0),h(!1),K.current&&(K.current.src=""),v(Date.now())},xe)},[T]);w.useEffect(()=>{if(o!=="stream"||f||M||g){oe.current&&(clearInterval(oe.current),oe.current=null);return}return oe.current=setInterval(async()=>{try{const xe=await ne.getCameraStatus(s);(xe.stalled||!xe.active&&!u)&&(console.log(`Stream issue detected: stalled=${xe.stalled}, active=${xe.active}, reconnecting...`),oe.current&&(clearInterval(oe.current),oe.current=null),p(!1),se())}catch{}},NJe),()=>{oe.current&&(clearInterval(oe.current),oe.current=null)}},[o,f,u,M,g,s,se]);const ze=()=>{p(!1),o==="stream"&&T{if(p(!1),h(!1),k(0),C(!1),Z.current&&clearTimeout(Z.current),we.current&&clearInterval(we.current),K.current&&!localStorage.getItem("cameraWindowState")){const xe=K.current,Ne=xe.naturalWidth,ye=xe.naturalHeight;if(Ne>0&&ye>0){const Te=window.outerWidth-window.innerWidth,nt=window.outerHeight-window.innerHeight,De=Ne+16+Te,Ke=ye+45+16+nt;try{window.resizeTo(De,Ke)}catch{}}}},X=()=>{if(s>0){const xe={},Ne=ru();Ne&&(xe.Authorization=`Bearer ${Ne}`),fetch(`/api/v1/printers/${s}/camera/stop`,{method:"POST",headers:xe}).catch(()=>{})}},me=xe=>{o===xe||g||(y(!0),p(!0),h(!1),k(0),C(!1),B(1),z({x:0,y:0}),Z.current&&clearTimeout(Z.current),we.current&&clearInterval(we.current),K.current&&(K.current.src=""),o==="stream"&&X(),setTimeout(()=>{l(xe),v(Date.now()),y(!1)},100))},Q=()=>{g||(y(!0),p(!0),h(!1),k(0),C(!1),Z.current&&clearTimeout(Z.current),we.current&&clearInterval(we.current),K.current&&(K.current.src=""),o==="stream"&&X(),setTimeout(()=>{v(Date.now()),y(!1)},100))},ie=()=>{ee.current&&(document.fullscreenElement?document.exitFullscreen():ee.current.requestFullscreen())},ue=()=>{B(xe=>Math.min(xe+.5,4))},Le=()=>{B(xe=>{const Ne=Math.max(xe-.5,1);return Ne===1&&z({x:0,y:0}),Ne})},Ce=xe=>{xe.preventDefault(),xe.deltaY<0?ue():Le()},ge=xe=>{E>1&&(xe.preventDefault(),$(!0),U({x:xe.clientX-O.x,y:xe.clientY-O.y}))},L=w.useCallback(()=>{if(!ee.current)return{x:300,y:200};const xe=ee.current.getBoundingClientRect(),Ne=xe.width*(E-1)/2,ye=xe.height*(E-1)/2;return{x:Math.max(50,Ne),y:Math.max(50,ye)}},[E]),R=xe=>{if(D&&E>1){const Ne=xe.clientX-G.x,ye=xe.clientY-G.y,ve=L();z({x:Math.max(-ve.x,Math.min(ve.x,Ne)),y:Math.max(-ve.y,Math.min(ve.y,ye))})}},q=()=>{$(!1)},ce=xe=>{if(xe.length<2)return 0;const Ne=xe[0].clientX-xe[1].clientX,ye=xe[0].clientY-xe[1].clientY;return Math.sqrt(Ne*Ne+ye*ye)},pe=xe=>xe.length<2?{x:xe[0].clientX,y:xe[0].clientY}:{x:(xe[0].clientX+xe[1].clientX)/2,y:(xe[0].clientY+xe[1].clientY)/2},te=xe=>{xe.touches.length===2?(xe.preventDefault(),Y(ce(xe.touches)),H(pe(xe.touches))):xe.touches.length===1&&E>1&&(xe.preventDefault(),$(!0),U({x:xe.touches[0].clientX-O.x,y:xe.touches[0].clientY-O.y}))},Be=xe=>{if(xe.touches.length===2&&W!==null){xe.preventDefault();const Ne=ce(xe.touches),ye=Ne/W;B(Ge=>{const Te=Math.max(1,Math.min(4,Ge*ye));return Te===1&&z({x:0,y:0}),Te}),Y(Ne);const ve=pe(xe.touches);if(re){const Ge=L();z(Te=>({x:Math.max(-Ge.x,Math.min(Ge.x,Te.x+(ve.x-re.x))),y:Math.max(-Ge.y,Math.min(Ge.y,Te.y+(ve.y-re.y)))}))}H(ve)}else if(xe.touches.length===1&&D&&E>1){xe.preventDefault();const Ne=xe.touches[0].clientX-G.x,ye=xe.touches[0].clientY-G.y,ve=L();z({x:Math.max(-ve.x,Math.min(ve.x,Ne)),y:Math.max(-ve.y,Math.min(ve.y,ye))})}},Ie=xe=>{xe.touches.length<2&&(Y(null),H(null)),xe.touches.length===0&&$(!1)},$e=()=>{B(1),z({x:0,y:0})},Re=g?"":o==="stream"?`/api/v1/printers/${s}/camera/stream?fps=15&t=${x}`:`/api/v1/printers/${s}/camera/snapshot?t=${x}`,fe=f||g||M;return s?a.jsxs("div",{ref:ee,className:"min-h-screen bg-black flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[a.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a.jsx(cb,{className:"w-4 h-4"}),J?.name||`Printer ${s}`]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[a.jsx("button",{onClick:()=>me("stream"),disabled:fe,className:`px-3 py-1 text-xs rounded transition-colors ${o==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.live")}),a.jsx("button",{onClick:()=>me("snapshot"),disabled:fe,className:`px-3 py-1 text-xs rounded transition-colors ${o==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.snapshot")})]}),a.jsx("button",{onClick:()=>de.mutate(!je?.chamber_light),disabled:!je?.connected||de.isPending||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${je?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30":"hover:bg-bambu-dark-tertiary"}`,title:r("printers:control")?t("camera.chamberLight"):t("printers.permission.noControl"),children:a.jsx(lL,{on:je?.chamber_light??!1,className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>d(!0),disabled:!le||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${le&&r("printers:control")?"hover:bg-bambu-dark-tertiary":""}`,title:r("printers:control")?t(le?"printers.skipObjects.tooltip":"printers.skipObjects.onlyWhilePrinting"):t("printers.permission.noControl"),children:a.jsx(uk,{className:"w-4 h-4 text-bambu-gray"})}),a.jsx("button",{onClick:Q,disabled:fe,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:t(o==="stream"?"camera.restartStream":"camera.refreshSnapshot"),children:a.jsx(vr,{className:`w-4 h-4 text-bambu-gray ${fe?"animate-spin":""}`})}),a.jsx("button",{onClick:ie,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:t(_?"camera.exitFullscreen":"camera.fullscreen"),children:_?a.jsx(yY,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(xfe,{className:"w-4 h-4 text-bambu-gray"})})]})]}),a.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:Ce,onMouseMove:R,onMouseUp:q,onMouseLeave:q,onTouchStart:te,onTouchMove:Be,onTouchEnd:Ie,style:{touchAction:"none"},children:a.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(f||g)&&!M&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:a.jsxs("div",{className:"text-center",children:[a.jsx(vr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t(o==="stream"?"camera.connectingToCamera":"camera.capturingSnapshot")})]})}),M&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:a.jsxs("div",{className:"text-center p-4",children:[a.jsx(qh,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:t("camera.connectionLost")}),a.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:t("camera.reconnecting",{countdown:j,attempt:T+1,max:Rj})}),a.jsx("button",{onClick:Q,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.reconnectNow")})]})}),u&&!M&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:a.jsxs("div",{className:"text-center p-4",children:[a.jsx(An,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:t("camera.cameraUnavailable")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:t("camera.cameraUnavailableDesc")}),a.jsx("button",{onClick:Q,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.retry")})]})}),a.jsx("img",{ref:K,src:Re,alt:t("camera.cameraStream"),className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${E}) translate(${O.x/E}px, ${O.y/E}px)`,cursor:E>1?D?"grabbing":"grab":"default"},onError:Re?ze:void 0,onLoad:Re?V:void 0,onMouseDown:ge,draggable:!1},x),a.jsxs("div",{className:"absolute bottom-4 left-4 flex items-center gap-1.5 bg-black/60 rounded-lg px-2 py-1.5",children:[a.jsx("button",{onClick:Le,disabled:E<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomOut"),children:a.jsx(jF,{className:"w-4 h-4 text-white"})}),a.jsxs("button",{onClick:$e,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:t("camera.resetZoom"),children:[Math.round(E*100),"%"]}),a.jsx("button",{onClick:ue,disabled:E>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomIn"),children:a.jsx(EF,{className:"w-4 h-4 text-white"})})]})]})}),a.jsx(cL,{printerId:s,isOpen:c,onClose:()=>d(!1)})]}):a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-white",children:t("camera.invalidPrinterId")})})}function kJe(t){const e=t.get("show")?.split(",")||["progress","layers","eta","filename","status"],n=parseInt(t.get("fps")||"15",10),r=Math.min(Math.max(isNaN(n)?15:n,1),30),i=t.get("camera"),s=i!=="false"&&i!=="0";return{size:t.get("size")||"medium",fps:r,showCamera:s,showProgress:e.includes("progress"),showLayers:e.includes("layers"),showEta:e.includes("eta"),showFilename:e.includes("filename"),showStatus:e.includes("status"),showPrinter:e.includes("printer")}}function AJe(t,e){if(t.stg_cur_name)return t.stg_cur_name;switch(t.state){case"RUNNING":return e("streamOverlay.status.printing");case"PAUSE":return e("streamOverlay.status.paused");case"FINISH":return e("streamOverlay.status.finished");case"FAILED":return e("streamOverlay.status.failed");case"IDLE":return e("streamOverlay.status.idle");default:return t.state||e("streamOverlay.status.unknown")}}function TJe(t){switch(t){case"small":return{container:"p-3",text:"text-sm",textLarge:"text-lg",progressHeight:"h-2",icon:"w-3 h-3",gap:"gap-2",logoHeight:"h-12"};case"large":return{container:"p-6",text:"text-xl",textLarge:"text-3xl",progressHeight:"h-4",icon:"w-6 h-6",gap:"gap-4",logoHeight:"h-24"};default:return{container:"p-4",text:"text-base",textLarge:"text-xl",progressHeight:"h-3",icon:"w-4 h-4",gap:"gap-3",logoHeight:"h-16"}}}function MJe(){const{printerId:t}=o0(),[e]=gF(),{t:n}=Dt(),r=Jt(),i=parseInt(t||"0",10),[s,o]=w.useState(Date.now()),l=w.useMemo(()=>kJe(e),[e]),c=TJe(l.size),{data:d}=Je({queryKey:["printer",i],queryFn:()=>ne.getPrinter(i),enabled:i>0}),{data:u}=Je({queryKey:["printerStatus",i],queryFn:()=>ne.getPrinterStatus(i),enabled:i>0,refetchInterval:2e3}),{data:h}=Je({queryKey:["settings"],queryFn:ne.getSettings}),f=h?.time_format||"system";w.useEffect(()=>{if(!i)return;const _=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,N=new WebSocket(_);return N.onmessage=T=>{try{const k=JSON.parse(T.data);k.type==="printer_status"&&k.printer_id===i&&r.setQueryData(["printerStatus",i],k.status)}catch{}},N.onerror=()=>{},()=>{N.close()}},[i,r]),w.useEffect(()=>(document.title=d?`${d.name} - ${n("streamOverlay.title")}`:n("streamOverlay.title"),()=>{document.title="Bambuddy"}),[d,n]);const p=()=>{setTimeout(()=>{o(Date.now())},3e3)};if(!i)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-white",children:n("streamOverlay.invalidPrinterId")})});if(!u)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-gray-400",children:n("common.loading")})});const x=u.state==="RUNNING"||u.state==="PAUSE",v=u.progress||0,g=`/api/v1/printers/${i}/camera/stream?fps=${l.fps}&t=${s}`;return a.jsxs("div",{className:"min-h-screen bg-black relative overflow-hidden",children:[l.showCamera&&a.jsx("img",{src:g,alt:n("streamOverlay.cameraStream"),className:"absolute inset-0 w-full h-full object-contain",onError:p},s),a.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"absolute top-4 right-4 z-10",children:a.jsx("img",{src:"/img/bambuddy_logo_dark_transparent.png",alt:"Bambuddy",className:`${c.logoHeight} object-contain drop-shadow-lg hover:scale-105 transition-transform`})}),a.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-10 bg-gradient-to-t from-black/80 via-black/60 to-transparent",children:a.jsxs("div",{className:`${c.container}`,children:[l.showPrinter&&d&&a.jsxs("div",{className:`flex items-center ${c.gap} mb-2`,children:[a.jsx(Sr,{className:`${c.icon} text-white/70`}),a.jsx("span",{className:`${c.text} text-white font-medium`,children:d.name})]}),l.showFilename&&u.current_print&&a.jsx("div",{className:`${c.textLarge} text-white font-semibold mb-2 truncate drop-shadow-md`,children:u.current_print.replace(/\.gcode\.3mf$|\.3mf$|\.gcode$/i,"")}),l.showStatus&&a.jsx("div",{className:`${c.text} text-white/70 mb-2`,children:AJe(u,n)}),l.showProgress&&x&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:`flex items-center justify-between mb-1 ${c.text}`,children:[a.jsx("span",{className:"text-white/70",children:n("streamOverlay.progress")}),a.jsxs("span",{className:"text-white font-bold",children:[Math.round(v),"%"]})]}),a.jsx("div",{className:`w-full bg-white/20 rounded-full ${c.progressHeight}`,children:a.jsx("div",{className:`bg-bambu-green ${c.progressHeight} rounded-full transition-all duration-500`,style:{width:`${v}%`}})})]}),x&&(l.showLayers||l.showEta)&&a.jsxs("div",{className:`flex items-center ${c.gap} flex-wrap`,children:[l.showLayers&&u.layer_num!=null&&u.total_layers!=null&&u.total_layers>0&&a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(oi,{className:c.icon}),a.jsxs("span",{className:c.text,children:[a.jsx("span",{className:"text-white",children:u.layer_num}),a.jsx("span",{className:"mx-1",children:"/"}),a.jsx("span",{children:u.total_layers})]})]}),l.showEta&&u.remaining_time!=null&&u.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(Ld,{className:c.icon}),a.jsx("span",{className:`${c.text} text-white`,children:Qs(u.remaining_time*60)})]}),a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(Vn,{className:c.icon}),a.jsxs("span",{className:`${c.text} text-white`,children:[n("streamOverlay.eta")," ",DF(u.remaining_time,f,n)]})]})]})]}),!x&&a.jsx("div",{className:`${c.text} text-white/70 py-2`,children:u.connected?n("streamOverlay.printerIdle"):n("streamOverlay.printerOffline")})]})})]})}function PJe(){const{t}=Dt(),{id:e}=o0(),{mode:n}=ep(),{data:r,isLoading:i,error:s}=Je({queryKey:["external-link",e],queryFn:()=>ne.getExternalLink(Number(e)),enabled:!!e});return i?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s||!r?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[a.jsx(An,{className:"w-12 h-12"}),a.jsx("p",{children:t("common.linkNotFound")})]}):a.jsx("iframe",{src:r.url,className:"h-full w-full border-0",style:{colorScheme:n},title:r.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}function sK(){const{id:t}=o0(),e=nc(),n=Jt(),{t:r}=Dt(),{showToast:i}=ln(),s=!!t,[o,l]=w.useState(""),[c,d]=w.useState(""),[u,h]=w.useState([]),[f,p]=w.useState(""),[x,v]=w.useState(!1),{data:g,isLoading:y}=Je({queryKey:["group",t],queryFn:()=>ne.getGroup(Number(t)),enabled:s}),{data:_,isLoading:N}=Je({queryKey:["permissions"],queryFn:()=>ne.getPermissions()});s&&g&&!x&&(l(g.name),d(g.description||""),h(g.permissions),v(!0));const T=st({mutationFn:U=>ne.createGroup(U),onSuccess:()=>{n.invalidateQueries({queryKey:["groups"]}),i(r("groups.toast.created")),e("/settings?tab=users")},onError:U=>{i(U.message,"error")}}),k=st({mutationFn:U=>ne.updateGroup(Number(t),U),onSuccess:()=>{n.invalidateQueries({queryKey:["groups"]}),i(r("groups.toast.updated")),e("/settings?tab=users")},onError:U=>{i(U.message,"error")}}),M=T.isPending||k.isPending,C=()=>{if(!o.trim()){i(r("groups.toast.enterGroupName"),"error");return}s?k.mutate({name:o!==g?.name?o:void 0,description:c,permissions:u}):T.mutate({name:o,description:c||void 0,permissions:u})},j=U=>{h(W=>W.includes(U)?W.filter(Y=>Y!==U):[...W,U])},P=(U,W)=>{const Y=U.permissions.map(re=>re.value);h(re=>{const H=re.filter(K=>!Y.includes(K));return W?[...H,...Y]:H})},E=U=>U.permissions.every(W=>u.includes(W.value)),B=U=>{const W=U.permissions.filter(Y=>u.includes(Y.value)).length;return W>0&&W{_&&h(_.all_permissions)},z=()=>{h([])},D=f.toLowerCase(),$=w.useMemo(()=>_?D?_.categories.map(U=>({...U,permissions:U.permissions.filter(W=>W.label.toLowerCase().includes(D))})).filter(U=>U.permissions.length>0):_.categories:[],[_,D]),G=_?.all_permissions.length??0;return y||N?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:()=>e("/settings?tab=users"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",children:a.jsx(dY,{className:"w-5 h-5"})}),a.jsx("h1",{className:"text-xl font-bold text-white",children:r(s?"groups.editor.title":"groups.editor.createTitle")})]}),s&&g?.is_system&&a.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-lg bg-yellow-500/10 border border-yellow-500/20 text-yellow-400 text-sm",children:[a.jsx(An,{className:"w-4 h-4 shrink-0"}),r("groups.form.systemGroupWarning")]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:r("groups.form.groupName")}),a.jsx("input",{type:"text",value:o,onChange:U=>l(U.target.value),disabled:s&&g?.is_system,className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors disabled:opacity-50",placeholder:r("groups.form.groupNamePlaceholder")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:r("groups.form.description")}),a.jsx("input",{type:"text",value:c,onChange:U=>d(U.target.value),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:r("groups.form.descriptionPlaceholder")})]})]}),a.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("span",{className:"text-sm text-bambu-gray",children:[r("groups.editor.permissionsSelected",{count:u.length})," / ",G]}),a.jsx(Me,{size:"sm",variant:"ghost",onClick:O,children:r("groups.editor.selectAll")}),a.jsx(Me,{size:"sm",variant:"ghost",onClick:z,children:r("groups.editor.clearAll")})]}),a.jsxs("div",{className:"relative",children:[a.jsx(Mr,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray"}),a.jsx("input",{type:"text",value:f,onChange:U=>p(U.target.value),placeholder:r("groups.editor.search"),className:"pl-9 pr-4 py-2 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors w-64"})]})]}),$.length===0?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:r("groups.editor.noResults")}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:$.map(U=>{const W=_.categories.find(ee=>ee.name===U.name),Y=W.permissions.filter(ee=>u.includes(ee.value)).length,re=W.permissions.length,H=E(W),K=B(W);return a.jsxs(wt,{children:[a.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between px-4 py-3 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary rounded-t-xl",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("button",{type:"button",onClick:()=>P(W,!H),className:`w-5 h-5 rounded border flex items-center justify-center transition-colors shrink-0 ${H?"bg-bambu-green border-bambu-green":K?"bg-bambu-green/50 border-bambu-green":"border-bambu-gray hover:border-white"}`,children:[H&&a.jsx(Jr,{className:"w-3 h-3 text-white"}),K&&!H&&a.jsx(w1,{className:"w-3 h-3 text-white"})]}),a.jsx(l3,{className:"w-4 h-4 text-bambu-gray shrink-0"}),a.jsx("span",{className:"text-white font-medium text-sm",children:U.name})]}),a.jsxs("span",{className:"text-xs text-bambu-gray tabular-nums",children:[Y,"/",re]})]}),a.jsx("div",{className:"p-3 space-y-1",children:U.permissions.map(ee=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-secondary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:u.includes(ee.value),onChange:()=>j(ee.value),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark-secondary"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:ee.label})]},ee.value))})]},U.name)})}),a.jsx("div",{className:"h-16"}),a.jsxs("div",{className:"fixed bottom-0 left-0 right-0 z-20 px-6 py-3 bg-bambu-dark-secondary border-t border-bambu-dark-tertiary flex items-center justify-center gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>e("/settings?tab=users"),children:r("common.cancel")}),a.jsx(Me,{onClick:C,disabled:M||!o.trim(),children:M?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),r("common.saving")]}):a.jsxs(a.Fragment,{children:[a.jsx(bs,{className:"w-4 h-4"}),r("common.save")]})})]})]})}const oK={material:"",subtype:"",brand:"",color_name:"",rgba:"808080FF",label_weight:1e3,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:"",note:"",cost_per_kg:null};function EJe(t,e=!1){const n={};return e?(t.material||(n.material="Material is required"),{isValid:Object.keys(n).length===0,errors:n}):(t.slicer_filament||(n.slicer_filament="Slicer preset is required"),t.material||(n.material="Material is required"),t.brand||(n.brand="Brand is required"),t.subtype||(n.subtype="Subtype is required"),{isValid:Object.keys(n).length===0,errors:n})}const jJe=["PLA","PETG","ABS","TPU","ASA","PC","PA","PVA","HIPS","PA-CF","PETG-CF","PLA-CF"],DJe=["Bambu","PolyLite","PolyTerra","eSUN","Overture","Fiberon","SUNLU","Inland","Hatchbox","Generic"],dv=["Basic","Matte","Silk","Tough","HF","High Flow","Engineering","Galaxy","Glow","Marble","Metal","Rainbow","Sparkle","Wood","Translucent","Transparent","Clear","Lite","Pro","Plus","Max","Super","Ultra","Flex","Soft","Hard","Strong","Impact","Heat Resistant","UV Resistant","ESD","Conductive","Magnetic","Gradient","Dual Color","Tri Color","Multicolor"],Jie=[{name:"Black",hex:"000000"},{name:"White",hex:"FFFFFF"},{name:"Gray",hex:"808080"},{name:"Red",hex:"FF0000"},{name:"Orange",hex:"FFA500"},{name:"Yellow",hex:"FFFF00"},{name:"Green",hex:"00AE42"},{name:"Blue",hex:"0066FF"},{name:"Purple",hex:"8B00FF"},{name:"Pink",hex:"FF69B4"},{name:"Brown",hex:"8B4513"},{name:"Silver",hex:"C0C0C0"}],RJe=[{name:"Dark Red",hex:"8B0000"},{name:"Crimson",hex:"DC143C"},{name:"Coral",hex:"FF7F50"},{name:"Salmon",hex:"FA8072"},{name:"Dark Orange",hex:"FF8C00"},{name:"Peach",hex:"FFDAB9"},{name:"Gold",hex:"FFD700"},{name:"Khaki",hex:"F0E68C"},{name:"Lemon",hex:"FFF44F"},{name:"Lime",hex:"32CD32"},{name:"Forest Green",hex:"228B22"},{name:"Olive",hex:"808000"},{name:"Mint",hex:"98FF98"},{name:"Teal",hex:"008080"},{name:"Navy",hex:"000080"},{name:"Sky Blue",hex:"87CEEB"},{name:"Royal Blue",hex:"4169E1"},{name:"Cyan",hex:"00FFFF"},{name:"Turquoise",hex:"40E0D0"},{name:"Violet",hex:"EE82EE"},{name:"Magenta",hex:"FF00FF"},{name:"Indigo",hex:"4B0082"},{name:"Lavender",hex:"E6E6FA"},{name:"Plum",hex:"DDA0DD"},{name:"Hot Pink",hex:"FF69B4"},{name:"Rose",hex:"FF007F"},{name:"Blush",hex:"FFB6C1"},{name:"Chocolate",hex:"D2691E"},{name:"Tan",hex:"D2B48C"},{name:"Beige",hex:"F5F5DC"},{name:"Maroon",hex:"800000"},{name:"Dark Gray",hex:"404040"},{name:"Light Gray",hex:"D3D3D3"},{name:"Charcoal",hex:"36454F"},{name:"Ivory",hex:"FFFFF0"},{name:"Bambu Green",hex:"00AE42"},{name:"Jade White",hex:"E8E8E8"},{name:"Titan Gray",hex:"5A5A5A"}],lK=[...Jie,...RJe],ese="bambuddy-recent-colors",FJe=8,LJe=[{code:"GFL00",name:"Bambu PLA Basic",displayName:"Bambu PLA Basic",isCustom:!1,allCodes:["GFL00"]},{code:"GFL01",name:"Bambu PLA Matte",displayName:"Bambu PLA Matte",isCustom:!1,allCodes:["GFL01"]},{code:"GFL05",name:"Generic PLA",displayName:"Generic PLA",isCustom:!1,allCodes:["GFL05"]},{code:"GFG00",name:"Bambu PETG Basic",displayName:"Bambu PETG Basic",isCustom:!1,allCodes:["GFG00"]},{code:"GFG05",name:"Generic PETG",displayName:"Generic PETG",isCustom:!1,allCodes:["GFG05"]},{code:"GFB00",name:"Bambu ABS Basic",displayName:"Bambu ABS Basic",isCustom:!1,allCodes:["GFB00"]},{code:"GFB05",name:"Generic ABS",displayName:"Generic ABS",isCustom:!1,allCodes:["GFB05"]},{code:"GFA00",name:"Bambu ASA Basic",displayName:"Bambu ASA Basic",isCustom:!1,allCodes:["GFA00"]},{code:"GFU00",name:"Bambu TPU 95A",displayName:"Bambu TPU 95A",isCustom:!1,allCodes:["GFU00"]},{code:"GFU05",name:"Generic TPU",displayName:"Generic TPU",isCustom:!1,allCodes:["GFU05"]},{code:"GFC00",name:"Bambu PC Basic",displayName:"Bambu PC Basic",isCustom:!1,allCodes:["GFC00"]},{code:"GFN00",name:"Bambu PA Basic",displayName:"Bambu PA Basic",isCustom:!1,allCodes:["GFN00"]},{code:"GFN05",name:"Generic PA",displayName:"Generic PA",isCustom:!1,allCodes:["GFN05"]},{code:"GFS00",name:"Bambu PLA-CF",displayName:"Bambu PLA-CF",isCustom:!1,allCodes:["GFS00"]},{code:"GFT00",name:"Bambu PETG-CF",displayName:"Bambu PETG-CF",isCustom:!1,allCodes:["GFT00"]},{code:"GFNC0",name:"Bambu PA-CF",displayName:"Bambu PA-CF",isCustom:!1,allCodes:["GFNC0"]},{code:"GFV00",name:"Bambu PVA",displayName:"Bambu PVA",isCustom:!1,allCodes:["GFV00"]}];function Ob(t){let e=t.replace(/@.*$/,"").trim();e=e.replace(/\(Custom\)/i,"").trim(),e=e.replace(/^[#*]+\s*/,"").trim();const n=["PLA-CF","PETG-CF","ABS-GF","ASA-CF","PA-CF","PAHT-CF","PA6-CF","PA6-GF","PPA-CF","PPA-GF","PET-CF","PPS-CF","PC-CF","PC-ABS","ABS-GF","PCTG","PETG","PLA","ABS","ASA","PC","PA","TPU","PVA","HIPS","BVOH","PPS","PEEK","PEI"];let r="",i=-1;for(const c of n){const d=e.toUpperCase().indexOf(c.toUpperCase());if(d!==-1){r=c,i=d;break}}let s="";i>0&&(s=e.substring(0,i).trim(),s=s.replace(/[-_\s]+$/,""));let o="";i!==-1&&r&&(o=e.substring(i+r.length).trim(),o=o.replace(/^[-_\s]+/,""));let l="";for(const c of dv)if(o.toLowerCase().includes(c.toLowerCase())){l=c;break}if(!l&&s)for(const c of dv){const d=new RegExp(`\\s+${c}$`,"i");if(d.test(s)){l=c,s=s.replace(d,"").trim();break}}return{brand:s,material:r,variant:l}}function OJe(t,e){const n=new Set(DJe);for(const r of t){const{brand:i}=Ob(r.name);i&&i.length>1&&n.add(i)}if(e)for(const r of e)if(r.filament_vendor&&r.filament_vendor.length>1)n.add(r.filament_vendor);else{const{brand:i}=Ob(r.name);i&&i.length>1&&n.add(i)}return Array.from(n).sort((r,i)=>r.localeCompare(i))}function IJe(t){const e=t.filter(r=>r.preset_type==="filament");if(e.length===0)return[];const n=new Map;for(const r of e){const i=r.name.replace(/@.*$/,"").trim(),s=n.get(i);if(s)s.allCodes.push(String(r.id));else{const o=r.filament_type||String(r.id);n.set(i,{code:o,name:i,displayName:i,isCustom:!1,allCodes:[o]})}}return Array.from(n.values()).sort((r,i)=>r.displayName.localeCompare(i.displayName))}function zJe(t,e,n){if(t.length>0){const r=[],i=new Map;for(const s of t)if(s.is_custom){const o=s.name.toUpperCase();(e.size===0||Array.from(e).some(c=>o.includes(c))||!o.includes("@"))&&r.push({code:s.setting_id,name:s.name,displayName:`${s.name} (Custom)`,isCustom:!0,allCodes:[s.setting_id]})}else{const o=s.name.replace(/@.*$/,"").trim(),l=i.get(o);l?l.allCodes.push(s.setting_id):i.set(o,{code:s.setting_id,name:o,displayName:o,isCustom:!1,allCodes:[s.setting_id]})}return[...r,...Array.from(i.values())].sort((s,o)=>s.displayName.localeCompare(o.displayName))}if(n&&n.length>0){const r=IJe(n);if(r.length>0)return r}return LJe}function UJe(t,e){if(!t)return;let n=e.find(r=>r.code===t);if(n||(n=e.find(r=>r.allCodes.includes(t))),!n){const r=t.toLowerCase();n=e.find(i=>i.code.toLowerCase()===r||i.allCodes.some(s=>s.toLowerCase()===r))}return n}function BJe(){try{const t=localStorage.getItem(ese);if(t)return JSON.parse(t)}catch{}return[]}function HJe(t,e){const n=e.filter(i=>i.hex.toUpperCase()!==t.hex.toUpperCase()),r=[t,...n].slice(0,FJe);try{localStorage.setItem(ese,JSON.stringify(r))}catch{}return r}function Fj(t,e){if(!e.material)return!1;const r=(t.name||"").replace(/^High Flow[_\s]+/i,"").replace(/^Standard[_\s]+/i,"").replace(/^HF[_\s]+/i,"").replace(/^S[_\s]+/i,"").trim(),i=Ob(r);return!(!(i.material.toUpperCase()===e.material.toUpperCase())||e.brand&&!(i.brand.toLowerCase().includes(e.brand.toLowerCase())||e.brand.toLowerCase().includes(i.brand.toLowerCase()))||e.subtype&&!(i.variant.toLowerCase().includes(e.subtype.toLowerCase())||e.subtype.toLowerCase().includes(i.variant.toLowerCase())||r.toLowerCase().includes(e.subtype.toLowerCase())))}function $Je({formData:t,updateField:e,cloudAuthenticated:n,loadingCloudPresets:r,presetInputValue:i,setPresetInputValue:s,selectedPresetOption:o,filamentOptions:l,availableBrands:c,availableMaterials:d,quickAdd:u,quantity:h,onQuantityChange:f,errors:p}){const{t:x}=Dt(),[v,g]=w.useState(!1),[y,_]=w.useState(!1),[N,T]=w.useState(!1),[k,M]=w.useState(!1),[C,j]=w.useState(""),[P,E]=w.useState(""),[B,O]=w.useState(""),[z,D]=w.useState(String(t.label_weight)),[$,G]=w.useState(!1),U=w.useRef(null),W=w.useRef(null),Y=w.useRef(null),re=w.useRef(null);w.useEffect(()=>{const oe=J=>{U.current&&!U.current.contains(J.target)&&g(!1),re.current&&!re.current.contains(J.target)&&M(!1),W.current&&!W.current.contains(J.target)&&_(!1),Y.current&&!Y.current.contains(J.target)&&T(!1)};return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[]);const H=w.useMemo(()=>{if(!i)return l;const oe=i.toLowerCase();return l.filter(J=>J.displayName.toLowerCase().includes(oe)||J.code.toLowerCase().includes(oe))},[l,i]),K=w.useMemo(()=>{if(!C)return c;const oe=C.toLowerCase();return c.filter(je=>je.toLowerCase().includes(oe)).sort((je,de)=>{const le=je.toLowerCase()===oe,_e=de.toLowerCase()===oe;return le&&!_e?-1:!le&&_e?1:je.localeCompare(de)})},[c,C]),ee=w.useMemo(()=>{if(!P)return dv;const oe=P.toLowerCase();return dv.filter(J=>J.toLowerCase().includes(oe))},[P]),Z=w.useMemo(()=>{if(!B)return d;const oe=B.toLowerCase();return d.filter(je=>je.toLowerCase().includes(oe)).sort((je,de)=>{const le=je.toLowerCase()===oe,_e=de.toLowerCase()===oe;return le&&!_e?-1:!le&&_e?1:je.localeCompare(de)})},[B,d]);w.useEffect(()=>{$||D(String(t.label_weight))},[t.label_weight,$]);const we=oe=>{e("slicer_filament",oe.code),s(oe.displayName),g(!1);const J=Ob(oe.name);J.material&&e("material",J.material),J.brand&&e("brand",J.brand),J.variant&&e("subtype",J.variant)};return a.jsxs("div",{className:"space-y-4",children:[!u&&a.jsx("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:r?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-3 h-3 animate-spin"})," ",x("inventory.loadingPresets")]}):n?a.jsxs(a.Fragment,{children:[a.jsx(Hb,{className:"w-3 h-3 text-bambu-green"})," ",x("inventory.cloudConnected")]}):a.jsxs(a.Fragment,{children:[a.jsx(Phe,{className:"w-3 h-3"})," ",x("inventory.cloudNotConnected")]})}),!u&&a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[x("inventory.slicerPreset")," *"]}),a.jsxs("div",{className:"relative",ref:U,children:[a.jsx(Mr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),a.jsx("input",{type:"text",className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:x("inventory.searchPresets"),value:i,onChange:oe=>{s(oe.target.value),g(!0)},onFocus:()=>{g(!0),s("")}}),v&&a.jsx("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto",children:H.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:x("inventory.noPresetsFound")}):H.map(oe=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary truncate ${o?.code===oe.code?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>we(oe),children:oe.displayName},oe.code))})]}),o&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray",children:[x("inventory.selectedPreset"),": ",a.jsx("span",{className:"font-mono text-bambu-green",children:o.code})]}),p?.slicer_filament&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:p.slicer_filament})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[x("inventory.material")," *"]}),a.jsxs("div",{className:"relative",ref:re,children:[a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:x("inventory.selectMaterial"),value:k?B:t.material,onChange:oe=>{O(oe.target.value),M(!0)},onFocus:()=>{M(!0),O("")}}),a.jsx(Pn,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),k&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[Z.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:x("inventory.noResults")}):Z.map(oe=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.material===oe?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("material",oe),M(!1),O("")},children:oe},oe)),B&&!Z.includes(B)&&a.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary",onClick:()=>{e("material",B),M(!1),O("")},children:x("inventory.useCustomMaterial",{material:B})})]})]}),p?.material&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:p.material})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[x("inventory.brand"),!u&&" *"]}),a.jsxs("div",{className:"relative",ref:W,children:[a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:x("inventory.searchBrand"),value:y?C:t.brand,onChange:oe=>{j(oe.target.value),_(!0)},onFocus:()=>{_(!0),j("")}}),a.jsx(Pn,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),y&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[K.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:x("inventory.noResults")}):K.map(oe=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.brand===oe?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("brand",oe),_(!1),j("")},children:oe},oe)),C&&!K.includes(C)&&a.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary",onClick:()=>{e("brand",C),_(!1),j("")},children:x("inventory.useCustomBrand",{brand:C})})]})]}),p?.brand&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:p.brand})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[x("inventory.subtype"),!u&&" *"]}),a.jsxs("div",{className:"relative",ref:Y,children:[a.jsx("input",{type:"text",value:N?P:t.subtype,onChange:oe=>{E(oe.target.value),T(!0)},onFocus:()=>{T(!0),E("")},placeholder:"Basic, Matte, Silk...",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green"}),a.jsx(Pn,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),N&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[ee.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:x("inventory.noResults")}):ee.map(oe=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.subtype===oe?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("subtype",oe),T(!1),E("")},children:oe},oe)),P&&!dv.some(oe=>oe.toLowerCase()===P.toLowerCase().trim())&&a.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary",onClick:()=>{e("subtype",P),T(!1),E("")},children:x("inventory.useCustomBrand",{brand:P})})]})]}),p?.subtype&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:p.subtype})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:x("inventory.labelWeight")}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"number",className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green",value:z,min:0,onFocus:()=>G(!0),onChange:oe=>D(oe.target.value),onBlur:()=>{G(!1);const oe=z.trim(),J=Number(oe);if(!oe||!Number.isFinite(J)||J<0){D(String(t.label_weight));return}const je=Math.round(J);e("label_weight",je),D(String(je))}}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]})]}),u&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:x("inventory.quantity")}),a.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green",value:h,min:1,max:100,onChange:oe=>{const J=Math.max(1,Math.min(100,parseInt(oe.target.value)||1));f(J)}})]})]})}function VJe({formData:t,updateField:e,recentColors:n,onColorUsed:r,catalogColors:i}){const{t:s}=Dt(),[o,l]=w.useState(!1),[c,d]=w.useState(""),u=t.rgba.replace("#","").substring(0,6),h=y=>u.toUpperCase()===y.toUpperCase(),f=(y,_)=>{e("rgba",y.toUpperCase()+"FF"),e("color_name",_),r({name:_,hex:y})},p=w.useMemo(()=>{if(i.length===0)return[];const y=t.brand?.trim(),_=t.material?.toLowerCase().trim(),N=t.subtype?.toLowerCase().trim();if(!y&&!_)return[];const T=y?y.toLowerCase().split(/[\s\-_]+/).filter(C=>C.length>=2):[],k=C=>{if(T.length===0)return!0;const j=C.toLowerCase();return T.some(P=>j.includes(P))};if(y&&!_){const C=i.filter(j=>k(j.manufacturer));if(C.length>0)return C.map(j=>({name:j.color_name,hex:j.hex_color.replace("#","").substring(0,6),manufacturer:j.manufacturer,material:typeof j.material=="string"?j.material:void 0}))}const M=_&&N?`${_} ${N}`:"";if(M){const C=i.filter(P=>k(P.manufacturer)&&P.material?.toLowerCase()===M);if(C.length>0)return C.map(P=>({name:P.color_name,hex:P.hex_color.replace("#","").substring(0,6),manufacturer:P.manufacturer,material:typeof P.material=="string"?P.material:void 0}));const j=M.replace(/\+$/,"");if(j!==M){const P=i.filter(E=>k(E.manufacturer)&&E.material?.toLowerCase()===j);if(P.length>0)return P.map(E=>({name:E.color_name,hex:E.hex_color.replace("#","").substring(0,6),manufacturer:E.manufacturer,material:typeof E.material=="string"?E.material:void 0}))}}if(_){const C=i.filter(j=>k(j.manufacturer)&&(!j.material||j.material.toLowerCase().startsWith(_)));if(C.length>0)return C.map(j=>({name:j.color_name,hex:j.hex_color.replace("#","").substring(0,6),manufacturer:j.manufacturer,material:typeof j.material=="string"?j.material:void 0}))}return[]},[i,t.brand,t.material,t.subtype]),x=w.useMemo(()=>{if(!c)return p;if(p.length===0)return[];const y=c.toLowerCase();return p.filter(N=>N.name.toLowerCase().includes(y)||(N.manufacturer?.toLowerCase().includes(y)??!1)||(N.material?.toLowerCase().includes(y)??!1))},[c,p]),v=p.length>0,g=w.useMemo(()=>c?lK.filter(y=>y.name.toLowerCase().includes(c.toLowerCase())):o?lK:Jie,[c,o]);return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"h-10 rounded-lg border border-bambu-dark-tertiary",style:{backgroundColor:`#${u}`}}),n.length>0&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-bambu-gray shrink-0",children:[a.jsx(Vn,{className:"w-3 h-3"}),a.jsx("span",{children:s("inventory.recentColors")})]}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.map(y=>a.jsx("button",{type:"button",onClick:()=>f(y.hex,y.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 ${h(y.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${y.hex}`},title:y.name},y.hex))})]}),a.jsxs("div",{className:"relative",children:[a.jsx(Mr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),a.jsx("input",{type:"text",className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.searchColors"),value:c,onChange:y=>d(y.target.value)})]}),v?a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:c?s("inventory.searchResults"):`${t.brand}${t.material?` ${t.material}`:""}`}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[x.map(y=>a.jsx("button",{type:"button",onClick:()=>f(y.hex,y.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${h(y.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${y.hex}`},title:y.manufacturer&&y.material?`${y.name} (${y.manufacturer} — ${y.material})`:y.manufacturer?`${y.name} (${y.manufacturer})`:y.name,children:a.jsx("span",{className:"absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white",children:y.manufacturer&&y.material?`${y.name} (${y.manufacturer} — ${y.material})`:y.manufacturer?`${y.name} (${y.manufacturer})`:y.name})},`${y.hex}-${y.name}-${y.manufacturer??""}`)),x.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray py-1",children:s("inventory.noColorsFound")})]})]}):a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray",children:[a.jsx("span",{children:s(c?"inventory.searchResults":o?"inventory.allColors":"inventory.commonColors")}),!c&&a.jsx("button",{type:"button",onClick:()=>l(!o),className:"flex items-center gap-1 hover:text-white transition-colors",children:o?a.jsxs(a.Fragment,{children:[s("inventory.showLess")," ",a.jsx(yl,{className:"w-3 h-3"})]}):a.jsxs(a.Fragment,{children:[s("inventory.showAll")," ",a.jsx(Pn,{className:"w-3 h-3"})]})})]}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[g.map(y=>a.jsx("button",{type:"button",onClick:()=>f(y.hex,y.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${h(y.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${y.hex}`},title:y.name,children:a.jsx("span",{className:"absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white",children:y.name})},y.hex)),g.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray py-1",children:s("inventory.noColorsFound")})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:s("inventory.colorName")}),a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.colorNamePlaceholder"),value:t.color_name,onChange:y=>e("color_name",y.target.value)})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:s("inventory.hexColor")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray",children:"#"}),a.jsx("input",{type:"text",className:"w-full pl-7 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono uppercase focus:outline-none focus:border-bambu-green",placeholder:"RRGGBB",value:u.toUpperCase(),onChange:y=>{const _=y.target.value.replace("#","").replace(/[^0-9A-Fa-f]/g,"");_.length<=8&&e("rgba",_.toUpperCase()+(_.length<=6?"FF":""))}})]}),a.jsx("input",{type:"color",className:"w-11 h-[38px] rounded-lg cursor-pointer border border-bambu-dark-tertiary shrink-0 bg-transparent",value:`#${u}`,onChange:y=>{const _=y.target.value.replace("#","").toUpperCase();e("rgba",_+"FF")},title:s("inventory.pickColor")})]})]})]})]})}function qJe({catalog:t,value:e,onChange:n,catalogId:r,onCatalogIdChange:i}){const{t:s}=Dt(),[o,l]=w.useState(!1),[c,d]=w.useState(""),u=w.useRef(null),h=w.useRef(null);w.useEffect(()=>{const v=g=>{u.current&&!u.current.contains(g.target)&&l(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]),w.useEffect(()=>{if(t.length===0)return;const v=t.filter(g=>g.weight===e);if(r){const g=t.find(y=>y.id===r);if(g&&g.weight===e)return}v.length===1?i(v[0].id):v.length===0&&r!==null&&i(null)},[e,t,r,i]);const f=w.useMemo(()=>{if(!c)return t;const v=c.toLowerCase();return t.filter(g=>g.name.toLowerCase().includes(v)||g.weight.toString().includes(v))},[t,c]),p=w.useMemo(()=>t.filter(v=>v.weight===e),[t,e]),x=w.useMemo(()=>{if(o)return c;if(r){const v=t.find(g=>g.id===r);if(v)return v.name}return p.length>0?p[0].name:""},[o,c,r,t,p]);return a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(epe,{className:"w-3.5 h-3.5 text-bambu-gray"}),s("inventory.coreWeight")]})}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsxs("div",{className:"flex-1 min-w-0 relative",ref:u,children:[a.jsx("input",{ref:h,type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.searchSpoolWeight"),value:x,onFocus:()=>{l(!0),d("")},onChange:v=>{d(v.target.value),l(!0)}}),o&&a.jsx("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto",children:f.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:s("inventory.noResults")}):f.map(v=>a.jsxs("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex justify-between items-center ${(r?v.id===r:v.weight===e)?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{i(v.id),n(v.weight),l(!1),d("")},children:[a.jsx("span",{className:"truncate",children:v.name}),a.jsxs("span",{className:"font-mono text-xs text-bambu-gray ml-2 shrink-0",children:[v.weight,"g"]})]},v.id))})]}),a.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[a.jsx("input",{type:"number",className:"w-16 px-2 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm text-center font-mono focus:outline-none focus:border-bambu-green",value:e,min:0,max:2e3,onChange:v=>{const g=parseInt(v.target.value);!isNaN(g)&&g>=0&&n(g)}}),a.jsx("span",{className:"text-bambu-gray text-sm",children:"g"})]})]})]})}function GJe({formData:t,updateField:e,spoolCatalog:n,currencySymbol:r}){const{t:i}=Dt(),{showToast:s}=ln(),[o,l]=w.useState(""),[c,d]=w.useState(!1),[u,h]=w.useState(""),[f,p]=w.useState(!1),x=Math.max(0,t.label_weight-t.weight_used),v=t.core_weight+x;return w.useEffect(()=>{c||l(String(v))},[c,v]),w.useEffect(()=>{f||h(String(x))},[f,x]),a.jsxs("div",{className:"space-y-4",children:[a.jsx(qJe,{catalog:n,value:t.core_weight,onChange:g=>e("core_weight",g),catalogId:t.core_weight_catalog_id,onCatalogIdChange:g=>e("core_weight_catalog_id",g)}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:i("inventory.currentWeight")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:"number",value:u,min:0,max:t.label_weight,onFocus:()=>p(!0),onChange:g=>{h(g.target.value)},onBlur:()=>{p(!1);const g=u.trim(),y=Number(g);if(!g||!Number.isFinite(y)||y<0||y>t.label_weight){h(String(x));return}const _=Math.round(y);e("weight_used",Math.max(0,t.label_weight-_)),h(String(_))},className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]}),a.jsxs("span",{className:"text-xs text-bambu-gray shrink-0",children:["/ ",t.label_weight,"g"]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:i("inventory.measuredWeight")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:"number",value:o,min:0,onFocus:()=>d(!0),onChange:g=>{l(g.target.value)},onBlur:()=>{d(!1);const g=o.trim(),y=Number(g),_=t.core_weight,N=t.core_weight+t.label_weight;if(!g||!Number.isFinite(y)||y<_||y>N){s(i("inventory.measuredWeightError",{min:_,max:N}),"error"),l(String(v));return}const T=Math.round(y),k=Math.max(0,Math.min(t.label_weight,T-t.core_weight));e("weight_used",Math.max(0,t.label_weight-k)),l(String(T))},className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]}),a.jsxs("span",{className:"text-xs text-bambu-gray shrink-0",children:["/ ",t.core_weight+t.label_weight,"g"]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:i("inventory.costPerKg","Cost per kg")}),a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none",children:r}),a.jsx("input",{type:"number",value:t.cost_per_kg??"",min:0,step:.01,placeholder:"0.00",onChange:g=>{const y=g.target.value===""?null:parseFloat(g.target.value);e("cost_per_kg",y)},style:{paddingLeft:`${Math.max(2,r.length*.6+1)}rem`},className:"w-full py-2 pr-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"})]})})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:i("inventory.note")}),a.jsx("textarea",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green resize-none min-h-[80px]",placeholder:i("inventory.notePlaceholder"),value:t.note,onChange:g=>e("note",g.target.value)})]})]})}function WJe({formData:t,printersWithCalibrations:e,selectedProfiles:n,setSelectedProfiles:r,expandedPrinters:i,setExpandedPrinters:s}){const{t:o}=Dt(),l=f=>{s(p=>{const x=new Set(p);return x.has(f)?x.delete(f):x.add(f),x})},c=(f,p,x)=>{const v=`${f}:${p}:${x??"null"}`,g=`${f}:${x??"null"}`;r(y=>{const _=new Set(y);if(_.has(v))_.delete(v);else{for(const N of Array.from(_)){const T=N.split(":");`${T[0]}:${T[2]}`===g&&_.delete(N)}_.add(v)}return _})},d=()=>{const f=new Set;for(const{printer:p,calibrations:x}of e){if(!p.connected)continue;const v=x.filter(y=>Fj(y,t)),g=new Map;for(const y of v){const _=`${y.extruder_id??"null"}`;g.has(_)||g.set(_,[]),g.get(_).push(y)}for(const[y,_]of g)if(_.length>0){const T=[..._].sort((k,M)=>M.k_value-k.k_value)[0];f.add(`${p.id}:${T.cali_idx}:${y}`)}}r(f)};if(!t.material)return a.jsx("div",{className:"p-6 bg-bambu-dark rounded-lg text-center",children:a.jsx("p",{className:"text-bambu-gray",children:o("inventory.selectMaterialFirst")})});if(e.length===0)return a.jsx("div",{className:"p-6 bg-bambu-dark rounded-lg text-center",children:a.jsx("p",{className:"text-bambu-gray",children:o("inventory.noPrintersConfigured")})});const u=e.reduce((f,{printer:p,calibrations:x})=>p.connected?f+x.filter(v=>Fj(v,t)).length:f,0),h=(f,p)=>{const x=`${f.id}:${p.cali_idx}:${p.extruder_id??"null"}`,v=n.has(x);return a.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-all border ${v?"bg-bambu-green/10 border-bambu-green/30":"bg-bambu-dark border-transparent hover:bg-bambu-dark/80"}`,children:[a.jsx("input",{type:"checkbox",checked:v,onChange:()=>c(String(f.id),p.cali_idx,p.extruder_id),className:"w-4 h-4 rounded border-bambu-dark-tertiary text-bambu-green focus:ring-bambu-green"}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("span",{className:`text-sm font-medium ${v?"text-bambu-green":"text-white"}`,children:p.name||p.filament_id})}),a.jsx("div",{className:"flex items-center gap-2 shrink-0",children:a.jsxs("span",{className:"text-xs font-mono px-2 py-0.5 rounded bg-bambu-dark text-bambu-gray",children:["K=",p.k_value.toFixed(3)]})})]},`${p.cali_idx}-${p.extruder_id}`)};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("p",{className:"text-xs text-bambu-gray",children:[o("inventory.matchingFilter"),": ",t.brand||o("inventory.anyBrand")," / ",t.material," / ",t.subtype||o("inventory.anyVariant")]}),u>0&&a.jsxs("button",{type:"button",onClick:d,className:"flex items-center gap-1.5 px-2 py-1 text-xs bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white hover:border-bambu-green transition-colors",children:[a.jsx(ub,{className:"w-3.5 h-3.5"}),o("inventory.autoSelect")," (",u,")"]})]}),a.jsx("div",{className:"space-y-3",children:e.map(({printer:f,calibrations:p})=>{const x=i.has(String(f.id)),v=p.filter(T=>Fj(T,t)),g=v.length,y=v.some(T=>T.extruder_id!==void 0&&T.extruder_id!==null&&T.extruder_id>0),_=v.filter(T=>T.extruder_id===1),N=v.filter(T=>T.extruder_id===0||T.extruder_id===void 0||T.extruder_id===null);return a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{type:"button",onClick:()=>l(String(f.id)),className:"w-full px-4 py-3 flex items-center justify-between bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[x?a.jsx(Pn,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(yi,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"font-medium text-white",children:f.name}),g>0?a.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:[g," ",o(g!==1?"inventory.matches":"inventory.match")]}):a.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray",children:o("inventory.noMatches")})]}),a.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${f.connected?"bg-green-500/20 text-green-500":"bg-bambu-gray/20 text-bambu-gray"}`,children:f.connected?o("inventory.connected"):o("inventory.offline")})]}),x&&a.jsx("div",{className:"px-4 py-3 space-y-3 bg-bambu-dark border-t border-bambu-dark-tertiary",children:f.connected?g===0?a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:o("inventory.noKProfilesMatch")}):y?a.jsxs(a.Fragment,{children:[_.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wide",children:o("inventory.leftNozzle")}),a.jsx("div",{className:"space-y-2",children:_.map(T=>h(f,T))})]}),N.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wide",children:o("inventory.rightNozzle")}),a.jsx("div",{className:"space-y-2",children:N.map(T=>h(f,T))})]})]}):a.jsx("div",{className:"space-y-2",children:v.map(T=>h(f,T))}):a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:o("inventory.printerOffline")})})]},f.id)})}),n.size>0&&a.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[a.jsx("span",{className:"font-semibold",children:n.size})," ",o("inventory.profilesSelected")]})})]})}function KJe(t){const e=new Date(t);return e.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"})+" "+e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})}const YJe={completed:"text-bambu-green",failed:"text-red-400",aborted:"text-yellow-400"};function XJe({spoolId:t}){const{t:e}=Dt(),n=Jt(),{showToast:r}=ln(),{data:i,isLoading:s}=Je({queryKey:["spool-usage",t],queryFn:()=>ne.getSpoolUsageHistory(t)}),o=st({mutationFn:()=>ne.clearSpoolUsageHistory(t),onSuccess:()=>{n.invalidateQueries({queryKey:["spool-usage",t]}),r(e("inventory.historyCleared"),"success")}});return s?a.jsx("div",{className:"flex justify-center py-4",children:a.jsx(at,{className:"w-5 h-5 animate-spin text-bambu-green"})}):!i||i.length===0?a.jsxs("div",{className:"text-center py-4 text-bambu-gray text-sm",children:[a.jsx(Vn,{className:"w-5 h-5 mx-auto mb-2 opacity-50"}),e("inventory.noUsageHistory")]}):a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:e("inventory.usageHistory")}),a.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>o.mutate(),disabled:o.isPending,className:"text-xs text-bambu-gray hover:text-red-400",children:[a.jsx(Xt,{className:"w-3 h-3 mr-1"}),e("inventory.clearHistory")]})]}),a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:i.map(l=>a.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-bambu-dark/50 text-xs",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:"text-bambu-gray",children:KJe(l.created_at)}),l.print_name&&a.jsx("span",{className:"text-white ml-2 truncate",title:l.print_name,children:l.print_name})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-2",children:[a.jsxs("span",{className:"text-white font-medium",children:[l.weight_used.toFixed(1),"g"]}),a.jsxs("span",{className:"text-bambu-gray",children:["(",l.percent_used,"%)"]}),a.jsx("span",{className:YJe[l.status]||"text-bambu-gray",children:l.status})]})]},l.id))})]})}function QJe({isOpen:t,onClose:e,spool:n,printersWithCalibrations:r=[],currencySymbol:i}){const{t:s}=Dt(),o=Jt(),{showToast:l}=ln(),c=!!n,[d,u]=w.useState(oK),[h,f]=w.useState({}),[p,x]=w.useState("filament"),[v,g]=w.useState(!1),[y,_]=w.useState(!1),[N,T]=w.useState(1),[k,M]=w.useState(!1),[C,j]=w.useState(!1),[P,E]=w.useState([]),[B,O]=w.useState(""),[z,D]=w.useState([]),[$,G]=w.useState([]),[U,W]=w.useState([]),[Y,re]=w.useState([]),[H,K]=w.useState([]),[ee,Z]=w.useState(new Set),[we,oe]=w.useState(new Set),J=r.length>0?r:H,je=w.useMemo(()=>ee.size,[ee]);w.useEffect(()=>{re(BJe())},[]),w.useEffect(()=>{t&&((async()=>{j(!0);try{const pe=await ne.getCloudStatus();if(M(pe.is_authenticated),pe.is_authenticated){const te=await ne.getFilamentPresets();E(te)}}catch(pe){console.error("Failed to fetch cloud presets:",pe),M(!1)}finally{j(!1)}})(),ne.getSpoolCatalog().then(D).catch(console.error),ne.getColorCatalog().then(W).catch(console.error),ne.getLocalPresets().then(pe=>G(pe.filament)).catch(console.error),r.length===0&&(async()=>{try{const pe=await ne.getPrinters(),te=await Promise.all(pe.map(Ie=>ne.getPrinterStatus(Ie.id).catch(()=>null))),Be=[];for(let Ie=0;Ie({cali_idx:ye.slot_id,filament_id:ye.filament_id,setting_id:ye.setting_id||"",name:ye.name,k_value:parseFloat(ye.k_value)||0,n_coef:parseFloat(ye.n_coef)||0,extruder_id:ye.extruder_id,nozzle_diameter:ye.nozzle_diameter}))}catch{}Be.push({printer:{...$e,connected:fe},calibrations:xe})}K(Be)}catch(pe){console.error("Failed to fetch printer calibrations:",pe)}})())},[t,r.length]);const de=w.useMemo(()=>zJe(P,new Set,$),[P,$]),le=w.useMemo(()=>{const ce=OJe(P,$),pe=U.map(Be=>Be.manufacturer?.trim()).filter(Be=>!!Be),te=new Set([...ce,...pe]);return Array.from(te).sort((Be,Ie)=>Be.localeCompare(Ie))},[P,$,U]),_e=w.useMemo(()=>{const ce=U.map(te=>te.material?.trim()).filter(te=>!!te),pe=new Set([...jJe,...ce]);return Array.from(pe).sort((te,Be)=>te.localeCompare(Be))},[U]),se=w.useMemo(()=>{const ce=[];for(const pe of U){const te=pe.manufacturer?.trim(),Be=pe.material?.trim();te&&Be&&ce.push({brand:te,material:Be})}for(const pe of P){const te=Ob(pe.name);te.brand&&te.material&&ce.push({brand:te.brand,material:te.material})}for(const pe of $){const te=Ob(pe.name),Be=pe.filament_vendor?.trim()||te.brand,Ie=te.material;Be&&Ie&&ce.push({brand:Be,material:Ie})}return ce},[P,U,$]),ze=w.useMemo(()=>{const ce=new Map;for(const pe of se){const te=pe.brand.toLowerCase(),Be=pe.material.toLowerCase();ce.has(te)||ce.set(te,new Set),ce.get(te).add(Be)}return ce},[se]),V=w.useMemo(()=>{const ce=new Map;for(const pe of se){const te=pe.brand.toLowerCase(),Be=pe.material.toLowerCase();ce.has(Be)||ce.set(Be,new Set),ce.get(Be).add(te)}return ce},[se]),X=w.useMemo(()=>{if(!d.material)return le;const ce=d.material.toLowerCase(),pe=V.get(ce);return!pe||pe.size===0?le:le.filter(te=>pe.has(te.toLowerCase()))},[le,d.material,V]),me=w.useMemo(()=>{if(!d.brand)return _e;const ce=d.brand.toLowerCase(),pe=ze.get(ce);return!pe||pe.size===0?_e:_e.filter(te=>pe.has(te.toLowerCase()))},[_e,d.brand,ze]),Q=w.useMemo(()=>UJe(d.slicer_filament,de),[d.slicer_filament,de]);w.useEffect(()=>{if(t){if(n)if(u({material:n.material||"",subtype:n.subtype||"",brand:n.brand||"",color_name:n.color_name||"",rgba:n.rgba||"808080FF",label_weight:n.label_weight||1e3,core_weight:n.core_weight||250,core_weight_catalog_id:n.core_weight_catalog_id??null,weight_used:n.weight_used||0,slicer_filament:n.slicer_filament||"",note:n.note||"",cost_per_kg:n.cost_per_kg??null}),O(n.slicer_filament_name||n.slicer_filament||""),n.k_profiles&&n.k_profiles.length>0){const ce=new Set;for(const pe of n.k_profiles)pe.cali_idx!==null&&pe.cali_idx!==void 0&&ce.add(`${pe.printer_id}:${pe.cali_idx}:${pe.extruder??"null"}`);Z(ce)}else Z(new Set);else u(oK),O(""),Z(new Set),_(!1),T(1);f({}),x("filament"),g(!1)}},[t,n]),w.useEffect(()=>{t&&J.length>0&&oe(new Set(J.map(ce=>String(ce.printer.id))))},[t,J]);const ie=(ce,pe)=>{u(te=>({...te,[ce]:pe})),ce==="weight_used"&&g(!0),h[ce]&&f(te=>({...te,[ce]:void 0}))},ue=ce=>{re(pe=>HJe(ce,pe))},Le=st({mutationFn:ce=>ne.createSpool(ce),onSuccess:async ce=>{ee.size>0&&ce?.id&&await L(ce.id),await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolCreated"),"success"),e()},onError:ce=>{l(ce.message,"error")}}),Ce=st({mutationFn:({data:ce,qty:pe})=>ne.bulkCreateSpools(ce,pe),onSuccess:async ce=>{if(ee.size>0)for(const pe of ce)await L(pe.id);await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolsCreated",{count:ce.length}),"success"),e()},onError:ce=>{l(ce.message,"error")}}),ge=st({mutationFn:ce=>ne.updateSpool(n.id,ce),onSuccess:async()=>{n?.id&&await L(n.id),await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolUpdated"),"success"),e()},onError:ce=>{l(ce.message,"error")}}),L=async ce=>{if(ee.size===0){try{await ne.saveSpoolKProfiles(ce,[])}catch{}return}const pe=[];for(const te of ee){const[Be,Ie,$e]=te.split(":"),Re=parseInt(Be),fe=parseInt(Ie),xe=$e==="null"?0:parseInt($e),Ne=J.find(ye=>ye.printer.id===Re);if(Ne){const ye=Ne.calibrations.find(ve=>ve.cali_idx===fe);ye&&pe.push({printer_id:Re,extruder:xe,nozzle_diameter:ye.nozzle_diameter||"0.4",k_value:ye.k_value,name:ye.name||null,cali_idx:ye.cali_idx,setting_id:ye.setting_id||null})}}if(pe.length>0)try{await ne.saveSpoolKProfiles(ce,pe)}catch(te){console.error("Failed to save K-profiles:",te)}};if(w.useEffect(()=>{if(!t)return;const ce=pe=>{pe.key==="Escape"&&e()};return document.addEventListener("keydown",ce),()=>document.removeEventListener("keydown",ce)},[t,e]),!t)return null;const R=()=>{const ce=EJe(d,y);if(!ce.isValid){f(ce.errors),(ce.errors.slicer_filament||ce.errors.material||ce.errors.brand||ce.errors.subtype)&&x("filament");return}const pe=Q?.displayName||B||null,te={material:d.material,subtype:d.subtype||null,brand:d.brand||null,color_name:d.color_name||null,rgba:d.rgba||null,label_weight:d.label_weight,core_weight:d.core_weight,core_weight_catalog_id:d.core_weight_catalog_id,slicer_filament:d.slicer_filament||null,slicer_filament_name:pe,nozzle_temp_min:null,nozzle_temp_max:null,note:d.note||null,cost_per_kg:d.cost_per_kg};(!c||v)&&(te.weight_used=d.weight_used),c?ge.mutate(te):N>1?Ce.mutate({data:te,qty:N}):Le.mutate(te)},q=Le.isPending||Ce.isPending||ge.isPending;return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.jsxs("div",{className:"relative w-full max-w-xl mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:s(c?"inventory.editSpool":"inventory.addSpool")}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),!c&&a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(nu,{className:"w-4 h-4 text-amber-400"}),a.jsx("span",{className:"text-sm text-white",children:s("inventory.quickAdd")})]}),a.jsx("button",{type:"button",onClick:()=>{_(!y),y||x("filament")},className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${y?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${y?"translate-x-4":"translate-x-0.5"}`})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("button",{onClick:()=>x("filament"),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${p==="filament"?"text-bambu-green border-b-2 border-bambu-green":"text-bambu-gray hover:text-white"}`,children:[a.jsx(WC,{className:"w-4 h-4"}),s("inventory.filamentInfoTab")]}),!y&&a.jsxs("button",{onClick:()=>x("pa-profile"),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${p==="pa-profile"?"text-bambu-green border-b-2 border-bambu-green":"text-bambu-gray hover:text-white"}`,children:[a.jsx(Hue,{className:"w-4 h-4"}),s("inventory.paProfileTab"),je>0&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:je})]})]}),a.jsx("div",{className:"p-4 overflow-y-auto flex-1",style:{scrollbarGutter:"stable"},children:p==="filament"?a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:s("inventory.filamentInfo")}),a.jsx($Je,{formData:d,updateField:ie,cloudAuthenticated:k,loadingCloudPresets:C,presetInputValue:B,setPresetInputValue:O,selectedPresetOption:Q,filamentOptions:de,availableBrands:X,availableMaterials:me,quickAdd:y,quantity:N,onQuantityChange:T,errors:h})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:s("inventory.color")}),a.jsx(VJe,{formData:d,updateField:ie,recentColors:Y,onColorUsed:ue,catalogColors:U})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:s("inventory.additional")}),a.jsx(GJe,{formData:d,updateField:ie,spoolCatalog:z,currencySymbol:i})]}),c&&n&&a.jsx("div",{children:a.jsx(XJe,{spoolId:n.id})})]}):a.jsx(WJe,{formData:d,updateField:ie,printersWithCalibrations:J,selectedProfiles:ee,setSelectedProfiles:Z,expandedPrinters:we,setExpandedPrinters:oe})}),a.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx(Me,{variant:"secondary",onClick:e,children:s("common.cancel")}),a.jsx(Me,{onClick:R,disabled:q,children:q?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),s("common.saving")]}):a.jsxs(a.Fragment,{children:[a.jsx(bs,{className:"w-4 h-4"}),s(c?"common.save":"inventory.addSpool")]})})]})]})]})}function ZJe({isOpen:t,onClose:e,columns:n,defaultColumns:r,onSave:i}){const{t:s}=Dt(),[o,l]=w.useState(n),[c,d]=w.useState(null),u=w.useRef(null);if(w.useEffect(()=>{t&&l(n.map(T=>({...T})))},[t,n]),w.useEffect(()=>{if(!t)return;const T=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t,e]),!t)return null;const h=T=>{l(k=>k.map((M,C)=>C===T?{...M,visible:!M.visible}:M))},f=(T,k)=>{k<0||k>=o.length||l(M=>{const C=[...M],[j]=C.splice(T,1);return C.splice(k,0,j),C})},p=(T,k)=>{u.current=k,d(k),T.dataTransfer.effectAllowed="move"},x=(T,k)=>{T.preventDefault(),T.dataTransfer.dropEffect="move";const M=u.current;M!==null&&M!==k&&(f(M,k),u.current=k,d(k))},v=T=>{T.preventDefault()},g=()=>{u.current=null,d(null)},y=()=>{l(r.map(T=>({...T})))},_=()=>{i(o),e()},N=o.filter(T=>T.visible).length;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsx(wt,{className:"w-full max-w-md max-h-[80vh] flex flex-col",onClick:T=>T.stopPropagation(),children:a.jsxs(Nt,{className:"p-6 flex flex-col min-h-0",children:[a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:s("inventory.configureColumns")}),a.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:[s("inventory.configureColumnsDesc"),a.jsxs("span",{className:"ml-2 text-bambu-gray/60",children:["(",N," ",s("inventory.of")," ",o.length," ",s("inventory.visible"),")"]})]}),a.jsx("div",{className:"space-y-1 overflow-y-auto flex-1 min-h-0 pr-1",children:o.map((T,k)=>a.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg border transition-colors ${c===k?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-tertiary/50"} ${T.visible?"":"opacity-50"}`,draggable:!0,onDragStart:M=>p(M,k),onDragOver:M=>x(M,k),onDrop:v,onDragEnd:g,children:[a.jsx("div",{className:"cursor-grab text-bambu-gray/50 hover:text-bambu-gray",children:a.jsx(Eh,{className:"w-4 h-4"})}),a.jsx("span",{className:"flex-1 font-medium text-sm text-white",children:T.label}),a.jsxs("div",{className:"flex items-center gap-0.5",children:[a.jsx("button",{onClick:()=>f(k,k-1),disabled:k===0,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed",title:s("inventory.moveUp"),children:a.jsx(yl,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>f(k,k+1),disabled:k===o.length-1,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed",title:s("inventory.moveDown"),children:a.jsx(Pn,{className:"w-4 h-4"})})]}),a.jsx("button",{onClick:()=>h(k),className:`p-1.5 rounded transition-colors ${T.visible?"text-bambu-green hover:bg-bambu-green/10":"text-bambu-gray/50 hover:bg-bambu-dark-secondary"}`,title:T.visible?s("inventory.hideColumn"):s("inventory.showColumn"),children:T.visible?a.jsx(Xl,{className:"w-4 h-4"}):a.jsx(c0,{className:"w-4 h-4"})})]},T.id))}),a.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs(Me,{variant:"secondary",onClick:y,className:"mr-auto",children:[a.jsx(so,{className:"w-4 h-4"}),s("inventory.reset")]}),a.jsx(Me,{variant:"secondary",onClick:e,children:s("inventory.cancel")}),a.jsx(Me,{onClick:_,children:s("inventory.applyChanges")})]})]})})})}function cK(t){return`${t.material}|${t.subtype||""}|${t.brand||""}|${t.color_name||""}|${t.rgba||""}|${t.label_weight}`}const tse="bambuddy-inventory-columns",u1=[{id:"id",label:"#",visible:!0},{id:"added_time",label:"Added",visible:!0},{id:"encode_time",label:"Encoded",visible:!1},{id:"last_used_time",label:"Last Used",visible:!1},{id:"rgba",label:"Color",visible:!0},{id:"material",label:"Material",visible:!0},{id:"subtype",label:"Subtype",visible:!0},{id:"color_name",label:"Color Name",visible:!1},{id:"brand",label:"Brand",visible:!0},{id:"slicer_filament",label:"Slicer Filament",visible:!1},{id:"location",label:"Location",visible:!0},{id:"label_weight",label:"Label",visible:!0},{id:"net",label:"Net",visible:!0},{id:"gross",label:"Gross",visible:!1},{id:"added_full",label:"Full",visible:!1},{id:"used",label:"Used",visible:!1},{id:"printed_total",label:"Printed Total",visible:!1},{id:"printed_since_weight",label:"Printed Since Weight",visible:!1},{id:"note",label:"Note",visible:!1},{id:"pa_k",label:"PA(K)",visible:!0},{id:"tag_id",label:"Tag ID",visible:!1},{id:"data_origin",label:"Data Origin",visible:!1},{id:"tag_type",label:"Linked Tag Type",visible:!1},{id:"stock",label:"Stock",visible:!1},{id:"remaining",label:"Remaining",visible:!0},{id:"cost_per_kg",label:"Cost/kg",visible:!1}];function JJe(){try{const t=localStorage.getItem(tse);if(t){const e=JSON.parse(t),n=new Set(u1.map(o=>o.id)),r=new Set(e.map(o=>o.id)),i=e.filter(o=>n.has(o.id)),s=u1.filter(o=>!r.has(o.id));return[...i,...s]}}catch{}return u1.map(t=>({...t}))}function eet(t){try{localStorage.setItem(tse,JSON.stringify(t))}catch{}}function Mc(t,e=!1){return e&&t>=1e3?`${(t/1e3).toFixed(1)}kg`:`${Math.round(t)}g`}const tet={PLA:"bg-green-500/20 text-green-400",ABS:"bg-red-500/20 text-red-400",PETG:"bg-blue-500/20 text-blue-400",TPU:"bg-purple-500/20 text-purple-400",ASA:"bg-orange-500/20 text-orange-400",PA:"bg-yellow-500/20 text-yellow-400",PC:"bg-cyan-500/20 text-cyan-400",PET:"bg-sky-500/20 text-sky-400"};function Lj(t,e="system"){if(!t)return"-";const n=er(t);return n?d3(n,e):"-"}const net={id:()=>"#",added_time:()=>"Added",encode_time:()=>"Encoded",last_used_time:()=>"Last Used",rgba:t=>t("inventory.color"),material:t=>t("inventory.material"),subtype:t=>t("inventory.subtype"),color_name:t=>t("inventory.colorName"),brand:t=>t("inventory.brand"),slicer_filament:t=>t("inventory.slicerFilament"),location:()=>"Location",label_weight:t=>t("inventory.labelWeight"),net:t=>t("inventory.net"),gross:()=>"Gross",added_full:()=>"Full",used:t=>t("inventory.weightUsed"),printed_total:()=>"Printed Total",printed_since_weight:()=>"Printed Since Weight",note:t=>t("inventory.note"),pa_k:()=>"PA(K)",tag_id:()=>"Tag ID",data_origin:()=>"Data Origin",tag_type:()=>"Linked Tag Type",stock:t=>t("inventory.stock"),remaining:t=>t("inventory.remaining"),cost_per_kg:t=>t("inventory.costPerKg")},iF={id:({spool:t})=>a.jsx("span",{className:"text-sm font-medium text-white",children:t.id}),added_time:({spool:t,dateFormat:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:Lj(t.created_at,e)}),encode_time:({spool:t,dateFormat:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:Lj(t.encode_time,e)}),last_used_time:({spool:t,dateFormat:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.last_used?Lj(t.last_used,e):"Never"}),rgba:({spool:t})=>a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("span",{className:"w-5 h-5 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:t.rgba?`#${t.rgba.substring(0,6)}`:"#808080"},title:t.rgba?`#${t.rgba.substring(0,6)}`:void 0})}),material:({spool:t})=>a.jsx("span",{className:"text-sm text-white",children:t.material}),subtype:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.subtype||"-"}),color_name:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:b4(t.color_name,t.rgba)||"-"}),brand:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.brand||"-"}),slicer_filament:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",title:t.slicer_filament||void 0,children:t.slicer_filament_name||t.slicer_filament||"-"}),location:({spool:t,assignmentMap:e})=>{const n=e[t.id];if(!n)return a.jsx("span",{className:"text-sm text-bambu-gray",children:"-"});const r=n.printer_name||`Printer ${n.printer_id}`,i=n.ams_id===254||n.ams_id===255,s=!i&&n.ams_id>=128,o=m4(n.ams_id,n.tray_id,s,i);return a.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-purple-500/20 text-purple-400",children:[r," ",o]})},label_weight:({spool:t})=>a.jsx("span",{className:"text-sm text-white",children:Mc(t.label_weight)}),net:({remaining:t})=>a.jsx("span",{className:"text-sm text-white",children:Mc(t)}),gross:({spool:t,remaining:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:Mc(e+t.core_weight)}),added_full:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.added_full==null?"-":t.added_full?"Yes":"No"}),used:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.weight_used>0?Mc(t.weight_used):"-"}),printed_total:()=>a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"}),printed_since_weight:()=>a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"}),note:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray max-w-[150px] truncate block",title:t.note||void 0,children:t.note||"-"}),pa_k:({spool:t})=>(t.k_profiles?.length??0)===0?a.jsx("span",{className:"text-sm text-bambu-gray",children:"-"}):a.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-bambu-green/20 text-bambu-green",children:"K"}),tag_id:({spool:t})=>{const e=t.tag_uid||t.tray_uuid;return e?a.jsx("span",{className:"text-sm text-bambu-gray font-mono",title:e,children:e.length>12?`${e.slice(0,6)}...${e.slice(-4)}`:e}):a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"})},data_origin:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.data_origin||"-"}),tag_type:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.tag_type||"-"}),stock:({spool:t,t:e})=>t.slicer_filament?a.jsx("span",{className:"text-sm text-bambu-gray",children:"-"}):a.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-amber-500/20 text-amber-400",children:e("inventory.stock")}),remaining:({remaining:t,pct:e})=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full ${e>50?"bg-bambu-green":e>20?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(e,100)}%`}})}),a.jsxs("span",{className:"text-xs text-bambu-gray min-w-[40px] text-right",children:[Math.round(t),"g"]})]}),cost_per_kg:({spool:t,currencySymbol:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.cost_per_kg!=null?`${e}${t.cost_per_kg.toFixed(2)}`:"-"})},Oj={id:t=>t.id,added_time:t=>t.created_at||"",encode_time:t=>t.encode_time||"",last_used_time:t=>t.last_used||"",material:t=>(t.material||"").toLowerCase(),subtype:t=>(t.subtype||"").toLowerCase(),color_name:t=>(t.color_name||"").toLowerCase(),brand:t=>(t.brand||"").toLowerCase(),slicer_filament:t=>(t.slicer_filament_name||t.slicer_filament||"").toLowerCase(),location:(t,e)=>{const n=e[t.id];if(!n)return"";const r=n.ams_id===254||n.ams_id===255,i=!r&&n.ams_id>=128;return`${n.printer_name||""} ${m4(n.ams_id,n.tray_id,i,r)}`},label_weight:t=>t.label_weight,net:t=>Math.max(0,t.label_weight-t.weight_used),gross:t=>Math.max(0,t.label_weight-t.weight_used)+t.core_weight,used:t=>t.weight_used,remaining:t=>t.label_weight>0?Math.max(0,t.label_weight-t.weight_used)/t.label_weight:0,note:t=>(t.note||"").toLowerCase(),data_origin:t=>(t.data_origin||"").toLowerCase(),tag_type:t=>(t.tag_type||"").toLowerCase(),stock:t=>t.slicer_filament?1:0,cost_per_kg:t=>t.cost_per_kg??0},sF="bambuddy-inventory-sort";function ret(){try{const t=localStorage.getItem(sF);if(t)return JSON.parse(t)}catch{}return null}function aet(t){try{t?localStorage.setItem(sF,JSON.stringify(t)):localStorage.removeItem(sF)}catch{}}function iet(){const{data:t}=Je({queryKey:["spoolman-settings"],queryFn:ne.getSpoolmanSettings,staleTime:3e5});return t?.spoolman_enabled==="true"&&t?.spoolman_url?a.jsx("iframe",{src:t.spoolman_url,className:"h-full w-full border-0",title:"Spoolman",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"}):a.jsx(set,{})}function set(){const{t}=Dt(),e=Jt(),{showToast:n}=ln(),[r,i]=w.useState(null),[s,o]=w.useState(null),[l,c]=w.useState("active"),[d,u]=w.useState("all"),[h,f]=w.useState(""),[p,x]=w.useState(""),[v,g]=w.useState("all"),[y,_]=w.useState(""),[N,T]=w.useState("table"),[k,M]=w.useState(ret),[C,j]=w.useState(JJe),[P,E]=w.useState(!1),[B,O]=w.useState(()=>{try{return localStorage.getItem("bambuddy-inventory-group")==="true"}catch{return!1}}),[z,D]=w.useState(new Set),[$,G]=w.useState(0),[U,W]=w.useState(()=>{try{const Re=localStorage.getItem("bambuddy-inventory-pageSize");if(Re){const fe=Number(Re);if([15,30,50,100,-1].includes(fe))return fe}}catch{}return 15}),{data:Y}=Je({queryKey:["settings"],queryFn:ne.getSettings}),re=Y?.date_format||"system",{data:H,isLoading:K}=Je({queryKey:["inventory-spools"],queryFn:()=>ne.getSpools(!0),refetchInterval:3e4}),{data:ee}=Je({queryKey:["spool-assignments"],queryFn:()=>ne.getAssignments(),refetchInterval:3e4}),Z=st({mutationFn:Re=>ne.deleteSpool(Re),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolDeleted"),"success")}}),we=st({mutationFn:Re=>ne.archiveSpool(Re),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolArchived"),"success")}}),oe=st({mutationFn:Re=>ne.restoreSpool(Re),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolRestored"),"success")}}),J=w.useMemo(()=>{if(!H)return null;let Re=0,fe=0,xe=0,Ne=0;const ye={};for(const ve of H){if(ve.archived_at)continue;Ne++;const Ge=Math.max(0,ve.label_weight-ve.weight_used);Re+=Ge,fe+=ve.weight_used,(ve.label_weight>0?Ge/ve.label_weight*100:0)<20&&xe++;const nt=ve.material||"Unknown";ye[nt]||(ye[nt]={count:0,weight:0}),ye[nt].count++,ye[nt].weight+=Ge}return{totalWeight:Re,totalConsumed:fe,lowStock:xe,byMaterial:ye,totalSpools:Ne}},[H]),je=ee?.length??0,de=rl(Y?.currency||"USD"),le=w.useMemo(()=>{const Re={};for(const fe of ee||[])Re[fe.spool_id]=fe;return Re},[ee]),_e=w.useMemo(()=>J?Object.entries(J.byMaterial).sort((Re,fe)=>fe[1].weight-Re[1].weight).slice(0,4):[],[J]),se=w.useMemo(()=>{let Re=H||[];if(l==="active"?Re=Re.filter(fe=>!fe.archived_at):Re=Re.filter(fe=>!!fe.archived_at),d==="used"?Re=Re.filter(fe=>fe.weight_used>0):d==="new"&&(Re=Re.filter(fe=>fe.weight_used===0)),h&&(Re=Re.filter(fe=>fe.material===h)),p&&(Re=Re.filter(fe=>fe.brand===p)),v==="stock"?Re=Re.filter(fe=>!fe.slicer_filament):v==="configured"&&(Re=Re.filter(fe=>!!fe.slicer_filament)),y){const fe=y.toLowerCase();Re=Re.filter(xe=>xe.brand?.toLowerCase().includes(fe)||xe.material.toLowerCase().includes(fe)||xe.color_name?.toLowerCase().includes(fe)||xe.subtype?.toLowerCase().includes(fe)||xe.note?.toLowerCase().includes(fe)||xe.slicer_filament_name?.toLowerCase().includes(fe))}return Re},[H,l,d,h,p,v,y]),ze=()=>G(0),V=[...new Set(H?.map(Re=>Re.material)||[])].sort(),X=[...new Set(H?.map(Re=>Re.brand).filter(Boolean)||[])].sort(),me=l!=="active"||d!=="all"||!!h||!!p||v!=="all"||!!y,Q=Re=>{j(Re),eet(Re)},ie=w.useMemo(()=>C.filter(Re=>Re.visible).map(Re=>Re.id),[C]),ue=Re=>{Oj[Re]&&(M(fe=>{let xe;return fe?.column===Re?xe=fe.direction==="asc"?{column:Re,direction:"desc"}:null:xe={column:Re,direction:"asc"},aet(xe),xe}),ze())},Le=w.useMemo(()=>{if(!k)return se;const Re=Oj[k.column];return Re?[...se].sort((xe,Ne)=>{const ye=Re(xe,le),ve=Re(Ne,le);return yeve?k.direction==="asc"?1:-1:0}):se},[se,k,le]),Ce=w.useMemo(()=>{if(!B)return Le.map(Ne=>({type:"single",spool:Ne}));const Re=new Map;for(const Ne of Le)if(!(Ne.weight_used>0||le[Ne.id])){const ye=cK(Ne),ve=Re.get(ye);ve?ve.push(Ne):Re.set(ye,[Ne])}const fe=[],xe=new Set;for(const Ne of Le){if(Ne.weight_used>0||le[Ne.id]){fe.push({type:"single",spool:Ne});continue}const ye=cK(Ne);if(xe.has(ye))continue;xe.add(ye);const ve=Re.get(ye);ve.length===1?fe.push({type:"single",spool:ve[0]}):fe.push({type:"group",key:ye,spools:ve,representative:ve[0]})}return fe},[Le,B,le]),ge=U===-1,L=Ce.length,R=ge?L||1:U,q=Math.max(1,Math.ceil(L/R)),ce=ge?0:Math.min($,q-1),pe=ge?Ce:Ce.slice(ce*R,(ce+1)*R),te=()=>{const Re=!B;O(Re),D(new Set),ze();try{localStorage.setItem("bambuddy-inventory-group",String(Re))}catch{}},Be=Re=>{D(fe=>{const xe=new Set(fe);return xe.has(Re)?xe.delete(Re):xe.add(Re),xe})},Ie=Re=>{W(Re),G(0);try{localStorage.setItem("bambuddy-inventory-pageSize",String(Re))}catch{}},$e=()=>{c("active"),u("all"),f(""),x(""),g("all"),_(""),ze()};return a.jsxs("div",{className:"p-4 md:p-6 space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(xi,{className:"w-6 h-6 text-bambu-green"}),a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("inventory.title")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-9",children:(t("inventory.noSpools").split(".")[0],"")})]}),a.jsxs(Me,{onClick:()=>i({spool:null}),children:[a.jsx(Xn,{className:"w-4 h-4"}),t("inventory.addSpool")]})]}),J&&!K&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-3",children:[a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(xi,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.totalInventory")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:Mc(J.totalWeight,!0)}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[J.totalSpools," ",J.totalSpools!==1?t("inventory.spools"):t("inventory.spool")]})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(MF,{className:"w-4 h-4 text-blue-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.totalConsumed")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:Mc(J.totalConsumed,!0)}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.sinceTracking")})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(oi,{className:"w-4 h-4 text-green-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.byMaterial")})]}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:_e.map(([Re,fe])=>a.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${tet[Re]||"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Re," ",a.jsx("span",{className:"opacity-70",children:Mc(fe.weight,!0)})]},Re))})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(Sr,{className:"w-4 h-4 text-purple-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.inPrinter")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:je}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.loadedInAms")})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(An,{className:"w-4 h-4 text-yellow-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.lowStock")})]}),a.jsx("div",{className:`text-xl font-bold ${J.lowStock>0?"text-yellow-400":"text-white"}`,children:J.lowStock}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.lowStockThreshold")})]})]}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 items-start sm:items-center justify-between",children:[a.jsxs("div",{className:"relative flex-1 max-w-md",children:[a.jsx(Mr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50"}),a.jsx("input",{type:"text",value:y,onChange:Re=>{_(Re.target.value),ze()},placeholder:t("inventory.search"),className:"w-full pl-10 pr-8 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green"}),y&&a.jsx("button",{onClick:()=>{_(""),ze()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[N==="table"&&a.jsxs("button",{onClick:()=>E(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-bambu-gray border border-bambu-dark-tertiary rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:t("inventory.configureColumns"),children:[a.jsx(Hhe,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.columns")})]}),a.jsxs("button",{onClick:te,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium border rounded-lg transition-colors ${B?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,title:t("inventory.groupSimilar"),children:[a.jsx(Lme,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.groupSimilar")})]}),a.jsxs("div",{className:"flex bg-bambu-dark-primary border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>T("table"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${N==="table"?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(Tpe,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.table")})]}),a.jsxs("button",{onClick:()=>T("cards"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${N==="cards"?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(u0,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.cards")})]})]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsxs("button",{onClick:()=>{c("active"),ze()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${l==="active"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(xi,{className:"w-3.5 h-3.5"}),t("inventory.active")]}),a.jsxs("button",{onClick:()=>{c("archived"),ze()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${l==="archived"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(Ds,{className:"w-3.5 h-3.5"}),t("inventory.archived")]})]}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsx("button",{onClick:()=>{u("all"),ze()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${d==="all"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.all")}),a.jsxs("button",{onClick:()=>{u("used"),ze()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${d==="used"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(Vn,{className:"w-3.5 h-3.5"}),t("inventory.used")]}),a.jsx("button",{onClick:()=>{u("new"),ze()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${d==="new"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.new")})]}),a.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsx("button",{onClick:()=>{g("all"),ze()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${v==="all"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.all")}),a.jsx("button",{onClick:()=>{g("stock"),ze()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${v==="stock"?"bg-amber-500/20 text-amber-400":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.stock")}),a.jsx("button",{onClick:()=>{g("configured"),ze()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${v==="configured"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.configured")})]}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("select",{value:h,onChange:Re=>{f(Re.target.value),ze()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${h?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,children:[a.jsx("option",{value:"",children:t("inventory.material")}),V.map(Re=>a.jsx("option",{value:Re,children:Re},Re))]}),a.jsxs("select",{value:p,onChange:Re=>{x(Re.target.value),ze()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${p?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,children:[a.jsx("option",{value:"",children:t("inventory.brand")}),X.map(Re=>a.jsx("option",{value:Re,children:Re},Re))]}),me&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("button",{onClick:$e,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:[a.jsx(Rt,{className:"w-3.5 h-3.5"}),t("inventory.clearFilters")]})]}),a.jsxs("span",{className:"ml-auto text-xs text-bambu-gray",children:[Le.length," ",Le.length!==1?t("inventory.spools"):t("inventory.spool"),B&&L0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:pe.map(Re=>{if(Re.type==="group"){const{key:ve,spools:Ge,representative:Te}=Re,nt=Te.rgba?`#${Te.rgba.substring(0,6)}`:"#808080",De=z.has(ve);return a.jsxs("div",{className:"col-span-full",children:[a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-green/30 hover:border-bambu-green transition-colors cursor-pointer",onClick:()=>Be(ve),children:[a.jsx("div",{className:"h-10 flex items-center px-4 gap-3",style:{backgroundColor:nt},children:a.jsx("span",{className:"bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium",children:b4(Te.color_name,Te.rgba)||"-"})}),a.jsxs("div",{className:"px-4 py-3 flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Pn,{className:`w-4 h-4 text-bambu-gray transition-transform ${De?"":"-rotate-90"}`}),a.jsxs("div",{children:[a.jsxs("h3",{className:"font-semibold text-white",children:[Te.material,Te.subtype?` ${Te.subtype}`:""]}),a.jsx("p",{className:"text-sm text-bambu-gray",children:Te.brand||"-"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:Mc(Te.label_weight)}),a.jsx("span",{className:"text-xs font-medium bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full",children:t("inventory.groupedSpools",{count:Ge.length})})]})]})]}),De&&a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 mt-2 ml-4",children:Ge.map(Ke=>{const Oe=Math.max(0,Ke.label_weight-Ke.weight_used),Ee=Ke.label_weight>0?Oe/Ke.label_weight*100:0,Ve=Ke.rgba?`#${Ke.rgba.substring(0,6)}`:"#808080";return a.jsx(dK,{spool:Ke,remaining:Oe,pct:Ee,colorStyle:Ve,onClick:()=>i({spool:Ke}),t},Ke.id)})})]},`group-${ve}`)}const fe=Re.spool,xe=Math.max(0,fe.label_weight-fe.weight_used),Ne=fe.label_weight>0?xe/fe.label_weight*100:0,ye=fe.rgba?`#${fe.rgba.substring(0,6)}`:"#808080";return a.jsx(dK,{spool:fe,remaining:xe,pct:Ne,colorStyle:ye,onClick:()=>i({spool:fe}),t},fe.id)})}),a.jsx(oet,{pageIndex:ce,pageSize:U,totalRows:L,totalPages:q,onPageChange:G,onPageSizeChange:Ie,t})]}):a.jsx(uK,{hasFilters:me,onAddSpool:()=>i({spool:null}),t}):pe.length>0?a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/30",children:[ie.map(Re=>{const fe=!!Oj[Re],xe=k?.column===Re;return a.jsx("th",{className:`text-left py-3 px-4 text-xs font-medium uppercase tracking-wide select-none ${Re==="remaining"?"min-w-[150px]":""} ${fe?"cursor-pointer hover:text-bambu-green transition-colors":""} ${xe?"text-bambu-green":"text-bambu-gray"}`,onClick:fe?()=>ue(Re):void 0,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[net[Re]?.(t)??Re,fe&&(xe?k.direction==="asc"?a.jsx(Mf,{className:"w-3 h-3"}):a.jsx(lb,{className:"w-3 h-3"}):a.jsx(NF,{className:"w-3 h-3 opacity-30"}))]})},Re)}),a.jsx("th",{className:"text-right py-3 px-4 text-xs font-medium text-bambu-gray uppercase tracking-wide",children:t("common.actions")})]})}),a.jsx("tbody",{children:pe.map(Re=>{if(Re.type==="group"){const{key:ye,spools:ve,representative:Ge}=Re,Te=z.has(ye),nt=Math.max(0,Ge.label_weight-Ge.weight_used),De=Ge.label_weight>0?nt/Ge.label_weight*100:0;return a.jsx(cet,{spools:ve,representative:Ge,remaining:nt,pct:De,isExpanded:Te,onToggle:()=>Be(ye),onEdit:Ke=>i({spool:Ke}),onArchive:Ke=>o({type:"archive",spoolId:Ke}),onDelete:Ke=>o({type:"delete",spoolId:Ke}),visibleColumns:ie,assignmentMap:le,currencySymbol:de,dateFormat:re,t},`group-${ye}`)}const fe=Re.spool,xe=Math.max(0,fe.label_weight-fe.weight_used),Ne=fe.label_weight>0?xe/fe.label_weight*100:0;return a.jsx(nse,{spool:fe,remaining:xe,pct:Ne,onEdit:()=>i({spool:fe}),onRestore:()=>oe.mutate(fe.id),onArchive:()=>o({type:"archive",spoolId:fe.id}),onDelete:()=>o({type:"delete",spoolId:fe.id}),visibleColumns:ie,assignmentMap:le,currencySymbol:de,dateFormat:re,t},fe.id)})})]})}),a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-bambu-dark-tertiary/50 border-t border-bambu-dark-tertiary text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:ge?`${L} ${t(L!==1?"inventory.spools":"inventory.spool")}`:a.jsxs(a.Fragment,{children:[t("inventory.showing")," ",ce*R+1," ",t("inventory.to")," ",Math.min((ce+1)*R,L)," ",t("inventory.of")," ",L," ",t("inventory.spools")]})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-gray",children:t("inventory.show")}),a.jsxs("select",{value:U,onChange:Re=>Ie(Number(Re.target.value)),className:"px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green",children:[[15,30,50,100].map(Re=>a.jsx("option",{value:Re,children:Re},Re)),a.jsx("option",{value:-1,children:t("inventory.all")})]}),!ge&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>G(0),disabled:ce===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"First page",children:a.jsx(hY,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>G(Re=>Math.max(0,Re-1)),disabled:ce===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(Kl,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-bambu-gray px-2 whitespace-nowrap",children:[t("inventory.page")," ",ce+1," ",t("inventory.of")," ",q]}),a.jsx("button",{onClick:()=>G(Re=>Math.min(q-1,Re+1)),disabled:ce>=q-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(yi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>G(q-1),disabled:ce>=q-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"Last page",children:a.jsx(mY,{className:"w-4 h-4"})})]})]})]})]}):a.jsx(uK,{hasFilters:me,onAddSpool:()=>i({spool:null}),t}),r!==null&&a.jsx(QJe,{isOpen:!0,onClose:()=>i(null),spool:r.spool,currencySymbol:de}),s&&a.jsx(xn,{title:s.type==="delete"?t("common.delete"):t("inventory.archive"),message:s.type==="delete"?t("inventory.deleteConfirm"):t("inventory.archiveConfirm"),confirmText:s.type==="delete"?t("common.delete"):t("inventory.archive"),variant:s.type==="delete"?"danger":"warning",onConfirm:()=>{s.type==="delete"?Z.mutate(s.spoolId):we.mutate(s.spoolId),o(null)},onCancel:()=>o(null)}),a.jsx(ZJe,{isOpen:P,onClose:()=>E(!1),columns:C,defaultColumns:u1,onSave:Q})]})}function oet({pageIndex:t,pageSize:e,totalRows:n,totalPages:r,onPageChange:i,onPageSizeChange:s,t:o}){const l=e===-1;if(r<=1&&!l)return null;const c=l?n||1:e;return a.jsxs("div",{className:"flex items-center justify-between pt-2 text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:l?`${n} ${o(n!==1?"inventory.spools":"inventory.spool")}`:a.jsxs(a.Fragment,{children:[o("inventory.showing")," ",t*c+1," ",o("inventory.to")," ",Math.min((t+1)*c,n)," ",o("inventory.of")," ",n," ",o("inventory.spools")]})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-gray",children:o("inventory.show")}),a.jsxs("select",{value:e,onChange:d=>s(Number(d.target.value)),className:"px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green",children:[[15,30,50,100].map(d=>a.jsx("option",{value:d,children:d},d)),a.jsx("option",{value:-1,children:o("inventory.all")})]}),!l&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>i(0),disabled:t===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(hY,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>i(Math.max(0,t-1)),disabled:t===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(Kl,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-bambu-gray px-2 whitespace-nowrap",children:[o("inventory.page")," ",t+1," ",o("inventory.of")," ",r]}),a.jsx("button",{onClick:()=>i(Math.min(r-1,t+1)),disabled:t>=r-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(yi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>i(r-1),disabled:t>=r-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(mY,{className:"w-4 h-4"})})]})]})]})}function dK({spool:t,remaining:e,pct:n,colorStyle:r,onClick:i,t:s}){return a.jsxs("div",{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors cursor-pointer ${t.archived_at?"opacity-50":""}`,onClick:i,children:[a.jsx("div",{className:"h-14 flex items-center justify-center",style:{backgroundColor:r},children:a.jsx("span",{className:"bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium",children:b4(t.color_name,t.rgba)||"-"})}),a.jsxs("div",{className:"p-4 space-y-3",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{children:[a.jsxs("h3",{className:"font-semibold text-white",children:[t.material,t.subtype?` ${t.subtype}`:""]}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t.brand||"-"})]}),a.jsxs("span",{className:"text-xs font-mono text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:["#",t.id]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray mb-1",children:[a.jsx("span",{children:s("inventory.remaining")}),a.jsxs("span",{children:[Math.round(n),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full ${n>50?"bg-bambu-green":n>20?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(n,100)}%`}})}),a.jsxs("span",{className:"text-xs text-bambu-gray min-w-[40px] text-right",children:[Math.round(e),"g"]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[a.jsxs("div",{children:[a.jsxs("span",{className:"text-bambu-gray/60",children:[s("inventory.labelWeight"),": "]}),a.jsx("span",{className:"text-bambu-gray",children:Mc(t.label_weight)})]}),a.jsxs("div",{children:[a.jsxs("span",{className:"text-bambu-gray/60",children:[s("inventory.weightUsed"),": "]}),a.jsx("span",{className:"text-bambu-gray",children:t.weight_used>0?Mc(t.weight_used):"-"})]})]}),t.note&&a.jsx("div",{className:"text-xs text-bambu-gray/60 pt-2 border-t border-bambu-dark-tertiary truncate",title:t.note,children:t.note})]})]})}function nse({spool:t,remaining:e,pct:n,onEdit:r,onRestore:i,onArchive:s,onDelete:o,visibleColumns:l,assignmentMap:c,currencySymbol:d,dateFormat:u,t:h}){return a.jsxs("tr",{className:`border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-tertiary/30 transition-colors cursor-pointer ${t.archived_at?"opacity-50":""}`,onClick:r,children:[l.map(f=>a.jsx("td",{className:"py-3 px-4",children:iF[f]?.({spool:t,remaining:e,pct:n,assignmentMap:c,currencySymbol:d,dateFormat:u,t:h})},f)),a.jsx("td",{className:"py-3 px-4",children:a.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:f=>f.stopPropagation(),children:[a.jsx("button",{onClick:r,className:"p-1.5 text-bambu-gray hover:text-white rounded transition-colors",title:h("inventory.editSpool"),children:a.jsx(ef,{className:"w-4 h-4"})}),t.archived_at?a.jsx("button",{onClick:i,className:"p-1.5 text-bambu-gray hover:text-bambu-green rounded transition-colors",title:h("inventory.restore"),children:a.jsx(so,{className:"w-4 h-4"})}):a.jsx("button",{onClick:s,className:"p-1.5 text-bambu-gray hover:text-yellow-400 rounded transition-colors",title:h("inventory.archive"),children:a.jsx(Ds,{className:"w-4 h-4"})}),a.jsx("button",{onClick:o,className:"p-1.5 text-bambu-gray hover:text-red-400 rounded transition-colors",title:h("common.delete"),children:a.jsx(Xt,{className:"w-4 h-4"})})]})})]})}function cet({spools:t,representative:e,remaining:n,pct:r,isExpanded:i,onToggle:s,onEdit:o,onArchive:l,onDelete:c,visibleColumns:d,assignmentMap:u,currencySymbol:h,dateFormat:f,t:p}){return a.jsxs(a.Fragment,{children:[a.jsxs("tr",{className:"border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-tertiary/30 transition-colors cursor-pointer bg-bambu-green/5",onClick:s,children:[d.map((x,v)=>a.jsx("td",{className:"py-3 px-4",children:v===0?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Pn,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"":"-rotate-90"}`}),iF[x]?.({spool:e,remaining:n,pct:r,assignmentMap:u,currencySymbol:h,dateFormat:f,t:p})]}):x==="id"?a.jsx("span",{className:"text-xs font-medium bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full",children:p("inventory.groupedSpools",{count:t.length})}):iF[x]?.({spool:e,remaining:n,pct:r,assignmentMap:u,currencySymbol:h,dateFormat:f,t:p})},x)),a.jsx("td",{className:"py-3 px-4",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:t.map(x=>`#${x.id}`).join(", ")})})]}),i&&t.map(x=>{const v=Math.max(0,x.label_weight-x.weight_used),g=x.label_weight>0?v/x.label_weight*100:0;return a.jsx(nse,{spool:x,remaining:v,pct:g,onEdit:()=>o(x),onRestore:()=>{},onArchive:()=>l(x.id),onDelete:()=>c(x.id),visibleColumns:d,assignmentMap:u,currencySymbol:h,dateFormat:f,t:p},x.id)})]})}function uK({hasFilters:t,onAddSpool:e,t:n}){return a.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-4",children:[a.jsxs("div",{className:"relative mb-6",children:[a.jsx("div",{className:"absolute inset-0 -m-4 bg-bambu-green/5 rounded-full blur-2xl"}),a.jsxs("div",{className:"relative flex items-center justify-center w-24 h-24 rounded-2xl bg-gradient-to-br from-bambu-dark-secondary to-bambu-dark-tertiary border border-bambu-dark-tertiary shadow-lg",children:[a.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 rounded-full bg-bambu-green/30"}),a.jsx("div",{className:"absolute -bottom-2 -left-2 w-2 h-2 rounded-full bg-bambu-green/20"}),t?a.jsx(Mr,{className:"w-10 h-10 text-bambu-gray/40",strokeWidth:1.5}):a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"w-14 h-14 rounded-full border-4 border-bambu-gray/20 flex items-center justify-center",children:a.jsx("div",{className:"w-6 h-6 rounded-full bg-bambu-gray/10 border-2 border-bambu-gray/20"})}),a.jsx("div",{className:"absolute -bottom-1 -right-1 w-6 h-6 rounded-full bg-bambu-green flex items-center justify-center shadow-md",children:a.jsx("span",{className:"text-white text-lg font-bold leading-none",children:"+"})})]})]})]}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2 text-center",children:t?n("inventory.noSpoolsMatch"):n("inventory.noSpools").split(".")[0]}),a.jsx("p",{className:"text-sm text-bambu-gray text-center max-w-sm mb-6",children:n(t?"inventory.noSpoolsMatchDesc":"inventory.noSpools")}),!t&&a.jsxs(Me,{onClick:e,children:[a.jsx(xi,{className:"w-4 h-4"}),n("inventory.addSpool")]})]})}const hK=["DEBUG","INFO","WARNING","ERROR"],Ij={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},det={DEBUG:UC,INFO:Zs,WARNING:An,ERROR:Wa};function uet(){const t=Jt(),[e,n]=w.useState(!0),[r,i]=w.useState(new Set),[s,o]=w.useState(""),[l,c]=w.useState("ALL"),[d,u]=w.useState(!1),[h,f]=w.useState(!1),p=w.useRef(null),{data:x,isLoading:v,refetch:g}=Je({queryKey:["application-logs",l,s],queryFn:()=>Wg.getLogs({limit:200,level:l==="ALL"?void 0:l,search:s||void 0}),refetchInterval:h?2e3:!1,enabled:d});w.useEffect(()=>{d||f(!1)},[d]);const y=st({mutationFn:()=>Wg.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});w.useEffect(()=>{e&&p.current&&x?.entries&&(p.current.scrollTop=p.current.scrollHeight)},[x?.entries,e]);const _=C=>{i(j=>{const P=new Set(j);return P.has(C)?P.delete(C):P.add(C),P})},N=C=>{const j=C.split(" ");return j.length>=2?j[1]:C},T=w.useMemo(()=>x?.entries??[],[x?.entries]),k=w.useMemo(()=>[...T].reverse(),[T]),M=({level:C})=>{const j=det[C]||Zs;return a.jsx(j,{className:`w-3.5 h-3.5 ${Ij[C]||"text-gray-400"}`})};return a.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>u(!d),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${h?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(UC,{className:"w-5 h-5"})}),a.jsxs("div",{className:"text-left",children:[a.jsx("p",{className:"font-medium text-white",children:"Application Logs"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:h?`Live streaming - ${x?.filtered_count??0} entries`:"View and filter application logs"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[h&&a.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs",children:[a.jsx("span",{className:"w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse"}),"Live"]}),d?a.jsx(yl,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(Pn,{className:"w-5 h-5 text-bambu-gray"})]})]}),d&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h?a.jsxs("button",{onClick:C=>{C.stopPropagation(),f(!1)},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded transition-colors",children:[a.jsx(vl,{className:"w-4 h-4"}),"Stop"]}):a.jsxs("button",{onClick:C=>{C.stopPropagation(),f(!0),g()},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 rounded transition-colors",children:[a.jsx(io,{className:"w-4 h-4"}),"Start"]}),a.jsxs("button",{onClick:()=>y.mutate(),disabled:y.isPending||T.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:[a.jsx(Xt,{className:"w-4 h-4"}),"Clear"]}),a.jsx("button",{onClick:()=>g(),disabled:v,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:a.jsx(vr,{className:`w-4 h-4 ${v?"animate-spin":""}`})}),a.jsx("div",{className:"flex-1"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:C=>n(C.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary"}),"Auto-scroll"]}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[x?.filtered_count??0,"/",x?.total_in_file??0]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(Mr,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Search message or logger name...",value:s,onChange:C=>o(C.target.value),className:"w-full pl-8 pr-8 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),s&&a.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>c("ALL"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${l==="ALL"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),hK.map((C,j)=>a.jsx("button",{onClick:()=>c(C),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${j===hK.length-1?"rounded-r":""} ${l===C?`${Ij[C]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:C},C))]})]})]}),a.jsx("div",{ref:p,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:T.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-[300px] text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:"No log entries found"}),a.jsx("p",{className:"text-sm",children:"Log file may be empty or cleared"})]}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary/30",children:k.map((C,j)=>{const P=r.has(j),E=C.message.includes(` `);return a.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${P?"bg-bambu-dark-secondary/30":""}`,onClick:()=>E&&_(j),children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:N(C.timestamp)}),a.jsx("span",{className:"shrink-0",children:a.jsx(M,{level:C.level})}),a.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:C.logger_name,children:["[",C.logger_name,"]"]}),a.jsx("span",{className:`flex-1 ${Ij[C.level]||"text-white/80"} ${!P&&E?"truncate":""}`,children:P?a.jsx("pre",{className:"whitespace-pre-wrap break-all",children:C.message}):C.message.split(` `)[0]}),E&&a.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:P?a.jsx(yl,{className:"w-3.5 h-3.5"}):a.jsx(Pn,{className:"w-3.5 h-3.5"})})]})},j)})})}),a.jsx("div",{className:"flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray",children:h?a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Auto-refreshing every 2 seconds"]}):a.jsx("span",{children:"Click Start to enable live log streaming"})})]})]})}function het(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function Ta({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return a.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[a.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:a.jsx(t,{className:"w-5 h-5"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:e}),a.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function mK({percent:t,color:e="bg-bambu-green"}){return a.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function rh({title:t,icon:e,children:n}){return a.jsxs(wt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[a.jsx(e,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function met(){const{t}=Dt(),e=Jt(),[n,r]=w.useState(null),[i,s]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:d,refetch:u,isFetching:h}=Je({queryKey:["systemInfo"],queryFn:ne.getSystemInfo,refetchInterval:3e4}),{data:f}=Je({queryKey:["debugLogging"],queryFn:Wg.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:p}=Je({queryKey:["settings"],queryFn:ne.getSettings}),{data:x}=Je({queryKey:["library-stats"],queryFn:ne.getLibraryStats}),v=p?.time_format||"system",g=async()=>{l(!0);try{const T=await Wg.setDebugLogging(!f?.enabled);e.setQueryData(["debugLogging"],T)}catch(T){console.error("Failed to toggle debug logging:",T)}finally{l(!1)}},y=async()=>{r(null),s(!0);try{await Wg.downloadSupportBundle()}catch(T){r(T instanceof Error?T.message:"Failed to download support bundle")}finally{s(!1)}};if(d)return a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!c)return a.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const _=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",N=c.memory.percent_used>90?"bg-red-500":c.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return a.jsxs("div",{className:"p-6 space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),a.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),a.jsxs("button",{onClick:()=>u(),disabled:h,className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50",children:[a.jsx(vr,{className:`w-4 h-4 ${h?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),a.jsx(rh,{title:t("system.application","Application"),icon:Bm,children:a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[a.jsx(Ta,{icon:Bm,label:t("system.version","Version"),value:`v${c.app.version}`}),a.jsx(Ta,{icon:Vn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),a.jsx(Ta,{icon:Bm,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),a.jsx(rh,{title:t("support.title","Support & Troubleshooting"),icon:Hme,children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.description","Enable debug logging to capture detailed information, then download a support bundle to share when reporting issues.")}),a.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${f?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(UC,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-white",children:t("support.debugLogging","Debug Logging")}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[f?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),f?.enabled&&f.duration_seconds!==null&&a.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(f.duration_seconds/60),"m ",f.duration_seconds%60,"s)"]})]})]})]}),a.jsxs("button",{onClick:g,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${f?.enabled?"bg-amber-500/20 text-amber-400 hover:bg-amber-500/30":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30"} disabled:opacity-50`,children:[o&&a.jsx(at,{className:"w-4 h-4 animate-spin"}),f?.enabled?t("support.disableDebug","Disable"):t("support.enableDebug","Enable")]})]}),a.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green",children:a.jsx(ha,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-white",children:t("support.supportBundle","Support Bundle")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.supportBundleDescription","Download system info and logs as a ZIP file")})]})]}),a.jsxs("button",{onClick:y,disabled:i||!f?.enabled,className:"px-4 py-2 rounded-lg font-medium bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",title:f?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[i&&a.jsx(at,{className:"w-4 h-4 animate-spin"}),t("common.download","Download")]})]}),n&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/30 rounded-lg text-red-400 text-sm",children:n}),!f?.enabled&&a.jsx("div",{className:"p-4 bg-bambu-dark-tertiary/50 rounded-lg",children:a.jsxs("p",{className:"text-sm text-bambu-gray",children:[a.jsx("span",{className:"text-amber-400 font-medium",children:t("support.instructions","To report an issue:")}),a.jsx("br",{}),"1. ",t("support.step1","Enable debug logging"),a.jsx("br",{}),"2. ",t("support.step2","Reproduce the issue"),a.jsx("br",{}),"3. ",t("support.step3","Download the support bundle"),a.jsx("br",{}),"4. ",t("support.step4","Attach the ZIP file to your issue report")]})}),a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg space-y-3",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:t("support.privacyTitle","What's in the support bundle?")}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-bambu-green font-medium mb-1",children:t("support.collected","Collected:")}),a.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[a.jsxs("li",{children:["• ",t("support.collectItem1","App version and debug mode")]}),a.jsxs("li",{children:["• ",t("support.collectItem2","OS, architecture, Python version")]}),a.jsxs("li",{children:["• ",t("support.collectItem3","Database statistics (counts only)")]}),a.jsxs("li",{children:["• ",t("support.collectItem4","Printer models and nozzle counts")]}),a.jsxs("li",{children:["• ",t("support.collectItem5","Non-sensitive settings (themes, formats)")]}),a.jsxs("li",{children:["• ",t("support.collectItem6","Debug logs (sanitized)")]}),a.jsxs("li",{children:["• ",t("support.collectItem7","Printer connectivity and firmware versions")]}),a.jsxs("li",{children:["• ",t("support.collectItem8","Integration status (Spoolman, MQTT, HA)")]}),a.jsxs("li",{children:["• ",t("support.collectItem9","Network interfaces (subnets only)")]}),a.jsxs("li",{children:["• ",t("support.collectItem10","Python package versions")]}),a.jsxs("li",{children:["• ",t("support.collectItem11","Database health checks")]}),a.jsxs("li",{children:["• ",t("support.collectItem12","Docker environment details")]})]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-red-400 font-medium mb-1",children:t("support.notCollected","NOT collected:")}),a.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[a.jsxs("li",{children:["• ",t("support.notItem1","Printer names and serial numbers")]}),a.jsxs("li",{children:["• ",t("support.notItem2","Access codes and passwords")]}),a.jsxs("li",{children:["• ",t("support.notItem3","Email addresses")]}),a.jsxs("li",{children:["• ",t("support.notItem4","API keys and tokens")]}),a.jsxs("li",{children:["• ",t("support.notItem5","Webhook URLs")]}),a.jsxs("li",{children:["• ",t("support.notItem6","Your hostname or username")]}),a.jsxs("li",{children:["• ",t("support.notItem7","IP addresses")]})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:t("support.privacyNote","Email addresses in logs are replaced with [EMAIL], printer names with [PRINTER], serial numbers with [SERIAL], and IP addresses with [IP].")})]}),a.jsx(uet,{})]})}),a.jsxs(rh,{title:t("system.database","Database"),icon:Pc,children:[a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[a.jsx(Ta,{icon:Ds,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),a.jsx(Ta,{icon:db,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),a.jsx(Ta,{icon:bi,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),a.jsx(Ta,{icon:at,label:t("system.printing","Printing"),value:c.database.archives_printing,color:"text-yellow-500"})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(Ta,{icon:Sr,label:t("system.printers","Printers"),value:c.database.printers}),a.jsx(Ta,{icon:WC,label:t("system.filaments","Filaments"),value:c.database.filaments}),a.jsx(Ta,{icon:xs,label:t("system.projects","Projects"),value:c.database.projects}),a.jsx(Ta,{icon:fl,label:t("system.smartPlugs","Smart Plugs"),value:c.database.smart_plugs})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[a.jsx(Ta,{icon:Vn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),a.jsx(Ta,{icon:Ds,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),a.jsxs(rh,{title:t("system.connectedPrinters","Connected Printers"),icon:Sr,children:[a.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[a.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:c.printers.connected}),a.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?a.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(T=>a.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),a.jsx("span",{className:"font-medium text-white",children:T.name})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[a.jsx("span",{children:T.model}),a.jsx("span",{className:`px-2 py-0.5 rounded ${T.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":T.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:T.state})]})]},T.id))}):a.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),a.jsx(rh,{title:t("system.storage","Storage"),icon:$b,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),a.jsxs("span",{className:"text-white",children:[c.storage.disk_used_formatted," / ",c.storage.disk_total_formatted]})]}),a.jsx(mK,{percent:c.storage.disk_percent_used,color:_}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.storage.disk_free_formatted," ",t("system.free","free")," (",(100-c.storage.disk_percent_used).toFixed(1),"%)"]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[a.jsx(Ta,{icon:Ds,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),a.jsx(Ta,{icon:Pc,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),x&&a.jsx(Ta,{icon:Ql,label:t("system.fileManagerStorage","File Manager"),value:het(x.total_size_bytes),subValue:`${x.total_files} files, ${x.total_folders} folders`})]})]})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[a.jsx(rh,{title:t("system.memory","Memory"),icon:vfe,children:a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),a.jsxs("span",{className:"text-white",children:[c.memory.used_formatted," / ",c.memory.total_formatted]})]}),a.jsx(mK,{percent:c.memory.percent_used,color:N}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),a.jsx(rh,{title:t("system.cpu","CPU"),icon:tS,children:a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(Ta,{icon:tS,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),a.jsx(Ta,{icon:tS,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),a.jsx(rh,{title:t("system.systemDetails","System Details"),icon:Bm,children:a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(Ta,{icon:Bm,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),a.jsx(Ta,{icon:tS,label:t("system.architecture","Architecture"),value:c.system.architecture}),a.jsx(Ta,{icon:Bm,label:t("system.python","Python"),value:c.system.python_version}),a.jsx(Ta,{icon:Vn,label:t("system.bootTime","Boot Time"),value:Df(c.system.boot_time,v)})]})})]})}function fet(){const t=nc(),{t:e}=Dt(),{login:n}=Pr(),{showToast:r}=ln(),{mode:i}=ep(),[s,o]=w.useState(""),[l,c]=w.useState(""),[d,u]=w.useState(!1),[h,f]=w.useState(""),{data:p}=Je({queryKey:["advancedAuthStatus"],queryFn:()=>ne.getAdvancedAuthStatus()}),x=st({mutationFn:()=>n(s,l),onSuccess:()=>{r(e("login.loginSuccess")),t("/")},onError:_=>{r(_.message||e("login.loginFailed"),"error")}}),v=st({mutationFn:_=>ne.forgotPassword({email:_}),onSuccess:_=>{r(_.message,"success"),u(!1),f("")},onError:_=>{r(_.message,"error")}}),g=_=>{if(_.preventDefault(),!s||!l){r(e("login.enterCredentials"),"error");return}x.mutate()},y=_=>{if(_.preventDefault(),!h){r("Please enter your email address","error");return}v.mutate(h)};return a.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:[a.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"flex items-center justify-center mb-6",children:a.jsx("img",{src:i==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),a.jsx("h2",{className:"text-3xl font-bold text-white",children:e("login.title")}),a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("login.subtitle")})]}),a.jsxs("form",{className:"mt-8 space-y-6",onSubmit:g,children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-white mb-2",children:p?.advanced_auth_enabled?e("login.usernameOrEmail")||"Username or Email":e("login.username")}),a.jsx("input",{id:"username",type:"text",required:!0,value:s,onChange:_=>o(_.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:p?.advanced_auth_enabled?e("login.usernameOrEmailPlaceholder")||"Enter your username or email":e("login.usernamePlaceholder"),autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-white mb-2",children:e("login.password")}),a.jsx("input",{id:"password",type:"password",required:!0,value:l,onChange:_=>c(_.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("login.passwordPlaceholder"),autoComplete:"current-password"})]})]}),a.jsx("div",{children:a.jsx("button",{type:"submit",disabled:x.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:x.isPending?e("login.signingIn"):e("login.signIn")})}),p?.advanced_auth_enabled&&a.jsx("div",{className:"text-center",children:a.jsx("button",{type:"button",onClick:()=>u(!0),className:"text-sm text-bambu-gray hover:text-bambu-green transition-colors",children:e("login.forgotPassword")})})]})]}),d&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>u(!1),children:a.jsxs(wt,{className:"w-full max-w-md",onClick:_=>_.stopPropagation(),children:[a.jsx(On,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gv,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:e("login.forgotPasswordTitle")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{u(!1),f("")},children:a.jsx(Rt,{className:"w-5 h-5"})})]})}),a.jsx(Nt,{children:p?.advanced_auth_enabled?a.jsxs("form",{onSubmit:y,className:"space-y-4",children:[a.jsx("p",{className:"text-bambu-gray text-sm",children:e("login.forgotPasswordEmailMessage")||"Enter your email address and we'll send you a new password."}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"forgot-email",className:"block text-sm font-medium text-white mb-2",children:e("login.emailAddress")||"Email Address"}),a.jsx("input",{id:"forgot-email",type:"email",required:!0,value:h,onChange:_=>f(_.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("login.emailPlaceholder")||"your.email@example.com"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",className:"flex-1",onClick:()=>{u(!1),f("")},children:e("login.cancel")||"Cancel"}),a.jsx(Me,{type:"submit",className:"flex-1",disabled:v.isPending,children:v.isPending?e("login.sending")||"Sending...":e("login.sendResetEmail")||"Send Reset Email"})]})]}):a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-bambu-gray",children:e("login.forgotPasswordMessage")}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4 space-y-2",children:[a.jsx("p",{className:"text-sm text-white font-medium",children:e("login.howToReset")}),a.jsxs("ol",{className:"text-sm text-bambu-gray space-y-1 list-decimal list-inside",children:[a.jsx("li",{children:e("login.resetStep1")}),a.jsx("li",{children:e("login.resetStep2")}),a.jsx("li",{children:e("login.resetStep3")}),a.jsx("li",{children:e("login.resetStep4")})]})]}),a.jsx(Me,{variant:"secondary",className:"w-full",onClick:()=>u(!1),children:e("login.gotIt")})]})})]})})]})}function pet(){const t=nc(),{t:e}=Dt(),{showToast:n}=ln(),{mode:r}=ep(),{refreshAuth:i}=Pr(),[s,o]=w.useState(!1),[l,c]=w.useState(""),[d,u]=w.useState(""),[h,f]=w.useState(""),p=st({mutationFn:()=>ne.setupAuth({auth_enabled:s,admin_username:s?l:void 0,admin_password:s?d:void 0}),onSuccess:async v=>{await i(),v.auth_enabled?v.admin_created?(n(e("setup.toast.authEnabledAdminCreated")),t("/login")):(n(e("setup.toast.authEnabledExistingAdmins")),t("/login")):(n(e("setup.toast.setupCompleted")),t("/"))},onError:v=>{n(v.message,"error")}}),x=v=>{if(v.preventDefault(),s&&(l||d)){if(!l||!d){n(e("setup.toast.enterBothCredentials"),"error");return}if(d!==h){n(e("setup.toast.passwordsDoNotMatch"),"error");return}if(d.length<6){n(e("setup.toast.passwordTooShort"),"error");return}}p.mutate()};return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:a.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"flex items-center justify-center mb-6",children:a.jsx("img",{src:r==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),a.jsx("h2",{className:"text-3xl font-bold text-white",children:e("setup.title")}),a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("setup.subtitle")})]}),a.jsxs("form",{className:"mt-8 space-y-6",onSubmit:x,children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center p-4 bg-bambu-dark-secondary/50 rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("input",{id:"auth-enabled",type:"checkbox",checked:s,onChange:v=>o(v.target.checked),className:"h-4 w-4 text-bambu-green focus:ring-bambu-green border-bambu-dark-tertiary rounded bg-bambu-dark-secondary"}),a.jsx("label",{htmlFor:"auth-enabled",className:"ml-3 block text-sm font-medium text-white",children:e("setup.enableAuth")})]}),s&&a.jsxs("div",{className:"space-y-4 mt-4",children:[a.jsx("div",{className:"p-3 bg-bambu-dark-secondary/50 border border-bambu-dark-tertiary rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(Zs,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"text-sm text-bambu-gray",children:[a.jsx("p",{className:"text-white font-medium mb-1",children:e("setup.adminAccount")}),a.jsx("p",{children:e("setup.adminAccountDesc")})]})]})}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminUsername")," ",a.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),a.jsx("input",{id:"admin-username",type:"text",value:l,onChange:v=>c(v.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.adminUsernamePlaceholder"),autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminPassword")," ",a.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),a.jsx("input",{id:"admin-password",type:"password",value:d,onChange:v=>u(v.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.adminPasswordPlaceholder"),minLength:6,autoComplete:"new-password"})]}),d&&a.jsxs("div",{children:[a.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:e("setup.confirmPassword")}),a.jsx("input",{id:"confirm-password",type:"password",value:h,onChange:v=>f(v.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.confirmPasswordPlaceholder"),minLength:6,autoComplete:"new-password"})]})]})]}),a.jsx("div",{children:a.jsx("button",{type:"submit",disabled:p.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:p.isPending?e("setup.settingUp"):e("setup.completeSetup")})})]})]})})}function get(){const t=w.useRef(null),e=w.useRef(null),n=Jt(),[r,i]=w.useState(!1),s=w.useRef(new Set),o=w.useRef(null),l=w.useRef(new Map),c=w.useRef(null),d=w.useRef([]),u=w.useRef(!1),h=w.useRef(()=>{}),f=w.useCallback(()=>{if(u.current||d.current.length===0)return;u.current=!0;const _=()=>{const N=d.current.shift();N?requestAnimationFrame(()=>{h.current(N),d.current.length>0?setTimeout(_,16):u.current=!1}):u.current=!1};_()},[]),p=w.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const N=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,T=new WebSocket(N);let k=null;T.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),k=window.setInterval(()=>{T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:"ping"}))},3e4)},T.onmessage=M=>{try{const C=JSON.parse(M.data);C.type==="printer_status"&&C.printer_id!==void 0&&C.data?h.current(C):(d.current.push(C),f())}catch{}},T.onclose=M=>{console.log("[WebSocket] Closed",M.code,M.reason),k&&(clearInterval(k),k=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{p()},3e3)},T.onerror=M=>{console.error("[WebSocket] Error",M),T.close()},t.current=T},[f]),x=w.useCallback((_,N)=>{const T=l.current.get(_)||{};l.current.set(_,{...T,...N}),c.current||(c.current=window.setTimeout(()=>{const k=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{k.forEach((M,C)=>{n.setQueryData(["printerStatus",C],j=>{const P={...j,...M};return P.wifi_signal==null&&j?.wifi_signal!=null&&(P.wifi_signal=j.wifi_signal),P})})})},100))},[n]),v=w.useCallback(_=>{s.current.add(_),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const N=Array.from(s.current);s.current.clear(),o.current=null;let T=0;N.forEach(k=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[k]})})},T),T+=500})},3e3)},[n]),g=w.useCallback(_=>{switch(_.type){case"printer_status":_.printer_id!==void 0&&_.data&&x(_.printer_id,_.data);break;case"print_start":_.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",_.printer_id]});break;case"print_complete":v("archives"),v("archiveStats");break;case"archive_created":v("archives"),v("archiveStats");break;case"archive_updated":v("archives");break;case"pong":break;case"plate_not_empty":window.dispatchEvent(new CustomEvent("plate-not-empty",{detail:{printer_id:_.printer_id,printer_name:_.printer_name,message:_.message}}));break;case"spool_auto_assigned":v("inventory-spools"),v("spool-assignments");break;case"spool_usage_logged":v("inventory-spools");break;case"unknown_tag":window.dispatchEvent(new CustomEvent("unknown-tag",{detail:{printer_id:_.printer_id,ams_id:_.ams_id,tray_id:_.tray_id,tag_uid:_.tag_uid,tray_uuid:_.tray_uuid}}));break;case"background_dispatch":window.dispatchEvent(new CustomEvent("background-dispatch",{detail:_.data||{}}));break;case"spoolbuddy_weight":window.dispatchEvent(new CustomEvent("spoolbuddy-weight",{detail:_}));break;case"spoolbuddy_tag_matched":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-matched",{detail:_})),v("inventory-spools");break;case"spoolbuddy_unknown_tag":window.dispatchEvent(new CustomEvent("spoolbuddy-unknown-tag",{detail:_}));break;case"spoolbuddy_tag_removed":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-removed",{detail:_}));break;case"spoolbuddy_online":window.dispatchEvent(new CustomEvent("spoolbuddy-online",{detail:_}));break;case"spoolbuddy_offline":window.dispatchEvent(new CustomEvent("spoolbuddy-offline",{detail:_}));break}},[n,v,x]);w.useEffect(()=>{h.current=g},[g]),w.useEffect(()=>(p(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[p]);const y=w.useCallback(_=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(_))},[]);return{isConnected:r,sendMessage:y}}function bet({selectedPrinterId:t,onPrinterChange:e,deviceOnline:n}){const{t:r}=Dt(),[i,s]=w.useState(new Date),{data:o=[]}=Je({queryKey:["printers"],queryFn:()=>ne.getPrinters()});w.useEffect(()=>{!t&&o.length>0&&e(o[0].id)},[o,t,e]),w.useEffect(()=>{const c=setInterval(()=>s(new Date),1e3);return()=>clearInterval(c)},[]);const l=c=>c.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return a.jsxs("div",{className:"h-11 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-3 gap-4 shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[a.jsx("div",{className:"w-6 h-6 rounded bg-bambu-green flex items-center justify-center",children:a.jsx("svg",{className:"w-4 h-4 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})}),a.jsx("span",{className:"text-white font-semibold text-sm",children:"SpoolBuddy"})]}),a.jsx("div",{className:"flex-1 flex justify-center",children:a.jsx("select",{value:t??"",onChange:c=>e(Number(c.target.value)),className:"bg-bambu-dark text-white text-sm px-3 py-1.5 rounded border border-bambu-dark-tertiary focus:outline-none focus:border-bambu-green min-w-[150px]",children:o.length===0?a.jsx("option",{value:"",children:r("spoolbuddy.status.noPrinters","No printers")}):o.map(c=>a.jsx("option",{value:c.id,children:c.name},c.id))})}),a.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[a.jsx("div",{className:"flex items-center",title:n?r("spoolbuddy.status.online","Online"):r("spoolbuddy.status.offline","Offline"),children:n?a.jsx("div",{className:"flex items-end gap-0.5 h-4",children:[1,2,3,4].map(c=>a.jsx("div",{className:`w-1 rounded-sm ${c<=4?"bg-white":"bg-bambu-dark-tertiary"}`,style:{height:`${c*4}px`}},c))}):a.jsx(qh,{className:"w-5 h-5 text-red-400"})}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${n?"bg-bambu-green shadow-[0_0_6px_rgba(34,197,94,0.5)]":"bg-bambu-gray"}`}),a.jsx("span",{className:"text-xs text-white/50",children:n?r("spoolbuddy.status.online","Online"):r("spoolbuddy.status.offline","Offline")})]}),a.jsx("span",{className:"text-white/50 text-sm font-mono min-w-[50px] text-right",children:l(i)})]})]})}const xet=[{to:"/spoolbuddy",labelKey:"spoolbuddy.nav.dashboard",fallback:"Dashboard",icon:a.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})})},{to:"/spoolbuddy/ams",labelKey:"spoolbuddy.nav.ams",fallback:"AMS",icon:a.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})},{to:"/spoolbuddy/inventory",labelKey:"spoolbuddy.nav.inventory",fallback:"Inventory",icon:a.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})},{to:"/spoolbuddy/settings",labelKey:"spoolbuddy.nav.settings",fallback:"Settings",icon:a.jsxs("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}];function yet(){const{t}=Dt();return a.jsx("nav",{className:"h-12 bg-bambu-dark-secondary border-t border-bambu-dark-tertiary flex items-stretch shrink-0",children:xet.map(e=>a.jsxs(Lg,{to:e.to,end:e.to==="/spoolbuddy",className:({isActive:n})=>`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${n?"text-bambu-green bg-bambu-dark":"text-white/50 hover:text-white/70 hover:bg-bambu-dark-tertiary"}`,children:[e.icon,a.jsx("span",{className:"text-[10px] font-medium",children:t(e.labelKey,e.fallback)})]},e.to))})}function vet({alert:t}){const{t:e}=Dt(),n=t?t.type==="error"?"bg-red-500":t.type==="warning"?"bg-amber-500":"bg-bambu-green":"bg-bambu-green",r=t?t.type==="error"?"border-red-500":t.type==="warning"?"border-amber-500":"border-bambu-dark-tertiary":"border-bambu-dark-tertiary";return a.jsxs("div",{className:`h-8 bg-bambu-dark-secondary border-t-2 ${r} flex items-center px-3 gap-3 shrink-0`,children:[a.jsx("div",{className:`w-3 h-3 rounded-full ${n} animate-pulse`}),a.jsx("div",{className:"flex-1 text-sm text-white/50 truncate",children:t?a.jsx("span",{children:t.message}):a.jsx("span",{className:"text-bambu-green",children:e("spoolbuddy.status.systemReady","System Ready")})})]})}const wet={weight:null,weightStable:!1,rawAdc:null,matchedSpool:null,unknownTagUid:null,deviceOnline:!1,deviceId:null};function _et(t,e){switch(e.type){case"WEIGHT_UPDATE":return{...t,weight:e.weight,weightStable:e.stable,rawAdc:e.rawAdc,deviceId:e.deviceId,deviceOnline:!0};case"TAG_MATCHED":return{...t,matchedSpool:e.spool,unknownTagUid:null,deviceId:e.deviceId};case"UNKNOWN_TAG":return{...t,matchedSpool:null,unknownTagUid:e.tagUid,deviceId:e.deviceId};case"TAG_REMOVED":return{...t,matchedSpool:null,unknownTagUid:null};case"DEVICE_ONLINE":return{...t,deviceOnline:!0,deviceId:e.deviceId};case"DEVICE_OFFLINE":return{...t,deviceOnline:!1,weight:null,weightStable:!1,rawAdc:null};default:return t}}function Net(){const[t,e]=w.useReducer(_et,wet),n=w.useCallback(u=>{const h=u.detail;e({type:"WEIGHT_UPDATE",weight:h.weight_grams??h.data?.weight_grams,stable:h.stable??h.data?.stable??!1,rawAdc:h.raw_adc??h.data?.raw_adc??null,deviceId:h.device_id??h.data?.device_id??""})},[]),r=w.useCallback(u=>{const h=u.detail,f=h.spool??h.data?.spool;f&&e({type:"TAG_MATCHED",spool:{id:f.id,tag_uid:h.tag_uid??h.data?.tag_uid??"",material:f.material??"",subtype:f.subtype??null,color_name:f.color_name??null,rgba:f.rgba??null,brand:f.brand??null,label_weight:f.label_weight??0,core_weight:f.core_weight??0,weight_used:f.weight_used??0},deviceId:h.device_id??h.data?.device_id??""})},[]),i=w.useCallback(u=>{const h=u.detail;e({type:"UNKNOWN_TAG",tagUid:h.tag_uid??h.data?.tag_uid??"",deviceId:h.device_id??h.data?.device_id??""})},[]),s=w.useCallback(u=>{const h=u.detail;e({type:"TAG_REMOVED",deviceId:h.device_id??h.data?.device_id??""})},[]),o=w.useCallback(u=>{const h=u.detail;e({type:"DEVICE_ONLINE",deviceId:h.device_id??h.data?.device_id??""})},[]),l=w.useCallback(u=>{const h=u.detail;e({type:"DEVICE_OFFLINE",deviceId:h.device_id??h.data?.device_id??""})},[]);w.useEffect(()=>(window.addEventListener("spoolbuddy-weight",n),window.addEventListener("spoolbuddy-tag-matched",r),window.addEventListener("spoolbuddy-unknown-tag",i),window.addEventListener("spoolbuddy-tag-removed",s),window.addEventListener("spoolbuddy-online",o),window.addEventListener("spoolbuddy-offline",l),()=>{window.removeEventListener("spoolbuddy-weight",n),window.removeEventListener("spoolbuddy-tag-matched",r),window.removeEventListener("spoolbuddy-unknown-tag",i),window.removeEventListener("spoolbuddy-tag-removed",s),window.removeEventListener("spoolbuddy-online",o),window.removeEventListener("spoolbuddy-offline",l)}),[n,r,i,s,o,l]);const c=t.matchedSpool?Math.max(0,t.matchedSpool.label_weight-t.matchedSpool.weight_used):null,d=t.weight!==null&&t.matchedSpool?Math.max(0,t.weight-t.matchedSpool.core_weight):null;return{...t,remainingWeight:c,netWeight:d}}function Cet(){const[t,e]=w.useState(null),[n,r]=w.useState(null),i=Net();return w.useEffect(()=>{const s=document.documentElement,o=s.classList.contains("dark");return s.classList.add("dark"),()=>{o||s.classList.remove("dark")}},[]),w.useEffect(()=>{i.deviceOnline?r(null):r({type:"warning",message:"SpoolBuddy device disconnected"})},[i.deviceOnline]),a.jsxs("div",{className:"w-screen h-screen bg-bambu-dark text-white flex flex-col overflow-hidden",children:[a.jsx(bet,{selectedPrinterId:t,onPrinterChange:e,deviceOnline:i.deviceOnline}),a.jsx("main",{className:"flex-1 overflow-y-auto",children:a.jsx(HK,{context:{selectedPrinterId:t,setSelectedPrinterId:e,sbState:i,setAlert:r}})}),a.jsx(vet,{alert:n}),a.jsx(yet,{})]})}function MA({color:t,isEmpty:e,size:n=32}){return e?a.jsx("div",{className:"rounded-full border-2 border-dashed border-zinc-500 flex items-center justify-center",style:{width:n,height:n},children:a.jsx("div",{className:"w-2 h-2 rounded-full bg-zinc-600"})}):a.jsxs("svg",{width:n,height:n,viewBox:"0 0 32 32",children:[a.jsx("circle",{cx:"16",cy:"16",r:"14",fill:t,stroke:"white",strokeWidth:"1.5",strokeOpacity:"0.7"}),a.jsx("circle",{cx:"16",cy:"16",r:"11",fill:t,style:{filter:"brightness(0.85)"}})]})}const ket="spoolbuddy-default-core-weight";function rse(){try{const t=localStorage.getItem(ket);if(t){const e=parseInt(t,10);if(e>=0&&e<=500)return e}}catch{}return 250}function Aet({spool:t,scaleWeight:e,weightStable:n,onClose:r,onSyncWeight:i}){const{t:s}=Dt(),[o,l]=w.useState(!1),[c,d]=w.useState(!1),u=t.rgba?`#${t.rgba.slice(0,6)}`:"#808080",h=t.core_weight&&t.core_weight>0?t.core_weight:rse(),f=e!==null?Math.round(Math.max(0,e)):null,p=f!==null?Math.round(Math.max(0,f-h)):null,x=Math.round(t.label_weight||1e3),v=p!==null?Math.min(100,Math.round(p/x*100)):null,g=v!==null?v>50?"#22c55e":v>20?"#eab308":"#ef4444":"#808080",_=Math.max(0,(t.label_weight||0)-(t.weight_used||0))+h,N=f!==null?f-_:null,T=N!==null?Math.abs(N)<=50:null,k=async()=>{if(!(e===null||!n)){l(!0);try{await Kg.updateSpoolWeight(t.id,Math.round(e)),d(!0),i?.(),setTimeout(()=>d(!1),3e3)}catch(M){console.error("Failed to sync weight:",M)}finally{l(!1)}}};return a.jsxs("div",{className:"flex flex-col items-center space-y-4 max-w-md",children:[a.jsxs("div",{className:"flex items-start gap-5",children:[a.jsxs("div",{className:"relative shrink-0",children:[a.jsx(MA,{color:u,isEmpty:!1,size:100}),v!==null&&a.jsxs("div",{className:"absolute -bottom-2 -right-2 px-2 py-0.5 rounded-full text-xs font-bold text-white shadow-lg",style:{backgroundColor:g},children:[v,"%"]})]}),a.jsxs("div",{className:"flex-1 min-w-0 pt-1",children:[a.jsx("h3",{className:"text-lg font-semibold text-zinc-100",children:t.color_name||"Unknown color"}),a.jsxs("p",{className:"text-sm text-zinc-400",children:[t.brand," • ",t.material,t.subtype&&` ${t.subtype}`]}),p!==null&&a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-baseline gap-2",children:[a.jsxs("span",{className:"text-3xl font-bold font-mono text-zinc-100",children:[p,"g"]}),a.jsxs("span",{className:"text-sm text-zinc-500",children:["/ ",x,"g"]})]}),a.jsx("p",{className:"text-xs text-zinc-500 mt-0.5",children:s("spoolbuddy.spool.remaining","Remaining")}),a.jsx("div",{className:"mt-2 max-w-xs",children:a.jsx("div",{className:"h-2 bg-zinc-700 rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${v}%`,backgroundColor:g}})})})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2 text-sm bg-zinc-800 rounded-lg p-3 w-full",children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:s("spoolbuddy.dashboard.grossWeight","Gross weight")}),a.jsx("span",{className:"font-mono text-zinc-300",children:f!==null?`${f}g`:"—"})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:s("spoolbuddy.spool.coreWeight","Core")}),a.jsxs("span",{className:"font-mono text-zinc-300",children:[h,"g"]})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:s("spoolbuddy.dashboard.spoolSize","Spool size")}),a.jsxs("span",{className:"font-mono text-zinc-300",children:[x,"g"]})]}),a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsx("span",{className:"text-zinc-500",children:s("spoolbuddy.spool.scaleWeight","Scale")}),f!==null?a.jsxs("span",{className:`flex items-center gap-1 font-mono ${T?"text-green-500":"text-yellow-500"}`,children:[f,"g",T?a.jsx(Jr,{className:"w-3 h-3"}):a.jsxs(a.Fragment,{children:[a.jsx(An,{className:"w-3 h-3"}),a.jsx("button",{onClick:k,className:"p-1 hover:bg-green-500/20 rounded transition-colors text-green-500",title:s("spoolbuddy.dashboard.syncWeight","Sync Weight"),children:a.jsx(vr,{className:"w-3.5 h-3.5"})})]})]}):a.jsx("span",{className:"text-zinc-500",children:"—"})]}),a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsx("span",{className:"text-zinc-500",children:s("spoolbuddy.dashboard.tagId","Tag")}),a.jsx("span",{className:"font-mono text-xs text-zinc-400 truncate max-w-[120px]",title:t.tag_uid||"",children:t.tag_uid?t.tag_uid.slice(-8):"—"})]})]}),a.jsxs("div",{className:"flex gap-2 justify-center",children:[a.jsx("button",{onClick:k,disabled:!n||e===null||o,className:`px-5 py-2.5 rounded-lg text-sm font-medium transition-colors min-h-[44px] ${c?"bg-green-600/20 text-green-400":"bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 disabled:cursor-not-allowed"}`,children:o?"...":c?s("spoolbuddy.dashboard.weightSynced","Synced!"):s("spoolbuddy.dashboard.syncWeight","Sync Weight")}),r&&a.jsx("button",{onClick:r,className:"px-5 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]",children:s("spoolbuddy.dashboard.close","Close")})]})]})}function Tet({tagUid:t,scaleWeight:e,coreWeight:n,onLinkSpool:r,onClose:i}){const{t:s}=Dt(),o=n??rse(),l=e!==null?Math.round(Math.max(0,e)):null,c=l!==null?Math.round(Math.max(0,l-o)):null;return a.jsxs("div",{className:"flex flex-col items-center text-center space-y-5",children:[a.jsx("div",{className:"w-20 h-20 rounded-2xl bg-green-500/15 flex items-center justify-center",children:a.jsx("svg",{className:"w-10 h-10 text-green-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A2 2 0 013 12V7a4 4 0 014-4z"})})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-zinc-100",children:s("spoolbuddy.dashboard.newTag","New Tag Detected")}),a.jsx("p",{className:"text-sm text-zinc-500 font-mono mt-1",children:t})]}),l!==null&&a.jsxs("div",{className:"text-sm text-zinc-400",children:[a.jsxs("span",{className:"font-mono font-semibold",children:[l,"g"]})," ",s("spoolbuddy.dashboard.onScale","on scale"),c!==null&&c>0&&a.jsxs("span",{className:"text-zinc-500",children:[" • ~",c,"g filament"]})]}),a.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[r&&a.jsxs("button",{onClick:r,className:"px-5 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 transition-colors min-h-[44px]",children:[a.jsx("svg",{className:"w-4 h-4 inline-block mr-1.5 -mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),s("spoolbuddy.dashboard.linkSpool","Link to Spool")]}),i&&a.jsx("button",{onClick:i,className:"px-5 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]",children:s("spoolbuddy.dashboard.close","Close")})]})]})}function Met({isOpen:t,onClose:e,tagId:n,untaggedSpools:r,onLink:i}){const{t:s}=Dt(),[o,l]=w.useState(null),c=w.useCallback(()=>{l(null),e()},[e]),d=w.useCallback(h=>{h.key==="Escape"&&c()},[c]);if(w.useEffect(()=>(t&&(document.addEventListener("keydown",d),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",d),document.body.style.overflow=""}),[t,d]),!t)return null;const u=()=>{o&&(i(o),l(null))};return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 animate-fade-in",onClick:c,children:a.jsxs("div",{className:"bg-zinc-800 rounded-xl shadow-2xl w-full max-w-lg mx-4 animate-slide-up",onClick:h=>h.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-zinc-700",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-base font-semibold text-zinc-100",children:s("spoolbuddy.dashboard.linkTagTitle","Link Tag to Spool")}),a.jsx("p",{className:"text-sm text-zinc-500 font-mono",children:n})]}),a.jsx("button",{onClick:c,className:"p-2 rounded-lg text-zinc-500 hover:text-zinc-300 hover:bg-zinc-700 transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"px-5 py-4 space-y-3 max-h-[400px] overflow-y-auto",children:[a.jsx("p",{className:"text-sm text-zinc-400",children:s("spoolbuddy.dashboard.selectSpool","Select a spool to link this tag to:")}),r.length===0?a.jsx("div",{className:"text-center py-8 text-zinc-500",children:s("spoolbuddy.dashboard.noUntagged","No spools without tags found")}):a.jsx("div",{className:"space-y-2",children:r.map(h=>a.jsxs("button",{type:"button",onClick:()=>l(h),className:`w-full flex items-center gap-3 p-3 rounded-lg border-2 transition-all text-left ${o?.id===h.id?"border-green-500 bg-green-500/10":"border-zinc-700 hover:border-green-500/50 hover:bg-zinc-700/50"}`,children:[a.jsx(MA,{color:h.rgba?`#${h.rgba.slice(0,6)}`:"#808080",isEmpty:!1,size:40}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"font-medium text-zinc-100 truncate",children:h.color_name||"Unknown color"}),a.jsxs("div",{className:"text-sm text-zinc-400 truncate",children:[h.brand," • ",h.material,h.subtype&&` ${h.subtype}`]})]}),a.jsxs("div",{className:"text-sm font-mono text-zinc-500",children:[Math.max(0,h.label_weight-h.weight_used),"g"]})]},h.id))})]}),a.jsxs("div",{className:"flex justify-end gap-2 px-5 py-4 border-t border-zinc-700",children:[a.jsx("button",{onClick:c,className:"px-4 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]",children:s("common.cancel","Cancel")}),a.jsx("button",{onClick:u,disabled:!o,className:"px-4 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors min-h-[44px]",children:s("spoolbuddy.dashboard.linkTag","Link Tag")})]})]})})}const fK=["#00AE42","#FF6B35","#3B82F6","#EF4444","#A855F7","#FBBF24","#14B8A6","#EC4899","#F97316","#22C55E"];function Pet(){const{t}=Dt(),[e,n]=w.useState(0);w.useEffect(()=>{const i=setInterval(()=>{n(s=>(s+1)%fK.length)},2e3);return()=>clearInterval(i)},[]);const r=fK[e];return a.jsxs("div",{className:"flex flex-col items-center text-center",children:[a.jsxs("div",{className:"relative mb-6 flex items-center justify-center",style:{width:160,height:160},children:[a.jsx("div",{className:"absolute w-24 h-24 rounded-full border-2 border-green-500/30 animate-ping",style:{animationDuration:"2.5s"}}),a.jsx("div",{className:"absolute w-32 h-32 rounded-full border border-green-500/20 animate-ping",style:{animationDuration:"2.5s",animationDelay:"0.4s"}}),a.jsx("div",{className:"absolute w-40 h-40 rounded-full border border-green-500/10 animate-ping",style:{animationDuration:"2.5s",animationDelay:"0.8s"}}),a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"absolute -inset-4 rounded-full blur-2xl opacity-30 transition-colors duration-1000",style:{backgroundColor:r}}),a.jsx("div",{className:"transition-all duration-1000",children:a.jsx(MA,{color:r,isEmpty:!1,size:100})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-lg font-medium text-zinc-300",children:t("spoolbuddy.dashboard.readyToScan","Ready to scan")}),a.jsx("p",{className:"text-sm text-zinc-500",children:t("spoolbuddy.dashboard.idleMessage","Place a spool on the scale to identify it")})]}),a.jsxs("div",{className:"mt-6 flex items-center gap-2 text-xs text-zinc-600",children:[a.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("span",{children:t("spoolbuddy.dashboard.nfcHint","NFC tag will be read automatically")})]})]})}function Eet(){const{t}=Dt();return a.jsxs("div",{className:"flex flex-col items-center text-center",children:[a.jsx("div",{className:"relative mb-6 flex items-center justify-center",style:{width:160,height:160},children:a.jsx("div",{className:"w-24 h-24 rounded-full bg-zinc-800 flex items-center justify-center",children:a.jsx("svg",{className:"w-12 h-12 text-zinc-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M18.364 5.636a9 9 0 010 12.728m0 0l-12.728-12.728m12.728 12.728L5.636 5.636m12.728 0a9 9 0 00-12.728 0m0 12.728a9 9 0 010-12.728"})})})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-lg font-medium text-zinc-500",children:t("spoolbuddy.status.deviceOffline","Device Offline")}),a.jsx("p",{className:"text-sm text-zinc-600",children:t("spoolbuddy.status.waitingConnection","Waiting for device connection...")})]}),a.jsxs("div",{className:"mt-6 flex items-center gap-2 text-xs text-zinc-600",children:[a.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.14 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0"})}),a.jsx("span",{children:t("spoolbuddy.status.waitingConnection","Waiting for device connection...")})]})]})}function jet(){const{sbState:t}=uF(),{t:e}=Dt(),{data:n=[],refetch:r}=Je({queryKey:["inventory-spools"],queryFn:()=>ne.getSpools(!1)}),[i,s]=w.useState(null),[o,l]=w.useState(null),[c,d]=w.useState(null),[u,h]=w.useState(!1),f=t.matchedSpool?.tag_uid??t.unknownTagUid??null,p=t.weight,x=t.weightStable,v=w.useMemo(()=>i?n.find(z=>z.tag_uid===i)??null:null,[i,n]),g=w.useMemo(()=>n.filter(z=>!z.tag_uid&&!z.archived_at),[n]);w.useEffect(()=>{if(f){const z=c===f;(i!==null&&i!==f||!z&&i!==f)&&(s(f),l(null),d(null)),!z&&p!==null&&x&&l(Math.round(Math.max(0,p)))}else c&&(s(null),d(null),l(null))},[f,p,x,i,c]);const[y,_]=w.useState(null);w.useEffect(()=>{v?.id!==y&&_(null)},[v?.id]),w.useEffect(()=>{if(v&&f&&x&&y!==v.id){_(v.id);const z=p!==null?Math.round(Math.max(0,p)):null;z!==null&&Kg.updateSpoolWeight(v.id,z).catch(D=>console.error("Failed to update spool weight:",D))}},[v?.id,f,x]);const N=()=>{d(i)},T=async z=>{if(i)try{await ne.updateSpool(z.id,{tag_uid:i}),h(!1),r()}catch(D){console.error("Failed to link tag:",D)}},k=i&&c!==i,M=v!==null,C=k&&!M,P=p!==null&&(f===i||f===null&&i!==null)?p:null,E=n.length,B=new Set(n.map(z=>z.material)).size,O=new Set(n.filter(z=>z.brand).map(z=>z.brand)).size;return a.jsxs("div",{className:"h-full flex flex-col p-4",children:[a.jsxs("div",{className:"flex items-center gap-6 px-4 py-2 bg-zinc-800 rounded-xl border border-zinc-700 mb-4 shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-2xl font-bold text-zinc-100",children:E}),a.jsx("span",{className:"text-sm text-zinc-500",children:e("spoolbuddy.inventory.spools","Spools")})]}),a.jsx("div",{className:"w-px h-6 bg-zinc-700"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-2xl font-bold text-zinc-100",children:B}),a.jsx("span",{className:"text-sm text-zinc-500",children:e("spoolbuddy.spool.material","Materials")})]}),a.jsx("div",{className:"w-px h-6 bg-zinc-700"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-2xl font-bold text-zinc-100",children:O}),a.jsx("span",{className:"text-sm text-zinc-500",children:e("spoolbuddy.spool.brand","Brands")})]})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsxs("div",{className:"w-1/3 flex flex-col gap-3",children:[a.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4",children:[a.jsx("h2",{className:"text-xs font-semibold text-zinc-400 uppercase tracking-wide mb-3",children:e("spoolbuddy.dashboard.device","Device")}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${t.deviceOnline?"bg-green-500 animate-pulse":"bg-red-500"}`}),a.jsx("span",{className:"text-sm text-zinc-400",children:t.deviceOnline?e("spoolbuddy.status.online","Online"):e("spoolbuddy.status.offline","Offline")})]}),a.jsxs("div",{className:"flex items-center justify-between p-3 bg-zinc-900 rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("svg",{className:"w-4 h-4 text-zinc-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M3 6l3 1m0 0l-3 9a5.002 5.002 0 006.001 0M6 7l3 9M6 7l6-2m6 2l3-1m-3 1l-3 9a5.002 5.002 0 006.001 0M18 7l3 9m-3-9l-6-2m0-2v2m0 16V5m0 16H9m3 0h3"})}),a.jsx("span",{className:"text-xs text-zinc-500",children:e("spoolbuddy.spool.scaleWeight","Scale")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-lg font-mono font-semibold text-zinc-100",children:p!==null?`${Math.abs(p)<=20?0:Math.round(Math.max(0,p))}g`:"—"}),x&&p!==null&&a.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500",title:e("spoolbuddy.weight.stable","Stable")})]})]}),a.jsxs("div",{className:"flex items-center justify-between p-3 bg-zinc-900 rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("svg",{className:"w-4 h-4 text-zinc-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A2 2 0 013 12V7a4 4 0 014-4z"})}),a.jsx("span",{className:"text-xs text-zinc-500",children:"NFC"})]}),a.jsx("span",{className:`text-sm font-medium ${f?"text-green-500":"text-zinc-500"}`,children:f?e("spoolbuddy.dashboard.tagDetected","Tag detected"):e("spoolbuddy.dashboard.noTag","No tag")})]})]})]}),a.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4 flex flex-col items-center",children:[a.jsx("span",{className:"text-4xl font-light tabular-nums text-zinc-100",children:p!==null?p.toFixed(1):"--.-"}),a.jsx("span",{className:"text-lg text-zinc-500",children:"g"}),a.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${t.deviceOnline?x?"bg-green-500 shadow-[0_0_6px_rgba(34,197,94,0.5)]":"bg-amber-500 animate-pulse":"bg-zinc-600"}`}),a.jsx("span",{className:"text-xs text-zinc-400",children:t.deviceOnline?x?e("spoolbuddy.weight.stable","Stable"):e("spoolbuddy.weight.measuring","Measuring..."):e("spoolbuddy.weight.noReading","No reading")})]})]})]}),a.jsx("div",{className:"w-2/3",children:a.jsx("div",{className:"bg-zinc-800 rounded-lg p-6 h-full flex items-center justify-center",children:k&&M&&v?a.jsx(Aet,{spool:{id:v.id,tag_uid:i,material:v.material,subtype:v.subtype,color_name:v.color_name,rgba:v.rgba,brand:v.brand,label_weight:v.label_weight,core_weight:v.core_weight,weight_used:v.weight_used},scaleWeight:P,weightStable:x,onClose:N,onSyncWeight:()=>r()}):k&&C?a.jsx(Tet,{tagUid:i,scaleWeight:P??(o!==null?o:null),onLinkSpool:g.length>0?()=>h(!0):void 0,onClose:N}):t.deviceOnline?a.jsx(Pet,{}):a.jsx(Eet,{})})})]}),i&&a.jsx(Met,{isOpen:u,onClose:()=>h(!1),tagId:i,untaggedSpools:g,onLink:T})]})}function Det(t){return t?`#${t.slice(0,6)}`:"#808080"}function Ret(t){return!t.tray_type||t.tray_type===""}function Fet(t){return t<=3?`AMS ${String.fromCharCode(65+t)}`:t>=128&&t<=135?`AMS HT ${String.fromCharCode(65+t-128)}`:`AMS ${t}`}function Let(t){return t==null?"-":t>5?`${t}%`:`Level ${t}`}function Oet({tray:t,slotIndex:e,isActive:n}){const r=Ret(t),i=Det(t.tray_color);return a.jsxs("div",{className:`relative flex flex-col items-center p-2 rounded-lg transition-all ${n?"ring-2 ring-bambu-green":""}`,children:[a.jsxs("div",{className:"relative w-14 h-14 mb-1",children:[r?a.jsx("div",{className:"w-full h-full rounded-full border-2 border-dashed border-gray-500 flex items-center justify-center",children:a.jsx("div",{className:"w-3 h-3 rounded-full bg-gray-600"})}):a.jsxs("svg",{viewBox:"0 0 56 56",className:"w-full h-full",children:[a.jsx("circle",{cx:"28",cy:"28",r:"26",fill:i}),a.jsx("circle",{cx:"28",cy:"28",r:"20",fill:i,style:{filter:"brightness(0.85)"}}),a.jsx("ellipse",{cx:"20",cy:"20",rx:"6",ry:"4",fill:"white",opacity:"0.3"}),a.jsx("circle",{cx:"28",cy:"28",r:"8",fill:"#2d2d2d"}),a.jsx("circle",{cx:"28",cy:"28",r:"5",fill:"#1a1a1a"})]}),n&&a.jsx("div",{className:"absolute -bottom-1 left-1/2 -translate-x-1/2 w-2 h-2 bg-bambu-green rounded-full"})]}),a.jsx("span",{className:"text-xs text-white/70 truncate max-w-full",children:r?"Empty":t.tray_type||"Unknown"}),!r&&t.remain!==null&&t.remain!==void 0&&t.remain>=0&&a.jsx("div",{className:"w-full h-1 bg-bambu-dark-tertiary rounded-full overflow-hidden mt-1",children:a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${t.remain}%`,backgroundColor:t.remain>50?"#22c55e":t.remain>20?"#f59e0b":"#ef4444"}})}),a.jsx("span",{className:"absolute top-1 right-1 text-[10px] text-white/30",children:e+1})]})}function Iet({unit:t,activeSlot:e}){const n=t.tray||[],r=t.is_ams_ht,i=r?1:4;return a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("span",{className:"text-white font-medium",children:Fet(t.id)}),t.humidity!==null&&t.humidity!==void 0&&a.jsxs("div",{className:"flex items-center gap-1 text-xs text-white/50",children:[a.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{d:"M12 2.69l5.66 5.66a8 8 0 1 1-11.31 0z"})}),a.jsx("span",{children:Let(t.humidity)})]})]}),a.jsx("div",{className:`grid ${r?"grid-cols-1 max-w-[100px] mx-auto":"grid-cols-4"} gap-2`,children:Array.from({length:i}).map((s,o)=>{const l=n[o]||{id:o,tray_color:null,tray_type:"",tray_sub_brands:null,tray_id_name:null,tray_info_idx:null,remain:-1,k:null,cali_idx:null,tag_uid:null,tray_uuid:null,nozzle_temp_min:null,nozzle_temp_max:null};return a.jsx(Oet,{tray:l,slotIndex:o,isActive:e===o},o)})})]})}function zet(t){return t<=3?`AMS ${String.fromCharCode(65+t)}`:t>=128&&t<=135?`AMS HT ${String.fromCharCode(65+t-128)}`:`AMS ${t}`}function Uet(){const{selectedPrinterId:t,setAlert:e}=uF(),{t:n}=Dt(),{data:r}=Je({queryKey:["printerStatus",t],queryFn:()=>ne.getPrinterStatus(t),enabled:t!==null,staleTime:30*1e3}),i=r?.connected??!1,s=w.useMemo(()=>r?.ams??[],[r?.ams]),o=r?.tray_now??255,l=c=>{if(o===255||o===254)return null;if(c<=3&&Math.floor(o/4)===c)return o%4;if(c>=128&&c<=135){const d=c-128;if(o===16+d)return 0}return null};return w.useEffect(()=>{if(!i&&t){e({type:"warning",message:n("spoolbuddy.ams.printerDisconnected","Printer disconnected")});return}for(const c of s)for(const d of c.tray||[])if(d.remain!==null&&d.remain>=0&&d.remain<15&&d.tray_type){e({type:"warning",message:`Low Filament: ${d.tray_type} (${zet(c.id)}) - ${d.remain}% remaining`});return}e(null)},[s,i,t,e,n]),a.jsx("div",{className:"h-full flex flex-col p-4",children:a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:t?i?s.length===0?a.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center text-white/50",children:[a.jsx(oi,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),a.jsx("p",{className:"text-lg mb-2",children:n("spoolbuddy.ams.noData","No AMS detected")}),a.jsx("p",{className:"text-sm",children:n("spoolbuddy.ams.connectAms","Connect an AMS to see filament slots")})]})}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:s.map(c=>a.jsx(Iet,{unit:c,activeSlot:l(c.id)},c.id))}):a.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:a.jsx("div",{className:"text-center text-white/50",children:a.jsx("p",{className:"text-lg mb-2",children:n("spoolbuddy.ams.printerDisconnected","Printer disconnected")})})}):a.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center text-white/50",children:[a.jsx("p",{className:"text-lg mb-2",children:n("spoolbuddy.ams.noPrinter","No printer selected")}),a.jsx("p",{className:"text-sm",children:n("spoolbuddy.ams.selectPrinter","Select a printer from the top bar")})]})})})})}function Bet(t){if(!t)return"-";try{return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}catch{return"-"}}function Het({spool:t}){const{t:e}=Dt(),[n,r]=w.useState(!1),i=Math.max(0,t.label_weight-t.weight_used),s=t.label_weight>0?i/t.label_weight*100:0,o=t.rgba?`#${t.rgba.slice(0,6)}`:"#808080",l=s>50?"#22c55e":s>15?"#f59e0b":"#ef4444";return a.jsxs("button",{className:"w-full bg-zinc-800 rounded-lg p-3 text-left transition-colors hover:bg-zinc-750 active:bg-zinc-700",onClick:()=>r(!n),children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(MA,{color:o,isEmpty:!1,size:36}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium text-zinc-100 truncate",children:t.color_name||t.material}),t.tag_uid&&a.jsx("svg",{className:"w-3 h-3 text-green-500 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A2 2 0 013 12V7a4 4 0 014-4z"})})]}),a.jsxs("span",{className:"text-xs text-zinc-500 truncate block",children:[t.brand?`${t.brand} • `:"",t.material,t.subtype?` ${t.subtype}`:""]})]}),a.jsxs("div",{className:"text-right shrink-0",children:[a.jsxs("div",{className:"text-sm text-zinc-300",children:[Math.round(i),"g"]}),a.jsx("div",{className:"text-xs text-zinc-500",children:e("spoolbuddy.spool.remaining","Remaining")})]})]}),a.jsx("div",{className:"w-full h-1 bg-zinc-700 rounded-full overflow-hidden mt-2",children:a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Math.min(100,s)}%`,backgroundColor:l}})}),n&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-zinc-700 grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.spool.labelWeight","Label")}),a.jsxs("span",{className:"text-zinc-400",children:[t.label_weight,"g"]})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.spool.coreWeight","Core")}),a.jsxs("span",{className:"text-zinc-400",children:[t.core_weight,"g"]})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.spool.material","Material")}),a.jsxs("span",{className:"text-zinc-400",children:[t.material,t.subtype?` ${t.subtype}`:""]})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.spool.lastUsed","Last used")}),a.jsx("span",{className:"text-zinc-400",children:Bet(t.last_used)})]}),t.tag_uid&&a.jsxs("div",{className:"col-span-2 flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:"Tag"}),a.jsx("span",{className:"text-zinc-400 font-mono text-[10px]",children:t.tag_uid})]})]})]})}function $et(){const{t}=Dt(),[e,n]=w.useState(""),{data:r=[],isLoading:i}=Je({queryKey:["inventory-spools"],queryFn:()=>ne.getSpools(!1)}),s=w.useMemo(()=>{if(!e.trim())return r;const o=e.toLowerCase();return r.filter(l=>l.material.toLowerCase().includes(o)||l.brand?.toLowerCase().includes(o)||l.color_name?.toLowerCase().includes(o))},[r,e]);return a.jsxs("div",{className:"h-full flex flex-col p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h1",{className:"text-lg font-semibold text-zinc-100",children:t("spoolbuddy.nav.inventory","Inventory")}),a.jsxs("span",{className:"text-sm text-zinc-500",children:[r.length," ",t("spoolbuddy.inventory.spools","spools")]})]}),a.jsxs("div",{className:"relative mb-4",children:[a.jsx("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),a.jsx("input",{type:"text",value:e,onChange:o=>n(o.target.value),placeholder:t("spoolbuddy.inventory.search","Search spools..."),className:"w-full pl-10 pr-4 py-2.5 bg-zinc-800 border border-zinc-700 rounded-lg text-sm text-zinc-100 placeholder-zinc-500 focus:outline-none focus:border-green-500 min-h-[44px]"})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-2",children:i?a.jsx("div",{className:"flex items-center justify-center h-32",children:a.jsx("span",{className:"text-zinc-500",children:t("common.loading","Loading...")})}):s.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-zinc-500",children:[a.jsx("svg",{className:"w-10 h-10 mb-2 opacity-50",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})}),a.jsx("p",{className:"text-sm",children:e?t("spoolbuddy.inventory.noResults","No matching spools"):t("spoolbuddy.inventory.empty","No spools in inventory")})]}):s.map(o=>a.jsx(Het,{spool:o},o.id))})]})}function Vet(t){if(t<60)return`${t}s`;if(t<3600)return`${Math.floor(t/60)}m`;const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return`${e}h ${n}m`}function qet({device:t,weight:e,weightStable:n,rawAdc:r}){const{t:i}=Dt(),[s,o]=w.useState(!1),[l,c]=w.useState("idle"),[d,u]=w.useState(500),[h,f]=w.useState(!1),p=async()=>{f(!0);try{await Kg.tare(t.device_id)}catch(g){console.error("Failed to tare:",g)}finally{f(!1)}},x=()=>{c("tare")},v=async()=>{if(l==="tare"){o(!0);try{await Kg.tare(t.device_id),c("weight")}catch(g){console.error("Failed to tare:",g)}finally{o(!1)}}else if(l==="weight"){if(r===null)return;o(!0);try{await Kg.setCalibrationFactor(t.device_id,d,r),c("idle")}catch(g){console.error("Failed to calibrate:",g)}finally{o(!1)}}};return a.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-zinc-100 mb-4",children:i("spoolbuddy.settings.scaleCalibration","Scale Calibration")}),a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("span",{className:"text-sm text-zinc-400",children:i("spoolbuddy.settings.currentWeight","Current weight")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${n?"bg-green-500":"bg-amber-500 animate-pulse"}`}),a.jsx("span",{className:"text-sm font-mono text-zinc-200",children:e!==null?`${e.toFixed(1)} g`:"-- g"})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-4 text-xs",children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:i("spoolbuddy.settings.tareOffset","Tare offset")}),a.jsx("span",{className:"text-zinc-400 font-mono",children:t.tare_offset})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:i("spoolbuddy.settings.calFactor","Cal. factor")}),a.jsx("span",{className:"text-zinc-400 font-mono",children:t.calibration_factor.toFixed(2)})]})]}),l==="idle"?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:p,disabled:h,className:"flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-200 hover:bg-zinc-600 disabled:opacity-40 transition-colors min-h-[44px]",children:h?"...":i("spoolbuddy.weight.tare","Tare")}),a.jsx("button",{onClick:x,className:"flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 transition-colors min-h-[44px]",children:i("spoolbuddy.weight.calibrate","Calibrate")})]}):a.jsxs("div",{className:"border border-zinc-700 rounded-lg p-3 space-y-3",children:[a.jsx("div",{className:"text-sm font-medium text-zinc-200",children:l==="tare"?i("spoolbuddy.settings.calStep1","Step 1: Remove all items from the scale"):i("spoolbuddy.settings.calStep2","Step 2: Place known weight on scale")}),l==="weight"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("label",{className:"text-xs text-zinc-400",children:i("spoolbuddy.settings.knownWeight","Known weight (g)")}),a.jsx("input",{type:"number",value:d,onChange:g=>u(Number(g.target.value)),className:"w-24 px-2 py-1.5 bg-zinc-900 border border-zinc-600 rounded text-sm text-zinc-100 focus:outline-none focus:border-green-500",min:1})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>c("idle"),className:"flex-1 px-4 py-2 rounded-lg text-sm bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[40px]",children:i("common.cancel","Cancel")}),a.jsx("button",{onClick:v,disabled:s,className:"flex-1 px-4 py-2 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 transition-colors min-h-[40px]",children:s?"...":l==="tare"?i("spoolbuddy.settings.setZero","Set Zero"):i("spoolbuddy.settings.calibrateNow","Calibrate")})]})]})]})}function Get({device:t}){const{t:e}=Dt();return a.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-zinc-100 mb-4",children:e("spoolbuddy.settings.deviceInfo","Device Info")}),a.jsxs("div",{className:"space-y-2 text-sm",children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:"Device ID"}),a.jsx("span",{className:"text-zinc-300 font-mono text-xs",children:t.device_id})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.settings.hostname","Hostname")}),a.jsx("span",{className:"text-zinc-300",children:t.hostname})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:"IP"}),a.jsx("span",{className:"text-zinc-300",children:t.ip_address})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.settings.firmware","Firmware")}),a.jsx("span",{className:"text-zinc-300",children:t.firmware_version??"-"})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:"NFC"}),a.jsx("span",{className:t.nfc_ok?"text-green-400":"text-zinc-500",children:t.nfc_ok?e("spoolbuddy.status.nfcReady","Ready"):e("spoolbuddy.status.nfcOff","Off")})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.settings.scale","Scale")}),a.jsx("span",{className:t.scale_ok?"text-green-400":"text-red-400",children:t.scale_ok?"OK":e("common.error","Error")})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.settings.uptime","Uptime")}),a.jsx("span",{className:"text-zinc-300",children:Vet(t.uptime_s)})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.status.status","Status")}),a.jsx("span",{className:t.online?"text-green-400":"text-zinc-500",children:t.online?e("spoolbuddy.status.online","Online"):e("spoolbuddy.status.offline","Offline")})]})]})]})}function Wet(){const{sbState:t}=uF(),{t:e}=Dt(),{data:n=[]}=Je({queryKey:["spoolbuddy-devices"],queryFn:()=>Kg.getDevices(),refetchInterval:1e4}),r=t.deviceId?n.find(i=>i.device_id===t.deviceId)??n[0]:n[0];return a.jsxs("div",{className:"h-full flex flex-col p-4",children:[a.jsx("h1",{className:"text-lg font-semibold text-zinc-100 mb-4",children:e("spoolbuddy.nav.settings","Settings")}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-4",children:r?a.jsxs(a.Fragment,{children:[a.jsx(qet,{device:r,weight:t.weight,weightStable:t.weightStable,rawAdc:t.rawAdc}),a.jsx(Get,{device:r})]}):a.jsx("div",{className:"flex items-center justify-center h-32",children:a.jsx("div",{className:"text-center text-zinc-500",children:a.jsx("p",{className:"text-sm",children:e("spoolbuddy.settings.noDevice","No SpoolBuddy device found")})})})})]})}const Ket=new xue({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function pK({children:t}){return get(),a.jsx(a.Fragment,{children:t})}function gK({children:t}){const{authEnabled:e,loading:n,user:r}=Pr();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?a.jsx(ob,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function zj({children:t}){const{authEnabled:e,loading:n,user:r,isAdmin:i}=Pr();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?i?a.jsx(a.Fragment,{children:t}):a.jsx(ob,{to:"/",replace:!0}):a.jsx(ob,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function Yet({children:t}){const{authEnabled:e,loading:n}=Pr();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?a.jsx(ob,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function Xet(){return a.jsx(mge,{children:a.jsx(wge,{children:a.jsx(yue,{client:Ket,children:a.jsx(yge,{children:a.jsx(Ide,{children:a.jsxs(mde,{children:[a.jsx(Lr,{path:"/setup",element:a.jsx(Yet,{children:a.jsx(pet,{})})}),a.jsx(Lr,{path:"/login",element:a.jsx(fet,{})}),a.jsx(Lr,{path:"/camera/:printerId",element:a.jsx(CJe,{})}),a.jsx(Lr,{path:"/overlay/:printerId",element:a.jsx(MJe,{})}),a.jsxs(Lr,{element:a.jsx(gK,{children:a.jsx(pK,{children:a.jsx(Cet,{})})}),children:[a.jsx(Lr,{path:"spoolbuddy",element:a.jsx(jet,{})}),a.jsx(Lr,{path:"spoolbuddy/ams",element:a.jsx(Uet,{})}),a.jsx(Lr,{path:"spoolbuddy/inventory",element:a.jsx($et,{})}),a.jsx(Lr,{path:"spoolbuddy/settings",element:a.jsx(Wet,{})})]}),a.jsxs(Lr,{element:a.jsx(gK,{children:a.jsx(pK,{children:a.jsx(Pge,{})})}),children:[a.jsx(Lr,{index:!0,element:a.jsx(N$e,{})}),a.jsx(Lr,{path:"archives",element:a.jsx(uXe,{})}),a.jsx(Lr,{path:"queue",element:a.jsx(YQe,{})}),a.jsx(Lr,{path:"stats",element:a.jsx(cZe,{})}),a.jsx(Lr,{path:"profiles",element:a.jsx(eJe,{})}),a.jsx(Lr,{path:"maintenance",element:a.jsx(iJe,{})}),a.jsx(Lr,{path:"projects",element:a.jsx(oJe,{})}),a.jsx(Lr,{path:"projects/:id",element:a.jsx(fJe,{})}),a.jsx(Lr,{path:"inventory",element:a.jsx(iet,{})}),a.jsx(Lr,{path:"files",element:a.jsx(wJe,{})}),a.jsx(Lr,{path:"settings",element:a.jsx(zj,{children:a.jsx(UZe,{})})}),a.jsx(Lr,{path:"groups/new",element:a.jsx(zj,{children:a.jsx(sK,{})})}),a.jsx(Lr,{path:"groups/:id/edit",element:a.jsx(zj,{children:a.jsx(sK,{})})}),a.jsx(Lr,{path:"users",element:a.jsx(ob,{to:"/settings?tab=users",replace:!0})}),a.jsx(Lr,{path:"groups",element:a.jsx(ob,{to:"/settings?tab=users",replace:!0})}),a.jsx(Lr,{path:"system",element:a.jsx(met,{})}),a.jsx(Lr,{path:"external/:id",element:a.jsx(PJe,{})})]})]})})})})})})}cle.createRoot(document.getElementById("root")).render(a.jsx(w.StrictMode,{children:a.jsx(Xet,{})})); diff --git a/static/assets/index-DJjXosw8.css b/static/assets/index-DJjXosw8.css new file mode 100644 index 000000000..6c40b2a2d --- /dev/null +++ b/static/assets/index-DJjXosw8.css @@ -0,0 +1 @@ +@import"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap";@layer properties,theme,base,components,utilities;@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-950:oklch(25.8% .092 26.042);--color-orange-200:oklch(90.1% .076 70.697);--color-orange-300:oklch(83.7% .128 66.29);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-600:oklch(64.6% .222 41.116);--color-orange-700:oklch(55.3% .195 38.402);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-yellow-200:oklch(94.5% .129 101.54);--color-yellow-300:oklch(90.5% .182 98.111);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-yellow-600:oklch(68.1% .162 75.834);--color-yellow-700:oklch(55.4% .135 66.442);--color-lime-500:oklch(76.8% .233 130.85);--color-green-100:oklch(96.2% .044 156.743);--color-green-200:oklch(92.5% .084 155.995);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-green-900:oklch(39.3% .095 152.535);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-700:oklch(50.8% .118 165.612);--color-teal-400:oklch(77.7% .152 181.912);--color-teal-500:oklch(70.4% .14 182.503);--color-cyan-300:oklch(86.5% .127 207.078);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-500:oklch(71.5% .143 215.221);--color-cyan-600:oklch(60.9% .126 221.723);--color-sky-400:oklch(74.6% .16 232.661);--color-sky-500:oklch(68.5% .169 237.323);--color-blue-50:oklch(97% .014 254.604);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-indigo-400:oklch(67.3% .182 276.935);--color-indigo-500:oklch(58.5% .233 277.117);--color-violet-500:oklch(60.6% .25 292.717);--color-purple-300:oklch(82.7% .119 306.383);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-500:oklch(62.7% .265 303.9);--color-purple-700:oklch(49.6% .265 301.924);--color-fuchsia-500:oklch(66.7% .295 322.15);--color-rose-300:oklch(81% .117 11.638);--color-rose-400:oklch(71.2% .194 13.428);--color-rose-500:oklch(64.5% .246 16.439);--color-rose-600:oklch(58.6% .253 17.585);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-500:oklch(55.4% .046 257.417);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-gray-900:oklch(21% .034 264.665);--color-zinc-100:oklch(96.7% .001 286.375);--color-zinc-200:oklch(92% .004 286.32);--color-zinc-300:oklch(87.1% .006 286.286);--color-zinc-400:oklch(70.5% .015 286.067);--color-zinc-500:oklch(55.2% .016 285.938);--color-zinc-600:oklch(44.2% .017 285.786);--color-zinc-700:oklch(37% .013 285.805);--color-zinc-800:oklch(27.4% .006 286.033);--color-zinc-900:oklch(21% .006 285.885);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-xl:36rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--container-5xl:64rem;--container-6xl:72rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--text-3xl:1.875rem;--text-3xl--line-height: 1.2 ;--text-4xl:2.25rem;--text-4xl--line-height:calc(2.5/2.25);--text-5xl:3rem;--text-5xl--line-height:1;--font-weight-light:300;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--tracking-wider:.05em;--tracking-widest:.1em;--leading-tight:1.25;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--drop-shadow-md:0 3px 3px #0000001f;--drop-shadow-lg:0 4px 4px #00000026;--ease-out:cubic-bezier(0,0,.2,1);--ease-in-out:cubic-bezier(.4,0,.2,1);--animate-spin:spin 1s linear infinite;--animate-ping:ping 1s cubic-bezier(0,0,.2,1)infinite;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--blur-sm:8px;--blur-2xl:40px;--aspect-video:16/9;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-bambu-green:var(--accent);--color-bambu-green-light:var(--accent-light);--color-bambu-green-dark:var(--accent-dark);--color-status-ok:var(--status-ok);--color-status-error:var(--status-error);--color-status-warning:var(--status-warning);--color-bambu-dark:var(--bg-primary);--color-bambu-dark-secondary:var(--bg-secondary);--color-bambu-dark-tertiary:var(--bg-tertiary);--color-bambu-gray:var(--text-muted);--color-bambu-gray-light:var(--text-secondary);--color-bambu-gray-dark:var(--text-tertiary)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.-inset-4{inset:calc(var(--spacing)*-4)}.inset-0{inset:calc(var(--spacing)*0)}.inset-x-0{inset-inline:calc(var(--spacing)*0)}.inset-y-0{inset-block:calc(var(--spacing)*0)}.-top-0\.5{top:calc(var(--spacing)*-.5)}.-top-1{top:calc(var(--spacing)*-1)}.-top-1\.5{top:calc(var(--spacing)*-1.5)}.top-0{top:calc(var(--spacing)*0)}.top-0\.5{top:calc(var(--spacing)*.5)}.top-1{top:calc(var(--spacing)*1)}.top-1\.5{top:calc(var(--spacing)*1.5)}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing)*2)}.top-2\.5{top:calc(var(--spacing)*2.5)}.top-3{top:calc(var(--spacing)*3)}.top-4{top:calc(var(--spacing)*4)}.top-8{top:calc(var(--spacing)*8)}.top-\[2px\]{top:2px}.top-\[3px\]{top:3px}.top-\[52px\]{top:52px}.top-full{top:100%}.-right-0\.5{right:calc(var(--spacing)*-.5)}.-right-1{right:calc(var(--spacing)*-1)}.-right-1\.5{right:calc(var(--spacing)*-1.5)}.-right-2{right:calc(var(--spacing)*-2)}.right-0{right:calc(var(--spacing)*0)}.right-1{right:calc(var(--spacing)*1)}.right-1\.5{right:calc(var(--spacing)*1.5)}.right-2{right:calc(var(--spacing)*2)}.right-3{right:calc(var(--spacing)*3)}.right-4{right:calc(var(--spacing)*4)}.right-6{right:calc(var(--spacing)*6)}.right-12{right:calc(var(--spacing)*12)}.right-\[5\.5rem\]{right:5.5rem}.right-full{right:100%}.-bottom-1{bottom:calc(var(--spacing)*-1)}.-bottom-2{bottom:calc(var(--spacing)*-2)}.-bottom-7{bottom:calc(var(--spacing)*-7)}.bottom-0{bottom:calc(var(--spacing)*0)}.bottom-1{bottom:calc(var(--spacing)*1)}.bottom-2{bottom:calc(var(--spacing)*2)}.bottom-3{bottom:calc(var(--spacing)*3)}.bottom-4{bottom:calc(var(--spacing)*4)}.bottom-6{bottom:calc(var(--spacing)*6)}.bottom-8{bottom:calc(var(--spacing)*8)}.bottom-full{bottom:100%}.-left-2{left:calc(var(--spacing)*-2)}.left-0{left:calc(var(--spacing)*0)}.left-0\.5{left:calc(var(--spacing)*.5)}.left-1{left:calc(var(--spacing)*1)}.left-1\/2{left:50%}.left-2{left:calc(var(--spacing)*2)}.left-2\.5{left:calc(var(--spacing)*2.5)}.left-3{left:calc(var(--spacing)*3)}.left-4{left:calc(var(--spacing)*4)}.left-10{left:calc(var(--spacing)*10)}.left-12{left:calc(var(--spacing)*12)}.left-\[2px\]{left:2px}.left-\[3px\]{left:3px}.left-full{left:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-60,.z-\[60\]{z-index:60}.z-\[100\]{z-index:100}.col-span-1{grid-column:span 1/span 1}.col-span-2{grid-column:span 2/span 2}.col-span-3{grid-column:span 3/span 3}.col-span-4{grid-column:span 4/span 4}.col-span-full{grid-column:1/-1}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.-m-4{margin:calc(var(--spacing)*-4)}.-mx-4{margin-inline:calc(var(--spacing)*-4)}.mx-1{margin-inline:calc(var(--spacing)*1)}.mx-2{margin-inline:calc(var(--spacing)*2)}.mx-4{margin-inline:calc(var(--spacing)*4)}.mx-auto{margin-inline:auto}.my-1{margin-block:calc(var(--spacing)*1)}.my-8{margin-block:calc(var(--spacing)*8)}.-mt-0\.5{margin-top:calc(var(--spacing)*-.5)}.-mt-2{margin-top:calc(var(--spacing)*-2)}.mt-0\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-1\.5{margin-top:calc(var(--spacing)*1.5)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-6{margin-top:calc(var(--spacing)*6)}.mt-8{margin-top:calc(var(--spacing)*8)}.mt-14{margin-top:calc(var(--spacing)*14)}.mt-auto{margin-top:auto}.mr-1{margin-right:calc(var(--spacing)*1)}.mr-1\.5{margin-right:calc(var(--spacing)*1.5)}.mr-2{margin-right:calc(var(--spacing)*2)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-4{margin-right:calc(var(--spacing)*4)}.mr-auto{margin-right:auto}.-mb-px{margin-bottom:-1px}.mb-0\.5{margin-bottom:calc(var(--spacing)*.5)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-1\.5{margin-bottom:calc(var(--spacing)*1.5)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.mb-5{margin-bottom:calc(var(--spacing)*5)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.-ml-1{margin-left:calc(var(--spacing)*-1)}.-ml-2{margin-left:calc(var(--spacing)*-2)}.ml-0\.5{margin-left:calc(var(--spacing)*.5)}.ml-1{margin-left:calc(var(--spacing)*1)}.ml-1\.5{margin-left:calc(var(--spacing)*1.5)}.ml-2{margin-left:calc(var(--spacing)*2)}.ml-3{margin-left:calc(var(--spacing)*3)}.ml-4{margin-left:calc(var(--spacing)*4)}.ml-6{margin-left:calc(var(--spacing)*6)}.ml-7{margin-left:calc(var(--spacing)*7)}.ml-9{margin-left:calc(var(--spacing)*9)}.ml-14{margin-left:calc(var(--spacing)*14)}.ml-16{margin-left:calc(var(--spacing)*16)}.ml-64{margin-left:calc(var(--spacing)*64)}.ml-auto{margin-left:auto}.line-clamp-1{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.aspect-square{aspect-ratio:1}.aspect-video{aspect-ratio:var(--aspect-video)}.h-0{height:calc(var(--spacing)*0)}.h-0\.5{height:calc(var(--spacing)*.5)}.h-1{height:calc(var(--spacing)*1)}.h-1\.5{height:calc(var(--spacing)*1.5)}.h-2{height:calc(var(--spacing)*2)}.h-2\.5{height:calc(var(--spacing)*2.5)}.h-3{height:calc(var(--spacing)*3)}.h-3\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-10{height:calc(var(--spacing)*10)}.h-11{height:calc(var(--spacing)*11)}.h-12{height:calc(var(--spacing)*12)}.h-14{height:calc(var(--spacing)*14)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-24{height:calc(var(--spacing)*24)}.h-32{height:calc(var(--spacing)*32)}.h-40{height:calc(var(--spacing)*40)}.h-48{height:calc(var(--spacing)*48)}.h-64{height:calc(var(--spacing)*64)}.h-80{height:calc(var(--spacing)*80)}.h-\[18px\]{height:18px}.h-\[38px\]{height:38px}.h-\[80vh\]{height:80vh}.h-\[160px\]{height:160px}.h-\[300px\]{height:300px}.h-\[calc\(100\%-40px\)\]{height:calc(100% - 40px)}.h-full{height:100%}.h-px{height:1px}.h-screen{height:100vh}.max-h-40{max-height:calc(var(--spacing)*40)}.max-h-48{max-height:calc(var(--spacing)*48)}.max-h-60{max-height:calc(var(--spacing)*60)}.max-h-64{max-height:calc(var(--spacing)*64)}.max-h-80{max-height:calc(var(--spacing)*80)}.max-h-96{max-height:calc(var(--spacing)*96)}.max-h-\[60vh\]{max-height:60vh}.max-h-\[80vh\]{max-height:80vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[300px\]{max-height:300px}.max-h-\[400px\]{max-height:400px}.max-h-\[500px\]{max-height:500px}.max-h-\[600px\]{max-height:600px}.max-h-\[calc\(90vh-80px\)\]{max-height:calc(90vh - 80px)}.max-h-\[calc\(100vh-320px\)\]{max-height:calc(100vh - 320px)}.max-h-full{max-height:100%}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-\[40px\]{min-height:40px}.min-h-\[44px\]{min-height:44px}.min-h-\[48px\]{min-height:48px}.min-h-\[80px\]{min-height:80px}.min-h-\[120px\]{min-height:120px}.min-h-\[300px\]{min-height:300px}.min-h-\[400px\]{min-height:400px}.min-h-\[calc\(100vh-64px\)\]{min-height:calc(100vh - 64px)}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-0{width:calc(var(--spacing)*0)}.w-0\.5{width:calc(var(--spacing)*.5)}.w-1{width:calc(var(--spacing)*1)}.w-1\.5{width:calc(var(--spacing)*1.5)}.w-1\/3{width:33.3333%}.w-2{width:calc(var(--spacing)*2)}.w-2\.5{width:calc(var(--spacing)*2.5)}.w-2\/3{width:66.6667%}.w-3{width:calc(var(--spacing)*3)}.w-3\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-4\.5{width:calc(var(--spacing)*4.5)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-8{width:calc(var(--spacing)*8)}.w-9{width:calc(var(--spacing)*9)}.w-10{width:calc(var(--spacing)*10)}.w-11{width:calc(var(--spacing)*11)}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.w-16{width:calc(var(--spacing)*16)}.w-20{width:calc(var(--spacing)*20)}.w-24{width:calc(var(--spacing)*24)}.w-32{width:calc(var(--spacing)*32)}.w-36{width:calc(var(--spacing)*36)}.w-40{width:calc(var(--spacing)*40)}.w-44{width:calc(var(--spacing)*44)}.w-48{width:calc(var(--spacing)*48)}.w-52{width:calc(var(--spacing)*52)}.w-56{width:calc(var(--spacing)*56)}.w-64{width:calc(var(--spacing)*64)}.w-72{width:calc(var(--spacing)*72)}.w-96{width:calc(var(--spacing)*96)}.w-\[420px\]{width:420px}.w-\[560px\]{width:560px}.w-auto{width:auto}.w-fit{width:fit-content}.w-full{width:100%}.w-px{width:1px}.w-screen{width:100vw}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-5xl{max-width:var(--container-5xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-32{max-width:calc(var(--spacing)*32)}.max-w-\[40\%\]{max-width:40%}.max-w-\[50\%\]{max-width:50%}.max-w-\[80px\]{max-width:80px}.max-w-\[90vw\]{max-width:90vw}.max-w-\[100px\]{max-width:100px}.max-w-\[120px\]{max-width:120px}.max-w-\[150px\]{max-width:150px}.max-w-\[160px\]{max-width:160px}.max-w-\[200px\]{max-width:200px}.max-w-\[280px\]{max-width:280px}.max-w-\[600px\]{max-width:600px}.max-w-full{max-width:100%}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.max-w-xl{max-width:var(--container-xl)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-48{min-width:calc(var(--spacing)*48)}.min-w-\[16px\]{min-width:16px}.min-w-\[18px\]{min-width:18px}.min-w-\[32px\]{min-width:32px}.min-w-\[40px\]{min-width:40px}.min-w-\[48px\]{min-width:48px}.min-w-\[50px\]{min-width:50px}.min-w-\[80px\]{min-width:80px}.min-w-\[100px\]{min-width:100px}.min-w-\[120px\]{min-width:120px}.min-w-\[140px\]{min-width:140px}.min-w-\[150px\]{min-width:150px}.min-w-\[160px\]{min-width:160px}.min-w-\[180px\]{min-width:180px}.min-w-\[200px\]{min-width:200px}.min-w-full{min-width:100%}.flex-1{flex:1}.flex-\[2_1_190px\]{flex:2 190px}.flex-shrink{flex-shrink:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-x-full{--tw-translate-x:-100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0\.5{--tw-translate-x:calc(var(--spacing)*.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-1{--tw-translate-x:calc(var(--spacing)*1);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-3\.5{--tw-translate-x:calc(var(--spacing)*3.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-4{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-5{--tw-translate-x:calc(var(--spacing)*5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-6{--tw-translate-x:calc(var(--spacing)*6);translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.scale-105{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-\[1\.02\]{scale:1.02}.-rotate-90{rotate:-90deg}.rotate-90{rotate:90deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-col-resize{cursor:col-resize}.cursor-default{cursor:default}.cursor-ew-resize{cursor:ew-resize}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-row-resize{cursor:row-resize}.cursor-se-resize{cursor:se-resize}.touch-manipulation{touch-action:manipulation}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.appearance-none{appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}.grid-cols-\[auto_1fr_100px_100px_100px_80px\]{grid-template-columns:auto 1fr 100px 100px 100px 80px}.grid-cols-\[auto_1fr_120px_100px_100px_100px_80px\]{grid-template-columns:auto 1fr 120px 100px 100px 100px 80px}.flex-col{flex-direction:column}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0{gap:calc(var(--spacing)*0)}.gap-0\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-6{gap:calc(var(--spacing)*6)}.gap-8{gap:calc(var(--spacing)*8)}.gap-\[3px\]{gap:3px}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*4)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*4)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*6)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*6)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}.gap-x-3{column-gap:calc(var(--spacing)*3)}.gap-x-4{column-gap:calc(var(--spacing)*4)}.gap-x-6{column-gap:calc(var(--spacing)*6)}.gap-y-1{row-gap:calc(var(--spacing)*1)}.gap-y-2{row-gap:calc(var(--spacing)*2)}.gap-y-3{row-gap:calc(var(--spacing)*3)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px*var(--tw-divide-y-reverse));border-bottom-width:calc(1px*calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-bambu-dark-tertiary>:not(:last-child)),:where(.divide-bambu-dark-tertiary\/30>:not(:last-child)){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){:where(.divide-bambu-dark-tertiary\/30>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}:where(.divide-bambu-gray\/20>:not(:last-child)){border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){:where(.divide-bambu-gray\/20>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-none{border-radius:0}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-t-lg{border-top-left-radius:var(--radius-lg);border-top-right-radius:var(--radius-lg)}.rounded-t-xl{border-top-left-radius:var(--radius-xl);border-top-right-radius:var(--radius-xl)}.\!rounded-l-none{border-top-left-radius:0!important;border-bottom-left-radius:0!important}.rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-l-lg{border-top-left-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.rounded-tl{border-top-left-radius:.25rem}.\!rounded-r-none{border-top-right-radius:0!important;border-bottom-right-radius:0!important}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.rounded-r-lg{border-top-right-radius:var(--radius-lg);border-bottom-right-radius:var(--radius-lg)}.rounded-b-lg{border-bottom-right-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-4{border-style:var(--tw-border-style);border-width:4px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-2{border-top-style:var(--tw-border-style);border-top-width:2px}.border-t-\[5px\]{border-top-style:var(--tw-border-style);border-top-width:5px}.border-t-\[6px\]{border-top-style:var(--tw-border-style);border-top-width:6px}.\!border-r-0{border-right-style:var(--tw-border-style)!important;border-right-width:0!important}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-\[5px\]{border-right-style:var(--tw-border-style);border-right-width:5px}.border-r-\[6px\]{border-right-style:var(--tw-border-style);border-right-width:6px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-b-\[6px\]{border-bottom-style:var(--tw-border-style);border-bottom-width:6px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-l-\[5px\]{border-left-style:var(--tw-border-style);border-left-width:5px}.border-l-\[6px\]{border-left-style:var(--tw-border-style);border-left-width:6px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.\!border-green-500{border-color:var(--color-green-500)!important}.border-amber-500{border-color:var(--color-amber-500)}.border-amber-500\/20{border-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/20{border-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.border-amber-500\/30{border-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/30{border-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.border-bambu-dark-secondary{border-color:var(--color-bambu-dark-secondary)}.border-bambu-dark-tertiary,.border-bambu-dark-tertiary\/20{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/20{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)20%,transparent)}}.border-bambu-dark-tertiary\/30{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/30{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.border-bambu-dark-tertiary\/40{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/40{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.border-bambu-dark-tertiary\/50{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/50{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.border-bambu-gray,.border-bambu-gray\/20{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/20{border-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.border-bambu-gray\/30{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/30{border-color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.border-bambu-gray\/50{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/50{border-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.border-bambu-green,.border-bambu-green\/20{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/20{border-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.border-bambu-green\/30{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/30{border-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.border-bambu-green\/40{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/40{border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.border-bambu-green\/50{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/50{border-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.border-blue-400\/20{border-color:#54a2ff33}@supports (color:color-mix(in lab,red,red)){.border-blue-400\/20{border-color:color-mix(in oklab,var(--color-blue-400)20%,transparent)}}.border-blue-400\/50{border-color:#54a2ff80}@supports (color:color-mix(in lab,red,red)){.border-blue-400\/50{border-color:color-mix(in oklab,var(--color-blue-400)50%,transparent)}}.border-blue-500{border-color:var(--color-blue-500)}.border-blue-500\/20{border-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/20{border-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.border-blue-500\/30{border-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/30{border-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.border-blue-500\/50{border-color:#3080ff80}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/50{border-color:color-mix(in oklab,var(--color-blue-500)50%,transparent)}}.border-gray-200{border-color:var(--color-gray-200)}.border-gray-300{border-color:var(--color-gray-300)}.border-gray-400\/20{border-color:#99a1af33}@supports (color:color-mix(in lab,red,red)){.border-gray-400\/20{border-color:color-mix(in oklab,var(--color-gray-400)20%,transparent)}}.border-gray-500{border-color:var(--color-gray-500)}.border-gray-500\/20{border-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.border-gray-500\/20{border-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.border-gray-700{border-color:var(--color-gray-700)}.border-green-300{border-color:var(--color-green-300)}.border-green-500{border-color:var(--color-green-500)}.border-green-500\/10{border-color:#00c7581a}@supports (color:color-mix(in lab,red,red)){.border-green-500\/10{border-color:color-mix(in oklab,var(--color-green-500)10%,transparent)}}.border-green-500\/20{border-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.border-green-500\/20{border-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500)30%,transparent)}}.border-green-500\/50{border-color:#00c75880}@supports (color:color-mix(in lab,red,red)){.border-green-500\/50{border-color:color-mix(in oklab,var(--color-green-500)50%,transparent)}}.border-orange-400\/20{border-color:#ff8b1a33}@supports (color:color-mix(in lab,red,red)){.border-orange-400\/20{border-color:color-mix(in oklab,var(--color-orange-400)20%,transparent)}}.border-orange-400\/50{border-color:#ff8b1a80}@supports (color:color-mix(in lab,red,red)){.border-orange-400\/50{border-color:color-mix(in oklab,var(--color-orange-400)50%,transparent)}}.border-orange-500\/20{border-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/20{border-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.border-orange-500\/30{border-color:#fe6e004d}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/30{border-color:color-mix(in oklab,var(--color-orange-500)30%,transparent)}}.border-purple-400\/20{border-color:#c07eff33}@supports (color:color-mix(in lab,red,red)){.border-purple-400\/20{border-color:color-mix(in oklab,var(--color-purple-400)20%,transparent)}}.border-purple-500\/20{border-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/20{border-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.border-purple-500\/30{border-color:#ac4bff4d}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/30{border-color:color-mix(in oklab,var(--color-purple-500)30%,transparent)}}.border-red-300{border-color:var(--color-red-300)}.border-red-500{border-color:var(--color-red-500)}.border-red-500\/20{border-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.border-red-500\/20{border-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.border-red-500\/50{border-color:#fb2c3680}@supports (color:color-mix(in lab,red,red)){.border-red-500\/50{border-color:color-mix(in oklab,var(--color-red-500)50%,transparent)}}.border-red-800\/70{border-color:#9f0712b3}@supports (color:color-mix(in lab,red,red)){.border-red-800\/70{border-color:color-mix(in oklab,var(--color-red-800)70%,transparent)}}.border-slate-500{border-color:var(--color-slate-500)}.border-status-error\/20{border-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.border-status-error\/20{border-color:color-mix(in oklab,var(--color-status-error)20%,transparent)}}.border-status-ok,.border-status-ok\/20{border-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.border-status-ok\/20{border-color:color-mix(in oklab,var(--color-status-ok)20%,transparent)}}.border-status-warning\/20{border-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.border-status-warning\/20{border-color:color-mix(in oklab,var(--color-status-warning)20%,transparent)}}.border-transparent{border-color:#0000}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.border-white\/20{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.border-white\/20{border-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.border-white\/30{border-color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.border-white\/30{border-color:color-mix(in oklab,var(--color-white)30%,transparent)}}.border-yellow-400\/20{border-color:#fac80033}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/20{border-color:color-mix(in oklab,var(--color-yellow-400)20%,transparent)}}.border-yellow-400\/30{border-color:#fac8004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/30{border-color:color-mix(in oklab,var(--color-yellow-400)30%,transparent)}}.border-yellow-400\/50{border-color:#fac80080}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/50{border-color:color-mix(in oklab,var(--color-yellow-400)50%,transparent)}}.border-yellow-500{border-color:var(--color-yellow-500)}.border-yellow-500\/20{border-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/20{border-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.border-yellow-500\/30{border-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/30{border-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.border-yellow-500\/50{border-color:#edb20080}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/50{border-color:color-mix(in oklab,var(--color-yellow-500)50%,transparent)}}.border-zinc-500{border-color:var(--color-zinc-500)}.border-zinc-600{border-color:var(--color-zinc-600)}.border-zinc-700{border-color:var(--color-zinc-700)}.border-t-bambu-dark-tertiary{border-top-color:var(--color-bambu-dark-tertiary)}.border-t-transparent{border-top-color:#0000}.border-r-transparent{border-right-color:#0000}.border-b-bambu-dark-tertiary{border-bottom-color:var(--color-bambu-dark-tertiary)}.border-l-transparent{border-left-color:#0000}.border-l-yellow-500{border-left-color:var(--color-yellow-500)}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-500\/5{background-color:#f99c000d}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/5{background-color:color-mix(in oklab,var(--color-amber-500)5%,transparent)}}.bg-amber-500\/10{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/10{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.bg-amber-500\/20{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/20{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.bg-amber-600\/20{background-color:#dd740033}@supports (color:color-mix(in lab,red,red)){.bg-amber-600\/20{background-color:color-mix(in oklab,var(--color-amber-600)20%,transparent)}}.bg-bambu-dark{background-color:var(--color-bambu-dark)}.bg-bambu-dark-secondary,.bg-bambu-dark-secondary\/30{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/30{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)30%,transparent)}}.bg-bambu-dark-secondary\/50{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/50{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)50%,transparent)}}.bg-bambu-dark-secondary\/60{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/60{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)60%,transparent)}}.bg-bambu-dark-secondary\/90{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/90{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)90%,transparent)}}.bg-bambu-dark-secondary\/95{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/95{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)95%,transparent)}}.bg-bambu-dark-tertiary,.bg-bambu-dark-tertiary\/20{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/20{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)20%,transparent)}}.bg-bambu-dark-tertiary\/30{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/30{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.bg-bambu-dark-tertiary\/40{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/40{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.bg-bambu-dark-tertiary\/50{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/50{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.bg-bambu-dark-tertiary\/70{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/70{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)70%,transparent)}}.bg-bambu-dark-tertiary\/80{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/80{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.bg-bambu-dark\/20{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/20{background-color:color-mix(in oklab,var(--color-bambu-dark)20%,transparent)}}.bg-bambu-dark\/30{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/30{background-color:color-mix(in oklab,var(--color-bambu-dark)30%,transparent)}}.bg-bambu-dark\/50{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/50{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.bg-bambu-dark\/80{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/80{background-color:color-mix(in oklab,var(--color-bambu-dark)80%,transparent)}}.bg-bambu-dark\/90{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/90{background-color:color-mix(in oklab,var(--color-bambu-dark)90%,transparent)}}.bg-bambu-gray,.bg-bambu-gray\/10{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/10{background-color:color-mix(in oklab,var(--color-bambu-gray)10%,transparent)}}.bg-bambu-gray\/20{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/20{background-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.bg-bambu-gray\/30{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/30{background-color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.bg-bambu-gray\/50{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/50{background-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.bg-bambu-gray\/60{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/60{background-color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.bg-bambu-gray\/90{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/90{background-color:color-mix(in oklab,var(--color-bambu-gray)90%,transparent)}}.bg-bambu-green,.bg-bambu-green\/5{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/5{background-color:color-mix(in oklab,var(--color-bambu-green)5%,transparent)}}.bg-bambu-green\/10{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/10{background-color:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.bg-bambu-green\/20{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/20{background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.bg-bambu-green\/30{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/30{background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.bg-bambu-green\/50{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/50{background-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.bg-bambu-green\/75{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/75{background-color:color-mix(in oklab,var(--color-bambu-green)75%,transparent)}}.bg-bambu-green\/90{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/90{background-color:color-mix(in oklab,var(--color-bambu-green)90%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/15{background-color:#00000026}@supports (color:color-mix(in lab,red,red)){.bg-black\/15{background-color:color-mix(in oklab,var(--color-black)15%,transparent)}}.bg-black\/30{background-color:#0000004d}@supports (color:color-mix(in lab,red,red)){.bg-black\/30{background-color:color-mix(in oklab,var(--color-black)30%,transparent)}}.bg-black\/40{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.bg-black\/40{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black)60%,transparent)}}.bg-black\/70{background-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.bg-black\/70{background-color:color-mix(in oklab,var(--color-black)70%,transparent)}}.bg-black\/80{background-color:#000c}@supports (color:color-mix(in lab,red,red)){.bg-black\/80{background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.bg-black\/90{background-color:#000000e6}@supports (color:color-mix(in lab,red,red)){.bg-black\/90{background-color:color-mix(in oklab,var(--color-black)90%,transparent)}}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-blue-400{background-color:var(--color-blue-400)}.bg-blue-400\/10{background-color:#54a2ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-400\/10{background-color:color-mix(in oklab,var(--color-blue-400)10%,transparent)}}.bg-blue-500{background-color:var(--color-blue-500)}.bg-blue-500\/5{background-color:#3080ff0d}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/5{background-color:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.bg-blue-500\/10{background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/10{background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.bg-blue-500\/20{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/20{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.bg-blue-500\/30{background-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/30{background-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.bg-blue-500\/90{background-color:#3080ffe6}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/90{background-color:color-mix(in oklab,var(--color-blue-500)90%,transparent)}}.bg-blue-600{background-color:var(--color-blue-600)}.bg-blue-600\/20{background-color:#155dfc33}@supports (color:color-mix(in lab,red,red)){.bg-blue-600\/20{background-color:color-mix(in oklab,var(--color-blue-600)20%,transparent)}}.bg-cyan-500{background-color:var(--color-cyan-500)}.bg-cyan-500\/10{background-color:#00b7d71a}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/10{background-color:color-mix(in oklab,var(--color-cyan-500)10%,transparent)}}.bg-cyan-500\/20{background-color:#00b7d733}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/20{background-color:color-mix(in oklab,var(--color-cyan-500)20%,transparent)}}.bg-cyan-600\/20{background-color:#0092b533}@supports (color:color-mix(in lab,red,red)){.bg-cyan-600\/20{background-color:color-mix(in oklab,var(--color-cyan-600)20%,transparent)}}.bg-emerald-500\/20{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/20{background-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.bg-emerald-700{background-color:var(--color-emerald-700)}.bg-fuchsia-500{background-color:var(--color-fuchsia-500)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-100{background-color:var(--color-gray-100)}.bg-gray-400{background-color:var(--color-gray-400)}.bg-gray-400\/10{background-color:#99a1af1a}@supports (color:color-mix(in lab,red,red)){.bg-gray-400\/10{background-color:color-mix(in oklab,var(--color-gray-400)10%,transparent)}}.bg-gray-500{background-color:var(--color-gray-500)}.bg-gray-500\/20{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.bg-gray-500\/20{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.bg-gray-600{background-color:var(--color-gray-600)}.bg-gray-800{background-color:var(--color-gray-800)}.bg-gray-900{background-color:var(--color-gray-900)}.bg-green-100{background-color:var(--color-green-100)}.bg-green-400{background-color:var(--color-green-400)}.bg-green-500{background-color:var(--color-green-500)}.bg-green-500\/10{background-color:#00c7581a}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/10{background-color:color-mix(in oklab,var(--color-green-500)10%,transparent)}}.bg-green-500\/15{background-color:#00c75826}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/15{background-color:color-mix(in oklab,var(--color-green-500)15%,transparent)}}.bg-green-500\/20{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/20{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.bg-green-600{background-color:var(--color-green-600)}.bg-green-600\/20{background-color:#00a54433}@supports (color:color-mix(in lab,red,red)){.bg-green-600\/20{background-color:color-mix(in oklab,var(--color-green-600)20%,transparent)}}.bg-green-900\/50{background-color:#0d542b80}@supports (color:color-mix(in lab,red,red)){.bg-green-900\/50{background-color:color-mix(in oklab,var(--color-green-900)50%,transparent)}}.bg-indigo-500\/20{background-color:#625fff33}@supports (color:color-mix(in lab,red,red)){.bg-indigo-500\/20{background-color:color-mix(in oklab,var(--color-indigo-500)20%,transparent)}}.bg-lime-500{background-color:var(--color-lime-500)}.bg-orange-400\/10{background-color:#ff8b1a1a}@supports (color:color-mix(in lab,red,red)){.bg-orange-400\/10{background-color:color-mix(in oklab,var(--color-orange-400)10%,transparent)}}.bg-orange-500{background-color:var(--color-orange-500)}.bg-orange-500\/10{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/10{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.bg-orange-500\/20{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/20{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.bg-orange-600{background-color:var(--color-orange-600)}.bg-orange-600\/20{background-color:#f0510033}@supports (color:color-mix(in lab,red,red)){.bg-orange-600\/20{background-color:color-mix(in oklab,var(--color-orange-600)20%,transparent)}}.bg-purple-400\/10{background-color:#c07eff1a}@supports (color:color-mix(in lab,red,red)){.bg-purple-400\/10{background-color:color-mix(in oklab,var(--color-purple-400)10%,transparent)}}.bg-purple-500{background-color:var(--color-purple-500)}.bg-purple-500\/10{background-color:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/10{background-color:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.bg-purple-500\/20{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/20{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.bg-purple-500\/80{background-color:#ac4bffcc}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/80{background-color:color-mix(in oklab,var(--color-purple-500)80%,transparent)}}.bg-purple-500\/90{background-color:#ac4bffe6}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/90{background-color:color-mix(in oklab,var(--color-purple-500)90%,transparent)}}.bg-purple-700{background-color:var(--color-purple-700)}.bg-red-50{background-color:var(--color-red-50)}.bg-red-100{background-color:var(--color-red-100)}.bg-red-400{background-color:var(--color-red-400)}.bg-red-500{background-color:var(--color-red-500)}.bg-red-500\/5{background-color:#fb2c360d}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/5{background-color:color-mix(in oklab,var(--color-red-500)5%,transparent)}}.bg-red-500\/10{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/10{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.bg-red-500\/15{background-color:#fb2c3626}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/15{background-color:color-mix(in oklab,var(--color-red-500)15%,transparent)}}.bg-red-500\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.bg-red-500\/30{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/30{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.bg-red-500\/40{background-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/40{background-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.bg-red-500\/80{background-color:#fb2c36cc}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/80{background-color:color-mix(in oklab,var(--color-red-500)80%,transparent)}}.bg-red-600{background-color:var(--color-red-600)}.bg-red-950\/70{background-color:#460809b3}@supports (color:color-mix(in lab,red,red)){.bg-red-950\/70{background-color:color-mix(in oklab,var(--color-red-950)70%,transparent)}}.bg-rose-500\/20{background-color:#ff235733}@supports (color:color-mix(in lab,red,red)){.bg-rose-500\/20{background-color:color-mix(in oklab,var(--color-rose-500)20%,transparent)}}.bg-rose-600\/20{background-color:#e7004433}@supports (color:color-mix(in lab,red,red)){.bg-rose-600\/20{background-color:color-mix(in oklab,var(--color-rose-600)20%,transparent)}}.bg-sky-500{background-color:var(--color-sky-500)}.bg-sky-500\/20{background-color:#00a5ef33}@supports (color:color-mix(in lab,red,red)){.bg-sky-500\/20{background-color:color-mix(in oklab,var(--color-sky-500)20%,transparent)}}.bg-status-error,.bg-status-error\/10{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/10{background-color:color-mix(in oklab,var(--color-status-error)10%,transparent)}}.bg-status-error\/20{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/20{background-color:color-mix(in oklab,var(--color-status-error)20%,transparent)}}.bg-status-error\/80{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/80{background-color:color-mix(in oklab,var(--color-status-error)80%,transparent)}}.bg-status-ok,.bg-status-ok\/10{background-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.bg-status-ok\/10{background-color:color-mix(in oklab,var(--color-status-ok)10%,transparent)}}.bg-status-ok\/20{background-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.bg-status-ok\/20{background-color:color-mix(in oklab,var(--color-status-ok)20%,transparent)}}.bg-status-warning\/10{background-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.bg-status-warning\/10{background-color:color-mix(in oklab,var(--color-status-warning)10%,transparent)}}.bg-status-warning\/20{background-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.bg-status-warning\/20{background-color:color-mix(in oklab,var(--color-status-warning)20%,transparent)}}.bg-teal-500{background-color:var(--color-teal-500)}.bg-teal-500\/20{background-color:#00baa733}@supports (color:color-mix(in lab,red,red)){.bg-teal-500\/20{background-color:color-mix(in oklab,var(--color-teal-500)20%,transparent)}}.bg-transparent{background-color:#0000}.bg-violet-500{background-color:var(--color-violet-500)}.bg-white{background-color:var(--color-white)}.bg-white\/10{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.bg-white\/10{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.bg-white\/20{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.bg-white\/20{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.bg-white\/50{background-color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.bg-white\/50{background-color:color-mix(in oklab,var(--color-white)50%,transparent)}}.bg-white\/70{background-color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.bg-white\/70{background-color:color-mix(in oklab,var(--color-white)70%,transparent)}}.bg-white\/90{background-color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.bg-white\/90{background-color:color-mix(in oklab,var(--color-white)90%,transparent)}}.bg-yellow-400{background-color:var(--color-yellow-400)}.bg-yellow-400\/10{background-color:#fac8001a}@supports (color:color-mix(in lab,red,red)){.bg-yellow-400\/10{background-color:color-mix(in oklab,var(--color-yellow-400)10%,transparent)}}.bg-yellow-400\/20{background-color:#fac80033}@supports (color:color-mix(in lab,red,red)){.bg-yellow-400\/20{background-color:color-mix(in oklab,var(--color-yellow-400)20%,transparent)}}.bg-yellow-500{background-color:var(--color-yellow-500)}.bg-yellow-500\/5{background-color:#edb2000d}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/5{background-color:color-mix(in oklab,var(--color-yellow-500)5%,transparent)}}.bg-yellow-500\/10{background-color:#edb2001a}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/10{background-color:color-mix(in oklab,var(--color-yellow-500)10%,transparent)}}.bg-yellow-500\/20{background-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/20{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.bg-zinc-600{background-color:var(--color-zinc-600)}.bg-zinc-700{background-color:var(--color-zinc-700)}.bg-zinc-800{background-color:var(--color-zinc-800)}.bg-zinc-900{background-color:var(--color-zinc-900)}.bg-gradient-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-r{--tw-gradient-position:to right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-t{--tw-gradient-position:to top in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-bambu-dark-secondary{--tw-gradient-from:var(--color-bambu-dark-secondary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-bambu-green\/10{--tw-gradient-from:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.from-bambu-green\/10{--tw-gradient-from:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.from-bambu-green\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-black\/80{--tw-gradient-from:#000c}@supports (color:color-mix(in lab,red,red)){.from-black\/80{--tw-gradient-from:color-mix(in oklab,var(--color-black)80%,transparent)}}.from-black\/80{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/5{--tw-gradient-from:#3080ff0d}@supports (color:color-mix(in lab,red,red)){.from-blue-500\/5{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.from-blue-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/10{--tw-gradient-from:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.from-blue-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.from-blue-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-gray-500\/10{--tw-gradient-from:#6a72821a}@supports (color:color-mix(in lab,red,red)){.from-gray-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-gray-500)10%,transparent)}}.from-gray-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-purple-500\/10{--tw-gradient-from:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.from-purple-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.from-purple-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-white\/10{--tw-gradient-from:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.from-white\/10{--tw-gradient-from:color-mix(in oklab,var(--color-white)10%,transparent)}}.from-white\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-yellow-500\/10{--tw-gradient-from:#edb2001a}@supports (color:color-mix(in lab,red,red)){.from-yellow-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-yellow-500)10%,transparent)}}.from-yellow-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.via-black\/60{--tw-gradient-via:#0009}@supports (color:color-mix(in lab,red,red)){.via-black\/60{--tw-gradient-via:color-mix(in oklab,var(--color-black)60%,transparent)}}.via-black\/60{--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-via)var(--tw-gradient-via-position),var(--tw-gradient-to)var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-bambu-dark-secondary{--tw-gradient-to:var(--color-bambu-dark-secondary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-bambu-dark-tertiary{--tw-gradient-to:var(--color-bambu-dark-tertiary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-transparent{--tw-gradient-to:transparent;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.bg-cover{background-size:cover}.bg-center{background-position:50%}.fill-yellow-400{fill:var(--color-yellow-400)}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.object-left{object-position:left}.p-0{padding:calc(var(--spacing)*0)}.p-0\.5{padding:calc(var(--spacing)*.5)}.p-1{padding:calc(var(--spacing)*1)}.p-1\.5{padding:calc(var(--spacing)*1.5)}.p-2{padding:calc(var(--spacing)*2)}.p-2\.5{padding:calc(var(--spacing)*2.5)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.p-8{padding:calc(var(--spacing)*8)}.p-12{padding:calc(var(--spacing)*12)}.\!px-1\.5{padding-inline:calc(var(--spacing)*1.5)!important}.\!px-3{padding-inline:calc(var(--spacing)*3)!important}.px-1{padding-inline:calc(var(--spacing)*1)}.px-1\.5{padding-inline:calc(var(--spacing)*1.5)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-2\.5{padding-inline:calc(var(--spacing)*2.5)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-5{padding-inline:calc(var(--spacing)*5)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-0\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-6{padding-block:calc(var(--spacing)*6)}.py-8{padding-block:calc(var(--spacing)*8)}.py-12{padding-block:calc(var(--spacing)*12)}.py-16{padding-block:calc(var(--spacing)*16)}.py-20{padding-block:calc(var(--spacing)*20)}.py-24{padding-block:calc(var(--spacing)*24)}.pt-0{padding-top:calc(var(--spacing)*0)}.pt-1{padding-top:calc(var(--spacing)*1)}.pt-2{padding-top:calc(var(--spacing)*2)}.pt-3{padding-top:calc(var(--spacing)*3)}.pt-4{padding-top:calc(var(--spacing)*4)}.pr-1{padding-right:calc(var(--spacing)*1)}.pr-2{padding-right:calc(var(--spacing)*2)}.pr-3{padding-right:calc(var(--spacing)*3)}.pr-4{padding-right:calc(var(--spacing)*4)}.pr-6{padding-right:calc(var(--spacing)*6)}.pr-7{padding-right:calc(var(--spacing)*7)}.pr-8{padding-right:calc(var(--spacing)*8)}.pr-10{padding-right:calc(var(--spacing)*10)}.pb-1{padding-bottom:calc(var(--spacing)*1)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pl-2{padding-left:calc(var(--spacing)*2)}.pl-4{padding-left:calc(var(--spacing)*4)}.pl-6{padding-left:calc(var(--spacing)*6)}.pl-7{padding-left:calc(var(--spacing)*7)}.pl-8{padding-left:calc(var(--spacing)*8)}.pl-9{padding-left:calc(var(--spacing)*9)}.pl-10{padding-left:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.text-5xl{font-size:var(--text-5xl);line-height:var(--tw-leading,var(--text-5xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[7px\]{font-size:7px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-none{--tw-leading:1;line-height:1}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-light{--tw-font-weight:var(--font-weight-light);font-weight:var(--font-weight-light)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.\!text-green-400{color:var(--color-green-400)!important}.text-amber-200{color:var(--color-amber-200)}.text-amber-300{color:var(--color-amber-300)}.text-amber-300\/60{color:#ffd23699}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/60{color:color-mix(in oklab,var(--color-amber-300)60%,transparent)}}.text-amber-300\/70{color:#ffd236b3}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/70{color:color-mix(in oklab,var(--color-amber-300)70%,transparent)}}.text-amber-300\/80{color:#ffd236cc}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/80{color:color-mix(in oklab,var(--color-amber-300)80%,transparent)}}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/70{color:#fcbb00b3}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/70{color:color-mix(in oklab,var(--color-amber-400)70%,transparent)}}.text-amber-500{color:var(--color-amber-500)}.text-amber-500\/80{color:#f99c00cc}@supports (color:color-mix(in lab,red,red)){.text-amber-500\/80{color:color-mix(in oklab,var(--color-amber-500)80%,transparent)}}.text-amber-600{color:var(--color-amber-600)}.text-bambu-dark-tertiary{color:var(--color-bambu-dark-tertiary)}.text-bambu-gray{color:var(--color-bambu-gray)}.text-bambu-gray-dark{color:var(--color-bambu-gray-dark)}.text-bambu-gray-light{color:var(--color-bambu-gray-light)}.text-bambu-gray\/30{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/30{color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.text-bambu-gray\/40{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/40{color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.text-bambu-gray\/50{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/50{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.text-bambu-gray\/60{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/60{color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.text-bambu-gray\/70{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/70{color:color-mix(in oklab,var(--color-bambu-gray)70%,transparent)}}.text-bambu-gray\/80{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/80{color:color-mix(in oklab,var(--color-bambu-gray)80%,transparent)}}.text-bambu-green,.text-bambu-green\/70{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.text-bambu-green\/70{color:color-mix(in oklab,var(--color-bambu-green)70%,transparent)}}.text-black{color:var(--color-black)}.text-black\/80{color:#000c}@supports (color:color-mix(in lab,red,red)){.text-black\/80{color:color-mix(in oklab,var(--color-black)80%,transparent)}}.text-blue-300{color:var(--color-blue-300)}.text-blue-300\/70{color:#90c5ffb3}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/70{color:color-mix(in oklab,var(--color-blue-300)70%,transparent)}}.text-blue-300\/80{color:#90c5ffcc}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/80{color:color-mix(in oklab,var(--color-blue-300)80%,transparent)}}.text-blue-400{color:var(--color-blue-400)}.text-blue-500{color:var(--color-blue-500)}.text-blue-500\/70{color:#3080ffb3}@supports (color:color-mix(in lab,red,red)){.text-blue-500\/70{color:color-mix(in oklab,var(--color-blue-500)70%,transparent)}}.text-blue-600{color:var(--color-blue-600)}.text-blue-700{color:var(--color-blue-700)}.text-cyan-300{color:var(--color-cyan-300)}.text-cyan-400{color:var(--color-cyan-400)}.text-emerald-400{color:var(--color-emerald-400)}.text-gray-300{color:var(--color-gray-300)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-gray-800{color:var(--color-gray-800)}.text-gray-900{color:var(--color-gray-900)}.text-green-200{color:var(--color-green-200)}.text-green-300{color:var(--color-green-300)}.text-green-400{color:var(--color-green-400)}.text-green-500{color:var(--color-green-500)}.text-green-500\/60{color:#00c75899}@supports (color:color-mix(in lab,red,red)){.text-green-500\/60{color:color-mix(in oklab,var(--color-green-500)60%,transparent)}}.text-green-600{color:var(--color-green-600)}.text-indigo-400{color:var(--color-indigo-400)}.text-orange-200{color:var(--color-orange-200)}.text-orange-300{color:var(--color-orange-300)}.text-orange-400{color:var(--color-orange-400)}.text-orange-500{color:var(--color-orange-500)}.text-orange-600{color:var(--color-orange-600)}.text-orange-700{color:var(--color-orange-700)}.text-purple-300{color:var(--color-purple-300)}.text-purple-300\/70{color:#d9b3ffb3}@supports (color:color-mix(in lab,red,red)){.text-purple-300\/70{color:color-mix(in oklab,var(--color-purple-300)70%,transparent)}}.text-purple-400{color:var(--color-purple-400)}.text-purple-400\/80{color:#c07effcc}@supports (color:color-mix(in lab,red,red)){.text-purple-400\/80{color:color-mix(in oklab,var(--color-purple-400)80%,transparent)}}.text-purple-500{color:var(--color-purple-500)}.text-red-200{color:var(--color-red-200)}.text-red-300{color:var(--color-red-300)}.text-red-300\/80{color:#ffa3a3cc}@supports (color:color-mix(in lab,red,red)){.text-red-300\/80{color:color-mix(in oklab,var(--color-red-300)80%,transparent)}}.text-red-400{color:var(--color-red-400)}.text-red-400\/50{color:#ff656880}@supports (color:color-mix(in lab,red,red)){.text-red-400\/50{color:color-mix(in oklab,var(--color-red-400)50%,transparent)}}.text-red-400\/60{color:#ff656899}@supports (color:color-mix(in lab,red,red)){.text-red-400\/60{color:color-mix(in oklab,var(--color-red-400)60%,transparent)}}.text-red-400\/70{color:#ff6568b3}@supports (color:color-mix(in lab,red,red)){.text-red-400\/70{color:color-mix(in oklab,var(--color-red-400)70%,transparent)}}.text-red-500{color:var(--color-red-500)}.text-red-600{color:var(--color-red-600)}.text-rose-300{color:var(--color-rose-300)}.text-rose-400{color:var(--color-rose-400)}.text-sky-400{color:var(--color-sky-400)}.text-slate-300{color:var(--color-slate-300)}.text-status-error{color:var(--color-status-error)}.text-status-ok{color:var(--color-status-ok)}.text-status-warning{color:var(--color-status-warning)}.text-teal-400{color:var(--color-teal-400)}.text-white{color:var(--color-white)}.text-white\/30{color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.text-white\/30{color:color-mix(in oklab,var(--color-white)30%,transparent)}}.text-white\/40{color:#fff6}@supports (color:color-mix(in lab,red,red)){.text-white\/40{color:color-mix(in oklab,var(--color-white)40%,transparent)}}.text-white\/50{color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.text-white\/50{color:color-mix(in oklab,var(--color-white)50%,transparent)}}.text-white\/60{color:#fff9}@supports (color:color-mix(in lab,red,red)){.text-white\/60{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.text-white\/70{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.text-white\/80{color:#fffc}@supports (color:color-mix(in lab,red,red)){.text-white\/80{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.text-white\/90{color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.text-white\/90{color:color-mix(in oklab,var(--color-white)90%,transparent)}}.text-yellow-200{color:var(--color-yellow-200)}.text-yellow-200\/70{color:#fff085b3}@supports (color:color-mix(in lab,red,red)){.text-yellow-200\/70{color:color-mix(in oklab,var(--color-yellow-200)70%,transparent)}}.text-yellow-300{color:var(--color-yellow-300)}.text-yellow-400{color:var(--color-yellow-400)}.text-yellow-500{color:var(--color-yellow-500)}.text-yellow-500\/70{color:#edb200b3}@supports (color:color-mix(in lab,red,red)){.text-yellow-500\/70{color:color-mix(in oklab,var(--color-yellow-500)70%,transparent)}}.text-yellow-600{color:var(--color-yellow-600)}.text-yellow-700{color:var(--color-yellow-700)}.text-zinc-100{color:var(--color-zinc-100)}.text-zinc-200{color:var(--color-zinc-200)}.text-zinc-300{color:var(--color-zinc-300)}.text-zinc-400{color:var(--color-zinc-400)}.text-zinc-500{color:var(--color-zinc-500)}.text-zinc-600{color:var(--color-zinc-600)}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.line-through{text-decoration-line:line-through}.underline{text-decoration-line:underline}.placeholder-bambu-gray::placeholder{color:var(--color-bambu-gray)}.placeholder-bambu-gray-dark::placeholder{color:var(--color-bambu-gray-dark)}.placeholder-bambu-gray\/40::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder-bambu-gray\/40::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.placeholder-bambu-gray\/50::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder-bambu-gray\/50::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.placeholder-zinc-500::placeholder{color:var(--color-zinc-500)}.accent-bambu-green{accent-color:var(--color-bambu-green)}.accent-green-500{accent-color:var(--color-green-500)}.opacity-0{opacity:0}.opacity-20{opacity:.2}.opacity-25{opacity:.25}.opacity-30{opacity:.3}.opacity-40{opacity:.4}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-80{opacity:.8}.opacity-100{opacity:1}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_6px_rgba\(34\,197\,94\,0\.5\)\]{--tw-shadow:0 0 6px var(--tw-shadow-color,#22c55e80);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow\/depth{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring,.ring-1{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-bambu-green\/20{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.shadow-bambu-green\/20{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)20%,transparent)var(--tw-shadow-alpha),transparent)}}.shadow-bambu-green\/25{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.shadow-bambu-green\/25{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)25%,transparent)var(--tw-shadow-alpha),transparent)}}.ring-bambu-green,.ring-bambu-green\/30{--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.ring-bambu-green\/30{--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.ring-blue-400\/50{--tw-ring-color:#54a2ff80}@supports (color:color-mix(in lab,red,red)){.ring-blue-400\/50{--tw-ring-color:color-mix(in oklab,var(--color-blue-400)50%,transparent)}}.ring-green-500{--tw-ring-color:var(--color-green-500)}.ring-white{--tw-ring-color:var(--color-white)}.ring-offset-1{--tw-ring-offset-width:1px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-2{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-bambu-dark{--tw-ring-offset-color:var(--color-bambu-dark)}.ring-offset-bambu-dark-secondary{--tw-ring-offset-color:var(--color-bambu-dark-secondary)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.blur-2xl{--tw-blur:blur(var(--blur-2xl));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow-lg{--tw-drop-shadow-size:drop-shadow(0 4px 4px var(--tw-drop-shadow-color,#00000026));--tw-drop-shadow:drop-shadow(var(--drop-shadow-lg));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow-md{--tw-drop-shadow-size:drop-shadow(0 3px 3px var(--tw-drop-shadow-color,#0000001f));--tw-drop-shadow:drop-shadow(var(--drop-shadow-md));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-500{--tw-duration:.5s;transition-duration:.5s}.duration-1000{--tw-duration:1s;transition-duration:1s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.select-none{-webkit-user-select:none;user-select:none}@media(hover:hover){.group-hover\:bg-bambu-green\/20:is(:where(.group):hover *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.group-hover\:bg-bambu-green\/20:is(:where(.group):hover *){background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.group-hover\:text-bambu-gray:is(:where(.group):hover *){color:var(--color-bambu-gray)}.group-hover\:text-bambu-green:is(:where(.group):hover *){color:var(--color-bambu-green)}.group-hover\:opacity-50:is(:where(.group):hover *){opacity:.5}.group-hover\:opacity-100:is(:where(.group):hover *),.group-hover\/resize\:opacity-100:is(:where(.group\/resize):hover *){opacity:1}.group-hover\/thumb\:block:is(:where(.group\/thumb):hover *){display:block}}.peer-checked\:bg-bambu-green:is(:where(.peer):checked~*){background-color:var(--color-bambu-green)}.peer-focus\:outline-none:is(:where(.peer):focus~*){--tw-outline-style:none;outline-style:none}.placeholder\:text-bambu-gray::placeholder,.placeholder\:text-bambu-gray\/50::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-bambu-gray\/50::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:top-0:before{content:var(--tw-content);top:calc(var(--spacing)*0)}.before\:right-0:before{content:var(--tw-content);right:calc(var(--spacing)*0)}.before\:left-0:before{content:var(--tw-content);left:calc(var(--spacing)*0)}.before\:h-0\.5:before{content:var(--tw-content);height:calc(var(--spacing)*.5)}.before\:bg-bambu-green:before{content:var(--tw-content);background-color:var(--color-bambu-green)}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:top-\[2px\]:after{content:var(--tw-content);top:2px}.after\:left-\[2px\]:after{content:var(--tw-content);left:2px}.after\:h-4:after{content:var(--tw-content);height:calc(var(--spacing)*4)}.after\:h-5:after{content:var(--tw-content);height:calc(var(--spacing)*5)}.after\:w-4:after{content:var(--tw-content);width:calc(var(--spacing)*4)}.after\:w-5:after{content:var(--tw-content);width:calc(var(--spacing)*5)}.after\:rounded-full:after{content:var(--tw-content);border-radius:3.40282e38px}.after\:border:after{content:var(--tw-content);border-style:var(--tw-border-style);border-width:1px}.after\:border-gray-300:after{content:var(--tw-content);border-color:var(--color-gray-300)}.after\:bg-white:after{content:var(--tw-content);background-color:var(--color-white)}.after\:transition-all:after{content:var(--tw-content);transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.after\:content-\[\'\'\]:after{--tw-content:"";content:var(--tw-content)}.peer-checked\:after\:translate-x-full:is(:where(.peer):checked~*):after{content:var(--tw-content);--tw-translate-x:100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.peer-checked\:after\:border-white:is(:where(.peer):checked~*):after{content:var(--tw-content);border-color:var(--color-white)}.last\:border-0:last-child{border-style:var(--tw-border-style);border-width:0}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media(hover:hover){.hover\:z-20:hover{z-index:20}.hover\:scale-105:hover{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\:border-bambu-dark-tertiary\/80:hover{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-dark-tertiary\/80:hover{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.hover\:border-bambu-gray:hover{border-color:var(--color-bambu-gray)}.hover\:border-bambu-gray-dark:hover{border-color:var(--color-bambu-gray-dark)}.hover\:border-bambu-gray\/50:hover{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-gray\/50:hover{border-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.hover\:border-bambu-green:hover,.hover\:border-bambu-green\/50:hover{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-green\/50:hover{border-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.hover\:border-green-500\/50:hover{border-color:#00c75880}@supports (color:color-mix(in lab,red,red)){.hover\:border-green-500\/50:hover{border-color:color-mix(in oklab,var(--color-green-500)50%,transparent)}}.hover\:border-white:hover{border-color:var(--color-white)}.hover\:border-white\/40:hover{border-color:#fff6}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/40:hover{border-color:color-mix(in oklab,var(--color-white)40%,transparent)}}.hover\:\!bg-green-500\/20:hover{background-color:#00c75833!important}@supports (color:color-mix(in lab,red,red)){.hover\:\!bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)!important}}.hover\:bg-amber-500\/30:hover{background-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/30:hover{background-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.hover\:bg-bambu-dark:hover{background-color:var(--color-bambu-dark)}.hover\:bg-bambu-dark-secondary:hover,.hover\:bg-bambu-dark-secondary\/50:hover{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-secondary\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)50%,transparent)}}.hover\:bg-bambu-dark-tertiary:hover,.hover\:bg-bambu-dark-tertiary\/30:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.hover\:bg-bambu-dark-tertiary\/50:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.hover\:bg-bambu-dark-tertiary\/70:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/70:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)70%,transparent)}}.hover\:bg-bambu-dark-tertiary\/80:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.hover\:bg-bambu-dark\/50:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.hover\:bg-bambu-dark\/80:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)80%,transparent)}}.hover\:bg-bambu-gray-dark:hover{background-color:var(--color-bambu-gray-dark)}.hover\:bg-bambu-green:hover{background-color:var(--color-bambu-green)}.hover\:bg-bambu-green-dark:hover{background-color:var(--color-bambu-green-dark)}.hover\:bg-bambu-green-light:hover{background-color:var(--color-bambu-green-light)}.hover\:bg-bambu-green\/10:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/10:hover{background-color:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.hover\:bg-bambu-green\/20:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/20:hover{background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.hover\:bg-bambu-green\/30:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.hover\:bg-bambu-green\/50:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.hover\:bg-bambu-green\/80:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)}}.hover\:bg-black\/40:hover{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/40:hover{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.hover\:bg-black\/70:hover{background-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/70:hover{background-color:color-mix(in oklab,var(--color-black)70%,transparent)}}.hover\:bg-black\/80:hover{background-color:#000c}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/80:hover{background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.hover\:bg-blue-500\/30:hover{background-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-500\/30:hover{background-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.hover\:bg-gray-50:hover{background-color:var(--color-gray-50)}.hover\:bg-gray-100:hover{background-color:var(--color-gray-100)}.hover\:bg-gray-700:hover{background-color:var(--color-gray-700)}.hover\:bg-green-500\/20:hover{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.hover\:bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.hover\:bg-green-700:hover{background-color:var(--color-green-700)}.hover\:bg-orange-400\/20:hover{background-color:#ff8b1a33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-orange-400\/20:hover{background-color:color-mix(in oklab,var(--color-orange-400)20%,transparent)}}.hover\:bg-red-200:hover{background-color:var(--color-red-200)}.hover\:bg-red-400\/10:hover{background-color:#ff65681a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-400\/10:hover{background-color:color-mix(in oklab,var(--color-red-400)10%,transparent)}}.hover\:bg-red-500\/10:hover{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/10:hover{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.hover\:bg-red-500\/30:hover{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/30:hover{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.hover\:bg-red-600:hover{background-color:var(--color-red-600)}.hover\:bg-red-700:hover{background-color:var(--color-red-700)}.hover\:bg-white\/5:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/5:hover{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.hover\:bg-white\/10:hover{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/10:hover{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.hover\:bg-white\/80:hover{background-color:#fffc}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/80:hover{background-color:color-mix(in oklab,var(--color-white)80%,transparent)}}.hover\:bg-yellow-500\/30:hover{background-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-yellow-500\/30:hover{background-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.hover\:bg-yellow-600:hover{background-color:var(--color-yellow-600)}.hover\:bg-zinc-600:hover{background-color:var(--color-zinc-600)}.hover\:bg-zinc-700:hover{background-color:var(--color-zinc-700)}.hover\:bg-zinc-700\/50:hover{background-color:#3f3f4680}@supports (color:color-mix(in lab,red,red)){.hover\:bg-zinc-700\/50:hover{background-color:color-mix(in oklab,var(--color-zinc-700)50%,transparent)}}.hover\:text-amber-300:hover{color:var(--color-amber-300)}.hover\:text-bambu-gray:hover{color:var(--color-bambu-gray)}.hover\:text-bambu-green:hover{color:var(--color-bambu-green)}.hover\:text-bambu-green-light:hover{color:var(--color-bambu-green-light)}.hover\:text-bambu-green\/70:hover{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:text-bambu-green\/70:hover{color:color-mix(in oklab,var(--color-bambu-green)70%,transparent)}}.hover\:text-bambu-green\/80:hover{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:text-bambu-green\/80:hover{color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)}}.hover\:text-blue-300:hover{color:var(--color-blue-300)}.hover\:text-gray-900:hover{color:var(--color-gray-900)}.hover\:text-orange-300:hover{color:var(--color-orange-300)}.hover\:text-red-200:hover{color:var(--color-red-200)}.hover\:text-red-300:hover{color:var(--color-red-300)}.hover\:text-red-400:hover{color:var(--color-red-400)}.hover\:text-white:hover{color:var(--color-white)}.hover\:text-white\/70:hover{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/70:hover{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.hover\:text-white\/80:hover{color:#fffc}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/80:hover{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.hover\:text-yellow-400:hover{color:var(--color-yellow-400)}.hover\:text-zinc-300:hover{color:var(--color-zinc-300)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-70:hover{opacity:.7}.hover\:opacity-80:hover{opacity:.8}.hover\:shadow-lg:hover{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:shadow-bambu-green\/5:hover{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:shadow-bambu-green\/5:hover{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)5%,transparent)var(--tw-shadow-alpha),transparent)}}.hover\:shadow-bambu-green\/30:hover{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:shadow-bambu-green\/30:hover{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)30%,transparent)var(--tw-shadow-alpha),transparent)}}}.focus\:border-bambu-green:focus{border-color:var(--color-bambu-green)}.focus\:border-green-500:focus{border-color:var(--color-green-500)}.focus\:border-red-500:focus{border-color:var(--color-red-500)}.focus\:ring-1:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-bambu-gray:focus{--tw-ring-color:var(--color-bambu-gray)}.focus\:ring-bambu-green:focus,.focus\:ring-bambu-green\/50:focus{--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.focus\:ring-bambu-green\/50:focus{--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.focus\:ring-red-500:focus{--tw-ring-color:var(--color-red-500)}.focus\:ring-offset-0:focus{--tw-ring-offset-width:0px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:ring-offset-bambu-dark:focus{--tw-ring-offset-color:var(--color-bambu-dark)}.focus\:ring-offset-bambu-dark-secondary:focus{--tw-ring-offset-color:var(--color-bambu-dark-secondary)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.active\:cursor-grabbing:active{cursor:grabbing}.active\:bg-zinc-700:active{background-color:var(--color-zinc-700)}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}@media(hover:hover){.disabled\:hover\:bg-bambu-green:disabled:hover{background-color:var(--color-bambu-green)}}@media not all and (min-width:640px){.max-\[640px\]\:hidden{display:none}.max-\[640px\]\:w-full{width:100%}.max-\[640px\]\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.max-\[640px\]\:flex-col{flex-direction:column}.max-\[640px\]\:flex-wrap{flex-wrap:wrap}.max-\[640px\]\:items-center{align-items:center}.max-\[640px\]\:items-start{align-items:flex-start}}@media not all and (min-width:550px){.max-\[550px\]\:order-1{order:1}.max-\[550px\]\:order-2{order:2}.max-\[550px\]\:order-3{order:3}.max-\[550px\]\:order-4{order:4}.max-\[550px\]\:mt-1{margin-top:calc(var(--spacing)*1)}.max-\[550px\]\:w-full{width:100%}.max-\[550px\]\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.max-\[550px\]\:flex-col{flex-direction:column}.max-\[550px\]\:flex-wrap{flex-wrap:wrap}.max-\[550px\]\:items-center{align-items:center}.max-\[550px\]\:items-start{align-items:flex-start}.max-\[550px\]\:justify-end{justify-content:flex-end}.max-\[550px\]\:gap-1\.5{gap:calc(var(--spacing)*1.5)}.max-\[550px\]\:gap-2{gap:calc(var(--spacing)*2)}.max-\[550px\]\:gap-3{gap:calc(var(--spacing)*3)}.max-\[550px\]\:self-start{align-self:flex-start}}@media(min-width:40rem){.sm\:col-span-1{grid-column:span 1/span 1}.sm\:mt-0{margin-top:calc(var(--spacing)*0)}.sm\:mt-2{margin-top:calc(var(--spacing)*2)}.sm\:mt-3{margin-top:calc(var(--spacing)*3)}.sm\:mr-1{margin-right:calc(var(--spacing)*1)}.sm\:mb-4{margin-bottom:calc(var(--spacing)*4)}.sm\:ml-auto{margin-left:auto}.sm\:block{display:block}.sm\:flex{display:flex}.sm\:grid{display:grid}.sm\:hidden{display:none}.sm\:inline{display:inline}.sm\:h-2{height:calc(var(--spacing)*2)}.sm\:h-3{height:calc(var(--spacing)*3)}.sm\:h-3\.5{height:calc(var(--spacing)*3.5)}.sm\:h-4{height:calc(var(--spacing)*4)}.sm\:h-5{height:calc(var(--spacing)*5)}.sm\:h-6{height:calc(var(--spacing)*6)}.sm\:h-10{height:calc(var(--spacing)*10)}.sm\:h-14{height:calc(var(--spacing)*14)}.sm\:w-3{width:calc(var(--spacing)*3)}.sm\:w-3\.5{width:calc(var(--spacing)*3.5)}.sm\:w-4{width:calc(var(--spacing)*4)}.sm\:w-5{width:calc(var(--spacing)*5)}.sm\:w-6{width:calc(var(--spacing)*6)}.sm\:w-10{width:calc(var(--spacing)*10)}.sm\:w-14{width:calc(var(--spacing)*14)}.sm\:w-16{width:calc(var(--spacing)*16)}.sm\:w-40{width:calc(var(--spacing)*40)}.sm\:w-auto{width:auto}.sm\:max-w-none{max-width:none}.sm\:max-w-xs{max-width:var(--container-xs)}.sm\:flex-1{flex:1}.sm\:flex-none{flex:none}.sm\:cursor-default{cursor:default}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:gap-1{gap:calc(var(--spacing)*1)}.sm\:gap-1\.5{gap:calc(var(--spacing)*1.5)}.sm\:gap-2{gap:calc(var(--spacing)*2)}.sm\:gap-3{gap:calc(var(--spacing)*3)}.sm\:gap-4{gap:calc(var(--spacing)*4)}.sm\:gap-6{gap:calc(var(--spacing)*6)}:where(.sm\:space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.sm\:space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}.sm\:border-bambu-dark-tertiary{border-color:var(--color-bambu-dark-tertiary)}.sm\:p-1\.5{padding:calc(var(--spacing)*1.5)}.sm\:p-2{padding:calc(var(--spacing)*2)}.sm\:p-3{padding:calc(var(--spacing)*3)}.sm\:p-4{padding:calc(var(--spacing)*4)}.sm\:px-2{padding-inline:calc(var(--spacing)*2)}.sm\:px-3{padding-inline:calc(var(--spacing)*3)}.sm\:text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.sm\:text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.sm\:text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.sm\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.sm\:text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}}@media(min-width:48rem){.md\:top-\[2px\]{top:2px}.md\:left-\[2px\]{left:2px}.md\:mx-0{margin-inline:calc(var(--spacing)*0)}.md\:block{display:block}.md\:inline{display:inline}.md\:h-4{height:calc(var(--spacing)*4)}.md\:h-5{height:calc(var(--spacing)*5)}.md\:min-h-0{min-height:calc(var(--spacing)*0)}.md\:w-4{width:calc(var(--spacing)*4)}.md\:w-9{width:calc(var(--spacing)*9)}.md\:min-w-\[200px\]{min-width:200px}.md\:flex-1{flex:1}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.md\:flex-row{flex-direction:row}.md\:flex-wrap{flex-wrap:wrap}.md\:items-center{align-items:center}.md\:gap-4{gap:calc(var(--spacing)*4)}.md\:p-6{padding:calc(var(--spacing)*6)}.md\:p-8{padding:calc(var(--spacing)*8)}.md\:px-0{padding-inline:calc(var(--spacing)*0)}.md\:py-2{padding-block:calc(var(--spacing)*2)}.md\:pb-0{padding-bottom:calc(var(--spacing)*0)}}@media(min-width:64rem){.lg\:static{position:static}.lg\:col-span-2{grid-column:span 2/span 2}.lg\:col-span-3{grid-column:span 3/span 3}.lg\:flex{display:flex}.lg\:hidden{display:none}.lg\:h-\[calc\(100vh-64px\)\]{height:calc(100vh - 64px)}.lg\:w-1\/3{width:33.3333%}.lg\:w-2\/3{width:66.6667%}.lg\:w-80{width:calc(var(--spacing)*80)}.lg\:w-\[480px\]{width:480px}.lg\:max-w-md{max-width:var(--container-md)}.lg\:max-w-sm{max-width:var(--container-sm)}.lg\:max-w-xl{max-width:var(--container-xl)}.lg\:flex-shrink-0{flex-shrink:0}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.lg\:flex-row{flex-direction:row}.lg\:gap-4{gap:calc(var(--spacing)*4)}.lg\:gap-6{gap:calc(var(--spacing)*6)}.lg\:gap-8{gap:calc(var(--spacing)*8)}.lg\:overflow-y-auto{overflow-y:auto}.lg\:p-8{padding:calc(var(--spacing)*8)}}@media(min-width:80rem){.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}@media(min-width:96rem){.\32xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}.dark\:border-bambu-dark-tertiary:where(.dark,.dark *),.dark\:border-bambu-dark-tertiary\/50:where(.dark,.dark *){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.dark\:border-bambu-dark-tertiary\/50:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.dark\:border-bambu-green\/40:where(.dark,.dark *){border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:border-bambu-green\/40:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.dark\:border-gray-600:where(.dark,.dark *){border-color:var(--color-gray-600)}.dark\:border-red-500\/30:where(.dark,.dark *){border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.dark\:border-red-500\/30:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.dark\:border-red-500\/40:where(.dark,.dark *){border-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.dark\:border-red-500\/40:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.dark\:bg-amber-500\/10:where(.dark,.dark *){background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-amber-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.dark\:bg-bambu-dark:where(.dark,.dark *){background-color:var(--color-bambu-dark)}.dark\:bg-bambu-dark-secondary:where(.dark,.dark *){background-color:var(--color-bambu-dark-secondary)}.dark\:bg-bambu-green\/20:where(.dark,.dark *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:bg-bambu-green\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.dark\:bg-black\/80:where(.dark,.dark *){background-color:#000c}@supports (color:color-mix(in lab,red,red)){.dark\:bg-black\/80:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.dark\:bg-blue-500\/10:where(.dark,.dark *){background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-blue-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.dark\:bg-blue-500\/20:where(.dark,.dark *){background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.dark\:bg-blue-500\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.dark\:bg-gray-900:where(.dark,.dark *){background-color:var(--color-gray-900)}.dark\:bg-red-500\/10:where(.dark,.dark *){background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-red-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.dark\:bg-red-500\/20:where(.dark,.dark *){background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.dark\:bg-red-500\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.dark\:text-amber-400:where(.dark,.dark *){color:var(--color-amber-400)}.dark\:text-bambu-gray:where(.dark,.dark *),.dark\:text-bambu-gray\/30:where(.dark,.dark *){color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-gray\/30:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.dark\:text-bambu-gray\/50:where(.dark,.dark *){color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-gray\/50:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.dark\:text-bambu-green:where(.dark,.dark *),.dark\:text-bambu-green\/60:where(.dark,.dark *){color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-green\/60:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-green)60%,transparent)}}.dark\:text-blue-200:where(.dark,.dark *){color:var(--color-blue-200)}.dark\:text-blue-200\/80:where(.dark,.dark *){color:#bedbffcc}@supports (color:color-mix(in lab,red,red)){.dark\:text-blue-200\/80:where(.dark,.dark *){color:color-mix(in oklab,var(--color-blue-200)80%,transparent)}}.dark\:text-blue-300:where(.dark,.dark *){color:var(--color-blue-300)}.dark\:text-blue-300\/60:where(.dark,.dark *){color:#90c5ff99}@supports (color:color-mix(in lab,red,red)){.dark\:text-blue-300\/60:where(.dark,.dark *){color:color-mix(in oklab,var(--color-blue-300)60%,transparent)}}.dark\:text-blue-400:where(.dark,.dark *){color:var(--color-blue-400)}.dark\:text-orange-200:where(.dark,.dark *){color:var(--color-orange-200)}.dark\:text-orange-400:where(.dark,.dark *){color:var(--color-orange-400)}.dark\:text-red-400:where(.dark,.dark *){color:var(--color-red-400)}.dark\:text-red-400\/70:where(.dark,.dark *){color:#ff6568b3}@supports (color:color-mix(in lab,red,red)){.dark\:text-red-400\/70:where(.dark,.dark *){color:color-mix(in oklab,var(--color-red-400)70%,transparent)}}.dark\:text-white:where(.dark,.dark *){color:var(--color-white)}.dark\:text-yellow-200:where(.dark,.dark *){color:var(--color-yellow-200)}.dark\:text-yellow-200\/70:where(.dark,.dark *){color:#fff085b3}@supports (color:color-mix(in lab,red,red)){.dark\:text-yellow-200\/70:where(.dark,.dark *){color:color-mix(in oklab,var(--color-yellow-200)70%,transparent)}}@media(hover:hover){.dark\:hover\:bg-bambu-dark-tertiary:where(.dark,.dark *):hover{background-color:var(--color-bambu-dark-tertiary)}.dark\:hover\:bg-bambu-dark\/50:where(.dark,.dark *):hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.dark\:hover\:bg-bambu-dark\/50:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.dark\:hover\:bg-red-500\/30:where(.dark,.dark *):hover{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.dark\:hover\:bg-red-500\/30:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.dark\:hover\:text-white:where(.dark,.dark *):hover{color:var(--color-white)}}.\[\&\:\:-webkit-slider-thumb\]\:h-3::-webkit-slider-thumb{height:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:w-3::-webkit-slider-thumb{width:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:cursor-pointer::-webkit-slider-thumb{cursor:pointer}.\[\&\:\:-webkit-slider-thumb\]\:appearance-none::-webkit-slider-thumb{appearance:none}.\[\&\:\:-webkit-slider-thumb\]\:rounded-full::-webkit-slider-thumb{border-radius:3.40282e38px}.\[\&\:\:-webkit-slider-thumb\]\:bg-bambu-green::-webkit-slider-thumb{background-color:var(--color-bambu-green)}}:root{--accent:#00ae42;--accent-light:#00c64d;--accent-dark:#009438;--status-ok:#22c55e;--status-error:#ef4444;--status-warning:#f59e0b;--bg-primary:#f5f5f5;--bg-secondary:#fff;--bg-tertiary:#e5e5e5;--text-primary:#1a1a1a;--text-secondary:#4a4a4a;--text-muted:#6b6b6b;--text-tertiary:gray;--border-color:#d4d4d4;--card-shadow:0 2px 8px #00000014;--glow-color:transparent;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,system-ui,sans-serif;font-weight:400;line-height:1.5}.dark{--bg-primary:#1a1a1a;--bg-secondary:#2d2d2d;--bg-tertiary:#3d3d3d;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:gray;--text-tertiary:#4a4a4a;--border-color:#3d3d3d;--card-shadow:0 4px 16px #0006}.bg-warm{--bg-primary:#faf8f5;--bg-secondary:#fffefa;--bg-tertiary:#e8e4dd;--text-primary:#2d2a26;--text-secondary:#5c5750;--text-muted:#7a756c;--text-tertiary:#9a9590;--border-color:#d8d4cc}.bg-cool{--bg-primary:#f0f4f8;--bg-secondary:#fff;--bg-tertiary:#dce4ec;--text-primary:#1a2530;--text-secondary:#4a5568;--text-muted:#6b7a8a;--text-tertiary:#8a9aaa;--border-color:#c8d4e0}.dark.bg-neutral{--bg-primary:#1a1a1a;--bg-secondary:#2d2d2d;--bg-tertiary:#3d3d3d;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:gray;--text-tertiary:#4a4a4a;--border-color:#3d3d3d}.dark.bg-warm{--bg-primary:#1c1a18;--bg-secondary:#2e2a26;--bg-tertiary:#3e3a36;--text-primary:#f5f0ea;--text-secondary:#b0a898;--text-muted:#8a8278;--text-tertiary:#5a5248;--border-color:#3e3a36}.dark.bg-cool{--bg-primary:#181c20;--bg-secondary:#262c32;--bg-tertiary:#363e46;--text-primary:#f0f4f8;--text-secondary:#98a8b8;--text-muted:#788898;--text-tertiary:#4a5a6a;--border-color:#363e46}.dark.bg-oled{--bg-primary:#000;--bg-secondary:#141414;--bg-tertiary:#1f1f1f;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:#707070;--text-tertiary:#404040;--border-color:#2a2a2a}.dark.bg-slate{--bg-primary:#0f172a;--bg-secondary:#1e293b;--bg-tertiary:#334155;--text-primary:#f1f5f9;--text-secondary:#94a3b8;--text-muted:#64748b;--text-tertiary:#475569;--border-color:#334155}.dark.bg-forest{--bg-primary:#121a16;--bg-secondary:#1c2a22;--bg-tertiary:#2a3d30;--text-primary:#e8f5ec;--text-secondary:#8aa894;--text-muted:#6a8874;--text-tertiary:#4a6854;--border-color:#2a3d30}.printer-control-buttons-container{container-type:inline-size}@container (max-width:220px){.printer-control-buttons{flex-direction:column;align-items:stretch}.printer-control-buttons>button{width:100%}}.style-glow{--card-shadow:0 2px 8px #00000014,0 0 25px var(--accent)}@supports (color:color-mix(in lab,red,red)){.style-glow{--card-shadow:0 2px 8px #00000014,0 0 25px color-mix(in srgb,var(--accent)12%,transparent)}}.dark.style-glow{--card-shadow:0 4px 20px #00000080,0 0 40px var(--accent)}@supports (color:color-mix(in lab,red,red)){.dark.style-glow{--card-shadow:0 4px 20px #00000080,0 0 40px color-mix(in srgb,var(--accent)15%,transparent)}}.style-vibrant{--card-shadow:0 8px 30px #00000026,0 2px 8px #0000001a}.dark.style-vibrant{--card-shadow:0 10px 40px #0009,0 4px 12px #0006}.accent-green{--accent:#00ae42;--accent-light:#00c64d;--accent-dark:#009438}.accent-teal{--accent:#14b8a6;--accent-light:#2dd4bf;--accent-dark:#0d9488}.accent-blue{--accent:#3b82f6;--accent-light:#60a5fa;--accent-dark:#2563eb}.accent-orange{--accent:#f97316;--accent-light:#fb923c;--accent-dark:#ea580c}.accent-purple{--accent:#8b5cf6;--accent-light:#a78bfa;--accent-dark:#7c3aed}.accent-red{--accent:#ef4444;--accent-light:#f87171;--accent-dark:#dc2626}body{background-color:var(--bg-primary);color:var(--text-primary);min-height:100vh;margin:0;transition:background-color .2s,color .2s}#root{min-height:100vh}.text-white{color:var(--text-primary)}.bg-bambu-dark,.bg-bambu-dark-secondary,.bg-bambu-dark-tertiary,.border-bambu-dark-tertiary{transition:background-color .2s,border-color .2s}@keyframes slide-in{0%{opacity:0;transform:translate(100%)}to{opacity:1;transform:translate(0)}}.animate-slide-in{animation:.2s ease-out slide-in}.icon-theme{opacity:.5}.dark .icon-theme{filter:invert();opacity:.4}.icon-green{filter:invert(48%)sepia(89%)saturate(459%)hue-rotate(93deg)brightness(95%)contrast(92%);opacity:1}.icon-heating{filter:invert(50%)sepia()saturate(1000%)hue-rotate(360deg)brightness()contrast();opacity:1}.dark .jogpad-theme{filter:brightness(.35)contrast(1.2)}.ams-empty-slot{background:repeating-linear-gradient(45deg,#444,#444 2px,#222 2px 4px)}.dark .ams-empty-slot{background:repeating-linear-gradient(45deg,#555,#555 2px,#333 2px 4px)}.touch-manipulation{touch-action:manipulation}.safe-area-bottom{padding-bottom:env(safe-area-inset-bottom,0)}.safe-area-top{padding-top:env(safe-area-inset-top,0)}.scrollbar-hide{-ms-overflow-style:none;scrollbar-width:none}.scrollbar-hide::-webkit-scrollbar{display:none}@keyframes slide-in-left{0%{transform:translate(-100%)}to{transform:translate(0)}}.animate-slide-in-left{animation:.3s ease-out slide-in-left}.card-shadow{box-shadow:var(--card-shadow)}.calendar-scroll{scrollbar-width:thin;scrollbar-color:var(--text-muted)transparent}@supports (color:color-mix(in lab,red,red)){.calendar-scroll{scrollbar-color:color-mix(in srgb,var(--text-muted)60%,transparent)transparent}}.calendar-scroll::-webkit-scrollbar{width:8px}.calendar-scroll::-webkit-scrollbar-track{background:0 0}.calendar-scroll::-webkit-scrollbar-thumb{background-color:var(--text-muted)}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb{background-color:color-mix(in srgb,var(--text-muted)60%,transparent)}}.calendar-scroll::-webkit-scrollbar-thumb{border:2px solid var(--bg-secondary);border-radius:999px}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb{border:2px solid color-mix(in srgb,var(--bg-secondary)70%,transparent)}}.calendar-scroll::-webkit-scrollbar-thumb:hover{background-color:var(--text-muted)}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb:hover{background-color:color-mix(in srgb,var(--text-muted)80%,transparent)}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@property --tw-content{syntax:"*";inherits:false;initial-value:""}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:""}}} diff --git a/static/index.html b/static/index.html index 987a81330..e99a5e78c 100644 --- a/static/index.html +++ b/static/index.html @@ -23,8 +23,8 @@ - - + +