diff --git a/backend/app/services/bambu_mqtt.py b/backend/app/services/bambu_mqtt.py
index bd5e5170d..a2e2aa20b 100644
--- a/backend/app/services/bambu_mqtt.py
+++ b/backend/app/services/bambu_mqtt.py
@@ -645,27 +645,64 @@ class BambuMQTTClient:
temps["bed"] = float(data["bed_temper"])
if "bed_target_temper" in data:
temps["bed_target"] = float(data["bed_target_temper"])
+ # Check if this is H2D (has device.extruder.info with 2 extruders)
+ has_h2d_extruder_info = (
+ "device" in data and
+ isinstance(data.get("device"), dict) and
+ "extruder" in data["device"] and
+ isinstance(data["device"]["extruder"].get("info"), list) and
+ len(data["device"]["extruder"]["info"]) >= 2
+ )
+
+ # Standard nozzle fields: these are for the RIGHT/default nozzle on H2D
+ # For H2D, we use these for nozzle_2 (RIGHT), for others use as nozzle (primary)
if "nozzle_temper" in data:
- temps["nozzle"] = float(data["nozzle_temper"])
+ if has_h2d_extruder_info:
+ temps["nozzle_2"] = float(data["nozzle_temper"]) # RIGHT nozzle on H2D
+ else:
+ temps["nozzle"] = float(data["nozzle_temper"])
if "nozzle_target_temper" in data:
- temps["nozzle_target"] = float(data["nozzle_target_temper"])
- # Second nozzle for dual-extruder printers (H2 series)
- # Try multiple possible field names used by different firmware versions
- if "nozzle_temper_2" in data:
- temps["nozzle_2"] = float(data["nozzle_temper_2"])
- elif "right_nozzle_temper" in data:
- temps["nozzle_2"] = float(data["right_nozzle_temper"])
- if "nozzle_target_temper_2" in data:
- temps["nozzle_2_target"] = float(data["nozzle_target_temper_2"])
- elif "right_nozzle_target_temper" in data:
- temps["nozzle_2_target"] = float(data["right_nozzle_target_temper"])
- # Also check for left nozzle as primary (some H2 models)
- if "left_nozzle_temper" in data and "nozzle" not in temps:
- temps["nozzle"] = float(data["left_nozzle_temper"])
- if "left_nozzle_target_temper" in data and "nozzle_target" not in temps:
- temps["nozzle_target"] = float(data["left_nozzle_target_temper"])
+ if has_h2d_extruder_info:
+ temps["nozzle_2_target"] = float(data["nozzle_target_temper"]) # RIGHT target on H2D
+ else:
+ temps["nozzle_target"] = float(data["nozzle_target_temper"])
+ # Second nozzle for dual-extruder printers - skip for H2D (uses device.extruder.info instead)
+ if not has_h2d_extruder_info:
+ # Try multiple possible field names used by different firmware versions
+ if "nozzle_temper_2" in data:
+ val = float(data["nozzle_temper_2"])
+ if -50 < val < 500: # Valid temp range
+ temps["nozzle_2"] = val
+ else:
+ logger.debug(f"[{self.serial_number}] nozzle_temper_2={val} out of range")
+ elif "right_nozzle_temper" in data:
+ val = float(data["right_nozzle_temper"])
+ if -50 < val < 500: # Valid temp range
+ temps["nozzle_2"] = val
+ else:
+ logger.debug(f"[{self.serial_number}] right_nozzle_temper={val} out of range")
+ if "nozzle_target_temper_2" in data:
+ val = float(data["nozzle_target_temper_2"])
+ if 0 <= val < 500: # Valid temp range
+ temps["nozzle_2_target"] = val
+ else:
+ logger.debug(f"[{self.serial_number}] nozzle_target_temper_2={val} out of range")
+ elif "right_nozzle_target_temper" in data:
+ val = float(data["right_nozzle_target_temper"])
+ if 0 <= val < 500: # Valid temp range
+ temps["nozzle_2_target"] = val
+ else:
+ logger.debug(f"[{self.serial_number}] right_nozzle_target_temper={val} out of range")
+ # Also check for left nozzle as primary (some H2 models)
+ if "left_nozzle_temper" in data and "nozzle" not in temps:
+ temps["nozzle"] = float(data["left_nozzle_temper"])
+ if "left_nozzle_target_temper" in data and "nozzle_target" not in temps:
+ temps["nozzle_target"] = float(data["left_nozzle_target_temper"])
if "chamber_temper" in data:
temps["chamber"] = float(data["chamber_temper"])
+ # Chamber target temperature (set by print file or display)
+ if "mc_target_cham" in data:
+ temps["chamber_target"] = float(data["mc_target_cham"])
# H2D series: Chamber temp is in info.temp (directly in °C)
try:
if "info" in data and isinstance(data["info"], dict):
@@ -680,37 +717,85 @@ class BambuMQTTClient:
extruder_data = device.get("extruder", {})
extruder_info = extruder_data.get("info", [])
if isinstance(extruder_info, list) and len(extruder_info) >= 1:
- # Log extruder info structure for debugging (once)
- if not getattr(self, '_extruder_info_logged', False):
- logger.debug(f"[{self.serial_number}] H2D extruder info[0]: {extruder_info[0]}")
- if len(extruder_info) >= 2:
- logger.debug(f"[{self.serial_number}] H2D extruder info[1]: {extruder_info[1]}")
- self._extruder_info_logged = True
- # Left nozzle (extruder 0) - temp is already in Celsius
- if "nozzle" not in temps and "temp" in extruder_info[0]:
+ # H2D nozzle mapping: id=0 is RIGHT nozzle (default), id=1 is LEFT nozzle
+ # RIGHT nozzle uses standard nozzle_temper/nozzle_target_temper fields (already parsed above)
+ # LEFT nozzle uses extruder_info[1] - no standard fields available
+ # Note: hnow/htar flags are unreliable (static values, not actual heating state)
+ # Real heating indicator: temp > 500 means encoded (target*65536+current)
+ # Heating = target > 0 AND current < target
+ # Right nozzle (extruder 0)
+ if len(extruder_info) >= 1 and "temp" in extruder_info[0]:
temp_val = extruder_info[0]["temp"]
- if -50 < temp_val < 500: # Valid temp range
- temps["nozzle"] = float(temp_val)
- # Left nozzle target temp - star field, but 65535/65279 means "not set"
- if "nozzle_target" not in temps:
- star = extruder_info[0].get("star")
- if star is not None and 0 <= star < 500: # Valid temp range
- temps["nozzle_target"] = float(star)
- # Right nozzle (extruder 1) - only for dual nozzle printers
+ if temp_val > 500:
+ target = temp_val // 65536
+ current = temp_val % 65536
+ temps["nozzle_2_heating"] = target > 0 and current < target
+ else:
+ temps["nozzle_2_heating"] = False
+ # Left nozzle (extruder 1)
+ # H2D protocol: temp field encoding depends on value
+ # - When > 500: encoded as (target * 65536 + current) - heater is ON
+ # - When < 500: direct Celsius current temp only - heater is OFF
if len(extruder_info) >= 2 and "temp" in extruder_info[1]:
- temp_val = extruder_info[1]["temp"]
- if -50 < temp_val < 500: # Valid temp range
- temps["nozzle_2"] = float(temp_val)
- # Right nozzle target temp - star field, but 65535/65279 means "not set"
- if len(extruder_info) >= 2:
- star = extruder_info[1].get("star")
- if star is not None and 0 <= star < 500: # Valid temp range
- temps["nozzle_2_target"] = float(star)
+ ext1 = extruder_info[1]
+ temp_val = ext1["temp"]
+
+ # Check if we recently set the target locally (within 5 seconds)
+ # If so, don't let MQTT data overwrite it
+ local_set_time = self.state.temperatures.get("_nozzle_target_set_time", 0)
+ respect_local_target = (time.time() - local_set_time) < 5.0
+
+ if temp_val > 500:
+ # Encoded format: temp = target * 65536 + current
+ target = temp_val // 65536
+ current = temp_val % 65536
+ if 0 < target < 500 and not respect_local_target:
+ temps["nozzle_target"] = float(target)
+ if -50 < current < 500:
+ temps["nozzle"] = float(current)
+ # Heating = encoded AND we're using the MQTT target (not local override)
+ # If local target is being respected, use local target to determine heating
+ if respect_local_target:
+ local_target = self.state.temperatures.get("nozzle_target", 0)
+ temps["nozzle_heating"] = local_target > 0 and current < local_target
+ else:
+ temps["nozzle_heating"] = target > 0 and current < target
+ elif -50 < temp_val < 500:
+ # Direct Celsius = heater is OFF (or at target with heater off)
+ temps["nozzle"] = float(temp_val)
+ if not respect_local_target:
+ temps["nozzle_target"] = 0.0
+ temps["nozzle_heating"] = False # Direct = not heating
+ # Parse bed heating state from device.bed.info.temp encoding
+ # temp > 500 means encoded (target*65536+current), heating = target > 0 AND current < target
+ bed_data = device.get("bed", {})
+ bed_info = bed_data.get("info", {})
+ if "temp" in bed_info:
+ temp_val = bed_info["temp"]
+ if temp_val > 500:
+ target = temp_val // 65536
+ current = temp_val % 65536
+ temps["bed_heating"] = target > 0 and current < target
+ else:
+ temps["bed_heating"] = False
# Parse chamber temp from device.ctc.info.temp if not already set
ctc_data = device.get("ctc", {})
ctc_info = ctc_data.get("info", {})
if "temp" in ctc_info and "chamber" not in temps:
temps["chamber"] = float(ctc_info["temp"])
+ # Parse chamber target from ctc.info.target if available
+ if "target" in ctc_info and "chamber_target" not in temps:
+ temps["chamber_target"] = float(ctc_info["target"])
+ # Parse chamber heating state from temp encoding
+ # temp > 500 means encoded (target*65536+current), heating = target > 0 AND current < target
+ if "temp" in ctc_info:
+ temp_val = ctc_info["temp"]
+ if temp_val > 500:
+ target = temp_val // 65536
+ current = temp_val % 65536
+ temps["chamber_heating"] = target > 0 and current < target
+ else:
+ temps["chamber_heating"] = False
except Exception as e:
logger.warning(f"[{self.serial_number}] Error parsing H2D temperatures: {e}")
if temps:
@@ -1650,7 +1735,8 @@ class BambuMQTTClient:
"sequence_id": str(self._sequence_id)
}
}
- self._client.publish(self.topic_publish, json.dumps(command))
+ # Use QoS 1 for reliable delivery (at least once)
+ self._client.publish(self.topic_publish, json.dumps(command), qos=1)
logger.debug(f"[{self.serial_number}] Sent G-code: {gcode[:50]}...")
return True
@@ -1663,8 +1749,6 @@ class BambuMQTTClient:
Returns:
True if command was sent, False otherwise
"""
- # Use M140 for non-blocking (preferred when not waiting)
- # Note: P1/A1 series with newer firmware may need M190 (blocking)
return self.send_gcode(f"M140 S{target}")
def set_nozzle_temperature(self, target: int, nozzle: int = 0) -> bool:
@@ -1672,17 +1756,21 @@ class BambuMQTTClient:
Args:
target: Target temperature in Celsius (0 to turn off)
- nozzle: Nozzle index (0 for primary, 1 for secondary on H2D)
+ nozzle: Nozzle index (0 for right/default, 1 for left on H2D)
Returns:
True if command was sent, False otherwise
"""
# Use M104 for non-blocking
- # For dual nozzle (H2D), T parameter selects the tool
- if nozzle == 0:
- return self.send_gcode(f"M104 S{target}")
- else:
- return self.send_gcode(f"M104 T{nozzle} S{target}")
+ # Always use T parameter for H2D compatibility
+ result = self.send_gcode(f"M104 T{nozzle} S{target}")
+ # H2D quirk: left nozzle (nozzle=1) target isn't reported in MQTT
+ # Track it locally so we can display it correctly
+ if result and nozzle == 1:
+ self.state.temperatures["nozzle_target"] = float(target)
+ self.state.temperatures["_nozzle_target_set_time"] = time.time()
+ logger.info(f"[{self.serial_number}] Tracking LEFT nozzle target locally: {target}°C")
+ return result
def set_print_speed(self, mode: int) -> bool:
"""Set the print speed mode.
diff --git a/frontend/src/components/control/TemperatureColumn.tsx b/frontend/src/components/control/TemperatureColumn.tsx
index fbd0badb2..04d568ad8 100644
--- a/frontend/src/components/control/TemperatureColumn.tsx
+++ b/frontend/src/components/control/TemperatureColumn.tsx
@@ -6,11 +6,16 @@ import type { PrinterStatus } from '../../api/client';
interface Temperatures {
bed?: number;
bed_target?: number;
+ bed_heating?: boolean;
nozzle?: number;
nozzle_target?: number;
+ nozzle_heating?: boolean;
nozzle_2?: number;
nozzle_2_target?: number;
+ nozzle_2_heating?: boolean;
chamber?: number;
+ chamber_target?: number;
+ chamber_heating?: boolean;
}
interface TemperatureColumnProps {
@@ -64,9 +69,13 @@ export function TemperatureColumn({ printerId, status, nozzleCount, disabled = f
if (editing === 'bed') {
bedMutation.mutate(target);
} else if (editing === 'nozzle') {
- nozzleMutation.mutate({ target, nozzle: 0 });
+ // nozzle field = LEFT nozzle display
+ // H2D: LEFT is T1 (index 1), single nozzle: index 0
+ nozzleMutation.mutate({ target, nozzle: isDualNozzle ? 1 : 0 });
} else if (editing === 'nozzle_2') {
- nozzleMutation.mutate({ target, nozzle: 1 });
+ // nozzle_2 field = RIGHT nozzle display
+ // H2D: RIGHT is T0/default (index 0)
+ nozzleMutation.mutate({ target, nozzle: 0 });
}
cancelEditing();
};
@@ -81,6 +90,12 @@ export function TemperatureColumn({ printerId, status, nozzleCount, disabled = f
const isDisabled = !isConnected;
+ // Use live heating state from MQTT
+ const isNozzleHeating = temps.nozzle_heating ?? false;
+ const isNozzle2Heating = temps.nozzle_2_heating ?? false;
+ const isBedHeating = temps.bed_heating ?? false;
+ const isChamberHeating = temps.chamber_heating ?? false;
+
const renderTargetTemp = (
field: EditingField,
targetValue: number
@@ -88,15 +103,19 @@ export function TemperatureColumn({ printerId, status, nozzleCount, disabled = f
if (editing === field) {
return (
setEditValue(e.target.value)}
+ onChange={(e) => {
+ // Only allow numeric input
+ const val = e.target.value.replace(/[^0-9]/g, '');
+ setEditValue(val);
+ }}
onBlur={submitEdit}
onKeyDown={handleKeyDown}
autoFocus
- className="w-12 text-sm bg-bambu-dark border border-bambu-green rounded px-1 py-0.5 text-white text-center"
- min={0}
- max={350}
+ className="w-12 text-sm bg-bambu-dark border border-bambu-green rounded px-1 py-0.5 text-white text-center [appearance:textfield]"
/>
);
}
@@ -117,7 +136,11 @@ export function TemperatureColumn({ printerId, status, nozzleCount, disabled = f
{/* Nozzle 1 (Left) */}
-
+
{isDualNozzle && (
@@ -132,7 +155,11 @@ export function TemperatureColumn({ printerId, status, nozzleCount, disabled = f
{isDualNozzle && (
-
+
R
@@ -145,21 +172,25 @@ export function TemperatureColumn({ printerId, status, nozzleCount, disabled = f
{/* Bed */}
-
+
{isDualNozzle &&
}
{Math.round(temps.bed ?? 0)}
{renderTargetTemp('bed', temps.bed_target ?? 0)}
- {/* Chamber - read only */}
+ {/* Chamber - read only (target set by print file or display) */}
-
+
{isDualNozzle &&
}
{Math.round(temps.chamber ?? 0)}
-
°C
+
/{Math.round(temps.chamber_target ?? 0)} °C
{/* Air Condition - button */}
diff --git a/frontend/src/index.css b/frontend/src/index.css
index 11f347536..436a019c0 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -108,6 +108,12 @@ body {
opacity: 1;
}
+/* Orange/red-colored icon for heating indicators */
+.icon-heating {
+ filter: invert(50%) sepia(100%) saturate(1000%) hue-rotate(360deg) brightness(100%) contrast(100%);
+ opacity: 1;
+}
+
/* Jogpad theme styling - darken background in dark mode */
.jogpad-theme {
/* Light mode - normal */
diff --git a/static/assets/index-C4OBhD7e.js b/static/assets/index-1LVQBXOF.js
similarity index 99%
rename from static/assets/index-C4OBhD7e.js
rename to static/assets/index-1LVQBXOF.js
index 7c0e2f519..d2d883626 100644
--- a/static/assets/index-C4OBhD7e.js
+++ b/static/assets/index-1LVQBXOF.js
@@ -8591,7 +8591,7 @@ Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Gg(t.
To pick up a draggable item, press the space bar.
While dragging, use the arrow keys to move the item.
Press space again to drop the item in its new position, or press escape to cancel.
- `},V8e={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function $8e(t){let{announcements:e=V8e,container:n,hiddenTextDescribedById:i,screenReaderInstructions:r=H8e}=t;const{announce:a,announcement:s}=F8e(),o=pv("DndLiveRegion"),[l,c]=A.useState(!1);if(A.useEffect(()=>{c(!0)},[]),z8e(A.useMemo(()=>({onDragStart(f){let{active:m}=f;a(e.onDragStart({active:m}))},onDragMove(f){let{active:m,over:g}=f;e.onDragMove&&a(e.onDragMove({active:m,over:g}))},onDragOver(f){let{active:m,over:g}=f;a(e.onDragOver({active:m,over:g}))},onDragEnd(f){let{active:m,over:g}=f;a(e.onDragEnd({active:m,over:g}))},onDragCancel(f){let{active:m,over:g}=f;a(e.onDragCancel({active:m,over:g}))}}),[a,e])),!l)return null;const u=ui.createElement(ui.Fragment,null,ui.createElement(j8e,{id:i,value:r.draggable}),ui.createElement(U8e,{id:o,announcement:s}));return n?Kl.createPortal(u,n):u}var nr;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(nr||(nr={}));function jS(){}function z$(t,e){return A.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function G8e(){for(var t=arguments.length,e=new Array(t),n=0;n[...e].filter(i=>i!=null),[...e])}const wo=Object.freeze({x:0,y:0});function bJ(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function yJ(t,e){let{data:{value:n}}=t,{data:{value:i}}=e;return n-i}function W8e(t,e){let{data:{value:n}}=t,{data:{value:i}}=e;return i-n}function B$(t){let{left:e,top:n,height:i,width:r}=t;return[{x:e,y:n},{x:e+r,y:n},{x:e,y:n+i},{x:e+r,y:n+i}]}function _J(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function H$(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+t.width*.5,y:n+t.height*.5}}const q8e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:i}=t;const r=H$(e,e.left,e.top),a=[];for(const s of i){const{id:o}=s,l=n.get(o);if(l){const c=bJ(H$(l),r);a.push({id:o,data:{droppableContainer:s,value:c}})}}return a.sort(yJ)},X8e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:i}=t;const r=B$(e),a=[];for(const s of i){const{id:o}=s,l=n.get(o);if(l){const c=B$(l),u=r.reduce((m,g,b)=>m+bJ(c[b],g),0),f=Number((u/4).toFixed(4));a.push({id:o,data:{droppableContainer:s,value:f}})}}return a.sort(yJ)};function K8e(t,e){const n=Math.max(e.top,t.top),i=Math.max(e.left,t.left),r=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height),s=r-i,o=a-n;if(i{let{collisionRect:e,droppableRects:n,droppableContainers:i}=t;const r=[];for(const a of i){const{id:s}=a,o=n.get(s);if(o){const l=K8e(o,e);l>0&&r.push({id:s,data:{droppableContainer:a,value:l}})}}return r.sort(W8e)};function Z8e(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function SJ(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:wo}function Q8e(t){return function(n){for(var i=arguments.length,r=new Array(i>1?i-1:0),a=1;a({...s,top:s.top+t*o.y,bottom:s.bottom+t*o.y,left:s.left+t*o.x,right:s.right+t*o.x}),{...n})}}const J8e=Q8e(1);function e6e(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function t6e(t,e,n){const i=e6e(e);if(!i)return t;const{scaleX:r,scaleY:a,x:s,y:o}=i,l=t.left-s-(1-r)*parseFloat(n),c=t.top-o-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),u=r?t.width/r:t.width,f=a?t.height/a:t.height;return{width:u,height:f,top:c,right:l+u,bottom:c+f,left:l}}const n6e={ignoreTransform:!1};function jm(t,e){e===void 0&&(e=n6e);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:c,transformOrigin:u}=$a(t).getComputedStyle(t);c&&(n=t6e(n,c,u))}const{top:i,left:r,width:a,height:s,bottom:o,right:l}=n;return{top:i,left:r,width:a,height:s,bottom:o,right:l}}function V$(t){return jm(t,{ignoreTransform:!0})}function i6e(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function r6e(t,e){return e===void 0&&(e=$a(t).getComputedStyle(t)),e.position==="fixed"}function a6e(t,e){e===void 0&&(e=$a(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(r=>{const a=e[r];return typeof a=="string"?n.test(a):!1})}function dM(t,e){const n=[];function i(r){if(e!=null&&n.length>=e||!r)return n;if(YO(r)&&r.scrollingElement!=null&&!n.includes(r.scrollingElement))return n.push(r.scrollingElement),n;if(!fv(r)||gJ(r)||n.includes(r))return n;const a=$a(t).getComputedStyle(r);return r!==t&&a6e(r,a)&&n.push(r),r6e(r,a)?n:i(r.parentNode)}return t?i(t):n}function wJ(t){const[e]=dM(t,1);return e??null}function aN(t){return!uM||!t?null:Lm(t)?t:KO(t)?YO(t)||t===Im(t).scrollingElement?window:fv(t)?t:null:null}function MJ(t){return Lm(t)?t.scrollX:t.scrollLeft}function EJ(t){return Lm(t)?t.scrollY:t.scrollTop}function hP(t){return{x:MJ(t),y:EJ(t)}}var Mr;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Mr||(Mr={}));function AJ(t){return!uM||!t?!1:t===document.scrollingElement}function TJ(t){const e={x:0,y:0},n=AJ(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},i={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},r=t.scrollTop<=e.y,a=t.scrollLeft<=e.x,s=t.scrollTop>=i.y,o=t.scrollLeft>=i.x;return{isTop:r,isLeft:a,isBottom:s,isRight:o,maxScroll:i,minScroll:e}}const s6e={x:.2,y:.2};function o6e(t,e,n,i,r){let{top:a,left:s,right:o,bottom:l}=n;i===void 0&&(i=10),r===void 0&&(r=s6e);const{isTop:c,isBottom:u,isLeft:f,isRight:m}=TJ(t),g={x:0,y:0},b={x:0,y:0},y={height:e.height*r.y,width:e.width*r.x};return!c&&a<=e.top+y.height?(g.y=Mr.Backward,b.y=i*Math.abs((e.top+y.height-a)/y.height)):!u&&l>=e.bottom-y.height&&(g.y=Mr.Forward,b.y=i*Math.abs((e.bottom-y.height-l)/y.height)),!m&&o>=e.right-y.width?(g.x=Mr.Forward,b.x=i*Math.abs((e.right-y.width-o)/y.width)):!f&&s<=e.left+y.width&&(g.x=Mr.Backward,b.x=i*Math.abs((e.left+y.width-s)/y.width)),{direction:g,speed:b}}function l6e(t){if(t===document.scrollingElement){const{innerWidth:a,innerHeight:s}=window;return{top:0,left:0,right:a,bottom:s,width:a,height:s}}const{top:e,left:n,right:i,bottom:r}=t.getBoundingClientRect();return{top:e,left:n,right:i,bottom:r,width:t.clientWidth,height:t.clientHeight}}function CJ(t){return t.reduce((e,n)=>Ip(e,hP(n)),wo)}function c6e(t){return t.reduce((e,n)=>e+MJ(n),0)}function u6e(t){return t.reduce((e,n)=>e+EJ(n),0)}function d6e(t,e){if(e===void 0&&(e=jm),!t)return;const{top:n,left:i,bottom:r,right:a}=e(t);wJ(t)&&(r<=0||a<=0||n>=window.innerHeight||i>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const f6e=[["x",["left","right"],c6e],["y",["top","bottom"],u6e]];class JO{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const i=dM(n),r=CJ(i);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,s,o]of f6e)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=o(i),u=r[a]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Rx{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var i;return(i=this.target)==null?void 0:i.removeEventListener(...n)})},this.target=e}add(e,n,i){var r;(r=this.target)==null||r.addEventListener(e,n,i),this.listeners.push([e,n,i])}}function h6e(t){const{EventTarget:e}=$a(t);return t instanceof e?t:Im(t)}function sN(t,e){const n=Math.abs(t.x),i=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+i**2)>e:"x"in e&&"y"in e?n>e.x&&i>e.y:"x"in e?n>e.x:"y"in e?i>e.y:!1}var Os;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Os||(Os={}));function $$(t){t.preventDefault()}function p6e(t){t.stopPropagation()}var yn;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(yn||(yn={}));const NJ={start:[yn.Space,yn.Enter],cancel:[yn.Esc],end:[yn.Space,yn.Enter,yn.Tab]},m6e=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case yn.Right:return{...n,x:n.x+25};case yn.Left:return{...n,x:n.x-25};case yn.Down:return{...n,y:n.y+25};case yn.Up:return{...n,y:n.y-25}}};class eL{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new Rx(Im(n)),this.windowListeners=new Rx($a(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Os.Resize,this.handleCancel),this.windowListeners.add(Os.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Os.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,i=e.node.current;i&&d6e(i),n(wo)}handleKeyDown(e){if(QO(e)){const{active:n,context:i,options:r}=this.props,{keyboardCodes:a=NJ,coordinateGetter:s=m6e,scrollBehavior:o="smooth"}=r,{code:l}=e;if(a.end.includes(l)){this.handleEnd(e);return}if(a.cancel.includes(l)){this.handleCancel(e);return}const{collisionRect:c}=i.current,u=c?{x:c.left,y:c.top}:wo;this.referenceCoordinates||(this.referenceCoordinates=u);const f=s(e,{active:n,context:i.current,currentCoordinates:u});if(f){const m=M0(f,u),g={x:0,y:0},{scrollableAncestors:b}=i.current;for(const y of b){const v=e.code,{isTop:x,isRight:M,isLeft:w,isBottom:E,maxScroll:T,minScroll:R}=TJ(y),N=l6e(y),j={x:Math.min(v===yn.Right?N.right-N.width/2:N.right,Math.max(v===yn.Right?N.left:N.left+N.width/2,f.x)),y:Math.min(v===yn.Down?N.bottom-N.height/2:N.bottom,Math.max(v===yn.Down?N.top:N.top+N.height/2,f.y))},C=v===yn.Right&&!M||v===yn.Left&&!w,k=v===yn.Down&&!E||v===yn.Up&&!x;if(C&&j.x!==f.x){const F=y.scrollLeft+m.x,I=v===yn.Right&&F<=T.x||v===yn.Left&&F>=R.x;if(I&&!m.y){y.scrollTo({left:F,behavior:o});return}I?g.x=y.scrollLeft-F:g.x=v===yn.Right?y.scrollLeft-T.x:y.scrollLeft-R.x,g.x&&y.scrollBy({left:-g.x,behavior:o});break}else if(k&&j.y!==f.y){const F=y.scrollTop+m.y,I=v===yn.Down&&F<=T.y||v===yn.Up&&F>=R.y;if(I&&!m.x){y.scrollTo({top:F,behavior:o});return}I?g.y=y.scrollTop-F:g.y=v===yn.Down?y.scrollTop-T.y:y.scrollTop-R.y,g.y&&y.scrollBy({top:-g.y,behavior:o});break}}this.handleMove(e,Ip(M0(f,this.referenceCoordinates),g))}}}handleMove(e,n){const{onMove:i}=this.props;e.preventDefault(),i(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}eL.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:i=NJ,onActivation:r}=e,{active:a}=n;const{code:s}=t.nativeEvent;if(i.start.includes(s)){const o=a.activatorNode.current;return o&&t.target!==o?!1:(t.preventDefault(),r?.({event:t.nativeEvent}),!0)}return!1}}];function G$(t){return!!(t&&"distance"in t)}function W$(t){return!!(t&&"delay"in t)}class tL{constructor(e,n,i){var r;i===void 0&&(i=h6e(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:a}=e,{target:s}=a;this.props=e,this.events=n,this.document=Im(s),this.documentListeners=new Rx(this.document),this.listeners=new Rx(i),this.windowListeners=new Rx($a(s)),this.initialCoordinates=(r=fP(a))!=null?r:wo,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:i}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Os.Resize,this.handleCancel),this.windowListeners.add(Os.DragStart,$$),this.windowListeners.add(Os.VisibilityChange,this.handleCancel),this.windowListeners.add(Os.ContextMenu,$$),this.documentListeners.add(Os.Keydown,this.handleKeydown),n){if(i!=null&&i({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(W$(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(G$(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:i,onPending:r}=this.props;r(i,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(Os.Click,p6e,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Os.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:i,initialCoordinates:r,props:a}=this,{onMove:s,options:{activationConstraint:o}}=a;if(!r)return;const l=(n=fP(e))!=null?n:wo,c=M0(r,l);if(!i&&o){if(G$(o)){if(o.tolerance!=null&&sN(c,o.tolerance))return this.handleCancel();if(sN(c,o.distance))return this.handleStart()}if(W$(o)&&sN(c,o.tolerance))return this.handleCancel();this.handlePending(o,c);return}e.cancelable&&e.preventDefault(),s(l)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===yn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const g6e={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class nL extends tL{constructor(e){const{event:n}=e,i=Im(n.target);super(e,g6e,i)}}nL.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:i}=e;return!n.isPrimary||n.button!==0?!1:(i?.({event:n}),!0)}}];const x6e={move:{name:"mousemove"},end:{name:"mouseup"}};var pP;(function(t){t[t.RightClick=2]="RightClick"})(pP||(pP={}));class v6e extends tL{constructor(e){super(e,x6e,Im(e.event.target))}}v6e.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:i}=e;return n.button===pP.RightClick?!1:(i?.({event:n}),!0)}}];const oN={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class b6e extends tL{constructor(e){super(e,oN)}static setup(){return window.addEventListener(oN.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(oN.move.name,e)};function e(){}}}b6e.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:i}=e;const{touches:r}=n;return r.length>1?!1:(i?.({event:n}),!0)}}];var Px;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Px||(Px={}));var US;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(US||(US={}));function y6e(t){let{acceleration:e,activator:n=Px.Pointer,canScroll:i,draggingRect:r,enabled:a,interval:s=5,order:o=US.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:f,threshold:m}=t;const g=S6e({delta:f,disabled:!a}),[b,y]=k8e(),v=A.useRef({x:0,y:0}),x=A.useRef({x:0,y:0}),M=A.useMemo(()=>{switch(n){case Px.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Px.DraggableRect:return r}},[n,r,l]),w=A.useRef(null),E=A.useCallback(()=>{const R=w.current;if(!R)return;const N=v.current.x*x.current.x,j=v.current.y*x.current.y;R.scrollBy(N,j)},[]),T=A.useMemo(()=>o===US.TreeOrder?[...c].reverse():c,[o,c]);A.useEffect(()=>{if(!a||!c.length||!M){y();return}for(const R of T){if(i?.(R)===!1)continue;const N=c.indexOf(R),j=u[N];if(!j)continue;const{direction:C,speed:k}=o6e(R,j,M,e,m);for(const F of["x","y"])g[F][C[F]]||(k[F]=0,C[F]=0);if(k.x>0||k.y>0){y(),w.current=R,b(E,s),v.current=k,x.current=C;return}}v.current={x:0,y:0},x.current={x:0,y:0},y()},[e,E,i,y,a,s,JSON.stringify(M),JSON.stringify(g),b,c,T,u,JSON.stringify(m)])}const _6e={x:{[Mr.Backward]:!1,[Mr.Forward]:!1},y:{[Mr.Backward]:!1,[Mr.Forward]:!1}};function S6e(t){let{delta:e,disabled:n}=t;const i=dP(e);return hv(r=>{if(n||!i||!r)return _6e;const a={x:Math.sign(e.x-i.x),y:Math.sign(e.y-i.y)};return{x:{[Mr.Backward]:r.x[Mr.Backward]||a.x===-1,[Mr.Forward]:r.x[Mr.Forward]||a.x===1},y:{[Mr.Backward]:r.y[Mr.Backward]||a.y===-1,[Mr.Forward]:r.y[Mr.Forward]||a.y===1}}},[n,e,i])}function w6e(t,e){const n=e!=null?t.get(e):void 0,i=n?n.node.current:null;return hv(r=>{var a;return e==null?null:(a=i??r)!=null?a:null},[i,e])}function M6e(t,e){return A.useMemo(()=>t.reduce((n,i)=>{const{sensor:r}=i,a=r.activators.map(s=>({eventName:s.eventName,handler:e(s.handler,i)}));return[...n,...a]},[]),[t,e])}var A0;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(A0||(A0={}));var mP;(function(t){t.Optimized="optimized"})(mP||(mP={}));const q$=new Map;function E6e(t,e){let{dragging:n,dependencies:i,config:r}=e;const[a,s]=A.useState(null),{frequency:o,measure:l,strategy:c}=r,u=A.useRef(t),f=v(),m=w0(f),g=A.useCallback(function(x){x===void 0&&(x=[]),!m.current&&s(M=>M===null?x:M.concat(x.filter(w=>!M.includes(w))))},[m]),b=A.useRef(null),y=hv(x=>{if(f&&!n)return q$;if(!x||x===q$||u.current!==t||a!=null){const M=new Map;for(let w of t){if(!w)continue;if(a&&a.length>0&&!a.includes(w.id)&&w.rect.current){M.set(w.id,w.rect.current);continue}const E=w.node.current,T=E?new JO(l(E),E):null;w.rect.current=T,T&&M.set(w.id,T)}return M}return x},[t,a,n,f,l]);return A.useEffect(()=>{u.current=t},[t]),A.useEffect(()=>{f||g()},[n,f]),A.useEffect(()=>{a&&a.length>0&&s(null)},[JSON.stringify(a)]),A.useEffect(()=>{f||typeof o!="number"||b.current!==null||(b.current=setTimeout(()=>{g(),b.current=null},o))},[o,f,g,...i]),{droppableRects:y,measureDroppableContainers:g,measuringScheduled:a!=null};function v(){switch(c){case A0.Always:return!1;case A0.BeforeDragging:return n;default:return!n}}}function RJ(t,e){return hv(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function A6e(t,e){return RJ(t,e)}function T6e(t){let{callback:e,disabled:n}=t;const i=ZO(e),r=A.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(i)},[i,n]);return A.useEffect(()=>()=>r?.disconnect(),[r]),r}function fM(t){let{callback:e,disabled:n}=t;const i=ZO(e),r=A.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(i)},[n]);return A.useEffect(()=>()=>r?.disconnect(),[r]),r}function C6e(t){return new JO(jm(t),t)}function X$(t,e,n){e===void 0&&(e=C6e);const[i,r]=A.useState(null);function a(){r(l=>{if(!t)return null;if(t.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=e(t);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const s=T6e({callback(l){if(t)for(const c of l){const{type:u,target:f}=c;if(u==="childList"&&f instanceof HTMLElement&&f.contains(t)){a();break}}}}),o=fM({callback:a});return rl(()=>{a(),t?(o?.observe(t),s?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),s?.disconnect())},[t]),i}function N6e(t){const e=RJ(t);return SJ(t,e)}const K$=[];function R6e(t){const e=A.useRef(t),n=hv(i=>t?i&&i!==K$&&t&&e.current&&t.parentNode===e.current.parentNode?i:dM(t):K$,[t]);return A.useEffect(()=>{e.current=t},[t]),n}function P6e(t){const[e,n]=A.useState(null),i=A.useRef(t),r=A.useCallback(a=>{const s=aN(a.target);s&&n(o=>o?(o.set(s,hP(s)),new Map(o)):null)},[]);return A.useEffect(()=>{const a=i.current;if(t!==a){s(a);const o=t.map(l=>{const c=aN(l);return c?(c.addEventListener("scroll",r,{passive:!0}),[c,hP(c)]):null}).filter(l=>l!=null);n(o.length?new Map(o):null),i.current=t}return()=>{s(t),s(a)};function s(o){o.forEach(l=>{const c=aN(l);c?.removeEventListener("scroll",r)})}},[r,t]),A.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,s)=>Ip(a,s),wo):CJ(t):wo,[t,e])}function Y$(t,e){e===void 0&&(e=[]);const n=A.useRef(null);return A.useEffect(()=>{n.current=null},e),A.useEffect(()=>{const i=t!==wo;i&&!n.current&&(n.current=t),!i&&n.current&&(n.current=null)},[t]),n.current?M0(t,n.current):wo}function k6e(t){A.useEffect(()=>{if(!uM)return;const e=t.map(n=>{let{sensor:i}=n;return i.setup==null?void 0:i.setup()});return()=>{for(const n of e)n?.()}},t.map(e=>{let{sensor:n}=e;return n}))}function D6e(t,e){return A.useMemo(()=>t.reduce((n,i)=>{let{eventName:r,handler:a}=i;return n[r]=s=>{a(s,e)},n},{}),[t,e])}function PJ(t){return A.useMemo(()=>t?i6e(t):null,[t])}const Z$=[];function O6e(t,e){e===void 0&&(e=jm);const[n]=t,i=PJ(n?$a(n):null),[r,a]=A.useState(Z$);function s(){a(()=>t.length?t.map(l=>AJ(l)?i:new JO(e(l),l)):Z$)}const o=fM({callback:s});return rl(()=>{o?.disconnect(),s(),t.forEach(l=>o?.observe(l))},[t]),r}function L6e(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return fv(e)?e:t}function I6e(t){let{measure:e}=t;const[n,i]=A.useState(null),r=A.useCallback(c=>{for(const{target:u}of c)if(fv(u)){i(f=>{const m=e(u);return f?{...f,width:m.width,height:m.height}:m});break}},[e]),a=fM({callback:r}),s=A.useCallback(c=>{const u=L6e(c);a?.disconnect(),u&&a?.observe(u),i(u?e(u):null)},[e,a]),[o,l]=IS(s);return A.useMemo(()=>({nodeRef:o,rect:n,setRef:l}),[n,o,l])}const j6e=[{sensor:nL,options:{}},{sensor:eL,options:{}}],U6e={current:{}},C_={draggable:{measure:V$},droppable:{measure:V$,strategy:A0.WhileDragging,frequency:mP.Optimized},dragOverlay:{measure:jm}};class kx extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,i;return(n=(i=this.get(e))==null?void 0:i.node.current)!=null?n:void 0}}const F6e={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new kx,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:jS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:C_,measureDroppableContainers:jS,windowRect:null,measuringScheduled:!1},z6e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:jS,draggableNodes:new Map,over:null,measureDroppableContainers:jS},hM=A.createContext(z6e),kJ=A.createContext(F6e);function B6e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new kx}}}function H6e(t,e){switch(e.type){case nr.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case nr.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case nr.DragEnd:case nr.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case nr.RegisterDroppable:{const{element:n}=e,{id:i}=n,r=new kx(t.droppable.containers);return r.set(i,n),{...t,droppable:{...t.droppable,containers:r}}}case nr.SetDroppableDisabled:{const{id:n,key:i,disabled:r}=e,a=t.droppable.containers.get(n);if(!a||i!==a.key)return t;const s=new kx(t.droppable.containers);return s.set(n,{...a,disabled:r}),{...t,droppable:{...t.droppable,containers:s}}}case nr.UnregisterDroppable:{const{id:n,key:i}=e,r=t.droppable.containers.get(n);if(!r||i!==r.key)return t;const a=new kx(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function V6e(t){let{disabled:e}=t;const{active:n,activatorEvent:i,draggableNodes:r}=A.useContext(hM),a=dP(i),s=dP(n?.id);return A.useEffect(()=>{if(!e&&!i&&a&&s!=null){if(!QO(a)||document.activeElement===a.target)return;const o=r.get(s);if(!o)return;const{activatorNode:l,node:c}=o;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const f=L8e(u);if(f){f.focus();break}}})}},[i,e,r,s,a]),null}function $6e(t,e){let{transform:n,...i}=e;return t!=null&&t.length?t.reduce((r,a)=>a({transform:r,...i}),n):n}function G6e(t){return A.useMemo(()=>({draggable:{...C_.draggable,...t?.draggable},droppable:{...C_.droppable,...t?.droppable},dragOverlay:{...C_.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function W6e(t){let{activeNode:e,measure:n,initialRect:i,config:r=!0}=t;const a=A.useRef(!1),{x:s,y:o}=typeof r=="boolean"?{x:r,y:r}:r;rl(()=>{if(!s&&!o||!e){a.current=!1;return}if(a.current||!i)return;const c=e?.node.current;if(!c||c.isConnected===!1)return;const u=n(c),f=SJ(u,i);if(s||(f.x=0),o||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const m=wJ(c);m&&m.scrollBy({top:f.y,left:f.x})}},[e,s,o,i,n])}const DJ=A.createContext({...wo,scaleX:1,scaleY:1});var Mu;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Mu||(Mu={}));const q6e=A.memo(function(e){var n,i,r,a;let{id:s,accessibility:o,autoScroll:l=!0,children:c,sensors:u=j6e,collisionDetection:f=Y8e,measuring:m,modifiers:g,...b}=e;const y=A.useReducer(H6e,void 0,B6e),[v,x]=y,[M,w]=B8e(),[E,T]=A.useState(Mu.Uninitialized),R=E===Mu.Initialized,{draggable:{active:N,nodes:j,translate:C},droppable:{containers:k}}=v,F=N!=null?j.get(N):null,I=A.useRef({initial:null,translated:null}),q=A.useMemo(()=>{var Oe;return N!=null?{id:N,data:(Oe=F?.data)!=null?Oe:U6e,rect:I}:null},[N,F]),O=A.useRef(null),[H,V]=A.useState(null),[$,K]=A.useState(null),Y=w0(b,Object.values(b)),se=pv("DndDescribedBy",s),B=A.useMemo(()=>k.getEnabled(),[k]),X=G6e(m),{droppableRects:ae,measureDroppableContainers:ce,measuringScheduled:xe}=E6e(B,{dragging:R,dependencies:[C.x,C.y],config:X.droppable}),ie=w6e(j,N),ve=A.useMemo(()=>$?fP($):null,[$]),Pe=fe(),pe=A6e(ie,X.draggable.measure);W6e({activeNode:N!=null?j.get(N):null,config:Pe.layoutShiftCompensation,initialRect:pe,measure:X.draggable.measure});const we=X$(ie,X.draggable.measure,pe),ze=X$(ie?ie.parentElement:null),ue=A.useRef({activatorEvent:null,active:null,activeNode:ie,collisionRect:null,collisions:null,droppableRects:ae,draggableNodes:j,draggingNode:null,draggingNodeRect:null,droppableContainers:k,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ht=k.getNodeFor((n=ue.current.over)==null?void 0:n.id),z=I6e({measure:X.dragOverlay.measure}),W=(i=z.nodeRef.current)!=null?i:ie,re=R?(r=z.rect)!=null?r:we:null,J=!!(z.nodeRef.current&&z.rect),ee=N6e(J?null:we),oe=PJ(W?$a(W):null),ke=R6e(R?ht??ie:null),Ne=O6e(ke),te=$6e(g,{transform:{x:C.x-ee.x,y:C.y-ee.y,scaleX:1,scaleY:1},activatorEvent:$,active:q,activeNodeRect:we,containerNodeRect:ze,draggingNodeRect:re,over:ue.current.over,overlayNodeRect:z.rect,scrollableAncestors:ke,scrollableAncestorRects:Ne,windowRect:oe}),U=ve?Ip(ve,C):null,L=P6e(ke),Z=Y$(L),me=Y$(L,[we]),be=Ip(te,Z),he=re?J8e(re,te):null,Ze=q&&he?f({active:q,collisionRect:he,droppableRects:ae,droppableContainers:B,pointerCoordinates:U}):null,Le=_J(Ze,"id"),[Xe,at]=A.useState(null),Ie=J?te:Ip(te,me),Re=Z8e(Ie,(a=Xe?.rect)!=null?a:null,we),pt=A.useRef(null),tt=A.useCallback((Oe,Me)=>{let{sensor:ge,options:Be}=Me;if(O.current==null)return;const ct=j.get(O.current);if(!ct)return;const yt=Oe.nativeEvent,Rt=new ge({active:O.current,activeNode:ct,event:yt,options:Be,context:ue,onAbort(Dt){if(!j.get(Dt))return;const{onDragAbort:qn}=Y.current,pr={id:Dt};qn?.(pr),M({type:"onDragAbort",event:pr})},onPending(Dt,Rn,qn,pr){if(!j.get(Dt))return;const{onDragPending:mr}=Y.current,Rr={id:Dt,constraint:Rn,initialCoordinates:qn,offset:pr};mr?.(Rr),M({type:"onDragPending",event:Rr})},onStart(Dt){const Rn=O.current;if(Rn==null)return;const qn=j.get(Rn);if(!qn)return;const{onDragStart:pr}=Y.current,Zi={activatorEvent:yt,active:{id:Rn,data:qn.data,rect:I}};Kl.unstable_batchedUpdates(()=>{pr?.(Zi),T(Mu.Initializing),x({type:nr.DragStart,initialCoordinates:Dt,active:Rn}),M({type:"onDragStart",event:Zi}),V(pt.current),K(yt)})},onMove(Dt){x({type:nr.DragMove,coordinates:Dt})},onEnd:ln(nr.DragEnd),onCancel:ln(nr.DragCancel)});pt.current=Rt;function ln(Dt){return async function(){const{active:qn,collisions:pr,over:Zi,scrollAdjustedTranslate:mr}=ue.current;let Rr=null;if(qn&&mr){const{cancelDrop:Wr}=Y.current;Rr={activatorEvent:yt,active:qn,collisions:pr,delta:mr,over:Zi},Dt===nr.DragEnd&&typeof Wr=="function"&&await Promise.resolve(Wr(Rr))&&(Dt=nr.DragCancel)}O.current=null,Kl.unstable_batchedUpdates(()=>{x({type:Dt}),T(Mu.Uninitialized),at(null),V(null),K(null),pt.current=null;const Wr=Dt===nr.DragEnd?"onDragEnd":"onDragCancel";if(Rr){const Li=Y.current[Wr];Li?.(Rr),M({type:Wr,event:Rr})}})}}},[j]),et=A.useCallback((Oe,Me)=>(ge,Be)=>{const ct=ge.nativeEvent,yt=j.get(Be);if(O.current!==null||!yt||ct.dndKit||ct.defaultPrevented)return;const Rt={active:yt};Oe(ge,Me.options,Rt)===!0&&(ct.dndKit={capturedBy:Me.sensor},O.current=Be,tt(ge,Me))},[j,tt]),ut=M6e(u,et);k6e(u),rl(()=>{we&&E===Mu.Initializing&&T(Mu.Initialized)},[we,E]),A.useEffect(()=>{const{onDragMove:Oe}=Y.current,{active:Me,activatorEvent:ge,collisions:Be,over:ct}=ue.current;if(!Me||!ge)return;const yt={active:Me,activatorEvent:ge,collisions:Be,delta:{x:be.x,y:be.y},over:ct};Kl.unstable_batchedUpdates(()=>{Oe?.(yt),M({type:"onDragMove",event:yt})})},[be.x,be.y]),A.useEffect(()=>{const{active:Oe,activatorEvent:Me,collisions:ge,droppableContainers:Be,scrollAdjustedTranslate:ct}=ue.current;if(!Oe||O.current==null||!Me||!ct)return;const{onDragOver:yt}=Y.current,Rt=Be.get(Le),ln=Rt&&Rt.rect.current?{id:Rt.id,rect:Rt.rect.current,data:Rt.data,disabled:Rt.disabled}:null,Dt={active:Oe,activatorEvent:Me,collisions:ge,delta:{x:ct.x,y:ct.y},over:ln};Kl.unstable_batchedUpdates(()=>{at(ln),yt?.(Dt),M({type:"onDragOver",event:Dt})})},[Le]),rl(()=>{ue.current={activatorEvent:$,active:q,activeNode:ie,collisionRect:he,collisions:Ze,droppableRects:ae,draggableNodes:j,draggingNode:W,draggingNodeRect:re,droppableContainers:k,over:Xe,scrollableAncestors:ke,scrollAdjustedTranslate:be},I.current={initial:re,translated:he}},[q,ie,Ze,he,j,W,re,ae,k,Xe,ke,be]),y6e({...Pe,delta:C,draggingRect:he,pointerCoordinates:U,scrollableAncestors:ke,scrollableAncestorRects:Ne});const de=A.useMemo(()=>({active:q,activeNode:ie,activeNodeRect:we,activatorEvent:$,collisions:Ze,containerNodeRect:ze,dragOverlay:z,draggableNodes:j,droppableContainers:k,droppableRects:ae,over:Xe,measureDroppableContainers:ce,scrollableAncestors:ke,scrollableAncestorRects:Ne,measuringConfiguration:X,measuringScheduled:xe,windowRect:oe}),[q,ie,we,$,Ze,ze,z,j,k,ae,Xe,ce,ke,Ne,X,xe,oe]),nt=A.useMemo(()=>({activatorEvent:$,activators:ut,active:q,activeNodeRect:we,ariaDescribedById:{draggable:se},dispatch:x,draggableNodes:j,over:Xe,measureDroppableContainers:ce}),[$,ut,q,we,x,se,j,Xe,ce]);return ui.createElement(vJ.Provider,{value:w},ui.createElement(hM.Provider,{value:nt},ui.createElement(kJ.Provider,{value:de},ui.createElement(DJ.Provider,{value:Re},c)),ui.createElement(V6e,{disabled:o?.restoreFocus===!1})),ui.createElement($8e,{...o,hiddenTextDescribedById:se}));function fe(){const Oe=H?.autoScrollEnabled===!1,Me=typeof l=="object"?l.enabled===!1:l===!1,ge=R&&!Oe&&!Me;return typeof l=="object"?{...l,enabled:ge}:{enabled:ge}}}),X6e=A.createContext(null),Q$="button",K6e="Draggable";function Y6e(t){let{id:e,data:n,disabled:i=!1,attributes:r}=t;const a=pv(K6e),{activators:s,activatorEvent:o,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:f,over:m}=A.useContext(hM),{role:g=Q$,roleDescription:b="draggable",tabIndex:y=0}=r??{},v=l?.id===e,x=A.useContext(v?DJ:X6e),[M,w]=IS(),[E,T]=IS(),R=D6e(s,e),N=w0(n);rl(()=>(f.set(e,{id:e,key:a,node:M,activatorNode:E,data:N}),()=>{const C=f.get(e);C&&C.key===a&&f.delete(e)}),[f,e]);const j=A.useMemo(()=>({role:g,tabIndex:y,"aria-disabled":i,"aria-pressed":v&&g===Q$?!0:void 0,"aria-roledescription":b,"aria-describedby":u.draggable}),[i,g,y,v,b,u.draggable]);return{active:l,activatorEvent:o,activeNodeRect:c,attributes:j,isDragging:v,listeners:i?void 0:R,node:M,over:m,setNodeRef:w,setActivatorNodeRef:T,transform:x}}function Z6e(){return A.useContext(kJ)}const Q6e="Droppable",J6e={timeout:25};function eVe(t){let{data:e,disabled:n=!1,id:i,resizeObserverConfig:r}=t;const a=pv(Q6e),{active:s,dispatch:o,over:l,measureDroppableContainers:c}=A.useContext(hM),u=A.useRef({disabled:n}),f=A.useRef(!1),m=A.useRef(null),g=A.useRef(null),{disabled:b,updateMeasurementsFor:y,timeout:v}={...J6e,...r},x=w0(y??i),M=A.useCallback(()=>{if(!f.current){f.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{c(Array.isArray(x.current)?x.current:[x.current]),g.current=null},v)},[v]),w=fM({callback:M,disabled:b||!s}),E=A.useCallback((j,C)=>{w&&(C&&(w.unobserve(C),f.current=!1),j&&w.observe(j))},[w]),[T,R]=IS(E),N=w0(e);return A.useEffect(()=>{!w||!T.current||(w.disconnect(),f.current=!1,w.observe(T.current))},[T,w]),A.useEffect(()=>(o({type:nr.RegisterDroppable,element:{id:i,key:a,disabled:n,node:T,rect:m,data:N}}),()=>o({type:nr.UnregisterDroppable,key:a,id:i})),[i]),A.useEffect(()=>{n!==u.current.disabled&&(o({type:nr.SetDroppableDisabled,id:i,key:a,disabled:n}),u.current.disabled=n)},[i,a,n,o]),{active:s,rect:m,isOver:l?.id===i,node:T,over:l,setNodeRef:R}}function iL(t,e,n){const i=t.slice();return i.splice(n<0?i.length+n:n,0,i.splice(e,1)[0]),i}function tVe(t,e){return t.reduce((n,i,r)=>{const a=e.get(i);return a&&(n[r]=a),n},Array(t.length))}function i_(t){return t!==null&&t>=0}function nVe(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n{let{rects:e,activeIndex:n,overIndex:i,index:r}=t;const a=iL(e,i,n),s=e[r],o=a[r];return!o||!s?null:{x:o.left-s.left,y:o.top-s.top,scaleX:o.width/s.width,scaleY:o.height/s.height}},OJ="Sortable",LJ=ui.createContext({activeIndex:-1,containerId:OJ,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:rL,disabled:{draggable:!1,droppable:!1}});function rVe(t){let{children:e,id:n,items:i,strategy:r=rL,disabled:a=!1}=t;const{active:s,dragOverlay:o,droppableRects:l,over:c,measureDroppableContainers:u}=Z6e(),f=pv(OJ,n),m=o.rect!==null,g=A.useMemo(()=>i.map(R=>typeof R=="object"&&"id"in R?R.id:R),[i]),b=s!=null,y=s?g.indexOf(s.id):-1,v=c?g.indexOf(c.id):-1,x=A.useRef(g),M=!nVe(g,x.current),w=v!==-1&&y===-1||M,E=iVe(a);rl(()=>{M&&b&&u(g)},[M,g,b,u]),A.useEffect(()=>{x.current=g},[g]);const T=A.useMemo(()=>({activeIndex:y,containerId:f,disabled:E,disableTransforms:w,items:g,overIndex:v,useDragOverlay:m,sortedRects:tVe(g,l),strategy:r}),[y,f,E.draggable,E.droppable,w,g,v,l,m,r]);return ui.createElement(LJ.Provider,{value:T},e)}const aVe=t=>{let{id:e,items:n,activeIndex:i,overIndex:r}=t;return iL(n,i,r).indexOf(e)},sVe=t=>{let{containerId:e,isSorting:n,wasDragging:i,index:r,items:a,newIndex:s,previousItems:o,previousContainerId:l,transition:c}=t;return!c||!i||o!==a&&r===s?!1:n?!0:s!==r&&e===l},oVe={duration:200,easing:"ease"},IJ="transform",lVe=E0.Transition.toString({property:IJ,duration:0,easing:"linear"}),cVe={roleDescription:"sortable"};function uVe(t){let{disabled:e,index:n,node:i,rect:r}=t;const[a,s]=A.useState(null),o=A.useRef(n);return rl(()=>{if(!e&&n!==o.current&&i.current){const l=r.current;if(l){const c=jm(i.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&s(u)}}n!==o.current&&(o.current=n)},[e,n,i,r]),A.useEffect(()=>{a&&s(null)},[a]),a}function dVe(t){let{animateLayoutChanges:e=sVe,attributes:n,disabled:i,data:r,getNewIndex:a=aVe,id:s,strategy:o,resizeObserverConfig:l,transition:c=oVe}=t;const{items:u,containerId:f,activeIndex:m,disabled:g,disableTransforms:b,sortedRects:y,overIndex:v,useDragOverlay:x,strategy:M}=A.useContext(LJ),w=fVe(i,g),E=u.indexOf(s),T=A.useMemo(()=>({sortable:{containerId:f,index:E,items:u},...r}),[f,r,E,u]),R=A.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:N,node:j,isOver:C,setNodeRef:k}=eVe({id:s,data:T,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:R,...l}}),{active:F,activatorEvent:I,activeNodeRect:q,attributes:O,setNodeRef:H,listeners:V,isDragging:$,over:K,setActivatorNodeRef:Y,transform:se}=Y6e({id:s,data:T,attributes:{...cVe,...n},disabled:w.draggable}),B=P8e(k,H),X=!!F,ae=X&&!b&&i_(m)&&i_(v),ce=!x&&$,xe=ce&&ae?se:null,ve=ae?xe??(o??M)({rects:y,activeNodeRect:q,activeIndex:m,overIndex:v,index:E}):null,Pe=i_(m)&&i_(v)?a({id:s,items:u,activeIndex:m,overIndex:v}):E,pe=F?.id,we=A.useRef({activeId:pe,items:u,newIndex:Pe,containerId:f}),ze=u!==we.current.items,ue=e({active:F,containerId:f,isDragging:$,isSorting:X,id:s,index:E,items:u,newIndex:we.current.newIndex,previousItems:we.current.items,previousContainerId:we.current.containerId,transition:c,wasDragging:we.current.activeId!=null}),ht=uVe({disabled:!ue,index:E,node:j,rect:N});return A.useEffect(()=>{X&&we.current.newIndex!==Pe&&(we.current.newIndex=Pe),f!==we.current.containerId&&(we.current.containerId=f),u!==we.current.items&&(we.current.items=u)},[X,Pe,f,u]),A.useEffect(()=>{if(pe===we.current.activeId)return;if(pe!=null&&we.current.activeId==null){we.current.activeId=pe;return}const W=setTimeout(()=>{we.current.activeId=pe},50);return()=>clearTimeout(W)},[pe]),{active:F,activeIndex:m,attributes:O,data:T,rect:N,index:E,newIndex:Pe,items:u,isOver:C,isSorting:X,isDragging:$,listeners:V,node:j,overIndex:v,over:K,setNodeRef:B,setActivatorNodeRef:Y,setDroppableNodeRef:k,setDraggableNodeRef:H,transform:ht??ve,transition:z()};function z(){if(ht||ze&&we.current.newIndex===E)return lVe;if(!(ce&&!QO(I)||!c)&&(X||ue))return E0.Transition.toString({...c,property:IJ})}}function fVe(t,e){var n,i;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t?.draggable)!=null?n:e.draggable,droppable:(i=t?.droppable)!=null?i:e.droppable}}function FS(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const hVe=[yn.Down,yn.Right,yn.Up,yn.Left],pVe=(t,e)=>{let{context:{active:n,collisionRect:i,droppableRects:r,droppableContainers:a,over:s,scrollableAncestors:o}}=e;if(hVe.includes(t.code)){if(t.preventDefault(),!n||!i)return;const l=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const m=r.get(f.id);if(m)switch(t.code){case yn.Down:i.topm.top&&l.push(f);break;case yn.Left:i.left>m.left&&l.push(f);break;case yn.Right:i.left1&&(u=c[1].id),u!=null){const f=a.get(n.id),m=a.get(u),g=m?r.get(m.id):null,b=m?.node.current;if(b&&g&&f&&m){const v=dM(b).some((R,N)=>o[N]!==R),x=jJ(f,m),M=mVe(f,m),w=v||!x?{x:0,y:0}:{x:M?i.width-g.width:0,y:M?i.height-g.height:0},E={x:g.left,y:g.top};return w.x&&w.y?E:M0(E,w)}}}};function jJ(t,e){return!FS(t)||!FS(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function mVe(t,e){return!FS(t)||!FS(e)||!jJ(t,e)?!1:t.data.current.sortable.index{const v={};return t.forEach(x=>{v[x.id]=x.defaultSize||4}),v},[r,a]=A.useState(()=>{const v=localStorage.getItem(e);if(v)try{const x=JSON.parse(v);return x.sizes||(x.sizes=i()),x}catch{}return{order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:i()}}),[s,o]=A.useState(!1);A.useEffect(()=>{localStorage.setItem(e,JSON.stringify(r))},[r,e]),A.useEffect(()=>{const x=t.map(M=>M.id).filter(M=>!r.order.includes(M));x.length>0&&a(M=>({...M,order:[...M.order,...x]}))},[t,r.order]);const l=G8e(z$(nL,{activationConstraint:{distance:8}}),z$(eL,{coordinateGetter:pVe})),c=v=>{const{active:x,over:M}=v;M&&x.id!==M.id&&a(w=>{const E=w.order.indexOf(x.id),T=w.order.indexOf(M.id);return{...w,order:iL(w.order,E,T)}})},u=v=>{a(x=>({...x,hidden:x.hidden.includes(v)?x.hidden.filter(M=>M!==v):[...x.hidden,v]}))},f=v=>{a(x=>{const M=x.sizes[v]||4,w=M===1?2:M===2?4:1;return{...x,sizes:{...x.sizes,[v]:w}}})},m=()=>{const v={order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:i()};a(v)},g=r.order.map(v=>t.find(x=>x.id===v)).filter(Boolean),b=g.filter(v=>!r.hidden.includes(v.id)),y=g.filter(v=>r.hidden.includes(v.id));return p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"flex items-center justify-end gap-2",children:[y.length>0&&p.jsxs(lt,{variant:"secondary",size:"sm",onClick:()=>o(!s),children:[p.jsx(U4,{className:"w-4 h-4"}),y.length," Hidden"]}),p.jsxs(lt,{variant:"secondary",size:"sm",onClick:m,children:[p.jsx(XS,{className:"w-4 h-4"}),"Reset Layout"]})]}),s&&y.length>0&&p.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[p.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),p.jsx("div",{className:"flex flex-wrap gap-2",children:y.map(v=>p.jsxs("button",{onClick:()=>u(v.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[p.jsx(U4,{className:"w-3 h-3"}),v.title]},v.id))})]}),p.jsx(q6e,{sensors:l,collisionDetection:q8e,onDragEnd:c,children:p.jsx(rVe,{items:b.map(v=>v.id),strategy:rL,children:p.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:b.map(v=>p.jsx(gVe,{id:v.id,title:v.title,isHidden:r.hidden.includes(v.id),size:r.sizes[v.id]||2,onToggleVisibility:()=>u(v.id),onToggleSize:()=>f(v.id),children:v.component},v.id))})})}),b.length===0&&p.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[p.jsx("p",{children:"All widgets are hidden."}),p.jsx(lt,{className:"mt-4",onClick:m,children:"Reset Layout"})]})]})}function vVe({stats:t,currency:e}){return p.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:p.jsx(F_,{className:"w-5 h-5"})}),p.jsxs("div",{children:[p.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),p.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:p.jsx(xa,{className:"w-5 h-5"})}),p.jsxs("div",{children:[p.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),p.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:p.jsx(F_,{className:"w-5 h-5"})}),p.jsxs("div",{children:[p.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),p.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:p.jsx(j4,{className:"w-5 h-5"})}),p.jsxs("div",{children:[p.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),p.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:p.jsx(r9,{className:"w-5 h-5"})}),p.jsxs("div",{children:[p.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),p.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:p.jsx(j4,{className:"w-5 h-5"})}),p.jsxs("div",{children:[p.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),p.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function bVe({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return p.jsxs("div",{className:"flex items-center gap-6",children:[p.jsxs("div",{className:"relative w-28 h-28",children:[p.jsxs("svg",{className:"w-full h-full -rotate-90",children:[p.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),p.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),p.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:p.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(rd,{className:"w-4 h-4 text-bambu-green"}),p.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),p.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(R0,{className:"w-4 h-4 text-red-400"}),p.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),p.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function yVe({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return p.jsx("div",{className:"flex items-center justify-center h-full",children:p.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const r=(Math.min(150,Math.max(50,n))-50)/100*100,s=(l=>l>=95&&l<=105?"#00ae42":l>105?"#3b82f6":"#f97316")(n),o=n-100;return p.jsxs("div",{className:"flex items-center gap-6",children:[p.jsxs("div",{className:"relative w-28 h-28",children:[p.jsxs("svg",{className:"w-full h-full -rotate-90",children:[p.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),p.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:s,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${r*3.02} 302`})]}),p.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[p.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),p.jsxs("span",{className:`text-xs ${o>=0?"text-blue-400":"text-orange-400"}`,children:[o>=0?"+":"",o.toFixed(0),"%"]})]})]}),p.jsxs("div",{className:"space-y-2 flex-1",children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[p.jsx($oe,{className:"w-3 h-3"}),p.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&p.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([l,c])=>p.jsxs("div",{className:"flex items-center justify-between text-xs",children:[p.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(l)||`Printer ${l}`}),p.jsxs("span",{className:`font-medium ${c>=95&&c<=105?"text-bambu-green":c>105?"text-blue-400":"text-orange-400"}`,children:[c.toFixed(0),"%"]})]},l))})]})]})}function _Ve({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return p.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No filament data available"});const e=Object.entries(t.prints_by_filament_type).sort(([,n],[,i])=>i-n);return p.jsx("div",{className:"space-y-3",children:e.map(([n,i])=>{const r=Math.round(i/(t.total_prints||1)*100);return p.jsxs("div",{children:[p.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[p.jsx("span",{className:"text-white",children:n}),p.jsxs("span",{className:"text-bambu-gray",children:[i," prints"]})]}),p.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:p.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${r}%`}})})]},n)})})}function SVe({printDates:t}){return p.jsx(w2e,{printDates:t,months:4})}function wVe({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?p.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):p.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,i])=>p.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[p.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:p.jsx(hc,{className:"w-4 h-4 text-bambu-green"})}),p.jsxs("div",{children:[p.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),p.jsxs("p",{className:"text-xs text-bambu-gray",children:[i," prints"]})]})]},n))})}function MVe({archives:t,currency:e}){return!t||t.length===0?p.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):p.jsx(R8e,{archives:t,currency:e})}function EVe(){const{data:t,isLoading:e}=Ht({queryKey:["archiveStats"],queryFn:$e.getArchiveStats}),{data:n}=Ht({queryKey:["printers"],queryFn:$e.getPrinters}),{data:i}=Ht({queryKey:["archives"],queryFn:()=>$e.getArchives(void 0,1e3,0)}),{data:r}=Ht({queryKey:["settings"],queryFn:$e.getSettings}),a=r?.currency||"$",s=new Map(n?.map(c=>[String(c.id),c.name])||[]),o=i?.map(c=>c.created_at)||[];if(e)return p.jsx("div",{className:"p-8",children:p.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const l=[{id:"quick-stats",title:"Quick Stats",component:p.jsx(vVe,{stats:t,currency:a}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:p.jsx(bVe,{stats:t}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:p.jsx(yVe,{stats:t,printerMap:s}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:p.jsx(_Ve,{stats:t}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:p.jsx(SVe,{printDates:o}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:p.jsx(wVe,{stats:t,printerMap:s}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:p.jsx(MVe,{archives:i||[],currency:a}),defaultSize:4}];return p.jsxs("div",{className:"p-8",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),p.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),p.jsx(xVe,{widgets:l,storageKey:"bambusy-dashboard-layout"})]})}function AVe({plug:t,onEdit:e}){const n=Gn(),[i,r]=A.useState(!1),[a,s]=A.useState(!1),[o,l]=A.useState(!1),[c,u]=A.useState(!1),{data:f,isLoading:m,refetch:g}=Ht({queryKey:["smart-plug-status",t.id],queryFn:()=>$e.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:b}=Ht({queryKey:["printers"],queryFn:$e.getPrinters}),y=b?.find(R=>R.id===t.printer_id),v=Mt({mutationFn:R=>$e.controlSmartPlug(t.id,R),onSuccess:()=>{g()}}),x=Mt({mutationFn:R=>$e.updateSmartPlug(t.id,R),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),M=Mt({mutationFn:()=>$e.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=f?.state==="ON",E=f?.reachable??!1,T=v.isPending;return p.jsxs(p.Fragment,{children:[p.jsx(Xt,{className:"relative",children:p.jsxs(en,{className:"p-4",children:[p.jsxs("div",{className:"flex items-start justify-between mb-3",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`p-2 rounded-lg ${E?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:p.jsx(EN,{className:`w-5 h-5 ${E?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),p.jsxs("div",{children:[p.jsx("h3",{className:"font-medium text-white",children:t.name}),p.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),p.jsx("div",{className:"flex items-center gap-2",children:m?p.jsx(It,{className:"w-4 h-4 text-bambu-gray animate-spin"}):E?p.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[p.jsx(OP,{className:"w-4 h-4 text-bambu-green"}),p.jsx("span",{className:w?"text-bambu-green":"text-bambu-gray",children:f?.state||"Unknown"})]}):p.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[p.jsx(Fp,{className:"w-4 h-4"}),p.jsx("span",{children:"Offline"})]})})]}),y&&p.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[p.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),p.jsx("span",{className:"text-sm text-white",children:y.name})]}),p.jsxs("div",{className:"flex gap-2 mb-3",children:[p.jsxs(lt,{size:"sm",variant:w?"primary":"secondary",disabled:!E||T,onClick:()=>s(!0),className:"flex-1",children:[T?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(qS,{className:"w-4 h-4"}),"On"]}),p.jsxs(lt,{size:"sm",variant:w?"secondary":"primary",disabled:!E||T,onClick:()=>l(!0),className:"flex-1",children:[T?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(e9,{className:"w-4 h-4"}),"Off"]})]}),p.jsxs("button",{onClick:()=>u(!c),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx(DP,{className:"w-4 h-4"}),"Automation Settings"]}),p.jsx("span",{children:c?"-":"+"})]}),c&&p.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-sm text-white",children:"Enabled"}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),p.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:t.enabled,onChange:R=>x.mutate({enabled:R.target.checked}),className:"sr-only peer"}),p.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-sm text-white",children:"Auto On"}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),p.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:R=>x.mutate({auto_on:R.target.checked}),className:"sr-only peer"}),p.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),p.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:R=>x.mutate({auto_off:R.target.checked}),className:"sr-only peer"}),p.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&p.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),p.jsxs("div",{className:"flex gap-2",children:[p.jsxs("button",{onClick:()=>x.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[p.jsx(xa,{className:"w-4 h-4"}),"Time"]}),p.jsxs("button",{onClick:()=>x.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[p.jsx(o_,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?p.jsxs("div",{children:[p.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),p.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:R=>x.mutate({off_delay_minutes:parseInt(R.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):p.jsxs("div",{children:[p.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),p.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:R=>x.mutate({off_temp_threshold:parseInt(R.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),p.jsxs("div",{className:"flex gap-2 pt-2",children:[p.jsxs(lt,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[p.jsx(JG,{className:"w-4 h-4"}),"Edit"]}),p.jsx(lt,{size:"sm",variant:"secondary",onClick:()=>r(!0),className:"text-red-400 hover:text-red-300",children:p.jsx(ia,{className:"w-4 h-4"})})]})]})]})}),i&&p.jsx(rr,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{M.mutate(),r(!1)},onCancel:()=>r(!1)}),a&&p.jsx(rr,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{v.mutate("on"),s(!1)},onCancel:()=>s(!1)}),o&&p.jsx(rr,{title:"Turn Off Smart Plug",message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:"Turn Off",variant:"danger",onConfirm:()=>{v.mutate("off"),l(!1)},onCancel:()=>l(!1)})]})}function TVe({plug:t,onClose:e}){const n=Gn(),i=!!t,[r,a]=A.useState(t?.name||""),[s,o]=A.useState(t?.ip_address||""),[l,c]=A.useState(t?.username||""),[u,f]=A.useState(t?.password||""),[m,g]=A.useState(t?.printer_id||null),[b,y]=A.useState(null),[v,x]=A.useState(null),{data:M}=Ht({queryKey:["printers"],queryFn:$e.getPrinters}),{data:w}=Ht({queryKey:["smart-plugs"],queryFn:$e.getSmartPlugs});A.useEffect(()=>{const k=F=>{F.key==="Escape"&&e()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[e]);const E=Mt({mutationFn:()=>$e.testSmartPlugConnection(s,l||null,u||null),onSuccess:k=>{y(k),x(null),!r&&k.device_name&&a(k.device_name)},onError:k=>{y(null),x(k.message)}}),T=Mt({mutationFn:k=>$e.createSmartPlug(k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:k=>{x(k.message)}}),R=Mt({mutationFn:k=>$e.updateSmartPlug(t.id,k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:k=>{x(k.message)}}),N=M?.filter(k=>!w?.some(I=>I.printer_id===k.id&&I.id!==t?.id)),j=k=>{if(k.preventDefault(),x(null),!r.trim()){x("Name is required");return}if(!s.trim()){x("IP address is required");return}const F={name:r.trim(),ip_address:s.trim(),username:l.trim()||null,password:u.trim()||null,printer_id:m};i?R.mutate(F):T.mutate(F)},C=T.isPending||R.isPending;return p.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:p.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:k=>k.stopPropagation(),children:[p.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[p.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Smart Plug":"Add Smart Plug"}),p.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:p.jsx(Sn,{className:"w-5 h-5"})})]}),p.jsxs("form",{onSubmit:j,className:"p-6 space-y-4",children:[v&&p.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:v}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{type:"text",value:s,onChange:k=>{o(k.target.value),y(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),p.jsxs(lt,{type:"button",variant:"secondary",onClick:()=>E.mutate(),disabled:!s.trim()||E.isPending,children:[E.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(OP,{className:"w-4 h-4"}),"Test"]})]})]}),b&&p.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${b.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:b.success?p.jsxs(p.Fragment,{children:[p.jsx(rd,{className:"w-5 h-5"}),p.jsxs("div",{children:[p.jsx("p",{className:"font-medium",children:"Connected!"}),p.jsxs("p",{className:"text-sm opacity-80",children:[b.device_name&&`Device: ${b.device_name} - `,"State: ",b.state]})]})]}):p.jsxs(p.Fragment,{children:[p.jsx(Fp,{className:"w-5 h-5"}),p.jsx("span",{children:"Connection failed"})]})}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),p.jsx("input",{type:"text",value:r,onChange:k=>a(k.target.value),placeholder:"Living Room Plug",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"})]}),p.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),p.jsx("input",{type:"text",value:l,onChange:k=>c(k.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),p.jsx("input",{type:"password",value:u,onChange:k=>f(k.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),p.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),p.jsxs("select",{value:m??"",onChange:k=>g(k.target.value?Number(k.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[p.jsx("option",{value:"",children:"No printer (manual control only)"}),N?.map(k=>p.jsx("option",{value:k.id,children:k.name},k.id))]}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),p.jsxs("div",{className:"flex gap-3 pt-2",children:[p.jsx(lt,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),p.jsxs(lt,{type:"submit",disabled:C,className:"flex-1",children:[C?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(P0,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function ns({checked:t,onChange:e,disabled:n}){const i=r=>{r.preventDefault(),r.stopPropagation(),n||e(!t)};return p.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:i,className:`relative inline-flex w-9 h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:p.jsx("span",{className:`pointer-events-none absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const CVe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email"};function NVe({provider:t,onEdit:e}){const n=Gn(),[i,r]=A.useState(!1),[a,s]=A.useState(!1),[o,l]=A.useState(null),{data:c}=Ht({queryKey:["printers"],queryFn:$e.getPrinters}),u=c?.find(y=>y.id===t.printer_id),f=Mt({mutationFn:y=>$e.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=Mt({mutationFn:()=>$e.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=Mt({mutationFn:()=>$e.testNotificationProvider(t.id),onSuccess:y=>{l(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{l({success:!1,message:y.message})}}),b=y=>y||"";return p.jsxs(p.Fragment,{children:[p.jsx(Xt,{className:"relative",children:p.jsxs(en,{className:"p-4",children:[p.jsxs("div",{className:"flex items-start justify-between mb-3",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:p.jsx(SN,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),p.jsxs("div",{children:[p.jsx("h3",{className:"font-medium text-white",children:t.name}),p.jsx("p",{className:"text-sm text-bambu-gray",children:CVe[t.provider_type]||t.provider_type})]})]}),p.jsxs("div",{className:"flex items-center gap-2",children:[t.last_success&&p.jsxs("span",{className:"text-xs text-bambu-green",children:["Last sent: ",new Date(t.last_success).toLocaleDateString()]}),t.last_error&&p.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"})]})]}),u&&p.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[p.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),p.jsx("span",{className:"text-sm text-white",children:u.name})]}),!u&&!t.printer_id&&p.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:p.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),p.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&p.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&p.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&p.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&p.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&p.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&p.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&p.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Error"}),t.on_filament_low&&p.jsx("span",{className:"px-2 py-0.5 bg-amber-500/20 text-amber-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&p.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.quiet_hours_enabled&&p.jsxs("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded flex items-center gap-1",children:[p.jsx(U_,{className:"w-3 h-3"}),"Quiet"]})]}),p.jsx("div",{className:"mb-3",children:p.jsxs(lt,{size:"sm",variant:"secondary",disabled:g.isPending,onClick:()=>{l(null),g.mutate()},className:"w-full",children:[g.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(t9,{className:"w-4 h-4"}),"Send Test Notification"]})}),o&&p.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${o.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[o.success?p.jsx(rd,{className:"w-4 h-4"}):p.jsx(R0,{className:"w-4 h-4"}),p.jsx("span",{children:o.message})]}),p.jsxs("button",{onClick:()=>s(!a),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx(DP,{className:"w-4 h-4"}),"Event Settings"]}),a?p.jsx(CP,{className:"w-4 h-4"}):p.jsx(gm,{className:"w-4 h-4"})]}),a&&p.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-sm text-white",children:"Enabled"}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),p.jsx(ns,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("p",{className:"text-sm text-white",children:"Print Started"}),p.jsx(ns,{checked:t.on_print_start,onChange:y=>f.mutate({on_print_start:y})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),p.jsx(ns,{checked:t.on_print_complete,onChange:y=>f.mutate({on_print_complete:y})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),p.jsx(ns,{checked:t.on_print_failed,onChange:y=>f.mutate({on_print_failed:y})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),p.jsx(ns,{checked:t.on_print_stopped,onChange:y=>f.mutate({on_print_stopped:y})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),p.jsx(ns,{checked:t.on_print_progress,onChange:y=>f.mutate({on_print_progress:y})})]})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),p.jsx(ns,{checked:t.on_printer_offline,onChange:y=>f.mutate({on_printer_offline:y})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),p.jsx(ns,{checked:t.on_printer_error,onChange:y=>f.mutate({on_printer_error:y})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),p.jsx(ns,{checked:t.on_filament_low,onChange:y=>f.mutate({on_filament_low:y})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),p.jsx(ns,{checked:t.on_maintenance_due??!1,onChange:y=>f.mutate({on_maintenance_due:y})})]})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(U_,{className:"w-4 h-4 text-purple-400"}),p.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),p.jsx(ns,{checked:t.quiet_hours_enabled,onChange:y=>f.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&p.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[p.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(xa,{className:"w-4 h-4 text-bambu-gray"}),p.jsxs("span",{className:"text-sm text-white",children:[b(t.quiet_hours_start)||"22:00"," - ",b(t.quiet_hours_end)||"07:00"]})]}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),p.jsxs("div",{className:"flex gap-2 pt-2",children:[p.jsxs(lt,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[p.jsx(JG,{className:"w-4 h-4"}),"Edit"]}),p.jsx(lt,{size:"sm",variant:"secondary",onClick:()=>r(!0),className:"text-red-400 hover:text-red-300",children:p.jsx(ia,{className:"w-4 h-4"})})]})]})]})}),i&&p.jsx(rr,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{m.mutate(),r(!1)},onCancel:()=>r(!1)})]})}const J$=[{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"email",label:"Email",description:"SMTP email notifications"}];function RVe({provider:t,onClose:e}){const n=Gn(),i=!!t,[r,a]=A.useState(t?.name||""),[s,o]=A.useState(t?.provider_type||"ntfy"),[l,c]=A.useState(t?.printer_id||null),[u,f]=A.useState(t?.quiet_hours_enabled||!1),[m,g]=A.useState(t?.quiet_hours_start||"22:00"),[b,y]=A.useState(t?.quiet_hours_end||"07:00"),[v,x]=A.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([H,V])=>[H,String(V)])):{}),[M,w]=A.useState(null),[E,T]=A.useState(null),{data:R}=Ht({queryKey:["printers"],queryFn:$e.getPrinters});A.useEffect(()=>{const H=V=>{V.key==="Escape"&&e()};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[e]);const N=Mt({mutationFn:()=>$e.testNotificationConfig({provider_type:s,config:v}),onSuccess:H=>{w(H),T(null)},onError:H=>{w({success:!1,message:H.message})}}),j=Mt({mutationFn:H=>$e.createNotificationProvider(H),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:H=>{T(H.message)}}),C=Mt({mutationFn:H=>$e.updateNotificationProvider(t.id,H),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:H=>{T(H.message)}}),k=H=>{if(H.preventDefault(),T(null),!r.trim()){T("Name is required");return}const V=q(s);for(const K of V)if(!v[K.key]?.trim()){T(`${K.label} is required`);return}const $={name:r.trim(),provider_type:s,config:v,printer_id:l,quiet_hours_enabled:u,quiet_hours_start:u?m:null,quiet_hours_end:u?b:null};i?C.mutate($):j.mutate($)},F=j.isPending||C.isPending,I=H=>{switch(H){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambutrack",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];default:return[]}},q=H=>I(H).filter(V=>V.required),O=I(s);return p.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:p.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8",onClick:H=>H.stopPropagation(),children:[p.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[p.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Notification Provider":"Add Notification Provider"}),p.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:p.jsx(Sn,{className:"w-5 h-5"})})]}),p.jsxs("form",{onSubmit:k,className:"p-6 space-y-4",children:[E&&p.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:E}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),p.jsx("input",{type:"text",value:r,onChange:H=>a(H.target.value),placeholder:"My Notifications",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"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),p.jsx("select",{value:s,onChange:H=>{o(H.target.value),x({}),w(null)},disabled:i,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:J$.map(H=>p.jsx("option",{value:H.value,children:H.label},H.value))}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:J$.find(H=>H.value===s)?.description})]}),p.jsxs("div",{className:"space-y-3",children:[p.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),O.map(H=>p.jsxs("div",{children:[p.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[H.label," ",H.required&&"*"]}),H.type==="select"&&H.options?p.jsx("select",{value:v[H.key]||H.options[0]?.value||"",onChange:V=>{x({...v,[H.key]:V.target.value}),w(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:H.options.map(V=>p.jsx("option",{value:V.value,children:V.label},V.value))}):p.jsx("input",{type:H.type,value:v[H.key]||"",onChange:V=>{x({...v,[H.key]:V.target.value}),w(null)},placeholder:H.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},H.key))]}),p.jsx("div",{className:"flex gap-2",children:p.jsxs(lt,{type:"button",variant:"secondary",onClick:()=>{w(null),N.mutate()},disabled:N.isPending||!v[q(s)[0]?.key],className:"flex-1",children:[N.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(t9,{className:"w-4 h-4"}),"Test Configuration"]})}),M&&p.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${M.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:M.success?p.jsxs(p.Fragment,{children:[p.jsx(rd,{className:"w-5 h-5"}),p.jsx("span",{children:M.message})]}):p.jsxs(p.Fragment,{children:[p.jsx(R0,{className:"w-5 h-5"}),p.jsx("span",{children:M.message})]})}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),p.jsxs("select",{value:l??"",onChange:H=>c(H.target.value?Number(H.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[p.jsx("option",{value:"",children:"All printers"}),R?.map(H=>p.jsx("option",{value:H.id,children:H.name},H.id))]}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),p.jsx(ns,{checked:u,onChange:f})]}),u&&p.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[p.jsxs("div",{children:[p.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),p.jsx("input",{type:"time",value:m,onChange:H=>g(H.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"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),p.jsx("input",{type:"time",value:b,onChange:H=>y(H.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"})]})]})]}),p.jsxs("div",{className:"flex gap-3 pt-2",children:[p.jsx(lt,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),p.jsxs(lt,{type:"submit",disabled:F,className:"flex-1",children:[F?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(P0,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}async function PVe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function kVe(t){const e=await fetch("/api/v1/settings/spoolman",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw new Error("Failed to save Spoolman settings");return e.json()}function DVe(){const t=Gn(),[e,n]=A.useState(!1),[i,r]=A.useState(""),[a,s]=A.useState("auto"),[o,l]=A.useState(!1),[c,u]=A.useState(!1),[f,m]=A.useState("all"),{data:g,isLoading:b}=Ht({queryKey:["spoolman-settings"],queryFn:PVe}),{data:y,isLoading:v,refetch:x}=Ht({queryKey:["spoolman-status"],queryFn:$e.getSpoolmanStatus,refetchInterval:3e4}),{data:M}=Ht({queryKey:["printers"],queryFn:$e.getPrinters});A.useEffect(()=>{g&&(n(g.spoolman_enabled==="true"),r(g.spoolman_url||""),s(g.spoolman_sync_mode||"auto"))},[g]),A.useEffect(()=>{if(g){const I=g.spoolman_enabled==="true"!==e||(g.spoolman_url||"")!==i||(g.spoolman_sync_mode||"auto")!==a;l(I)}},[g,e,i,a]);const w=Mt({mutationFn:()=>kVe({spoolman_enabled:e?"true":"false",spoolman_url:i,spoolman_sync_mode:a}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),l(!1),u(!0),setTimeout(()=>u(!1),2e3)}}),E=Mt({mutationFn:$e.connectSpoolman,onSuccess:()=>{x()}}),T=Mt({mutationFn:$e.disconnectSpoolman,onSuccess:()=>{x()}}),R=Mt({mutationFn:$e.syncAllPrintersAms,onSuccess:I=>{I.success}}),N=Mt({mutationFn:I=>$e.syncPrinterAms(I),onSuccess:I=>{I.success}}),j=()=>{f==="all"?R.mutate():N.mutate(f)},C=R.isPending||N.isPending,k=f==="all"?R.data:N.data,F=f==="all"?R.isSuccess:N.isSuccess;return b?p.jsxs(Xt,{children:[p.jsx($l,{children:p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(I4,{className:"w-5 h-5 text-bambu-green"}),p.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),p.jsx(en,{children:p.jsx("div",{className:"flex justify-center py-8",children:p.jsx(It,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):p.jsxs(Xt,{children:[p.jsx($l,{children:p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(I4,{className:"w-5 h-5 text-bambu-green"}),p.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),o&&p.jsx(lt,{size:"sm",onClick:()=>w.mutate(),disabled:w.isPending,children:w.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):c?p.jsx(jp,{className:"w-4 h-4"}):"Save"})]})}),p.jsxs(en,{className:"space-y-4",children:[p.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-white",children:"Enable Spoolman"}),p.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),p.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:e,onChange:I=>n(I.target.checked),className:"sr-only peer"}),p.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),p.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:i,onChange:I=>r(I.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),p.jsxs("select",{value:a,onChange:I=>s(I.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[p.jsx("option",{value:"auto",children:"Automatic"}),p.jsx("option",{value:"manual",children:"Manual Only"})]}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&p.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[p.jsxs("div",{className:"flex items-center justify-between mb-3",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),v?p.jsx(It,{className:"w-4 h-4 text-bambu-gray animate-spin"}):y?.connected?p.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[p.jsx(jp,{className:"w-4 h-4"}),"Connected"]}):p.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[p.jsx(Sn,{className:"w-4 h-4"}),"Disconnected"]})]}),p.jsx("div",{className:"flex gap-2",children:y?.connected?p.jsxs(lt,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(Gse,{className:"w-4 h-4"}),"Disconnect"]}):p.jsxs(lt,{size:"sm",onClick:()=>E.mutate(),disabled:E.isPending||!i,children:[E.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(qse,{className:"w-4 h-4"}),"Connect"]})})]}),E.isError&&p.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:E.error.message}),y?.connected&&p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs("div",{className:"relative flex-1",children:[p.jsxs("select",{value:f,onChange:I=>m(I.target.value==="all"?"all":Number(I.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[p.jsx("option",{value:"all",children:"All Printers"}),M?.map(I=>p.jsx("option",{value:I.id,children:I.name},I.id))]}),p.jsx(gm,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),p.jsxs(lt,{variant:"secondary",size:"sm",onClick:j,disabled:C,children:[C?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(Yo,{className:"w-4 h-4"}),"Sync"]})]})]}),F&&k&&p.jsx("div",{className:`mt-2 p-2 rounded text-sm ${k.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:k.success?`Synced ${k.synced_count} trays successfully`:`Synced ${k.synced_count} trays with ${k.errors.length} errors`})]})]})]})}function OVe(){const t=Gn(),{t:e,i18n:n}=vP(),[i,r]=A.useState(null),[a,s]=A.useState(!1),[o,l]=A.useState(!1),[c,u]=A.useState(!1),[f,m]=A.useState(null),[g,b]=A.useState(!1),[y,v]=A.useState(null),[x,M]=A.useState(s9()),w=X=>{M(X),Tle(X)},E=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:T,isLoading:R}=Ht({queryKey:["settings"],queryFn:$e.getSettings}),{data:N,isLoading:j}=Ht({queryKey:["smart-plugs"],queryFn:$e.getSmartPlugs}),{data:C,isLoading:k}=Ht({queryKey:["notification-providers"],queryFn:$e.getNotificationProviders}),{data:F}=Ht({queryKey:["ffmpeg-status"],queryFn:$e.checkFfmpeg}),{data:I}=Ht({queryKey:["version"],queryFn:$e.getVersion}),{data:q,refetch:O,isRefetching:H}=Ht({queryKey:["updateCheck"],queryFn:$e.checkForUpdates,staleTime:300*1e3}),{data:V,refetch:$}=Ht({queryKey:["updateStatus"],queryFn:$e.getUpdateStatus,refetchInterval:X=>{const ae=X.state.data;return ae?.status==="downloading"||ae?.status==="installing"?1e3:!1}}),K=Mt({mutationFn:$e.applyUpdate,onSuccess:()=>{$()}});A.useEffect(()=>{T&&!i&&r(T)},[T,i]),A.useEffect(()=>{if(T&&i){const X=T.auto_archive!==i.auto_archive||T.save_thumbnails!==i.save_thumbnails||T.capture_finish_photo!==i.capture_finish_photo||T.default_filament_cost!==i.default_filament_cost||T.currency!==i.currency||T.energy_cost_per_kwh!==i.energy_cost_per_kwh||T.energy_tracking_mode!==i.energy_tracking_mode||T.check_updates!==i.check_updates||T.notification_language!==i.notification_language;s(X)}},[T,i]);const Y=Mt({mutationFn:$e.updateSettings,onSuccess:X=>{t.setQueryData(["settings"],X),r(X),s(!1),l(!0),setTimeout(()=>l(!1),2e3),t.invalidateQueries({queryKey:["archiveStats"]})}}),se=()=>{i&&Y.mutate(i)},B=(X,ae)=>{i&&r({...i,[X]:ae})};return R||!i?p.jsx("div",{className:"p-8 flex justify-center",children:p.jsx(It,{className:"w-8 h-8 text-bambu-green animate-spin"})}):p.jsxs("div",{className:"p-8",children:[p.jsxs("div",{className:"mb-8 flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),p.jsx("p",{className:"text-bambu-gray",children:"Configure Bambusy"})]}),p.jsxs(lt,{onClick:se,disabled:!a||Y.isPending,children:[Y.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):o?p.jsx(jp,{className:"w-4 h-4"}):p.jsx(P0,{className:"w-4 h-4"}),o?"Saved!":"Save"]})]}),Y.isError&&p.jsxs("div",{className:"mb-6 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:["Failed to save settings: ",Y.error.message]}),p.jsxs("div",{className:"flex gap-8",children:[p.jsxs("div",{className:"space-y-6 flex-1 max-w-xl",children:[p.jsxs(Xt,{children:[p.jsx($l,{children:p.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),p.jsxs(en,{className:"space-y-4",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-white",children:"Auto-archive prints"}),p.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),p.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:i.auto_archive,onChange:X=>B("auto_archive",X.target.checked),className:"sr-only peer"}),p.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-white",children:"Save thumbnails"}),p.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),p.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:i.save_thumbnails,onChange:X=>B("save_thumbnails",X.target.checked),className:"sr-only peer"}),p.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-white",children:"Capture finish photo"}),p.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),p.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:i.capture_finish_photo,onChange:X=>B("capture_finish_photo",X.target.checked),className:"sr-only peer"}),p.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.capture_finish_photo&&F&&!F.installed&&p.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[p.jsx(_o,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),p.jsxs("div",{className:"text-sm",children:[p.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),p.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",p.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",p.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]}),p.jsxs(Xt,{children:[p.jsx($l,{children:p.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),p.jsxs(en,{className:"space-y-4",children:[p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),p.jsx("input",{type:"number",step:"0.01",min:"0",value:i.default_filament_cost,onChange:X=>B("default_filament_cost",parseFloat(X.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),p.jsxs("select",{value:i.currency,onChange:X=>B("currency",X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[p.jsx("option",{value:"USD",children:"USD ($)"}),p.jsx("option",{value:"EUR",children:"EUR (€)"}),p.jsx("option",{value:"GBP",children:"GBP (£)"}),p.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),p.jsx("option",{value:"JPY",children:"JPY (¥)"}),p.jsx("option",{value:"CNY",children:"CNY (¥)"}),p.jsx("option",{value:"CAD",children:"CAD ($)"}),p.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),p.jsx("input",{type:"number",step:"0.01",min:"0",value:i.energy_cost_per_kwh,onChange:X=>B("energy_cost_per_kwh",parseFloat(X.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),p.jsxs("select",{value:i.energy_tracking_mode||"total",onChange:X=>B("energy_tracking_mode",X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[p.jsx("option",{value:"print",children:"Prints Only"}),p.jsx("option",{value:"total",children:"Total Consumption"})]}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),p.jsxs(Xt,{children:[p.jsx($l,{children:p.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),p.jsxs(en,{className:"space-y-4",children:[p.jsxs("div",{children:[p.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[p.jsx(j_,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),p.jsx("select",{value:n.language,onChange:X=>n.changeLanguage(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:g4.map(X=>p.jsxs("option",{value:X.code,children:[X.nativeName," (",X.name,")"]},X.code))}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),p.jsx("select",{value:x,onChange:X=>w(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:l_.map(X=>p.jsx("option",{value:X.to,children:e(X.labelKey)},X.id))}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-white",children:"Sidebar order"}),p.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),p.jsxs(lt,{variant:"secondary",size:"sm",onClick:E,children:[p.jsx(XS,{className:"w-4 h-4"}),"Reset"]})]})]})]})]}),p.jsxs("div",{className:"space-y-6 flex-1 max-w-md",children:[p.jsx(DVe,{}),p.jsxs(Xt,{children:[p.jsx($l,{children:p.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),p.jsxs(en,{className:"space-y-4",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-white",children:"Check for updates"}),p.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),p.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:i.check_updates,onChange:X=>B("check_updates",X.target.checked),className:"sr-only peer"}),p.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),p.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between mb-2",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-white",children:"Current version"}),p.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",I?.version||"..."]})]}),p.jsxs(lt,{variant:"secondary",size:"sm",onClick:()=>O(),disabled:H,children:[H?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(Yo,{className:"w-4 h-4"}),"Check now"]})]}),q?.update_available?p.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[p.jsxs("div",{className:"flex items-start justify-between",children:[p.jsxs("div",{children:[p.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",q.latest_version]}),q.release_name&&q.release_name!==q.latest_version&&p.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:q.release_name}),q.release_notes&&p.jsx("p",{className:"text-sm text-bambu-gray mt-2 whitespace-pre-line line-clamp-3",children:q.release_notes})]}),q.release_url&&p.jsx("a",{href:q.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:p.jsx(dc,{className:"w-4 h-4"})})]}),V?.status==="downloading"||V?.status==="installing"?p.jsxs("div",{className:"mt-3",children:[p.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[p.jsx(It,{className:"w-4 h-4 animate-spin"}),p.jsx("span",{children:V.message})]}),p.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:p.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${V.progress}%`}})})]}):V?.status==="complete"?p.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:V.message}):V?.status==="error"?p.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:V.error||V.message}):p.jsxs(lt,{className:"mt-3",onClick:()=>K.mutate(),disabled:K.isPending,children:[K.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(Gu,{className:"w-4 h-4"}),"Install Update"]})]}):q?.error?p.jsxs("div",{className:"mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400",children:["Failed to check for updates: ",q.error]}):q&&!q.update_available?p.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]})]}),p.jsx("div",{className:"w-80 flex-shrink-0",children:p.jsxs(Xt,{children:[p.jsx($l,{children:p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(EN,{className:"w-5 h-5 text-bambu-green"}),p.jsx("h2",{className:"text-lg font-semibold text-white",children:"Smart Plugs"})]}),p.jsxs(lt,{size:"sm",onClick:()=>{m(null),u(!0)},children:[p.jsx(fc,{className:"w-4 h-4"}),"Add"]})]})}),p.jsxs(en,{children:[p.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Connect Tasmota-based smart plugs to automate power control for your printers."}),j?p.jsx("div",{className:"flex justify-center py-8",children:p.jsx(It,{className:"w-6 h-6 text-bambu-green animate-spin"})}):N&&N.length>0?p.jsx("div",{className:"space-y-4",children:N.map(X=>p.jsx(AVe,{plug:X,onEdit:ae=>{m(ae),u(!0)}},X.id))}):p.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[p.jsx(EN,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),p.jsx("p",{children:"No smart plugs configured"}),p.jsx("p",{className:"text-sm mt-1",children:"Add a Tasmota plug to get started"})]})]})]})}),p.jsx("div",{className:"w-80 flex-shrink-0",children:p.jsxs(Xt,{children:[p.jsx($l,{children:p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(SN,{className:"w-5 h-5 text-bambu-green"}),p.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notifications"})]}),p.jsxs(lt,{size:"sm",onClick:()=>{v(null),b(!0)},children:[p.jsx(fc,{className:"w-4 h-4"}),"Add"]})]})}),p.jsxs(en,{children:[p.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Get notified about print events via WhatsApp, Telegram, Email, and more."}),p.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary mb-4",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-white",children:e("settings.notificationLanguage")}),p.jsx("p",{className:"text-sm text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),p.jsx("select",{value:i.notification_language||"en",onChange:X=>B("notification_language",X.target.value),className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green",children:g4.map(X=>p.jsx("option",{value:X.code,children:X.nativeName},X.code))})]}),k?p.jsx("div",{className:"flex justify-center py-8",children:p.jsx(It,{className:"w-6 h-6 text-bambu-green animate-spin"})}):C&&C.length>0?p.jsx("div",{className:"space-y-4",children:C.map(X=>p.jsx(NVe,{provider:X,onEdit:ae=>{v(ae),b(!0)}},X.id))}):p.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[p.jsx(SN,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),p.jsx("p",{children:"No notification providers configured"}),p.jsx("p",{className:"text-sm mt-1",children:"Add a provider to get started"})]})]})]})})]}),c&&p.jsx(TVe,{plug:f,onClose:()=>{u(!1),m(null)}}),g&&p.jsx(RVe,{provider:y,onClose:()=>{b(!1),v(null)}})]})}const UJ=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},LVe=t=>t.startsWith("HH")?"HF":"S",IVe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},FJ=t=>{const e=["High Flow_","High Flow ","Standard_","Standard ","HF_","HF ","S_","S "];for(const i of e)if(t.startsWith(i))return t.slice(i.length);const n=t.indexOf("_");return n>0?t.slice(n+1):t};function lN({profile:t,onEdit:e}){const n=LVe(t.nozzle_id),i=t.nozzle_diameter,r=t.name||"Unnamed",a=FJ(t.name||"");return p.jsxs("button",{onClick:e,className:"w-full text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:UJ(t.k_value)}),p.jsx("span",{className:"text-white text-sm truncate flex-1",title:r,children:r}),p.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[n," ",i]})]}),p.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 truncate",title:`Filament: ${a}`,children:["Filament: ",a||t.filament_id]})]})}function eG({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:i=[],isDualNozzle:r=!1,onClose:a,onSave:s}){const{showToast:o}=Mo(),l=Gn(),[c,u]=A.useState(t?.name||""),[f,m]=A.useState(t?.k_value?UJ(t.k_value):"0.020"),[g,b]=A.useState(t?.filament_id||""),[y,v]=A.useState(t?.nozzle_id?IVe(t.nozzle_id):"HH00"),[x,M]=A.useState(t?.nozzle_diameter||n),[w,E]=A.useState(t?[t.extruder_id]:r?[0,1]:[0]),[T,R]=A.useState(!1),[N,j]=A.useState({current:0,total:0}),C=ui.useMemo(()=>{const V=new Map;for(const $ of i)if($.filament_id&&!V.has($.filament_id)){const K=FJ($.name||"");V.set($.filament_id,{id:$.filament_id,name:K||$.filament_id})}return Array.from(V.values()).sort(($,K)=>$.name.localeCompare(K.name))},[i]),k=Mt({mutationFn:V=>(console.log("[KProfile] Calling API..."),$e.setKProfile(e,V)),onSuccess:V=>{console.log("[KProfile] Save success:",V),o("K-profile saved"),R(!0),setTimeout(()=>{l.invalidateQueries({queryKey:["kprofiles",e]}),R(!1),s()},2500)},onError:V=>{console.error("[KProfile] Save error:",V),o(V.message,"error"),R(!1)}}),F=Mt({mutationFn:V=>(console.log("[KProfile] Deleting profile..."),$e.deleteKProfile(e,V)),onSuccess:V=>{console.log("[KProfile] Delete success:",V),o("K-profile deleted"),R(!0),setTimeout(()=>{l.invalidateQueries({queryKey:["kprofiles",e]}),R(!1),a()},2500)},onError:V=>{console.error("[KProfile] Delete error:",V),o(V.message,"error"),R(!1)}}),[I,q]=A.useState(!1),O=()=>{t&&F.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},H=async V=>{if(V.preventDefault(),r&&!t&&w.length===0){o("Please select at least one extruder","error");return}const $=parseFloat(f).toFixed(6),K=`${y}-${x}`;if(t||w.length===1){const Y={name:c,k_value:$,filament_id:g,nozzle_id:K,nozzle_diameter:x,extruder_id:t?t.extruder_id:w[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",Y),k.mutate(Y);return}R(!0),j({current:0,total:w.length});for(let Y=0;YsetTimeout(X,1500))}catch(X){console.error(`[KProfile] Failed to save for extruder ${se}:`,X),o(`Failed to save for ${se===1?"Left":"Right"} extruder`,"error"),R(!1),j({current:0,total:0});return}}o(`K-profile saved to ${w.length} extruders`),setTimeout(()=>{l.invalidateQueries({queryKey:["kprofiles",e]}),R(!1),j({current:0,total:0}),s()},2500)};return p.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[p.jsxs(Xt,{className:"w-full max-w-md relative",children:[T&&p.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[p.jsx(It,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),p.jsx("p",{className:"text-white font-medium",children:N.total>1?`Saving to extruder ${N.current}/${N.total}...`:"Syncing with printer..."}),p.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),p.jsxs(en,{className:"p-0",children:[p.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[p.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),p.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors",disabled:T,children:p.jsx(Sn,{className:"w-5 h-5"})})]}),p.jsxs("form",{onSubmit:H,className:"p-4 space-y-4",children:[p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),p.jsx("input",{type:"text",value:c,onChange:V=>u(V.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:"My PLA Profile",required:!t})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),p.jsx("input",{type:"text",inputMode:"decimal",value:f,onChange:V=>{const $=V.target.value;($===""||/^\d*\.?\d*$/.test($))&&m($)},onBlur:V=>{const $=parseFloat(V.target.value);isNaN($)||m((Math.trunc($*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),p.jsxs("select",{value:g,onChange:V=>{const $=V.target.value;if(b($),!t&&$&&!c){const K=C.find(Y=>Y.id===$);K&&u(`${y==="HH00"?"HF":"S"} ${K.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[p.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&p.jsx("option",{value:t.filament_id,children:C.find(V=>V.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&C.map(V=>p.jsx("option",{value:V.id,children:V.name},V.id))]}),!t&&C.length===0&&p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),p.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),p.jsxs("select",{value:y,onChange:V=>{const $=V.target.value;if(v($),!t&&g&&!c){const K=C.find(Y=>Y.id===g);K&&u(`${$==="HH00"?"HF":"S"} ${K.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[p.jsx("option",{value:"HH00",children:"High Flow"}),p.jsx("option",{value:"HS00",children:"Standard"})]})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),p.jsxs("select",{value:x,onChange:V=>M(V.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[p.jsx("option",{value:"0.2",children:"0.2mm"}),p.jsx("option",{value:"0.4",children:"0.4mm"}),p.jsx("option",{value:"0.6",children:"0.6mm"}),p.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),r&&p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?p.jsx("div",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60",children:t.extruder_id===1?"Left":"Right"}):p.jsxs("div",{className:"flex gap-4",children:[p.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:w.includes(1),onChange:V=>{V.target.checked?E([...w,1]):E(w.filter($=>$!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),p.jsx("span",{className:"text-white",children:"Left"})]}),p.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:w.includes(0),onChange:V=>{V.target.checked?E([...w,0]):E(w.filter($=>$!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),p.jsx("span",{className:"text-white",children:"Right"})]})]})]}),p.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&p.jsx(lt,{type:"button",variant:"secondary",onClick:()=>q(!0),disabled:F.isPending||T,className:"text-red-500 hover:bg-red-500/10",children:F.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(ia,{className:"w-4 h-4"})}),p.jsx(lt,{type:"button",variant:"secondary",onClick:a,disabled:T,className:"flex-1",children:"Cancel"}),p.jsxs(lt,{type:"submit",disabled:k.isPending||T,className:"flex-1",children:[k.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(RP,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),I&&p.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:p.jsx(Xt,{className:"w-full max-w-sm",children:p.jsxs(en,{className:"p-6",children:[p.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[p.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:p.jsx(ia,{className:"w-5 h-5 text-red-500"})}),p.jsxs("div",{children:[p.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),p.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),p.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",p.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),p.jsxs("div",{className:"flex gap-3",children:[p.jsx(lt,{variant:"secondary",onClick:()=>q(!1),className:"flex-1",children:"Cancel"}),p.jsxs(lt,{onClick:()=>{q(!1),O()},disabled:F.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[F.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(ia,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function jVe(){const[t,e]=A.useState(null),[n,i]=A.useState("0.4"),[r,a]=A.useState(null),[s,o]=A.useState(!1),[l,c]=A.useState(""),[u,f]=A.useState("all"),[m,g]=A.useState("all"),{data:b,isLoading:y}=Ht({queryKey:["printers"],queryFn:$e.getPrinters}),{data:v,isLoading:x,error:M,refetch:w}=Ht({queryKey:["kprofiles",t,n],queryFn:()=>$e.getKProfiles(t,n),enabled:!!t,retry:!1,staleTime:0,refetchOnMount:"always"}),E=M?.message?.includes("not connected");A.useEffect(()=>{if(!t&&b&&b.length>0){const C=b.find(k=>k.is_active);C&&e(C.id)}},[t,b]),A.useEffect(()=>{if(t){const C=setTimeout(()=>{w()},150);return()=>clearTimeout(C)}},[t,n]);const T=b?.filter(C=>C.is_active)||[],R=ui.useMemo(()=>v?.profiles?v.profiles.filter(C=>{const k=l.toLowerCase(),F=!k||C.name.toLowerCase().includes(k)||C.filament_id.toLowerCase().includes(k),I=u==="all"||u==="left"&&C.extruder_id===1||u==="right"&&C.extruder_id===0,q=m==="all"||m==="hf"&&C.nozzle_id.startsWith("HH")||m==="s"&&C.nozzle_id.startsWith("HS");return F&&I&&q}):[],[v?.profiles,l,u,m]),j=b?.find(C=>C.id===t)?.nozzle_count===2;return y?p.jsx("div",{className:"flex justify-center py-12",children:p.jsx(It,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!b||b.length===0?p.jsx(Xt,{children:p.jsxs(en,{className:"py-12 text-center",children:[p.jsx(id,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),p.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),p.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):T.length===0?p.jsx(Xt,{children:p.jsxs(en,{className:"py-12 text-center",children:[p.jsx(hc,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),p.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),p.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[p.jsxs("div",{className:"flex-1 min-w-48",children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),p.jsx("select",{value:t||"",onChange:C=>e(parseInt(C.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:T.map(C=>p.jsx("option",{value:C.id,children:C.name},C.id))})]}),p.jsxs("div",{className:"w-32",children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),p.jsxs("select",{value:n,onChange:C=>i(C.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[p.jsx("option",{value:"0.2",children:"0.2mm"}),p.jsx("option",{value:"0.4",children:"0.4mm"}),p.jsx("option",{value:"0.6",children:"0.6mm"}),p.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),p.jsxs("div",{className:"flex items-end gap-2",children:[p.jsxs(lt,{variant:"secondary",onClick:()=>w(),disabled:x,children:[p.jsx(Yo,{className:`w-4 h-4 ${x?"animate-spin":""}`}),"Refresh"]}),p.jsxs(lt,{onClick:()=>o(!0),children:[p.jsx(fc,{className:"w-4 h-4"}),"Add Profile"]})]})]}),p.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[p.jsxs("div",{className:"flex-1 min-w-48 relative",children:[p.jsx(z_,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),p.jsx("input",{type:"text",value:l,onChange:C=>c(C.target.value),placeholder:"Search by name or filament...",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),j&&p.jsx("div",{className:"w-36",children:p.jsxs("select",{value:u,onChange:C=>f(C.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[p.jsx("option",{value:"all",children:"All Extruders"}),p.jsx("option",{value:"left",children:"Left Only"}),p.jsx("option",{value:"right",children:"Right Only"})]})}),p.jsx("div",{className:"w-32",children:p.jsxs("select",{value:m,onChange:C=>g(C.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[p.jsx("option",{value:"all",children:"All Flow"}),p.jsx("option",{value:"hf",children:"HF Only"}),p.jsx("option",{value:"s",children:"S Only"})]})})]}),x?p.jsx("div",{className:"flex justify-center py-12",children:p.jsx(It,{className:"w-8 h-8 text-bambu-green animate-spin"})}):E?p.jsx(Xt,{children:p.jsxs(en,{className:"py-12 text-center",children:[p.jsx(Fp,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),p.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),p.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),p.jsxs(lt,{variant:"secondary",onClick:()=>w(),children:[p.jsx(Yo,{className:"w-4 h-4"}),"Retry"]})]})}):R.length>0?j?p.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[p.jsxs("div",{children:[p.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),p.jsx("div",{className:"space-y-1",children:R.filter(C=>C.extruder_id===1).map(C=>p.jsx(lN,{profile:C,onEdit:()=>a(C)},C.slot_id))})]}),p.jsxs("div",{children:[p.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),p.jsx("div",{className:"space-y-1",children:R.filter(C=>C.extruder_id===0).map(C=>p.jsx(lN,{profile:C,onEdit:()=>a(C)},C.slot_id))})]})]}):p.jsx("div",{className:"space-y-1",children:R.map(C=>p.jsx(lN,{profile:C,onEdit:()=>a(C)},C.slot_id))}):l||u!=="all"||m!=="all"?p.jsx(Xt,{children:p.jsxs(en,{className:"py-12 text-center",children:[p.jsx(z_,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),p.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),p.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):p.jsx(Xt,{children:p.jsxs(en,{className:"py-12 text-center",children:[p.jsx(RP,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),p.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),p.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",n,"mm nozzle"]}),p.jsxs(lt,{onClick:()=>o(!0),children:[p.jsx(fc,{className:"w-4 h-4"}),"Create First Profile"]})]})}),r&&t&&p.jsx(eG,{profile:r,printerId:t,nozzleDiameter:n,existingProfiles:v?.profiles,isDualNozzle:j,onClose:()=>a(null),onSave:()=>a(null)}),s&&t&&p.jsx(eG,{printerId:t,nozzleDiameter:n,existingProfiles:v?.profiles,isDualNozzle:j,onClose:()=>o(!1),onSave:()=>o(!1)})]})}function UVe({onSuccess:t}){const{showToast:e}=Mo(),[n,i]=A.useState("email"),[r,a]=A.useState(""),[s,o]=A.useState(""),[l,c]=A.useState(""),[u,f]=A.useState(""),[m,g]=A.useState("global"),b=Mt({mutationFn:()=>$e.cloudLogin(r,s,m),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):w.needs_verification?(e("Verification code sent to your email"),i("code")):e(w.message,"error")},onError:w=>{e(w.message,"error")}}),y=Mt({mutationFn:()=>$e.cloudVerify(r,l),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>{e(w.message,"error")}}),v=Mt({mutationFn:()=>$e.cloudSetToken(u),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>{e(w.message,"error")}}),x=w=>{w.preventDefault(),n==="email"?b.mutate():n==="code"?y.mutate():n==="token"&&v.mutate()},M=b.isPending||y.isPending||v.isPending;return p.jsxs(Xt,{className:"max-w-md mx-auto",children:[p.jsx($l,{children:p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(NP,{className:"w-5 h-5 text-bambu-green"}),p.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"})]})}),p.jsx(en,{children:p.jsxs("form",{onSubmit:x,className:"space-y-4",children:[n==="email"&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),p.jsx("input",{type:"email",value:r,onChange:w=>a(w.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:"your@email.com",required:!0})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),p.jsx("input",{type:"password",value:s,onChange:w=>o(w.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:"••••••••",required:!0})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),p.jsxs("select",{value:m,onChange:w=>g(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[p.jsx("option",{value:"global",children:"Global"}),p.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),p.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",r,") for a 6-digit code"]}),p.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),p.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),p.jsx("textarea",{value:u,onChange:w=>f(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:3,required:!0})]}),p.jsxs("div",{className:"flex gap-2",children:[n==="code"&&p.jsx(lt,{type:"button",variant:"secondary",onClick:()=>i("email"),className:"flex-1",children:"Back"}),p.jsxs(lt,{type:"submit",disabled:M,className:"flex-1",children:[M?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(B4,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&p.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:p.jsxs("button",{type:"button",onClick:()=>i("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-1",children:[p.jsx(Fse,{className:"w-3 h-3"}),"Use access token instead"]})}),n==="token"&&p.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:p.jsxs("button",{type:"button",onClick:()=>i("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-1",children:[p.jsx(B4,{className:"w-3 h-3"}),"Login with email instead"]})})]})})]})}function FVe({setting:t,onClick:e}){return p.jsxs("button",{onClick:e,className:"w-full text-left p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[p.jsx("p",{className:"text-white font-medium truncate",children:t.name}),t.updated_time&&p.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Updated: ",new Date(t.updated_time).toLocaleDateString()]})]})}function zVe({setting:t,onClose:e}){const{data:n,isLoading:i}=Ht({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>$e.getCloudSettingDetail(t.setting_id)});return p.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:p.jsx(Xt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:p.jsxs(en,{className:"p-0 flex flex-col h-full",children:[p.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[p.jsxs("div",{children:[p.jsx("h2",{className:"text-xl font-semibold text-white",children:t.name}),p.jsxs("p",{className:"text-sm text-bambu-gray capitalize",children:[t.type," preset"]})]}),p.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:p.jsx(Sn,{className:"w-5 h-5"})})]}),p.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:i?p.jsx("div",{className:"flex justify-center py-8",children:p.jsx(It,{className:"w-8 h-8 text-bambu-green animate-spin"})}):n?p.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap overflow-x-auto bg-bambu-dark p-4 rounded-lg",children:JSON.stringify(n,null,2)}):p.jsx("p",{className:"text-bambu-gray text-center py-8",children:"Failed to load preset details"})}),p.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:p.jsx(lt,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})})}function BVe({settings:t}){const[e,n]=A.useState(new Set),[i,r]=A.useState(null),a=l=>[...l].sort((c,u)=>c.name.localeCompare(u.name)),s=l=>{n(c=>{const u=new Set(c);return u.has(l)?u.delete(l):u.add(l),u})},o=[{key:"filament",label:"Filament Presets",icon:GG,items:a(t.filament)},{key:"printer",label:"Printer Presets",icon:hc,items:a(t.printer)},{key:"process",label:"Process Presets",icon:DP,items:a(t.process)}];return p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"space-y-4",children:o.map(({key:l,label:c,icon:u,items:f})=>p.jsxs(Xt,{children:[p.jsxs("button",{onClick:()=>s(l),className:"w-full flex items-center justify-between p-4",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(u,{className:"w-5 h-5 text-bambu-green"}),p.jsx("span",{className:"text-lg font-semibold text-white",children:c}),p.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",f.length,")"]})]}),e.has(l)?p.jsx(gm,{className:"w-5 h-5 text-bambu-gray"}):p.jsx(Bf,{className:"w-5 h-5 text-bambu-gray"})]}),e.has(l)&&f.length>0&&p.jsx(en,{className:"pt-0",children:p.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:f.map(m=>p.jsx(FVe,{setting:m,onClick:()=>r(m)},m.setting_id))})}),e.has(l)&&f.length===0&&p.jsx(en,{className:"pt-0",children:p.jsx("p",{className:"text-bambu-gray text-sm",children:"No presets found"})})]},l))}),i&&p.jsx(zVe,{setting:i,onClose:()=>r(null)})]})}function HVe(){const t=Gn(),{showToast:e}=Mo(),[n,i]=A.useState("kprofiles"),{data:r,isLoading:a}=Ht({queryKey:["cloudStatus"],queryFn:$e.getCloudStatus}),{data:s,isLoading:o,refetch:l}=Ht({queryKey:["cloudSettings"],queryFn:()=>$e.getCloudSettings(),enabled:!!r?.is_authenticated,retry:!1,staleTime:1e3*60*5}),c=Mt({mutationFn:$e.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),u=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return a?p.jsx("div",{className:"p-8 flex justify-center",children:p.jsx(It,{className:"w-8 h-8 text-bambu-green animate-spin"})}):p.jsxs("div",{className:"p-8",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),p.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),p.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[p.jsxs("button",{onClick:()=>i("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[p.jsx(NP,{className:"w-4 h-4"}),"Cloud Profiles"]}),p.jsxs("button",{onClick:()=>i("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[p.jsx(RP,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[p.jsx("p",{className:"text-bambu-gray",children:r?.is_authenticated?`Connected as ${r.email}`:"Connect to Bambu Cloud to access your slicer presets"}),r?.is_authenticated&&p.jsxs("div",{className:"flex gap-2",children:[p.jsxs(lt,{variant:"secondary",onClick:()=>l(),disabled:o,children:[p.jsx(Yo,{className:`w-4 h-4 ${o?"animate-spin":""}`}),"Refresh"]}),p.jsxs(lt,{variant:"secondary",onClick:()=>c.mutate(),disabled:c.isPending,children:[p.jsx(noe,{className:"w-4 h-4"}),"Logout"]})]})]}),r?.is_authenticated?o?p.jsx("div",{className:"flex justify-center py-12",children:p.jsx(It,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s?p.jsx(BVe,{settings:s}):p.jsx(Xt,{children:p.jsxs(en,{className:"py-8 text-center",children:[p.jsx("p",{className:"text-bambu-gray",children:"Failed to load profiles"}),p.jsx(lt,{className:"mt-4",onClick:()=>l(),children:"Retry"})]})}):p.jsx(UVe,{onSuccess:u})]}),n==="kprofiles"&&p.jsx(jVe,{})]})}const gP={Droplet:GG,Flame:yse,Ruler:woe,Sparkles:Loe,Square:Up,Cable:Rae,Wrench:zp};function N_(t){return t&&gP[t]||zp}function Dx(t){return t<1?`${Math.round(t*60)}m`:`${t.toFixed(1)}h`}function VVe(t){const e=Math.floor(t),n=Math.round((t-e)*60);return e===0?`${n} minutes`:n===0?`${e} hours`:`${e}h ${n}m`}function $Ve({item:t,onPerform:e,onToggle:n}){const i=N_(t.maintenance_type_icon),r=Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100)),a=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-yellow-400":"text-bambu-green":"text-bambu-gray",s=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-yellow-500":"bg-bambu-green":"bg-bambu-gray/30",o=()=>t.enabled?t.is_due?`Overdue by ${Dx(Math.abs(t.hours_until_due))}`:t.is_warning?`Due in ${Dx(t.hours_until_due)}`:`${Dx(t.hours_until_due)} left`:"Disabled";return p.jsxs("div",{className:`flex items-center gap-4 p-3 rounded-lg ${t.is_due?"bg-red-500/10":t.is_warning?"bg-yellow-500/10":"bg-bambu-dark"}`,children:[p.jsxs("div",{className:"flex items-center gap-3 min-w-[180px]",children:[p.jsx(i,{className:`w-4 h-4 ${a()}`}),p.jsx("span",{className:`text-sm ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name})]}),p.jsx("div",{className:"flex-1 max-w-[200px]",children:p.jsx("div",{className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:p.jsx("div",{className:`h-full transition-all ${s()}`,style:{width:`${r}%`}})})}),p.jsxs("div",{className:`text-xs min-w-[120px] ${a()}`,children:[t.is_due&&p.jsx(_o,{className:"w-3 h-3 inline mr-1"}),t.is_warning&&p.jsx(xa,{className:"w-3 h-3 inline mr-1"}),!t.is_due&&!t.is_warning&&t.enabled&&p.jsx(jp,{className:"w-3 h-3 inline mr-1"}),o()]}),p.jsx(ns,{checked:t.enabled,onChange:l=>n(t.id,l)}),p.jsxs(lt,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"min-w-[70px]",children:[p.jsx(XS,{className:"w-3 h-3"}),"Done"]})]})}function GVe({overview:t,onPerform:e,onToggle:n,onSetHours:i}){const[r,a]=A.useState(!1),[s,o]=A.useState(!1),[l,c]=A.useState(t.total_print_hours.toFixed(1)),u=[...t.maintenance_items].sort((g,b)=>g.maintenance_type_id-b.maintenance_type_id),f=[...t.maintenance_items].filter(g=>g.enabled).sort((g,b)=>g.is_due&&!b.is_due?-1:!g.is_due&&b.is_due?1:g.is_warning&&!b.is_warning?-1:!g.is_warning&&b.is_warning?1:g.hours_until_due-b.hours_until_due)[0],m=()=>{const g=parseFloat(l);!isNaN(g)&&g>=0&&(i(t.printer_id,g),o(!1))};return p.jsxs(Xt,{children:[p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"flex items-center justify-between mb-4",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("h2",{className:"text-lg font-semibold text-white",children:t.printer_name}),t.due_count>0&&p.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",children:[p.jsx(_o,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&p.jsxs("span",{className:"px-2.5 py-1 bg-yellow-500/20 text-yellow-400 text-xs font-medium rounded-full flex items-center gap-1",children:[p.jsx(xa,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&p.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",children:[p.jsx(jp,{className:"w-3 h-3"}),"All good"]})]}),p.jsx("button",{onClick:()=>a(!r),className:"flex items-center gap-1 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded transition-colors",children:r?p.jsxs(p.Fragment,{children:[p.jsx(CP,{className:"w-4 h-4"}),"Hide"]}):p.jsxs(p.Fragment,{children:[p.jsx(gm,{className:"w-4 h-4"}),"Details"]})})]}),p.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[p.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[p.jsx("div",{className:"text-xs text-bambu-gray mb-1 uppercase tracking-wide",children:"Total Print Time"}),s?p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("input",{type:"number",value:l,onChange:g=>c(g.target.value),onKeyDown:g=>{g.key==="Enter"&&m(),g.key==="Escape"&&o(!1)},className:"w-20 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-lg font-semibold",min:"0",step:"1",autoFocus:!0}),p.jsx("span",{className:"text-sm text-bambu-gray",children:"hours"}),p.jsxs("div",{className:"flex gap-1 ml-auto",children:[p.jsx(lt,{size:"sm",onClick:m,children:"Save"}),p.jsx(lt,{size:"sm",variant:"secondary",onClick:()=>o(!1),children:"✕"})]})]}):p.jsxs("button",{onClick:()=>{c(Math.round(t.total_print_hours).toString()),o(!0)},className:"flex items-center gap-2 group",title:"Click to edit total print hours",children:[p.jsx("span",{className:"text-xl font-semibold text-white group-hover:text-bambu-green transition-colors",children:VVe(t.total_print_hours)}),p.jsx(kP,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})]})]}),p.jsxs("div",{className:`p-3 rounded-lg ${f?.is_due?"bg-red-500/10":f?.is_warning?"bg-yellow-500/10":"bg-bambu-dark"}`,children:[p.jsx("div",{className:"text-xs text-bambu-gray mb-1 uppercase tracking-wide",children:"Next Maintenance"}),f?p.jsxs("div",{children:[p.jsx("div",{className:`text-lg font-semibold ${f.is_due?"text-red-400":f.is_warning?"text-yellow-400":"text-white"}`,children:f.maintenance_type_name}),p.jsx("div",{className:`text-sm ${f.is_due?"text-red-400":f.is_warning?"text-yellow-400":"text-bambu-gray"}`,children:f.is_due?p.jsxs(p.Fragment,{children:["Overdue by ",Dx(Math.abs(f.hours_until_due))]}):p.jsxs(p.Fragment,{children:["Due in ",Dx(f.hours_until_due)]})})]}):p.jsx("div",{className:"text-white",children:"No tasks enabled"})]})]})]}),r&&p.jsx(en,{className:"pt-0 space-y-2 border-t border-bambu-dark-tertiary mt-4",children:p.jsx("div",{className:"pt-4",children:u.map(g=>p.jsx($Ve,{item:g,onPerform:e,onToggle:n},g.id))})})]})}function WVe({overview:t,types:e,onUpdateInterval:n,onAddType:i,onDeleteType:r}){const[a,s]=A.useState(null),[o,l]=A.useState(""),[c,u]=A.useState(!1),[f,m]=A.useState(""),[g,b]=A.useState("100"),[y,v]=A.useState("Wrench"),x=(R,N)=>{const j=parseFloat(o);if(!isNaN(j)&&j>0){const C=Math.abs(j-N)<.01?null:j;n(R,C)}s(null)},M=R=>{R.preventDefault(),f.trim()&&parseFloat(g)>0&&(i({name:f.trim(),default_interval_hours:parseFloat(g),icon:y}),m(""),b("100"),u(!1))},w=t?.map(R=>({printerId:R.printer_id,printerName:R.printer_name,items:R.maintenance_items.sort((N,j)=>N.maintenance_type_id-j.maintenance_type_id)})).sort((R,N)=>R.printerName.localeCompare(N.printerName))||[],E=e.filter(R=>R.is_system),T=e.filter(R=>!R.is_system);return p.jsxs("div",{className:"space-y-8",children:[p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center justify-between mb-4",children:[p.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),p.jsxs(lt,{size:"sm",variant:"secondary",onClick:()=>u(!c),children:[p.jsx(fc,{className:"w-4 h-4"}),"Add Custom Type"]})]}),c&&p.jsx(Xt,{className:"mb-4",children:p.jsx("div",{className:"p-4",children:p.jsx("form",{onSubmit:M,children:p.jsxs("div",{className:"flex gap-3 items-end",children:[p.jsxs("div",{className:"flex-1",children:[p.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Name"}),p.jsx("input",{type:"text",value:f,onChange:R=>m(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",placeholder:"e.g., Replace HEPA Filter",autoFocus:!0})]}),p.jsxs("div",{className:"w-28",children:[p.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Interval (hours)"}),p.jsx("input",{type:"number",value:g,onChange:R=>b(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"1"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Icon"}),p.jsx("div",{className:"flex gap-1",children:Object.keys(gP).map(R=>{const N=gP[R];return p.jsx("button",{type:"button",onClick:()=>v(R),className:`p-2 rounded ${y===R?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:p.jsx(N,{className:"w-4 h-4"})},R)})})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx(lt,{type:"submit",size:"sm",disabled:!f.trim(),children:"Add"}),p.jsx(lt,{type:"button",size:"sm",variant:"secondary",onClick:()=>u(!1),children:"Cancel"})]})]})})})}),p.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[E.map(R=>{const N=N_(R.icon);return p.jsx("div",{className:"bg-bambu-dark-secondary rounded-lg p-4 border border-bambu-dark-tertiary",children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:p.jsx(N,{className:"w-5 h-5 text-bambu-gray"})}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:"text-sm font-medium text-white truncate",children:R.name}),p.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5",children:[R.default_interval_hours,"h interval"]})]})]})},R.id)}),T.map(R=>{const N=N_(R.icon);return p.jsx("div",{className:"bg-bambu-dark-secondary rounded-lg p-4 border border-bambu-green/30",children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:"p-2 bg-bambu-green/20 rounded-lg",children:p.jsx(N,{className:"w-5 h-5 text-bambu-green"})}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("span",{className:"text-sm font-medium text-white truncate",children:R.name}),p.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),p.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5",children:[R.default_interval_hours,"h interval"]})]}),p.jsx("button",{onClick:()=>{confirm(`Delete "${R.name}"?`)&&r(R.id)},className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:p.jsx(ia,{className:"w-4 h-4"})})]})},R.id)})]})]}),w.length>0&&p.jsxs("div",{children:[p.jsx("h2",{className:"text-lg font-semibold text-white mb-2",children:"Interval Overrides"}),p.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Set custom intervals per printer."}),p.jsx("div",{className:"space-y-3",children:w.map(R=>p.jsx(Xt,{children:p.jsxs("div",{className:"p-4",children:[p.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:R.printerName}),p.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:R.items.map(N=>{const j=N_(N.maintenance_type_icon),k=e.find(I=>I.id===N.maintenance_type_id)?.default_interval_hours||N.interval_hours,F=a===N.id;return p.jsxs("div",{className:"flex items-center gap-2 p-2 bg-bambu-dark rounded-lg",children:[p.jsx(j,{className:"w-4 h-4 text-bambu-gray shrink-0"}),p.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:N.maintenance_type_name}),F?p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("input",{type:"number",value:o,onChange:I=>l(I.target.value),onKeyDown:I=>{I.key==="Enter"&&x(N.id,k),I.key==="Escape"&&s(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1",autoFocus:!0}),p.jsx(lt,{size:"sm",onClick:()=>x(N.id,k),children:"OK"})]}):p.jsxs("button",{onClick:()=>{s(N.id),l(N.interval_hours.toString())},className:"px-2 py-1 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary border border-bambu-dark-tertiary hover:border-bambu-green rounded text-xs font-medium text-white transition-colors",children:[N.interval_hours,"h",p.jsx(kP,{className:"w-3 h-3 inline ml-1.5 text-bambu-gray"})]})]},N.id)})})]})},R.printerId))})]}),w.length===0&&p.jsx(Xt,{children:p.jsxs(en,{className:"text-center py-12",children:[p.jsx(xa,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),p.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),p.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function qVe(){const t=Gn(),{showToast:e}=Mo(),[n,i]=A.useState("status"),{data:r,isLoading:a}=Ht({queryKey:["maintenanceOverview"],queryFn:$e.getMaintenanceOverview}),{data:s}=Ht({queryKey:["maintenanceTypes"],queryFn:$e.getMaintenanceTypes}),o=Mt({mutationFn:({id:x,notes:M})=>$e.performMaintenance(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as done")},onError:x=>{e(x.message,"error")}}),l=Mt({mutationFn:({id:x,data:M})=>$e.updateMaintenanceItem(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:x=>{e(x.message,"error")}}),c=Mt({mutationFn:$e.createMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onError:x=>{e(x.message,"error")}}),u=Mt({mutationFn:$e.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:x=>{e(x.message,"error")}}),f=Mt({mutationFn:({printerId:x,hours:M})=>$e.setPrinterHours(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:x=>{e(x.message,"error")}}),m=x=>{o.mutate({id:x})},g=(x,M)=>{l.mutate({id:x,data:{enabled:M}})},b=(x,M)=>{f.mutate({printerId:x,hours:M})};if(a)return p.jsx("div",{className:"p-8 flex justify-center",children:p.jsx(It,{className:"w-8 h-8 text-bambu-green animate-spin"})});const y=r?.reduce((x,M)=>x+M.due_count,0)||0,v=r?.reduce((x,M)=>x+M.warning_count,0)||0;return p.jsxs("div",{className:"p-8",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),p.jsx("p",{className:"text-bambu-gray text-sm",children:n==="status"?p.jsxs(p.Fragment,{children:[y>0&&p.jsxs("span",{className:"text-red-400",children:[y," tasks overdue"]}),y>0&&v>0&&" · ",v>0&&p.jsxs("span",{className:"text-yellow-400",children:[v," due soon"]}),y===0&&v===0&&"All maintenance up to date"]}):"Configure maintenance types and intervals"})]}),p.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[p.jsx("button",{onClick:()=>i("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Status"}),p.jsx("button",{onClick:()=>i("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Settings"})]}),n==="status"?p.jsx("div",{className:"space-y-4",children:r&&r.length>0?[...r].sort((x,M)=>x.printer_name.localeCompare(M.printer_name)).map(x=>p.jsx(GVe,{overview:x,onPerform:m,onToggle:g,onSetHours:b},x.printer_id)):p.jsx(Xt,{children:p.jsxs(en,{className:"text-center py-12",children:[p.jsx(zp,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),p.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),p.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to start tracking maintenance"})]})})}):p.jsx(WVe,{overview:r,types:s||[],onUpdateInterval:(x,M)=>l.mutate({id:x,data:{custom_interval_hours:M}}),onAddType:x=>c.mutate(x),onDeleteType:x=>u.mutate(x)})]})}function XVe({printerId:t,isConnected:e}){const[n,i]=A.useState(!1),[r,a]=A.useState(!1),[s,o]=A.useState(null),l=A.useRef(null),c=$e.getCameraStreamUrl(t,10),u=()=>{n?(i(!1),o(null)):(a(!0),o(null),i(!0))},f=()=>{a(!1),o(null)},m=()=>{a(!1),o("Failed to load camera stream")},g=()=>{l.current&&(document.fullscreenElement?document.exitFullscreen():l.current.requestFullscreen())},b=()=>{i(!1),setTimeout(()=>{a(!0),i(!0)},100)};return p.jsx("div",{className:"relative w-full h-full bg-black",children:n?p.jsxs(p.Fragment,{children:[r&&p.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:p.jsx(It,{className:"w-8 h-8 animate-spin text-bambu-green"})}),s?p.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-red-400",children:[p.jsx(Lae,{className:"w-12 h-12 mb-2"}),p.jsx("span",{className:"text-sm",children:s}),p.jsx("button",{onClick:b,className:"mt-2 text-xs text-bambu-green hover:underline",children:"Retry"})]}):p.jsx("img",{ref:l,src:c,alt:"Camera stream",className:"w-full h-full object-contain",onLoad:f,onError:m}),p.jsxs("div",{className:"absolute top-2 right-2 flex gap-2",children:[p.jsx("button",{onClick:b,className:"p-2 rounded bg-black/50 hover:bg-black/70 text-white transition-colors",title:"Refresh stream",children:p.jsx(Yo,{className:"w-4 h-4"})}),p.jsx("button",{onClick:g,className:"p-2 rounded bg-black/50 hover:bg-black/70 text-white transition-colors",title:"Fullscreen",children:p.jsx(ZG,{className:"w-4 h-4"})}),p.jsx("button",{onClick:u,className:"px-3 py-1.5 rounded bg-red-500/80 hover:bg-red-500 text-white text-sm transition-colors",children:"Stop"})]})]}):p.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-bambu-gray",children:p.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-6 flex flex-col items-center",children:[p.jsx(I_,{className:"w-8 h-8 mb-2"}),p.jsx("span",{className:"text-sm mb-3",children:e?"Click Start to view camera":"Printer not connected"}),p.jsx("button",{onClick:u,disabled:!e,className:"px-4 py-1.5 rounded text-sm bg-bambu-green text-white hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed",children:"Start"})]})})})}function KVe(t){if(!t)return"N/A";const e=new Date;return new Date(e.getTime()+t*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function YVe({printerId:t,status:e}){const n=Gn(),[i,r]=A.useState(null),a=e?.connected??!1,s=e?.state==="RUNNING",o=e?.state==="PAUSE",l=e?.progress??0,c=Mt({mutationFn:()=>$e.pausePrint(t),onSuccess:()=>{n.invalidateQueries({queryKey:["printerStatuses"]})}}),u=Mt({mutationFn:()=>$e.resumePrint(t),onSuccess:()=>{n.invalidateQueries({queryKey:["printerStatuses"]})}}),f=Mt({mutationFn:x=>$e.stopPrint(t,x),onSuccess:x=>{Bx(x)?r({action:"stop",token:x.token,warning:x.warning}):n.invalidateQueries({queryKey:["printerStatuses"]})}}),m=()=>{s?c.mutate():o&&u.mutate()},g=()=>{f.mutate(void 0)},b=()=>{i&&(f.mutate(i.token),r(null))},y=c.isPending||u.isPending||f.isPending,v=a&&(s||o);return p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"text-xs text-bambu-gray mb-3",children:"Printing Progress"}),p.jsxs("div",{className:"flex gap-4 items-center",children:[p.jsx("div",{className:"w-20 h-20 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg flex items-center justify-center flex-shrink-0 overflow-hidden",children:e?.subtask_name?p.jsx("img",{src:`/api/v1/archives/thumbnail/${encodeURIComponent(e.subtask_name)}`,alt:"",className:"w-full h-full object-contain",onError:x=>{x.target.style.display="none",x.target.parentElement.innerHTML='Bambu Lab '}}):p.jsxs("span",{className:"text-xs text-bambu-gray text-center",children:["Bambu",p.jsx("br",{}),"Lab"]})}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:"font-medium text-sm text-white truncate mb-0.5",children:e?.subtask_name||"N/A"}),p.jsx("div",{className:`text-sm mb-2 ${e?.state==="RUNNING"||e?.state==="PAUSE"?"text-bambu-green":"text-bambu-gray"}`,children:e?.state||"N/A"}),p.jsx("div",{className:"h-1 bg-bambu-dark-tertiary rounded-full overflow-hidden mb-2",children:p.jsx("div",{className:`h-full transition-all duration-300 ${e?.state==="PAUSE"?"bg-yellow-500":"bg-bambu-green"}`,style:{width:`${l}%`}})}),p.jsxs("div",{className:"text-xs text-bambu-gray mb-1",children:["Layer: ",e?.layer_num??"N/A"," / ",e?.total_layers??"N/A"," ",Math.round(l),"%"]}),p.jsxs("div",{className:"text-xs text-bambu-gray",children:["Estimated finish time: ",KVe(e?.remaining_time)]})]}),p.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[p.jsx("button",{onClick:m,disabled:!v||y,className:"w-8 h-8 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary flex items-center justify-center text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:s?"Pause":"Resume",children:c.isPending||u.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(QG,{className:"w-4 h-4"})}),p.jsx("button",{onClick:g,disabled:!v||y,className:"w-8 h-8 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary flex items-center justify-center text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Stop",children:f.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(Up,{className:"w-4 h-4"})}),p.jsx("button",{disabled:!v||y,className:"w-8 h-8 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary flex items-center justify-center text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Skip Objects",children:p.jsx("img",{src:"/icons/skip-objects.svg",alt:"Skip Objects",className:"w-4 h-4 icon-theme"})})]})]}),(c.error||u.error||f.error)&&p.jsx("p",{className:"mt-2 text-xs text-red-500",children:(c.error||u.error||f.error)?.message}),i&&p.jsx(rr,{title:"Confirm Stop",message:i.warning,confirmText:"Stop Print",variant:"danger",onConfirm:b,onCancel:()=>r(null)})]})}function ZVe({printerId:t,status:e,nozzleCount:n,disabled:i=!1}){const r=e?.temperatures??{},a=n>1,s=(e?.connected??!1)&&!i,[o,l]=A.useState(null),[c,u]=A.useState(""),f=Mt({mutationFn:E=>$e.setBedTemperature(t,E)}),m=Mt({mutationFn:({target:E,nozzle:T})=>$e.setNozzleTemperature(t,E,T)}),g=Mt({mutationFn:E=>$e.setChamberLight(t,E)}),b=(E,T)=>{s&&(l(E),u(String(Math.round(T))))},y=()=>{l(null),u("")},v=()=>{const E=parseInt(c,10);if(isNaN(E)||E<0){y();return}o==="bed"?f.mutate(E):o==="nozzle"?m.mutate({target:E,nozzle:0}):o==="nozzle_2"&&m.mutate({target:E,nozzle:1}),y()},x=E=>{E.key==="Enter"?v():E.key==="Escape"&&y()},M=!s,w=(E,T)=>o===E?p.jsx("input",{type:"number",value:c,onChange:R=>u(R.target.value),onBlur:v,onKeyDown:x,autoFocus:!0,className:"w-12 text-sm bg-bambu-dark border border-bambu-green rounded px-1 py-0.5 text-white text-center",min:0,max:350}):p.jsxs("button",{onClick:()=>b(E,T),disabled:M,className:"text-sm text-bambu-gray hover:text-bambu-green disabled:hover:text-bambu-gray disabled:cursor-not-allowed",title:M?"Printer not connected":"Click to set target temperature",children:["/",Math.round(T)," °C"]});return p.jsxs("div",{className:"flex flex-col justify-evenly min-w-[150px] pr-5 border-r border-bambu-dark-tertiary",children:[p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:p.jsx("img",{src:"/icons/hotend.svg",alt:"",className:"w-5 icon-theme"})}),a&&p.jsx("span",{className:"text-[11px] font-semibold text-bambu-green bg-bambu-green/20 px-1.5 py-0.5 rounded min-w-[18px] text-center flex-shrink-0",children:"L"}),p.jsx("span",{className:"text-lg font-medium text-white",children:Math.round(r.nozzle??0)}),w("nozzle",r.nozzle_target??0)]}),a&&p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:p.jsx("img",{src:"/icons/hotend.svg",alt:"",className:"w-5 icon-theme"})}),p.jsx("span",{className:"text-[11px] font-semibold text-bambu-green bg-bambu-green/20 px-1.5 py-0.5 rounded min-w-[18px] text-center flex-shrink-0",children:"R"}),p.jsx("span",{className:"text-lg font-medium text-white",children:Math.round(r.nozzle_2??0)}),w("nozzle_2",r.nozzle_2_target??0)]}),p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:p.jsx("img",{src:"/icons/heatbed.svg",alt:"",className:"w-5 icon-theme"})}),a&&p.jsx("span",{className:"min-w-[18px] flex-shrink-0"}),p.jsx("span",{className:"text-lg font-medium text-white",children:Math.round(r.bed??0)}),w("bed",r.bed_target??0)]}),p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:p.jsx("img",{src:"/icons/chamber.svg",alt:"",className:"w-5 icon-theme"})}),a&&p.jsx("span",{className:"min-w-[18px] flex-shrink-0"}),p.jsx("span",{className:"text-lg font-medium text-white",children:Math.round(r.chamber??0)}),p.jsx("span",{className:"text-sm text-bambu-gray",children:"°C"})]}),p.jsxs("button",{disabled:M,className:"flex items-center gap-2 hover:opacity-80 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed",children:[p.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:p.jsx("img",{src:"/icons/ventilation.svg",alt:"",className:"w-5 icon-theme"})}),p.jsx("span",{className:"text-sm text-bambu-gray",children:"Air Condition"})]}),p.jsxs("button",{onClick:()=>g.mutate(!0),disabled:M||g.isPending,className:"flex items-center gap-2 hover:opacity-80 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed",children:[p.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:p.jsx("img",{src:"/icons/lamp.svg",alt:"",className:"w-4 icon-theme"})}),p.jsx("span",{className:"text-sm text-bambu-gray",children:"Lamp"})]})]})}function QVe({printerId:t,status:e,disabled:n=!1}){const i=(e?.connected??!1)&&!n,[r,a]=A.useState(null),s=Mt({mutationFn:({axes:g,token:b})=>$e.homeAxes(t,g,b),onSuccess:g=>{Bx(g)&&a({action:"home",token:g.token,warning:g.warning,onConfirm:()=>s.mutate({axes:"XY",token:g.token})})}}),o=Mt({mutationFn:({axis:g,distance:b,token:y})=>$e.moveAxis(t,g,b,3e3,y),onSuccess:(g,b)=>{Bx(g)&&a({action:"move",token:g.token,warning:g.warning,onConfirm:()=>o.mutate({axis:b.axis,distance:b.distance,token:g.token})})}}),l=()=>{s.mutate({axes:"XY"})},c=(g,b)=>{o.mutate({axis:g,distance:b})},u=()=>{r&&(r.onConfirm(),a(null))},f=s.isPending||o.isPending,m=!i||f;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"relative w-[220px] h-[220px] mb-3.5",children:[p.jsx("img",{src:"/icons/jogpad.svg",alt:"Jog Pad",className:"w-full h-full jogpad-theme"}),p.jsx("button",{onClick:()=>c("Y",10),disabled:m,className:"absolute top-[8px] left-1/2 -translate-x-1/2 w-[40px] h-[30px] opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"Y+10"}),p.jsx("button",{onClick:()=>c("Y",-10),disabled:m,className:"absolute bottom-[8px] left-1/2 -translate-x-1/2 w-[40px] h-[30px] opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"Y-10"}),p.jsx("button",{onClick:()=>c("X",-10),disabled:m,className:"absolute left-[8px] top-1/2 -translate-y-1/2 w-[30px] h-[40px] opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"X-10"}),p.jsx("button",{onClick:()=>c("X",10),disabled:m,className:"absolute right-[8px] top-1/2 -translate-y-1/2 w-[30px] h-[40px] opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"X+10"}),p.jsx("button",{onClick:()=>c("Y",1),disabled:m,className:"absolute top-[42px] left-1/2 -translate-x-1/2 w-[35px] h-[25px] opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"Y+1"}),p.jsx("button",{onClick:()=>c("Y",-1),disabled:m,className:"absolute bottom-[42px] left-1/2 -translate-x-1/2 w-[35px] h-[25px] opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"Y-1"}),p.jsx("button",{onClick:()=>c("X",-1),disabled:m,className:"absolute left-[42px] top-1/2 -translate-y-1/2 w-[25px] h-[35px] opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"X-1"}),p.jsx("button",{onClick:()=>c("X",1),disabled:m,className:"absolute right-[42px] top-1/2 -translate-y-1/2 w-[25px] h-[35px] opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"X+1"}),p.jsx("button",{onClick:l,disabled:m,className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[50px] h-[50px] rounded-full opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"Home XY"})]}),r&&p.jsx(rr,{title:"Confirm Action",message:r.warning,confirmText:"Continue",variant:"warning",onConfirm:u,onCancel:()=>a(null)})]})}function JVe({printerId:t,status:e,disabled:n=!1}){const i=(e?.connected??!1)&&!n,[r,a]=A.useState(null),s=Mt({mutationFn:({distance:u,token:f})=>$e.moveAxis(t,"Z",u,1e3,f),onSuccess:(u,f)=>{Bx(u)&&a({token:u.token,warning:u.warning,distance:f.distance})}}),o=u=>{s.mutate({distance:u})},l=()=>{r&&(s.mutate({distance:r.distance,token:r.token}),a(null))},c=!i||s.isPending;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("button",{onClick:()=>o(10),disabled:c,className:"px-3.5 py-2 rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary text-sm text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Z+10",children:"↑10"}),p.jsx("button",{onClick:()=>o(1),disabled:c,className:"px-3.5 py-2 rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary text-sm text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Z+1",children:"↑1"}),p.jsx("span",{className:"px-2 py-2 text-sm text-bambu-gray",children:"Bed"}),p.jsx("button",{onClick:()=>o(-1),disabled:c,className:"px-3.5 py-2 rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary text-sm text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Z-1",children:"↓1"}),p.jsx("button",{onClick:()=>o(-10),disabled:c,className:"px-3.5 py-2 rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary text-sm text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Z-10",children:"↓10"})]}),r&&p.jsx(rr,{title:"Confirm Bed Movement",message:r.warning,confirmText:"Continue",variant:"warning",onConfirm:l,onCancel:()=>a(null)})]})}function e$e({printerId:t,status:e,nozzleCount:n,disabled:i=!1}){const r=(e?.connected??!1)&&!i,a=e?.state==="RUNNING"||e?.state==="PAUSE",s=n>1,[o,l]=A.useState("left"),[c,u]=A.useState(null),f=Mt({mutationFn:({distance:y,token:v})=>{const M=`${s?`T${o==="left"?0:1}
+ `},V8e={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function $8e(t){let{announcements:e=V8e,container:n,hiddenTextDescribedById:i,screenReaderInstructions:r=H8e}=t;const{announce:a,announcement:s}=F8e(),o=pv("DndLiveRegion"),[l,c]=A.useState(!1);if(A.useEffect(()=>{c(!0)},[]),z8e(A.useMemo(()=>({onDragStart(f){let{active:m}=f;a(e.onDragStart({active:m}))},onDragMove(f){let{active:m,over:g}=f;e.onDragMove&&a(e.onDragMove({active:m,over:g}))},onDragOver(f){let{active:m,over:g}=f;a(e.onDragOver({active:m,over:g}))},onDragEnd(f){let{active:m,over:g}=f;a(e.onDragEnd({active:m,over:g}))},onDragCancel(f){let{active:m,over:g}=f;a(e.onDragCancel({active:m,over:g}))}}),[a,e])),!l)return null;const u=ui.createElement(ui.Fragment,null,ui.createElement(j8e,{id:i,value:r.draggable}),ui.createElement(U8e,{id:o,announcement:s}));return n?Kl.createPortal(u,n):u}var nr;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(nr||(nr={}));function jS(){}function z$(t,e){return A.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function G8e(){for(var t=arguments.length,e=new Array(t),n=0;n[...e].filter(i=>i!=null),[...e])}const wo=Object.freeze({x:0,y:0});function bJ(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function yJ(t,e){let{data:{value:n}}=t,{data:{value:i}}=e;return n-i}function W8e(t,e){let{data:{value:n}}=t,{data:{value:i}}=e;return i-n}function B$(t){let{left:e,top:n,height:i,width:r}=t;return[{x:e,y:n},{x:e+r,y:n},{x:e,y:n+i},{x:e+r,y:n+i}]}function _J(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function H$(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+t.width*.5,y:n+t.height*.5}}const q8e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:i}=t;const r=H$(e,e.left,e.top),a=[];for(const s of i){const{id:o}=s,l=n.get(o);if(l){const c=bJ(H$(l),r);a.push({id:o,data:{droppableContainer:s,value:c}})}}return a.sort(yJ)},X8e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:i}=t;const r=B$(e),a=[];for(const s of i){const{id:o}=s,l=n.get(o);if(l){const c=B$(l),u=r.reduce((m,g,b)=>m+bJ(c[b],g),0),f=Number((u/4).toFixed(4));a.push({id:o,data:{droppableContainer:s,value:f}})}}return a.sort(yJ)};function K8e(t,e){const n=Math.max(e.top,t.top),i=Math.max(e.left,t.left),r=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height),s=r-i,o=a-n;if(i{let{collisionRect:e,droppableRects:n,droppableContainers:i}=t;const r=[];for(const a of i){const{id:s}=a,o=n.get(s);if(o){const l=K8e(o,e);l>0&&r.push({id:s,data:{droppableContainer:a,value:l}})}}return r.sort(W8e)};function Z8e(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function SJ(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:wo}function Q8e(t){return function(n){for(var i=arguments.length,r=new Array(i>1?i-1:0),a=1;a({...s,top:s.top+t*o.y,bottom:s.bottom+t*o.y,left:s.left+t*o.x,right:s.right+t*o.x}),{...n})}}const J8e=Q8e(1);function e6e(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function t6e(t,e,n){const i=e6e(e);if(!i)return t;const{scaleX:r,scaleY:a,x:s,y:o}=i,l=t.left-s-(1-r)*parseFloat(n),c=t.top-o-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),u=r?t.width/r:t.width,f=a?t.height/a:t.height;return{width:u,height:f,top:c,right:l+u,bottom:c+f,left:l}}const n6e={ignoreTransform:!1};function jm(t,e){e===void 0&&(e=n6e);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:c,transformOrigin:u}=$a(t).getComputedStyle(t);c&&(n=t6e(n,c,u))}const{top:i,left:r,width:a,height:s,bottom:o,right:l}=n;return{top:i,left:r,width:a,height:s,bottom:o,right:l}}function V$(t){return jm(t,{ignoreTransform:!0})}function i6e(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function r6e(t,e){return e===void 0&&(e=$a(t).getComputedStyle(t)),e.position==="fixed"}function a6e(t,e){e===void 0&&(e=$a(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(r=>{const a=e[r];return typeof a=="string"?n.test(a):!1})}function dM(t,e){const n=[];function i(r){if(e!=null&&n.length>=e||!r)return n;if(YO(r)&&r.scrollingElement!=null&&!n.includes(r.scrollingElement))return n.push(r.scrollingElement),n;if(!fv(r)||gJ(r)||n.includes(r))return n;const a=$a(t).getComputedStyle(r);return r!==t&&a6e(r,a)&&n.push(r),r6e(r,a)?n:i(r.parentNode)}return t?i(t):n}function wJ(t){const[e]=dM(t,1);return e??null}function aN(t){return!uM||!t?null:Lm(t)?t:KO(t)?YO(t)||t===Im(t).scrollingElement?window:fv(t)?t:null:null}function MJ(t){return Lm(t)?t.scrollX:t.scrollLeft}function EJ(t){return Lm(t)?t.scrollY:t.scrollTop}function hP(t){return{x:MJ(t),y:EJ(t)}}var Mr;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Mr||(Mr={}));function AJ(t){return!uM||!t?!1:t===document.scrollingElement}function TJ(t){const e={x:0,y:0},n=AJ(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},i={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},r=t.scrollTop<=e.y,a=t.scrollLeft<=e.x,s=t.scrollTop>=i.y,o=t.scrollLeft>=i.x;return{isTop:r,isLeft:a,isBottom:s,isRight:o,maxScroll:i,minScroll:e}}const s6e={x:.2,y:.2};function o6e(t,e,n,i,r){let{top:a,left:s,right:o,bottom:l}=n;i===void 0&&(i=10),r===void 0&&(r=s6e);const{isTop:c,isBottom:u,isLeft:f,isRight:m}=TJ(t),g={x:0,y:0},b={x:0,y:0},y={height:e.height*r.y,width:e.width*r.x};return!c&&a<=e.top+y.height?(g.y=Mr.Backward,b.y=i*Math.abs((e.top+y.height-a)/y.height)):!u&&l>=e.bottom-y.height&&(g.y=Mr.Forward,b.y=i*Math.abs((e.bottom-y.height-l)/y.height)),!m&&o>=e.right-y.width?(g.x=Mr.Forward,b.x=i*Math.abs((e.right-y.width-o)/y.width)):!f&&s<=e.left+y.width&&(g.x=Mr.Backward,b.x=i*Math.abs((e.left+y.width-s)/y.width)),{direction:g,speed:b}}function l6e(t){if(t===document.scrollingElement){const{innerWidth:a,innerHeight:s}=window;return{top:0,left:0,right:a,bottom:s,width:a,height:s}}const{top:e,left:n,right:i,bottom:r}=t.getBoundingClientRect();return{top:e,left:n,right:i,bottom:r,width:t.clientWidth,height:t.clientHeight}}function CJ(t){return t.reduce((e,n)=>Ip(e,hP(n)),wo)}function c6e(t){return t.reduce((e,n)=>e+MJ(n),0)}function u6e(t){return t.reduce((e,n)=>e+EJ(n),0)}function d6e(t,e){if(e===void 0&&(e=jm),!t)return;const{top:n,left:i,bottom:r,right:a}=e(t);wJ(t)&&(r<=0||a<=0||n>=window.innerHeight||i>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const f6e=[["x",["left","right"],c6e],["y",["top","bottom"],u6e]];class JO{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const i=dM(n),r=CJ(i);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,s,o]of f6e)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=o(i),u=r[a]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Rx{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var i;return(i=this.target)==null?void 0:i.removeEventListener(...n)})},this.target=e}add(e,n,i){var r;(r=this.target)==null||r.addEventListener(e,n,i),this.listeners.push([e,n,i])}}function h6e(t){const{EventTarget:e}=$a(t);return t instanceof e?t:Im(t)}function sN(t,e){const n=Math.abs(t.x),i=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+i**2)>e:"x"in e&&"y"in e?n>e.x&&i>e.y:"x"in e?n>e.x:"y"in e?i>e.y:!1}var Os;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Os||(Os={}));function $$(t){t.preventDefault()}function p6e(t){t.stopPropagation()}var yn;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(yn||(yn={}));const NJ={start:[yn.Space,yn.Enter],cancel:[yn.Esc],end:[yn.Space,yn.Enter,yn.Tab]},m6e=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case yn.Right:return{...n,x:n.x+25};case yn.Left:return{...n,x:n.x-25};case yn.Down:return{...n,y:n.y+25};case yn.Up:return{...n,y:n.y-25}}};class eL{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new Rx(Im(n)),this.windowListeners=new Rx($a(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Os.Resize,this.handleCancel),this.windowListeners.add(Os.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Os.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,i=e.node.current;i&&d6e(i),n(wo)}handleKeyDown(e){if(QO(e)){const{active:n,context:i,options:r}=this.props,{keyboardCodes:a=NJ,coordinateGetter:s=m6e,scrollBehavior:o="smooth"}=r,{code:l}=e;if(a.end.includes(l)){this.handleEnd(e);return}if(a.cancel.includes(l)){this.handleCancel(e);return}const{collisionRect:c}=i.current,u=c?{x:c.left,y:c.top}:wo;this.referenceCoordinates||(this.referenceCoordinates=u);const f=s(e,{active:n,context:i.current,currentCoordinates:u});if(f){const m=M0(f,u),g={x:0,y:0},{scrollableAncestors:b}=i.current;for(const y of b){const v=e.code,{isTop:x,isRight:M,isLeft:w,isBottom:E,maxScroll:T,minScroll:R}=TJ(y),N=l6e(y),j={x:Math.min(v===yn.Right?N.right-N.width/2:N.right,Math.max(v===yn.Right?N.left:N.left+N.width/2,f.x)),y:Math.min(v===yn.Down?N.bottom-N.height/2:N.bottom,Math.max(v===yn.Down?N.top:N.top+N.height/2,f.y))},C=v===yn.Right&&!M||v===yn.Left&&!w,k=v===yn.Down&&!E||v===yn.Up&&!x;if(C&&j.x!==f.x){const F=y.scrollLeft+m.x,I=v===yn.Right&&F<=T.x||v===yn.Left&&F>=R.x;if(I&&!m.y){y.scrollTo({left:F,behavior:o});return}I?g.x=y.scrollLeft-F:g.x=v===yn.Right?y.scrollLeft-T.x:y.scrollLeft-R.x,g.x&&y.scrollBy({left:-g.x,behavior:o});break}else if(k&&j.y!==f.y){const F=y.scrollTop+m.y,I=v===yn.Down&&F<=T.y||v===yn.Up&&F>=R.y;if(I&&!m.x){y.scrollTo({top:F,behavior:o});return}I?g.y=y.scrollTop-F:g.y=v===yn.Down?y.scrollTop-T.y:y.scrollTop-R.y,g.y&&y.scrollBy({top:-g.y,behavior:o});break}}this.handleMove(e,Ip(M0(f,this.referenceCoordinates),g))}}}handleMove(e,n){const{onMove:i}=this.props;e.preventDefault(),i(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}eL.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:i=NJ,onActivation:r}=e,{active:a}=n;const{code:s}=t.nativeEvent;if(i.start.includes(s)){const o=a.activatorNode.current;return o&&t.target!==o?!1:(t.preventDefault(),r?.({event:t.nativeEvent}),!0)}return!1}}];function G$(t){return!!(t&&"distance"in t)}function W$(t){return!!(t&&"delay"in t)}class tL{constructor(e,n,i){var r;i===void 0&&(i=h6e(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:a}=e,{target:s}=a;this.props=e,this.events=n,this.document=Im(s),this.documentListeners=new Rx(this.document),this.listeners=new Rx(i),this.windowListeners=new Rx($a(s)),this.initialCoordinates=(r=fP(a))!=null?r:wo,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:i}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Os.Resize,this.handleCancel),this.windowListeners.add(Os.DragStart,$$),this.windowListeners.add(Os.VisibilityChange,this.handleCancel),this.windowListeners.add(Os.ContextMenu,$$),this.documentListeners.add(Os.Keydown,this.handleKeydown),n){if(i!=null&&i({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(W$(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(G$(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:i,onPending:r}=this.props;r(i,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(Os.Click,p6e,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Os.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:i,initialCoordinates:r,props:a}=this,{onMove:s,options:{activationConstraint:o}}=a;if(!r)return;const l=(n=fP(e))!=null?n:wo,c=M0(r,l);if(!i&&o){if(G$(o)){if(o.tolerance!=null&&sN(c,o.tolerance))return this.handleCancel();if(sN(c,o.distance))return this.handleStart()}if(W$(o)&&sN(c,o.tolerance))return this.handleCancel();this.handlePending(o,c);return}e.cancelable&&e.preventDefault(),s(l)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===yn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const g6e={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class nL extends tL{constructor(e){const{event:n}=e,i=Im(n.target);super(e,g6e,i)}}nL.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:i}=e;return!n.isPrimary||n.button!==0?!1:(i?.({event:n}),!0)}}];const x6e={move:{name:"mousemove"},end:{name:"mouseup"}};var pP;(function(t){t[t.RightClick=2]="RightClick"})(pP||(pP={}));class v6e extends tL{constructor(e){super(e,x6e,Im(e.event.target))}}v6e.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:i}=e;return n.button===pP.RightClick?!1:(i?.({event:n}),!0)}}];const oN={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class b6e extends tL{constructor(e){super(e,oN)}static setup(){return window.addEventListener(oN.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(oN.move.name,e)};function e(){}}}b6e.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:i}=e;const{touches:r}=n;return r.length>1?!1:(i?.({event:n}),!0)}}];var Px;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Px||(Px={}));var US;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(US||(US={}));function y6e(t){let{acceleration:e,activator:n=Px.Pointer,canScroll:i,draggingRect:r,enabled:a,interval:s=5,order:o=US.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:f,threshold:m}=t;const g=S6e({delta:f,disabled:!a}),[b,y]=k8e(),v=A.useRef({x:0,y:0}),x=A.useRef({x:0,y:0}),M=A.useMemo(()=>{switch(n){case Px.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Px.DraggableRect:return r}},[n,r,l]),w=A.useRef(null),E=A.useCallback(()=>{const R=w.current;if(!R)return;const N=v.current.x*x.current.x,j=v.current.y*x.current.y;R.scrollBy(N,j)},[]),T=A.useMemo(()=>o===US.TreeOrder?[...c].reverse():c,[o,c]);A.useEffect(()=>{if(!a||!c.length||!M){y();return}for(const R of T){if(i?.(R)===!1)continue;const N=c.indexOf(R),j=u[N];if(!j)continue;const{direction:C,speed:k}=o6e(R,j,M,e,m);for(const F of["x","y"])g[F][C[F]]||(k[F]=0,C[F]=0);if(k.x>0||k.y>0){y(),w.current=R,b(E,s),v.current=k,x.current=C;return}}v.current={x:0,y:0},x.current={x:0,y:0},y()},[e,E,i,y,a,s,JSON.stringify(M),JSON.stringify(g),b,c,T,u,JSON.stringify(m)])}const _6e={x:{[Mr.Backward]:!1,[Mr.Forward]:!1},y:{[Mr.Backward]:!1,[Mr.Forward]:!1}};function S6e(t){let{delta:e,disabled:n}=t;const i=dP(e);return hv(r=>{if(n||!i||!r)return _6e;const a={x:Math.sign(e.x-i.x),y:Math.sign(e.y-i.y)};return{x:{[Mr.Backward]:r.x[Mr.Backward]||a.x===-1,[Mr.Forward]:r.x[Mr.Forward]||a.x===1},y:{[Mr.Backward]:r.y[Mr.Backward]||a.y===-1,[Mr.Forward]:r.y[Mr.Forward]||a.y===1}}},[n,e,i])}function w6e(t,e){const n=e!=null?t.get(e):void 0,i=n?n.node.current:null;return hv(r=>{var a;return e==null?null:(a=i??r)!=null?a:null},[i,e])}function M6e(t,e){return A.useMemo(()=>t.reduce((n,i)=>{const{sensor:r}=i,a=r.activators.map(s=>({eventName:s.eventName,handler:e(s.handler,i)}));return[...n,...a]},[]),[t,e])}var A0;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(A0||(A0={}));var mP;(function(t){t.Optimized="optimized"})(mP||(mP={}));const q$=new Map;function E6e(t,e){let{dragging:n,dependencies:i,config:r}=e;const[a,s]=A.useState(null),{frequency:o,measure:l,strategy:c}=r,u=A.useRef(t),f=v(),m=w0(f),g=A.useCallback(function(x){x===void 0&&(x=[]),!m.current&&s(M=>M===null?x:M.concat(x.filter(w=>!M.includes(w))))},[m]),b=A.useRef(null),y=hv(x=>{if(f&&!n)return q$;if(!x||x===q$||u.current!==t||a!=null){const M=new Map;for(let w of t){if(!w)continue;if(a&&a.length>0&&!a.includes(w.id)&&w.rect.current){M.set(w.id,w.rect.current);continue}const E=w.node.current,T=E?new JO(l(E),E):null;w.rect.current=T,T&&M.set(w.id,T)}return M}return x},[t,a,n,f,l]);return A.useEffect(()=>{u.current=t},[t]),A.useEffect(()=>{f||g()},[n,f]),A.useEffect(()=>{a&&a.length>0&&s(null)},[JSON.stringify(a)]),A.useEffect(()=>{f||typeof o!="number"||b.current!==null||(b.current=setTimeout(()=>{g(),b.current=null},o))},[o,f,g,...i]),{droppableRects:y,measureDroppableContainers:g,measuringScheduled:a!=null};function v(){switch(c){case A0.Always:return!1;case A0.BeforeDragging:return n;default:return!n}}}function RJ(t,e){return hv(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function A6e(t,e){return RJ(t,e)}function T6e(t){let{callback:e,disabled:n}=t;const i=ZO(e),r=A.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(i)},[i,n]);return A.useEffect(()=>()=>r?.disconnect(),[r]),r}function fM(t){let{callback:e,disabled:n}=t;const i=ZO(e),r=A.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(i)},[n]);return A.useEffect(()=>()=>r?.disconnect(),[r]),r}function C6e(t){return new JO(jm(t),t)}function X$(t,e,n){e===void 0&&(e=C6e);const[i,r]=A.useState(null);function a(){r(l=>{if(!t)return null;if(t.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=e(t);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const s=T6e({callback(l){if(t)for(const c of l){const{type:u,target:f}=c;if(u==="childList"&&f instanceof HTMLElement&&f.contains(t)){a();break}}}}),o=fM({callback:a});return rl(()=>{a(),t?(o?.observe(t),s?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),s?.disconnect())},[t]),i}function N6e(t){const e=RJ(t);return SJ(t,e)}const K$=[];function R6e(t){const e=A.useRef(t),n=hv(i=>t?i&&i!==K$&&t&&e.current&&t.parentNode===e.current.parentNode?i:dM(t):K$,[t]);return A.useEffect(()=>{e.current=t},[t]),n}function P6e(t){const[e,n]=A.useState(null),i=A.useRef(t),r=A.useCallback(a=>{const s=aN(a.target);s&&n(o=>o?(o.set(s,hP(s)),new Map(o)):null)},[]);return A.useEffect(()=>{const a=i.current;if(t!==a){s(a);const o=t.map(l=>{const c=aN(l);return c?(c.addEventListener("scroll",r,{passive:!0}),[c,hP(c)]):null}).filter(l=>l!=null);n(o.length?new Map(o):null),i.current=t}return()=>{s(t),s(a)};function s(o){o.forEach(l=>{const c=aN(l);c?.removeEventListener("scroll",r)})}},[r,t]),A.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,s)=>Ip(a,s),wo):CJ(t):wo,[t,e])}function Y$(t,e){e===void 0&&(e=[]);const n=A.useRef(null);return A.useEffect(()=>{n.current=null},e),A.useEffect(()=>{const i=t!==wo;i&&!n.current&&(n.current=t),!i&&n.current&&(n.current=null)},[t]),n.current?M0(t,n.current):wo}function k6e(t){A.useEffect(()=>{if(!uM)return;const e=t.map(n=>{let{sensor:i}=n;return i.setup==null?void 0:i.setup()});return()=>{for(const n of e)n?.()}},t.map(e=>{let{sensor:n}=e;return n}))}function D6e(t,e){return A.useMemo(()=>t.reduce((n,i)=>{let{eventName:r,handler:a}=i;return n[r]=s=>{a(s,e)},n},{}),[t,e])}function PJ(t){return A.useMemo(()=>t?i6e(t):null,[t])}const Z$=[];function O6e(t,e){e===void 0&&(e=jm);const[n]=t,i=PJ(n?$a(n):null),[r,a]=A.useState(Z$);function s(){a(()=>t.length?t.map(l=>AJ(l)?i:new JO(e(l),l)):Z$)}const o=fM({callback:s});return rl(()=>{o?.disconnect(),s(),t.forEach(l=>o?.observe(l))},[t]),r}function L6e(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return fv(e)?e:t}function I6e(t){let{measure:e}=t;const[n,i]=A.useState(null),r=A.useCallback(c=>{for(const{target:u}of c)if(fv(u)){i(f=>{const m=e(u);return f?{...f,width:m.width,height:m.height}:m});break}},[e]),a=fM({callback:r}),s=A.useCallback(c=>{const u=L6e(c);a?.disconnect(),u&&a?.observe(u),i(u?e(u):null)},[e,a]),[o,l]=IS(s);return A.useMemo(()=>({nodeRef:o,rect:n,setRef:l}),[n,o,l])}const j6e=[{sensor:nL,options:{}},{sensor:eL,options:{}}],U6e={current:{}},C_={draggable:{measure:V$},droppable:{measure:V$,strategy:A0.WhileDragging,frequency:mP.Optimized},dragOverlay:{measure:jm}};class kx extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,i;return(n=(i=this.get(e))==null?void 0:i.node.current)!=null?n:void 0}}const F6e={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new kx,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:jS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:C_,measureDroppableContainers:jS,windowRect:null,measuringScheduled:!1},z6e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:jS,draggableNodes:new Map,over:null,measureDroppableContainers:jS},hM=A.createContext(z6e),kJ=A.createContext(F6e);function B6e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new kx}}}function H6e(t,e){switch(e.type){case nr.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case nr.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case nr.DragEnd:case nr.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case nr.RegisterDroppable:{const{element:n}=e,{id:i}=n,r=new kx(t.droppable.containers);return r.set(i,n),{...t,droppable:{...t.droppable,containers:r}}}case nr.SetDroppableDisabled:{const{id:n,key:i,disabled:r}=e,a=t.droppable.containers.get(n);if(!a||i!==a.key)return t;const s=new kx(t.droppable.containers);return s.set(n,{...a,disabled:r}),{...t,droppable:{...t.droppable,containers:s}}}case nr.UnregisterDroppable:{const{id:n,key:i}=e,r=t.droppable.containers.get(n);if(!r||i!==r.key)return t;const a=new kx(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function V6e(t){let{disabled:e}=t;const{active:n,activatorEvent:i,draggableNodes:r}=A.useContext(hM),a=dP(i),s=dP(n?.id);return A.useEffect(()=>{if(!e&&!i&&a&&s!=null){if(!QO(a)||document.activeElement===a.target)return;const o=r.get(s);if(!o)return;const{activatorNode:l,node:c}=o;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const f=L8e(u);if(f){f.focus();break}}})}},[i,e,r,s,a]),null}function $6e(t,e){let{transform:n,...i}=e;return t!=null&&t.length?t.reduce((r,a)=>a({transform:r,...i}),n):n}function G6e(t){return A.useMemo(()=>({draggable:{...C_.draggable,...t?.draggable},droppable:{...C_.droppable,...t?.droppable},dragOverlay:{...C_.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function W6e(t){let{activeNode:e,measure:n,initialRect:i,config:r=!0}=t;const a=A.useRef(!1),{x:s,y:o}=typeof r=="boolean"?{x:r,y:r}:r;rl(()=>{if(!s&&!o||!e){a.current=!1;return}if(a.current||!i)return;const c=e?.node.current;if(!c||c.isConnected===!1)return;const u=n(c),f=SJ(u,i);if(s||(f.x=0),o||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const m=wJ(c);m&&m.scrollBy({top:f.y,left:f.x})}},[e,s,o,i,n])}const DJ=A.createContext({...wo,scaleX:1,scaleY:1});var Mu;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Mu||(Mu={}));const q6e=A.memo(function(e){var n,i,r,a;let{id:s,accessibility:o,autoScroll:l=!0,children:c,sensors:u=j6e,collisionDetection:f=Y8e,measuring:m,modifiers:g,...b}=e;const y=A.useReducer(H6e,void 0,B6e),[v,x]=y,[M,w]=B8e(),[E,T]=A.useState(Mu.Uninitialized),R=E===Mu.Initialized,{draggable:{active:N,nodes:j,translate:C},droppable:{containers:k}}=v,F=N!=null?j.get(N):null,I=A.useRef({initial:null,translated:null}),q=A.useMemo(()=>{var Oe;return N!=null?{id:N,data:(Oe=F?.data)!=null?Oe:U6e,rect:I}:null},[N,F]),O=A.useRef(null),[H,V]=A.useState(null),[$,K]=A.useState(null),Y=w0(b,Object.values(b)),se=pv("DndDescribedBy",s),B=A.useMemo(()=>k.getEnabled(),[k]),X=G6e(m),{droppableRects:ae,measureDroppableContainers:ce,measuringScheduled:xe}=E6e(B,{dragging:R,dependencies:[C.x,C.y],config:X.droppable}),ie=w6e(j,N),ve=A.useMemo(()=>$?fP($):null,[$]),Pe=fe(),pe=A6e(ie,X.draggable.measure);W6e({activeNode:N!=null?j.get(N):null,config:Pe.layoutShiftCompensation,initialRect:pe,measure:X.draggable.measure});const we=X$(ie,X.draggable.measure,pe),ze=X$(ie?ie.parentElement:null),ue=A.useRef({activatorEvent:null,active:null,activeNode:ie,collisionRect:null,collisions:null,droppableRects:ae,draggableNodes:j,draggingNode:null,draggingNodeRect:null,droppableContainers:k,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ht=k.getNodeFor((n=ue.current.over)==null?void 0:n.id),z=I6e({measure:X.dragOverlay.measure}),W=(i=z.nodeRef.current)!=null?i:ie,re=R?(r=z.rect)!=null?r:we:null,J=!!(z.nodeRef.current&&z.rect),ee=N6e(J?null:we),oe=PJ(W?$a(W):null),ke=R6e(R?ht??ie:null),Ne=O6e(ke),te=$6e(g,{transform:{x:C.x-ee.x,y:C.y-ee.y,scaleX:1,scaleY:1},activatorEvent:$,active:q,activeNodeRect:we,containerNodeRect:ze,draggingNodeRect:re,over:ue.current.over,overlayNodeRect:z.rect,scrollableAncestors:ke,scrollableAncestorRects:Ne,windowRect:oe}),U=ve?Ip(ve,C):null,L=P6e(ke),Z=Y$(L),me=Y$(L,[we]),be=Ip(te,Z),he=re?J8e(re,te):null,Ze=q&&he?f({active:q,collisionRect:he,droppableRects:ae,droppableContainers:B,pointerCoordinates:U}):null,Le=_J(Ze,"id"),[Xe,at]=A.useState(null),Ie=J?te:Ip(te,me),Re=Z8e(Ie,(a=Xe?.rect)!=null?a:null,we),pt=A.useRef(null),tt=A.useCallback((Oe,Me)=>{let{sensor:ge,options:Be}=Me;if(O.current==null)return;const ct=j.get(O.current);if(!ct)return;const yt=Oe.nativeEvent,Rt=new ge({active:O.current,activeNode:ct,event:yt,options:Be,context:ue,onAbort(Dt){if(!j.get(Dt))return;const{onDragAbort:qn}=Y.current,pr={id:Dt};qn?.(pr),M({type:"onDragAbort",event:pr})},onPending(Dt,Rn,qn,pr){if(!j.get(Dt))return;const{onDragPending:mr}=Y.current,Rr={id:Dt,constraint:Rn,initialCoordinates:qn,offset:pr};mr?.(Rr),M({type:"onDragPending",event:Rr})},onStart(Dt){const Rn=O.current;if(Rn==null)return;const qn=j.get(Rn);if(!qn)return;const{onDragStart:pr}=Y.current,Zi={activatorEvent:yt,active:{id:Rn,data:qn.data,rect:I}};Kl.unstable_batchedUpdates(()=>{pr?.(Zi),T(Mu.Initializing),x({type:nr.DragStart,initialCoordinates:Dt,active:Rn}),M({type:"onDragStart",event:Zi}),V(pt.current),K(yt)})},onMove(Dt){x({type:nr.DragMove,coordinates:Dt})},onEnd:ln(nr.DragEnd),onCancel:ln(nr.DragCancel)});pt.current=Rt;function ln(Dt){return async function(){const{active:qn,collisions:pr,over:Zi,scrollAdjustedTranslate:mr}=ue.current;let Rr=null;if(qn&&mr){const{cancelDrop:Wr}=Y.current;Rr={activatorEvent:yt,active:qn,collisions:pr,delta:mr,over:Zi},Dt===nr.DragEnd&&typeof Wr=="function"&&await Promise.resolve(Wr(Rr))&&(Dt=nr.DragCancel)}O.current=null,Kl.unstable_batchedUpdates(()=>{x({type:Dt}),T(Mu.Uninitialized),at(null),V(null),K(null),pt.current=null;const Wr=Dt===nr.DragEnd?"onDragEnd":"onDragCancel";if(Rr){const Li=Y.current[Wr];Li?.(Rr),M({type:Wr,event:Rr})}})}}},[j]),et=A.useCallback((Oe,Me)=>(ge,Be)=>{const ct=ge.nativeEvent,yt=j.get(Be);if(O.current!==null||!yt||ct.dndKit||ct.defaultPrevented)return;const Rt={active:yt};Oe(ge,Me.options,Rt)===!0&&(ct.dndKit={capturedBy:Me.sensor},O.current=Be,tt(ge,Me))},[j,tt]),ut=M6e(u,et);k6e(u),rl(()=>{we&&E===Mu.Initializing&&T(Mu.Initialized)},[we,E]),A.useEffect(()=>{const{onDragMove:Oe}=Y.current,{active:Me,activatorEvent:ge,collisions:Be,over:ct}=ue.current;if(!Me||!ge)return;const yt={active:Me,activatorEvent:ge,collisions:Be,delta:{x:be.x,y:be.y},over:ct};Kl.unstable_batchedUpdates(()=>{Oe?.(yt),M({type:"onDragMove",event:yt})})},[be.x,be.y]),A.useEffect(()=>{const{active:Oe,activatorEvent:Me,collisions:ge,droppableContainers:Be,scrollAdjustedTranslate:ct}=ue.current;if(!Oe||O.current==null||!Me||!ct)return;const{onDragOver:yt}=Y.current,Rt=Be.get(Le),ln=Rt&&Rt.rect.current?{id:Rt.id,rect:Rt.rect.current,data:Rt.data,disabled:Rt.disabled}:null,Dt={active:Oe,activatorEvent:Me,collisions:ge,delta:{x:ct.x,y:ct.y},over:ln};Kl.unstable_batchedUpdates(()=>{at(ln),yt?.(Dt),M({type:"onDragOver",event:Dt})})},[Le]),rl(()=>{ue.current={activatorEvent:$,active:q,activeNode:ie,collisionRect:he,collisions:Ze,droppableRects:ae,draggableNodes:j,draggingNode:W,draggingNodeRect:re,droppableContainers:k,over:Xe,scrollableAncestors:ke,scrollAdjustedTranslate:be},I.current={initial:re,translated:he}},[q,ie,Ze,he,j,W,re,ae,k,Xe,ke,be]),y6e({...Pe,delta:C,draggingRect:he,pointerCoordinates:U,scrollableAncestors:ke,scrollableAncestorRects:Ne});const de=A.useMemo(()=>({active:q,activeNode:ie,activeNodeRect:we,activatorEvent:$,collisions:Ze,containerNodeRect:ze,dragOverlay:z,draggableNodes:j,droppableContainers:k,droppableRects:ae,over:Xe,measureDroppableContainers:ce,scrollableAncestors:ke,scrollableAncestorRects:Ne,measuringConfiguration:X,measuringScheduled:xe,windowRect:oe}),[q,ie,we,$,Ze,ze,z,j,k,ae,Xe,ce,ke,Ne,X,xe,oe]),nt=A.useMemo(()=>({activatorEvent:$,activators:ut,active:q,activeNodeRect:we,ariaDescribedById:{draggable:se},dispatch:x,draggableNodes:j,over:Xe,measureDroppableContainers:ce}),[$,ut,q,we,x,se,j,Xe,ce]);return ui.createElement(vJ.Provider,{value:w},ui.createElement(hM.Provider,{value:nt},ui.createElement(kJ.Provider,{value:de},ui.createElement(DJ.Provider,{value:Re},c)),ui.createElement(V6e,{disabled:o?.restoreFocus===!1})),ui.createElement($8e,{...o,hiddenTextDescribedById:se}));function fe(){const Oe=H?.autoScrollEnabled===!1,Me=typeof l=="object"?l.enabled===!1:l===!1,ge=R&&!Oe&&!Me;return typeof l=="object"?{...l,enabled:ge}:{enabled:ge}}}),X6e=A.createContext(null),Q$="button",K6e="Draggable";function Y6e(t){let{id:e,data:n,disabled:i=!1,attributes:r}=t;const a=pv(K6e),{activators:s,activatorEvent:o,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:f,over:m}=A.useContext(hM),{role:g=Q$,roleDescription:b="draggable",tabIndex:y=0}=r??{},v=l?.id===e,x=A.useContext(v?DJ:X6e),[M,w]=IS(),[E,T]=IS(),R=D6e(s,e),N=w0(n);rl(()=>(f.set(e,{id:e,key:a,node:M,activatorNode:E,data:N}),()=>{const C=f.get(e);C&&C.key===a&&f.delete(e)}),[f,e]);const j=A.useMemo(()=>({role:g,tabIndex:y,"aria-disabled":i,"aria-pressed":v&&g===Q$?!0:void 0,"aria-roledescription":b,"aria-describedby":u.draggable}),[i,g,y,v,b,u.draggable]);return{active:l,activatorEvent:o,activeNodeRect:c,attributes:j,isDragging:v,listeners:i?void 0:R,node:M,over:m,setNodeRef:w,setActivatorNodeRef:T,transform:x}}function Z6e(){return A.useContext(kJ)}const Q6e="Droppable",J6e={timeout:25};function eVe(t){let{data:e,disabled:n=!1,id:i,resizeObserverConfig:r}=t;const a=pv(Q6e),{active:s,dispatch:o,over:l,measureDroppableContainers:c}=A.useContext(hM),u=A.useRef({disabled:n}),f=A.useRef(!1),m=A.useRef(null),g=A.useRef(null),{disabled:b,updateMeasurementsFor:y,timeout:v}={...J6e,...r},x=w0(y??i),M=A.useCallback(()=>{if(!f.current){f.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{c(Array.isArray(x.current)?x.current:[x.current]),g.current=null},v)},[v]),w=fM({callback:M,disabled:b||!s}),E=A.useCallback((j,C)=>{w&&(C&&(w.unobserve(C),f.current=!1),j&&w.observe(j))},[w]),[T,R]=IS(E),N=w0(e);return A.useEffect(()=>{!w||!T.current||(w.disconnect(),f.current=!1,w.observe(T.current))},[T,w]),A.useEffect(()=>(o({type:nr.RegisterDroppable,element:{id:i,key:a,disabled:n,node:T,rect:m,data:N}}),()=>o({type:nr.UnregisterDroppable,key:a,id:i})),[i]),A.useEffect(()=>{n!==u.current.disabled&&(o({type:nr.SetDroppableDisabled,id:i,key:a,disabled:n}),u.current.disabled=n)},[i,a,n,o]),{active:s,rect:m,isOver:l?.id===i,node:T,over:l,setNodeRef:R}}function iL(t,e,n){const i=t.slice();return i.splice(n<0?i.length+n:n,0,i.splice(e,1)[0]),i}function tVe(t,e){return t.reduce((n,i,r)=>{const a=e.get(i);return a&&(n[r]=a),n},Array(t.length))}function i_(t){return t!==null&&t>=0}function nVe(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n{let{rects:e,activeIndex:n,overIndex:i,index:r}=t;const a=iL(e,i,n),s=e[r],o=a[r];return!o||!s?null:{x:o.left-s.left,y:o.top-s.top,scaleX:o.width/s.width,scaleY:o.height/s.height}},OJ="Sortable",LJ=ui.createContext({activeIndex:-1,containerId:OJ,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:rL,disabled:{draggable:!1,droppable:!1}});function rVe(t){let{children:e,id:n,items:i,strategy:r=rL,disabled:a=!1}=t;const{active:s,dragOverlay:o,droppableRects:l,over:c,measureDroppableContainers:u}=Z6e(),f=pv(OJ,n),m=o.rect!==null,g=A.useMemo(()=>i.map(R=>typeof R=="object"&&"id"in R?R.id:R),[i]),b=s!=null,y=s?g.indexOf(s.id):-1,v=c?g.indexOf(c.id):-1,x=A.useRef(g),M=!nVe(g,x.current),w=v!==-1&&y===-1||M,E=iVe(a);rl(()=>{M&&b&&u(g)},[M,g,b,u]),A.useEffect(()=>{x.current=g},[g]);const T=A.useMemo(()=>({activeIndex:y,containerId:f,disabled:E,disableTransforms:w,items:g,overIndex:v,useDragOverlay:m,sortedRects:tVe(g,l),strategy:r}),[y,f,E.draggable,E.droppable,w,g,v,l,m,r]);return ui.createElement(LJ.Provider,{value:T},e)}const aVe=t=>{let{id:e,items:n,activeIndex:i,overIndex:r}=t;return iL(n,i,r).indexOf(e)},sVe=t=>{let{containerId:e,isSorting:n,wasDragging:i,index:r,items:a,newIndex:s,previousItems:o,previousContainerId:l,transition:c}=t;return!c||!i||o!==a&&r===s?!1:n?!0:s!==r&&e===l},oVe={duration:200,easing:"ease"},IJ="transform",lVe=E0.Transition.toString({property:IJ,duration:0,easing:"linear"}),cVe={roleDescription:"sortable"};function uVe(t){let{disabled:e,index:n,node:i,rect:r}=t;const[a,s]=A.useState(null),o=A.useRef(n);return rl(()=>{if(!e&&n!==o.current&&i.current){const l=r.current;if(l){const c=jm(i.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&s(u)}}n!==o.current&&(o.current=n)},[e,n,i,r]),A.useEffect(()=>{a&&s(null)},[a]),a}function dVe(t){let{animateLayoutChanges:e=sVe,attributes:n,disabled:i,data:r,getNewIndex:a=aVe,id:s,strategy:o,resizeObserverConfig:l,transition:c=oVe}=t;const{items:u,containerId:f,activeIndex:m,disabled:g,disableTransforms:b,sortedRects:y,overIndex:v,useDragOverlay:x,strategy:M}=A.useContext(LJ),w=fVe(i,g),E=u.indexOf(s),T=A.useMemo(()=>({sortable:{containerId:f,index:E,items:u},...r}),[f,r,E,u]),R=A.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:N,node:j,isOver:C,setNodeRef:k}=eVe({id:s,data:T,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:R,...l}}),{active:F,activatorEvent:I,activeNodeRect:q,attributes:O,setNodeRef:H,listeners:V,isDragging:$,over:K,setActivatorNodeRef:Y,transform:se}=Y6e({id:s,data:T,attributes:{...cVe,...n},disabled:w.draggable}),B=P8e(k,H),X=!!F,ae=X&&!b&&i_(m)&&i_(v),ce=!x&&$,xe=ce&&ae?se:null,ve=ae?xe??(o??M)({rects:y,activeNodeRect:q,activeIndex:m,overIndex:v,index:E}):null,Pe=i_(m)&&i_(v)?a({id:s,items:u,activeIndex:m,overIndex:v}):E,pe=F?.id,we=A.useRef({activeId:pe,items:u,newIndex:Pe,containerId:f}),ze=u!==we.current.items,ue=e({active:F,containerId:f,isDragging:$,isSorting:X,id:s,index:E,items:u,newIndex:we.current.newIndex,previousItems:we.current.items,previousContainerId:we.current.containerId,transition:c,wasDragging:we.current.activeId!=null}),ht=uVe({disabled:!ue,index:E,node:j,rect:N});return A.useEffect(()=>{X&&we.current.newIndex!==Pe&&(we.current.newIndex=Pe),f!==we.current.containerId&&(we.current.containerId=f),u!==we.current.items&&(we.current.items=u)},[X,Pe,f,u]),A.useEffect(()=>{if(pe===we.current.activeId)return;if(pe!=null&&we.current.activeId==null){we.current.activeId=pe;return}const W=setTimeout(()=>{we.current.activeId=pe},50);return()=>clearTimeout(W)},[pe]),{active:F,activeIndex:m,attributes:O,data:T,rect:N,index:E,newIndex:Pe,items:u,isOver:C,isSorting:X,isDragging:$,listeners:V,node:j,overIndex:v,over:K,setNodeRef:B,setActivatorNodeRef:Y,setDroppableNodeRef:k,setDraggableNodeRef:H,transform:ht??ve,transition:z()};function z(){if(ht||ze&&we.current.newIndex===E)return lVe;if(!(ce&&!QO(I)||!c)&&(X||ue))return E0.Transition.toString({...c,property:IJ})}}function fVe(t,e){var n,i;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t?.draggable)!=null?n:e.draggable,droppable:(i=t?.droppable)!=null?i:e.droppable}}function FS(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const hVe=[yn.Down,yn.Right,yn.Up,yn.Left],pVe=(t,e)=>{let{context:{active:n,collisionRect:i,droppableRects:r,droppableContainers:a,over:s,scrollableAncestors:o}}=e;if(hVe.includes(t.code)){if(t.preventDefault(),!n||!i)return;const l=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const m=r.get(f.id);if(m)switch(t.code){case yn.Down:i.topm.top&&l.push(f);break;case yn.Left:i.left>m.left&&l.push(f);break;case yn.Right:i.left1&&(u=c[1].id),u!=null){const f=a.get(n.id),m=a.get(u),g=m?r.get(m.id):null,b=m?.node.current;if(b&&g&&f&&m){const v=dM(b).some((R,N)=>o[N]!==R),x=jJ(f,m),M=mVe(f,m),w=v||!x?{x:0,y:0}:{x:M?i.width-g.width:0,y:M?i.height-g.height:0},E={x:g.left,y:g.top};return w.x&&w.y?E:M0(E,w)}}}};function jJ(t,e){return!FS(t)||!FS(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function mVe(t,e){return!FS(t)||!FS(e)||!jJ(t,e)?!1:t.data.current.sortable.index{const v={};return t.forEach(x=>{v[x.id]=x.defaultSize||4}),v},[r,a]=A.useState(()=>{const v=localStorage.getItem(e);if(v)try{const x=JSON.parse(v);return x.sizes||(x.sizes=i()),x}catch{}return{order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:i()}}),[s,o]=A.useState(!1);A.useEffect(()=>{localStorage.setItem(e,JSON.stringify(r))},[r,e]),A.useEffect(()=>{const x=t.map(M=>M.id).filter(M=>!r.order.includes(M));x.length>0&&a(M=>({...M,order:[...M.order,...x]}))},[t,r.order]);const l=G8e(z$(nL,{activationConstraint:{distance:8}}),z$(eL,{coordinateGetter:pVe})),c=v=>{const{active:x,over:M}=v;M&&x.id!==M.id&&a(w=>{const E=w.order.indexOf(x.id),T=w.order.indexOf(M.id);return{...w,order:iL(w.order,E,T)}})},u=v=>{a(x=>({...x,hidden:x.hidden.includes(v)?x.hidden.filter(M=>M!==v):[...x.hidden,v]}))},f=v=>{a(x=>{const M=x.sizes[v]||4,w=M===1?2:M===2?4:1;return{...x,sizes:{...x.sizes,[v]:w}}})},m=()=>{const v={order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:i()};a(v)},g=r.order.map(v=>t.find(x=>x.id===v)).filter(Boolean),b=g.filter(v=>!r.hidden.includes(v.id)),y=g.filter(v=>r.hidden.includes(v.id));return p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"flex items-center justify-end gap-2",children:[y.length>0&&p.jsxs(lt,{variant:"secondary",size:"sm",onClick:()=>o(!s),children:[p.jsx(U4,{className:"w-4 h-4"}),y.length," Hidden"]}),p.jsxs(lt,{variant:"secondary",size:"sm",onClick:m,children:[p.jsx(XS,{className:"w-4 h-4"}),"Reset Layout"]})]}),s&&y.length>0&&p.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[p.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),p.jsx("div",{className:"flex flex-wrap gap-2",children:y.map(v=>p.jsxs("button",{onClick:()=>u(v.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[p.jsx(U4,{className:"w-3 h-3"}),v.title]},v.id))})]}),p.jsx(q6e,{sensors:l,collisionDetection:q8e,onDragEnd:c,children:p.jsx(rVe,{items:b.map(v=>v.id),strategy:rL,children:p.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:b.map(v=>p.jsx(gVe,{id:v.id,title:v.title,isHidden:r.hidden.includes(v.id),size:r.sizes[v.id]||2,onToggleVisibility:()=>u(v.id),onToggleSize:()=>f(v.id),children:v.component},v.id))})})}),b.length===0&&p.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[p.jsx("p",{children:"All widgets are hidden."}),p.jsx(lt,{className:"mt-4",onClick:m,children:"Reset Layout"})]})]})}function vVe({stats:t,currency:e}){return p.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:p.jsx(F_,{className:"w-5 h-5"})}),p.jsxs("div",{children:[p.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),p.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:p.jsx(xa,{className:"w-5 h-5"})}),p.jsxs("div",{children:[p.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),p.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:p.jsx(F_,{className:"w-5 h-5"})}),p.jsxs("div",{children:[p.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),p.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:p.jsx(j4,{className:"w-5 h-5"})}),p.jsxs("div",{children:[p.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),p.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:p.jsx(r9,{className:"w-5 h-5"})}),p.jsxs("div",{children:[p.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),p.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:p.jsx(j4,{className:"w-5 h-5"})}),p.jsxs("div",{children:[p.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),p.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function bVe({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return p.jsxs("div",{className:"flex items-center gap-6",children:[p.jsxs("div",{className:"relative w-28 h-28",children:[p.jsxs("svg",{className:"w-full h-full -rotate-90",children:[p.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),p.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),p.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:p.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(rd,{className:"w-4 h-4 text-bambu-green"}),p.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),p.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(R0,{className:"w-4 h-4 text-red-400"}),p.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),p.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function yVe({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return p.jsx("div",{className:"flex items-center justify-center h-full",children:p.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const r=(Math.min(150,Math.max(50,n))-50)/100*100,s=(l=>l>=95&&l<=105?"#00ae42":l>105?"#3b82f6":"#f97316")(n),o=n-100;return p.jsxs("div",{className:"flex items-center gap-6",children:[p.jsxs("div",{className:"relative w-28 h-28",children:[p.jsxs("svg",{className:"w-full h-full -rotate-90",children:[p.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),p.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:s,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${r*3.02} 302`})]}),p.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[p.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),p.jsxs("span",{className:`text-xs ${o>=0?"text-blue-400":"text-orange-400"}`,children:[o>=0?"+":"",o.toFixed(0),"%"]})]})]}),p.jsxs("div",{className:"space-y-2 flex-1",children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[p.jsx($oe,{className:"w-3 h-3"}),p.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&p.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([l,c])=>p.jsxs("div",{className:"flex items-center justify-between text-xs",children:[p.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(l)||`Printer ${l}`}),p.jsxs("span",{className:`font-medium ${c>=95&&c<=105?"text-bambu-green":c>105?"text-blue-400":"text-orange-400"}`,children:[c.toFixed(0),"%"]})]},l))})]})]})}function _Ve({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return p.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No filament data available"});const e=Object.entries(t.prints_by_filament_type).sort(([,n],[,i])=>i-n);return p.jsx("div",{className:"space-y-3",children:e.map(([n,i])=>{const r=Math.round(i/(t.total_prints||1)*100);return p.jsxs("div",{children:[p.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[p.jsx("span",{className:"text-white",children:n}),p.jsxs("span",{className:"text-bambu-gray",children:[i," prints"]})]}),p.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:p.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${r}%`}})})]},n)})})}function SVe({printDates:t}){return p.jsx(w2e,{printDates:t,months:4})}function wVe({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?p.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):p.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,i])=>p.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[p.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:p.jsx(hc,{className:"w-4 h-4 text-bambu-green"})}),p.jsxs("div",{children:[p.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),p.jsxs("p",{className:"text-xs text-bambu-gray",children:[i," prints"]})]})]},n))})}function MVe({archives:t,currency:e}){return!t||t.length===0?p.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):p.jsx(R8e,{archives:t,currency:e})}function EVe(){const{data:t,isLoading:e}=Ht({queryKey:["archiveStats"],queryFn:$e.getArchiveStats}),{data:n}=Ht({queryKey:["printers"],queryFn:$e.getPrinters}),{data:i}=Ht({queryKey:["archives"],queryFn:()=>$e.getArchives(void 0,1e3,0)}),{data:r}=Ht({queryKey:["settings"],queryFn:$e.getSettings}),a=r?.currency||"$",s=new Map(n?.map(c=>[String(c.id),c.name])||[]),o=i?.map(c=>c.created_at)||[];if(e)return p.jsx("div",{className:"p-8",children:p.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const l=[{id:"quick-stats",title:"Quick Stats",component:p.jsx(vVe,{stats:t,currency:a}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:p.jsx(bVe,{stats:t}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:p.jsx(yVe,{stats:t,printerMap:s}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:p.jsx(_Ve,{stats:t}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:p.jsx(SVe,{printDates:o}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:p.jsx(wVe,{stats:t,printerMap:s}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:p.jsx(MVe,{archives:i||[],currency:a}),defaultSize:4}];return p.jsxs("div",{className:"p-8",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),p.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),p.jsx(xVe,{widgets:l,storageKey:"bambusy-dashboard-layout"})]})}function AVe({plug:t,onEdit:e}){const n=Gn(),[i,r]=A.useState(!1),[a,s]=A.useState(!1),[o,l]=A.useState(!1),[c,u]=A.useState(!1),{data:f,isLoading:m,refetch:g}=Ht({queryKey:["smart-plug-status",t.id],queryFn:()=>$e.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:b}=Ht({queryKey:["printers"],queryFn:$e.getPrinters}),y=b?.find(R=>R.id===t.printer_id),v=Mt({mutationFn:R=>$e.controlSmartPlug(t.id,R),onSuccess:()=>{g()}}),x=Mt({mutationFn:R=>$e.updateSmartPlug(t.id,R),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),M=Mt({mutationFn:()=>$e.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=f?.state==="ON",E=f?.reachable??!1,T=v.isPending;return p.jsxs(p.Fragment,{children:[p.jsx(Xt,{className:"relative",children:p.jsxs(en,{className:"p-4",children:[p.jsxs("div",{className:"flex items-start justify-between mb-3",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`p-2 rounded-lg ${E?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:p.jsx(EN,{className:`w-5 h-5 ${E?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),p.jsxs("div",{children:[p.jsx("h3",{className:"font-medium text-white",children:t.name}),p.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),p.jsx("div",{className:"flex items-center gap-2",children:m?p.jsx(It,{className:"w-4 h-4 text-bambu-gray animate-spin"}):E?p.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[p.jsx(OP,{className:"w-4 h-4 text-bambu-green"}),p.jsx("span",{className:w?"text-bambu-green":"text-bambu-gray",children:f?.state||"Unknown"})]}):p.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[p.jsx(Fp,{className:"w-4 h-4"}),p.jsx("span",{children:"Offline"})]})})]}),y&&p.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[p.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),p.jsx("span",{className:"text-sm text-white",children:y.name})]}),p.jsxs("div",{className:"flex gap-2 mb-3",children:[p.jsxs(lt,{size:"sm",variant:w?"primary":"secondary",disabled:!E||T,onClick:()=>s(!0),className:"flex-1",children:[T?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(qS,{className:"w-4 h-4"}),"On"]}),p.jsxs(lt,{size:"sm",variant:w?"secondary":"primary",disabled:!E||T,onClick:()=>l(!0),className:"flex-1",children:[T?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(e9,{className:"w-4 h-4"}),"Off"]})]}),p.jsxs("button",{onClick:()=>u(!c),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx(DP,{className:"w-4 h-4"}),"Automation Settings"]}),p.jsx("span",{children:c?"-":"+"})]}),c&&p.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-sm text-white",children:"Enabled"}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),p.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:t.enabled,onChange:R=>x.mutate({enabled:R.target.checked}),className:"sr-only peer"}),p.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-sm text-white",children:"Auto On"}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),p.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:R=>x.mutate({auto_on:R.target.checked}),className:"sr-only peer"}),p.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),p.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:R=>x.mutate({auto_off:R.target.checked}),className:"sr-only peer"}),p.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&p.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),p.jsxs("div",{className:"flex gap-2",children:[p.jsxs("button",{onClick:()=>x.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[p.jsx(xa,{className:"w-4 h-4"}),"Time"]}),p.jsxs("button",{onClick:()=>x.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[p.jsx(o_,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?p.jsxs("div",{children:[p.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),p.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:R=>x.mutate({off_delay_minutes:parseInt(R.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):p.jsxs("div",{children:[p.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),p.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:R=>x.mutate({off_temp_threshold:parseInt(R.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),p.jsxs("div",{className:"flex gap-2 pt-2",children:[p.jsxs(lt,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[p.jsx(JG,{className:"w-4 h-4"}),"Edit"]}),p.jsx(lt,{size:"sm",variant:"secondary",onClick:()=>r(!0),className:"text-red-400 hover:text-red-300",children:p.jsx(ia,{className:"w-4 h-4"})})]})]})]})}),i&&p.jsx(rr,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{M.mutate(),r(!1)},onCancel:()=>r(!1)}),a&&p.jsx(rr,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{v.mutate("on"),s(!1)},onCancel:()=>s(!1)}),o&&p.jsx(rr,{title:"Turn Off Smart Plug",message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:"Turn Off",variant:"danger",onConfirm:()=>{v.mutate("off"),l(!1)},onCancel:()=>l(!1)})]})}function TVe({plug:t,onClose:e}){const n=Gn(),i=!!t,[r,a]=A.useState(t?.name||""),[s,o]=A.useState(t?.ip_address||""),[l,c]=A.useState(t?.username||""),[u,f]=A.useState(t?.password||""),[m,g]=A.useState(t?.printer_id||null),[b,y]=A.useState(null),[v,x]=A.useState(null),{data:M}=Ht({queryKey:["printers"],queryFn:$e.getPrinters}),{data:w}=Ht({queryKey:["smart-plugs"],queryFn:$e.getSmartPlugs});A.useEffect(()=>{const k=F=>{F.key==="Escape"&&e()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[e]);const E=Mt({mutationFn:()=>$e.testSmartPlugConnection(s,l||null,u||null),onSuccess:k=>{y(k),x(null),!r&&k.device_name&&a(k.device_name)},onError:k=>{y(null),x(k.message)}}),T=Mt({mutationFn:k=>$e.createSmartPlug(k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:k=>{x(k.message)}}),R=Mt({mutationFn:k=>$e.updateSmartPlug(t.id,k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:k=>{x(k.message)}}),N=M?.filter(k=>!w?.some(I=>I.printer_id===k.id&&I.id!==t?.id)),j=k=>{if(k.preventDefault(),x(null),!r.trim()){x("Name is required");return}if(!s.trim()){x("IP address is required");return}const F={name:r.trim(),ip_address:s.trim(),username:l.trim()||null,password:u.trim()||null,printer_id:m};i?R.mutate(F):T.mutate(F)},C=T.isPending||R.isPending;return p.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:p.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:k=>k.stopPropagation(),children:[p.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[p.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Smart Plug":"Add Smart Plug"}),p.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:p.jsx(Sn,{className:"w-5 h-5"})})]}),p.jsxs("form",{onSubmit:j,className:"p-6 space-y-4",children:[v&&p.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:v}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{type:"text",value:s,onChange:k=>{o(k.target.value),y(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),p.jsxs(lt,{type:"button",variant:"secondary",onClick:()=>E.mutate(),disabled:!s.trim()||E.isPending,children:[E.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(OP,{className:"w-4 h-4"}),"Test"]})]})]}),b&&p.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${b.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:b.success?p.jsxs(p.Fragment,{children:[p.jsx(rd,{className:"w-5 h-5"}),p.jsxs("div",{children:[p.jsx("p",{className:"font-medium",children:"Connected!"}),p.jsxs("p",{className:"text-sm opacity-80",children:[b.device_name&&`Device: ${b.device_name} - `,"State: ",b.state]})]})]}):p.jsxs(p.Fragment,{children:[p.jsx(Fp,{className:"w-5 h-5"}),p.jsx("span",{children:"Connection failed"})]})}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),p.jsx("input",{type:"text",value:r,onChange:k=>a(k.target.value),placeholder:"Living Room Plug",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"})]}),p.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),p.jsx("input",{type:"text",value:l,onChange:k=>c(k.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),p.jsx("input",{type:"password",value:u,onChange:k=>f(k.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),p.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),p.jsxs("select",{value:m??"",onChange:k=>g(k.target.value?Number(k.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[p.jsx("option",{value:"",children:"No printer (manual control only)"}),N?.map(k=>p.jsx("option",{value:k.id,children:k.name},k.id))]}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),p.jsxs("div",{className:"flex gap-3 pt-2",children:[p.jsx(lt,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),p.jsxs(lt,{type:"submit",disabled:C,className:"flex-1",children:[C?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(P0,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function ns({checked:t,onChange:e,disabled:n}){const i=r=>{r.preventDefault(),r.stopPropagation(),n||e(!t)};return p.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:i,className:`relative inline-flex w-9 h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:p.jsx("span",{className:`pointer-events-none absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const CVe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email"};function NVe({provider:t,onEdit:e}){const n=Gn(),[i,r]=A.useState(!1),[a,s]=A.useState(!1),[o,l]=A.useState(null),{data:c}=Ht({queryKey:["printers"],queryFn:$e.getPrinters}),u=c?.find(y=>y.id===t.printer_id),f=Mt({mutationFn:y=>$e.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=Mt({mutationFn:()=>$e.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=Mt({mutationFn:()=>$e.testNotificationProvider(t.id),onSuccess:y=>{l(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{l({success:!1,message:y.message})}}),b=y=>y||"";return p.jsxs(p.Fragment,{children:[p.jsx(Xt,{className:"relative",children:p.jsxs(en,{className:"p-4",children:[p.jsxs("div",{className:"flex items-start justify-between mb-3",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:p.jsx(SN,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),p.jsxs("div",{children:[p.jsx("h3",{className:"font-medium text-white",children:t.name}),p.jsx("p",{className:"text-sm text-bambu-gray",children:CVe[t.provider_type]||t.provider_type})]})]}),p.jsxs("div",{className:"flex items-center gap-2",children:[t.last_success&&p.jsxs("span",{className:"text-xs text-bambu-green",children:["Last sent: ",new Date(t.last_success).toLocaleDateString()]}),t.last_error&&p.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"})]})]}),u&&p.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[p.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),p.jsx("span",{className:"text-sm text-white",children:u.name})]}),!u&&!t.printer_id&&p.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:p.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),p.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&p.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&p.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&p.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&p.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&p.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&p.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&p.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Error"}),t.on_filament_low&&p.jsx("span",{className:"px-2 py-0.5 bg-amber-500/20 text-amber-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&p.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.quiet_hours_enabled&&p.jsxs("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded flex items-center gap-1",children:[p.jsx(U_,{className:"w-3 h-3"}),"Quiet"]})]}),p.jsx("div",{className:"mb-3",children:p.jsxs(lt,{size:"sm",variant:"secondary",disabled:g.isPending,onClick:()=>{l(null),g.mutate()},className:"w-full",children:[g.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(t9,{className:"w-4 h-4"}),"Send Test Notification"]})}),o&&p.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${o.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[o.success?p.jsx(rd,{className:"w-4 h-4"}):p.jsx(R0,{className:"w-4 h-4"}),p.jsx("span",{children:o.message})]}),p.jsxs("button",{onClick:()=>s(!a),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx(DP,{className:"w-4 h-4"}),"Event Settings"]}),a?p.jsx(CP,{className:"w-4 h-4"}):p.jsx(gm,{className:"w-4 h-4"})]}),a&&p.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-sm text-white",children:"Enabled"}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),p.jsx(ns,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("p",{className:"text-sm text-white",children:"Print Started"}),p.jsx(ns,{checked:t.on_print_start,onChange:y=>f.mutate({on_print_start:y})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),p.jsx(ns,{checked:t.on_print_complete,onChange:y=>f.mutate({on_print_complete:y})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),p.jsx(ns,{checked:t.on_print_failed,onChange:y=>f.mutate({on_print_failed:y})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),p.jsx(ns,{checked:t.on_print_stopped,onChange:y=>f.mutate({on_print_stopped:y})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),p.jsx(ns,{checked:t.on_print_progress,onChange:y=>f.mutate({on_print_progress:y})})]})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),p.jsx(ns,{checked:t.on_printer_offline,onChange:y=>f.mutate({on_printer_offline:y})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),p.jsx(ns,{checked:t.on_printer_error,onChange:y=>f.mutate({on_printer_error:y})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),p.jsx(ns,{checked:t.on_filament_low,onChange:y=>f.mutate({on_filament_low:y})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),p.jsx(ns,{checked:t.on_maintenance_due??!1,onChange:y=>f.mutate({on_maintenance_due:y})})]})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(U_,{className:"w-4 h-4 text-purple-400"}),p.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),p.jsx(ns,{checked:t.quiet_hours_enabled,onChange:y=>f.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&p.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[p.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(xa,{className:"w-4 h-4 text-bambu-gray"}),p.jsxs("span",{className:"text-sm text-white",children:[b(t.quiet_hours_start)||"22:00"," - ",b(t.quiet_hours_end)||"07:00"]})]}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),p.jsxs("div",{className:"flex gap-2 pt-2",children:[p.jsxs(lt,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[p.jsx(JG,{className:"w-4 h-4"}),"Edit"]}),p.jsx(lt,{size:"sm",variant:"secondary",onClick:()=>r(!0),className:"text-red-400 hover:text-red-300",children:p.jsx(ia,{className:"w-4 h-4"})})]})]})]})}),i&&p.jsx(rr,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{m.mutate(),r(!1)},onCancel:()=>r(!1)})]})}const J$=[{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"email",label:"Email",description:"SMTP email notifications"}];function RVe({provider:t,onClose:e}){const n=Gn(),i=!!t,[r,a]=A.useState(t?.name||""),[s,o]=A.useState(t?.provider_type||"ntfy"),[l,c]=A.useState(t?.printer_id||null),[u,f]=A.useState(t?.quiet_hours_enabled||!1),[m,g]=A.useState(t?.quiet_hours_start||"22:00"),[b,y]=A.useState(t?.quiet_hours_end||"07:00"),[v,x]=A.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([H,V])=>[H,String(V)])):{}),[M,w]=A.useState(null),[E,T]=A.useState(null),{data:R}=Ht({queryKey:["printers"],queryFn:$e.getPrinters});A.useEffect(()=>{const H=V=>{V.key==="Escape"&&e()};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[e]);const N=Mt({mutationFn:()=>$e.testNotificationConfig({provider_type:s,config:v}),onSuccess:H=>{w(H),T(null)},onError:H=>{w({success:!1,message:H.message})}}),j=Mt({mutationFn:H=>$e.createNotificationProvider(H),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:H=>{T(H.message)}}),C=Mt({mutationFn:H=>$e.updateNotificationProvider(t.id,H),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:H=>{T(H.message)}}),k=H=>{if(H.preventDefault(),T(null),!r.trim()){T("Name is required");return}const V=q(s);for(const K of V)if(!v[K.key]?.trim()){T(`${K.label} is required`);return}const $={name:r.trim(),provider_type:s,config:v,printer_id:l,quiet_hours_enabled:u,quiet_hours_start:u?m:null,quiet_hours_end:u?b:null};i?C.mutate($):j.mutate($)},F=j.isPending||C.isPending,I=H=>{switch(H){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambutrack",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];default:return[]}},q=H=>I(H).filter(V=>V.required),O=I(s);return p.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:p.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8",onClick:H=>H.stopPropagation(),children:[p.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[p.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Notification Provider":"Add Notification Provider"}),p.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:p.jsx(Sn,{className:"w-5 h-5"})})]}),p.jsxs("form",{onSubmit:k,className:"p-6 space-y-4",children:[E&&p.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:E}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),p.jsx("input",{type:"text",value:r,onChange:H=>a(H.target.value),placeholder:"My Notifications",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"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),p.jsx("select",{value:s,onChange:H=>{o(H.target.value),x({}),w(null)},disabled:i,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:J$.map(H=>p.jsx("option",{value:H.value,children:H.label},H.value))}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:J$.find(H=>H.value===s)?.description})]}),p.jsxs("div",{className:"space-y-3",children:[p.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),O.map(H=>p.jsxs("div",{children:[p.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[H.label," ",H.required&&"*"]}),H.type==="select"&&H.options?p.jsx("select",{value:v[H.key]||H.options[0]?.value||"",onChange:V=>{x({...v,[H.key]:V.target.value}),w(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:H.options.map(V=>p.jsx("option",{value:V.value,children:V.label},V.value))}):p.jsx("input",{type:H.type,value:v[H.key]||"",onChange:V=>{x({...v,[H.key]:V.target.value}),w(null)},placeholder:H.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},H.key))]}),p.jsx("div",{className:"flex gap-2",children:p.jsxs(lt,{type:"button",variant:"secondary",onClick:()=>{w(null),N.mutate()},disabled:N.isPending||!v[q(s)[0]?.key],className:"flex-1",children:[N.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(t9,{className:"w-4 h-4"}),"Test Configuration"]})}),M&&p.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${M.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:M.success?p.jsxs(p.Fragment,{children:[p.jsx(rd,{className:"w-5 h-5"}),p.jsx("span",{children:M.message})]}):p.jsxs(p.Fragment,{children:[p.jsx(R0,{className:"w-5 h-5"}),p.jsx("span",{children:M.message})]})}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),p.jsxs("select",{value:l??"",onChange:H=>c(H.target.value?Number(H.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[p.jsx("option",{value:"",children:"All printers"}),R?.map(H=>p.jsx("option",{value:H.id,children:H.name},H.id))]}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),p.jsx(ns,{checked:u,onChange:f})]}),u&&p.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[p.jsxs("div",{children:[p.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),p.jsx("input",{type:"time",value:m,onChange:H=>g(H.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"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),p.jsx("input",{type:"time",value:b,onChange:H=>y(H.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"})]})]})]}),p.jsxs("div",{className:"flex gap-3 pt-2",children:[p.jsx(lt,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),p.jsxs(lt,{type:"submit",disabled:F,className:"flex-1",children:[F?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(P0,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}async function PVe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function kVe(t){const e=await fetch("/api/v1/settings/spoolman",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw new Error("Failed to save Spoolman settings");return e.json()}function DVe(){const t=Gn(),[e,n]=A.useState(!1),[i,r]=A.useState(""),[a,s]=A.useState("auto"),[o,l]=A.useState(!1),[c,u]=A.useState(!1),[f,m]=A.useState("all"),{data:g,isLoading:b}=Ht({queryKey:["spoolman-settings"],queryFn:PVe}),{data:y,isLoading:v,refetch:x}=Ht({queryKey:["spoolman-status"],queryFn:$e.getSpoolmanStatus,refetchInterval:3e4}),{data:M}=Ht({queryKey:["printers"],queryFn:$e.getPrinters});A.useEffect(()=>{g&&(n(g.spoolman_enabled==="true"),r(g.spoolman_url||""),s(g.spoolman_sync_mode||"auto"))},[g]),A.useEffect(()=>{if(g){const I=g.spoolman_enabled==="true"!==e||(g.spoolman_url||"")!==i||(g.spoolman_sync_mode||"auto")!==a;l(I)}},[g,e,i,a]);const w=Mt({mutationFn:()=>kVe({spoolman_enabled:e?"true":"false",spoolman_url:i,spoolman_sync_mode:a}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),l(!1),u(!0),setTimeout(()=>u(!1),2e3)}}),E=Mt({mutationFn:$e.connectSpoolman,onSuccess:()=>{x()}}),T=Mt({mutationFn:$e.disconnectSpoolman,onSuccess:()=>{x()}}),R=Mt({mutationFn:$e.syncAllPrintersAms,onSuccess:I=>{I.success}}),N=Mt({mutationFn:I=>$e.syncPrinterAms(I),onSuccess:I=>{I.success}}),j=()=>{f==="all"?R.mutate():N.mutate(f)},C=R.isPending||N.isPending,k=f==="all"?R.data:N.data,F=f==="all"?R.isSuccess:N.isSuccess;return b?p.jsxs(Xt,{children:[p.jsx($l,{children:p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(I4,{className:"w-5 h-5 text-bambu-green"}),p.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),p.jsx(en,{children:p.jsx("div",{className:"flex justify-center py-8",children:p.jsx(It,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):p.jsxs(Xt,{children:[p.jsx($l,{children:p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(I4,{className:"w-5 h-5 text-bambu-green"}),p.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),o&&p.jsx(lt,{size:"sm",onClick:()=>w.mutate(),disabled:w.isPending,children:w.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):c?p.jsx(jp,{className:"w-4 h-4"}):"Save"})]})}),p.jsxs(en,{className:"space-y-4",children:[p.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-white",children:"Enable Spoolman"}),p.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),p.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:e,onChange:I=>n(I.target.checked),className:"sr-only peer"}),p.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),p.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:i,onChange:I=>r(I.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),p.jsxs("select",{value:a,onChange:I=>s(I.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[p.jsx("option",{value:"auto",children:"Automatic"}),p.jsx("option",{value:"manual",children:"Manual Only"})]}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&p.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[p.jsxs("div",{className:"flex items-center justify-between mb-3",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),v?p.jsx(It,{className:"w-4 h-4 text-bambu-gray animate-spin"}):y?.connected?p.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[p.jsx(jp,{className:"w-4 h-4"}),"Connected"]}):p.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[p.jsx(Sn,{className:"w-4 h-4"}),"Disconnected"]})]}),p.jsx("div",{className:"flex gap-2",children:y?.connected?p.jsxs(lt,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(Gse,{className:"w-4 h-4"}),"Disconnect"]}):p.jsxs(lt,{size:"sm",onClick:()=>E.mutate(),disabled:E.isPending||!i,children:[E.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(qse,{className:"w-4 h-4"}),"Connect"]})})]}),E.isError&&p.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:E.error.message}),y?.connected&&p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs("div",{className:"relative flex-1",children:[p.jsxs("select",{value:f,onChange:I=>m(I.target.value==="all"?"all":Number(I.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[p.jsx("option",{value:"all",children:"All Printers"}),M?.map(I=>p.jsx("option",{value:I.id,children:I.name},I.id))]}),p.jsx(gm,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),p.jsxs(lt,{variant:"secondary",size:"sm",onClick:j,disabled:C,children:[C?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(Yo,{className:"w-4 h-4"}),"Sync"]})]})]}),F&&k&&p.jsx("div",{className:`mt-2 p-2 rounded text-sm ${k.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:k.success?`Synced ${k.synced_count} trays successfully`:`Synced ${k.synced_count} trays with ${k.errors.length} errors`})]})]})]})}function OVe(){const t=Gn(),{t:e,i18n:n}=vP(),[i,r]=A.useState(null),[a,s]=A.useState(!1),[o,l]=A.useState(!1),[c,u]=A.useState(!1),[f,m]=A.useState(null),[g,b]=A.useState(!1),[y,v]=A.useState(null),[x,M]=A.useState(s9()),w=X=>{M(X),Tle(X)},E=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:T,isLoading:R}=Ht({queryKey:["settings"],queryFn:$e.getSettings}),{data:N,isLoading:j}=Ht({queryKey:["smart-plugs"],queryFn:$e.getSmartPlugs}),{data:C,isLoading:k}=Ht({queryKey:["notification-providers"],queryFn:$e.getNotificationProviders}),{data:F}=Ht({queryKey:["ffmpeg-status"],queryFn:$e.checkFfmpeg}),{data:I}=Ht({queryKey:["version"],queryFn:$e.getVersion}),{data:q,refetch:O,isRefetching:H}=Ht({queryKey:["updateCheck"],queryFn:$e.checkForUpdates,staleTime:300*1e3}),{data:V,refetch:$}=Ht({queryKey:["updateStatus"],queryFn:$e.getUpdateStatus,refetchInterval:X=>{const ae=X.state.data;return ae?.status==="downloading"||ae?.status==="installing"?1e3:!1}}),K=Mt({mutationFn:$e.applyUpdate,onSuccess:()=>{$()}});A.useEffect(()=>{T&&!i&&r(T)},[T,i]),A.useEffect(()=>{if(T&&i){const X=T.auto_archive!==i.auto_archive||T.save_thumbnails!==i.save_thumbnails||T.capture_finish_photo!==i.capture_finish_photo||T.default_filament_cost!==i.default_filament_cost||T.currency!==i.currency||T.energy_cost_per_kwh!==i.energy_cost_per_kwh||T.energy_tracking_mode!==i.energy_tracking_mode||T.check_updates!==i.check_updates||T.notification_language!==i.notification_language;s(X)}},[T,i]);const Y=Mt({mutationFn:$e.updateSettings,onSuccess:X=>{t.setQueryData(["settings"],X),r(X),s(!1),l(!0),setTimeout(()=>l(!1),2e3),t.invalidateQueries({queryKey:["archiveStats"]})}}),se=()=>{i&&Y.mutate(i)},B=(X,ae)=>{i&&r({...i,[X]:ae})};return R||!i?p.jsx("div",{className:"p-8 flex justify-center",children:p.jsx(It,{className:"w-8 h-8 text-bambu-green animate-spin"})}):p.jsxs("div",{className:"p-8",children:[p.jsxs("div",{className:"mb-8 flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),p.jsx("p",{className:"text-bambu-gray",children:"Configure Bambusy"})]}),p.jsxs(lt,{onClick:se,disabled:!a||Y.isPending,children:[Y.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):o?p.jsx(jp,{className:"w-4 h-4"}):p.jsx(P0,{className:"w-4 h-4"}),o?"Saved!":"Save"]})]}),Y.isError&&p.jsxs("div",{className:"mb-6 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:["Failed to save settings: ",Y.error.message]}),p.jsxs("div",{className:"flex gap-8",children:[p.jsxs("div",{className:"space-y-6 flex-1 max-w-xl",children:[p.jsxs(Xt,{children:[p.jsx($l,{children:p.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),p.jsxs(en,{className:"space-y-4",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-white",children:"Auto-archive prints"}),p.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),p.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:i.auto_archive,onChange:X=>B("auto_archive",X.target.checked),className:"sr-only peer"}),p.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-white",children:"Save thumbnails"}),p.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),p.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:i.save_thumbnails,onChange:X=>B("save_thumbnails",X.target.checked),className:"sr-only peer"}),p.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-white",children:"Capture finish photo"}),p.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),p.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:i.capture_finish_photo,onChange:X=>B("capture_finish_photo",X.target.checked),className:"sr-only peer"}),p.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.capture_finish_photo&&F&&!F.installed&&p.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[p.jsx(_o,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),p.jsxs("div",{className:"text-sm",children:[p.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),p.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",p.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",p.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]}),p.jsxs(Xt,{children:[p.jsx($l,{children:p.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),p.jsxs(en,{className:"space-y-4",children:[p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),p.jsx("input",{type:"number",step:"0.01",min:"0",value:i.default_filament_cost,onChange:X=>B("default_filament_cost",parseFloat(X.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),p.jsxs("select",{value:i.currency,onChange:X=>B("currency",X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[p.jsx("option",{value:"USD",children:"USD ($)"}),p.jsx("option",{value:"EUR",children:"EUR (€)"}),p.jsx("option",{value:"GBP",children:"GBP (£)"}),p.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),p.jsx("option",{value:"JPY",children:"JPY (¥)"}),p.jsx("option",{value:"CNY",children:"CNY (¥)"}),p.jsx("option",{value:"CAD",children:"CAD ($)"}),p.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),p.jsx("input",{type:"number",step:"0.01",min:"0",value:i.energy_cost_per_kwh,onChange:X=>B("energy_cost_per_kwh",parseFloat(X.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),p.jsxs("select",{value:i.energy_tracking_mode||"total",onChange:X=>B("energy_tracking_mode",X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[p.jsx("option",{value:"print",children:"Prints Only"}),p.jsx("option",{value:"total",children:"Total Consumption"})]}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),p.jsxs(Xt,{children:[p.jsx($l,{children:p.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),p.jsxs(en,{className:"space-y-4",children:[p.jsxs("div",{children:[p.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[p.jsx(j_,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),p.jsx("select",{value:n.language,onChange:X=>n.changeLanguage(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:g4.map(X=>p.jsxs("option",{value:X.code,children:[X.nativeName," (",X.name,")"]},X.code))}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),p.jsx("select",{value:x,onChange:X=>w(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:l_.map(X=>p.jsx("option",{value:X.to,children:e(X.labelKey)},X.id))}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-white",children:"Sidebar order"}),p.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),p.jsxs(lt,{variant:"secondary",size:"sm",onClick:E,children:[p.jsx(XS,{className:"w-4 h-4"}),"Reset"]})]})]})]})]}),p.jsxs("div",{className:"space-y-6 flex-1 max-w-md",children:[p.jsx(DVe,{}),p.jsxs(Xt,{children:[p.jsx($l,{children:p.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),p.jsxs(en,{className:"space-y-4",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-white",children:"Check for updates"}),p.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),p.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:i.check_updates,onChange:X=>B("check_updates",X.target.checked),className:"sr-only peer"}),p.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),p.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between mb-2",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-white",children:"Current version"}),p.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",I?.version||"..."]})]}),p.jsxs(lt,{variant:"secondary",size:"sm",onClick:()=>O(),disabled:H,children:[H?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(Yo,{className:"w-4 h-4"}),"Check now"]})]}),q?.update_available?p.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[p.jsxs("div",{className:"flex items-start justify-between",children:[p.jsxs("div",{children:[p.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",q.latest_version]}),q.release_name&&q.release_name!==q.latest_version&&p.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:q.release_name}),q.release_notes&&p.jsx("p",{className:"text-sm text-bambu-gray mt-2 whitespace-pre-line line-clamp-3",children:q.release_notes})]}),q.release_url&&p.jsx("a",{href:q.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:p.jsx(dc,{className:"w-4 h-4"})})]}),V?.status==="downloading"||V?.status==="installing"?p.jsxs("div",{className:"mt-3",children:[p.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[p.jsx(It,{className:"w-4 h-4 animate-spin"}),p.jsx("span",{children:V.message})]}),p.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:p.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${V.progress}%`}})})]}):V?.status==="complete"?p.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:V.message}):V?.status==="error"?p.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:V.error||V.message}):p.jsxs(lt,{className:"mt-3",onClick:()=>K.mutate(),disabled:K.isPending,children:[K.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(Gu,{className:"w-4 h-4"}),"Install Update"]})]}):q?.error?p.jsxs("div",{className:"mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400",children:["Failed to check for updates: ",q.error]}):q&&!q.update_available?p.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]})]}),p.jsx("div",{className:"w-80 flex-shrink-0",children:p.jsxs(Xt,{children:[p.jsx($l,{children:p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(EN,{className:"w-5 h-5 text-bambu-green"}),p.jsx("h2",{className:"text-lg font-semibold text-white",children:"Smart Plugs"})]}),p.jsxs(lt,{size:"sm",onClick:()=>{m(null),u(!0)},children:[p.jsx(fc,{className:"w-4 h-4"}),"Add"]})]})}),p.jsxs(en,{children:[p.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Connect Tasmota-based smart plugs to automate power control for your printers."}),j?p.jsx("div",{className:"flex justify-center py-8",children:p.jsx(It,{className:"w-6 h-6 text-bambu-green animate-spin"})}):N&&N.length>0?p.jsx("div",{className:"space-y-4",children:N.map(X=>p.jsx(AVe,{plug:X,onEdit:ae=>{m(ae),u(!0)}},X.id))}):p.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[p.jsx(EN,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),p.jsx("p",{children:"No smart plugs configured"}),p.jsx("p",{className:"text-sm mt-1",children:"Add a Tasmota plug to get started"})]})]})]})}),p.jsx("div",{className:"w-80 flex-shrink-0",children:p.jsxs(Xt,{children:[p.jsx($l,{children:p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(SN,{className:"w-5 h-5 text-bambu-green"}),p.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notifications"})]}),p.jsxs(lt,{size:"sm",onClick:()=>{v(null),b(!0)},children:[p.jsx(fc,{className:"w-4 h-4"}),"Add"]})]})}),p.jsxs(en,{children:[p.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Get notified about print events via WhatsApp, Telegram, Email, and more."}),p.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary mb-4",children:[p.jsxs("div",{children:[p.jsx("p",{className:"text-white",children:e("settings.notificationLanguage")}),p.jsx("p",{className:"text-sm text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),p.jsx("select",{value:i.notification_language||"en",onChange:X=>B("notification_language",X.target.value),className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green",children:g4.map(X=>p.jsx("option",{value:X.code,children:X.nativeName},X.code))})]}),k?p.jsx("div",{className:"flex justify-center py-8",children:p.jsx(It,{className:"w-6 h-6 text-bambu-green animate-spin"})}):C&&C.length>0?p.jsx("div",{className:"space-y-4",children:C.map(X=>p.jsx(NVe,{provider:X,onEdit:ae=>{v(ae),b(!0)}},X.id))}):p.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[p.jsx(SN,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),p.jsx("p",{children:"No notification providers configured"}),p.jsx("p",{className:"text-sm mt-1",children:"Add a provider to get started"})]})]})]})})]}),c&&p.jsx(TVe,{plug:f,onClose:()=>{u(!1),m(null)}}),g&&p.jsx(RVe,{provider:y,onClose:()=>{b(!1),v(null)}})]})}const UJ=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},LVe=t=>t.startsWith("HH")?"HF":"S",IVe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},FJ=t=>{const e=["High Flow_","High Flow ","Standard_","Standard ","HF_","HF ","S_","S "];for(const i of e)if(t.startsWith(i))return t.slice(i.length);const n=t.indexOf("_");return n>0?t.slice(n+1):t};function lN({profile:t,onEdit:e}){const n=LVe(t.nozzle_id),i=t.nozzle_diameter,r=t.name||"Unnamed",a=FJ(t.name||"");return p.jsxs("button",{onClick:e,className:"w-full text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:UJ(t.k_value)}),p.jsx("span",{className:"text-white text-sm truncate flex-1",title:r,children:r}),p.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[n," ",i]})]}),p.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 truncate",title:`Filament: ${a}`,children:["Filament: ",a||t.filament_id]})]})}function eG({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:i=[],isDualNozzle:r=!1,onClose:a,onSave:s}){const{showToast:o}=Mo(),l=Gn(),[c,u]=A.useState(t?.name||""),[f,m]=A.useState(t?.k_value?UJ(t.k_value):"0.020"),[g,b]=A.useState(t?.filament_id||""),[y,v]=A.useState(t?.nozzle_id?IVe(t.nozzle_id):"HH00"),[x,M]=A.useState(t?.nozzle_diameter||n),[w,E]=A.useState(t?[t.extruder_id]:r?[0,1]:[0]),[T,R]=A.useState(!1),[N,j]=A.useState({current:0,total:0}),C=ui.useMemo(()=>{const V=new Map;for(const $ of i)if($.filament_id&&!V.has($.filament_id)){const K=FJ($.name||"");V.set($.filament_id,{id:$.filament_id,name:K||$.filament_id})}return Array.from(V.values()).sort(($,K)=>$.name.localeCompare(K.name))},[i]),k=Mt({mutationFn:V=>(console.log("[KProfile] Calling API..."),$e.setKProfile(e,V)),onSuccess:V=>{console.log("[KProfile] Save success:",V),o("K-profile saved"),R(!0),setTimeout(()=>{l.invalidateQueries({queryKey:["kprofiles",e]}),R(!1),s()},2500)},onError:V=>{console.error("[KProfile] Save error:",V),o(V.message,"error"),R(!1)}}),F=Mt({mutationFn:V=>(console.log("[KProfile] Deleting profile..."),$e.deleteKProfile(e,V)),onSuccess:V=>{console.log("[KProfile] Delete success:",V),o("K-profile deleted"),R(!0),setTimeout(()=>{l.invalidateQueries({queryKey:["kprofiles",e]}),R(!1),a()},2500)},onError:V=>{console.error("[KProfile] Delete error:",V),o(V.message,"error"),R(!1)}}),[I,q]=A.useState(!1),O=()=>{t&&F.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},H=async V=>{if(V.preventDefault(),r&&!t&&w.length===0){o("Please select at least one extruder","error");return}const $=parseFloat(f).toFixed(6),K=`${y}-${x}`;if(t||w.length===1){const Y={name:c,k_value:$,filament_id:g,nozzle_id:K,nozzle_diameter:x,extruder_id:t?t.extruder_id:w[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",Y),k.mutate(Y);return}R(!0),j({current:0,total:w.length});for(let Y=0;YsetTimeout(X,1500))}catch(X){console.error(`[KProfile] Failed to save for extruder ${se}:`,X),o(`Failed to save for ${se===1?"Left":"Right"} extruder`,"error"),R(!1),j({current:0,total:0});return}}o(`K-profile saved to ${w.length} extruders`),setTimeout(()=>{l.invalidateQueries({queryKey:["kprofiles",e]}),R(!1),j({current:0,total:0}),s()},2500)};return p.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[p.jsxs(Xt,{className:"w-full max-w-md relative",children:[T&&p.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[p.jsx(It,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),p.jsx("p",{className:"text-white font-medium",children:N.total>1?`Saving to extruder ${N.current}/${N.total}...`:"Syncing with printer..."}),p.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),p.jsxs(en,{className:"p-0",children:[p.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[p.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),p.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors",disabled:T,children:p.jsx(Sn,{className:"w-5 h-5"})})]}),p.jsxs("form",{onSubmit:H,className:"p-4 space-y-4",children:[p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),p.jsx("input",{type:"text",value:c,onChange:V=>u(V.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:"My PLA Profile",required:!t})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),p.jsx("input",{type:"text",inputMode:"decimal",value:f,onChange:V=>{const $=V.target.value;($===""||/^\d*\.?\d*$/.test($))&&m($)},onBlur:V=>{const $=parseFloat(V.target.value);isNaN($)||m((Math.trunc($*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),p.jsxs("select",{value:g,onChange:V=>{const $=V.target.value;if(b($),!t&&$&&!c){const K=C.find(Y=>Y.id===$);K&&u(`${y==="HH00"?"HF":"S"} ${K.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[p.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&p.jsx("option",{value:t.filament_id,children:C.find(V=>V.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&C.map(V=>p.jsx("option",{value:V.id,children:V.name},V.id))]}),!t&&C.length===0&&p.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),p.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),p.jsxs("select",{value:y,onChange:V=>{const $=V.target.value;if(v($),!t&&g&&!c){const K=C.find(Y=>Y.id===g);K&&u(`${$==="HH00"?"HF":"S"} ${K.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[p.jsx("option",{value:"HH00",children:"High Flow"}),p.jsx("option",{value:"HS00",children:"Standard"})]})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),p.jsxs("select",{value:x,onChange:V=>M(V.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[p.jsx("option",{value:"0.2",children:"0.2mm"}),p.jsx("option",{value:"0.4",children:"0.4mm"}),p.jsx("option",{value:"0.6",children:"0.6mm"}),p.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),r&&p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?p.jsx("div",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60",children:t.extruder_id===1?"Left":"Right"}):p.jsxs("div",{className:"flex gap-4",children:[p.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:w.includes(1),onChange:V=>{V.target.checked?E([...w,1]):E(w.filter($=>$!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),p.jsx("span",{className:"text-white",children:"Left"})]}),p.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[p.jsx("input",{type:"checkbox",checked:w.includes(0),onChange:V=>{V.target.checked?E([...w,0]):E(w.filter($=>$!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),p.jsx("span",{className:"text-white",children:"Right"})]})]})]}),p.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&p.jsx(lt,{type:"button",variant:"secondary",onClick:()=>q(!0),disabled:F.isPending||T,className:"text-red-500 hover:bg-red-500/10",children:F.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(ia,{className:"w-4 h-4"})}),p.jsx(lt,{type:"button",variant:"secondary",onClick:a,disabled:T,className:"flex-1",children:"Cancel"}),p.jsxs(lt,{type:"submit",disabled:k.isPending||T,className:"flex-1",children:[k.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(RP,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),I&&p.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:p.jsx(Xt,{className:"w-full max-w-sm",children:p.jsxs(en,{className:"p-6",children:[p.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[p.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:p.jsx(ia,{className:"w-5 h-5 text-red-500"})}),p.jsxs("div",{children:[p.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),p.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),p.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",p.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),p.jsxs("div",{className:"flex gap-3",children:[p.jsx(lt,{variant:"secondary",onClick:()=>q(!1),className:"flex-1",children:"Cancel"}),p.jsxs(lt,{onClick:()=>{q(!1),O()},disabled:F.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[F.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(ia,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function jVe(){const[t,e]=A.useState(null),[n,i]=A.useState("0.4"),[r,a]=A.useState(null),[s,o]=A.useState(!1),[l,c]=A.useState(""),[u,f]=A.useState("all"),[m,g]=A.useState("all"),{data:b,isLoading:y}=Ht({queryKey:["printers"],queryFn:$e.getPrinters}),{data:v,isLoading:x,error:M,refetch:w}=Ht({queryKey:["kprofiles",t,n],queryFn:()=>$e.getKProfiles(t,n),enabled:!!t,retry:!1,staleTime:0,refetchOnMount:"always"}),E=M?.message?.includes("not connected");A.useEffect(()=>{if(!t&&b&&b.length>0){const C=b.find(k=>k.is_active);C&&e(C.id)}},[t,b]),A.useEffect(()=>{if(t){const C=setTimeout(()=>{w()},150);return()=>clearTimeout(C)}},[t,n]);const T=b?.filter(C=>C.is_active)||[],R=ui.useMemo(()=>v?.profiles?v.profiles.filter(C=>{const k=l.toLowerCase(),F=!k||C.name.toLowerCase().includes(k)||C.filament_id.toLowerCase().includes(k),I=u==="all"||u==="left"&&C.extruder_id===1||u==="right"&&C.extruder_id===0,q=m==="all"||m==="hf"&&C.nozzle_id.startsWith("HH")||m==="s"&&C.nozzle_id.startsWith("HS");return F&&I&&q}):[],[v?.profiles,l,u,m]),j=b?.find(C=>C.id===t)?.nozzle_count===2;return y?p.jsx("div",{className:"flex justify-center py-12",children:p.jsx(It,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!b||b.length===0?p.jsx(Xt,{children:p.jsxs(en,{className:"py-12 text-center",children:[p.jsx(id,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),p.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),p.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):T.length===0?p.jsx(Xt,{children:p.jsxs(en,{className:"py-12 text-center",children:[p.jsx(hc,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),p.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),p.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[p.jsxs("div",{className:"flex-1 min-w-48",children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),p.jsx("select",{value:t||"",onChange:C=>e(parseInt(C.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:T.map(C=>p.jsx("option",{value:C.id,children:C.name},C.id))})]}),p.jsxs("div",{className:"w-32",children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),p.jsxs("select",{value:n,onChange:C=>i(C.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[p.jsx("option",{value:"0.2",children:"0.2mm"}),p.jsx("option",{value:"0.4",children:"0.4mm"}),p.jsx("option",{value:"0.6",children:"0.6mm"}),p.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),p.jsxs("div",{className:"flex items-end gap-2",children:[p.jsxs(lt,{variant:"secondary",onClick:()=>w(),disabled:x,children:[p.jsx(Yo,{className:`w-4 h-4 ${x?"animate-spin":""}`}),"Refresh"]}),p.jsxs(lt,{onClick:()=>o(!0),children:[p.jsx(fc,{className:"w-4 h-4"}),"Add Profile"]})]})]}),p.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[p.jsxs("div",{className:"flex-1 min-w-48 relative",children:[p.jsx(z_,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),p.jsx("input",{type:"text",value:l,onChange:C=>c(C.target.value),placeholder:"Search by name or filament...",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),j&&p.jsx("div",{className:"w-36",children:p.jsxs("select",{value:u,onChange:C=>f(C.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[p.jsx("option",{value:"all",children:"All Extruders"}),p.jsx("option",{value:"left",children:"Left Only"}),p.jsx("option",{value:"right",children:"Right Only"})]})}),p.jsx("div",{className:"w-32",children:p.jsxs("select",{value:m,onChange:C=>g(C.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[p.jsx("option",{value:"all",children:"All Flow"}),p.jsx("option",{value:"hf",children:"HF Only"}),p.jsx("option",{value:"s",children:"S Only"})]})})]}),x?p.jsx("div",{className:"flex justify-center py-12",children:p.jsx(It,{className:"w-8 h-8 text-bambu-green animate-spin"})}):E?p.jsx(Xt,{children:p.jsxs(en,{className:"py-12 text-center",children:[p.jsx(Fp,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),p.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),p.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),p.jsxs(lt,{variant:"secondary",onClick:()=>w(),children:[p.jsx(Yo,{className:"w-4 h-4"}),"Retry"]})]})}):R.length>0?j?p.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[p.jsxs("div",{children:[p.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),p.jsx("div",{className:"space-y-1",children:R.filter(C=>C.extruder_id===1).map(C=>p.jsx(lN,{profile:C,onEdit:()=>a(C)},C.slot_id))})]}),p.jsxs("div",{children:[p.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),p.jsx("div",{className:"space-y-1",children:R.filter(C=>C.extruder_id===0).map(C=>p.jsx(lN,{profile:C,onEdit:()=>a(C)},C.slot_id))})]})]}):p.jsx("div",{className:"space-y-1",children:R.map(C=>p.jsx(lN,{profile:C,onEdit:()=>a(C)},C.slot_id))}):l||u!=="all"||m!=="all"?p.jsx(Xt,{children:p.jsxs(en,{className:"py-12 text-center",children:[p.jsx(z_,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),p.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),p.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):p.jsx(Xt,{children:p.jsxs(en,{className:"py-12 text-center",children:[p.jsx(RP,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),p.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),p.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",n,"mm nozzle"]}),p.jsxs(lt,{onClick:()=>o(!0),children:[p.jsx(fc,{className:"w-4 h-4"}),"Create First Profile"]})]})}),r&&t&&p.jsx(eG,{profile:r,printerId:t,nozzleDiameter:n,existingProfiles:v?.profiles,isDualNozzle:j,onClose:()=>a(null),onSave:()=>a(null)}),s&&t&&p.jsx(eG,{printerId:t,nozzleDiameter:n,existingProfiles:v?.profiles,isDualNozzle:j,onClose:()=>o(!1),onSave:()=>o(!1)})]})}function UVe({onSuccess:t}){const{showToast:e}=Mo(),[n,i]=A.useState("email"),[r,a]=A.useState(""),[s,o]=A.useState(""),[l,c]=A.useState(""),[u,f]=A.useState(""),[m,g]=A.useState("global"),b=Mt({mutationFn:()=>$e.cloudLogin(r,s,m),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):w.needs_verification?(e("Verification code sent to your email"),i("code")):e(w.message,"error")},onError:w=>{e(w.message,"error")}}),y=Mt({mutationFn:()=>$e.cloudVerify(r,l),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>{e(w.message,"error")}}),v=Mt({mutationFn:()=>$e.cloudSetToken(u),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>{e(w.message,"error")}}),x=w=>{w.preventDefault(),n==="email"?b.mutate():n==="code"?y.mutate():n==="token"&&v.mutate()},M=b.isPending||y.isPending||v.isPending;return p.jsxs(Xt,{className:"max-w-md mx-auto",children:[p.jsx($l,{children:p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(NP,{className:"w-5 h-5 text-bambu-green"}),p.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"})]})}),p.jsx(en,{children:p.jsxs("form",{onSubmit:x,className:"space-y-4",children:[n==="email"&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),p.jsx("input",{type:"email",value:r,onChange:w=>a(w.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:"your@email.com",required:!0})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),p.jsx("input",{type:"password",value:s,onChange:w=>o(w.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:"••••••••",required:!0})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),p.jsxs("select",{value:m,onChange:w=>g(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[p.jsx("option",{value:"global",children:"Global"}),p.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),p.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",r,") for a 6-digit code"]}),p.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),p.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),p.jsx("textarea",{value:u,onChange:w=>f(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:3,required:!0})]}),p.jsxs("div",{className:"flex gap-2",children:[n==="code"&&p.jsx(lt,{type:"button",variant:"secondary",onClick:()=>i("email"),className:"flex-1",children:"Back"}),p.jsxs(lt,{type:"submit",disabled:M,className:"flex-1",children:[M?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(B4,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&p.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:p.jsxs("button",{type:"button",onClick:()=>i("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-1",children:[p.jsx(Fse,{className:"w-3 h-3"}),"Use access token instead"]})}),n==="token"&&p.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:p.jsxs("button",{type:"button",onClick:()=>i("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-1",children:[p.jsx(B4,{className:"w-3 h-3"}),"Login with email instead"]})})]})})]})}function FVe({setting:t,onClick:e}){return p.jsxs("button",{onClick:e,className:"w-full text-left p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[p.jsx("p",{className:"text-white font-medium truncate",children:t.name}),t.updated_time&&p.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Updated: ",new Date(t.updated_time).toLocaleDateString()]})]})}function zVe({setting:t,onClose:e}){const{data:n,isLoading:i}=Ht({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>$e.getCloudSettingDetail(t.setting_id)});return p.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:p.jsx(Xt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:p.jsxs(en,{className:"p-0 flex flex-col h-full",children:[p.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[p.jsxs("div",{children:[p.jsx("h2",{className:"text-xl font-semibold text-white",children:t.name}),p.jsxs("p",{className:"text-sm text-bambu-gray capitalize",children:[t.type," preset"]})]}),p.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:p.jsx(Sn,{className:"w-5 h-5"})})]}),p.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:i?p.jsx("div",{className:"flex justify-center py-8",children:p.jsx(It,{className:"w-8 h-8 text-bambu-green animate-spin"})}):n?p.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap overflow-x-auto bg-bambu-dark p-4 rounded-lg",children:JSON.stringify(n,null,2)}):p.jsx("p",{className:"text-bambu-gray text-center py-8",children:"Failed to load preset details"})}),p.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:p.jsx(lt,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})})}function BVe({settings:t}){const[e,n]=A.useState(new Set),[i,r]=A.useState(null),a=l=>[...l].sort((c,u)=>c.name.localeCompare(u.name)),s=l=>{n(c=>{const u=new Set(c);return u.has(l)?u.delete(l):u.add(l),u})},o=[{key:"filament",label:"Filament Presets",icon:GG,items:a(t.filament)},{key:"printer",label:"Printer Presets",icon:hc,items:a(t.printer)},{key:"process",label:"Process Presets",icon:DP,items:a(t.process)}];return p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"space-y-4",children:o.map(({key:l,label:c,icon:u,items:f})=>p.jsxs(Xt,{children:[p.jsxs("button",{onClick:()=>s(l),className:"w-full flex items-center justify-between p-4",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(u,{className:"w-5 h-5 text-bambu-green"}),p.jsx("span",{className:"text-lg font-semibold text-white",children:c}),p.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",f.length,")"]})]}),e.has(l)?p.jsx(gm,{className:"w-5 h-5 text-bambu-gray"}):p.jsx(Bf,{className:"w-5 h-5 text-bambu-gray"})]}),e.has(l)&&f.length>0&&p.jsx(en,{className:"pt-0",children:p.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:f.map(m=>p.jsx(FVe,{setting:m,onClick:()=>r(m)},m.setting_id))})}),e.has(l)&&f.length===0&&p.jsx(en,{className:"pt-0",children:p.jsx("p",{className:"text-bambu-gray text-sm",children:"No presets found"})})]},l))}),i&&p.jsx(zVe,{setting:i,onClose:()=>r(null)})]})}function HVe(){const t=Gn(),{showToast:e}=Mo(),[n,i]=A.useState("kprofiles"),{data:r,isLoading:a}=Ht({queryKey:["cloudStatus"],queryFn:$e.getCloudStatus}),{data:s,isLoading:o,refetch:l}=Ht({queryKey:["cloudSettings"],queryFn:()=>$e.getCloudSettings(),enabled:!!r?.is_authenticated,retry:!1,staleTime:1e3*60*5}),c=Mt({mutationFn:$e.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),u=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return a?p.jsx("div",{className:"p-8 flex justify-center",children:p.jsx(It,{className:"w-8 h-8 text-bambu-green animate-spin"})}):p.jsxs("div",{className:"p-8",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),p.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),p.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[p.jsxs("button",{onClick:()=>i("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[p.jsx(NP,{className:"w-4 h-4"}),"Cloud Profiles"]}),p.jsxs("button",{onClick:()=>i("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[p.jsx(RP,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[p.jsx("p",{className:"text-bambu-gray",children:r?.is_authenticated?`Connected as ${r.email}`:"Connect to Bambu Cloud to access your slicer presets"}),r?.is_authenticated&&p.jsxs("div",{className:"flex gap-2",children:[p.jsxs(lt,{variant:"secondary",onClick:()=>l(),disabled:o,children:[p.jsx(Yo,{className:`w-4 h-4 ${o?"animate-spin":""}`}),"Refresh"]}),p.jsxs(lt,{variant:"secondary",onClick:()=>c.mutate(),disabled:c.isPending,children:[p.jsx(noe,{className:"w-4 h-4"}),"Logout"]})]})]}),r?.is_authenticated?o?p.jsx("div",{className:"flex justify-center py-12",children:p.jsx(It,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s?p.jsx(BVe,{settings:s}):p.jsx(Xt,{children:p.jsxs(en,{className:"py-8 text-center",children:[p.jsx("p",{className:"text-bambu-gray",children:"Failed to load profiles"}),p.jsx(lt,{className:"mt-4",onClick:()=>l(),children:"Retry"})]})}):p.jsx(UVe,{onSuccess:u})]}),n==="kprofiles"&&p.jsx(jVe,{})]})}const gP={Droplet:GG,Flame:yse,Ruler:woe,Sparkles:Loe,Square:Up,Cable:Rae,Wrench:zp};function N_(t){return t&&gP[t]||zp}function Dx(t){return t<1?`${Math.round(t*60)}m`:`${t.toFixed(1)}h`}function VVe(t){const e=Math.floor(t),n=Math.round((t-e)*60);return e===0?`${n} minutes`:n===0?`${e} hours`:`${e}h ${n}m`}function $Ve({item:t,onPerform:e,onToggle:n}){const i=N_(t.maintenance_type_icon),r=Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100)),a=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-yellow-400":"text-bambu-green":"text-bambu-gray",s=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-yellow-500":"bg-bambu-green":"bg-bambu-gray/30",o=()=>t.enabled?t.is_due?`Overdue by ${Dx(Math.abs(t.hours_until_due))}`:t.is_warning?`Due in ${Dx(t.hours_until_due)}`:`${Dx(t.hours_until_due)} left`:"Disabled";return p.jsxs("div",{className:`flex items-center gap-4 p-3 rounded-lg ${t.is_due?"bg-red-500/10":t.is_warning?"bg-yellow-500/10":"bg-bambu-dark"}`,children:[p.jsxs("div",{className:"flex items-center gap-3 min-w-[180px]",children:[p.jsx(i,{className:`w-4 h-4 ${a()}`}),p.jsx("span",{className:`text-sm ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name})]}),p.jsx("div",{className:"flex-1 max-w-[200px]",children:p.jsx("div",{className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:p.jsx("div",{className:`h-full transition-all ${s()}`,style:{width:`${r}%`}})})}),p.jsxs("div",{className:`text-xs min-w-[120px] ${a()}`,children:[t.is_due&&p.jsx(_o,{className:"w-3 h-3 inline mr-1"}),t.is_warning&&p.jsx(xa,{className:"w-3 h-3 inline mr-1"}),!t.is_due&&!t.is_warning&&t.enabled&&p.jsx(jp,{className:"w-3 h-3 inline mr-1"}),o()]}),p.jsx(ns,{checked:t.enabled,onChange:l=>n(t.id,l)}),p.jsxs(lt,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"min-w-[70px]",children:[p.jsx(XS,{className:"w-3 h-3"}),"Done"]})]})}function GVe({overview:t,onPerform:e,onToggle:n,onSetHours:i}){const[r,a]=A.useState(!1),[s,o]=A.useState(!1),[l,c]=A.useState(t.total_print_hours.toFixed(1)),u=[...t.maintenance_items].sort((g,b)=>g.maintenance_type_id-b.maintenance_type_id),f=[...t.maintenance_items].filter(g=>g.enabled).sort((g,b)=>g.is_due&&!b.is_due?-1:!g.is_due&&b.is_due?1:g.is_warning&&!b.is_warning?-1:!g.is_warning&&b.is_warning?1:g.hours_until_due-b.hours_until_due)[0],m=()=>{const g=parseFloat(l);!isNaN(g)&&g>=0&&(i(t.printer_id,g),o(!1))};return p.jsxs(Xt,{children:[p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"flex items-center justify-between mb-4",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("h2",{className:"text-lg font-semibold text-white",children:t.printer_name}),t.due_count>0&&p.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",children:[p.jsx(_o,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&p.jsxs("span",{className:"px-2.5 py-1 bg-yellow-500/20 text-yellow-400 text-xs font-medium rounded-full flex items-center gap-1",children:[p.jsx(xa,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&p.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",children:[p.jsx(jp,{className:"w-3 h-3"}),"All good"]})]}),p.jsx("button",{onClick:()=>a(!r),className:"flex items-center gap-1 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded transition-colors",children:r?p.jsxs(p.Fragment,{children:[p.jsx(CP,{className:"w-4 h-4"}),"Hide"]}):p.jsxs(p.Fragment,{children:[p.jsx(gm,{className:"w-4 h-4"}),"Details"]})})]}),p.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[p.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[p.jsx("div",{className:"text-xs text-bambu-gray mb-1 uppercase tracking-wide",children:"Total Print Time"}),s?p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("input",{type:"number",value:l,onChange:g=>c(g.target.value),onKeyDown:g=>{g.key==="Enter"&&m(),g.key==="Escape"&&o(!1)},className:"w-20 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-lg font-semibold",min:"0",step:"1",autoFocus:!0}),p.jsx("span",{className:"text-sm text-bambu-gray",children:"hours"}),p.jsxs("div",{className:"flex gap-1 ml-auto",children:[p.jsx(lt,{size:"sm",onClick:m,children:"Save"}),p.jsx(lt,{size:"sm",variant:"secondary",onClick:()=>o(!1),children:"✕"})]})]}):p.jsxs("button",{onClick:()=>{c(Math.round(t.total_print_hours).toString()),o(!0)},className:"flex items-center gap-2 group",title:"Click to edit total print hours",children:[p.jsx("span",{className:"text-xl font-semibold text-white group-hover:text-bambu-green transition-colors",children:VVe(t.total_print_hours)}),p.jsx(kP,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})]})]}),p.jsxs("div",{className:`p-3 rounded-lg ${f?.is_due?"bg-red-500/10":f?.is_warning?"bg-yellow-500/10":"bg-bambu-dark"}`,children:[p.jsx("div",{className:"text-xs text-bambu-gray mb-1 uppercase tracking-wide",children:"Next Maintenance"}),f?p.jsxs("div",{children:[p.jsx("div",{className:`text-lg font-semibold ${f.is_due?"text-red-400":f.is_warning?"text-yellow-400":"text-white"}`,children:f.maintenance_type_name}),p.jsx("div",{className:`text-sm ${f.is_due?"text-red-400":f.is_warning?"text-yellow-400":"text-bambu-gray"}`,children:f.is_due?p.jsxs(p.Fragment,{children:["Overdue by ",Dx(Math.abs(f.hours_until_due))]}):p.jsxs(p.Fragment,{children:["Due in ",Dx(f.hours_until_due)]})})]}):p.jsx("div",{className:"text-white",children:"No tasks enabled"})]})]})]}),r&&p.jsx(en,{className:"pt-0 space-y-2 border-t border-bambu-dark-tertiary mt-4",children:p.jsx("div",{className:"pt-4",children:u.map(g=>p.jsx($Ve,{item:g,onPerform:e,onToggle:n},g.id))})})]})}function WVe({overview:t,types:e,onUpdateInterval:n,onAddType:i,onDeleteType:r}){const[a,s]=A.useState(null),[o,l]=A.useState(""),[c,u]=A.useState(!1),[f,m]=A.useState(""),[g,b]=A.useState("100"),[y,v]=A.useState("Wrench"),x=(R,N)=>{const j=parseFloat(o);if(!isNaN(j)&&j>0){const C=Math.abs(j-N)<.01?null:j;n(R,C)}s(null)},M=R=>{R.preventDefault(),f.trim()&&parseFloat(g)>0&&(i({name:f.trim(),default_interval_hours:parseFloat(g),icon:y}),m(""),b("100"),u(!1))},w=t?.map(R=>({printerId:R.printer_id,printerName:R.printer_name,items:R.maintenance_items.sort((N,j)=>N.maintenance_type_id-j.maintenance_type_id)})).sort((R,N)=>R.printerName.localeCompare(N.printerName))||[],E=e.filter(R=>R.is_system),T=e.filter(R=>!R.is_system);return p.jsxs("div",{className:"space-y-8",children:[p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center justify-between mb-4",children:[p.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),p.jsxs(lt,{size:"sm",variant:"secondary",onClick:()=>u(!c),children:[p.jsx(fc,{className:"w-4 h-4"}),"Add Custom Type"]})]}),c&&p.jsx(Xt,{className:"mb-4",children:p.jsx("div",{className:"p-4",children:p.jsx("form",{onSubmit:M,children:p.jsxs("div",{className:"flex gap-3 items-end",children:[p.jsxs("div",{className:"flex-1",children:[p.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Name"}),p.jsx("input",{type:"text",value:f,onChange:R=>m(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",placeholder:"e.g., Replace HEPA Filter",autoFocus:!0})]}),p.jsxs("div",{className:"w-28",children:[p.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Interval (hours)"}),p.jsx("input",{type:"number",value:g,onChange:R=>b(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"1"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Icon"}),p.jsx("div",{className:"flex gap-1",children:Object.keys(gP).map(R=>{const N=gP[R];return p.jsx("button",{type:"button",onClick:()=>v(R),className:`p-2 rounded ${y===R?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:p.jsx(N,{className:"w-4 h-4"})},R)})})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx(lt,{type:"submit",size:"sm",disabled:!f.trim(),children:"Add"}),p.jsx(lt,{type:"button",size:"sm",variant:"secondary",onClick:()=>u(!1),children:"Cancel"})]})]})})})}),p.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[E.map(R=>{const N=N_(R.icon);return p.jsx("div",{className:"bg-bambu-dark-secondary rounded-lg p-4 border border-bambu-dark-tertiary",children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:p.jsx(N,{className:"w-5 h-5 text-bambu-gray"})}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:"text-sm font-medium text-white truncate",children:R.name}),p.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5",children:[R.default_interval_hours,"h interval"]})]})]})},R.id)}),T.map(R=>{const N=N_(R.icon);return p.jsx("div",{className:"bg-bambu-dark-secondary rounded-lg p-4 border border-bambu-green/30",children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:"p-2 bg-bambu-green/20 rounded-lg",children:p.jsx(N,{className:"w-5 h-5 text-bambu-green"})}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("span",{className:"text-sm font-medium text-white truncate",children:R.name}),p.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),p.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5",children:[R.default_interval_hours,"h interval"]})]}),p.jsx("button",{onClick:()=>{confirm(`Delete "${R.name}"?`)&&r(R.id)},className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:p.jsx(ia,{className:"w-4 h-4"})})]})},R.id)})]})]}),w.length>0&&p.jsxs("div",{children:[p.jsx("h2",{className:"text-lg font-semibold text-white mb-2",children:"Interval Overrides"}),p.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Set custom intervals per printer."}),p.jsx("div",{className:"space-y-3",children:w.map(R=>p.jsx(Xt,{children:p.jsxs("div",{className:"p-4",children:[p.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:R.printerName}),p.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:R.items.map(N=>{const j=N_(N.maintenance_type_icon),k=e.find(I=>I.id===N.maintenance_type_id)?.default_interval_hours||N.interval_hours,F=a===N.id;return p.jsxs("div",{className:"flex items-center gap-2 p-2 bg-bambu-dark rounded-lg",children:[p.jsx(j,{className:"w-4 h-4 text-bambu-gray shrink-0"}),p.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:N.maintenance_type_name}),F?p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("input",{type:"number",value:o,onChange:I=>l(I.target.value),onKeyDown:I=>{I.key==="Enter"&&x(N.id,k),I.key==="Escape"&&s(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1",autoFocus:!0}),p.jsx(lt,{size:"sm",onClick:()=>x(N.id,k),children:"OK"})]}):p.jsxs("button",{onClick:()=>{s(N.id),l(N.interval_hours.toString())},className:"px-2 py-1 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary border border-bambu-dark-tertiary hover:border-bambu-green rounded text-xs font-medium text-white transition-colors",children:[N.interval_hours,"h",p.jsx(kP,{className:"w-3 h-3 inline ml-1.5 text-bambu-gray"})]})]},N.id)})})]})},R.printerId))})]}),w.length===0&&p.jsx(Xt,{children:p.jsxs(en,{className:"text-center py-12",children:[p.jsx(xa,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),p.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),p.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function qVe(){const t=Gn(),{showToast:e}=Mo(),[n,i]=A.useState("status"),{data:r,isLoading:a}=Ht({queryKey:["maintenanceOverview"],queryFn:$e.getMaintenanceOverview}),{data:s}=Ht({queryKey:["maintenanceTypes"],queryFn:$e.getMaintenanceTypes}),o=Mt({mutationFn:({id:x,notes:M})=>$e.performMaintenance(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as done")},onError:x=>{e(x.message,"error")}}),l=Mt({mutationFn:({id:x,data:M})=>$e.updateMaintenanceItem(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:x=>{e(x.message,"error")}}),c=Mt({mutationFn:$e.createMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onError:x=>{e(x.message,"error")}}),u=Mt({mutationFn:$e.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:x=>{e(x.message,"error")}}),f=Mt({mutationFn:({printerId:x,hours:M})=>$e.setPrinterHours(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:x=>{e(x.message,"error")}}),m=x=>{o.mutate({id:x})},g=(x,M)=>{l.mutate({id:x,data:{enabled:M}})},b=(x,M)=>{f.mutate({printerId:x,hours:M})};if(a)return p.jsx("div",{className:"p-8 flex justify-center",children:p.jsx(It,{className:"w-8 h-8 text-bambu-green animate-spin"})});const y=r?.reduce((x,M)=>x+M.due_count,0)||0,v=r?.reduce((x,M)=>x+M.warning_count,0)||0;return p.jsxs("div",{className:"p-8",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),p.jsx("p",{className:"text-bambu-gray text-sm",children:n==="status"?p.jsxs(p.Fragment,{children:[y>0&&p.jsxs("span",{className:"text-red-400",children:[y," tasks overdue"]}),y>0&&v>0&&" · ",v>0&&p.jsxs("span",{className:"text-yellow-400",children:[v," due soon"]}),y===0&&v===0&&"All maintenance up to date"]}):"Configure maintenance types and intervals"})]}),p.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[p.jsx("button",{onClick:()=>i("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Status"}),p.jsx("button",{onClick:()=>i("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Settings"})]}),n==="status"?p.jsx("div",{className:"space-y-4",children:r&&r.length>0?[...r].sort((x,M)=>x.printer_name.localeCompare(M.printer_name)).map(x=>p.jsx(GVe,{overview:x,onPerform:m,onToggle:g,onSetHours:b},x.printer_id)):p.jsx(Xt,{children:p.jsxs(en,{className:"text-center py-12",children:[p.jsx(zp,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),p.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),p.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to start tracking maintenance"})]})})}):p.jsx(WVe,{overview:r,types:s||[],onUpdateInterval:(x,M)=>l.mutate({id:x,data:{custom_interval_hours:M}}),onAddType:x=>c.mutate(x),onDeleteType:x=>u.mutate(x)})]})}function XVe({printerId:t,isConnected:e}){const[n,i]=A.useState(!1),[r,a]=A.useState(!1),[s,o]=A.useState(null),l=A.useRef(null),c=$e.getCameraStreamUrl(t,10),u=()=>{n?(i(!1),o(null)):(a(!0),o(null),i(!0))},f=()=>{a(!1),o(null)},m=()=>{a(!1),o("Failed to load camera stream")},g=()=>{l.current&&(document.fullscreenElement?document.exitFullscreen():l.current.requestFullscreen())},b=()=>{i(!1),setTimeout(()=>{a(!0),i(!0)},100)};return p.jsx("div",{className:"relative w-full h-full bg-black",children:n?p.jsxs(p.Fragment,{children:[r&&p.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:p.jsx(It,{className:"w-8 h-8 animate-spin text-bambu-green"})}),s?p.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-red-400",children:[p.jsx(Lae,{className:"w-12 h-12 mb-2"}),p.jsx("span",{className:"text-sm",children:s}),p.jsx("button",{onClick:b,className:"mt-2 text-xs text-bambu-green hover:underline",children:"Retry"})]}):p.jsx("img",{ref:l,src:c,alt:"Camera stream",className:"w-full h-full object-contain",onLoad:f,onError:m}),p.jsxs("div",{className:"absolute top-2 right-2 flex gap-2",children:[p.jsx("button",{onClick:b,className:"p-2 rounded bg-black/50 hover:bg-black/70 text-white transition-colors",title:"Refresh stream",children:p.jsx(Yo,{className:"w-4 h-4"})}),p.jsx("button",{onClick:g,className:"p-2 rounded bg-black/50 hover:bg-black/70 text-white transition-colors",title:"Fullscreen",children:p.jsx(ZG,{className:"w-4 h-4"})}),p.jsx("button",{onClick:u,className:"px-3 py-1.5 rounded bg-red-500/80 hover:bg-red-500 text-white text-sm transition-colors",children:"Stop"})]})]}):p.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-bambu-gray",children:p.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-6 flex flex-col items-center",children:[p.jsx(I_,{className:"w-8 h-8 mb-2"}),p.jsx("span",{className:"text-sm mb-3",children:e?"Click Start to view camera":"Printer not connected"}),p.jsx("button",{onClick:u,disabled:!e,className:"px-4 py-1.5 rounded text-sm bg-bambu-green text-white hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed",children:"Start"})]})})})}function KVe(t){if(!t)return"N/A";const e=new Date;return new Date(e.getTime()+t*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function YVe({printerId:t,status:e}){const n=Gn(),[i,r]=A.useState(null),a=e?.connected??!1,s=e?.state==="RUNNING",o=e?.state==="PAUSE",l=e?.progress??0,c=Mt({mutationFn:()=>$e.pausePrint(t),onSuccess:()=>{n.invalidateQueries({queryKey:["printerStatuses"]})}}),u=Mt({mutationFn:()=>$e.resumePrint(t),onSuccess:()=>{n.invalidateQueries({queryKey:["printerStatuses"]})}}),f=Mt({mutationFn:x=>$e.stopPrint(t,x),onSuccess:x=>{Bx(x)?r({action:"stop",token:x.token,warning:x.warning}):n.invalidateQueries({queryKey:["printerStatuses"]})}}),m=()=>{s?c.mutate():o&&u.mutate()},g=()=>{f.mutate(void 0)},b=()=>{i&&(f.mutate(i.token),r(null))},y=c.isPending||u.isPending||f.isPending,v=a&&(s||o);return p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"text-xs text-bambu-gray mb-3",children:"Printing Progress"}),p.jsxs("div",{className:"flex gap-4 items-center",children:[p.jsx("div",{className:"w-20 h-20 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg flex items-center justify-center flex-shrink-0 overflow-hidden",children:e?.subtask_name?p.jsx("img",{src:`/api/v1/archives/thumbnail/${encodeURIComponent(e.subtask_name)}`,alt:"",className:"w-full h-full object-contain",onError:x=>{x.target.style.display="none",x.target.parentElement.innerHTML='Bambu Lab '}}):p.jsxs("span",{className:"text-xs text-bambu-gray text-center",children:["Bambu",p.jsx("br",{}),"Lab"]})}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:"font-medium text-sm text-white truncate mb-0.5",children:e?.subtask_name||"N/A"}),p.jsx("div",{className:`text-sm mb-2 ${e?.state==="RUNNING"||e?.state==="PAUSE"?"text-bambu-green":"text-bambu-gray"}`,children:e?.state||"N/A"}),p.jsx("div",{className:"h-1 bg-bambu-dark-tertiary rounded-full overflow-hidden mb-2",children:p.jsx("div",{className:`h-full transition-all duration-300 ${e?.state==="PAUSE"?"bg-yellow-500":"bg-bambu-green"}`,style:{width:`${l}%`}})}),p.jsxs("div",{className:"text-xs text-bambu-gray mb-1",children:["Layer: ",e?.layer_num??"N/A"," / ",e?.total_layers??"N/A"," ",Math.round(l),"%"]}),p.jsxs("div",{className:"text-xs text-bambu-gray",children:["Estimated finish time: ",KVe(e?.remaining_time)]})]}),p.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[p.jsx("button",{onClick:m,disabled:!v||y,className:"w-8 h-8 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary flex items-center justify-center text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:s?"Pause":"Resume",children:c.isPending||u.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(QG,{className:"w-4 h-4"})}),p.jsx("button",{onClick:g,disabled:!v||y,className:"w-8 h-8 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary flex items-center justify-center text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Stop",children:f.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(Up,{className:"w-4 h-4"})}),p.jsx("button",{disabled:!v||y,className:"w-8 h-8 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary flex items-center justify-center text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Skip Objects",children:p.jsx("img",{src:"/icons/skip-objects.svg",alt:"Skip Objects",className:"w-4 h-4 icon-theme"})})]})]}),(c.error||u.error||f.error)&&p.jsx("p",{className:"mt-2 text-xs text-red-500",children:(c.error||u.error||f.error)?.message}),i&&p.jsx(rr,{title:"Confirm Stop",message:i.warning,confirmText:"Stop Print",variant:"danger",onConfirm:b,onCancel:()=>r(null)})]})}function ZVe({printerId:t,status:e,nozzleCount:n,disabled:i=!1}){const r=e?.temperatures??{},a=n>1,s=(e?.connected??!1)&&!i,[o,l]=A.useState(null),[c,u]=A.useState(""),f=Mt({mutationFn:j=>$e.setBedTemperature(t,j)}),m=Mt({mutationFn:({target:j,nozzle:C})=>$e.setNozzleTemperature(t,j,C)}),g=Mt({mutationFn:j=>$e.setChamberLight(t,j)}),b=(j,C)=>{s&&(l(j),u(String(Math.round(C))))},y=()=>{l(null),u("")},v=()=>{const j=parseInt(c,10);if(isNaN(j)||j<0){y();return}o==="bed"?f.mutate(j):o==="nozzle"?m.mutate({target:j,nozzle:a?1:0}):o==="nozzle_2"&&m.mutate({target:j,nozzle:0}),y()},x=j=>{j.key==="Enter"?v():j.key==="Escape"&&y()},M=!s,w=r.nozzle_heating??!1,E=r.nozzle_2_heating??!1,T=r.bed_heating??!1,R=r.chamber_heating??!1,N=(j,C)=>o===j?p.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",value:c,onChange:k=>{const F=k.target.value.replace(/[^0-9]/g,"");u(F)},onBlur:v,onKeyDown:x,autoFocus:!0,className:"w-12 text-sm bg-bambu-dark border border-bambu-green rounded px-1 py-0.5 text-white text-center [appearance:textfield]"}):p.jsxs("button",{onClick:()=>b(j,C),disabled:M,className:"text-sm text-bambu-gray hover:text-bambu-green disabled:hover:text-bambu-gray disabled:cursor-not-allowed",title:M?"Printer not connected":"Click to set target temperature",children:["/",Math.round(C)," °C"]});return p.jsxs("div",{className:"flex flex-col justify-evenly min-w-[150px] pr-5 border-r border-bambu-dark-tertiary",children:[p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:p.jsx("img",{src:"/icons/hotend.svg",alt:"",className:`w-5 ${w?"icon-heating":"icon-theme"}`})}),a&&p.jsx("span",{className:"text-[11px] font-semibold text-bambu-green bg-bambu-green/20 px-1.5 py-0.5 rounded min-w-[18px] text-center flex-shrink-0",children:"L"}),p.jsx("span",{className:"text-lg font-medium text-white",children:Math.round(r.nozzle??0)}),N("nozzle",r.nozzle_target??0)]}),a&&p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:p.jsx("img",{src:"/icons/hotend.svg",alt:"",className:`w-5 ${E?"icon-heating":"icon-theme"}`})}),p.jsx("span",{className:"text-[11px] font-semibold text-bambu-green bg-bambu-green/20 px-1.5 py-0.5 rounded min-w-[18px] text-center flex-shrink-0",children:"R"}),p.jsx("span",{className:"text-lg font-medium text-white",children:Math.round(r.nozzle_2??0)}),N("nozzle_2",r.nozzle_2_target??0)]}),p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:p.jsx("img",{src:"/icons/heatbed.svg",alt:"",className:`w-5 ${T?"icon-heating":"icon-theme"}`})}),a&&p.jsx("span",{className:"min-w-[18px] flex-shrink-0"}),p.jsx("span",{className:"text-lg font-medium text-white",children:Math.round(r.bed??0)}),N("bed",r.bed_target??0)]}),p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:p.jsx("img",{src:"/icons/chamber.svg",alt:"",className:`w-5 ${R?"icon-heating":"icon-theme"}`})}),a&&p.jsx("span",{className:"min-w-[18px] flex-shrink-0"}),p.jsx("span",{className:"text-lg font-medium text-white",children:Math.round(r.chamber??0)}),p.jsxs("span",{className:"text-sm text-bambu-gray",children:["/",Math.round(r.chamber_target??0)," °C"]})]}),p.jsxs("button",{disabled:M,className:"flex items-center gap-2 hover:opacity-80 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed",children:[p.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:p.jsx("img",{src:"/icons/ventilation.svg",alt:"",className:"w-5 icon-theme"})}),p.jsx("span",{className:"text-sm text-bambu-gray",children:"Air Condition"})]}),p.jsxs("button",{onClick:()=>g.mutate(!0),disabled:M||g.isPending,className:"flex items-center gap-2 hover:opacity-80 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed",children:[p.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:p.jsx("img",{src:"/icons/lamp.svg",alt:"",className:"w-4 icon-theme"})}),p.jsx("span",{className:"text-sm text-bambu-gray",children:"Lamp"})]})]})}function QVe({printerId:t,status:e,disabled:n=!1}){const i=(e?.connected??!1)&&!n,[r,a]=A.useState(null),s=Mt({mutationFn:({axes:g,token:b})=>$e.homeAxes(t,g,b),onSuccess:g=>{Bx(g)&&a({action:"home",token:g.token,warning:g.warning,onConfirm:()=>s.mutate({axes:"XY",token:g.token})})}}),o=Mt({mutationFn:({axis:g,distance:b,token:y})=>$e.moveAxis(t,g,b,3e3,y),onSuccess:(g,b)=>{Bx(g)&&a({action:"move",token:g.token,warning:g.warning,onConfirm:()=>o.mutate({axis:b.axis,distance:b.distance,token:g.token})})}}),l=()=>{s.mutate({axes:"XY"})},c=(g,b)=>{o.mutate({axis:g,distance:b})},u=()=>{r&&(r.onConfirm(),a(null))},f=s.isPending||o.isPending,m=!i||f;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"relative w-[220px] h-[220px] mb-3.5",children:[p.jsx("img",{src:"/icons/jogpad.svg",alt:"Jog Pad",className:"w-full h-full jogpad-theme"}),p.jsx("button",{onClick:()=>c("Y",10),disabled:m,className:"absolute top-[8px] left-1/2 -translate-x-1/2 w-[40px] h-[30px] opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"Y+10"}),p.jsx("button",{onClick:()=>c("Y",-10),disabled:m,className:"absolute bottom-[8px] left-1/2 -translate-x-1/2 w-[40px] h-[30px] opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"Y-10"}),p.jsx("button",{onClick:()=>c("X",-10),disabled:m,className:"absolute left-[8px] top-1/2 -translate-y-1/2 w-[30px] h-[40px] opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"X-10"}),p.jsx("button",{onClick:()=>c("X",10),disabled:m,className:"absolute right-[8px] top-1/2 -translate-y-1/2 w-[30px] h-[40px] opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"X+10"}),p.jsx("button",{onClick:()=>c("Y",1),disabled:m,className:"absolute top-[42px] left-1/2 -translate-x-1/2 w-[35px] h-[25px] opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"Y+1"}),p.jsx("button",{onClick:()=>c("Y",-1),disabled:m,className:"absolute bottom-[42px] left-1/2 -translate-x-1/2 w-[35px] h-[25px] opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"Y-1"}),p.jsx("button",{onClick:()=>c("X",-1),disabled:m,className:"absolute left-[42px] top-1/2 -translate-y-1/2 w-[25px] h-[35px] opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"X-1"}),p.jsx("button",{onClick:()=>c("X",1),disabled:m,className:"absolute right-[42px] top-1/2 -translate-y-1/2 w-[25px] h-[35px] opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"X+1"}),p.jsx("button",{onClick:l,disabled:m,className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[50px] h-[50px] rounded-full opacity-0 hover:opacity-10 hover:bg-white disabled:cursor-not-allowed",title:"Home XY"})]}),r&&p.jsx(rr,{title:"Confirm Action",message:r.warning,confirmText:"Continue",variant:"warning",onConfirm:u,onCancel:()=>a(null)})]})}function JVe({printerId:t,status:e,disabled:n=!1}){const i=(e?.connected??!1)&&!n,[r,a]=A.useState(null),s=Mt({mutationFn:({distance:u,token:f})=>$e.moveAxis(t,"Z",u,1e3,f),onSuccess:(u,f)=>{Bx(u)&&a({token:u.token,warning:u.warning,distance:f.distance})}}),o=u=>{s.mutate({distance:u})},l=()=>{r&&(s.mutate({distance:r.distance,token:r.token}),a(null))},c=!i||s.isPending;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("button",{onClick:()=>o(10),disabled:c,className:"px-3.5 py-2 rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary text-sm text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Z+10",children:"↑10"}),p.jsx("button",{onClick:()=>o(1),disabled:c,className:"px-3.5 py-2 rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary text-sm text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Z+1",children:"↑1"}),p.jsx("span",{className:"px-2 py-2 text-sm text-bambu-gray",children:"Bed"}),p.jsx("button",{onClick:()=>o(-1),disabled:c,className:"px-3.5 py-2 rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary text-sm text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Z-1",children:"↓1"}),p.jsx("button",{onClick:()=>o(-10),disabled:c,className:"px-3.5 py-2 rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary text-sm text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Z-10",children:"↓10"})]}),r&&p.jsx(rr,{title:"Confirm Bed Movement",message:r.warning,confirmText:"Continue",variant:"warning",onConfirm:l,onCancel:()=>a(null)})]})}function e$e({printerId:t,status:e,nozzleCount:n,disabled:i=!1}){const r=(e?.connected??!1)&&!i,a=e?.state==="RUNNING"||e?.state==="PAUSE",s=n>1,[o,l]=A.useState("left"),[c,u]=A.useState(null),f=Mt({mutationFn:({distance:y,token:v})=>{const M=`${s?`T${o==="left"?0:1}
`:""}G91
G1 E${y} F300
G90`;return $e.sendGcode(t,M,v)},onSuccess:(y,v)=>{Bx(y)&&u({token:y.token,warning:y.warning,distance:v.distance})}}),m=y=>{f.mutate({distance:y})},g=()=>{c&&(f.mutate({distance:c.distance,token:c.token}),u(null))},b=!r||a||f.isPending;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex flex-col items-center gap-1.5 justify-center",children:[s&&p.jsxs("div",{className:`flex rounded-md overflow-hidden border border-bambu-dark-tertiary mb-1 flex-shrink-0 ${b?"opacity-50":""}`,children:[p.jsx("button",{onClick:()=>l("left"),disabled:b,className:`px-3 py-1.5 text-sm border-r border-bambu-dark-tertiary transition-colors disabled:cursor-not-allowed ${o==="left"?"bg-bambu-green text-white":"bg-bambu-dark-secondary text-bambu-gray hover:bg-bambu-dark-tertiary disabled:hover:bg-bambu-dark-secondary"}`,children:"Left"}),p.jsx("button",{onClick:()=>l("right"),disabled:b,className:`px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed ${o==="right"?"bg-bambu-green text-white":"bg-bambu-dark-secondary text-bambu-gray hover:bg-bambu-dark-tertiary disabled:hover:bg-bambu-dark-secondary"}`,children:"Right"})]}),p.jsx("button",{onClick:()=>m(5),disabled:b,className:"w-9 h-[30px] rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary flex items-center justify-center text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Extrude 5mm",children:p.jsx(CP,{className:"w-4 h-4"})}),p.jsx("div",{className:"h-[120px] flex items-center justify-center",children:p.jsx("img",{src:s?"/icons/dual-extruder.png":"/icons/single-extruder1.png",alt:s?"Dual Extruder":"Single Extruder",className:"h-full object-contain",onError:y=>{y.target.style.display="none"}})}),p.jsx("button",{onClick:()=>m(-5),disabled:b,className:"w-9 h-[30px] rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary flex items-center justify-center text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Retract 5mm",children:p.jsx(gm,{className:"w-4 h-4"})}),p.jsx("span",{className:"text-xs text-bambu-gray mt-0.5",children:"Extruder"})]}),c&&p.jsx(rr,{title:"Confirm Extrusion",message:c.warning,confirmText:"Continue",variant:"warning",onConfirm:g,onCancel:()=>u(null)})]})}function tG(t){if(!t)return"rgb(128, 128, 128)";const e=t.replace("#","").substring(0,6),n=parseInt(e.substring(0,2),16)||128,i=parseInt(e.substring(2,4),16)||128,r=parseInt(e.substring(4,6),16)||128;return`rgb(${n}, ${i}, ${r})`}function t$e(t){if(!t)return!1;const e=t.replace("#","").substring(0,6),n=parseInt(e.substring(0,2),16)||0,i=parseInt(e.substring(2,4),16)||0,r=parseInt(e.substring(4,6),16)||0;return(.299*n+.587*i+.114*r)/255>.5}function nG({units:t,side:e,isPrinting:n,selectedAmsIndex:i,onSelectAms:r,selectedTray:a,onSelectTray:s}){const o=t[i],l=e==="left"?"A":"B";return p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:"text-center text-[11px] font-semibold text-bambu-gray uppercase mb-2",children:e==="left"?"Left Nozzle":"Right Nozzle"}),p.jsx("div",{className:"flex gap-1.5 mb-2.5 p-1.5 bg-bambu-dark/50 rounded-lg w-fit",children:t.map((c,u)=>p.jsx("button",{onClick:()=>r(u),className:`flex items-center p-1.5 rounded border-2 transition-colors bg-bambu-dark ${i===u?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:p.jsx("div",{className:"flex gap-0.5",children:c.tray.map(f=>p.jsx("div",{className:"w-2.5 h-2.5 rounded-full",style:{backgroundColor:f.tray_color?tG(f.tray_color):"#808080"}},f.id))})},c.id))}),o&&p.jsxs("div",{className:"bg-bambu-dark-secondary rounded-[10px] p-2.5",children:[p.jsxs("div",{className:"flex items-center gap-2.5 text-xs text-bambu-gray mb-2",children:[o.humidity!==null&&p.jsxs("span",{className:"flex items-center gap-1",children:[p.jsx("img",{src:"/icons/water.svg",alt:"",className:"w-3.5 icon-theme"}),o.humidity," %"]}),o.temp!==null&&p.jsxs("span",{className:"flex items-center gap-1",children:[p.jsx("img",{src:"/icons/temperature.svg",alt:"",className:"w-3.5 icon-theme"}),o.temp,"°C"]}),p.jsx("span",{className:"text-yellow-500 text-sm",children:"☀"})]}),p.jsx("div",{className:"flex justify-center gap-1.5 mb-1.5",children:o.tray.map((c,u)=>p.jsxs("div",{className:"w-12 flex items-center justify-center gap-0.5 text-[10px] text-bambu-gray px-1.5 py-[3px] bg-bambu-dark rounded-full border border-bambu-dark-tertiary",children:[l,u+1,p.jsx("img",{src:"/icons/reload.svg",alt:"",className:"w-2.5 h-2.5 icon-theme"})]},c.id))}),p.jsx("div",{className:"flex justify-center gap-1.5",children:o.tray.map(c=>{const u=o.id*4+c.id,f=a===u,m=!c.tray_type||c.tray_type===""||c.tray_type==="NONE",g=t$e(c.tray_color);return p.jsx("button",{onClick:()=>!m&&s(f?null:u),disabled:m||n,className:`w-12 h-[70px] rounded-md border-2 overflow-hidden transition-all bg-bambu-dark ${f?"border-[#d4a84b]":"border-bambu-dark-tertiary hover:border-bambu-gray"} ${m?"opacity-50":""} disabled:cursor-not-allowed`,children:p.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-end pb-[5px]",style:{backgroundColor:m?void 0:tG(c.tray_color)},children:[p.jsx("span",{className:`text-[11px] font-semibold mb-1 ${g?"text-gray-800":"text-white"} ${g?"":"drop-shadow-sm"}`,children:m?"--":c.tray_type}),!m&&p.jsx("img",{src:"/icons/eye.svg",alt:"",className:`w-3.5 h-3.5 ${g?"":"invert"}`,style:{opacity:.8}})]})},c.id)})})]}),t.length===0&&p.jsxs("div",{className:"bg-bambu-dark-secondary rounded-[10px] p-6 text-center text-bambu-gray text-sm",children:["No AMS connected to ",e," nozzle"]})]})}function n$e({isDualNozzle:t}){return t?p.jsxs("div",{className:"relative w-full",style:{height:"120px"},children:[p.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 600 120",preserveAspectRatio:"xMidYMid meet",children:[p.jsx("line",{x1:"68",y1:"0",x2:"68",y2:"14",stroke:"#909090",strokeWidth:"2"}),p.jsx("line",{x1:"122",y1:"0",x2:"122",y2:"14",stroke:"#909090",strokeWidth:"2"}),p.jsx("line",{x1:"176",y1:"0",x2:"176",y2:"14",stroke:"#909090",strokeWidth:"2"}),p.jsx("line",{x1:"230",y1:"0",x2:"230",y2:"14",stroke:"#909090",strokeWidth:"2"}),p.jsx("line",{x1:"68",y1:"14",x2:"230",y2:"14",stroke:"#909090",strokeWidth:"2"}),p.jsx("rect",{x:"135",y:"8",width:"28",height:"14",rx:"2",fill:"#c0c0c0",stroke:"#909090",strokeWidth:"1"}),p.jsx("line",{x1:"149",y1:"22",x2:"149",y2:"36",stroke:"#909090",strokeWidth:"2"}),p.jsx("line",{x1:"149",y1:"36",x2:"288",y2:"36",stroke:"#909090",strokeWidth:"2"}),p.jsx("line",{x1:"288",y1:"36",x2:"288",y2:"85",stroke:"#909090",strokeWidth:"2"}),p.jsx("line",{x1:"370",y1:"0",x2:"370",y2:"14",stroke:"#909090",strokeWidth:"2"}),p.jsx("line",{x1:"424",y1:"0",x2:"424",y2:"14",stroke:"#909090",strokeWidth:"2"}),p.jsx("line",{x1:"478",y1:"0",x2:"478",y2:"14",stroke:"#909090",strokeWidth:"2"}),p.jsx("line",{x1:"532",y1:"0",x2:"532",y2:"14",stroke:"#909090",strokeWidth:"2"}),p.jsx("line",{x1:"370",y1:"14",x2:"532",y2:"14",stroke:"#909090",strokeWidth:"2"}),p.jsx("rect",{x:"437",y:"8",width:"28",height:"14",rx:"2",fill:"#c0c0c0",stroke:"#909090",strokeWidth:"1"}),p.jsx("line",{x1:"451",y1:"22",x2:"451",y2:"36",stroke:"#909090",strokeWidth:"2"}),p.jsx("line",{x1:"312",y1:"36",x2:"451",y2:"36",stroke:"#909090",strokeWidth:"2"}),p.jsx("line",{x1:"312",y1:"36",x2:"312",y2:"85",stroke:"#909090",strokeWidth:"2"})]}),p.jsx("img",{src:"/icons/extruder-left-right.png",alt:"Extruder",className:"absolute left-1/2 -translate-x-1/2 bottom-0 h-[50px]"})]}):null}function i$e({printerId:t,status:e,nozzleCount:n}){const i=e?.connected??!1,r=e?.state==="RUNNING",a=n>1,s=e?.ams??[],o=a?s.filter((E,T)=>T%2===0):s,l=a?s.filter((E,T)=>T%2===1):[],[c,u]=A.useState(0),[f,m]=A.useState(0),[g,b]=A.useState(null),y=Mt({mutationFn:E=>$e.amsLoadFilament(t,E)}),v=Mt({mutationFn:()=>$e.amsUnloadFilament(t)}),x=()=>{g!==null&&y.mutate(g)},M=()=>{v.mutate()},w=y.isPending||v.isPending;return p.jsxs("div",{className:"bg-bambu-dark-tertiary rounded-[10px] p-3",children:[p.jsxs("div",{className:"flex gap-5",children:[p.jsx(nG,{units:o,side:"left",isPrinting:r,selectedAmsIndex:c,onSelectAms:u,selectedTray:g,onSelectTray:b}),a&&p.jsx(nG,{units:l,side:"right",isPrinting:r,selectedAmsIndex:f,onSelectAms:m,selectedTray:g,onSelectTray:b})]}),p.jsx(n$e,{isDualNozzle:a}),p.jsxs("div",{className:"flex items-start -mt-[50px]",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("button",{className:"w-10 h-10 rounded-lg bg-bambu-dark-secondary hover:bg-bambu-dark border border-bambu-dark-tertiary flex items-center justify-center",children:p.jsx("img",{src:"/icons/ams-settings.svg",alt:"Settings",className:"w-5 icon-theme"})}),p.jsx("button",{className:"px-[18px] py-2.5 rounded-lg bg-bambu-dark-secondary hover:bg-bambu-dark border border-bambu-dark-tertiary text-sm text-bambu-gray flex items-center gap-1.5",children:"Auto-refill"})]}),p.jsx("div",{className:"flex-1"}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("button",{onClick:M,disabled:!i||r||w,className:"px-7 py-2.5 rounded-lg bg-bambu-dark hover:bg-bambu-dark-secondary text-sm text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",children:v.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):"Unload"}),p.jsx("button",{onClick:x,disabled:!i||r||g===null||w,className:"px-7 py-2.5 rounded-lg bg-bambu-dark hover:bg-bambu-dark-secondary text-sm text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",children:y.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):"Load"})]})]}),(y.error||v.error)&&p.jsx("p",{className:"mt-2 text-sm text-red-500 text-center",children:(y.error||v.error)?.message})]})}function r$e({printerId:t,status:e,onClose:n}){const i=Gn(),r=e?.connected??!1;A.useEffect(()=>{const c=u=>{u.key==="Escape"&&n()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n]);const a=Mt({mutationFn:c=>$e.setTimelapse(t,c),onSuccess:c=>{console.log("Timelapse mutation success:",c),i.invalidateQueries({queryKey:["printerStatuses"]})},onError:c=>{console.error("Timelapse mutation error:",c)}}),s=Mt({mutationFn:c=>$e.setLiveview(t,c),onSuccess:c=>{console.log("Liveview mutation success:",c),i.invalidateQueries({queryKey:["printerStatuses"]})},onError:c=>{console.error("Liveview mutation error:",c)}});console.log("CameraSettingsModal render - isConnected:",r,"status:",e);const o=()=>{console.log("Timelapse toggle clicked, current:",e?.timelapse,"setting to:",!e?.timelapse),a.mutate(!e?.timelapse)},l=()=>{console.log("Liveview toggle clicked, current:",e?.ipcam,"setting to:",!e?.ipcam),s.mutate(!e?.ipcam)};return p.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:p.jsx(Xt,{className:"w-full max-w-sm",onClick:c=>c.stopPropagation(),children:p.jsxs(en,{className:"p-0",children:[p.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary",children:[p.jsx("span",{className:"text-sm font-medium text-white",children:"Camera Settings"}),p.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:p.jsx(Sn,{className:"w-4 h-4"})})]}),p.jsxs("div",{className:"p-4 space-y-4",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-sm text-white",children:"Auto-record Monitoring"}),p.jsx("button",{onClick:l,disabled:!r||s.isPending,className:`relative w-12 h-6 rounded-full transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${e?.ipcam?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.isPending?p.jsx(It,{className:"absolute inset-0 m-auto w-4 h-4 animate-spin text-white"}):p.jsx("span",{className:`absolute top-1 w-4 h-4 rounded-full bg-white transition-transform ${e?.ipcam?"left-7":"left-1"}`})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-sm text-white",children:"Go Live"}),p.jsx("button",{onClick:o,disabled:!r||a.isPending,className:`relative w-12 h-6 rounded-full transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${e?.timelapse?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.isPending?p.jsx(It,{className:"absolute inset-0 m-auto w-4 h-4 animate-spin text-white"}):p.jsx("span",{className:`absolute top-1 w-4 h-4 rounded-full bg-white transition-transform ${e?.timelapse?"left-7":"left-1"}`})})]})]})]})})})}function iG(t){const e=t.toUpperCase();if(e.startsWith("HH")||e.startsWith("HS"))return"Hardened Steel";if(e.startsWith("SS"))return"Stainless Steel";switch(t){case"hardened_steel":return"Hardened Steel";case"stainless_steel":return"Stainless Steel";default:return t||"Unknown"}}function rG(t){return t.toUpperCase().startsWith("HH")?"High flow":"Standard"}function a$e({printer:t,status:e,onClose:n}){const i=Gn(),r=t.nozzle_count>1;A.useEffect(()=>{const u=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[n]);const a=e?.nozzles?.[0],s=e?.nozzles?.[1],o=s?.nozzle_type||s?.nozzle_diameter?s:a,l=Mt({mutationFn:()=>$e.refreshStatus(t.id),onSuccess:()=>{i.invalidateQueries({queryKey:["printerStatuses"]})}}),c=()=>{l.mutate()};return p.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:p.jsx(Xt,{className:"w-full max-w-2xl",onClick:u=>u.stopPropagation(),children:p.jsxs(en,{className:"p-0",children:[p.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary",children:[p.jsx("span",{className:"text-sm font-medium text-white",children:"Printer Parts"}),p.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:p.jsx(Sn,{className:"w-4 h-4"})})]}),p.jsxs("div",{className:"p-6 space-y-6",children:[p.jsxs("div",{children:[p.jsx("h3",{className:"text-base font-semibold text-white mb-3",children:r?"Left Nozzle":"Nozzle"}),p.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1.5",children:"Type"}),p.jsx("div",{className:"px-3 py-2 bg-bambu-dark rounded border border-bambu-dark-tertiary text-sm text-bambu-gray",children:iG(a?.nozzle_type||"")})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1.5",children:"Diameter"}),p.jsx("div",{className:"px-3 py-2 bg-bambu-dark rounded border border-bambu-dark-tertiary text-sm text-bambu-gray",children:a?.nozzle_diameter||"—"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1.5",children:"Flow"}),p.jsx("div",{className:"px-3 py-2 bg-bambu-dark rounded border border-bambu-dark-tertiary text-sm text-bambu-gray",children:rG(a?.nozzle_type||"")})]})]})]}),r&&p.jsxs("div",{children:[p.jsx("h3",{className:"text-base font-semibold text-white mb-3",children:"Right Nozzle"}),p.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1.5",children:"Type"}),p.jsx("div",{className:"px-3 py-2 bg-bambu-dark rounded border border-bambu-dark-tertiary text-sm text-bambu-gray",children:iG(o?.nozzle_type||"")})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1.5",children:"Diameter"}),p.jsx("div",{className:"px-3 py-2 bg-bambu-dark rounded border border-bambu-dark-tertiary text-sm text-bambu-gray",children:o?.nozzle_diameter||"—"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"block text-sm text-bambu-gray mb-1.5",children:"Flow"}),p.jsx("div",{className:"px-3 py-2 bg-bambu-dark rounded border border-bambu-dark-tertiary text-sm text-bambu-gray",children:rG(o?.nozzle_type||"")})]})]})]}),p.jsxs("p",{className:"text-sm text-bambu-gray",children:["Please change the nozzle settings on the printer."," ",p.jsx("a",{href:"https://wiki.bambulab.com",target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:"View wiki"})]})]}),p.jsx("div",{className:"flex justify-end px-4 py-3 border-t border-bambu-dark-tertiary",children:p.jsxs("button",{onClick:c,disabled:l.isPending,className:"flex items-center gap-2 px-4 py-2 bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 text-white text-sm font-medium rounded",children:[l.isPending?p.jsx(It,{className:"w-4 h-4 animate-spin"}):p.jsx(Yo,{className:"w-4 h-4"}),"Refresh"]})})]})})})}function Fd({checked:t,onChange:e,disabled:n,loading:i}){return p.jsx("button",{onClick:()=>!n&&!i&&e(!t),disabled:n||i,className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${t?"bg-bambu-green border-bambu-green":"bg-transparent border-bambu-gray"} ${n||i?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:i?p.jsx(It,{className:"w-3 h-3 animate-spin text-white"}):t?p.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):null})}function r_({value:t,onChange:e,disabled:n,loading:i}){const[r,a]=A.useState(!1),s=["Low","Medium","High"],o=t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),l=n||i;return p.jsxs("div",{className:"relative",children:[p.jsxs("button",{onClick:()=>!l&&a(!r),disabled:l,className:`flex items-center gap-2 px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-sm text-white min-w-[100px] justify-between ${l?"opacity-50 cursor-not-allowed":"cursor-pointer hover:border-bambu-gray"}`,children:[i?p.jsx(It,{className:"w-4 h-4 animate-spin text-bambu-green"}):p.jsx("span",{children:o}),p.jsx(gm,{className:"w-4 h-4 text-bambu-gray"})]}),r&&!l&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),p.jsx("div",{className:"absolute top-full left-0 mt-1 w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded shadow-lg z-20",children:s.map(c=>p.jsx("button",{onClick:()=>{e(c.toLowerCase()),a(!1)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.toLowerCase()===c.toLowerCase()?"text-bambu-green":"text-white"}`,children:c},c))})]})]})}function s$e({printer:t,status:e,onClose:n}){const i=Gn(),r=e?.print_options,a=e?.connected??!1;A.useEffect(()=>{const f=m=>{m.key==="Escape"&&n()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[n]);const s=Mt({mutationFn:({apiModuleName:f,enabled:m,printHalt:g,sensitivity:b})=>$e.setPrintOption(t.id,f,m,g,b),onSuccess:()=>{i.invalidateQueries({queryKey:["printerStatuses"]})}}),o=(f,m,g)=>{const b=m&&g!==void 0&&g!=="never_halt";s.mutate({uiModuleName:f,apiModuleName:f,enabled:m,printHalt:b,sensitivity:g??"medium"})},l=(f,m)=>{let g=f;f==="pileup_detector"&&(g="spaghetti_detector"),s.mutate({uiModuleName:f,apiModuleName:g,enabled:!0,printHalt:!0,sensitivity:m})},c=f=>s.isPending&&s.variables?.uiModuleName===f,u=f=>{if(!s.isPending||!s.variables?.sensitivity)return!1;const m=s.variables.uiModuleName;return m===f||m==="spaghetti_detector"&&f==="pileup_detector"||m==="pileup_detector"&&f==="spaghetti_detector"};return p.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:p.jsx(Xt,{className:"w-full max-w-xl max-h-[90vh] flex flex-col",onClick:f=>f.stopPropagation(),children:p.jsxs(en,{className:"p-0 flex flex-col h-full",children:[p.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary",children:[p.jsx("span",{className:"text-sm font-medium text-white",children:"Print Options"}),p.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:p.jsx(Sn,{className:"w-4 h-4"})})]}),p.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[!a&&p.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400",children:[p.jsx(_o,{className:"w-4 h-4"}),p.jsx("span",{className:"text-sm",children:"Printer not connected. Options cannot be changed."})]}),r?p.jsxs(p.Fragment,{children:[p.jsxs("div",{children:[p.jsx("h3",{className:"text-base font-semibold text-white mb-1",children:"AI Detections"}),p.jsx("p",{className:"text-xs text-bambu-gray mb-4",children:"Printer will send assistant message or pause printing if any of the following problem is detected."}),p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(Fd,{checked:r.spaghetti_detector,onChange:f=>o("spaghetti_detector",f,r.halt_print_sensitivity),disabled:!a,loading:c("spaghetti_detector")}),p.jsx("span",{className:"text-sm font-medium text-white",children:"Spaghetti Detection"})]}),p.jsx("p",{className:"text-xs text-bambu-gray ml-8",children:"Detects spaghetti failure (scattered loose filament)."}),p.jsxs("div",{className:"flex items-center gap-3 ml-8",children:[p.jsx("span",{className:"text-xs text-bambu-gray",children:"Pausing Sensitivity:"}),p.jsx(r_,{value:r.halt_print_sensitivity||"medium",onChange:f=>l("spaghetti_detector",f),disabled:!a||!r.spaghetti_detector,loading:u("spaghetti_detector")})]})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(Fd,{checked:r.pileup_detector,onChange:f=>o("pileup_detector",f,r.pileup_sensitivity),disabled:!a,loading:c("pileup_detector")}),p.jsx("span",{className:"text-sm font-medium text-white",children:"Purge Chute Pile-Up Detection"})]}),p.jsx("p",{className:"text-xs text-bambu-gray ml-8",children:"Monitors if the waste is piled up in the purge chute."}),p.jsxs("div",{className:"flex items-center gap-3 ml-8",children:[p.jsx("span",{className:"text-xs text-bambu-gray",children:"Pausing Sensitivity:"}),p.jsx(r_,{value:r.pileup_sensitivity||"medium",onChange:f=>l("pileup_detector",f),disabled:!a||!r.pileup_detector,loading:u("pileup_detector")})]})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(Fd,{checked:r.nozzle_clumping_detector,onChange:f=>o("clump_detector",f,r.nozzle_clumping_sensitivity),disabled:!a,loading:c("clump_detector")}),p.jsx("span",{className:"text-sm font-medium text-white",children:"Nozzle Clumping Detection"})]}),p.jsx("p",{className:"text-xs text-bambu-gray ml-8",children:"Checks if the nozzle is clumping by filaments or other foreign objects."}),p.jsxs("div",{className:"flex items-center gap-3 ml-8",children:[p.jsx("span",{className:"text-xs text-bambu-gray",children:"Pausing Sensitivity:"}),p.jsx(r_,{value:r.nozzle_clumping_sensitivity||"medium",onChange:f=>l("clump_detector",f),disabled:!a||!r.nozzle_clumping_detector,loading:u("clump_detector")})]})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(Fd,{checked:r.airprint_detector,onChange:f=>o("airprint_detector",f,r.airprint_sensitivity),disabled:!a,loading:c("airprint_detector")}),p.jsx("span",{className:"text-sm font-medium text-white",children:"Air Printing Detection"})]}),p.jsx("p",{className:"text-xs text-bambu-gray ml-8",children:"Detects air printing caused by nozzle clogging or filament grinding."}),p.jsxs("div",{className:"flex items-center gap-3 ml-8",children:[p.jsx("span",{className:"text-xs text-bambu-gray",children:"Pausing Sensitivity:"}),p.jsx(r_,{value:r.airprint_sensitivity||"medium",onChange:f=>l("airprint_detector",f),disabled:!a||!r.airprint_detector,loading:u("airprint_detector")})]})]})]})]}),p.jsx("hr",{className:"border-bambu-dark-tertiary"}),p.jsxs("div",{children:[p.jsx("h3",{className:"text-base font-semibold text-white mb-1",children:"Build Plate Detection"}),p.jsx("p",{className:"text-xs text-bambu-gray mb-4",children:"Ensures the build plate type and placement are correct."}),p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(Fd,{checked:r.buildplate_marker_detector,onChange:f=>o("buildplate_marker_detector",f),disabled:!a,loading:c("buildplate_marker_detector")}),p.jsx("span",{className:"text-sm font-medium text-white",children:"Type Detection"})]}),p.jsx("p",{className:"text-xs text-bambu-gray ml-8",children:"Pauses printing when the detected build plate type does not match the selected one."})]})]}),p.jsx("hr",{className:"border-bambu-dark-tertiary"}),p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(Fd,{checked:r.auto_recovery_step_loss,onChange:f=>o("auto_recovery_step_loss",f),disabled:!a,loading:c("auto_recovery_step_loss")}),p.jsx("span",{className:"text-sm font-medium text-white",children:"Auto-recover from step loss"})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(Fd,{checked:e?.store_to_sdcard??!1,onChange:()=>{},disabled:!0}),p.jsx("span",{className:"text-sm font-medium text-white",children:"Store Sent Files on External Storage"}),p.jsx("span",{className:"text-xs text-bambu-gray italic",children:"(read-only)"})]}),p.jsx("p",{className:"text-xs text-bambu-gray ml-8",children:"Save the printing files initiated from Bambu Studio, Bambu Handy and MakerWorld on External Storage. This option can only be changed on the printer's touchscreen."})]})]})]}):p.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[p.jsx(_o,{className:"w-4 h-4"}),p.jsx("span",{className:"text-sm",children:"Print options not available. Try refreshing."})]})]})]})})})}const o$e=new Set([1,3,13,25,39,40,47,48,50]);function ex({checked:t,onChange:e,disabled:n}){return p.jsx("button",{onClick:()=>!n&&e(!t),disabled:n,className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${t?"bg-bambu-green border-bambu-green":"bg-transparent border-bambu-gray"} ${n?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:t&&p.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})})}function l$e({step:t,name:e,isActive:n,isComplete:i,isLast:r}){return p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("div",{className:"flex flex-col items-center",children:[p.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium flex-shrink-0 bg-bambu-green text-white",children:t}),!r&&p.jsx("div",{className:`w-0.5 h-6 ${i?"bg-bambu-green":"bg-bambu-gray/30"}`})]}),p.jsx("span",{className:`text-sm pt-0.5 ${n?"text-white font-semibold":"text-bambu-gray"}`,children:e})]})}function c$e({printer:t,status:e,onClose:n}){const i=e?.connected??!1,r=t.nozzle_count===2,a=e?.stg_cur??-1,[s,o]=A.useState(!1),[l,c]=A.useState(!1),[u,f]=A.useState(!1),m=`calibration_options_${t.id}`,g=typeof window<"u"?localStorage.getItem(m):null,b=g?JSON.parse(g):null,[y,v]=A.useState(b?.bedLeveling??!0),[x,M]=A.useState(b?.vibration??!0),[w,E]=A.useState(b?.motorNoise??!0),[T,R]=A.useState(b?.nozzleOffset??r),[N,j]=A.useState(b?.highTempHeatbed??!1),[C,k]=A.useState(!1),F=e?.state,I=o$e.has(a)&&F==="RUNNING";A.useEffect(()=>{!C&&I?(c(!0),o(!0),k(!0)):!C&&!I&&k(!0)},[C,I]),A.useEffect(()=>{I&&!l&&(c(!0),f(!1))},[I,l]),A.useEffect(()=>{I&&!s&&o(!0)},[I,s]),A.useEffect(()=>{l&&!I&&!u&&f(!0)},[l,I,u]);const q=()=>{localStorage.removeItem(m),o(!1),c(!1),f(!1),v(!0),M(!0),E(!0),R(r),j(!1)};A.useEffect(()=>{const Y=se=>{se.key==="Escape"&&n()};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[n]);const O=Mt({mutationFn:()=>$e.startCalibration(t.id,{bed_leveling:y,vibration:x,motor_noise:w,nozzle_offset:T,high_temp_heatbed:N}),onSuccess:()=>{localStorage.setItem(m,JSON.stringify({bedLeveling:y,vibration:x,motorNoise:w,nozzleOffset:T,highTempHeatbed:N})),o(!0)}}),H=y||x||w||T||N,V=i&&H&&!O.isPending&&!I&&!u,$=[];$.push({name:"Homing toolhead",stages:[13]}),(y||N)&&$.push({name:"Cooling heatbed",stages:[50]}),y&&$.push({name:"Auto bed leveling - phase 1",stages:[1,47]}),w&&$.push({name:"Motor noise cancellation",stages:[25]}),x&&$.push({name:"Vibration compensation",stages:[3]}),y&&$.push({name:"Auto bed leveling - phase 2",stages:[48]}),r&&T&&$.push({name:"Nozzle offset calibration",stages:[39]}),N&&$.push({name:"High-temp heatbed calibration",stages:[40]});const K=$.findIndex(Y=>Y.stages.includes(a));return p.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:p.jsx(Xt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col",onClick:Y=>Y.stopPropagation(),children:p.jsxs(en,{className:"p-0 flex flex-col h-full",children:[p.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary",children:[p.jsx("span",{className:"text-sm font-medium text-white",children:"Calibration"}),p.jsx("button",{onClick:n,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white",children:p.jsx(Sn,{className:"w-4 h-4"})})]}),p.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[!i&&p.jsxs("div",{className:"flex items-center gap-2 p-3 mb-4 bg-red-500/20 border border-red-500/50 rounded text-red-400",children:[p.jsx(_o,{className:"w-4 h-4"}),p.jsx("span",{className:"text-sm",children:"Printer not connected. Calibration cannot be started."})]}),p.jsxs("div",{className:"grid grid-cols-2 gap-8",children:[p.jsxs("div",{children:[p.jsx("h3",{className:"text-base font-semibold text-white mb-4",children:"Calibration step selection"}),p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(ex,{checked:y,onChange:v,disabled:!i||I}),p.jsx("span",{className:"text-sm text-white",children:"Bed leveling"})]}),p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(ex,{checked:x,onChange:M,disabled:!i||I}),p.jsx("span",{className:"text-sm text-white",children:"Vibration compensation"})]}),p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(ex,{checked:w,onChange:E,disabled:!i||I}),p.jsx("span",{className:"text-sm text-white",children:"Motor noise cancellation"})]}),r&&p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(ex,{checked:T,onChange:R,disabled:!i||I}),p.jsx("span",{className:"text-sm text-white",children:"Nozzle offset calibration"})]}),p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(ex,{checked:N,onChange:j,disabled:!i||I}),p.jsx("span",{className:"text-sm text-white whitespace-nowrap",children:"High-temperature Heatbed Calibration"})]})]}),p.jsxs("div",{className:"mt-6",children:[p.jsx("h4",{className:"text-sm font-semibold text-white mb-2",children:"Calibration program"}),p.jsx("p",{className:"text-xs text-bambu-gray",children:"The calibration program detects the status of your device automatically to minimize deviation. It keeps the device performing optimally."})]})]}),p.jsxs("div",{className:"flex flex-col",children:[p.jsx("h3",{className:"text-base font-semibold text-bambu-green mb-4 text-center border-b border-bambu-dark-tertiary pb-2",children:"Calibration Flow"}),p.jsx("div",{className:"flex-1 py-4 pl-4",children:H?p.jsxs("div",{className:"space-y-0",children:[$.map((Y,se)=>{const B=s&&!u&&Y.stages.includes(a),X=u||s&&K>se;return p.jsx(l$e,{step:se+1,name:Y.name,isActive:B,isComplete:X,isLast:se===$.length-1},Y.name)}),a>=0&&K===-1&&e?.stg_cur_name&&p.jsxs("div",{className:"mt-4 text-xs text-bambu-gray",children:["Current: ",e.stg_cur_name]})]}):p.jsx("div",{className:"flex items-center justify-center h-full text-sm text-bambu-gray italic",children:"Select calibration steps"})}),u?p.jsxs("div",{className:"space-y-2",children:[p.jsxs("button",{disabled:!0,className:"w-full py-2.5 px-4 rounded-lg font-medium text-sm flex items-center justify-center gap-2 bg-bambu-green text-white cursor-default",children:[p.jsx(jp,{className:"w-4 h-4"}),"Completed"]}),p.jsx("button",{onClick:q,className:"w-full py-2 px-4 rounded-lg font-medium text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary transition-colors",children:"New Calibration"})]}):p.jsx("button",{onClick:()=>O.mutate(),disabled:!V,className:`w-full py-2.5 px-4 rounded-lg font-medium text-sm flex items-center justify-center gap-2 transition-colors ${I?"bg-bambu-gray/50 text-white cursor-not-allowed":V?"bg-bambu-green hover:bg-bambu-green/90 text-white":"bg-bambu-dark-tertiary text-bambu-gray cursor-not-allowed"}`,children:I?p.jsxs(p.Fragment,{children:[p.jsx(It,{className:"w-4 h-4 animate-spin"}),"Calibrating"]}):O.isPending?p.jsxs(p.Fragment,{children:[p.jsx(It,{className:"w-4 h-4 animate-spin"}),"Starting..."]}):"Start Calibration"}),O.isError&&p.jsx("div",{className:"mt-2 text-xs text-red-400 text-center",children:O.error?.message||"Failed to start calibration"})]})]})]})]})})})}function u$e(){const[t,e]=Mre(),[n,i]=A.useState(null),[r,a]=A.useState(!1),[s,o]=A.useState(!1),[l,c]=A.useState(!1),[u,f]=A.useState(!1),{data:m,isLoading:g}=Ht({queryKey:["printers"],queryFn:$e.getPrinters}),{data:b}=Ht({queryKey:["printerStatuses"],queryFn:async()=>{if(!m)return{};const E={};return await Promise.all(m.map(async T=>{try{E[T.id]=await $e.getPrinterStatus(T.id)}catch{}})),E},enabled:!!m&&m.length>0,refetchInterval:2e3});A.useEffect(()=>{const E=t.get("printer");if(E){const T=parseInt(E,10);if(!isNaN(T)){i(T);return}}m&&m.length>0&&!n&&i(m[0].id)},[m,t,n]);const y=E=>{i(E),e({printer:String(E)})},v=m?.find(E=>E.id===n),x=n?b?.[n]:null,w=x?new Set([1,3,13,25,39,40,47,48,50]).has(x.stg_cur):!1;return g?p.jsx("div",{className:"flex items-center justify-center h-screen",children:p.jsx(It,{className:"w-8 h-8 animate-spin text-bambu-green"})}):!m||m.length===0?p.jsxs("div",{className:"flex flex-col items-center justify-center h-screen text-bambu-gray",children:[p.jsx(Fp,{className:"w-16 h-16 mb-4"}),p.jsx("p",{className:"text-xl",children:"No printers configured"}),p.jsx("p",{className:"text-sm mt-2",children:"Add a printer in the Printers page first"})]}):p.jsxs("div",{className:"h-screen flex flex-col bg-bambu-dark",children:[p.jsx("div",{className:"bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:p.jsx("div",{className:"flex overflow-x-auto",children:m.filter(E=>b?.[E.id]?.connected).map(E=>{const T=b?.[E.id],R=E.id===n;return p.jsxs("button",{onClick:()=>y(E.id),className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors whitespace-nowrap border-b-2 ${R?"border-bambu-green text-bambu-green bg-bambu-dark":"border-transparent text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[p.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),E.name,T?.state&&T.state!=="IDLE"&&p.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-bambu-dark-tertiary",children:T.state})]},E.id)})})}),v&&p.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[p.jsxs("div",{className:"flex-1 flex flex-col bg-bambu-dark",children:[p.jsxs("div",{className:"flex items-center justify-end gap-2 px-3 py-2.5 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary min-h-[44px]",children:[p.jsx("button",{className:`p-1.5 rounded hover:bg-bambu-dark-tertiary ${x?.sdcard?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:p.jsx("img",{src:"/icons/micro-sd.svg",alt:"SD Card",className:`w-4 h-4 ${x?.sdcard?"icon-green":"icon-theme"}`})}),p.jsx("button",{className:`p-1.5 rounded hover:bg-bambu-dark-tertiary ${x?.timelapse?"text-red-500":"text-bambu-gray hover:text-white"}`,children:p.jsx(cle,{className:"w-4 h-4"})}),p.jsx("button",{className:`p-1.5 rounded hover:bg-bambu-dark-tertiary ${x?.ipcam?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:p.jsx(dle,{className:"w-4 h-4"})}),p.jsx("button",{onClick:()=>a(!0),className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:p.jsx(n9,{className:"w-4 h-4"})})]}),p.jsx("div",{className:"flex-1 bg-black",children:p.jsx(XVe,{printerId:v.id,isConnected:x?.connected??!1})}),p.jsx("div",{className:"h-1 bg-bambu-green"}),p.jsx("div",{className:"bg-bambu-dark-secondary p-4 px-5",children:p.jsx(YVe,{printerId:v.id,status:x})})]}),p.jsxs("div",{className:"w-[680px] flex flex-col bg-bambu-dark-secondary border-l border-bambu-dark-tertiary overflow-y-auto",children:[p.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5 border-b border-bambu-dark-tertiary min-h-[44px]",children:[p.jsx("span",{className:"text-sm text-bambu-gray",children:"Control"}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("button",{onClick:()=>o(!0),className:"px-4 py-1.5 text-xs rounded bg-bambu-green text-white hover:bg-bambu-green-dark",children:"Printer Parts"}),p.jsx("button",{onClick:()=>c(!0),className:"px-4 py-1.5 text-xs rounded bg-bambu-green text-white hover:bg-bambu-green-dark",children:"Print Options"}),p.jsx("button",{onClick:()=>f(!0),className:"px-4 py-1.5 text-xs rounded bg-bambu-green text-white hover:bg-bambu-green-dark",children:"Calibration"})]})]}),!x?.connected&&p.jsxs("div",{className:"m-3 p-3 bg-red-500/20 border border-red-500/50 rounded-lg flex items-center gap-3",children:[p.jsx(Fp,{className:"w-4 h-4 text-red-500"}),p.jsx("span",{className:"text-sm text-red-400",children:"Printer is not connected. Controls are disabled."})]}),p.jsxs("div",{className:"flex-1 p-4 bg-bambu-dark",children:[p.jsx("div",{className:"mb-4 bg-bambu-dark-tertiary rounded-[10px] p-3",children:p.jsxs("div",{className:"flex gap-4 bg-bambu-dark-secondary rounded-[8px] p-4 overflow-hidden",style:{minHeight:"300px"},children:[p.jsx(ZVe,{printerId:v.id,status:x,nozzleCount:v.nozzle_count,disabled:w}),p.jsxs("div",{className:"flex-1 flex gap-6 items-center justify-center",children:[p.jsxs("div",{className:"flex flex-col items-center",children:[p.jsx(QVe,{printerId:v.id,status:x,disabled:w}),p.jsx(JVe,{printerId:v.id,status:x,disabled:w})]}),p.jsx(e$e,{printerId:v.id,status:x,nozzleCount:v.nozzle_count,disabled:w})]})]})}),p.jsx(i$e,{printerId:v.id,status:x,nozzleCount:v.nozzle_count})]})]})]}),r&&v&&p.jsx(r$e,{printerId:v.id,status:x,onClose:()=>a(!1)}),s&&v&&p.jsx(a$e,{printer:v,status:x,onClose:()=>o(!1)}),l&&v&&p.jsx(s$e,{printer:v,status:x,onClose:()=>c(!1)}),u&&v&&p.jsx(c$e,{printer:v,status:x,onClose:()=>f(!1)})]})}function d$e(){const t=A.useRef(null),e=A.useRef(null),n=Gn(),[i,r]=A.useState(!1),a=A.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const c=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,u=new WebSocket(c);let f=null;u.onopen=()=>{console.log("[WebSocket] Connected"),r(!0),f=window.setInterval(()=>{u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({type:"ping"}))},3e4)},u.onmessage=m=>{try{const g=JSON.parse(m.data);s(g)}catch{}},u.onclose=m=>{console.log("[WebSocket] Closed",m.code,m.reason),f&&(clearInterval(f),f=null),r(!1),t.current=null,e.current=window.setTimeout(()=>{a()},3e3)},u.onerror=m=>{console.error("[WebSocket] Error",m),u.close()},t.current=u},[]),s=A.useCallback(l=>{switch(l.type){case"printer_status":l.printer_id!==void 0&&n.setQueryData(["printerStatus",l.printer_id],c=>({...c,...l.data}));break;case"print_complete":n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]});break;case"archive_created":n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]});break}},[n]);A.useEffect(()=>(a(),()=>{e.current&&clearTimeout(e.current),t.current&&t.current.close()}),[a]);const o=A.useCallback(l=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(l))},[]);return{isConnected:i,sendMessage:o}}const f$e=new Jre({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function h$e({children:t}){return d$e(),p.jsx(p.Fragment,{children:t})}function p$e(){return p.jsx(_le,{children:p.jsx(Ple,{children:p.jsx(eae,{client:f$e,children:p.jsx(h$e,{children:p.jsx(yre,{children:p.jsx(Yie,{children:p.jsxs(Lo,{path:"/",element:p.jsx(Cle,{}),children:[p.jsx(Lo,{index:!0,element:p.jsx(qle,{})}),p.jsx(Lo,{path:"archives",element:p.jsx(b2e,{})}),p.jsx(Lo,{path:"queue",element:p.jsx(S2e,{})}),p.jsx(Lo,{path:"stats",element:p.jsx(EVe,{})}),p.jsx(Lo,{path:"profiles",element:p.jsx(HVe,{})}),p.jsx(Lo,{path:"maintenance",element:p.jsx(qVe,{})}),p.jsx(Lo,{path:"control",element:p.jsx(u$e,{})}),p.jsx(Lo,{path:"settings",element:p.jsx(OVe,{})})]})})})})})})})}ene.createRoot(document.getElementById("root")).render(p.jsx(A.StrictMode,{children:p.jsx(p$e,{})}));
diff --git a/static/assets/index-CH7yvvuS.css b/static/assets/index-CH7yvvuS.css
new file mode 100644
index 000000000..3c01540c3
--- /dev/null
+++ b/static/assets/index-CH7yvvuS.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-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-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--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-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-500:oklch(62.7% .265 303.9);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-xl:36rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--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);--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--tracking-widest:.1em;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--drop-shadow-sm:0 1px 2px #00000026;--ease-in-out:cubic-bezier(.4,0,.2,1);--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--blur-sm:8px;--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:#00ae42;--color-bambu-green-light:#00c64d;--color-bambu-green-dark:#009438;--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}.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}.inset-0{inset:calc(var(--spacing)*0)}.inset-y-0{inset-block:calc(var(--spacing)*0)}.-top-1{top:calc(var(--spacing)*-1)}.top-1{top:calc(var(--spacing)*1)}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing)*2)}.top-4{top:calc(var(--spacing)*4)}.top-\[2px\]{top:2px}.top-\[8px\]{top:8px}.top-\[42px\]{top:42px}.top-full{top:100%}.-right-1{right:calc(var(--spacing)*-1)}.right-0{right:calc(var(--spacing)*0)}.right-2{right:calc(var(--spacing)*2)}.right-4{right:calc(var(--spacing)*4)}.right-12{right:calc(var(--spacing)*12)}.right-\[8px\]{right:8px}.right-\[42px\]{right:42px}.bottom-0{bottom:calc(var(--spacing)*0)}.bottom-1{bottom:calc(var(--spacing)*1)}.bottom-2{bottom:calc(var(--spacing)*2)}.bottom-4{bottom:calc(var(--spacing)*4)}.bottom-6{bottom:calc(var(--spacing)*6)}.bottom-\[8px\]{bottom:8px}.bottom-\[42px\]{bottom:42px}.left-0{left:calc(var(--spacing)*0)}.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-7{left:calc(var(--spacing)*7)}.left-12{left:calc(var(--spacing)*12)}.left-\[2px\]{left:2px}.left-\[8px\]{left:8px}.left-\[42px\]{left:42px}.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}.col-span-1{grid-column:span 1/span 1}.col-span-2{grid-column:span 2/span 2}.col-span-4{grid-column:span 4/span 4}.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-3{margin:calc(var(--spacing)*3)}.m-auto{margin:auto}.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-2{margin-top:calc(var(--spacing)*-2)}.-mt-\[50px\]{margin-top:-50px}.mt-0\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.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)}.mr-1{margin-right:calc(var(--spacing)*1)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-4{margin-right:calc(var(--spacing)*4)}.-mb-px{margin-bottom:-1px}.mb-0\.5{margin-bottom:calc(var(--spacing)*.5)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-1\.5{margin-bottom:calc(var(--spacing)*1.5)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-2\.5{margin-bottom:calc(var(--spacing)*2.5)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-3\.5{margin-bottom:calc(var(--spacing)*3.5)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.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-0\.5{margin-left:calc(var(--spacing)*.5)}.ml-1\.5{margin-left:calc(var(--spacing)*1.5)}.ml-2{margin-left:calc(var(--spacing)*2)}.ml-8{margin-left:calc(var(--spacing)*8)}.ml-16{margin-left:calc(var(--spacing)*16)}.ml-64{margin-left:calc(var(--spacing)*64)}.ml-auto{margin-left:auto}.line-clamp-3{-webkit-line-clamp:3;-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}.aspect-square{aspect-ratio:1}.aspect-video{aspect-ratio:var(--aspect-video)}.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-8{height:calc(var(--spacing)*8)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-28{height:calc(var(--spacing)*28)}.h-64{height:calc(var(--spacing)*64)}.h-\[25px\]{height:25px}.h-\[30px\]{height:30px}.h-\[35px\]{height:35px}.h-\[40px\]{height:40px}.h-\[50px\]{height:50px}.h-\[70px\]{height:70px}.h-\[80vh\]{height:80vh}.h-\[120px\]{height:120px}.h-\[160px\]{height:160px}.h-\[220px\]{height:220px}.h-full{height:100%}.h-screen{height:100vh}.max-h-40{max-height:calc(var(--spacing)*40)}.max-h-60{max-height:calc(var(--spacing)*60)}.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-full{max-height:100%}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-\[44px\]{min-height:44px}.min-h-\[48px\]{min-height:48px}.min-h-\[120px\]{min-height:120px}.min-h-\[400px\]{min-height:400px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-0\.5{width:calc(var(--spacing)*.5)}.w-2{width:calc(var(--spacing)*2)}.w-2\.5{width:calc(var(--spacing)*2.5)}.w-3{width:calc(var(--spacing)*3)}.w-3\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.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-16{width:calc(var(--spacing)*16)}.w-20{width:calc(var(--spacing)*20)}.w-28{width:calc(var(--spacing)*28)}.w-32{width:calc(var(--spacing)*32)}.w-36{width:calc(var(--spacing)*36)}.w-40{width:calc(var(--spacing)*40)}.w-48{width:calc(var(--spacing)*48)}.w-64{width:calc(var(--spacing)*64)}.w-80{width:calc(var(--spacing)*80)}.w-\[25px\]{width:25px}.w-\[30px\]{width:30px}.w-\[35px\]{width:35px}.w-\[40px\]{width:40px}.w-\[50px\]{width:50px}.w-\[220px\]{width:220px}.w-\[680px\]{width:680px}.w-auto{width:auto}.w-fit{width:fit-content}.w-full{width:100%}.w-px{width:1px}.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-\[90vw\]{max-width:90vw}.max-w-\[100px\]{max-width:100px}.max-w-\[200px\]{max-width:200px}.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)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-48{min-width:calc(var(--spacing)*48)}.min-w-\[18px\]{min-width:18px}.min-w-\[70px\]{min-width:70px}.min-w-\[80px\]{min-width:80px}.min-w-\[100px\]{min-width:100px}.min-w-\[120px\]{min-width:120px}.min-w-\[150px\]{min-width:150px}.min-w-\[160px\]{min-width:160px}.min-w-\[180px\]{min-width:180px}.min-w-\[200px\]{min-width:200px}.flex-1{flex: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-0{--tw-translate-x:calc(var(--spacing)*0);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-4{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-7{--tw-translate-x:calc(var(--spacing)*7);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-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.-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-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.resize{resize:both}.resize-none{resize:none}.\[appearance\:textfield\]{appearance:textfield}.appearance-none{appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-evenly{justify-content:space-evenly}.gap-0\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-2\.5{gap:calc(var(--spacing)*2.5)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-6{gap:calc(var(--spacing)*6)}.gap-8{gap:calc(var(--spacing)*8)}:where(.space-y-0>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*0)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*0)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-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-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-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)))}: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)){border-color:var(--color-bambu-dark-tertiary)}.self-center{align-self:center}.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-\[8px\]{border-radius:8px}.rounded-\[10px\]{border-radius:10px}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-t-xl{border-top-left-radius:var(--radius-xl);border-top-right-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.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-r{border-right-style:var(--tw-border-style);border-right-width:1px}.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-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-dashed{--tw-border-style:dashed;border-style:dashed}.border-\[\#d4a84b\]{border-color:#d4a84b}.border-bambu-dark-tertiary{border-color:var(--color-bambu-dark-tertiary)}.border-bambu-gray{border-color:var(--color-bambu-gray)}.border-bambu-green{border-color:var(--color-bambu-green)}.border-bambu-green\/30{border-color:#00ae424d}@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\/50{border-color:#00ae4280}@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-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-gray-700{border-color:var(--color-gray-700)}.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-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-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-yellow-500{border-color:var(--color-yellow-500)}.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-t-transparent{border-top-color:#0000}.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-bambu-dark{background-color:var(--color-bambu-dark)}.bg-bambu-dark-secondary,.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-tertiary,.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\/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\/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-green{background-color:var(--color-bambu-green)}.bg-bambu-green\/10{background-color:#00ae421a}@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:#00ae4233}@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:#00ae424d}@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:#00ae4280}@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:#00ae42bf}@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-black{background-color:var(--color-black)}.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-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\/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-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\/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-green-400{background-color:var(--color-green-400)}.bg-green-400\/10{background-color:#05df721a}@supports (color:color-mix(in lab,red,red)){.bg-green-400\/10{background-color:color-mix(in oklab,var(--color-green-400)10%,transparent)}}.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\/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-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\/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-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-red-400{background-color:var(--color-red-400)}.bg-red-400\/10{background-color:#ff65681a}@supports (color:color-mix(in lab,red,red)){.bg-red-400\/10{background-color:color-mix(in oklab,var(--color-red-400)10%,transparent)}}.bg-red-500{background-color:var(--color-red-500)}.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\/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-transparent{background-color:#0000}.bg-white{background-color:var(--color-white)}.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\/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)}}.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-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-6{padding:calc(var(--spacing)*6)}.p-8{padding:calc(var(--spacing)*8)}.p-12{padding:calc(var(--spacing)*12)}.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-3\.5{padding-inline:calc(var(--spacing)*3.5)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-5{padding-inline:calc(var(--spacing)*5)}.px-6{padding-inline:calc(var(--spacing)*6)}.px-7{padding-inline:calc(var(--spacing)*7)}.px-\[18px\]{padding-inline:18px}.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-8{padding-block:calc(var(--spacing)*8)}.py-12{padding-block:calc(var(--spacing)*12)}.py-\[3px\]{padding-block:3px}.pt-0{padding-top:calc(var(--spacing)*0)}.pt-0\.5{padding-top:calc(var(--spacing)*.5)}.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-3{padding-right:calc(var(--spacing)*3)}.pr-4{padding-right:calc(var(--spacing)*4)}.pr-5{padding-right:calc(var(--spacing)*5)}.pr-8{padding-right:calc(var(--spacing)*8)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pb-\[5px\]{padding-bottom:5px}.pl-4{padding-left:calc(var(--spacing)*4)}.pl-8{padding-left:calc(var(--spacing)*8)}.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)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--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-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.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-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.whitespace-pre-wrap{white-space:pre-wrap}.text-amber-400{color:var(--color-amber-400)}.text-bambu-dark-tertiary{color:var(--color-bambu-dark-tertiary)}.text-bambu-gray{color:var(--color-bambu-gray)}.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\/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\/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-green{color:var(--color-bambu-green)}.text-blue-400{color:var(--color-blue-400)}.text-gray-400{color:var(--color-gray-400)}.text-gray-800{color:var(--color-gray-800)}.text-green-400{color:var(--color-green-400)}.text-green-500{color:var(--color-green-500)}.text-orange-400{color:var(--color-orange-400)}.text-purple-400{color:var(--color-purple-400)}.text-red-400{color:var(--color-red-400)}.text-red-500{color:var(--color-red-500)}.text-white{color:var(--color-white)}.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-yellow-400{color:var(--color-yellow-400)}.text-yellow-500{color:var(--color-yellow-500)}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.italic{font-style:italic}.underline{text-decoration-line:underline}.placeholder-bambu-gray::placeholder,.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)}}.accent-bambu-green{accent-color:var(--color-bambu-green)}.opacity-0{opacity:0}.opacity-20{opacity:.2}.opacity-30{opacity:.3}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-80{opacity:.8}.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-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-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)}.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)}.ring-bambu-green{--tw-ring-color:var(--color-bambu-green)}.ring-white{--tw-ring-color:var(--color-white)}.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,)}.drop-shadow-sm{--tw-drop-shadow-size:drop-shadow(0 1px 2px var(--tw-drop-shadow-color,#00000026));--tw-drop-shadow:drop-shadow(var(--drop-shadow-sm));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,)}.invert{--tw-invert:invert(100%);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-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-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}@media(hover:hover){.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 *){opacity:1}}.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}.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\: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)}@media(hover:hover){.hover\:border-bambu-gray:hover{border-color:var(--color-bambu-gray)}.hover\:border-bambu-green:hover{border-color:var(--color-bambu-green)}.hover\:border-white\/40:hover{border-color:#fff6}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/40:hover{border-color:color-mix(in oklab,var(--color-white)40%,transparent)}}.hover\:bg-bambu-dark:hover{background-color:var(--color-bambu-dark)}.hover\:bg-bambu-dark-secondary:hover{background-color:var(--color-bambu-dark-secondary)}.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-gray-dark:hover{background-color:var(--color-bambu-gray-dark)}.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\/20:hover{background-color:#00ae4233}@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:#00ae424d}@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\/90:hover{background-color:#00ae42e6}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/90:hover{background-color:color-mix(in oklab,var(--color-bambu-green)90%,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-gray-700:hover{background-color:var(--color-gray-700)}.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:hover{background-color:var(--color-red-500)}.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\/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:hover{background-color:var(--color-white)}.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\:text-bambu-green:hover{color:var(--color-bambu-green)}.hover\:text-bambu-green\/80:hover{color:#00ae42cc}@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-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\:underline:hover{text-decoration-line:underline}.hover\:opacity-10:hover{opacity:.1}.hover\:opacity-70:hover{opacity:.7}.hover\:opacity-80:hover{opacity:.8}}.focus\:border-bambu-green:focus{border-color:var(--color-bambu-green)}.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{--tw-ring-color:var(--color-bambu-green)}.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\:outline-none:focus{--tw-outline-style:none;outline-style:none}.active\:cursor-grabbing:active{cursor:grabbing}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-50:disabled{opacity:.5}@media(hover:hover){.disabled\:hover\:bg-bambu-dark-secondary:disabled:hover{background-color:var(--color-bambu-dark-secondary)}.disabled\:hover\:text-bambu-gray:disabled:hover{color:var(--color-bambu-gray)}}@media(min-width:40rem){.sm\:inline{display:inline}.sm\:h-4{height:calc(var(--spacing)*4)}.sm\:w-4{width:calc(var(--spacing)*4)}.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\:p-1\.5{padding:calc(var(--spacing)*1.5)}}@media(min-width:48rem){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}}@media(min-width:64rem){.lg\:w-80{width:calc(var(--spacing)*80)}.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\:flex-row{flex-direction:row}}@media(min-width:80rem){.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}.\[\&\:\:-moz-range-thumb\]\:h-4::-moz-range-thumb{height:calc(var(--spacing)*4)}.\[\&\:\:-moz-range-thumb\]\:w-4::-moz-range-thumb{width:calc(var(--spacing)*4)}.\[\&\:\:-moz-range-thumb\]\:cursor-pointer::-moz-range-thumb{cursor:pointer}.\[\&\:\:-moz-range-thumb\]\:rounded-full::-moz-range-thumb{border-radius:3.40282e38px}.\[\&\:\:-moz-range-thumb\]\:border-0::-moz-range-thumb{border-style:var(--tw-border-style);border-width:0}.\[\&\:\:-moz-range-thumb\]\:bg-bambu-green::-moz-range-thumb{background-color:var(--color-bambu-green)}.\[\&\:\:-webkit-slider-thumb\]\:h-3::-webkit-slider-thumb{height:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:h-4::-webkit-slider-thumb{height:calc(var(--spacing)*4)}.\[\&\:\:-webkit-slider-thumb\]\:w-3::-webkit-slider-thumb{width:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:w-4::-webkit-slider-thumb{width:calc(var(--spacing)*4)}.\[\&\:\:-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{--bg-primary:#f5f5f5;--bg-secondary:#fff;--bg-tertiary:#e5e5e5;--text-primary:#1a1a1a;--text-secondary:#4a4a4a;--text-muted:#6b6b6b;--text-tertiary:gray;--border-color:#d4d4d4;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}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(.7)contrast(1.1)}@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-font-weight{syntax:"*";inherits:false}@property --tw-tracking{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-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 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-font-weight:initial;--tw-tracking: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-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-OlFdoeRK.css b/static/assets/index-OlFdoeRK.css
deleted file mode 100644
index ddf676746..000000000
--- a/static/assets/index-OlFdoeRK.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-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-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--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-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-500:oklch(62.7% .265 303.9);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-xl:36rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--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);--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--tracking-widest:.1em;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--drop-shadow-sm:0 1px 2px #00000026;--ease-in-out:cubic-bezier(.4,0,.2,1);--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--blur-sm:8px;--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:#00ae42;--color-bambu-green-light:#00c64d;--color-bambu-green-dark:#009438;--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}.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}.inset-0{inset:calc(var(--spacing)*0)}.inset-y-0{inset-block:calc(var(--spacing)*0)}.-top-1{top:calc(var(--spacing)*-1)}.top-1{top:calc(var(--spacing)*1)}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing)*2)}.top-4{top:calc(var(--spacing)*4)}.top-\[2px\]{top:2px}.top-\[8px\]{top:8px}.top-\[42px\]{top:42px}.top-full{top:100%}.-right-1{right:calc(var(--spacing)*-1)}.right-0{right:calc(var(--spacing)*0)}.right-2{right:calc(var(--spacing)*2)}.right-4{right:calc(var(--spacing)*4)}.right-12{right:calc(var(--spacing)*12)}.right-\[8px\]{right:8px}.right-\[42px\]{right:42px}.bottom-0{bottom:calc(var(--spacing)*0)}.bottom-1{bottom:calc(var(--spacing)*1)}.bottom-2{bottom:calc(var(--spacing)*2)}.bottom-4{bottom:calc(var(--spacing)*4)}.bottom-6{bottom:calc(var(--spacing)*6)}.bottom-\[8px\]{bottom:8px}.bottom-\[42px\]{bottom:42px}.left-0{left:calc(var(--spacing)*0)}.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-7{left:calc(var(--spacing)*7)}.left-12{left:calc(var(--spacing)*12)}.left-\[2px\]{left:2px}.left-\[8px\]{left:8px}.left-\[42px\]{left:42px}.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}.col-span-1{grid-column:span 1/span 1}.col-span-2{grid-column:span 2/span 2}.col-span-4{grid-column:span 4/span 4}.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-3{margin:calc(var(--spacing)*3)}.m-auto{margin:auto}.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-2{margin-top:calc(var(--spacing)*-2)}.-mt-\[50px\]{margin-top:-50px}.mt-0\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.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)}.mr-1{margin-right:calc(var(--spacing)*1)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-4{margin-right:calc(var(--spacing)*4)}.-mb-px{margin-bottom:-1px}.mb-0\.5{margin-bottom:calc(var(--spacing)*.5)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-1\.5{margin-bottom:calc(var(--spacing)*1.5)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-2\.5{margin-bottom:calc(var(--spacing)*2.5)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-3\.5{margin-bottom:calc(var(--spacing)*3.5)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.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-0\.5{margin-left:calc(var(--spacing)*.5)}.ml-1\.5{margin-left:calc(var(--spacing)*1.5)}.ml-2{margin-left:calc(var(--spacing)*2)}.ml-8{margin-left:calc(var(--spacing)*8)}.ml-16{margin-left:calc(var(--spacing)*16)}.ml-64{margin-left:calc(var(--spacing)*64)}.ml-auto{margin-left:auto}.line-clamp-3{-webkit-line-clamp:3;-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}.aspect-square{aspect-ratio:1}.aspect-video{aspect-ratio:var(--aspect-video)}.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-8{height:calc(var(--spacing)*8)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-28{height:calc(var(--spacing)*28)}.h-64{height:calc(var(--spacing)*64)}.h-\[25px\]{height:25px}.h-\[30px\]{height:30px}.h-\[35px\]{height:35px}.h-\[40px\]{height:40px}.h-\[50px\]{height:50px}.h-\[70px\]{height:70px}.h-\[80vh\]{height:80vh}.h-\[120px\]{height:120px}.h-\[160px\]{height:160px}.h-\[220px\]{height:220px}.h-full{height:100%}.h-screen{height:100vh}.max-h-40{max-height:calc(var(--spacing)*40)}.max-h-60{max-height:calc(var(--spacing)*60)}.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-full{max-height:100%}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-\[44px\]{min-height:44px}.min-h-\[48px\]{min-height:48px}.min-h-\[120px\]{min-height:120px}.min-h-\[400px\]{min-height:400px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-0\.5{width:calc(var(--spacing)*.5)}.w-2{width:calc(var(--spacing)*2)}.w-2\.5{width:calc(var(--spacing)*2.5)}.w-3{width:calc(var(--spacing)*3)}.w-3\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.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-16{width:calc(var(--spacing)*16)}.w-20{width:calc(var(--spacing)*20)}.w-28{width:calc(var(--spacing)*28)}.w-32{width:calc(var(--spacing)*32)}.w-36{width:calc(var(--spacing)*36)}.w-40{width:calc(var(--spacing)*40)}.w-48{width:calc(var(--spacing)*48)}.w-64{width:calc(var(--spacing)*64)}.w-80{width:calc(var(--spacing)*80)}.w-\[25px\]{width:25px}.w-\[30px\]{width:30px}.w-\[35px\]{width:35px}.w-\[40px\]{width:40px}.w-\[50px\]{width:50px}.w-\[220px\]{width:220px}.w-\[680px\]{width:680px}.w-auto{width:auto}.w-fit{width:fit-content}.w-full{width:100%}.w-px{width:1px}.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-\[90vw\]{max-width:90vw}.max-w-\[100px\]{max-width:100px}.max-w-\[200px\]{max-width:200px}.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)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-48{min-width:calc(var(--spacing)*48)}.min-w-\[18px\]{min-width:18px}.min-w-\[70px\]{min-width:70px}.min-w-\[80px\]{min-width:80px}.min-w-\[100px\]{min-width:100px}.min-w-\[120px\]{min-width:120px}.min-w-\[150px\]{min-width:150px}.min-w-\[160px\]{min-width:160px}.min-w-\[180px\]{min-width:180px}.min-w-\[200px\]{min-width:200px}.flex-1{flex: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-0{--tw-translate-x:calc(var(--spacing)*0);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-4{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-7{--tw-translate-x:calc(var(--spacing)*7);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-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.-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-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.resize{resize:both}.resize-none{resize:none}.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))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-evenly{justify-content:space-evenly}.gap-0\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-2\.5{gap:calc(var(--spacing)*2.5)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-6{gap:calc(var(--spacing)*6)}.gap-8{gap:calc(var(--spacing)*8)}:where(.space-y-0>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*0)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*0)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-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-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-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)))}: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)){border-color:var(--color-bambu-dark-tertiary)}.self-center{align-self:center}.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-\[8px\]{border-radius:8px}.rounded-\[10px\]{border-radius:10px}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-t-xl{border-top-left-radius:var(--radius-xl);border-top-right-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.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-r{border-right-style:var(--tw-border-style);border-right-width:1px}.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-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-dashed{--tw-border-style:dashed;border-style:dashed}.border-\[\#d4a84b\]{border-color:#d4a84b}.border-bambu-dark-tertiary{border-color:var(--color-bambu-dark-tertiary)}.border-bambu-gray{border-color:var(--color-bambu-gray)}.border-bambu-green{border-color:var(--color-bambu-green)}.border-bambu-green\/30{border-color:#00ae424d}@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\/50{border-color:#00ae4280}@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-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-gray-700{border-color:var(--color-gray-700)}.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-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-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-yellow-500{border-color:var(--color-yellow-500)}.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-t-transparent{border-top-color:#0000}.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-bambu-dark{background-color:var(--color-bambu-dark)}.bg-bambu-dark-secondary,.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-tertiary,.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\/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\/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-green{background-color:var(--color-bambu-green)}.bg-bambu-green\/10{background-color:#00ae421a}@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:#00ae4233}@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:#00ae424d}@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:#00ae4280}@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:#00ae42bf}@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-black{background-color:var(--color-black)}.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-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\/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-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\/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-green-400{background-color:var(--color-green-400)}.bg-green-400\/10{background-color:#05df721a}@supports (color:color-mix(in lab,red,red)){.bg-green-400\/10{background-color:color-mix(in oklab,var(--color-green-400)10%,transparent)}}.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\/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-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\/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-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-red-400{background-color:var(--color-red-400)}.bg-red-400\/10{background-color:#ff65681a}@supports (color:color-mix(in lab,red,red)){.bg-red-400\/10{background-color:color-mix(in oklab,var(--color-red-400)10%,transparent)}}.bg-red-500{background-color:var(--color-red-500)}.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\/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-transparent{background-color:#0000}.bg-white{background-color:var(--color-white)}.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\/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)}}.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-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-6{padding:calc(var(--spacing)*6)}.p-8{padding:calc(var(--spacing)*8)}.p-12{padding:calc(var(--spacing)*12)}.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-3\.5{padding-inline:calc(var(--spacing)*3.5)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-5{padding-inline:calc(var(--spacing)*5)}.px-6{padding-inline:calc(var(--spacing)*6)}.px-7{padding-inline:calc(var(--spacing)*7)}.px-\[18px\]{padding-inline:18px}.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-8{padding-block:calc(var(--spacing)*8)}.py-12{padding-block:calc(var(--spacing)*12)}.py-\[3px\]{padding-block:3px}.pt-0{padding-top:calc(var(--spacing)*0)}.pt-0\.5{padding-top:calc(var(--spacing)*.5)}.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-3{padding-right:calc(var(--spacing)*3)}.pr-4{padding-right:calc(var(--spacing)*4)}.pr-5{padding-right:calc(var(--spacing)*5)}.pr-8{padding-right:calc(var(--spacing)*8)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pb-\[5px\]{padding-bottom:5px}.pl-4{padding-left:calc(var(--spacing)*4)}.pl-8{padding-left:calc(var(--spacing)*8)}.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)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--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-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.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-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.whitespace-pre-wrap{white-space:pre-wrap}.text-amber-400{color:var(--color-amber-400)}.text-bambu-dark-tertiary{color:var(--color-bambu-dark-tertiary)}.text-bambu-gray{color:var(--color-bambu-gray)}.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\/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\/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-green{color:var(--color-bambu-green)}.text-blue-400{color:var(--color-blue-400)}.text-gray-400{color:var(--color-gray-400)}.text-gray-800{color:var(--color-gray-800)}.text-green-400{color:var(--color-green-400)}.text-green-500{color:var(--color-green-500)}.text-orange-400{color:var(--color-orange-400)}.text-purple-400{color:var(--color-purple-400)}.text-red-400{color:var(--color-red-400)}.text-red-500{color:var(--color-red-500)}.text-white{color:var(--color-white)}.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-yellow-400{color:var(--color-yellow-400)}.text-yellow-500{color:var(--color-yellow-500)}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.italic{font-style:italic}.underline{text-decoration-line:underline}.placeholder-bambu-gray::placeholder,.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)}}.accent-bambu-green{accent-color:var(--color-bambu-green)}.opacity-0{opacity:0}.opacity-20{opacity:.2}.opacity-30{opacity:.3}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-80{opacity:.8}.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-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-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)}.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)}.ring-bambu-green{--tw-ring-color:var(--color-bambu-green)}.ring-white{--tw-ring-color:var(--color-white)}.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,)}.drop-shadow-sm{--tw-drop-shadow-size:drop-shadow(0 1px 2px var(--tw-drop-shadow-color,#00000026));--tw-drop-shadow:drop-shadow(var(--drop-shadow-sm));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,)}.invert{--tw-invert:invert(100%);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-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-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}@media(hover:hover){.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 *){opacity:1}}.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}.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\: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)}@media(hover:hover){.hover\:border-bambu-gray:hover{border-color:var(--color-bambu-gray)}.hover\:border-bambu-green:hover{border-color:var(--color-bambu-green)}.hover\:border-white\/40:hover{border-color:#fff6}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/40:hover{border-color:color-mix(in oklab,var(--color-white)40%,transparent)}}.hover\:bg-bambu-dark:hover{background-color:var(--color-bambu-dark)}.hover\:bg-bambu-dark-secondary:hover{background-color:var(--color-bambu-dark-secondary)}.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-gray-dark:hover{background-color:var(--color-bambu-gray-dark)}.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\/20:hover{background-color:#00ae4233}@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:#00ae424d}@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\/90:hover{background-color:#00ae42e6}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/90:hover{background-color:color-mix(in oklab,var(--color-bambu-green)90%,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-gray-700:hover{background-color:var(--color-gray-700)}.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:hover{background-color:var(--color-red-500)}.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\/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:hover{background-color:var(--color-white)}.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\:text-bambu-green:hover{color:var(--color-bambu-green)}.hover\:text-bambu-green\/80:hover{color:#00ae42cc}@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-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\:underline:hover{text-decoration-line:underline}.hover\:opacity-10:hover{opacity:.1}.hover\:opacity-70:hover{opacity:.7}.hover\:opacity-80:hover{opacity:.8}}.focus\:border-bambu-green:focus{border-color:var(--color-bambu-green)}.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{--tw-ring-color:var(--color-bambu-green)}.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\:outline-none:focus{--tw-outline-style:none;outline-style:none}.active\:cursor-grabbing:active{cursor:grabbing}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-50:disabled{opacity:.5}@media(hover:hover){.disabled\:hover\:bg-bambu-dark-secondary:disabled:hover{background-color:var(--color-bambu-dark-secondary)}.disabled\:hover\:text-bambu-gray:disabled:hover{color:var(--color-bambu-gray)}}@media(min-width:40rem){.sm\:inline{display:inline}.sm\:h-4{height:calc(var(--spacing)*4)}.sm\:w-4{width:calc(var(--spacing)*4)}.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\:p-1\.5{padding:calc(var(--spacing)*1.5)}}@media(min-width:48rem){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}}@media(min-width:64rem){.lg\:w-80{width:calc(var(--spacing)*80)}.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\:flex-row{flex-direction:row}}@media(min-width:80rem){.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}.\[\&\:\:-moz-range-thumb\]\:h-4::-moz-range-thumb{height:calc(var(--spacing)*4)}.\[\&\:\:-moz-range-thumb\]\:w-4::-moz-range-thumb{width:calc(var(--spacing)*4)}.\[\&\:\:-moz-range-thumb\]\:cursor-pointer::-moz-range-thumb{cursor:pointer}.\[\&\:\:-moz-range-thumb\]\:rounded-full::-moz-range-thumb{border-radius:3.40282e38px}.\[\&\:\:-moz-range-thumb\]\:border-0::-moz-range-thumb{border-style:var(--tw-border-style);border-width:0}.\[\&\:\:-moz-range-thumb\]\:bg-bambu-green::-moz-range-thumb{background-color:var(--color-bambu-green)}.\[\&\:\:-webkit-slider-thumb\]\:h-3::-webkit-slider-thumb{height:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:h-4::-webkit-slider-thumb{height:calc(var(--spacing)*4)}.\[\&\:\:-webkit-slider-thumb\]\:w-3::-webkit-slider-thumb{width:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:w-4::-webkit-slider-thumb{width:calc(var(--spacing)*4)}.\[\&\:\:-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{--bg-primary:#f5f5f5;--bg-secondary:#fff;--bg-tertiary:#e5e5e5;--text-primary:#1a1a1a;--text-secondary:#4a4a4a;--text-muted:#6b6b6b;--text-tertiary:gray;--border-color:#d4d4d4;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}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}.dark .jogpad-theme{filter:brightness(.7)contrast(1.1)}@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-font-weight{syntax:"*";inherits:false}@property --tw-tracking{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-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 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-font-weight:initial;--tw-tracking: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-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 372d79452..0afbee2a0 100644
--- a/static/index.html
+++ b/static/index.html
@@ -7,8 +7,8 @@
-
-
+
+