@camstack/addon-admin-ui 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-CKfGBI-Z.js → __mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-CeLhKMin.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-CykPKLuU.js → __mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-DXPQtD9p.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-xMlwAAY4.js → __mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-OcRSBqRe.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-Clpxla3F.js → __mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-GvBGLFI2.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-B_akQFxJ.js → __mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-Dl4u0xYE.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-BZBxNMgx.js → __mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-CSyOECfO.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-CCRqQaXq.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-CzO_Esxm.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-B5D3mvYP.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-xw6c6JeS.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-CRHuTm5p.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-DNpf5SLz.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs_commonjs-proxy-XIS4Ck9-.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs_commonjs-proxy-BEKtiDI3.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D4TBsvIB.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CziSE-Do.js} +1 -1
- package/dist/assets/auth-records-BEfan3dC.js +1 -0
- package/dist/assets/capability-router-map-B3jHfbHt.js +1 -0
- package/dist/assets/devices-BfsgGvwu.js +1 -0
- package/dist/assets/{hostInit-DpSCsYyA.js → hostInit-7yPTCcmg.js} +1 -1
- package/dist/assets/index-BlKJSHE9.js +80 -0
- package/dist/assets/index-ByDDdVKJ.css +1 -0
- package/dist/assets/index-C-M4yvxf.js +1 -0
- package/dist/assets/index-DculG9Gi.js +1098 -0
- package/dist/assets/index-DfH297U6.js +1 -0
- package/dist/assets/index-Dvmk3HcY.js +1 -0
- package/dist/assets/index-K1-f6oQr.js +1 -0
- package/dist/assets/index-X-IEwb-L.js +80 -0
- package/dist/assets/index-cfq-Npln.js +1 -0
- package/dist/assets/index-iCcWZGKs.js +1 -0
- package/dist/assets/index-ptcmLXsE.js +1 -0
- package/dist/assets/{remoteEntry-0zDoMSWf.js → remoteEntry-Da_G1gka.js} +1 -1
- package/dist/assets/{schemas-BOzikgNT.js → schemas-XgIEoUz3.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BnGk9xo_.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-kSAHDLPS.js} +2 -2
- package/dist/index.html +7 -8
- package/dist/mf-entry-bootstrap-0.js +2 -2
- package/dist/server/addon.js +11 -25
- package/dist/server/addon.js.map +1 -1
- package/dist/sw.js +1 -1
- package/package.json +4 -3
- package/dist/assets/capability-router-map-Bqwnkkax.js +0 -1
- package/dist/assets/devices-CFL4MLSo.js +0 -511
- package/dist/assets/index-BP0PcGIN.js +0 -1
- package/dist/assets/index-BQVATbZy.js +0 -5
- package/dist/assets/index-BZhZ3Jvf.js +0 -1
- package/dist/assets/index-BfdtdylV.js +0 -533
- package/dist/assets/index-BkJ1uzOh.js +0 -8420
- package/dist/assets/index-BuajxCgS.js +0 -1
- package/dist/assets/index-CKMQgnc3.js +0 -1
- package/dist/assets/index-DAq7g5_U.js +0 -1
- package/dist/assets/index-DRebE_bu.js +0 -22
- package/dist/assets/index-DUjRaULz.js +0 -1
- package/dist/assets/index-OcuNiGT5.js +0 -34
- package/dist/assets/index-R6tzT59K.css +0 -1
- package/dist/assets/index-pmj5N6Ix.js +0 -5
- package/dist/server/addon.d.ts +0 -12
|
@@ -0,0 +1,1098 @@
|
|
|
1
|
+
import"./virtualExposes-_ivNhQLP.js";import{d as fr}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-kSAHDLPS.js";import{c as r,a as $f,d as u,e as ve,g as q1}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-C_6K4VBY.js";import{b as Oe,e as $,h as q,c as Y,f as Q,d as ye,a as _f,j as Ve,k as Me,i as ne,l as mr,m as Gs,g as Ws,R as Al,n as Pl,o as Q1,p as U1,q as hr,r as Fe,s as K1,t as G1,u as W1,v as Y1}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-Dl4u0xYE.js";import{a as Df,b as vo}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-CzO_Esxm.js";import{a as Lf,b as Tf}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-DNpf5SLz.js";import{_ as Rf,m as Kn,n as ke,o as Of,p as zf,h as El,j as Z1}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-CeLhKMin.js";import{_ as Bf,c as Ff,s as jf,n as X1,B as J1,F as ew}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.mjs-DIkg6-MH.js";import{_ as Hf,a as tw}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-OcRSBqRe.js";import{c as nw,D as Rn,a as at,M as rw,W as $i,S as us}from"./auth-records-BEfan3dC.js";import{S as _i,c as Vf}from"./devices-BfsgGvwu.js";import{E as Ne,A as ow,C as sw}from"./capability-router-map-B3jHfbHt.js";import{s as aw}from"./index-Dvmk3HcY.js";import{a as Pd,S as Ed,s as iw}from"./index-DfH297U6.js";import{r as qf}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-CSyOECfO.js";import"./preload-helper-BlTxHScW.js";import"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-xw6c6JeS.js";import"./schemas-XgIEoUz3.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function o(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();const Qf={frigate:"#3b82f6",scrypted:"#a855f7",reolink:"#06b6d4",homeAssistant:"#22d3ee",rtsp:"#78716c"},Uf={primary:"#f59e42",primaryForeground:"#0c0a09",background:"#0c0a09",backgroundElevated:"#1c1917",surface:"#1c1917",surfaceHover:"#292524",border:"#292524",borderSubtle:"#1c1917",foreground:"#fafaf9",foregroundMuted:"#a8a29e",foregroundSubtle:"#78716c",foregroundDisabled:"#57534e",success:"#4ade80",warning:"#fbbf24",danger:"#f87171",info:"#60a5fa",provider:Qf},Kf={primary:"#e67e22",primaryForeground:"#ffffff",background:"#fafaf9",backgroundElevated:"#ffffff",surface:"#f5f5f4",surfaceHover:"#e7e5e4",border:"#d6d3d1",borderSubtle:"#e7e5e4",foreground:"#1c1917",foregroundMuted:"#57534e",foregroundSubtle:"#78716c",foregroundDisabled:"#a8a29e",success:"#16a34a",warning:"#d97706",danger:"#dc2626",info:"#2563eb",provider:Qf},Di={colors:{dark:Uf,light:Kf},spacing:{xs:2,sm:4,md:8,lg:12,xl:16,"2xl":24,"3xl":32},radius:{sm:4,md:6,lg:8,xl:12},typography:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',sizes:{xs:{fontSize:10,lineHeight:14},sm:{fontSize:11,lineHeight:16},base:{fontSize:12,lineHeight:18},lg:{fontSize:13,lineHeight:18},xl:{fontSize:14,lineHeight:20},"2xl":{fontSize:16,lineHeight:22},"3xl":{fontSize:20,lineHeight:28}},weights:{regular:400,medium:500,semibold:600,bold:700}},table:{rowHeight:28,headerHeight:24,cellPaddingX:8,cellPaddingY:6},sidebar:{width:176,itemHeight:28,iconSize:14}};function Gf(e,t){const n={...e};for(const o in t){const s=t[o],a=e[o];s!==void 0&&typeof s=="object"&&s!==null&&!Array.isArray(s)&&typeof a=="object"&&a!==null?n[o]=Gf(a,s):s!==void 0&&(n[o]=s)}return n}function lw(e){return e?Gf(structuredClone(Di),e):structuredClone(Di)}function Wf(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function cw(e){return`--color-${Wf(e)}`}function $d(e){const t=[];for(const[n,o]of Object.entries(e))n!=="provider"&&t.push(` ${cw(n)}: ${o};`);return t.join(`
|
|
2
|
+
`)}function dw(e){const t=[];for(const[n,o]of Object.entries(e))t.push(` --color-provider-${Wf(n)}: ${o};`);return t.join(`
|
|
3
|
+
`)}function uw(e){const t=[];for(const[n,o]of Object.entries(e))t.push(` --spacing-${n}: ${o}px;`);return t.join(`
|
|
4
|
+
`)}function pw(e){const t=[];for(const[n,o]of Object.entries(e))t.push(` --radius-${n}: ${o}px;`);return t.join(`
|
|
5
|
+
`)}function fw(e){const t=$d(e.colors.dark),n=$d(e.colors.light),o=dw(e.colors.dark.provider),s=uw(e.spacing),a=pw(e.radius);return`@theme {
|
|
6
|
+
${o}
|
|
7
|
+
${s}
|
|
8
|
+
${a}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.dark {
|
|
12
|
+
${t}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.light {
|
|
16
|
+
${n}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@media (prefers-color-scheme: dark) {
|
|
20
|
+
:root {
|
|
21
|
+
${t.replace(/^ {2}/gm," ")}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@media (prefers-color-scheme: light) {
|
|
26
|
+
:root {
|
|
27
|
+
${n.replace(/^ {2}/gm," ")}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`}const Yf=Oe(null),za=["dark","light","system"];function Zf(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function mw(e,t){if(typeof window>"u")return t;const n=localStorage.getItem(e);return n==="dark"||n==="light"||n==="system"?n:t}function _d(e){return e==="system"?Zf():e}function ws({children:e,defaultMode:t="system",storageKey:n="camstack-theme-mode"}){const[o,s]=$(()=>mw(n,t)),[a,i]=$(()=>_d(o)),l=q(f=>{s(f),i(_d(f)),typeof window<"u"&&localStorage.setItem(n,f)},[n]),c=q(()=>{const p=(za.indexOf(o)+1)%za.length;l(za[p]??"dark")},[o,l]);Y(()=>{if(typeof document>"u")return;const f=document.documentElement;f.classList.remove("dark","light"),f.classList.add(a)},[o,a]),Y(()=>{if(typeof window>"u"||o!=="system")return;const f=window.matchMedia("(prefers-color-scheme: dark)"),p=()=>{i(Zf())};return f.addEventListener("change",p),()=>f.removeEventListener("change",p)},[o]);const d=Q(()=>({mode:o,resolvedMode:a,setMode:l,toggleMode:c}),[o,a,l,c]);return r(Yf.Provider,{value:d,children:e})}function Ir(){const e=ye(Yf);if(!e)throw new Error("useThemeMode must be used within a ThemeProvider");return e}function Xf(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=Xf(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Jf(){for(var e,t,n=0,o="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=Xf(e))&&(o&&(o+=" "),o+=t);return o}const hw=(e,t)=>{const n=new Array(e.length+t.length);for(let o=0;o<e.length;o++)n[o]=e[o];for(let o=0;o<t.length;o++)n[e.length+o]=t[o];return n},gw=(e,t)=>({classGroupId:e,validator:t}),em=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Ns="-",Dd=[],bw="arbitrary..",xw=e=>{const t=vw(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return yw(i);const l=i.split(Ns),c=l[0]===""&&l.length>1?1:0;return tm(l,c,t)},getConflictingClassGroupIds:(i,l)=>{if(l){const c=o[i],d=n[i];return c?d?hw(d,c):c:d||Dd}return n[i]||Dd}}},tm=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const s=e[t],a=n.nextPart.get(s);if(a){const d=tm(e,t+1,a);if(d)return d}const i=n.validators;if(i===null)return;const l=t===0?e.join(Ns):e.slice(t).join(Ns),c=i.length;for(let d=0;d<c;d++){const f=i[d];if(f.validator(l))return f.classGroupId}},yw=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),o=t.slice(0,n);return o?bw+o:void 0})(),vw=e=>{const{theme:t,classGroups:n}=e;return ww(n,t)},ww=(e,t)=>{const n=em();for(const o in e){const s=e[o];$l(s,n,o,t)}return n},$l=(e,t,n,o)=>{const s=e.length;for(let a=0;a<s;a++){const i=e[a];Nw(i,t,n,o)}},Nw=(e,t,n,o)=>{if(typeof e=="string"){kw(e,t,n);return}if(typeof e=="function"){Sw(e,t,n,o);return}Cw(e,t,n,o)},kw=(e,t,n)=>{const o=e===""?t:nm(t,e);o.classGroupId=n},Sw=(e,t,n,o)=>{if(Mw(e)){$l(e(o),t,n,o);return}t.validators===null&&(t.validators=[]),t.validators.push(gw(n,e))},Cw=(e,t,n,o)=>{const s=Object.entries(e),a=s.length;for(let i=0;i<a;i++){const[l,c]=s[i];$l(c,nm(t,l),n,o)}},nm=(e,t)=>{let n=e;const o=t.split(Ns),s=o.length;for(let a=0;a<s;a++){const i=o[a];let l=n.nextPart.get(i);l||(l=em(),n.nextPart.set(i,l)),n=l}return n},Mw=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Iw=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),o=Object.create(null);const s=(a,i)=>{n[a]=i,t++,t>e&&(t=0,o=n,n=Object.create(null))};return{get(a){let i=n[a];if(i!==void 0)return i;if((i=o[a])!==void 0)return s(a,i),i},set(a,i){a in n?n[a]=i:s(a,i)}}},Li="!",Ld=":",Aw=[],Td=(e,t,n,o,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:o,isExternal:s}),Pw=e=>{const{prefix:t,experimentalParseClassName:n}=e;let o=s=>{const a=[];let i=0,l=0,c=0,d;const f=s.length;for(let b=0;b<f;b++){const x=s[b];if(i===0&&l===0){if(x===Ld){a.push(s.slice(c,b)),c=b+1;continue}if(x==="/"){d=b;continue}}x==="["?i++:x==="]"?i--:x==="("?l++:x===")"&&l--}const p=a.length===0?s:s.slice(c);let m=p,h=!1;p.endsWith(Li)?(m=p.slice(0,-1),h=!0):p.startsWith(Li)&&(m=p.slice(1),h=!0);const g=d&&d>c?d-c:void 0;return Td(a,h,m,g)};if(t){const s=t+Ld,a=o;o=i=>i.startsWith(s)?a(i.slice(s.length)):Td(Aw,!1,i,void 0,!0)}if(n){const s=o;o=a=>n({className:a,parseClassName:s})}return o},Ew=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,o)=>{t.set(n,1e6+o)}),n=>{const o=[];let s=[];for(let a=0;a<n.length;a++){const i=n[a],l=i[0]==="[",c=t.has(i);l||c?(s.length>0&&(s.sort(),o.push(...s),s=[]),o.push(i)):s.push(i)}return s.length>0&&(s.sort(),o.push(...s)),o}},$w=e=>({cache:Iw(e.cacheSize),parseClassName:Pw(e),sortModifiers:Ew(e),...xw(e)}),_w=/\s+/,Dw=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:s,sortModifiers:a}=t,i=[],l=e.trim().split(_w);let c="";for(let d=l.length-1;d>=0;d-=1){const f=l[d],{isExternal:p,modifiers:m,hasImportantModifier:h,baseClassName:g,maybePostfixModifierPosition:b}=n(f);if(p){c=f+(c.length>0?" "+c:c);continue}let x=!!b,v=o(x?g.substring(0,b):g);if(!v){if(!x){c=f+(c.length>0?" "+c:c);continue}if(v=o(g),!v){c=f+(c.length>0?" "+c:c);continue}x=!1}const w=m.length===0?"":m.length===1?m[0]:a(m).join(":"),y=h?w+Li:w,N=y+v;if(i.indexOf(N)>-1)continue;i.push(N);const k=s(v,x);for(let S=0;S<k.length;++S){const M=k[S];i.push(y+M)}c=f+(c.length>0?" "+c:c)}return c},Lw=(...e)=>{let t=0,n,o,s="";for(;t<e.length;)(n=e[t++])&&(o=rm(n))&&(s&&(s+=" "),s+=o);return s},rm=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=rm(e[o]))&&(n&&(n+=" "),n+=t);return n},Tw=(e,...t)=>{let n,o,s,a;const i=c=>{const d=t.reduce((f,p)=>p(f),e());return n=$w(d),o=n.cache.get,s=n.cache.set,a=l,l(c)},l=c=>{const d=o(c);if(d)return d;const f=Dw(c,n);return s(c,f),f};return a=i,(...c)=>a(Lw(...c))},Rw=[],Ke=e=>{const t=n=>n[e]||Rw;return t.isThemeGetter=!0,t},om=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,sm=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ow=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,zw=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Bw=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Fw=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,jw=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Hw=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,mn=e=>Ow.test(e),Ae=e=>!!e&&!Number.isNaN(Number(e)),hn=e=>!!e&&Number.isInteger(Number(e)),Ba=e=>e.endsWith("%")&&Ae(e.slice(0,-1)),Zt=e=>zw.test(e),am=()=>!0,Vw=e=>Bw.test(e)&&!Fw.test(e),_l=()=>!1,qw=e=>jw.test(e),Qw=e=>Hw.test(e),Uw=e=>!be(e)&&!xe(e),Kw=e=>Sn(e,cm,_l),be=e=>om.test(e),En=e=>Sn(e,dm,Vw),Rd=e=>Sn(e,tN,Ae),Gw=e=>Sn(e,pm,am),Ww=e=>Sn(e,um,_l),Od=e=>Sn(e,im,_l),Yw=e=>Sn(e,lm,Qw),Ro=e=>Sn(e,fm,qw),xe=e=>sm.test(e),zr=e=>Gn(e,dm),Zw=e=>Gn(e,um),zd=e=>Gn(e,im),Xw=e=>Gn(e,cm),Jw=e=>Gn(e,lm),Oo=e=>Gn(e,fm,!0),eN=e=>Gn(e,pm,!0),Sn=(e,t,n)=>{const o=om.exec(e);return o?o[1]?t(o[1]):n(o[2]):!1},Gn=(e,t,n=!1)=>{const o=sm.exec(e);return o?o[1]?t(o[1]):n:!1},im=e=>e==="position"||e==="percentage",lm=e=>e==="image"||e==="url",cm=e=>e==="length"||e==="size"||e==="bg-size",dm=e=>e==="length",tN=e=>e==="number",um=e=>e==="family-name",pm=e=>e==="number"||e==="weight",fm=e=>e==="shadow",nN=()=>{const e=Ke("color"),t=Ke("font"),n=Ke("text"),o=Ke("font-weight"),s=Ke("tracking"),a=Ke("leading"),i=Ke("breakpoint"),l=Ke("container"),c=Ke("spacing"),d=Ke("radius"),f=Ke("shadow"),p=Ke("inset-shadow"),m=Ke("text-shadow"),h=Ke("drop-shadow"),g=Ke("blur"),b=Ke("perspective"),x=Ke("aspect"),v=Ke("ease"),w=Ke("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],k=()=>[...N(),xe,be],S=()=>["auto","hidden","clip","visible","scroll"],M=()=>["auto","contain","none"],P=()=>[xe,be,c],I=()=>[mn,"full","auto",...P()],F=()=>[hn,"none","subgrid",xe,be],E=()=>["auto",{span:["full",hn,xe,be]},hn,xe,be],B=()=>[hn,"auto",xe,be],O=()=>["auto","min","max","fr",xe,be],A=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],D=()=>["start","end","center","stretch","center-safe","end-safe"],_=()=>["auto",...P()],R=()=>[mn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...P()],L=()=>[mn,"screen","full","dvw","lvw","svw","min","max","fit",...P()],z=()=>[mn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...P()],j=()=>[e,xe,be],H=()=>[...N(),zd,Od,{position:[xe,be]}],T=()=>["no-repeat",{repeat:["","x","y","space","round"]}],W=()=>["auto","cover","contain",Xw,Kw,{size:[xe,be]}],G=()=>[Ba,zr,En],ee=()=>["","none","full",d,xe,be],se=()=>["",Ae,zr,En],te=()=>["solid","dashed","dotted","double"],X=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],re=()=>[Ae,Ba,zd,Od],ge=()=>["","none",g,xe,be],Z=()=>["none",Ae,xe,be],U=()=>["none",Ae,xe,be],J=()=>[Ae,xe,be],ae=()=>[mn,"full",...P()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Zt],breakpoint:[Zt],color:[am],container:[Zt],"drop-shadow":[Zt],ease:["in","out","in-out"],font:[Uw],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Zt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Zt],shadow:[Zt],spacing:["px",Ae],text:[Zt],"text-shadow":[Zt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",mn,be,xe,x]}],container:["container"],columns:[{columns:[Ae,be,xe,l]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:k()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{"inset-s":I(),start:I()}],end:[{"inset-e":I(),end:I()}],"inset-bs":[{"inset-bs":I()}],"inset-be":[{"inset-be":I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[hn,"auto",xe,be]}],basis:[{basis:[mn,"full","auto",l,...P()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ae,mn,"auto","initial","none",be]}],grow:[{grow:["",Ae,xe,be]}],shrink:[{shrink:["",Ae,xe,be]}],order:[{order:[hn,"first","last","none",xe,be]}],"grid-cols":[{"grid-cols":F()}],"col-start-end":[{col:E()}],"col-start":[{"col-start":B()}],"col-end":[{"col-end":B()}],"grid-rows":[{"grid-rows":F()}],"row-start-end":[{row:E()}],"row-start":[{"row-start":B()}],"row-end":[{"row-end":B()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":O()}],"auto-rows":[{"auto-rows":O()}],gap:[{gap:P()}],"gap-x":[{"gap-x":P()}],"gap-y":[{"gap-y":P()}],"justify-content":[{justify:[...A(),"normal"]}],"justify-items":[{"justify-items":[...D(),"normal"]}],"justify-self":[{"justify-self":["auto",...D()]}],"align-content":[{content:["normal",...A()]}],"align-items":[{items:[...D(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...D(),{baseline:["","last"]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...D(),"baseline"]}],"place-self":[{"place-self":["auto",...D()]}],p:[{p:P()}],px:[{px:P()}],py:[{py:P()}],ps:[{ps:P()}],pe:[{pe:P()}],pbs:[{pbs:P()}],pbe:[{pbe:P()}],pt:[{pt:P()}],pr:[{pr:P()}],pb:[{pb:P()}],pl:[{pl:P()}],m:[{m:_()}],mx:[{mx:_()}],my:[{my:_()}],ms:[{ms:_()}],me:[{me:_()}],mbs:[{mbs:_()}],mbe:[{mbe:_()}],mt:[{mt:_()}],mr:[{mr:_()}],mb:[{mb:_()}],ml:[{ml:_()}],"space-x":[{"space-x":P()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":P()}],"space-y-reverse":["space-y-reverse"],size:[{size:R()}],"inline-size":[{inline:["auto",...L()]}],"min-inline-size":[{"min-inline":["auto",...L()]}],"max-inline-size":[{"max-inline":["none",...L()]}],"block-size":[{block:["auto",...z()]}],"min-block-size":[{"min-block":["auto",...z()]}],"max-block-size":[{"max-block":["none",...z()]}],w:[{w:[l,"screen",...R()]}],"min-w":[{"min-w":[l,"screen","none",...R()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...R()]}],h:[{h:["screen","lh",...R()]}],"min-h":[{"min-h":["screen","lh","none",...R()]}],"max-h":[{"max-h":["screen","lh",...R()]}],"font-size":[{text:["base",n,zr,En]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,eN,Gw]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ba,be]}],"font-family":[{font:[Zw,Ww,t]}],"font-features":[{"font-features":[be]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,xe,be]}],"line-clamp":[{"line-clamp":[Ae,"none",xe,Rd]}],leading:[{leading:[a,...P()]}],"list-image":[{"list-image":["none",xe,be]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",xe,be]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:j()}],"text-color":[{text:j()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...te(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ae,"from-font","auto",xe,En]}],"text-decoration-color":[{decoration:j()}],"underline-offset":[{"underline-offset":[Ae,"auto",xe,be]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",xe,be]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",xe,be]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:H()}],"bg-repeat":[{bg:T()}],"bg-size":[{bg:W()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},hn,xe,be],radial:["",xe,be],conic:[hn,xe,be]},Jw,Yw]}],"bg-color":[{bg:j()}],"gradient-from-pos":[{from:G()}],"gradient-via-pos":[{via:G()}],"gradient-to-pos":[{to:G()}],"gradient-from":[{from:j()}],"gradient-via":[{via:j()}],"gradient-to":[{to:j()}],rounded:[{rounded:ee()}],"rounded-s":[{"rounded-s":ee()}],"rounded-e":[{"rounded-e":ee()}],"rounded-t":[{"rounded-t":ee()}],"rounded-r":[{"rounded-r":ee()}],"rounded-b":[{"rounded-b":ee()}],"rounded-l":[{"rounded-l":ee()}],"rounded-ss":[{"rounded-ss":ee()}],"rounded-se":[{"rounded-se":ee()}],"rounded-ee":[{"rounded-ee":ee()}],"rounded-es":[{"rounded-es":ee()}],"rounded-tl":[{"rounded-tl":ee()}],"rounded-tr":[{"rounded-tr":ee()}],"rounded-br":[{"rounded-br":ee()}],"rounded-bl":[{"rounded-bl":ee()}],"border-w":[{border:se()}],"border-w-x":[{"border-x":se()}],"border-w-y":[{"border-y":se()}],"border-w-s":[{"border-s":se()}],"border-w-e":[{"border-e":se()}],"border-w-bs":[{"border-bs":se()}],"border-w-be":[{"border-be":se()}],"border-w-t":[{"border-t":se()}],"border-w-r":[{"border-r":se()}],"border-w-b":[{"border-b":se()}],"border-w-l":[{"border-l":se()}],"divide-x":[{"divide-x":se()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":se()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...te(),"hidden","none"]}],"divide-style":[{divide:[...te(),"hidden","none"]}],"border-color":[{border:j()}],"border-color-x":[{"border-x":j()}],"border-color-y":[{"border-y":j()}],"border-color-s":[{"border-s":j()}],"border-color-e":[{"border-e":j()}],"border-color-bs":[{"border-bs":j()}],"border-color-be":[{"border-be":j()}],"border-color-t":[{"border-t":j()}],"border-color-r":[{"border-r":j()}],"border-color-b":[{"border-b":j()}],"border-color-l":[{"border-l":j()}],"divide-color":[{divide:j()}],"outline-style":[{outline:[...te(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ae,xe,be]}],"outline-w":[{outline:["",Ae,zr,En]}],"outline-color":[{outline:j()}],shadow:[{shadow:["","none",f,Oo,Ro]}],"shadow-color":[{shadow:j()}],"inset-shadow":[{"inset-shadow":["none",p,Oo,Ro]}],"inset-shadow-color":[{"inset-shadow":j()}],"ring-w":[{ring:se()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:j()}],"ring-offset-w":[{"ring-offset":[Ae,En]}],"ring-offset-color":[{"ring-offset":j()}],"inset-ring-w":[{"inset-ring":se()}],"inset-ring-color":[{"inset-ring":j()}],"text-shadow":[{"text-shadow":["none",m,Oo,Ro]}],"text-shadow-color":[{"text-shadow":j()}],opacity:[{opacity:[Ae,xe,be]}],"mix-blend":[{"mix-blend":[...X(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":X()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ae]}],"mask-image-linear-from-pos":[{"mask-linear-from":re()}],"mask-image-linear-to-pos":[{"mask-linear-to":re()}],"mask-image-linear-from-color":[{"mask-linear-from":j()}],"mask-image-linear-to-color":[{"mask-linear-to":j()}],"mask-image-t-from-pos":[{"mask-t-from":re()}],"mask-image-t-to-pos":[{"mask-t-to":re()}],"mask-image-t-from-color":[{"mask-t-from":j()}],"mask-image-t-to-color":[{"mask-t-to":j()}],"mask-image-r-from-pos":[{"mask-r-from":re()}],"mask-image-r-to-pos":[{"mask-r-to":re()}],"mask-image-r-from-color":[{"mask-r-from":j()}],"mask-image-r-to-color":[{"mask-r-to":j()}],"mask-image-b-from-pos":[{"mask-b-from":re()}],"mask-image-b-to-pos":[{"mask-b-to":re()}],"mask-image-b-from-color":[{"mask-b-from":j()}],"mask-image-b-to-color":[{"mask-b-to":j()}],"mask-image-l-from-pos":[{"mask-l-from":re()}],"mask-image-l-to-pos":[{"mask-l-to":re()}],"mask-image-l-from-color":[{"mask-l-from":j()}],"mask-image-l-to-color":[{"mask-l-to":j()}],"mask-image-x-from-pos":[{"mask-x-from":re()}],"mask-image-x-to-pos":[{"mask-x-to":re()}],"mask-image-x-from-color":[{"mask-x-from":j()}],"mask-image-x-to-color":[{"mask-x-to":j()}],"mask-image-y-from-pos":[{"mask-y-from":re()}],"mask-image-y-to-pos":[{"mask-y-to":re()}],"mask-image-y-from-color":[{"mask-y-from":j()}],"mask-image-y-to-color":[{"mask-y-to":j()}],"mask-image-radial":[{"mask-radial":[xe,be]}],"mask-image-radial-from-pos":[{"mask-radial-from":re()}],"mask-image-radial-to-pos":[{"mask-radial-to":re()}],"mask-image-radial-from-color":[{"mask-radial-from":j()}],"mask-image-radial-to-color":[{"mask-radial-to":j()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":N()}],"mask-image-conic-pos":[{"mask-conic":[Ae]}],"mask-image-conic-from-pos":[{"mask-conic-from":re()}],"mask-image-conic-to-pos":[{"mask-conic-to":re()}],"mask-image-conic-from-color":[{"mask-conic-from":j()}],"mask-image-conic-to-color":[{"mask-conic-to":j()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:T()}],"mask-size":[{mask:W()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",xe,be]}],filter:[{filter:["","none",xe,be]}],blur:[{blur:ge()}],brightness:[{brightness:[Ae,xe,be]}],contrast:[{contrast:[Ae,xe,be]}],"drop-shadow":[{"drop-shadow":["","none",h,Oo,Ro]}],"drop-shadow-color":[{"drop-shadow":j()}],grayscale:[{grayscale:["",Ae,xe,be]}],"hue-rotate":[{"hue-rotate":[Ae,xe,be]}],invert:[{invert:["",Ae,xe,be]}],saturate:[{saturate:[Ae,xe,be]}],sepia:[{sepia:["",Ae,xe,be]}],"backdrop-filter":[{"backdrop-filter":["","none",xe,be]}],"backdrop-blur":[{"backdrop-blur":ge()}],"backdrop-brightness":[{"backdrop-brightness":[Ae,xe,be]}],"backdrop-contrast":[{"backdrop-contrast":[Ae,xe,be]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ae,xe,be]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ae,xe,be]}],"backdrop-invert":[{"backdrop-invert":["",Ae,xe,be]}],"backdrop-opacity":[{"backdrop-opacity":[Ae,xe,be]}],"backdrop-saturate":[{"backdrop-saturate":[Ae,xe,be]}],"backdrop-sepia":[{"backdrop-sepia":["",Ae,xe,be]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":P()}],"border-spacing-x":[{"border-spacing-x":P()}],"border-spacing-y":[{"border-spacing-y":P()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",xe,be]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ae,"initial",xe,be]}],ease:[{ease:["linear","initial",v,xe,be]}],delay:[{delay:[Ae,xe,be]}],animate:[{animate:["none",w,xe,be]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,xe,be]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:Z()}],"rotate-x":[{"rotate-x":Z()}],"rotate-y":[{"rotate-y":Z()}],"rotate-z":[{"rotate-z":Z()}],scale:[{scale:U()}],"scale-x":[{"scale-x":U()}],"scale-y":[{"scale-y":U()}],"scale-z":[{"scale-z":U()}],"scale-3d":["scale-3d"],skew:[{skew:J()}],"skew-x":[{"skew-x":J()}],"skew-y":[{"skew-y":J()}],transform:[{transform:[xe,be,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ae()}],"translate-x":[{"translate-x":ae()}],"translate-y":[{"translate-y":ae()}],"translate-z":[{"translate-z":ae()}],"translate-none":["translate-none"],accent:[{accent:j()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:j()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",xe,be]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mbs":[{"scroll-mbs":P()}],"scroll-mbe":[{"scroll-mbe":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pbs":[{"scroll-pbs":P()}],"scroll-pbe":[{"scroll-pbe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",xe,be]}],fill:[{fill:["none",...j()]}],"stroke-w":[{stroke:[Ae,zr,En,Rd]}],stroke:[{stroke:["none",...j()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},rN=Tw(nN);function K(...e){return rN(Jf(e))}const oN="rounded-lg border border-border bg-surface overflow-hidden",sN="border-b border-border px-3 sm:px-4 py-1.5 sm:py-2",aN="p-2 sm:p-3 lg:p-4",mm="space-y-3 sm:space-y-4",hm="gap-2 sm:gap-3",gm="px-3 sm:px-4 py-1.5 sm:py-2",iN="grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4",lN="grid grid-cols-1 lg:grid-cols-2",cN="flex flex-col-reverse md:flex-row",dN="w-full md:w-44 lg:w-52 md:flex-shrink-0 border-b md:border-b-0 md:border-l border-border",uN="text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider",pN="text-[11px] sm:text-xs text-foreground",ks="text-[10px] text-foreground-subtle",fN="text-[11px] sm:text-xs font-medium text-foreground",Ti="text-base sm:text-lg font-semibold leading-tight text-foreground",mN="inline-flex items-center justify-center gap-1 rounded border border-border bg-surface px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40",hN="inline-flex items-center justify-center gap-1 rounded border border-primary/40 bg-primary/15 px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-primary hover:bg-primary/25 transition-colors disabled:opacity-40",gN="inline-flex items-center justify-center gap-1 rounded border border-danger/40 bg-danger/10 px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-danger hover:bg-danger/20 transition-colors disabled:opacity-40",bN="inline-flex items-center justify-center gap-1 rounded border border-warning/40 bg-warning/10 px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-warning hover:bg-warning/20 transition-colors disabled:opacity-40",xN="w-full rounded border border-border bg-background px-1.5 py-0.5 sm:px-2 sm:py-1 text-[11px] sm:text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none",yN="inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors",vN="border-primary/50 bg-primary/15 text-primary",wN="border-border bg-surface text-foreground-subtle hover:bg-surface-hover";function NN(e,t){for(const n of e.slots)for(const o of n.addons)if(o.id===t)return o;return null}function kN(e,t){return e.models.find(n=>n.id===t)??null}function SN(e,t){return e.models.find(n=>!!n.formats[t])??null}function CN(e,t){const n=new Set((t.configSchema??[]).map(s=>s.key)),o={};for(const[s,a]of Object.entries(e))n.has(s)&&(o[s]=a);return o}function bm(e){const{source:t,target:n,catalog:o,addonIds:s}=e,a=[];for(const i of s){const l=t.defaults[i];if(!l){a.push({addonId:i,outcome:"skip",modelId:null,reason:"no source entry",patch:null});continue}const c=NN(o,i);if(!c){a.push({addonId:i,outcome:"skip",modelId:null,reason:"addon not in target catalog",patch:null});continue}const d=kN(c,l.modelId),f=d!==null&&!!d.formats[n.engine.format];let p,m;if(f)p=l.modelId,m="exact";else{const g=SN(c,n.engine.format);if(!g){a.push({addonId:i,outcome:"skip",modelId:null,reason:"no compatible model for target format",patch:null});continue}p=g.id,m="mapped"}const h={enabled:l.enabled,modelId:p,settings:CN(l.settings,c)};a.push({addonId:i,outcome:m,modelId:p,patch:h})}return a}const Ri={idle:{label:"Idle",textColor:"text-foreground-subtle",badgeClass:"border-border bg-surface-hover text-foreground-subtle",dotClass:"bg-gray-400",icon:"PowerOff"},active:{label:"Active",textColor:"text-success",badgeClass:"border-success/40 bg-success/10 text-success",dotClass:"bg-red-500 animate-pulse",icon:"Activity"},watching:{label:"Watching",textColor:"text-foreground-subtle",badgeClass:"border-border bg-surface-hover text-foreground-subtle",dotClass:"bg-emerald-500",icon:"Eye"},"load-shed":{label:"Load-Shed",textColor:"text-amber-500",badgeClass:"border-amber-500/40 bg-amber-500/10 text-amber-500",dotClass:"bg-amber-500",icon:"AlertTriangle"},paused:{label:"Paused",textColor:"text-gray-400",badgeClass:"border-gray-500/40 bg-gray-500/10 text-gray-400",dotClass:"bg-gray-400",icon:"PauseCircle"}};function Wn(e){return Ri[e]??Ri.watching}function un(e,t){if(typeof globalThis>"u")return Oe(t);const n=globalThis.__camstackSharedContexts,o=n??new Map;n||(globalThis.__camstackSharedContexts=o);const s=o.get(e);if(s)return s;const a=Oe(t);return o.set(e,a),a}function lr(e){const n=(typeof globalThis<"u"?globalThis:void 0)?.[e];return n&&typeof n=="object"?n:{}}const MN={singleton:!0,requiredVersion:!1,eager:!0},Ft=e=>({version:"0.0.0",scope:"default",lib:e,shareConfig:MN}),Bd="__mf_module_cache__";function IN(){const e=globalThis,t=e[Bd];if(t&&typeof t=="object"){const o=t;return o.share??={},o.remote??={},o}const n={share:{},remote:{}};return e[Bd]=n,n}function AN(){const e=IN();e.share.react??=_f,e.share["react-dom"]??=Df,e.share["react-dom/client"]??=Lf,e.share["react/jsx-runtime"]??=$f,e.share["@tanstack/react-query"]??=Rf,e.share["@trpc/client"]??=Bf,e.share["@trpc/react-query"]??=Hf,e.share["@camstack/ui-library"]??=lr("__camstackUiLibrary"),e.share["@camstack/sdk"]??=lr("__camstackSdk"),e.share["@camstack/types"]??=lr("__camstackTypes")}function Dl(){AN(),fr.getInstance()===null&&fr.init({name:"admin_ui_host",remotes:[],shared:{react:Ft(()=>_f),"react-dom":Ft(()=>Df),"react-dom/client":Ft(()=>Lf),"react/jsx-runtime":Ft(()=>$f),"@tanstack/react-query":Ft(()=>Rf),"@trpc/client":Ft(()=>Bf),"@trpc/react-query":Ft(()=>Hf),"@camstack/ui-library":Ft(()=>lr("__camstackUiLibrary")),"@camstack/sdk":Ft(()=>lr("__camstackSdk")),"@camstack/types":Ft(()=>lr("__camstackTypes"))}})}/**
|
|
31
|
+
* @license lucide-react v0.576.0 - ISC
|
|
32
|
+
*
|
|
33
|
+
* This source code is licensed under the ISC license.
|
|
34
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
35
|
+
*/const xm=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim();/**
|
|
36
|
+
* @license lucide-react v0.576.0 - ISC
|
|
37
|
+
*
|
|
38
|
+
* This source code is licensed under the ISC license.
|
|
39
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
40
|
+
*/const PN=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
41
|
+
* @license lucide-react v0.576.0 - ISC
|
|
42
|
+
*
|
|
43
|
+
* This source code is licensed under the ISC license.
|
|
44
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
45
|
+
*/const EN=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase());/**
|
|
46
|
+
* @license lucide-react v0.576.0 - ISC
|
|
47
|
+
*
|
|
48
|
+
* This source code is licensed under the ISC license.
|
|
49
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
50
|
+
*/const Fd=e=>{const t=EN(e);return t.charAt(0).toUpperCase()+t.slice(1)};/**
|
|
51
|
+
* @license lucide-react v0.576.0 - ISC
|
|
52
|
+
*
|
|
53
|
+
* This source code is licensed under the ISC license.
|
|
54
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
55
|
+
*/var $N={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
56
|
+
* @license lucide-react v0.576.0 - ISC
|
|
57
|
+
*
|
|
58
|
+
* This source code is licensed under the ISC license.
|
|
59
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
60
|
+
*/const _N=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/**
|
|
61
|
+
* @license lucide-react v0.576.0 - ISC
|
|
62
|
+
*
|
|
63
|
+
* This source code is licensed under the ISC license.
|
|
64
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
65
|
+
*/const DN=Ve(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:s="",children:a,iconNode:i,...l},c)=>Me("svg",{ref:c,...$N,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:xm("lucide",s),...!a&&!_N(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,f])=>Me(d,f)),...Array.isArray(a)?a:[a]]));/**
|
|
66
|
+
* @license lucide-react v0.576.0 - ISC
|
|
67
|
+
*
|
|
68
|
+
* This source code is licensed under the ISC license.
|
|
69
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
70
|
+
*/const ce=(e,t)=>{const n=Ve(({className:o,...s},a)=>Me(DN,{ref:a,iconNode:t,className:xm(`lucide-${PN(Fd(e))}`,`lucide-${e}`,o),...s}));return n.displayName=Fd(e),n};/**
|
|
71
|
+
* @license lucide-react v0.576.0 - ISC
|
|
72
|
+
*
|
|
73
|
+
* This source code is licensed under the ISC license.
|
|
74
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
75
|
+
*/const LN=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],yn=ce("activity",LN);/**
|
|
76
|
+
* @license lucide-react v0.576.0 - ISC
|
|
77
|
+
*
|
|
78
|
+
* This source code is licensed under the ISC license.
|
|
79
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
80
|
+
*/const TN=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],RN=ce("arrow-down",TN);/**
|
|
81
|
+
* @license lucide-react v0.576.0 - ISC
|
|
82
|
+
*
|
|
83
|
+
* This source code is licensed under the ISC license.
|
|
84
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
85
|
+
*/const ON=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],zN=ce("arrow-left",ON);/**
|
|
86
|
+
* @license lucide-react v0.576.0 - ISC
|
|
87
|
+
*
|
|
88
|
+
* This source code is licensed under the ISC license.
|
|
89
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
90
|
+
*/const BN=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],FN=ce("arrow-right",BN);/**
|
|
91
|
+
* @license lucide-react v0.576.0 - ISC
|
|
92
|
+
*
|
|
93
|
+
* This source code is licensed under the ISC license.
|
|
94
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
95
|
+
*/const jN=[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]],Ll=ce("arrow-up-to-line",jN);/**
|
|
96
|
+
* @license lucide-react v0.576.0 - ISC
|
|
97
|
+
*
|
|
98
|
+
* This source code is licensed under the ISC license.
|
|
99
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
100
|
+
*/const HN=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],VN=ce("arrow-up",HN);/**
|
|
101
|
+
* @license lucide-react v0.576.0 - ISC
|
|
102
|
+
*
|
|
103
|
+
* This source code is licensed under the ISC license.
|
|
104
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
105
|
+
*/const qN=[["path",{d:"M10 10v4",key:"1mb2ec"}],["path",{d:"M14 10v4",key:"1nt88p"}],["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 10v4",key:"1n77qd"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],QN=ce("battery-full",qN);/**
|
|
106
|
+
* @license lucide-react v0.576.0 - ISC
|
|
107
|
+
*
|
|
108
|
+
* This source code is licensed under the ISC license.
|
|
109
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
110
|
+
*/const UN=[["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 14v-4",key:"14a6bd"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],KN=ce("battery-low",UN);/**
|
|
111
|
+
* @license lucide-react v0.576.0 - ISC
|
|
112
|
+
*
|
|
113
|
+
* This source code is licensed under the ISC license.
|
|
114
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
115
|
+
*/const GN=[["path",{d:"M10 17h.01",key:"nbq80n"}],["path",{d:"M10 7v6",key:"nne03l"}],["path",{d:"M14 6h2a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2",key:"1m83kb"}],["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 18H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"h8lgfh"}]],WN=ce("battery-warning",GN);/**
|
|
116
|
+
* @license lucide-react v0.576.0 - ISC
|
|
117
|
+
*
|
|
118
|
+
* This source code is licensed under the ISC license.
|
|
119
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
120
|
+
*/const YN=[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],ym=ce("battery",YN);/**
|
|
121
|
+
* @license lucide-react v0.576.0 - ISC
|
|
122
|
+
*
|
|
123
|
+
* This source code is licensed under the ISC license.
|
|
124
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
125
|
+
*/const ZN=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]],XN=ce("bell-ring",ZN);/**
|
|
126
|
+
* @license lucide-react v0.576.0 - ISC
|
|
127
|
+
*
|
|
128
|
+
* This source code is licensed under the ISC license.
|
|
129
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
130
|
+
*/const JN=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Ys=ce("bell",JN);/**
|
|
131
|
+
* @license lucide-react v0.576.0 - ISC
|
|
132
|
+
*
|
|
133
|
+
* This source code is licensed under the ISC license.
|
|
134
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
135
|
+
*/const e2=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],t2=ce("bug",e2);/**
|
|
136
|
+
* @license lucide-react v0.576.0 - ISC
|
|
137
|
+
*
|
|
138
|
+
* This source code is licensed under the ISC license.
|
|
139
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
140
|
+
*/const n2=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Tl=ce("camera",n2);/**
|
|
141
|
+
* @license lucide-react v0.576.0 - ISC
|
|
142
|
+
*
|
|
143
|
+
* This source code is licensed under the ISC license.
|
|
144
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
145
|
+
*/const r2=[["path",{d:"M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6",key:"3zrzxg"}],["path",{d:"M2 12a9 9 0 0 1 8 8",key:"g6cvee"}],["path",{d:"M2 16a5 5 0 0 1 4 4",key:"1y1dii"}],["line",{x1:"2",x2:"2.01",y1:"20",y2:"20",key:"xu2jvo"}]],o2=ce("cast",r2);/**
|
|
146
|
+
* @license lucide-react v0.576.0 - ISC
|
|
147
|
+
*
|
|
148
|
+
* This source code is licensed under the ISC license.
|
|
149
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
150
|
+
*/const s2=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],wo=ce("check",s2);/**
|
|
151
|
+
* @license lucide-react v0.576.0 - ISC
|
|
152
|
+
*
|
|
153
|
+
* This source code is licensed under the ISC license.
|
|
154
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
155
|
+
*/const a2=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Yn=ce("chevron-down",a2);/**
|
|
156
|
+
* @license lucide-react v0.576.0 - ISC
|
|
157
|
+
*
|
|
158
|
+
* This source code is licensed under the ISC license.
|
|
159
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
160
|
+
*/const i2=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],l2=ce("chevron-left",i2);/**
|
|
161
|
+
* @license lucide-react v0.576.0 - ISC
|
|
162
|
+
*
|
|
163
|
+
* This source code is licensed under the ISC license.
|
|
164
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
165
|
+
*/const c2=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Cn=ce("chevron-right",c2);/**
|
|
166
|
+
* @license lucide-react v0.576.0 - ISC
|
|
167
|
+
*
|
|
168
|
+
* This source code is licensed under the ISC license.
|
|
169
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
170
|
+
*/const d2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Zs=ce("circle-alert",d2);/**
|
|
171
|
+
* @license lucide-react v0.576.0 - ISC
|
|
172
|
+
*
|
|
173
|
+
* This source code is licensed under the ISC license.
|
|
174
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
175
|
+
*/const u2=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],p2=ce("circle-check-big",u2);/**
|
|
176
|
+
* @license lucide-react v0.576.0 - ISC
|
|
177
|
+
*
|
|
178
|
+
* This source code is licensed under the ISC license.
|
|
179
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
180
|
+
*/const f2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],m2=ce("circle-check",f2);/**
|
|
181
|
+
* @license lucide-react v0.576.0 - ISC
|
|
182
|
+
*
|
|
183
|
+
* This source code is licensed under the ISC license.
|
|
184
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
185
|
+
*/const h2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],g2=ce("circle-dot",h2);/**
|
|
186
|
+
* @license lucide-react v0.576.0 - ISC
|
|
187
|
+
*
|
|
188
|
+
* This source code is licensed under the ISC license.
|
|
189
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
190
|
+
*/const b2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]],x2=ce("circle-pause",b2);/**
|
|
191
|
+
* @license lucide-react v0.576.0 - ISC
|
|
192
|
+
*
|
|
193
|
+
* This source code is licensed under the ISC license.
|
|
194
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
195
|
+
*/const y2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],v2=ce("circle-plus",y2);/**
|
|
196
|
+
* @license lucide-react v0.576.0 - ISC
|
|
197
|
+
*
|
|
198
|
+
* This source code is licensed under the ISC license.
|
|
199
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
200
|
+
*/const w2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],vm=ce("circle-question-mark",w2);/**
|
|
201
|
+
* @license lucide-react v0.576.0 - ISC
|
|
202
|
+
*
|
|
203
|
+
* This source code is licensed under the ISC license.
|
|
204
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
205
|
+
*/const N2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],k2=ce("circle-x",N2);/**
|
|
206
|
+
* @license lucide-react v0.576.0 - ISC
|
|
207
|
+
*
|
|
208
|
+
* This source code is licensed under the ISC license.
|
|
209
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
210
|
+
*/const S2=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],C2=ce("copy-plus",S2);/**
|
|
211
|
+
* @license lucide-react v0.576.0 - ISC
|
|
212
|
+
*
|
|
213
|
+
* This source code is licensed under the ISC license.
|
|
214
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
215
|
+
*/const M2=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Mn=ce("copy",M2);/**
|
|
216
|
+
* @license lucide-react v0.576.0 - ISC
|
|
217
|
+
*
|
|
218
|
+
* This source code is licensed under the ISC license.
|
|
219
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
220
|
+
*/const I2=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],A2=ce("cpu",I2);/**
|
|
221
|
+
* @license lucide-react v0.576.0 - ISC
|
|
222
|
+
*
|
|
223
|
+
* This source code is licensed under the ISC license.
|
|
224
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
225
|
+
*/const P2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],wm=ce("crosshair",P2);/**
|
|
226
|
+
* @license lucide-react v0.576.0 - ISC
|
|
227
|
+
*
|
|
228
|
+
* This source code is licensed under the ISC license.
|
|
229
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
230
|
+
*/const E2=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],$2=ce("database",E2);/**
|
|
231
|
+
* @license lucide-react v0.576.0 - ISC
|
|
232
|
+
*
|
|
233
|
+
* This source code is licensed under the ISC license.
|
|
234
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
235
|
+
*/const _2=[["path",{d:"M11 20H2",key:"nlcfvz"}],["path",{d:"M11 4.562v16.157a1 1 0 0 0 1.242.97L19 20V5.562a2 2 0 0 0-1.515-1.94l-4-1A2 2 0 0 0 11 4.561z",key:"au4z13"}],["path",{d:"M11 4H8a2 2 0 0 0-2 2v14",key:"74r1mk"}],["path",{d:"M14 12h.01",key:"1jfl7z"}],["path",{d:"M22 20h-3",key:"vhrsz"}]],Nm=ce("door-open",_2);/**
|
|
236
|
+
* @license lucide-react v0.576.0 - ISC
|
|
237
|
+
*
|
|
238
|
+
* This source code is licensed under the ISC license.
|
|
239
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
240
|
+
*/const D2=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Oi=ce("download",D2);/**
|
|
241
|
+
* @license lucide-react v0.576.0 - ISC
|
|
242
|
+
*
|
|
243
|
+
* This source code is licensed under the ISC license.
|
|
244
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
245
|
+
*/const L2=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],km=ce("ellipsis-vertical",L2);/**
|
|
246
|
+
* @license lucide-react v0.576.0 - ISC
|
|
247
|
+
*
|
|
248
|
+
* This source code is licensed under the ISC license.
|
|
249
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
250
|
+
*/const T2=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Sm=ce("external-link",T2);/**
|
|
251
|
+
* @license lucide-react v0.576.0 - ISC
|
|
252
|
+
*
|
|
253
|
+
* This source code is licensed under the ISC license.
|
|
254
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
255
|
+
*/const R2=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Cm=ce("eye-off",R2);/**
|
|
256
|
+
* @license lucide-react v0.576.0 - ISC
|
|
257
|
+
*
|
|
258
|
+
* This source code is licensed under the ISC license.
|
|
259
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
260
|
+
*/const O2=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Xs=ce("eye",O2);/**
|
|
261
|
+
* @license lucide-react v0.576.0 - ISC
|
|
262
|
+
*
|
|
263
|
+
* This source code is licensed under the ISC license.
|
|
264
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
265
|
+
*/const z2=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Mm=ce("funnel",z2);/**
|
|
266
|
+
* @license lucide-react v0.576.0 - ISC
|
|
267
|
+
*
|
|
268
|
+
* This source code is licensed under the ISC license.
|
|
269
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
270
|
+
*/const B2=[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]],F2=ce("grip-horizontal",B2);/**
|
|
271
|
+
* @license lucide-react v0.576.0 - ISC
|
|
272
|
+
*
|
|
273
|
+
* This source code is licensed under the ISC license.
|
|
274
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
275
|
+
*/const j2=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Im=ce("house",j2);/**
|
|
276
|
+
* @license lucide-react v0.576.0 - ISC
|
|
277
|
+
*
|
|
278
|
+
* This source code is licensed under the ISC license.
|
|
279
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
280
|
+
*/const H2=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],V2=ce("image",H2);/**
|
|
281
|
+
* @license lucide-react v0.576.0 - ISC
|
|
282
|
+
*
|
|
283
|
+
* This source code is licensed under the ISC license.
|
|
284
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
285
|
+
*/const q2=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],Q2=ce("inbox",q2);/**
|
|
286
|
+
* @license lucide-react v0.576.0 - ISC
|
|
287
|
+
*
|
|
288
|
+
* This source code is licensed under the ISC license.
|
|
289
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
290
|
+
*/const U2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],K2=ce("info",U2);/**
|
|
291
|
+
* @license lucide-react v0.576.0 - ISC
|
|
292
|
+
*
|
|
293
|
+
* This source code is licensed under the ISC license.
|
|
294
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
295
|
+
*/const G2=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],W2=ce("layout-grid",G2);/**
|
|
296
|
+
* @license lucide-react v0.576.0 - ISC
|
|
297
|
+
*
|
|
298
|
+
* This source code is licensed under the ISC license.
|
|
299
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
300
|
+
*/const Y2=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],Am=ce("lightbulb",Y2);/**
|
|
301
|
+
* @license lucide-react v0.576.0 - ISC
|
|
302
|
+
*
|
|
303
|
+
* This source code is licensed under the ISC license.
|
|
304
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
305
|
+
*/const Z2=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Lt=ce("loader-circle",Z2);/**
|
|
306
|
+
* @license lucide-react v0.576.0 - ISC
|
|
307
|
+
*
|
|
308
|
+
* This source code is licensed under the ISC license.
|
|
309
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
310
|
+
*/const X2=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],J2=ce("locate-fixed",X2);/**
|
|
311
|
+
* @license lucide-react v0.576.0 - ISC
|
|
312
|
+
*
|
|
313
|
+
* This source code is licensed under the ISC license.
|
|
314
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
315
|
+
*/const ek=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],jd=ce("maximize-2",ek);/**
|
|
316
|
+
* @license lucide-react v0.576.0 - ISC
|
|
317
|
+
*
|
|
318
|
+
* This source code is licensed under the ISC license.
|
|
319
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
320
|
+
*/const tk=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],nk=ce("menu",tk);/**
|
|
321
|
+
* @license lucide-react v0.576.0 - ISC
|
|
322
|
+
*
|
|
323
|
+
* This source code is licensed under the ISC license.
|
|
324
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
325
|
+
*/const rk=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],Pm=ce("mic",rk);/**
|
|
326
|
+
* @license lucide-react v0.576.0 - ISC
|
|
327
|
+
*
|
|
328
|
+
* This source code is licensed under the ISC license.
|
|
329
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
330
|
+
*/const ok=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Hd=ce("minimize-2",ok);/**
|
|
331
|
+
* @license lucide-react v0.576.0 - ISC
|
|
332
|
+
*
|
|
333
|
+
* This source code is licensed under the ISC license.
|
|
334
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
335
|
+
*/const sk=[["path",{d:"M5 12h14",key:"1ays0h"}]],Em=ce("minus",sk);/**
|
|
336
|
+
* @license lucide-react v0.576.0 - ISC
|
|
337
|
+
*
|
|
338
|
+
* This source code is licensed under the ISC license.
|
|
339
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
340
|
+
*/const ak=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],Rl=ce("moon",ak);/**
|
|
341
|
+
* @license lucide-react v0.576.0 - ISC
|
|
342
|
+
*
|
|
343
|
+
* This source code is licensed under the ISC license.
|
|
344
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
345
|
+
*/const ik=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],lk=ce("music",ik);/**
|
|
346
|
+
* @license lucide-react v0.576.0 - ISC
|
|
347
|
+
*
|
|
348
|
+
* This source code is licensed under the ISC license.
|
|
349
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
350
|
+
*/const ck=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],zi=ce("network",ck);/**
|
|
351
|
+
* @license lucide-react v0.576.0 - ISC
|
|
352
|
+
*
|
|
353
|
+
* This source code is licensed under the ISC license.
|
|
354
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
355
|
+
*/const dk=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Bi=ce("play",dk);/**
|
|
356
|
+
* @license lucide-react v0.576.0 - ISC
|
|
357
|
+
*
|
|
358
|
+
* This source code is licensed under the ISC license.
|
|
359
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
360
|
+
*/const uk=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Js=ce("plus",uk);/**
|
|
361
|
+
* @license lucide-react v0.576.0 - ISC
|
|
362
|
+
*
|
|
363
|
+
* This source code is licensed under the ISC license.
|
|
364
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
365
|
+
*/const pk=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],fk=ce("plug",pk);/**
|
|
366
|
+
* @license lucide-react v0.576.0 - ISC
|
|
367
|
+
*
|
|
368
|
+
* This source code is licensed under the ISC license.
|
|
369
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
370
|
+
*/const mk=[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],hk=ce("power-off",mk);/**
|
|
371
|
+
* @license lucide-react v0.576.0 - ISC
|
|
372
|
+
*
|
|
373
|
+
* This source code is licensed under the ISC license.
|
|
374
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
375
|
+
*/const gk=[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]],$m=ce("radar",gk);/**
|
|
376
|
+
* @license lucide-react v0.576.0 - ISC
|
|
377
|
+
*
|
|
378
|
+
* This source code is licensed under the ISC license.
|
|
379
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
380
|
+
*/const bk=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],xk=ce("radio",bk);/**
|
|
381
|
+
* @license lucide-react v0.576.0 - ISC
|
|
382
|
+
*
|
|
383
|
+
* This source code is licensed under the ISC license.
|
|
384
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
385
|
+
*/const yk=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Ol=ce("refresh-cw",yk);/**
|
|
386
|
+
* @license lucide-react v0.576.0 - ISC
|
|
387
|
+
*
|
|
388
|
+
* This source code is licensed under the ISC license.
|
|
389
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
390
|
+
*/const vk=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],_m=ce("rotate-ccw",vk);/**
|
|
391
|
+
* @license lucide-react v0.576.0 - ISC
|
|
392
|
+
*
|
|
393
|
+
* This source code is licensed under the ISC license.
|
|
394
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
395
|
+
*/const wk=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Dm=ce("rotate-cw",wk);/**
|
|
396
|
+
* @license lucide-react v0.576.0 - ISC
|
|
397
|
+
*
|
|
398
|
+
* This source code is licensed under the ISC license.
|
|
399
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
400
|
+
*/const Nk=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],kk=ce("save",Nk);/**
|
|
401
|
+
* @license lucide-react v0.576.0 - ISC
|
|
402
|
+
*
|
|
403
|
+
* This source code is licensed under the ISC license.
|
|
404
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
405
|
+
*/const Sk=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],Ck=ce("scan",Sk);/**
|
|
406
|
+
* @license lucide-react v0.576.0 - ISC
|
|
407
|
+
*
|
|
408
|
+
* This source code is licensed under the ISC license.
|
|
409
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
410
|
+
*/const Mk=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],Ik=ce("scroll-text",Mk);/**
|
|
411
|
+
* @license lucide-react v0.576.0 - ISC
|
|
412
|
+
*
|
|
413
|
+
* This source code is licensed under the ISC license.
|
|
414
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
415
|
+
*/const Ak=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],oo=ce("search",Ak);/**
|
|
416
|
+
* @license lucide-react v0.576.0 - ISC
|
|
417
|
+
*
|
|
418
|
+
* This source code is licensed under the ISC license.
|
|
419
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
420
|
+
*/const Pk=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Ek=ce("server",Pk);/**
|
|
421
|
+
* @license lucide-react v0.576.0 - ISC
|
|
422
|
+
*
|
|
423
|
+
* This source code is licensed under the ISC license.
|
|
424
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
425
|
+
*/const $k=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],_k=ce("shield",$k);/**
|
|
426
|
+
* @license lucide-react v0.576.0 - ISC
|
|
427
|
+
*
|
|
428
|
+
* This source code is licensed under the ISC license.
|
|
429
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
430
|
+
*/const Dk=[["path",{d:"M12 10.189V14",key:"1p8cqu"}],["path",{d:"M12 2v3",key:"qbqxhf"}],["path",{d:"M19 13V7a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v6",key:"qpkstq"}],["path",{d:"M19.38 20A11.6 11.6 0 0 0 21 14l-8.188-3.639a2 2 0 0 0-1.624 0L3 14a11.6 11.6 0 0 0 2.81 7.76",key:"7tigtc"}],["path",{d:"M2 21c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1s1.2 1 2.5 1c2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"1924j5"}]],Lk=ce("ship",Dk);/**
|
|
431
|
+
* @license lucide-react v0.576.0 - ISC
|
|
432
|
+
*
|
|
433
|
+
* This source code is licensed under the ISC license.
|
|
434
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
435
|
+
*/const Tk=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],Rk=ce("sliders-horizontal",Tk);/**
|
|
436
|
+
* @license lucide-react v0.576.0 - ISC
|
|
437
|
+
*
|
|
438
|
+
* This source code is licensed under the ISC license.
|
|
439
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
440
|
+
*/const Ok=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Vd=ce("square",Ok);/**
|
|
441
|
+
* @license lucide-react v0.576.0 - ISC
|
|
442
|
+
*
|
|
443
|
+
* This source code is licensed under the ISC license.
|
|
444
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
445
|
+
*/const zk=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],Bk=ce("star",zk);/**
|
|
446
|
+
* @license lucide-react v0.576.0 - ISC
|
|
447
|
+
*
|
|
448
|
+
* This source code is licensed under the ISC license.
|
|
449
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
450
|
+
*/const Fk=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],Lm=ce("sun",Fk);/**
|
|
451
|
+
* @license lucide-react v0.576.0 - ISC
|
|
452
|
+
*
|
|
453
|
+
* This source code is licensed under the ISC license.
|
|
454
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
455
|
+
*/const jk=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],Hk=ce("table-2",jk);/**
|
|
456
|
+
* @license lucide-react v0.576.0 - ISC
|
|
457
|
+
*
|
|
458
|
+
* This source code is licensed under the ISC license.
|
|
459
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
460
|
+
*/const Vk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],qd=ce("target",Vk);/**
|
|
461
|
+
* @license lucide-react v0.576.0 - ISC
|
|
462
|
+
*
|
|
463
|
+
* This source code is licensed under the ISC license.
|
|
464
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
465
|
+
*/const qk=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Qk=ce("thermometer",qk);/**
|
|
466
|
+
* @license lucide-react v0.576.0 - ISC
|
|
467
|
+
*
|
|
468
|
+
* This source code is licensed under the ISC license.
|
|
469
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
470
|
+
*/const Uk=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],Kk=ce("toggle-left",Uk);/**
|
|
471
|
+
* @license lucide-react v0.576.0 - ISC
|
|
472
|
+
*
|
|
473
|
+
* This source code is licensed under the ISC license.
|
|
474
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
475
|
+
*/const Gk=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],rn=ce("trash-2",Gk);/**
|
|
476
|
+
* @license lucide-react v0.576.0 - ISC
|
|
477
|
+
*
|
|
478
|
+
* This source code is licensed under the ISC license.
|
|
479
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
480
|
+
*/const Wk=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Yk=ce("trending-up",Wk);/**
|
|
481
|
+
* @license lucide-react v0.576.0 - ISC
|
|
482
|
+
*
|
|
483
|
+
* This source code is licensed under the ISC license.
|
|
484
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
485
|
+
*/const Zk=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],Xk=ce("trending-down",Zk);/**
|
|
486
|
+
* @license lucide-react v0.576.0 - ISC
|
|
487
|
+
*
|
|
488
|
+
* This source code is licensed under the ISC license.
|
|
489
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
490
|
+
*/const Jk=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],No=ce("triangle-alert",Jk);/**
|
|
491
|
+
* @license lucide-react v0.576.0 - ISC
|
|
492
|
+
*
|
|
493
|
+
* This source code is licensed under the ISC license.
|
|
494
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
495
|
+
*/const e5=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Tm=ce("upload",e5);/**
|
|
496
|
+
* @license lucide-react v0.576.0 - ISC
|
|
497
|
+
*
|
|
498
|
+
* This source code is licensed under the ISC license.
|
|
499
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
500
|
+
*/const t5=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],n5=ce("wifi-off",t5);/**
|
|
501
|
+
* @license lucide-react v0.576.0 - ISC
|
|
502
|
+
*
|
|
503
|
+
* This source code is licensed under the ISC license.
|
|
504
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
505
|
+
*/const r5=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Rm=ce("wifi",r5);/**
|
|
506
|
+
* @license lucide-react v0.576.0 - ISC
|
|
507
|
+
*
|
|
508
|
+
* This source code is licensed under the ISC license.
|
|
509
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
510
|
+
*/const o5=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],zl=ce("wrench",o5);/**
|
|
511
|
+
* @license lucide-react v0.576.0 - ISC
|
|
512
|
+
*
|
|
513
|
+
* This source code is licensed under the ISC license.
|
|
514
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
515
|
+
*/const s5=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Je=ce("x",s5);/**
|
|
516
|
+
* @license lucide-react v0.576.0 - ISC
|
|
517
|
+
*
|
|
518
|
+
* This source code is licensed under the ISC license.
|
|
519
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
520
|
+
*/const a5=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Qd=ce("zap",a5);/**
|
|
521
|
+
* @license lucide-react v0.576.0 - ISC
|
|
522
|
+
*
|
|
523
|
+
* This source code is licensed under the ISC license.
|
|
524
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
525
|
+
*/const i5=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],l5=ce("zoom-in",i5);/**
|
|
526
|
+
* @license lucide-react v0.576.0 - ISC
|
|
527
|
+
*
|
|
528
|
+
* This source code is licensed under the ISC license.
|
|
529
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
530
|
+
*/const c5=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],d5=ce("zoom-out",c5),u5={frigate:Lk,scrypted:_k,reolink:xk,homeAssistant:Im,rtsp:o2},p5={online:m2,offline:k2,degraded:Zs,unknown:vm},Ud=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Kd=Jf,Zn=(e,t)=>n=>{var o;if(t?.variants==null)return Kd(e,n?.class,n?.className);const{variants:s,defaultVariants:a}=t,i=Object.keys(s).map(d=>{const f=n?.[d],p=a?.[d];if(f===null)return null;const m=Ud(f)||Ud(p);return s[d][m]}),l=n&&Object.entries(n).reduce((d,f)=>{let[p,m]=f;return m===void 0||(d[p]=m),d},{}),c=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((d,f)=>{let{class:p,className:m,...h}=f;return Object.entries(h).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...a,...l}[b]):{...a,...l}[b]===x})?[...d,p,m]:d},[]);return Kd(e,i,c,n?.class,n?.className)},f5=Zn("inline-flex items-center justify-center rounded-md font-medium transition-colors cursor-pointer disabled:opacity-50 disabled:pointer-events-none",{variants:{variant:{primary:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-surface text-foreground hover:bg-surface-hover",ghost:"hover:bg-surface-hover text-foreground-muted",danger:"bg-danger text-white hover:bg-danger/90",outline:"border border-border bg-transparent hover:bg-surface-hover"},size:{sm:"h-7 px-2.5 text-xs gap-1.5",md:"h-8 px-3 text-sm gap-2",lg:"h-9 px-4 text-sm gap-2"}},defaultVariants:{variant:"primary",size:"sm"}}),He=Ve(({className:e,variant:t,size:n,...o},s)=>r("button",{ref:s,className:K(f5({variant:t,size:n}),e),...o}));He.displayName="Button";const m5=Zn("inline-flex items-center justify-center rounded-md font-medium transition-colors cursor-pointer disabled:opacity-50 disabled:pointer-events-none",{variants:{variant:{primary:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-surface text-foreground hover:bg-surface-hover",ghost:"hover:bg-surface-hover text-foreground-muted",danger:"bg-danger text-white hover:bg-danger/90",outline:"border border-border bg-transparent hover:bg-surface-hover"},size:{sm:"h-7 w-7",md:"h-8 w-8",lg:"h-9 w-9"}},defaultVariants:{variant:"primary",size:"sm"}}),Bl=Ve(({className:e,variant:t,size:n,icon:o,...s},a)=>r("button",{ref:a,className:K(m5({variant:t,size:n}),e),...s,children:r(o,{className:"h-4 w-4"})}));Bl.displayName="IconButton";const h5=Zn("inline-flex items-center rounded-full text-xs font-medium px-2 py-0.5",{variants:{variant:{default:"bg-surface-hover text-foreground",success:"bg-success/15 text-success",warning:"bg-warning/15 text-warning",danger:"bg-danger/15 text-danger",info:"bg-info/15 text-info"},styleVariant:{solid:"",outline:"border bg-transparent"}},defaultVariants:{variant:"default",styleVariant:"solid"}}),cr=Ve(({className:e,variant:t,style:n,...o},s)=>r("span",{ref:s,className:K(h5({variant:t,styleVariant:n}),e),...o}));cr.displayName="Badge";const g5=Zn("rounded-lg p-3",{variants:{variant:{flat:"bg-surface",bordered:"bg-surface border border-border"}},defaultVariants:{variant:"bordered"}}),Ge=Ve(({className:e,variant:t,...n},o)=>r("div",{ref:o,className:K(g5({variant:t}),e),...n}));Ge.displayName="Card";function Om({expanded:e,onExpandedChange:t,header:n,children:o,dimmed:s=!1,hideChevron:a=!1,className:i}){return u("div",{className:K("rounded-lg border border-border bg-surface overflow-hidden",s&&"opacity-[0.45]",i),children:[u("div",{role:"button",tabIndex:0,className:"flex items-center gap-2.5 px-3 py-2.5 cursor-pointer select-none",onClick:()=>t(!e),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),t(!e))},children:[!a&&r("span",{className:"text-foreground-subtle shrink-0",children:e?r(Yn,{className:"h-4 w-4"}):r(Cn,{className:"h-4 w-4"})}),n]}),e&&o&&r("div",{className:"border-t border-border px-3 py-3",children:o})]})}const Fl=Ve(({className:e,...t},n)=>r("label",{ref:n,className:K("text-[10px] uppercase tracking-wider text-foreground-muted font-medium",e),...t}));Fl.displayName="Label";const b5=Zn("",{variants:{orientation:{horizontal:"h-px w-full bg-border-subtle",vertical:"w-px h-full bg-border-subtle"}},defaultVariants:{orientation:"horizontal"}}),jl=Ve(({className:e,orientation:t,...n},o)=>r("div",{ref:o,role:"separator",className:K(b5({orientation:t}),e),...n}));jl.displayName="Separator";const zm=Ve(({className:e,...t},n)=>r("div",{ref:n,className:K("animate-pulse bg-surface-hover rounded-md h-4 w-full",e),...t}));zm.displayName="Skeleton";const Gd=Zn("h-7 w-full px-2.5 text-xs bg-surface border rounded-md text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary transition-colors",{variants:{state:{default:"border-border",error:"border-danger"}},defaultVariants:{state:"default"}}),Ss=Ve(({className:e,state:t,leftSlot:n,rightSlot:o,...s},a)=>n||o?u("div",{className:"relative flex items-center w-full",children:[n&&r("div",{className:"absolute left-2.5 flex items-center pointer-events-none",children:n}),r("input",{ref:a,className:K(Gd({state:t}),n?"pl-7":"",o?"pr-7":"",e),...s}),o&&r("div",{className:"absolute right-2.5 flex items-center pointer-events-none",children:o})]}):r("input",{ref:a,className:K(Gd({state:t}),e),...s}));Ss.displayName="Input";const Cs=Ve(({className:e,options:t,...n},o)=>u("div",{className:"relative w-full",children:[r("select",{ref:o,className:K("h-7 w-full px-2.5 text-xs bg-surface border border-border rounded-md text-foreground appearance-none pr-7 focus:outline-none focus:ring-1 focus:ring-primary",e),...n,children:t.map(s=>r("option",{value:s.value,children:s.label},s.value))}),r("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none text-foreground-muted",children:r(Yn,{className:"h-3.5 w-3.5"})})]}));Cs.displayName="Select";const Bm=Ve(({className:e,...t},n)=>r("input",{ref:n,type:"checkbox",className:K("w-3.5 h-3.5 rounded-sm border border-border accent-primary",e),...t}));Bm.displayName="Checkbox";const Hl=Ve(({className:e,checked:t,onCheckedChange:n,label:o,...s},a)=>u("button",{ref:a,role:"switch","aria-checked":t,type:"button",onClick:()=>n(!t),className:K("inline-flex items-center gap-2",e),...s,children:[r("span",{className:K("w-8 h-4 rounded-full transition-colors",t?"bg-primary":"bg-surface-hover"),children:r("span",{className:K("block w-3.5 h-3.5 rounded-full bg-white transition-transform",t?"translate-x-4":"translate-x-0.5")})}),o&&r("span",{className:"text-xs text-foreground",children:o})]}));Hl.displayName="Switch";const Fm=Oe(null);function jm(){const e=ye(Fm);if(!e)throw new Error("Dialog compound components must be used within <Dialog>");return e}function Hm({children:e,open:t,onOpenChange:n}){const[o,s]=$(!1),a=t??o,i=mr(),l=q(c=>{n?.(c),t===void 0&&s(c)},[t,n]);return r(Fm.Provider,{value:{open:a,setOpen:l,contentId:i},children:e})}function x5({children:e,...t}){const{setOpen:n}=jm();return r("button",{type:"button",onClick:()=>n(!0),...t,children:e})}const y5=Zn("bg-background-elevated border border-border rounded-lg p-4 backdrop:bg-black/50 backdrop:backdrop-blur-sm max-w-[calc(100vw-2rem)] max-h-[calc(100dvh-2rem)] overflow-y-auto",{variants:{width:{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"}},defaultVariants:{width:"md"}}),Vl=Ve(({className:e,width:t,children:n,...o},s)=>{const{open:a,setOpen:i,contentId:l}=jm(),c=ne(null),d=s??c;Y(()=>{const p=d.current;p&&(a&&!p.open&&p.showModal(),!a&&p.open&&p.close())},[a,d]);const f=p=>{p.target===p.currentTarget&&i(!1)};return r("dialog",{ref:d,id:l,className:K(y5({width:t}),"w-full",e),onClick:f,onClose:()=>i(!1),...o,children:n})});Vl.displayName="DialogContent";function Vm({className:e,...t}){return r("div",{className:K("flex flex-col gap-1 mb-3",e),...t})}function qm({className:e,...t}){return r("div",{className:K("flex justify-end gap-2 mt-4",e),...t})}function Qm({className:e,...t}){return r("h2",{className:K("text-sm font-semibold text-foreground",e),...t})}function Um({className:e,...t}){return r("p",{className:K("text-xs text-foreground-muted",e),...t})}const Km=Oe(null);function ql(){const e=ye(Km);if(!e)throw new Error("Dropdown compound components must be used within <Dropdown>");return e}function Gm({children:e}){const[t,n]=$(!1),o=mr(),s=mr(),a=ne(null);return r(Km.Provider,{value:{open:t,setOpen:n,triggerId:o,contentId:s,triggerRef:a},children:r("div",{className:"relative inline-block",children:e})})}function Wm({children:e,...t}){const{open:n,setOpen:o,triggerId:s,contentId:a,triggerRef:i}=ql();return r("button",{type:"button",ref:i,id:s,"aria-haspopup":"menu","aria-expanded":n,"aria-controls":n?a:void 0,onClick:()=>o(!n),...t,children:e})}function Ym({className:e,children:t,align:n="start",offset:o=4,...s}){const{open:a,setOpen:i,contentId:l,triggerId:c,triggerRef:d}=ql(),f=ne(null),[p,m]=$(null);if(Gs(()=>{if(!a){m(null);return}const g=()=>{const b=d.current;if(!b)return;const x=b.getBoundingClientRect(),v=n==="end"?x.right:x.left;m({top:x.bottom+o,left:v,minWidth:x.width})};return g(),window.addEventListener("resize",g),window.addEventListener("scroll",g,!0),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0)}},[a,n,o,d]),Y(()=>{if(!a)return;const g=x=>{const v=f.current,w=d.current;v&&!v.contains(x.target)&&!w?.contains(x.target)&&i(!1)},b=x=>{x.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",b)}},[a,i,d]),!a||!p||typeof document>"u")return null;const h={position:"fixed",top:p.top,...n==="end"?{right:window.innerWidth-p.left}:{left:p.left},minWidth:p.minWidth};return vo(r("div",{ref:f,id:l,role:"menu","aria-labelledby":c,style:h,className:K("z-50 bg-background-elevated border border-border rounded-md shadow-lg py-1 min-w-[160px]",e),...s,children:t}),document.body)}function Zm({className:e,icon:t,variant:n="default",children:o,onClick:s,...a}){const{setOpen:i}=ql(),l=q(c=>{s?.(c),i(!1)},[s,i]);return u("button",{type:"button",role:"menuitem",className:K("h-7 text-xs px-2 w-full text-left flex items-center gap-2",n==="danger"?"text-danger hover:bg-danger/10":"text-foreground hover:bg-surface-hover",e),onClick:l,...a,children:[t&&r(t,{size:14}),o]})}const Xm=Oe(null);function Jm(){const e=ye(Xm);if(!e)throw new Error("Tooltip compound components must be used within <Tooltip>");return e}function v5({children:e}){const[t,n]=$(!1),o=ne(null),s=mr(),a=()=>{o.current=setTimeout(()=>n(!0),300)},i=()=>{o.current&&clearTimeout(o.current),n(!1)};return r(Xm.Provider,{value:{open:t,show:a,hide:i,tooltipId:s},children:r("div",{className:"relative inline-block",children:e})})}function w5({children:e,...t}){const{show:n,hide:o,tooltipId:s,open:a}=Jm();return r("div",{onMouseEnter:n,onMouseLeave:o,onFocus:n,onBlur:o,"aria-describedby":a?s:void 0,...t,children:e})}function N5({className:e,children:t,...n}){const{open:o,tooltipId:s}=Jm();return r("div",{id:s,role:"tooltip",className:K("absolute bottom-full left-1/2 -translate-x-1/2 mb-2 bg-foreground text-background text-xs px-2 py-1 rounded-md shadow-md whitespace-nowrap pointer-events-none transition-opacity duration-150",o?"opacity-100":"opacity-0",e),...n,children:t})}const Wd="(max-width: 767px)",Yd="(min-width: 768px) and (max-width: 1023px)";function eh(e){return t=>{const n=window.matchMedia(e);return n.addEventListener("change",t),()=>n.removeEventListener("change",t)}}function th(e){return()=>window.matchMedia(e).matches}function nh(){return!1}function Xn(){return Ws(eh(Wd),th(Wd),nh)}function rh(){return Ws(eh(Yd),th(Yd),nh)}function Ql({open:e,onClose:t,title:n,children:o,className:s}){return Y(()=>{if(!e)return;const a=i=>{i.key==="Escape"&&t()};return document.addEventListener("keydown",a),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",a),document.body.style.overflow=""}},[e,t]),u(ve,{children:[r("div",{className:K("fixed inset-0 z-40 bg-black/50 transition-opacity duration-200",e?"opacity-100":"pointer-events-none opacity-0"),onClick:t,"aria-hidden":"true"}),u("div",{role:"dialog","aria-modal":"true",className:K("fixed inset-x-0 bottom-0 z-50 flex flex-col bg-background-elevated border-t border-border rounded-t-xl shadow-2xl transition-transform duration-200 ease-out","max-h-[80dvh]",e?"translate-y-0":"translate-y-full",s),children:[r("div",{className:"flex justify-center pt-2 pb-1",children:r("div",{className:"h-1 w-8 rounded-full bg-foreground-subtle/30"})}),n&&u("div",{className:"flex items-center justify-between px-4 pb-2",children:[r("span",{className:"text-sm font-medium text-foreground",children:n}),r("button",{onClick:t,className:"p-1 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors",children:r(Je,{className:"h-4 w-4"})})]}),r("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:o})]})]})}const oh=Oe(null);function sh(){const e=ye(oh);if(!e)throw new Error("Popover compound components must be used within <Popover>");return e}function ah({children:e,open:t,onOpenChange:n}){const[o,s]=$(!1),a=t??o,i=mr(),l=mr(),c=q(d=>{n?.(d),t===void 0&&s(d)},[t,n]);return r(oh.Provider,{value:{open:a,setOpen:c,triggerId:i,contentId:l},children:r("div",{className:"relative inline-block",children:e})})}function ih({children:e,...t}){const{open:n,setOpen:o,triggerId:s,contentId:a}=sh();return r("button",{type:"button",id:s,"aria-haspopup":"dialog","aria-expanded":n,"aria-controls":n?a:void 0,onClick:()=>o(!n),...t,children:e})}function lh({className:e,children:t,...n}){const{open:o,setOpen:s,contentId:a,triggerId:i}=sh(),l=Xn(),c=ne(null);return Y(()=>{if(!o||l)return;const d=p=>{const m=c.current,h=document.getElementById(i);m&&!m.contains(p.target)&&!h?.contains(p.target)&&s(!1)},f=p=>{p.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",d),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",f)}},[o,s,i,l]),o?l?r(Ql,{open:o,onClose:()=>s(!1),children:t}):r("div",{ref:c,id:a,role:"dialog","aria-labelledby":i,className:K("absolute left-0 top-full z-50 mt-1 bg-background-elevated border border-border rounded-lg shadow-lg p-3",e),...n,children:t}):null}const ch=Oe(null);function dh(){const e=ye(ch);if(!e)throw new Error("Tabs compound components must be used within <Tabs>");return e}function k5({value:e,onValueChange:t,defaultValue:n="",className:o,...s}){const[a,i]=$(n),l=e??a,c=q(d=>{t?.(d),e===void 0&&i(d)},[e,t]);return r(ch.Provider,{value:{value:l,setValue:c},children:r("div",{className:o,...s})})}function S5({className:e,...t}){return r("div",{role:"tablist",className:K("flex flex-row border-b border-border-subtle",e),...t})}function C5({value:e,className:t,...n}){const{value:o,setValue:s}=dh(),a=e===o,i=`tabpanel-${e}`;return r("button",{type:"button",role:"tab","aria-selected":a,"aria-controls":i,tabIndex:a?0:-1,className:K("h-7 text-xs px-3 transition-colors",a?"border-b-2 border-primary text-foreground font-medium":"text-foreground-muted hover:text-foreground",t),onClick:()=>s(e),...n})}function M5({value:e,className:t,...n}){const{value:o}=dh();return e!==o?null:r("div",{role:"tabpanel",id:`tabpanel-${e}`,className:K("pt-3",t),...n})}const Ul=Ve(({className:e,...t},n)=>r("div",{ref:n,className:K("overflow-auto [&::-webkit-scrollbar]:w-1 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-surface-hover [&::-webkit-scrollbar-thumb]:rounded-full",e),...t}));Ul.displayName="ScrollArea";function I5({title:e,onClose:t,children:n,defaultWidth:o=360,defaultHeight:s=280,minWidth:a=280,minHeight:i=160,offsetIndex:l=0,className:c}){const[d,f]=$({x:80+l*30,y:80+l*30}),[p,m]=$({w:o,h:s}),[h,g]=$(!1),b=ne(!1),x=ne(!1),v=ne({x:0,y:0}),w=Xn(),y=q(k=>{k.preventDefault(),b.current=!0,v.current={x:k.clientX-d.x,y:k.clientY-d.y}},[d]),N=q(k=>{k.preventDefault(),k.stopPropagation(),x.current=!0,v.current={x:k.clientX,y:k.clientY}},[]);return Y(()=>{const k=M=>{if(b.current&&f({x:M.clientX-v.current.x,y:M.clientY-v.current.y}),x.current){const P=M.clientX-v.current.x,I=M.clientY-v.current.y;v.current={x:M.clientX,y:M.clientY},m(F=>({w:Math.max(a,F.w+P),h:Math.max(i,F.h+I)}))}},S=()=>{b.current=!1,x.current=!1};return window.addEventListener("mousemove",k),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",S)}},[a,i]),w?u("div",{className:K("fixed inset-x-0 bottom-0 z-50 rounded-t-xl border-t border-border bg-background-elevated shadow-2xl flex flex-col overflow-hidden",c),style:{maxHeight:"60dvh"},children:[u("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border shrink-0 bg-surface",children:[r("span",{className:"text-[11px] font-medium truncate",children:e}),u("div",{className:"flex items-center gap-1 shrink-0",children:[r("button",{onClick:()=>g(!h),className:"p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors",children:h?r(jd,{size:12}):r(Hd,{size:12})}),r("button",{onClick:t,className:"p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors",children:r(Je,{size:12})})]})]}),!h&&r("div",{className:"flex-1 min-h-0 overflow-y-auto",children:n})]}):u("div",{className:K("fixed z-50 rounded-lg border border-border bg-background-elevated shadow-2xl flex flex-col overflow-hidden",c),style:{left:d.x,top:d.y,width:h?280:p.w,height:h?"auto":p.h},children:[u("div",{onMouseDown:y,className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border cursor-move select-none shrink-0 bg-surface",children:[u("div",{className:"flex items-center gap-2 min-w-0",children:[r(F2,{size:12,className:"text-foreground-subtle shrink-0"}),r("span",{className:"text-[11px] font-medium truncate",children:e})]}),u("div",{className:"flex items-center gap-1 shrink-0",children:[r("button",{onClick:()=>g(!h),className:"p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors",title:h?"Restore":"Minimize",children:h?r(jd,{size:12}):r(Hd,{size:12})}),r("button",{onClick:t,className:"p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors",title:"Close",children:r(Je,{size:12})})]})]}),!h&&u("div",{className:"flex-1 min-h-0 overflow-y-auto relative",children:[n,r("div",{onMouseDown:N,className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",style:{background:"linear-gradient(135deg, transparent 50%, var(--color-foreground-subtle) 50%)",opacity:.4}})]})]})}function Kl({open:e,onClose:t,children:n,className:o,width:s="w-64"}){const a=ne(null);return Y(()=>{if(!e)return;const i=l=>{l.key==="Escape"&&t()};return document.addEventListener("keydown",i),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",i),document.body.style.overflow=""}},[e,t]),u(ve,{children:[r("div",{className:K("fixed inset-0 z-40 bg-black/50 backdrop-blur-sm transition-opacity duration-200",e?"opacity-100":"pointer-events-none opacity-0"),onClick:t,"aria-hidden":"true"}),r("div",{ref:a,role:"dialog","aria-modal":"true",className:K("fixed inset-y-0 left-0 z-50 flex flex-col bg-surface border-r border-border shadow-2xl transition-transform duration-200 ease-out",s,e?"translate-x-0":"-translate-x-full",o),children:n})]})}function Gl({items:e,className:t}){return r("nav",{className:`flex items-center gap-1 text-[11px] text-foreground-subtle ${t??""}`,children:e.map((n,o)=>{const s=o===e.length-1,a=!s&&(n.onClick||n.href);return u(Al.Fragment,{children:[o>0&&r(Cn,{className:"h-3 w-3 flex-shrink-0"}),a?n.onClick?r("button",{type:"button",onClick:n.onClick,className:"hover:text-foreground transition-colors",children:n.label}):r("a",{href:n.href,className:"hover:text-foreground transition-colors",children:n.label}):r("span",{className:s?"text-foreground font-medium":"",children:n.label})]},o)})})}const Zd={left:"text-left",right:"text-right",center:"text-center"};function uh({columns:e,rows:t,rowKey:n,onRowClick:o,minWidthPx:s=480,emptyMessage:a,className:i,bordered:l=!0,rowClassName:c}){if(t.length===0&&a)return r("div",{className:`rounded-lg ${l?"border border-border":""} bg-surface px-3 py-4 text-xs text-foreground-subtle text-center ${i??""}`,children:a});if(t.length===0)return null;const d=`rounded-lg ${l?"border border-border":""} bg-surface overflow-x-auto ${i??""}`;return r("div",{className:d,children:u("table",{className:"w-full text-xs",style:{minWidth:`${s}px`},children:[r("thead",{className:"bg-surface",children:r("tr",{children:e.map(f=>{const p=f.align??"left",m=f.nowrap??!0;return r("th",{className:["px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border",Zd[p],m?"whitespace-nowrap":"",f.width??""].filter(Boolean).join(" "),children:f.headerRender?f.headerRender():f.header},f.key)})})}),r("tbody",{children:t.map((f,p)=>{const m=n?n(f,p):p,h=c?.(f,p)??"",g=o!==void 0;return r("tr",{onClick:g?()=>o(f,p):void 0,className:[g?"cursor-pointer hover:bg-primary/5":"hover:bg-primary/5",h].filter(Boolean).join(" "),children:e.map(b=>{const x=b.align??"left",v=b.nowrap??!1;return r("td",{className:["px-3 py-2 text-foreground border-b border-border",Zd[x],v?"whitespace-nowrap":""].filter(Boolean).join(" "),children:b.render(f,p)},b.key)})},m)})})]})})}function Wl({open:e,onClose:t,title:n,subtitle:o,footer:s,children:a,widthClass:i="w-[360px]"}){return Y(()=>{if(!e)return;const l=c=>{c.key==="Escape"&&t()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e,t]),e?u("aside",{className:K("absolute top-0 right-0 bottom-0 z-20 flex flex-col","bg-surface border-l border-border shadow-xl",i),role:"dialog","aria-modal":"false",children:[u("header",{className:"flex items-start justify-between gap-2 px-4 py-3 border-b border-border",children:[u("div",{className:"min-w-0",children:[r("div",{className:"text-sm font-semibold text-foreground truncate",children:n}),o!==void 0&&r("div",{className:"text-[11px] text-foreground-subtle mt-0.5 truncate",children:o})]}),r("button",{type:"button",onClick:t,className:"p-1 rounded hover:bg-muted text-foreground-subtle hover:text-foreground","aria-label":"Close panel",children:r(Je,{className:"w-4 h-4"})})]}),r("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-3",children:a}),s!==void 0&&r("footer",{className:"flex items-center gap-2 justify-end px-4 py-3 border-t border-border",children:s})]}):null}const A5={inherit:"bg-muted",on:"bg-emerald-500",off:"bg-orange-500",na:"bg-gray-300 opacity-50"};function ph({node:e,depth:t,selectedAddonId:n,onSelect:o,agentDots:s}){const a=e.addonId===n,i=s?.[e.addonId]??[];return u("div",{children:[u("button",{type:"button",onClick:()=>o(e.addonId),className:K("w-full flex items-center justify-between gap-2 text-left px-3 py-1.5 text-xs","border-l-2",a?"bg-accent border-primary text-foreground font-medium":"border-transparent hover:bg-muted/40 text-foreground"),style:{paddingLeft:`${12+t*14}px`},children:[r("span",{className:"truncate",children:e.addonName}),i.length>0&&r("span",{className:"flex items-center gap-1 shrink-0",children:i.map(l=>r("span",{title:`${l.agentNodeId}: ${l.state}`,className:K("w-2 h-2 rounded-full",A5[l.state])},l.agentNodeId))})]}),e.children.map(l=>r(ph,{node:l,depth:t+1,selectedAddonId:n,onSelect:o,agentDots:s},l.addonId))]})}function fh({tree:e,selectedAddonId:t,onSelect:n,agentDots:o,className:s}){return r("div",{className:K("flex flex-col py-2",s),children:e.map(a=>r(ph,{node:a,depth:0,selectedAddonId:t,onSelect:n,agentDots:o},a.addonId))})}function ea(e){const t=[],n=[],o=new Map;for(const a of e.slots)for(const i of a.addons){const l={addonId:i.id,addonName:i.name,slot:i.slot,inputClasses:i.inputClasses,outputClasses:i.outputClasses,children:[]};i.slot==="audio-classifier"?t.push(l):(n.push(l),o.set(i.id,l))}const s=[];for(const a of n){if(a.inputClasses.length===0){s.push(a);continue}const i=n.find(l=>l.addonId!==a.addonId&&l.outputClasses.some(c=>a.inputClasses.includes(c)));i&&i.children.push(a)}return[...s,...t]}function P5(e){return e?e.models.map(t=>({id:t.id,name:t.name})):[]}function ps({step:e,schema:t,allSchemas:n,depth:o=0,onChange:s,onDelete:a,readOnly:i=!1,toggleMode:l="simple",overrideState:c=null,onOverrideChange:d,inheritedEnabled:f,hideModelAndSettings:p=!1}){const[m,h]=$(!1),g=P5(t);if(g.length>0&&!g.some(x=>x.id===e.modelId)&&!i){const v=(t?.defaultModelId?g.find(w=>w.id===t.defaultModelId):null)??g[0];v&&v.id!==e.modelId&&queueMicrotask(()=>s({...e,modelId:v.id}))}const b=u(ve,{children:[u("div",{className:"flex-1 min-w-0",children:[r("span",{className:"text-[10px] uppercase tracking-wider font-medium text-foreground-subtle/60 block leading-none",children:e.slot}),r("span",{className:"text-sm font-semibold text-foreground truncate block leading-tight",children:e.addonName}),u("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(x=>r("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-blue-500/12 text-blue-400",children:x},x)),e.inputClasses.length>0&&e.outputClasses.length>0&&r("span",{className:"text-foreground-subtle/40 text-[10px]",children:"→"}),e.outputClasses.map(x=>r("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-green-500/12 text-green-400",children:x},x))]})]}),!i&&l==="simple"&&r("button",{onClick:x=>{x.stopPropagation(),s({...e,enabled:!e.enabled})},className:K("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors",e.enabled?"bg-success":"bg-foreground-subtle/30"),children:r("span",{className:K("inline-block h-4 w-4 rounded-full bg-white shadow transition-transform",e.enabled?"translate-x-6":"translate-x-1")})}),!i&&l==="threeState"&&d&&u("div",{className:"flex items-center gap-0.5 rounded-md border border-border p-0.5",onClick:x=>x.stopPropagation(),children:[r(Fa,{label:"Inherit",active:c===null,variant:"inherit",subtext:f===void 0?void 0:f?"on":"off",onClick:()=>d(null)}),r(Fa,{label:"On",active:c===!0,variant:"on",onClick:()=>d(!0)}),r(Fa,{label:"Off",active:c===!1,variant:"off",onClick:()=>d(!1)})]})]});return r(Om,{expanded:m,onExpandedChange:h,dimmed:!e.enabled,header:b,children:p?r("p",{className:"text-[11px] text-foreground-subtle",children:"Model and detection settings are managed per agent — open the Pipeline page for this camera's agent to edit them."}):u("div",{className:"space-y-3",children:[r(Fi,{label:"Model",value:e.modelId,disabled:i,options:g.map(x=>({value:x.id,label:x.name})),onChange:x=>s({...e,modelId:x})}),e.slot==="audio-classifier"&&e.engine&&r(Fi,{label:"Runtime",value:`${e.engine.runtime}/${e.engine.backend}`,disabled:i,options:[{value:"node/cpu",label:"Node.js — ONNX CPU"},{value:"node/coreml",label:"Node.js — Apple SoundAnalysis (macOS)"},{value:"python/cpu",label:"Python — ONNX CPU"}],onChange:x=>{const[v,w]=x.split("/");s({...e,engine:{runtime:v,backend:w,format:w==="coreml"?"coreml":"onnx"}})}}),t?.configSchema?.map(x=>r(ta,{field:x,allFields:t.configSchema??[],step:e,disabled:i,onChange:s},x.key))]})})}function Fi({label:e,value:t,options:n,disabled:o,onChange:s}){return u("div",{children:[r("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e}),u("select",{value:t,onChange:a=>s(a.target.value),disabled:o,className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground focus:outline-none focus:border-primary/50",children:[n.length===0&&r("option",{value:t,children:t||"default"}),n.map(a=>r("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]})]})}function E5({label:e,description:t,value:n,options:o,disabled:s,onChange:a}){function i(l){if(s)return;const c=n.includes(l)?n.filter(d=>d!==l):[...n,l];a(c)}return u("div",{children:[r("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1",children:e}),t&&r("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:t}),r("div",{className:"flex flex-wrap gap-1.5",children:o.map(l=>{const c=n.includes(l.value);return r("button",{type:"button",disabled:s,onClick:()=>i(l.value),className:K("text-[10px] font-medium px-2 py-1 rounded-md border transition-colors",c?"bg-primary/20 text-primary border-primary/40":"bg-surface text-foreground-subtle border-border hover:border-primary/30",s&&"opacity-50 cursor-not-allowed"),children:l.label},l.value)})})]})}function $5(e,t,n){const o=t.settings?.[e];if(o!==void 0)return o;const s=n.find(a=>"key"in a&&a.key===e);return s&&"default"in s?s.default:void 0}function ta({field:e,allFields:t,step:n,disabled:o,onChange:s}){const a=e.type!=="separator"&&e.type!=="info"?e.showWhen:void 0;if(a){const{field:l,equals:c,notEquals:d,in:f,notIn:p}=a,m=$5(l,n,t);if(c!==void 0&&m!==c||d!==void 0&&m===d||f!==void 0&&!f.includes(m)||p!==void 0&&p.includes(m))return null}function i(l){s({...n,settings:{...n.settings,[e.key]:l}})}if(e.type==="select"){const l=n.settings?.[e.key],c=typeof l=="string"?l:e.default??"";return r(Fi,{label:e.label,value:c,disabled:o||e.disabled,options:e.options,onChange:i})}if(e.type==="multiselect"){const l=n.settings?.[e.key],c=Array.isArray(l)?l:Array.isArray(e.default)?e.default:[];return r(E5,{label:e.label,description:e.description,value:c,options:e.options,disabled:o||e.disabled,onChange:i})}if(e.type==="slider"||e.type==="number"){const l=n.settings?.[e.key],c=typeof e.default=="number"?e.default:e.min??0,d=typeof l=="number"?l:c,f=e.min??0,p=e.max??1,m=e.step??.01,h=e.type==="slider"?e.showValue:!0,g="unit"in e?e.unit:void 0,b=e.type==="slider"?e.displayScale:void 0,x=b?d/b:d;return u("div",{children:[u("div",{className:"flex items-center justify-between mb-1",children:[r("span",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide",children:e.label}),h&&u("span",{className:"text-xs font-medium text-foreground tabular-nums",children:[typeof x=="number"?x.toFixed(2).replace(/\.?0+$/,""):x,g?` ${g}`:""]})]}),e.description&&r("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:e.description}),r("input",{type:"range",min:f,max:p,step:m,value:d,disabled:o||e.disabled,onChange:v=>i(Number(v.target.value)),className:"w-full accent-primary h-1.5"})]})}if(e.type==="boolean"){const l=n.settings?.[e.key],c=typeof l=="boolean"?l:e.default===!0;return u("label",{className:"flex items-center gap-2",children:[r("input",{type:"checkbox",checked:c,disabled:o||e.disabled,onChange:d=>i(d.target.checked),className:"h-3.5 w-3.5 accent-primary"}),r("span",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide",children:e.label})]})}if(e.type==="text"||e.type==="password"||e.type==="textarea"){const l=n.settings?.[e.key],c=typeof l=="string"?l:e.default??"",d=e.type==="password"?"password":"text";return u("div",{children:[r("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e.label}),e.type==="textarea"?r("textarea",{value:c,disabled:o||e.disabled,placeholder:e.placeholder,onChange:f=>i(f.target.value),rows:3,className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground focus:outline-none focus:border-primary/50 resize-y"}):r("input",{type:d,value:c,disabled:o||e.disabled,placeholder:e.placeholder,onChange:f=>i(f.target.value),className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground focus:outline-none focus:border-primary/50"})]})}return e.type==="separator"?r("div",{className:"border-t border-border my-2"}):e.type==="info"?r("div",{className:"rounded-md border border-border bg-surface px-2 py-1.5 text-[10px] text-foreground-subtle",children:e.content}):null}function Fa({label:e,active:t,variant:n,subtext:o,onClick:s}){return u("button",{type:"button",onClick:s,className:K("px-2 py-1 text-[10px] font-medium rounded transition-colors",t?n==="on"?"bg-green-500/20 text-green-400":n==="off"?"bg-red-500/20 text-red-400":"bg-primary/20 text-primary":"text-foreground-subtle hover:bg-surface-hover"),children:[e,o&&t&&u("span",{className:"ml-1 opacity-60",children:["(",o,")"]})]})}function mh(e,t){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:t.enabled,modelId:t.modelId,children:[],settings:{...t.settings}}}function _5(e,t,n){return n?{enabled:n.enabled??t.enabled,modelId:n.modelId??t.modelId,settings:n.settings??t.settings}:t}function D5({addon:e,agentDefault:t,modelsForFormat:n,onChangeAgentConfig:o}){const s=a=>{o?.({...t,...a})};return u("div",{className:"space-y-4 text-xs",children:[u("label",{className:"flex items-center gap-2",children:[r("input",{type:"checkbox",checked:t.enabled,onChange:a=>s({enabled:a.target.checked})}),u("span",{children:["Enabled on this agent (",e.name,")"]})]}),u("div",{children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle mb-1",children:"Model"}),r("select",{className:"w-full bg-surface border border-border rounded px-2 py-1 text-xs",value:t.modelId,onChange:a=>s({modelId:a.target.value}),children:n.map(a=>r("option",{value:a.id,children:a.name},a.id))})]}),(e.configSchema?.length??0)>0&&u("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Settings"}),e.configSchema?.map(a=>r(ta,{field:a,allFields:e.configSchema??[],step:mh(e,t),disabled:!1,onChange:i=>s({settings:{...i.settings}})},a.key))]})]})}function L5({addon:e,agentDefault:t,agentNodeId:n,currentPatch:o,modelsForFormat:s,onChangePatch:a}){const i=_5("device",t,o),l=h=>{const g=h.enabled!==void 0||h.modelId!==void 0||h.settings!==void 0;a?.(g?h:null)},c=h=>{const{enabled:g,...b}=o??{},x=h==="inherit"?b:{...b,enabled:h==="on"};l(x)},d=h=>{const{modelId:g,...b}=o??{},x=h===void 0?b:{...b,modelId:h};l(x)},f=h=>{const{settings:g,...b}=o??{},x=h===void 0?b:{...b,settings:h};l(x)},p=o?.enabled===void 0?"inherit":o.enabled?"on":"off",m=o?.modelId!==void 0;return u("div",{className:"space-y-4 text-xs",children:[u("div",{className:"flex items-center gap-1",children:[["inherit","on","off"].map(h=>r("button",{type:"button",onClick:()=>c(h),className:K("px-3 py-1 border border-border rounded text-xs capitalize",p===h?"bg-primary text-primary-foreground border-primary":"bg-surface text-foreground hover:bg-muted"),children:h},h)),u("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["agent default: ",r("span",{className:"font-semibold",children:t.enabled?"on":"off"})]})]}),u("div",{children:[u("div",{className:"flex items-center justify-between mb-1",children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Model"}),m?r("button",{type:"button",className:"text-[10px] text-foreground-subtle hover:text-foreground",onClick:()=>d(void 0),children:"Clear"}):r("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>d(t.modelId),children:"Override"})]}),r("select",{disabled:!m,className:"w-full bg-surface border border-border rounded px-2 py-1 text-xs disabled:opacity-50",value:m?o?.modelId??t.modelId:t.modelId,onChange:h=>d(h.target.value),children:s.map(h=>r("option",{value:h.id,children:h.name},h.id))}),!m&&u("div",{className:"text-[10px] text-foreground-subtle mt-1",children:["inherits from ",n]})]}),(e.configSchema?.length??0)>0&&(()=>{const h=o?.settings!==void 0;return u("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[u("div",{className:"flex items-center justify-between",children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Settings"}),h?r("button",{type:"button",className:"text-[10px] text-foreground-subtle hover:text-foreground",onClick:()=>f(void 0),children:"Clear"}):r("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>f({...t.settings}),children:"Override"})]}),e.configSchema?.map(g=>r(ta,{field:g,allFields:e.configSchema??[],step:mh(e,i),disabled:!h,onChange:b=>f({...b.settings})},g.key)),!h&&u("div",{className:"text-[10px] text-foreground-subtle",children:["inherits from ",n]})]})})(),u("div",{className:"rounded bg-muted/40 px-3 py-2 text-[11px] text-foreground-subtle",children:[r("div",{className:"font-semibold text-foreground mb-0.5",children:"Effective config preview"}),u("div",{className:"font-mono truncate",children:[e.id," · model: ",i.modelId," · ",i.enabled?"on":"off"]})]})]})}function na(e){const{mode:t,addon:n,agentDefault:o,agentNodeId:s,currentPatch:a,onChangeAgentConfig:i,onChangePatch:l,engineFormat:c}=e,d=Q(()=>n.models.filter(f=>!!f.formats[c]),[n.models,c]);return t==="agent"?r(D5,{addon:n,agentDefault:o,modelsForFormat:d,onChangeAgentConfig:i}):r(L5,{addon:n,agentDefault:o,agentNodeId:s,currentPatch:a,modelsForFormat:d,onChangePatch:l})}function T5(e){const t=[],n=(o,s)=>{for(const a of o)t.push({node:a,depth:s}),n(a.children,s+1)};return n(e,0),t}const Xd={detector:{label:"detector",className:"text-emerald-500"},cropper:{label:"cropper",className:"text-blue-500"},classifier:{label:"classifier",className:"text-violet-500"},refiner:{label:"refiner",className:"text-amber-500"},"audio-classifier":{label:"audio classifier",className:"text-pink-500"}};function R5({slot:e}){const t=Xd[e]??Xd.classifier;return r("span",{className:K("text-[9px] font-semibold uppercase tracking-widest leading-none",t.className),children:t.label})}const Jd="inline-flex items-center rounded bg-muted px-1.5 py-px text-[9px] font-medium text-foreground-subtle";function O5({inputs:e,outputs:t}){return e.length===0&&t.length===0?null:u("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[e.map(n=>r("span",{className:K(Jd,"bg-blue-500/10 text-blue-500"),children:n},`in-${n}`)),e.length>0&&t.length>0&&r("span",{className:"text-foreground-subtle/60 text-[9px]",children:"→"}),t.map(n=>r("span",{className:K(Jd,"bg-emerald-500/10 text-emerald-500"),children:n},`out-${n}`))]})}function z5({enabled:e,onChange:t,disabled:n}){return r("button",{type:"button",role:"switch","aria-checked":e,disabled:n,onClick:o=>{o.stopPropagation(),t(!e)},className:K("relative inline-flex h-3.5 w-7 shrink-0 items-center rounded-full transition-colors",e?"bg-emerald-500":"bg-foreground-subtle/30",n?"opacity-50 cursor-not-allowed":"cursor-pointer"),title:e?"Click to disable":"Click to enable",children:r("span",{className:K("inline-block h-3 w-3 rounded-full bg-white shadow transition-transform",e?"translate-x-3.5":"translate-x-0.5")})})}function B5(e){return e.kind==="enabled"?u("span",{className:"inline-flex items-center gap-1",children:[r("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 shrink-0"}),r("span",{className:"font-mono text-foreground",children:e.modelId})]}):e.kind==="disabled"?u("span",{className:"inline-flex items-center gap-1 text-foreground-subtle",children:[r("span",{className:"h-1.5 w-1.5 rounded-full border border-foreground-subtle/60 shrink-0"}),"off"]}):u("span",{className:"inline-flex items-center gap-1 text-foreground-subtle/70",children:[r("span",{className:"h-1.5 w-1.5 rounded-full bg-muted shrink-0"}),"n/a"]})}function F5({node:e,depth:t,agents:n,getCellState:o,onCellClick:s,selectedCell:a,toggleProps:i}){return u(ve,{children:[u("div",{className:"sticky left-0 z-10 bg-surface px-3 py-2 border-b border-border text-xs flex items-start gap-2",style:{paddingLeft:`${12+t*14}px`},children:[u("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:[r(R5,{slot:e.slot}),u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"font-semibold truncate",children:e.addonName}),r(O5,{inputs:e.inputClasses,outputs:e.outputClasses})]})]}),i&&r("span",{className:"pl-2 pt-0.5 shrink-0",children:r(z5,{enabled:i.enabled,onChange:i.onChange,disabled:i.disabled})})]}),n.map(l=>{const c=o(e.addonId,l.agentNodeId),d=a?.addonId===e.addonId&&a.agentNodeId===l.agentNodeId;return r("button",{type:"button",onClick:()=>s(e.addonId,l.agentNodeId),className:K("text-left px-3 py-1.5 border-b border-l border-border text-xs hover:bg-muted/40",c.kind==="enabled"&&"bg-emerald-500/5",c.kind==="na"&&"bg-muted/30",d&&"ring-2 ring-primary ring-inset"),children:B5(c)},l.agentNodeId)})]})}function Yl({tree:e,agents:t,getCellState:n,onCellClick:o,selectedCell:s,onToggleEnabled:a}){const i=Q(()=>T5(e),[e]),l=`minmax(320px, 1fr) repeat(${t.length}, minmax(160px, 220px))`,c=a!==void 0&&t.length===1,d=t[0]?.agentNodeId;return r("div",{className:"overflow-auto border border-border rounded",children:u("div",{className:"grid",style:{gridTemplateColumns:l},children:[r("div",{className:"sticky top-0 left-0 z-20 bg-muted/60 px-3 py-2 text-[10px] uppercase tracking-widest text-foreground-subtle border-b border-border",children:"Step"}),t.map(f=>u("div",{className:"sticky top-0 z-10 bg-muted/60 px-3 py-2 border-b border-l border-border",children:[r("div",{className:"text-xs font-semibold text-foreground",children:f.agentNodeId}),r("div",{className:"text-[10px] text-foreground-subtle truncate",children:f.engineLabel})]},f.agentNodeId)),i.map(({node:f,depth:p})=>{const m=c&&d!==void 0?n(f.addonId,d):null,h=c&&m!==null?{enabled:m.kind==="enabled",onChange:g=>a?.(f.addonId,g),disabled:m.kind==="na"}:void 0;return r(F5,{node:f,depth:p,agents:t,getCellState:n,onCellClick:o,selectedCell:s,toggleProps:h},f.addonId)})]})})}const hh=typeof globalThis<"u"?globalThis.__camstackTrpcReact:void 0,C=hh??tw();typeof globalThis<"u"&&!hh&&(globalThis.__camstackTrpcReact=C);const Zl=un("camstack:system",null);function Xl({system:e,children:t}){return r(Zl.Provider,{value:e,children:t})}function Le(){const e=ye(Zl);if(!e)throw new Error("useSystem(): no <SystemProvider> in tree");return e}function j5(){return ye(Zl)}function dt(e,t){const n=Le(),o=ne(t);o.current=t;const[s,a]=$(n.connectionVersion);Y(()=>n.subscribeConnectionEvents((i,l)=>{i==="connected"&&a(l)}),[n]),Y(()=>n.subscribeEvent(e,l=>{o.current(l)}),[n,e,s])}function ji(e){const t=ne(e);return t.current=e,t}function Ar(e,t){const[n,o]=$(null),s=ji(t);return dt(e,a=>{const i=a.data,l=s.current;l&&!l(i)||o(i)}),n}function Jl(e,t,n){const[o,s]=$(()=>new Map),a=ji(t),i=ji(n);dt(e,c=>{const d=c.data,f=i.current;if(f&&!f(d))return;const p=a.current(d);s(m=>{const h=new Map(m);return h.set(p,d),h})});const l=Q(()=>Array.from(o.values()),[o]);return{map:o,values:l}}function Pr(){const{data:e,isLoading:t}=C.nodes.topology.useQuery(void 0,{staleTime:6e4}),o=Ar("cluster.topology-snapshot")?.nodes??e;return{nodes:Q(()=>{const a=[];for(const i of o??[])a.push({id:String(i.id??""),name:String(i.name??i.id??""),shortName:i.isHub?"HUB":String(i.name??i.id??""),isHub:!!i.isHub,isOnline:!!i.isOnline,localIps:i.localIps??[],addons:(i.addons??[]).map(l=>({addonId:l.id,capabilities:l.capabilities}))});return a.sort((i,l)=>i.isHub!==l.isHub?i.isHub?-1:1:i.name.localeCompare(l.name)),a},[o]),isLoading:t}}function gh({selectedNodeId:e,onSelect:t,label:n="Node",hideIcon:o=!1,alwaysShow:s=!1}){const{nodes:a}=Pr();return!s&&a.length<=1?null:u("div",{className:"flex items-center gap-1.5",children:[!o&&r(Ek,{className:"h-3.5 w-3.5 text-foreground-subtle"}),n&&r("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:n}),r("div",{className:"flex rounded-md border border-border overflow-hidden text-[11px] font-medium",children:a.map((i,l)=>{const c=e===i.id;return r("button",{type:"button",onClick:()=>t(i.id),disabled:!i.isOnline,title:i.isOnline?i.name:`${i.name} (offline)`,className:K("px-2.5 py-1 transition-colors",c?"bg-primary/15 text-primary":"bg-transparent text-foreground-subtle hover:bg-surface-hover hover:text-foreground",l>0&&"border-l border-border",!i.isOnline&&"opacity-50 cursor-not-allowed"),children:i.shortName},i.id)})})]})}const H5={online:{colorClass:"bg-success",label:"Online"},offline:{colorClass:"bg-danger",label:"Offline"},degraded:{colorClass:"bg-warning",label:"Degraded"},unknown:{colorClass:"bg-foreground-subtle",label:"Unknown"}};function V5({status:e,showDot:t=!0,showLabel:n=!0,size:o="sm",className:s}){const a=H5[e];return u("span",{className:K("inline-flex items-center gap-1.5",o==="sm"?"text-xs":"text-sm",s),children:[t&&r("span",{className:K("h-1.5 w-1.5 shrink-0 rounded-full",a.colorClass),"aria-hidden":"true"}),n&&r("span",{className:"text-foreground",children:a.label})]})}const q5={frigate:{colorClass:"bg-provider-frigate",label:"Frigate"},scrypted:{colorClass:"bg-provider-scrypted",label:"Scrypted"},reolink:{colorClass:"bg-provider-reolink",label:"Reolink"},homeAssistant:{colorClass:"bg-provider-homeAssistant",label:"Home Assistant"},rtsp:{colorClass:"bg-provider-rtsp",label:"RTSP"}};function Q5({provider:e,showLabel:t=!0,className:n}){const o=q5[e];return u("span",{className:K("inline-flex items-center gap-1.5 text-xs",n),children:[r("span",{className:K("h-1.5 w-1.5 shrink-0 rounded-sm",o.colorClass),"aria-hidden":"true"}),t&&r("span",{className:"text-foreground",children:o.label})]})}const U5={success:"bg-emerald-400 text-emerald-950",warning:"bg-amber-400 text-amber-950",danger:"bg-red-400 text-red-950",info:"bg-blue-400 text-blue-950",neutral:"bg-foreground-subtle/20 text-foreground"};function bh({children:e,variant:t="neutral",mono:n,className:o}){return r("span",{className:K("inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-bold leading-tight",n&&"font-mono",U5[t],o),children:e})}function K5({version:e,preRelease:t,className:n}){const o=t??/-(alpha|beta|rc|dev|canary|next)/i.test(e);return r(bh,{variant:o?"warning":"success",mono:!0,className:n,children:e})}function G5({label:e,description:t,error:n,required:o,children:s,orientation:a="vertical",className:i}){const l=a==="horizontal";return u("div",{className:K("flex gap-2",l?"flex-row items-center justify-between":"flex-col",i),children:[u("div",{className:K(l?"flex-1":""),children:[u(Fl,{children:[e,o&&r("span",{className:"text-danger ml-0.5",children:"*"})]}),t&&r("p",{className:"text-foreground-subtle text-xs mt-0.5",children:t})]}),r("div",{className:K(l?"shrink-0":""),children:s}),n&&r("p",{className:"text-danger text-xs",children:n})]})}function W5({title:e,subtitle:t,actions:n,className:o}){return u("div",{className:K("flex flex-col gap-2 mb-3 sm:flex-row sm:items-center sm:justify-between",o),children:[u("div",{children:[r("h1",{className:"text-sm font-semibold text-foreground",children:e}),t&&r("p",{className:"text-foreground-subtle text-xs",children:t})]}),n&&r("div",{className:"flex items-center gap-2 flex-wrap",children:n})]})}function ko({icon:e,title:t,description:n,action:o,className:s}){return u("div",{className:K("flex flex-col items-center justify-center gap-3 py-12",s),children:[e&&r(e,{className:"h-12 w-12 text-foreground-subtle","aria-hidden":"true"}),u("div",{className:"flex flex-col items-center gap-1 text-center",children:[r("p",{className:"text-foreground-muted text-sm font-medium",children:t}),n&&r("p",{className:"text-foreground-subtle text-xs max-w-xs",children:n})]}),o&&r("div",{className:"mt-1",children:o})]})}const xh=un("camstack:confirm-dialog",null);function rt(){const e=ye(xh);if(!e)throw new Error("useConfirm must be used within ConfirmDialogProvider");return e.confirm}function yh({children:e}){const[t,n]=$(null),o=q(c=>new Promise(d=>{n({...c,resolve:d})}),[]),s=()=>{t?.resolve(!0),n(null)},a=()=>{t?.resolve(!1),n(null)},i={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600 text-white"},warning:{icon:"text-orange-400",button:"bg-orange-500 hover:bg-orange-600 text-white"},default:{icon:"text-primary",button:"bg-primary hover:bg-primary/90 text-white"}},l=t?i[t.variant??"default"]:i.default;return u(xh.Provider,{value:{confirm:o},children:[e,t&&u("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[r("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:a}),u("div",{className:"relative z-10 w-full max-w-sm mx-4 rounded-xl border border-border bg-surface shadow-2xl overflow-hidden animate-in fade-in zoom-in-95 duration-150",onClick:c=>c.stopPropagation(),children:[u("div",{className:"px-5 pt-5 pb-4",children:[r("h3",{className:"text-sm font-semibold text-foreground",children:t.title}),r("p",{className:"mt-2 text-xs text-foreground-subtle leading-relaxed",children:t.message})]}),u("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-border bg-surface-hover/30",children:[r("button",{type:"button",onClick:a,className:"px-3 py-1.5 text-xs font-medium rounded-md border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:t.cancelLabel??"Cancel"}),r("button",{type:"button",onClick:s,className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${l.button}`,children:t.confirmLabel??"Confirm"})]})]})]})]})}function Y5({value:e,label:t,trend:n,className:o}){return u(Ge,{className:K("flex flex-col gap-1",o),children:[u("div",{className:"flex items-baseline gap-2",children:[r("span",{className:"text-2xl font-semibold text-foreground",children:e}),n&&u("span",{className:K("inline-flex items-center gap-0.5 text-xs font-medium",n.direction==="up"?"text-success":"text-danger"),children:[n.direction==="up"?r(Yk,{className:"h-3 w-3"}):r(Xk,{className:"h-3 w-3"}),n.value,"%"]})]}),r("span",{className:"text-xs text-foreground-muted",children:t})]})}function Z5({items:e,className:t}){return r("dl",{className:K("flex flex-col",t),children:e.map(n=>u("div",{className:"flex items-center h-7",children:[r("dt",{className:"text-foreground-subtle text-xs w-1/3 shrink-0",children:n.key}),r("dd",{className:"text-foreground text-xs",children:n.value})]},n.key))})}function X5({children:e,maxHeight:t=300,className:n}){const[o,s]=$(!1),a=q(()=>{navigator.clipboard.writeText(e).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)})},[e]);return u("div",{className:K("relative group",n),children:[r(Ul,{style:{maxHeight:t},children:r("pre",{className:"font-mono text-xs bg-surface p-3 rounded-md border border-border-subtle",children:r("code",{children:e})})}),r("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:r(Bl,{icon:o?wo:Mn,"aria-label":"Copy code",variant:"ghost",size:"sm",onClick:a})})]})}function J5({filters:e,values:t,onChange:n,className:o}){const s=Xn(),[a,i]=$(!1),l=(d,f)=>{n({...t,[d]:f})},c=Object.values(t).filter(d=>d!==void 0&&d!=="").length;if(s){const d=e.find(p=>p.type==="search"),f=e.some(p=>p.type!=="search");return u("div",{className:K("flex items-center gap-2",o),children:[d&&r(Ss,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:p=>l(d.key,p.target.value),leftSlot:r(oo,{className:"h-3 w-3 text-foreground-subtle"}),className:"flex-1"}),f&&u(ve,{children:[u("button",{onClick:()=>i(!0),className:"flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-foreground-muted hover:bg-surface-hover transition-colors shrink-0",children:[r(Rk,{className:"h-3.5 w-3.5"}),"Filters",c>0&&r(cr,{variant:"info",className:"ml-1 text-[10px] px-1 py-0",children:c})]}),r(Ql,{open:a,onClose:()=>i(!1),title:"Filters",children:r("div",{className:"flex flex-col gap-3",children:e.filter(p=>p.type!=="search").map(p=>{switch(p.type){case"select":return u("div",{children:[r("label",{className:"text-xs text-foreground-muted mb-1 block",children:p.label}),r(Cs,{options:p.options,value:t[p.key]??"",onChange:m=>l(p.key,m.target.value),className:"w-full"})]},p.key);case"badge-toggle":return r("div",{className:"flex items-center gap-1 flex-wrap",children:p.options.map(m=>{const g=t[p.key]===m.value;return r("button",{type:"button",onClick:()=>l(p.key,g?void 0:m.value),children:r(cr,{variant:g?"info":"default",className:"cursor-pointer",children:m.label})},m.value)})},p.key);default:return null}})})})]})]})}return r("div",{className:K("flex items-center gap-2 flex-wrap",o),children:e.map(d=>{switch(d.type){case"search":return r(Ss,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:f=>l(d.key,f.target.value),leftSlot:r(oo,{className:"h-3 w-3 text-foreground-subtle"}),className:"w-48"},d.key);case"select":return r(Cs,{options:d.options,value:t[d.key]??"",onChange:f=>l(d.key,f.target.value),className:"w-36"},d.key);case"badge-toggle":return r("div",{className:"flex items-center gap-1",children:d.options.map(f=>{const m=t[d.key]===f.value;return r("button",{type:"button",onClick:()=>l(d.key,m?void 0:f.value),children:r(cr,{variant:m?"info":"default",className:"cursor-pointer",children:f.label})},f.value)})},d.key);default:return null}})})}function Hi({label:e,icon:t,href:n,badge:o,active:s=!1,className:a}){return u("a",{href:n,className:K("flex items-center gap-2 h-7 px-2 text-[11px] transition-colors",s?"border-l-2 border-primary bg-primary/[0.08] text-foreground rounded-r-md":"text-foreground-subtle hover:bg-surface-hover rounded-md",a),children:[r(t,{className:"h-3.5 w-3.5 shrink-0"}),r("span",{className:"truncate flex-1",children:e}),o!==void 0&&r(cr,{className:"ml-auto text-[10px] px-1.5 py-0",children:o})]})}function Vi({logo:e,sections:t,footer:n,onNavigate:o,className:s}){return u("nav",{className:K("bg-surface border-r border-border h-full flex flex-col",s),children:[e&&r("div",{className:"px-3 py-2 shrink-0",children:e}),r("div",{className:"flex-1 overflow-auto px-1 py-1",children:t.map((a,i)=>u("div",{className:K(i>0?"mt-3":""),children:[a.label&&r("span",{className:"text-[10px] text-foreground-disabled uppercase tracking-wider px-2 mb-1 block",children:a.label}),r("div",{className:"flex flex-col gap-0.5",onClick:o,children:a.items.map(l=>r(Hi,{...l},l.href))})]},i))}),n&&n.length>0&&u("div",{className:"shrink-0 px-1 pb-1",children:[r(jl,{className:"mb-1"}),r("div",{className:"flex flex-col gap-0.5",onClick:o,children:n.map(a=>r(Hi,{...a},a.href))})]})]})}function eS({sidebar:e,header:t,mobileLogo:n,mobileActions:o,children:s,className:a}){const i=Xn(),[l,c]=$(!1);return u("div",{className:K("flex h-screen",a),children:[!i&&r(Vi,{...e,className:K("w-44",e.className)}),i&&r(Kl,{open:l,onClose:()=>c(!1),width:"w-64",children:r(Vi,{...e,onNavigate:()=>c(!1),className:"w-full border-r-0"})}),u("div",{className:"flex flex-1 flex-col min-w-0",children:[i&&u("header",{className:"flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm",children:[r("button",{onClick:()=>c(!0),className:"p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors","aria-label":"Open menu",children:r(nk,{className:"h-5 w-5"})}),n&&r("div",{className:"flex-1 flex justify-center",children:n}),o&&r("div",{className:"shrink-0",children:o})]}),!i&&t&&u("header",{className:"flex items-center h-10 border-b border-border px-4 shrink-0",children:[t.breadcrumbs&&t.breadcrumbs.length>0&&r("nav",{className:"flex items-center gap-1 text-xs flex-1 min-w-0",children:t.breadcrumbs.map((d,f)=>{const p=f===t.breadcrumbs.length-1;return u("span",{className:"flex items-center gap-1",children:[f>0&&r(Cn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),d.href&&!p?r("a",{href:d.href,className:"text-foreground-subtle hover:text-foreground transition-colors truncate",children:d.label}):r("span",{className:"text-foreground truncate",children:d.label})]},f)})}),t.actions&&r("div",{className:"flex items-center gap-2 ml-auto shrink-0",children:t.actions})]}),r("main",{className:"flex-1 overflow-auto p-4",children:s})]})]})}const tS={online:"bg-success",offline:"bg-danger",warning:"bg-warning",unknown:"bg-foreground-subtle"};function nS({title:e,subtitle:t,status:n,selected:o,onClick:s,badges:a,actions:i,offlineAction:l,className:c}){const d=n==="offline";return u("div",{onClick:s,className:K("w-full rounded-lg border p-3 text-left transition-colors",s&&"cursor-pointer",o?"border-primary bg-primary/10":"border-border bg-surface hover:bg-surface-hover",d&&!o&&"opacity-50",c),children:[u("div",{className:"flex items-center justify-between mb-2",children:[r("span",{className:"text-sm font-medium truncate",children:e}),n&&r("span",{className:K("h-2 w-2 rounded-full shrink-0",tS[n])})]}),t&&r("div",{className:"text-[11px] text-foreground-muted",children:t}),a&&a.length>0&&r("div",{className:"flex flex-wrap gap-1 mt-2",children:a.map((f,p)=>{const m=K("rounded px-1.5 py-0.5 text-[10px] flex items-center gap-0.5",o?"bg-primary/20":"bg-surface-hover",f.onClick&&"hover:opacity-80 transition-opacity cursor-pointer");return f.onClick?u("button",{onClick:h=>{h.stopPropagation(),f.onClick()},className:m,children:[f.icon,f.label]},p):u("span",{className:m,children:[f.icon,f.label]},p)})}),!d&&i&&i.length>0&&r("div",{className:"flex items-center gap-0.5 mt-2 -mb-1",children:i.map((f,p)=>r("button",{onClick:m=>{m.stopPropagation(),f.onClick()},className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",title:f.label,"aria-label":f.label,children:f.icon},p))}),d&&l&&r("div",{className:"mt-2",onClick:f=>f.stopPropagation(),children:l})]})}function rS({children:e,minCardWidth:t=220,gap:n=3,className:o}){return r("div",{className:K("p-4 overflow-y-auto flex-1 content-start",o),style:{display:"grid",gridTemplateColumns:`repeat(auto-fill, minmax(${t}px, 1fr))`,gap:`${n*4}px`},children:e})}const oS="capability.binding-changed";function kt(e,t){const[n,o]=$(null);return Y(()=>{if(t===null){o(null);return}let s=!1;const a=async()=>{try{const l=await e.deviceManager.getBindings.query({deviceId:t});s||o(l)}catch{s||o(l=>l)}};a();const i=e.live?.onEvent.subscribe({category:oS},{onData:l=>{const c=l.data?.source;if(!c){a();return}c.type==="device"&&c.id===t&&a()}});return()=>{s=!0,i?.unsubscribe()}},[e,t]),Q(()=>n?nw(e,n):null,[e,n])}function on(e){const t=q(o=>e?e.subscribe(()=>o()):()=>{},[e]),n=q(()=>e?.value,[e]);return Ws(t,n,n)}function vh(e,t,n){const o=kt(e,t),s=o?n(o.state):void 0;return on(s)}function Er(e){const t=kt(e.trpc,e.deviceId),n=t!==null?e.slice(t):void 0,o=on(n),s=t!==null?e.cap(t):void 0,c=(e.requireFeature===void 0||(e.deviceFeatures??[]).includes(e.requireFeature))&&s!==void 0&&o!==void 0;return{dev:t,cap:s,slice:o,available:c}}function sS(e){return e.parentDeviceId===null?"top-level":e.role?"accessory":"adopted"}const aS={minimal:{showIntegrationIcon:!1,showParentBadge:!1,showSnapshot:!1,showBattery:!1,showStableId:!1,showId:!1,showSwitchToggle:!0,showChildrenAccordion:!1},compact:{showIntegrationIcon:!0,showParentBadge:!0,showSnapshot:!0,showBattery:!0,showStableId:!1,showId:!1,showSwitchToggle:!0,showChildrenAccordion:!0},expanded:{showIntegrationIcon:!1,showParentBadge:!0,showSnapshot:!0,showBattery:!0,showStableId:!0,showId:!0,showSwitchToggle:!0,showChildrenAccordion:!0}};function iS(e){const t=aS[e.variant??"compact"];return{showIntegrationIcon:e.showIntegrationIcon??t.showIntegrationIcon,showParentBadge:e.showParentBadge??t.showParentBadge,showSnapshot:e.showSnapshot??t.showSnapshot,showBattery:e.showBattery??t.showBattery,showStableId:e.showStableId??t.showStableId,showId:e.showId??t.showId,showSwitchToggle:e.showSwitchToggle??t.showSwitchToggle,showChildrenAccordion:e.showChildrenAccordion??t.showChildrenAccordion}}const lS={siren:Ys,floodlight:Am,spotlight:Lm,"pir-sensor":$m,chime:lk,autotrack:wm,nightvision:Rl,"privacy-mask":Cm,doorbell:Nm},cS={camera:Tl,hub:zi,nvr:zi,light:Am,siren:Ys,switch:Kk,sensor:$m,thermostat:Qk,button:g2,generic:zl};function wh(e){return e.role?lS[e.role]??zl:cS[e.type.toLowerCase()]??Tl}const Nh={"native-snapshot":V2,"two-way-audio":Pm,"pan-tilt-zoom":wm,"ptz-autotrack":J2,"doorbell-button":Nm,"motion-trigger":yn,"battery-operated":ym,rebootable:Dm},kh={"native-snapshot":"Native snapshot","two-way-audio":"Two-way audio","pan-tilt-zoom":"Pan-Tilt-Zoom","ptz-autotrack":"PTZ autotrack","doorbell-button":"Doorbell button","motion-trigger":"Motion trigger","battery-operated":"Battery operated",rebootable:"Rebootable"},dS={"native-snapshot":"snapshot",rebootable:"reboot","pan-tilt-zoom":"ptz","ptz-autotrack":"ptz-autotrack","two-way-audio":"intercom","motion-trigger":"motion-trigger"},Sh=new Set(["camera","hub","nvr"]);function Ch(e){return!Sh.has(e.type.toLowerCase())}function eu(e){return e.role?!0:!Sh.has(e.type.toLowerCase())}function Mh(e){return(e.features??[]).includes("motion-trigger")}function uS(e){if(e.length<=24)return e;const t=e.lastIndexOf(":");if(t>=0&&t<e.length-4)return e.slice(t+1);const n=e.split("-");if(n.length>2){const o=n.slice(-2).join("-");if(o.length>=6)return o}return`…${e.slice(-18)}`}function pS({trpc:e,accessoryChildren:t,adoptedChildren:n,onNavigate:o}){return u("div",{className:"border-t border-border-subtle/50",children:[n.length>0&&r(tu,{trpc:e,label:"Adopted devices",rows:n,onNavigate:o}),t.length>0&&r(tu,{trpc:e,label:"Accessories",rows:t,onNavigate:o})]})}function tu({trpc:e,label:t,rows:n,onNavigate:o}){return u("div",{children:[r("div",{className:"px-3 pt-1.5 pb-1 text-[9px] font-semibold uppercase tracking-wide text-foreground-subtle",children:t}),r("ul",{children:n.map(s=>r(fS,{trpc:e,child:s,onNavigate:o},s.id))})]})}function fS({trpc:e,child:t,onNavigate:n}){const o=!t.disabled,s=o&&Ch(t),a=o&&Mh(t),i=wh(t);return r("li",{children:u("div",{onClick:l=>{l.stopPropagation(),n(t.id)},className:"w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-surface-hover transition-colors cursor-pointer",children:[r(i,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),r("span",{className:"text-[10.5px] text-foreground flex-1 truncate",children:t.name}),a&&r(hS,{trpc:e,deviceId:t.id,features:t.features}),s&&r(mS,{trpc:e,deviceId:t.id}),r("span",{className:K("h-1.5 w-1.5 rounded-full flex-shrink-0",t.online?"bg-success":"bg-foreground-subtle/40"),title:t.online?"Online":"Offline"})]})})}function mS({trpc:e,deviceId:t}){const{dev:n,cap:o,slice:s,available:a}=Er({trpc:e,deviceId:t,cap:p=>p.switch,slice:p=>p.state.switch}),[i,l]=$(!1);if(n!==null&&!o)return null;const c=s?.on===!0,d={transform:c?"translateX(14px)":"translateX(2px)"},f=async p=>{if(p.stopPropagation(),!(i||!a||!o)){l(!0);try{await o.setState({on:!c})}finally{l(!1)}}};return r("button",{type:"button",onClick:p=>{f(p)},disabled:i||!a,className:K("relative inline-flex h-4 w-7 items-center rounded-full border transition-colors flex-shrink-0",c?"bg-success/30 border-success/50":"bg-surface-hover border-border",i&&"opacity-60",!a&&"opacity-40 cursor-not-allowed"),title:a?c?"Turn off":"Turn on":"Awaiting state…","aria-pressed":c,children:r("span",{className:K("absolute h-3 w-3 rounded-full transition-all",c?"bg-success":"bg-foreground-subtle"),style:d})})}function hS({trpc:e,deviceId:t,features:n}){const{dev:o,cap:s,slice:a,available:i}=Er({trpc:e,deviceId:t,cap:p=>p.motionTrigger,slice:p=>p.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:n}),[l,c]=$(!1);if(o!==null&&!s)return null;const d=a?.enabled===!0,f=async p=>{if(p.stopPropagation(),!(l||!i||!s)){c(!0);try{await s.setMotionTrigger({enabled:!d})}finally{c(!1)}}};return r("button",{type:"button",onClick:p=>{f(p)},disabled:l||!i,className:K("inline-flex h-4 w-4 items-center justify-center rounded transition-colors flex-shrink-0",d?"text-primary bg-primary/10":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover",(l||!i)&&"opacity-50"),title:i?d?"Motion-trigger: on (click to disable)":"Motion-trigger: off (click to enable)":"Awaiting state…","aria-pressed":d,children:r(yn,{className:"h-2.5 w-2.5"})})}function Ih({trpc:e,device:t,flags:n}){if(!!t.disabled)return null;const s=t.type.toLowerCase(),a=n.showSwitchToggle&&Ch(t),i=Mh(t),l=s==="hub"||s==="nvr",c=(t.features??[]).includes("rebootable"),d=l&&c;return u(ve,{children:[i&&r(bS,{trpc:e,deviceId:t.id,features:t.features}),a&&r(gS,{trpc:e,deviceId:t.id}),d&&r(yS,{trpc:e,deviceId:t.id})]})}function gS({trpc:e,deviceId:t}){const{dev:n,cap:o,slice:s,available:a}=Er({trpc:e,deviceId:t,cap:p=>p.switch,slice:p=>p.state.switch}),[i,l]=$(!1);if(n!==null&&!o)return null;const c=s?.on===!0,d={transform:c?"translateX(14px)":"translateX(2px)"},f=async p=>{if(p.stopPropagation(),!(i||!a||!o)){l(!0);try{await o.setState({on:!c})}finally{l(!1)}}};return r("button",{type:"button",onClick:p=>{f(p)},disabled:i||!a,className:K("relative inline-flex h-4 w-7 items-center rounded-full border transition-colors flex-shrink-0",c?"bg-success/30 border-success/50":"bg-surface-hover border-border",i&&"opacity-60",!a&&"opacity-40 cursor-not-allowed"),title:a?c?"Turn off":"Turn on":"Awaiting state…","aria-pressed":c,children:r("span",{className:K("absolute h-3 w-3 rounded-full transition-all",c?"bg-success":"bg-foreground-subtle"),style:d})})}function bS({trpc:e,deviceId:t,features:n}){const{dev:o,cap:s,slice:a,available:i}=Er({trpc:e,deviceId:t,cap:p=>p.motionTrigger,slice:p=>p.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:n}),[l,c]=$(!1);if(o!==null&&!s)return null;const d=a?.enabled===!0,f=async p=>{if(p.stopPropagation(),!(l||!i||!s)){c(!0);try{await s.setMotionTrigger({enabled:!d})}finally{c(!1)}}};return r("button",{type:"button",onClick:p=>{f(p)},disabled:l||!i,className:K("inline-flex h-4 w-4 items-center justify-center rounded transition-colors flex-shrink-0",d?"text-primary bg-primary/10":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover",(l||!i)&&"opacity-50"),title:i?d?"Motion-trigger: on (click to disable)":"Motion-trigger: off (click to enable)":"Awaiting state…","aria-pressed":d,children:r(yn,{className:"h-2.5 w-2.5"})})}const ja=168,xS=4;function yS({trpc:e,deviceId:t}){const{dev:n,cap:o}=Er({trpc:e,deviceId:t,cap:x=>x.reboot,slice:()=>{}}),s=ne(null),a=ne(null),[i,l]=$(null),[c,d]=$(!1),f=n!==null&&o!==void 0&&o!==null,p=i!==null,m=()=>l(null),h=()=>{const x=s.current;if(!x)return;const v=x.getBoundingClientRect(),w=v.right-ja,y=Math.max(8,Math.min(w,window.innerWidth-ja-8)),N=v.bottom+xS;l({top:N,left:y})};if(Y(()=>{if(!p)return;const x=w=>{const y=s.current,N=a.current,k=w.target;k!==null&&(y&&y.contains(k)||N&&N.contains(k)||m())},v=w=>{w.key==="Escape"&&(w.stopPropagation(),m())};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v)}},[p]),n!==null&&!o)return null;const g=x=>{x.stopPropagation(),p?m():h()},b=async()=>{if(!(c||!f||!o)){d(!0),m();try{await o.reboot({})}finally{d(!1)}}};return u(ve,{children:[r("button",{ref:s,type:"button",onClick:g,disabled:c||!f,className:K("inline-flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors flex-shrink-0",(c||!f)&&"opacity-50",p&&"bg-surface-hover text-foreground"),title:"More actions","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":p,children:r(km,{className:"h-3 w-3"})}),i&&vo(r("div",{ref:a,role:"menu",style:{position:"fixed",top:i.top,left:i.left,width:ja},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-1",onClick:x=>x.stopPropagation(),children:u("button",{type:"button",role:"menuitem",onClick:()=>{b()},disabled:c||!f,className:K("flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-[11px] text-foreground","hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed"),children:[r(Dm,{className:"h-3 w-3 shrink-0 text-foreground-subtle"}),r("span",{children:"Reboot device"})]})}),document.body)]})}const vS=Object.freeze([]);function wS(e){return e==="native"?"native":"enhanced"}function NS(e){return e.map(t=>({kind:"marker",feature:t}))}function kS(e,t){const n=new Map,o=t.entries??[];for(const a of o)n.set(a.capName,a);const s=[];for(const a of e){const i=dS[a];if(i===void 0){s.push({kind:"marker",feature:a});continue}const l=n.get(i);l&&s.push({kind:wS(l.kind),feature:a,capName:i})}return s}function SS(e,t,n){const[o,s]=$(null),[a,i]=$(!1),[l,c]=$(!0);return Y(()=>{if(t===null){s(null),i(!1),c(!1);return}let d=!1;c(!0),i(!1);const f=async()=>{try{const m=await e.deviceManager.getBindings.query({deviceId:t});if(d)return;s(m),c(!1)}catch{if(d)return;i(!0),c(!1)}};f();const p=e.live?.onEvent.subscribe({category:"capability.binding-changed"},{onData:m=>{const h=m.data?.source;if(!h){f();return}h.type==="device"&&h.id===t&&f()}});return()=>{d=!0,p?.unsubscribe()}},[e,t]),n.length===0?{loading:l,resolved:vS}:l||a||!o?{loading:l,resolved:NS(n)}:{loading:!1,resolved:kS(n,o)}}const CS=[];function Ah({trpc:e,device:t,flags:n,accessoryCount:o,adoptedCount:s,showFeatureRow:a=!1}){const i=o+s,l=n.showChildrenAccordion&&i>0,c=t.features??CS,d=a&&c.length>0,{resolved:f}=SS(e,d?t.id:null,c),p=d&&f.length>0;return!l&&!p?null:u("div",{className:"flex items-center gap-1.5 flex-nowrap whitespace-nowrap min-w-0",children:[l&&r(MS,{accessoryCount:o,adoptedCount:s}),p&&r(IS,{resolved:f})]})}function MS({accessoryCount:e,adoptedCount:t}){const n=e+t;if(n===0)return null;const o=t>0&&e>0?`${String(t)} adopted · ${String(e)} accessor${e===1?"y":"ies"}`:t>0?`${String(t)} adopted`:`${String(e)} accessor${e===1?"y":"ies"}`;return u("span",{className:"text-[9px] font-medium text-foreground-subtle bg-surface-elevated/60 rounded px-1.5 py-0.5 flex-shrink-0",title:o,children:["+",n]})}const Ph=240,nu=200;function IS({resolved:e}){const t=ne(null),[n,o]=$(null);return u("span",{ref:t,className:"relative inline-flex items-center gap-1 cursor-help",onMouseEnter:()=>{const i=t.current;if(!i)return;const l=i.getBoundingClientRect(),f=window.innerHeight-l.bottom>=nu?l.bottom+4:l.top-nu-4,p=Math.max(8,Math.min(l.left,window.innerWidth-Ph-8));o({top:f,left:p})},onMouseLeave:()=>o(null),children:[e.map(i=>{const l=Nh[i.feature];return l?r("span",{className:"inline-flex items-center justify-center h-4 w-4 rounded bg-surface-elevated/60 text-foreground-subtle",title:kh[i.feature]??i.feature,children:r(l,{className:"h-2.5 w-2.5"})},i.feature):null}),n&&vo(r(AS,{resolved:e,position:n}),document.body)]})}function AS({resolved:e,position:t}){return u("div",{style:{position:"fixed",top:t.top,left:t.left,width:Ph,pointerEvents:"none"},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-2",children:[r("h5",{className:"text-[9px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5",children:"Features"}),r("ul",{className:"space-y-0.5",children:e.map(n=>r(PS,{entry:n},n.feature))})]})}function PS({entry:e}){const t=Nh[e.feature],n=kh[e.feature]??e.feature;return u("li",{className:"flex items-center justify-between gap-2 text-[10px]",children:[u("span",{className:"flex items-center gap-1.5 text-foreground",children:[t&&r(t,{className:"h-3 w-3 text-foreground-subtle"}),r("span",{children:n})]}),r(ES,{kind:e.kind})]})}function ES({kind:e}){return e==="marker"?r("span",{className:"text-[8.5px] px-1 rounded text-foreground-subtle",title:"Informational marker (no cap registered)",children:"marker"}):r("span",{className:K("text-[8.5px] px-1 rounded",e==="native"?"bg-success/15 text-success":"bg-primary/15 text-primary"),children:e})}function Eh({device:e,variant:t,flags:n,parent:o,integrationIcon:s,hasChildren:a,expanded:i,onToggleExpand:l,onNavigateToParent:c}){const d=wh(e);return u("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[n.showChildrenAccordion&&a?r("button",{type:"button",onClick:f=>{f.stopPropagation(),l()},className:"flex h-3.5 w-3.5 items-center justify-center text-foreground-subtle hover:text-foreground transition-colors flex-shrink-0","aria-label":i?"Collapse children":"Expand children","aria-expanded":i,children:i?r(Yn,{className:"h-3 w-3"}):r(Cn,{className:"h-3 w-3"})}):n.showChildrenAccordion?r("span",{className:"h-3.5 w-3.5 flex-shrink-0"}):null,r(d,{className:K("text-foreground-subtle flex-shrink-0",t==="minimal"?"h-3 w-3":"h-3.5 w-3.5")}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.showIntegrationIcon&&s&&r("span",{className:"flex-shrink-0",children:s}),r("span",{className:K("font-semibold text-foreground truncate",t==="minimal"?"text-[10.5px]":"text-[11px]"),title:e.name,children:e.name})]}),(n.showId||n.showStableId)&&u("div",{className:"mt-0.5 flex items-center gap-1 text-[9px] text-foreground-subtle font-mono truncate",title:n.showStableId?`stableId: ${e.stableId}`:void 0,children:[n.showId&&u("span",{className:"flex-shrink-0 tabular-nums",children:["#",String(e.id)]}),n.showId&&n.showStableId&&r("span",{className:"flex-shrink-0 opacity-50",children:"·"}),n.showStableId&&r("span",{className:"truncate",children:uS(e.stableId)})]}),n.showParentBadge&&o&&u("button",{type:"button",onClick:f=>{f.stopPropagation(),c(o.id)},className:"mt-0.5 inline-flex max-w-full items-center gap-1 text-[9px] text-foreground-subtle hover:text-primary transition-colors",title:`Open parent: ${o.name} (#${String(o.id)})`,children:[r(zi,{className:"h-2.5 w-2.5 shrink-0"}),u("span",{className:"truncate",children:["Under: ",o.name]})]})]})]})}function ec(e,t){return vh(e,t,o=>o.battery)??null}function tc(e,t){const n=kt(e,t),o=ne(!1),{data:s,isLoading:a,isFetching:i,refetch:l}=Kn({queryKey:["device",t,"snapshot"],queryFn:()=>{if(!n)throw new Error("useDeviceSnapshotImage: device proxy not ready");const f=o.current;return o.current=!1,n.snapshot?.getSnapshot({force:f})??null},enabled:n!==null&&t!==null,staleTime:1e4,gcTime:1440*60*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:!1}),c=s?`data:${s.contentType};base64,${s.base64}`:null;function d(){o.current=!0,l()}return{src:c,loading:a||i,refresh:d}}function $S(e){return e<=10?WN:e<=30?KN:e>=95?QN:ym}function _S(e,t){return t!=="none"?"text-emerald-400":e<=10?"text-rose-400":e<=30?"text-amber-400":"text-foreground-subtle"}function nc({status:e,variant:t="compact",className:n}){if(!e)return null;const o=$S(e.percentage),s=_S(e.percentage,e.charging),a=e.charging==="solar"?Lm:e.charging==="dc"?fk:null,i=e.sleeping;return u("span",{className:K("inline-flex items-center gap-1 text-[10px] font-medium",s,n),title:`Battery: ${Math.round(e.percentage)}%`+(e.charging!=="none"?` · charging (${e.charging})`:"")+(e.sleeping?" · sleeping":""),children:[r(o,{className:"h-3.5 w-3.5"}),u("span",{children:[Math.round(e.percentage),"%"]}),a&&r(a,{className:"h-3 w-3"}),i&&r(Rl,{className:"h-3 w-3 text-blue-300"}),t==="full"&&e.charging!=="none"&&r("span",{className:"text-foreground-subtle",children:e.charging})]})}function $h({trpc:e,device:t,status:n,enabled:o,showStatusPills:s=!1}){const a=o&&t.online,i=tc(e,a?t.id:null),l=(t.features??[]).includes("battery-operated"),c=s&&l&&!t.disabled,d=ec(e,c?t.id:null);return!o&&!c?null:u("span",{className:"inline-flex items-center gap-1.5 flex-nowrap whitespace-nowrap",children:[c&&d&&r(nc,{status:d}),o&&r(DS,{deviceName:t.name,snapshotUrl:i.src,status:n})]})}const Ha=288,ru=196,Va=8;function DS({deviceName:e,snapshotUrl:t,status:n}){const o=ne(null),[s,a]=$(null),i=n==="offline"||n==="disabled",l=()=>{const d=o.current;if(!d)return;const f=d.getBoundingClientRect(),p=f.top,m=window.innerHeight-f.bottom,h=p<ru+Va&&m>p,g=h?f.bottom+Va:f.top-ru-Va,b=f.right-Ha,x=Math.max(8,Math.min(b,window.innerWidth-Ha-8));a({top:g,left:x,placeBelow:h})},c=()=>a(null);return u(ve,{children:[r("button",{ref:o,type:"button",onClick:d=>d.stopPropagation(),onMouseEnter:l,onMouseLeave:c,onFocus:l,onBlur:c,className:"flex h-6 w-6 items-center justify-center rounded text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors flex-shrink-0",title:"Preview","aria-label":"Preview snapshot",children:r(Xs,{className:"h-3.5 w-3.5"})}),s&&vo(u("div",{style:{position:"fixed",top:s.top,left:s.left,width:Ha,pointerEvents:"none"},className:"rounded-lg border border-border bg-surface shadow-lg shadow-black/30 z-[9999] overflow-hidden",children:[r("div",{className:"h-40 bg-background flex items-center justify-center",children:t&&!i?r("img",{src:t,alt:e,className:"h-full w-full object-cover"}):r("span",{className:"text-xs text-foreground-subtle",children:n==="offline"?"Offline — no snapshot":n==="disabled"?"Disabled":"No snapshot yet"})}),r("div",{className:"px-3 py-2",children:r("p",{className:"text-xs font-semibold text-foreground truncate",children:e})})]}),document.body)]})}function _h({status:e}){const t=e==="disabled"?"bg-warning":e==="online"?"bg-success":"bg-danger",n=e==="disabled"?"Disabled":e==="online"?"Online":"Offline";return r("span",{className:K("h-1.5 w-1.5 rounded-full flex-shrink-0",t),title:n})}function so(e){const{trpc:t,device:n,parent:o,integrationIcon:s,onNavigate:a,className:i}=e,l=iS(e),c=e.variant??"compact",d=e.view??"card",f=!n.disabled,p=n.isCamera??n.type.toLowerCase()==="camera",m=e.children??[],h=m.filter(eu),g=m.filter(M=>!eu(M)),b=m.length>0,[x,v]=$(!1),w=e.expanded??x,y=e.onToggleExpand??(()=>v(M=>!M)),N=M=>{a?.(M)},k=e.indentLevel??(e.isAccessoryRow?2:0),S=f?n.online?"online":"offline":"disabled";return d==="table"?r(TS,{trpc:t,device:n,variant:c,flags:l,parent:o??null,integrationIcon:s??null,accessoryCount:h.length,adoptedCount:g.length,hasChildren:b,expanded:w,onToggleExpand:y,onNavigate:N,displayStatus:S,isCamera:p,showSnapshot:l.showSnapshot&&p,isAccessoryRow:e.isAccessoryRow??!1,indentLevel:k,className:i}):u("div",{className:K("rounded-lg border border-border bg-surface transition-colors",!f&&"opacity-60",i),children:[u("div",{onClick:()=>N(n.id),className:K("flex items-center gap-2 cursor-pointer hover:border-foreground-subtle/30 w-full",c==="minimal"?"px-2.5 py-1.5":"px-3 py-2.5"),children:[r(Eh,{device:n,variant:c,flags:l,parent:o??null,integrationIcon:s??null,hasChildren:b,expanded:w,onToggleExpand:y,onNavigateToParent:N}),r(Ah,{trpc:t,device:n,flags:l,accessoryCount:h.length,adoptedCount:g.length,showFeatureRow:!1}),r($h,{trpc:t,device:n,status:S,enabled:l.showSnapshot&&p,showStatusPills:!0}),r(Ih,{trpc:t,device:n,flags:l}),r(_h,{status:S})]}),w&&b&&r(pS,{trpc:t,accessoryChildren:h,adoptedChildren:g,onNavigate:N})]})}const LS={0:"pl-2",1:"pl-6",2:"pl-8"};function TS(e){const{trpc:t,device:n,variant:o,flags:s,parent:a,integrationIcon:i,accessoryCount:l,adoptedCount:c,hasChildren:d,expanded:f,onToggleExpand:p,onNavigate:m,displayStatus:h,isCamera:g,showSnapshot:b,isAccessoryRow:x,indentLevel:v,className:w}=e;return u("tr",{onClick:()=>m(n.id),className:K("cursor-pointer hover:bg-surface-hover transition-colors",!s.showChildrenAccordion&&"border-b border-border-subtle/40",x&&"bg-foreground-subtle/[0.03]",w),children:[r("td",{className:K("py-2 align-middle pr-2",LS[v]),children:r(Eh,{device:n,variant:o,flags:s,parent:a,integrationIcon:i,hasChildren:d,expanded:f,onToggleExpand:p,onNavigateToParent:m})}),r("td",{className:"px-2 py-2 align-middle text-[10px] text-foreground-subtle whitespace-nowrap",children:n.type}),r("td",{className:"px-2 py-2 align-middle",children:r(Ah,{trpc:t,device:n,flags:s,accessoryCount:l,adoptedCount:c,showFeatureRow:!0})}),r("td",{className:"px-2 py-2 align-middle",children:r($h,{trpc:t,device:n,status:h,enabled:b&&g,showStatusPills:!0})}),r("td",{className:"px-2 py-2 align-middle text-right whitespace-nowrap",children:u("span",{className:"inline-flex items-center gap-1.5",children:[r(Ih,{trpc:t,device:n,flags:s}),r(_h,{status:h})]})})]})}function Dh(e,t){const[n,o]=$(e);return Y(()=>{const s=setTimeout(()=>o(e),t);return()=>clearTimeout(s)},[e,t]),n}const RS=new Set(["hub","nvr"]);function OS(e){const t=new Map;for(const s of e)t.set(s.id,s);const n=[],o=new Map;for(const s of e){const a=s.parentDeviceId;if(a==null){n.push(s);continue}const i=t.get(a);if(!i){n.push(s);continue}const l=s.role!==null&&s.role!==void 0;if(RS.has(i.type)&&!l){n.push(s);continue}const d=o.get(a);d?d.push(s):o.set(a,[s])}return{topLevel:n,accessoriesByParent:o}}const ou=2;function zS(e,t){if(t<=1)return[{kind:"page",n:1}];if(t<=7){const a=[];for(let i=1;i<=t;i++)a.push({kind:"page",n:i});return a}const n=[],o=Math.max(2,e-ou),s=Math.min(t-1,e+ou);n.push({kind:"page",n:1}),o>2&&n.push({kind:"ellipsis",side:"left"});for(let a=o;a<=s;a++)n.push({kind:"page",n:a});return s<t-1&&n.push({kind:"ellipsis",side:"right"}),n.push({kind:"page",n:t}),n}function BS({currentPage:e,totalItems:t,pageSize:n,onPageChange:o,itemNoun:s="devices"}){if(t<=n)return null;const a=Math.ceil(t/n),i=(e-1)*n+1,l=Math.min(e*n,t),c=zS(e,a);return u("div",{className:"flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle",children:[u("span",{children:["Showing ",i,"–",l," of ",t," ",s]}),u("span",{className:"inline-flex items-center gap-1",children:[r("button",{type:"button","aria-label":"Previous page",disabled:e===1,onClick:()=>o(e-1),className:K("inline-flex items-center justify-center h-7 w-7 rounded border border-border bg-surface text-foreground-subtle","hover:text-foreground hover:bg-surface-hover transition-colors","disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-surface"),children:r(l2,{className:"h-3 w-3"})}),c.map((d,f)=>{if(d.kind==="ellipsis")return r("span",{className:"px-1 text-foreground-subtle/60 select-none",children:"…"},`e-${f}`);const p=d.n===e;return r("button",{type:"button",onClick:()=>o(d.n),className:K("inline-flex items-center justify-center h-7 min-w-7 px-1.5 rounded border text-[10.5px] font-medium transition-colors",p?"border-primary/40 bg-primary/10 text-primary":"border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),children:d.n},`p-${d.n}`)}),r("button",{type:"button","aria-label":"Next page",disabled:e===a,onClick:()=>o(e+1),className:K("inline-flex items-center justify-center h-7 w-7 rounded border border-border bg-surface text-foreground-subtle","hover:text-foreground hover:bg-surface-hover transition-colors","disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-surface"),children:r(Cn,{className:"h-3 w-3"})})]})]})}function FS({view:e,onViewChange:t,types:n,currentType:o,onTypeChange:s,addons:a,currentAddon:i,onAddonChange:l,hideAddons:c=!1}){return u("div",{className:"flex items-center gap-2 flex-wrap",children:[u("span",{className:"inline-flex border border-border rounded-md overflow-hidden",children:[r("button",{type:"button",onClick:()=>t("cards"),className:K("inline-flex items-center justify-center h-7 w-8 transition-colors",e==="cards"?"bg-primary/10 text-primary":"bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),"aria-label":"Cards view",children:r(W2,{className:"h-3.5 w-3.5"})}),r("button",{type:"button",onClick:()=>t("table"),className:K("inline-flex items-center justify-center h-7 w-8 border-l border-border transition-colors",e==="table"?"bg-primary/10 text-primary":"bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),"aria-label":"Table view",children:r(Hk,{className:"h-3.5 w-3.5"})})]}),n&&n.length>0&&u(ve,{children:[r(su,{children:"Type"}),r(qa,{active:o===null,onClick:()=>s(null),children:"All"}),n.map(d=>r(qa,{active:o===d,onClick:()=>s(o===d?null:d),children:jS(d)},d))]}),!c&&a&&a.length>0&&u(ve,{children:[r(su,{children:"Integration"}),a.map(d=>r(qa,{active:i===d.id,icon:d.icon,onClick:()=>l(i===d.id?null:d.id),showClearIcon:i===d.id,children:d.name},d.id))]})]})}function su({children:e}){return r("span",{className:"text-[10px] font-medium uppercase tracking-wider text-foreground-subtle ml-1",children:e})}function qa({active:e,icon:t,onClick:n,showClearIcon:o,children:s}){return u("button",{type:"button",onClick:n,className:K("inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full border text-[10.5px] font-medium transition-colors",e?"border-primary/40 bg-primary/15 text-primary":"border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),children:[t&&r("span",{className:"inline-flex items-center",children:t}),r("span",{children:s}),e&&o&&r(Je,{className:"h-2.5 w-2.5 opacity-70"})]})}function jS(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function HS({variant:e,onClearFilters:t}){return u("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r(Q2,{className:"h-8 w-8 text-foreground-subtle/40 mb-3"}),r("p",{className:"text-sm font-medium text-foreground-subtle",children:e==="filtered"?"No devices match the current filters":"No devices yet"}),e==="filtered"&&t&&r("button",{type:"button",onClick:t,className:"mt-2 text-[11px] text-primary hover:underline",children:"Clear filters"})]})}function qt(e,t){if(e==="root")return t;switch(t){case"view":return"deviceView";case"page":return"devicePage";case"type":return"deviceType";case"q":return"deviceQ";case"addon":return"deviceAddon"}}function au(e){try{const t=localStorage.getItem(`camstack:${e}:lastFilters`);if(!t)return{};const n=JSON.parse(t);return typeof n!="object"||n===null?{}:n}catch{return{}}}function VS(e,t){try{localStorage.setItem(`camstack:${e}:lastFilters`,JSON.stringify(t))}catch{}}function iu(e,t,n){const o=new URLSearchParams(window.location.search),s=o.get(qt(e,"view")),a=s==="cards"||s==="table"?s:n.view??t,i=o.get(qt(e,"page")),l=i?parseInt(i,10):1,c=Number.isFinite(l)&&l>=1?l:1,d=o.get(qt(e,"addon"))??n.addon??null,f=o.get(qt(e,"type"))??n.type??null,p=o.get(qt(e,"q"))??n.q??"";return{view:a,page:c,addon:d,type:f,q:p}}function qS(e,t,n){const o=new URLSearchParams(window.location.search),s=(l,c)=>{c===null||c===""?o.delete(l):o.set(l,c)};s(qt(e,"view"),t.view===n?null:t.view),s(qt(e,"page"),t.page===1?null:String(t.page)),s(qt(e,"addon"),t.addon),s(qt(e,"type"),t.type),s(qt(e,"q"),t.q||null);const a=o.toString(),i=a?`${window.location.pathname}?${a}`:window.location.pathname;window.history.replaceState(null,"",i)}function QS(e){const{scope:t,defaultView:n,lsKey:o}=e,[s,a]=$(()=>{const g=au(o);return iu(t,n,g)}),i=ne(s);i.current=s,Y(()=>{const g=()=>{const b=au(o),x=iu(t,n,b);i.current=x,a(x)};return window.addEventListener("popstate",g),()=>window.removeEventListener("popstate",g)},[t,n,o]);const l=q(g=>{const b=g(i.current);i.current=b,a(b),qS(t,b,n),VS(o,{view:b.view,addon:b.addon,type:b.type,q:b.q})},[t,n,o]),c=q(g=>l(b=>({...b,view:g})),[l]),d=q(g=>l(b=>({...b,page:g})),[l]),f=q(g=>l(b=>({...b,addon:g,page:1})),[l]),p=q(g=>l(b=>({...b,type:g,page:1})),[l]),m=q(g=>l(b=>({...b,q:g,page:1})),[l]),h=q(()=>l(g=>({...g,addon:null,type:null,q:"",page:1})),[l]);return{state:s,setView:c,setPage:d,setAddon:f,setType:p,setQ:m,clearFilters:h}}const US={cards:24,table:50};function ao(e){const{devices:t,trpc:n,defaultView:o="table",filters:s,forceAddon:a,resolveIntegrationIcon:i,resolveParent:l,onNavigate:c,pageSize:d=US,urlScope:f="root",lsKey:p=f==="root"?"devices":"integrations:nested"}=e,m=QS({scope:f,defaultView:o,lsKey:p}),h=m.state.view,g=h==="cards"?d.cards:d.table,[b,x]=$(m.state.q),v=Dh(b,300);Y(()=>{v!==m.state.q&&m.setQ(v)},[v]);const w=a??m.state.addon,y=Q(()=>{const O=m.state.q.toLowerCase().trim();return t.filter(A=>!(w&&A.addonId!==w||m.state.type&&A.type!==m.state.type||O&&!A.name.toLowerCase().includes(O)&&!A.stableId.toLowerCase().includes(O)))},[t,w,m.state.type,m.state.q]),N=Q(()=>OS(y),[y]),k=Q(()=>{if(m.state.q.trim()==="")return new Set;const O=m.state.q.toLowerCase().trim(),A=new Set;for(const[D,_]of N.accessoriesByParent.entries())_.some(R=>R.name.toLowerCase().includes(O)||R.stableId.toLowerCase().includes(O))&&A.add(D);return A},[N.accessoriesByParent,m.state.q]),S=N.topLevel.length,M=Math.max(1,Math.ceil(S/g)),P=Math.min(m.state.page,M),I=(P-1)*g,F=N.topLevel.slice(I,I+g);Y(()=>{P!==m.state.page&&m.setPage(P)},[P]),XS();const E=w!=null||m.state.type!==null||m.state.q!=="",B=S===0;return u("div",{className:"flex flex-col gap-3",children:[u("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[r(FS,{view:h,onViewChange:m.setView,types:s?.types,currentType:m.state.type,onTypeChange:m.setType,addons:s?.addons,currentAddon:m.state.addon,onAddonChange:m.setAddon,hideAddons:a!==void 0}),u("div",{className:"relative",children:[r(oo,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle pointer-events-none"}),r("input",{type:"text",value:b,onChange:O=>x(O.target.value),placeholder:"Search by name or stableId","aria-label":"Search devices by name or stableId",className:"h-7 pl-7 pr-2.5 rounded-md border border-border bg-surface text-[11px] text-foreground placeholder:text-foreground-subtle/60 focus:outline-none focus:ring-1 focus:ring-primary/40 w-56"})]})]}),B?r(HS,{variant:E?"filtered":"nofilter",onClearFilters:E?m.clearFilters:void 0}):h==="cards"?r(KS,{rows:F,accessoriesByParent:N.accessoriesByParent,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:c??null}):r(YS,{rows:F,accessoriesByParent:N.accessoriesByParent,autoExpandedParents:k,devices:y,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:c??null}),r(BS,{currentPage:P,totalItems:S,pageSize:g,onPageChange:m.setPage}),a===void 0&&E&&S>0&&u("p",{className:"text-[11px] text-foreground-subtle",children:["Showing ",S," of ",t.length," devices",w&&u(ve,{children:[" ","· filtered by"," ",r("strong",{className:"text-primary",children:s?.addons?.find(O=>O.id===w)?.name??w})]})]})]})}function KS({rows:e,accessoriesByParent:t,trpc:n,resolveIntegrationIcon:o,resolveParent:s,onNavigate:a}){return r("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.map(i=>{const l=t.get(i.id)??[];return r(so,{trpc:n,device:i,view:"card",integrationIcon:o?.(i.addonId)??null,parent:i.parentDeviceId!==null?s?.(i.parentDeviceId)??null:null,children:l,onNavigate:a??void 0},i.id)})})}const GS=new Set(["hub","nvr"]);function WS(e,t){return e.parentDeviceId===null||t===null?0:GS.has(t.toLowerCase())?1:0}function YS({rows:e,accessoriesByParent:t,autoExpandedParents:n,devices:o,trpc:s,resolveIntegrationIcon:a,resolveParent:i,onNavigate:l}){const c=Q(()=>{const d=new Map;for(const f of o)d.set(f.id,f.type);return d},[o]);return r("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:u("table",{className:"w-full border-collapse",children:[r("thead",{children:u("tr",{className:"border-b border-border",children:[r("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle",children:"Name"}),r("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-24",children:"Type"}),r("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Features"}),r("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-20",children:"Preview"}),r("th",{className:"text-right px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Actions"})]})}),r("tbody",{children:e.map(d=>{const f=t.get(d.id)??[],p=f.length>0,m=n.has(d.id),h=d.parentDeviceId!==null?i?.(d.parentDeviceId)??null:null,g=d.parentDeviceId!==null?c.get(d.parentDeviceId)??null:null;return r(ZS,{parent:d,accessories:f,hasAccessories:p,forceExpanded:m,trpc:s,integrationIcon:a?.(d.addonId)??null,parentRowParent:h,indentLevel:WS(d,g),onNavigate:l??null},d.id)})})]})})}function ZS({parent:e,accessories:t,hasAccessories:n,forceExpanded:o,trpc:s,integrationIcon:a,parentRowParent:i,indentLevel:l,onNavigate:c}){const[d,f]=$(o),p=ne(o);return Y(()=>{p.current!==o&&(f(o),p.current=o)},[o]),u(ve,{children:[r(so,{trpc:s,device:e,view:"table",integrationIcon:a,parent:i,children:t,onNavigate:c??void 0,showChildrenAccordion:n,expanded:d,onToggleExpand:()=>f(g=>!g),indentLevel:l}),n&&d&&t.map(g=>r(so,{trpc:s,device:g,view:"table",integrationIcon:null,parent:null,isAccessoryRow:!0,showChildrenAccordion:!1,onNavigate:c??void 0},g.id))]})}function XS(){ke()}function JS({options:e,value:t,onChange:n}){return r("div",{className:"flex flex-wrap gap-2",children:e.map(o=>{const s=o.id===t;return u("button",{onClick:()=>o.available&&n(o.id),disabled:!o.available,className:`flex items-center gap-2 rounded-lg border px-3 py-2 text-xs font-medium transition-all ${s?"border-primary/40 bg-primary/10 text-primary":o.available?"border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground":"border-border/40 bg-surface/40 text-foreground-subtle/40 cursor-not-allowed"}`,children:[r(A2,{className:"h-3.5 w-3.5 shrink-0"}),o.label,o.isBest&&u("span",{className:"inline-flex items-center gap-0.5 rounded-full bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-amber-400",children:[r(Bk,{className:"h-2.5 w-2.5"}),"Best"]}),o.platformScore!=null&&u("span",{className:"text-[10px] text-foreground-subtle/60",children:["(",o.platformScore,")"]}),r("span",{className:`h-1.5 w-1.5 rounded-full ${o.available?"bg-success":"bg-danger"}`})]},o.id)})})}function eC(e,t){const n=new Set(t.slots.flatMap(i=>i.addons.map(l=>l.id))),o=[];function s(i){if(!n.has(i.addonId))return o.push(`Addon "${i.addonId}" is no longer available — step removed`),null;const l=t.slots.flatMap(f=>f.addons).find(f=>f.id===i.addonId);let c=i.modelId;if(l&&!l.models.some(f=>f.id===c)){const f=l.defaultModelId;o.push(`Model "${c}" not available for ${i.addonId} — using "${f}"`),c=f}const d=i.children.map(f=>s(f)).filter(f=>f!==null);return{...i,modelId:c,children:d}}const a=e.map(i=>s(i)).filter(i=>i!==null);return{valid:o.length===0,steps:a,warnings:o}}function tC(e){const t=new Map;for(const n of e.slots)for(const o of n.addons)t.set(o.id,o);return t}function Qa(e){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:!0,modelId:e.defaultModelId,children:[]}}function Ua({addon:e,onClick:t}){return r("button",{type:"button",onClick:t,className:"w-full rounded-lg border border-dashed border-border/60 px-3 py-2.5 text-left transition-all hover:border-primary/30 hover:bg-surface/60 group",children:u("div",{className:"flex items-center gap-3",children:[r(v2,{className:"h-[18px] w-[18px] text-foreground-subtle/30 group-hover:text-primary/60 shrink-0"}),u("div",{className:"flex-1 min-w-0",children:[r("span",{className:"text-[13px] font-medium text-foreground-subtle/50 group-hover:text-foreground-subtle block truncate",children:e.name}),u("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(n=>r("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-blue-500/8 text-blue-400/50",children:n},n)),e.inputClasses.length>0&&e.outputClasses.length>0&&r("span",{className:"text-foreground-subtle/25 text-[10px]",children:"→"}),e.outputClasses.map(n=>r("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-green-500/8 text-green-400/50",children:n},n))]})]})]})})}function rc({schema:e,steps:t,onChange:n,templates:o,selectedTemplateId:s,onSelectTemplate:a,onSaveTemplate:i,onUpdateTemplate:l,onDeleteTemplate:c,readOnly:d=!1,excludeAddons:f=[],hideTemplates:p=!1,showOnlyEnabled:m=!1,showSlotLabels:h=!1,toggleMode:g="simple",overrides:b={},onOverrideChange:x,inheritedEnabledByAddon:v={},hideModelAndSettings:w=!1}){const y=H=>({toggleMode:g,hideModelAndSettings:w,...g==="threeState"?{overrideState:b[H]!==void 0?b[H]:null,onOverrideChange:x?T=>x(H,T):void 0,inheritedEnabled:v[H]}:{}}),N=Q(()=>new Set(f),[f]),k=Q(()=>tC(e),[e]),[S,M]=$([]),P=s?JSON.stringify(t)!==JSON.stringify(o.find(H=>H.id===s)?.steps):!1;function I(H){const T=H.target.value||null;if(T){const W=o.find(G=>G.id===T);if(W){const G=eC(W.steps,e);M([...G.warnings])}}else M([]);a(T)}function F(){s&&l(s,t)}function E(){const H=window.prompt("Template name:");H?.trim()&&i(H.trim(),t)}function B(){if(!s)return;const H=o.find(T=>T.id===s);H&&window.confirm(`Delete template "${H.name}"?`)&&c(s)}function O(H){n(t.map(T=>T.addonId!==H.addonId?T:A(H)))}function A(H){const T=H.children.some(W=>W.enabled||W.children.some(G=>G.enabled));return{...H,enabled:H.enabled||T,children:H.children.map(W=>{const G=W.children.some(ee=>ee.enabled);return{...W,enabled:W.enabled||G}})}}function D(H,T){const W=Qa(T);n(t.map(G=>G.addonId!==H?G:{...G,children:[...G.children,W]}))}function _(H){const T=new Set;for(const W of H){T.add(W.addonId);for(const ee of W.children)T.add(ee.addonId);const G=_(W.children);for(const ee of G)T.add(ee)}return T}const R=_(t);function L(H){const T=k.get(H.addonId);if(!T)return[];const G=e.slots.find(X=>X.id===T.slot)?.parentSlot==null,ee=T.childSlots,se=new Set(H.children.map(X=>X.addonId)),te=[];for(const X of e.slots)if(ee.includes(X.id))for(const re of X.addons){if(se.has(re.id)||N.has(re.id))continue;const ge=re.inputClasses.length===0;if(ge&&!G)continue;(ge||re.inputClasses.some(U=>H.outputClasses.includes(U)))&&te.push(re)}return te}function z(H){const T=m?{...H,children:H.children.filter(G=>G.enabled).map(G=>({...G,children:G.children.filter(ee=>ee.enabled)}))}:H,W=m?[]:L(T);return u("div",{className:"space-y-1.5",children:[r(ps,{step:T,schema:k.get(T.addonId)??null,allSchemas:k,onChange:O,onDelete:d?void 0:G=>n(t.filter(ee=>ee.addonId!==G)),readOnly:d,...y(T.addonId)}),(T.children.length>0||W.length>0)&&u("div",{className:"ml-4 pl-3 border-l border-border/60 space-y-1.5",children:[h&&r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/40",children:"Slot: Cropper / Classifier"}),T.children.map(G=>{const ee=L(G);return u("div",{className:"space-y-1.5",children:[r(ps,{step:G,schema:k.get(G.addonId)??null,allSchemas:k,depth:1,onChange:se=>{O({...T,children:T.children.map(te=>te.addonId===se.addonId?se:te)})},onDelete:d?void 0:se=>{O({...T,children:T.children.filter(te=>te.addonId!==se)})},readOnly:d,...y(G.addonId)}),(G.children.length>0||ee.length>0)&&u("div",{className:"ml-4 pl-3 border-l border-border/40 space-y-1.5",children:[h&&r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/30",children:"Slot: Recognizer"}),G.children.map(se=>r(ps,{step:se,schema:k.get(se.addonId)??null,allSchemas:k,depth:2,onChange:te=>{O({...T,children:T.children.map(X=>X.addonId===G.addonId?{...X,children:X.children.map(re=>re.addonId===te.addonId?te:re)}:X)})},onDelete:d?void 0:te=>{O({...T,children:T.children.map(X=>X.addonId===G.addonId?{...X,children:X.children.filter(re=>re.addonId!==te)}:X)})},readOnly:d,...y(se.addonId)},se.addonId)),!d&&ee.map(se=>r(Ua,{addon:se,onClick:()=>{const te=Qa(se);O({...T,children:T.children.map(X=>X.addonId===G.addonId?{...X,children:[...X.children,te]}:X)})}},se.id))]})]},G.addonId)}),!d&&W.map(G=>r(Ua,{addon:G,onClick:()=>D(T.addonId,G)},G.id))]})]},T.addonId)}const j=e.slots.filter(H=>H.parentSlot===null).sort((H,T)=>H.priority-T.priority);return u("div",{className:"space-y-4",children:[!p&&r("div",{className:"rounded-lg border border-border bg-surface p-3",children:u("div",{className:"flex items-center gap-2",children:[r("div",{className:"relative flex-1 min-w-0",children:u("select",{value:s??"",onChange:I,className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:border-primary/50",children:[r("option",{value:"",children:"No template"}),o.map(H=>r("option",{value:H.id,children:H.name},H.id))]})}),P&&r("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500 shrink-0"}),r("button",{onClick:F,disabled:!s||d,title:"Save",className:K("p-2 rounded-lg border border-border transition-colors",s&&!d?"text-foreground-subtle hover:bg-surface-hover":"text-foreground-subtle/30 cursor-not-allowed"),children:r(kk,{className:"h-4 w-4"})}),r("button",{onClick:E,disabled:d,title:"Save As",className:K("p-2 rounded-lg border border-border transition-colors",d?"text-foreground-subtle/30 cursor-not-allowed":"text-foreground-subtle hover:bg-surface-hover"),children:r(C2,{className:"h-4 w-4"})}),r("button",{onClick:B,disabled:!s||d,title:"Delete",className:K("p-2 rounded-lg border border-border transition-colors",s&&!d?"text-foreground-subtle hover:text-danger":"text-foreground-subtle/30 cursor-not-allowed"),children:r(rn,{className:"h-4 w-4"})})]})}),S.length>0&&u("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 text-xs text-amber-400 space-y-1",children:[u("div",{className:"flex items-center justify-between",children:[r("span",{className:"font-medium",children:"Template loaded with warnings:"}),r("button",{onClick:()=>M([]),className:"text-amber-400/60 hover:text-amber-400",children:r(Je,{className:"h-3.5 w-3.5"})})]}),S.map((H,T)=>u("div",{children:["• ",H]},T))]}),j.map(H=>{const T=t.filter(te=>te.slot===H.id&&!N.has(te.addonId)),W=m?T.filter(te=>te.enabled):T,G=m?[]:H.addons.filter(te=>!R.has(te.id)&&!N.has(te.id)),ee=new Map,se=[];for(const te of W)te.group?(ee.has(te.group)||ee.set(te.group,[]),ee.get(te.group).push(te)):se.push(te);return u("div",{className:"space-y-2",children:[h&&u("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50",children:["Slot: ",H.label]}),se.map(te=>z(te)),[...ee.entries()].map(([te,X])=>u("div",{className:"space-y-2 rounded-lg border border-border/40 p-2",children:[r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50 px-1",children:te}),X.map(re=>z(re))]},te)),!d&&G.map(te=>r(Ua,{addon:te,onClick:()=>{n([...t,Qa(te)])}},te.id))]},H.id)})]})}const Qr={person:"#3b82f6",vehicle:"#f59e0b",animal:"#22c55e",face:"#a855f7",plate:"#ec4899",bird:"#14b8a6",dog:"#84cc16",cat:"#f97316",car:"#f59e0b",truck:"#d97706",bus:"#b45309",motorcycle:"#eab308",bicycle:"#ca8a04",motion:"#facc15"},lu=["#ef4444","#8b5cf6","#06b6d4","#f97316","#10b981","#6366f1","#e11d48","#0891b2","#7c3aed","#059669"],Lh="#f59e42";function ct(e,t){if(t?.[e])return t[e];if(t?.[e.toLowerCase()])return t[e.toLowerCase()];if(Qr[e])return Qr[e];if(Qr[e.toLowerCase()])return Qr[e.toLowerCase()];let n=0;for(let o=0;o<e.length;o++)n=n*31+(e.codePointAt(o)??0)>>>0;return lu[n%lu.length]??Lh}function nC({src:e,imageWidth:t,imageHeight:n,detections:o=[],classColors:s,aspectRatio:a,className:i,placeholder:l,showConfidence:c=!0,minConfidence:d=0,borderWidth:f=2}){function p(v){return ct(v,s)}const m=a??(t&&n?`${t}/${n}`:"16/9"),h=o.filter(v=>v.score>=d),g=h.filter(v=>v.kind==="first-level"),b=h.filter(v=>v.kind==="detail"),x=sC(b,v=>v.parentId??"");return r("div",{className:K("rounded-lg border border-border bg-surface overflow-hidden relative",i),style:{aspectRatio:m},children:e?u(ve,{children:[r("img",{src:e,className:"absolute inset-0 w-full h-full object-fill",alt:""}),h.map((v,w)=>v.debug?.mask&&v.debug.maskWidth&&v.debug.maskHeight?r(rC,{mask:v.debug.mask,maskWidth:v.debug.maskWidth,maskHeight:v.debug.maskHeight,bbox:v.bbox,imageWidth:t,imageHeight:n,color:p(v.macroClass)},`mask-${w}`):null),g.map(v=>{const w=x.get(v.id)??[];return r(cu,{detection:v,imageWidth:t,imageHeight:n,color:p(v.macroClass),showConfidence:c,borderWidth:v.debug?.mask?1:f,children:w.map(y=>r(oC,{child:y,parentBbox:v.bbox,color:p(y.macroClass),showConfidence:c},`child-${y.id}`))},`det-${v.id}`)}),b.filter(v=>!v.parentId||!g.some(w=>w.id===v.parentId)).map(v=>r(cu,{detection:v,imageWidth:t,imageHeight:n,color:p(v.macroClass),showConfidence:c,borderWidth:f},`orphan-${v.id}`))]}):r("div",{className:"w-full h-full flex items-center justify-center text-foreground-subtle text-sm",children:l??"No image loaded"})})}function cu({detection:e,imageWidth:t,imageHeight:n,color:o,showConfidence:s,borderWidth:a,children:i}){const{x:l,y:c,width:d,height:f}=e.bbox,p=u("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"2px"},children:[u("span",{className:"text-[10px] px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:o},children:[e.macroClass,s&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((m,h)=>u("span",{className:"text-[9px] font-semibold px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:ct(m.label)},children:[m.label," ",(m.score*100).toFixed(0),"%"]},`${e.id}-lbl-${h}`))]});return u("div",{className:"absolute rounded-sm",style:{left:`${l/t*100}%`,top:`${c/n*100}%`,width:`${d/t*100}%`,height:`${f/n*100}%`,borderWidth:`${a}px`,borderStyle:"solid",borderColor:o},children:[p,i]})}function rC({mask:e,maskWidth:t,maskHeight:n,bbox:o,imageWidth:s,imageHeight:a,color:i}){const l=ne(null);return Y(()=>{const c=l.current;if(!c)return;const d=c.getContext("2d");if(!d)return;const f=atob(e),p=new Uint8Array(f.length);for(let v=0;v<f.length;v++)p[v]=f.charCodeAt(v);const m=parseInt(i.slice(1,3),16),h=parseInt(i.slice(3,5),16),g=parseInt(i.slice(5,7),16);c.width=t,c.height=n;const b=d.createImageData(t,n),x=t*n;for(let v=0;v<x;v++){const w=v<p.length?p[v]:0,y=v*4;w>0&&(b.data[y]=m,b.data[y+1]=h,b.data[y+2]=g,b.data[y+3]=120)}d.putImageData(b,0,0)},[e,t,n,i]),r("canvas",{ref:l,className:"absolute pointer-events-none",style:{left:`${o.x/s*100}%`,top:`${o.y/a*100}%`,width:`${o.width/s*100}%`,height:`${o.height/a*100}%`,imageRendering:"pixelated"}})}function oC({child:e,parentBbox:t,color:n,showConfidence:o}){if(t.width<=0||t.height<=0)return null;const s=(e.bbox.x-t.x)/t.width*100,a=(e.bbox.y-t.y)/t.height*100,i=e.bbox.width/t.width*100,l=e.bbox.height/t.height*100;return r("div",{className:"absolute rounded-sm",style:{left:`${Math.max(0,s)}%`,top:`${Math.max(0,a)}%`,width:`${Math.min(100,i)}%`,height:`${Math.min(100,l)}%`,borderWidth:"1px",borderStyle:"solid",borderColor:n},children:u("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"1px"},children:[u("span",{className:"text-[9px] px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:n},children:[e.macroClass,o&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((c,d)=>u("span",{className:"text-[8px] font-semibold px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:ct(c.label)},children:[c.label," ",(c.score*100).toFixed(0),"%"]},`${e.id}-lbl-${d}`))]})})}function sC(e,t){const n=new Map;for(const o of e){const s=t(o),a=n.get(s)??[];a.push(o),n.set(s,a)}return n}function aC({detections:e,classColors:t,className:n,hiddenKeys:o,onToggleVisibility:s}){const a=t;if(e.length===0)return r("div",{className:"text-sm text-foreground-subtle italic text-center py-4",children:"No detections"});const i=e.filter(f=>f.kind==="first-level"),l=e.filter(f=>f.kind==="detail"),c=new Map;for(const f of l){if(!f.parentId)continue;const p=c.get(f.parentId)??[];p.push(f),c.set(f.parentId,p)}const d=l.filter(f=>!f.parentId||!i.some(p=>p.id===f.parentId));return u("div",{className:n,children:[u("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Detections (",e.length,")"]}),u("div",{className:"space-y-2",children:[i.map(f=>r(du,{detection:f,children_:c.get(f.id)??[],colors:a,hiddenKeys:o,onToggleVisibility:s},f.id)),d.map(f=>r(du,{detection:f,children_:[],colors:a,hiddenKeys:o,onToggleVisibility:s},f.id))]})]})}function du({detection:e,children_:t,colors:n,hiddenKeys:o,onToggleVisibility:s}){const a=ct(e.macroClass,n),i=!o?.has(e.id),l=e.debug?.mask,c=e.debug?.maskWidth,d=e.debug?.maskHeight,f=e.debug?.alternateLabels;return u("div",{className:`rounded-md border border-border bg-surface p-3 space-y-1 ${i?"":"opacity-40"}`,children:[u("div",{className:"flex justify-between items-center",children:[u("div",{className:"flex items-center gap-2",children:[s&&r("input",{type:"checkbox",checked:i,onChange:()=>s(e.id,!i),className:"h-3.5 w-3.5 rounded border-border accent-primary cursor-pointer shrink-0"}),r("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:a}}),r("span",{className:"text-sm font-medium text-foreground",children:e.macroClass}),e.kind==="detail"&&r("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:"detail"}),l&&c&&d&&u("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:["mask ",c,"x",d]})]}),r(cC,{confidence:e.score})]}),u("div",{className:"text-[10px] text-foreground-subtle font-mono",children:["bbox: [",Math.round(e.bbox.x),", ",Math.round(e.bbox.y),","," ",Math.round(e.bbox.x+e.bbox.width),","," ",Math.round(e.bbox.y+e.bbox.height),"]"]}),e.labels.length>0&&r("div",{className:"flex flex-wrap gap-1 mt-1",children:e.labels.map((p,m)=>u("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{backgroundColor:ct(p.label,n)+"20",color:ct(p.label,n)},children:[p.label,u("span",{className:"opacity-60",children:[(p.score*100).toFixed(0),"%"]}),p.detectionId&&u("span",{className:"opacity-40 text-[8px]",children:["→ ",p.detectionId]})]},m))}),f&&Object.keys(f).length>0&&r(lC,{alternateLabels:f,colors:n}),t.length>0&&r(iC,{items:t,colors:n,hiddenKeys:o,onToggleVisibility:s})]})}function iC({items:e,colors:t,hiddenKeys:n,onToggleVisibility:o}){return r("div",{className:"ml-4 mt-1.5 space-y-1.5 border-l-2 border-border pl-3",children:e.map(s=>{const a=ct(s.macroClass,t),i=!n?.has(s.id),l=s.debug?.mask,c=s.debug?.maskWidth,d=s.debug?.maskHeight;return u("div",{className:`text-xs space-y-0.5 ${i?"":"opacity-40"}`,children:[u("div",{className:"flex items-center gap-1.5",children:[o&&r("input",{type:"checkbox",checked:i,onChange:()=>o(s.id,!i),className:"h-3 w-3 rounded border-border accent-primary cursor-pointer shrink-0"}),r("span",{className:"h-1.5 w-1.5 rounded-full shrink-0",style:{backgroundColor:a}}),r("span",{className:"font-medium",style:{color:a},children:s.macroClass}),u("span",{className:"text-foreground-subtle",children:[(s.score*100).toFixed(0),"%"]}),l&&c&&d&&u("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:["mask ",c,"x",d]})]}),s.labels.length>0&&r("div",{className:"flex flex-wrap gap-1 ml-5 mt-0.5",children:s.labels.map((f,p)=>u("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-medium px-1 py-0.5 rounded-full",style:{backgroundColor:ct(f.label,t)+"20",color:ct(f.label,t)},children:[f.label," ",u("span",{className:"opacity-60",children:[(f.score*100).toFixed(0),"%"]})]},p))})]},s.id)})})}function lC({alternateLabels:e,colors:t}){const[n,o]=$(!1),s=Object.keys(e);return u("div",{className:"mt-1",children:[u("button",{onClick:()=>o(a=>!a),className:"text-[9px] text-foreground-subtle hover:text-foreground transition-colors flex items-center gap-1",children:[r("span",{className:`transition-transform ${n?"rotate-90":""}`,children:"▶"}),"Alternates (",s.length," source",s.length!==1?"s":"",")"]}),n&&r("div",{className:"mt-1 ml-3 space-y-1.5",children:s.map(a=>{const i=e[a];return!i||i.length===0?null:u("div",{children:[r("div",{className:"text-[9px] font-medium text-foreground-subtle mb-0.5",children:a}),r("div",{className:"flex flex-wrap gap-1",children:i.map((l,c)=>u("span",{className:"inline-flex items-center gap-0.5 text-[9px] px-1 py-0.5 rounded-full",style:{backgroundColor:ct(a,t)+"10",color:ct(a,t),opacity:Math.max(.4,l.score)},children:[l.label,u("span",{className:"opacity-60",children:[(l.score*100).toFixed(1),"%"]})]},c))})]},a)})})]})}function cC({confidence:e}){const t=e>=.8?"bg-success/10 text-success":e>=.5?"bg-warning/10 text-warning":"bg-danger/10 text-danger";return u("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${t}`,children:[(e*100).toFixed(1),"%"]})}function dC({timings:e,totalMs:t,className:n}){const o=Object.entries(e);return o.length===0&&t===void 0?null:u("div",{className:`rounded-lg border border-border bg-surface p-3 space-y-2 ${n??""}`,children:[r("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide",children:"Timings"}),u("div",{className:"space-y-1 text-xs",children:[o.map(([s,a])=>u("div",{className:"flex justify-between",children:[r("span",{className:"text-foreground-subtle",children:s}),u("span",{className:"font-mono text-foreground",children:[a.toFixed(1),"ms"]})]},s)),t!==void 0&&u("div",{className:"flex justify-between pt-1 border-t border-border font-medium text-foreground",children:[r("span",{children:"Total"}),u("span",{className:"font-mono",children:[t.toFixed(1),"ms"]})]})]})]})}function uC({images:e,selectedFilename:t,uploadedName:n,onSelect:o,onUpload:s,className:a,accept:i="image/*",uploadLabel:l="Upload..."}){const c=()=>{const d=document.createElement("input");d.type="file",d.accept=i,d.onchange=()=>{const f=d.files?.[0];if(!f)return;const p=new FileReader;p.onload=()=>{const m=p.result,h=m.split(",")[1];h&&s(h,f.name,m)},p.readAsDataURL(f)},d.click()};return u("div",{className:`flex flex-wrap items-center gap-2 ${a??""}`,children:[e.map(d=>r("button",{onClick:()=>o(d.filename),className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${t===d.filename?"bg-primary text-primary-foreground border-primary":"bg-surface border-border text-foreground hover:border-primary/50"}`,children:d.id??d.filename.replace(/\.[^.]+$/,"")},d.filename)),r("button",{onClick:c,className:"px-3 py-1.5 text-xs rounded-md border border-border bg-surface text-foreground hover:bg-surface-hover transition-colors",children:l}),n&&r("span",{className:"text-xs text-foreground-subtle",children:n})]})}const zo="w-full px-3 py-2 text-sm rounded-md border border-border bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-primary/50";function pC({runtime:e,backend:t,modelId:n,agentId:o="hub",runtimes:s,backends:a,models:i,agents:l=[],onRuntimeChange:c,onBackendChange:d,onModelChange:f,onAgentChange:p,layout:m="grid",className:h,showAgent:g=!1}){return u("div",{className:`${m==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4":m==="horizontal"?"flex flex-wrap items-end gap-4":"space-y-3"} ${h??""}`,children:[g&&l.length>0&&u("label",{className:"space-y-1",children:[r("span",{className:"text-xs font-medium text-foreground-subtle",children:"Agent"}),r("select",{value:o,onChange:x=>p?.(x.target.value),className:zo,children:l.map(x=>u("option",{value:x.id,children:[x.name," (",x.status,")"]},x.id))})]}),u("label",{className:"space-y-1",children:[r("span",{className:"text-xs font-medium text-foreground-subtle",children:"Runtime"}),r("select",{value:e,onChange:x=>c(x.target.value),className:zo,children:s.map(x=>u("option",{value:x.value,disabled:!x.available,children:[x.label,x.available?"":" (unavailable)"]},x.value))})]}),u("label",{className:"space-y-1",children:[r("span",{className:"text-xs font-medium text-foreground-subtle",children:"Backend"}),r("select",{value:t,onChange:x=>d(x.target.value),className:zo,children:a.map(x=>u("option",{value:x.id,disabled:!x.available,children:[x.label,x.available?"":" (unavailable)"]},x.id))})]}),u("label",{className:"space-y-1",children:[r("span",{className:"text-xs font-medium text-foreground-subtle",children:"Model"}),r("select",{value:n,onChange:x=>f(x.target.value),className:zo,children:i.length===0?r("option",{value:"",children:"No compatible models"}):i.map(x=>u("option",{value:x.id,children:[x.name,x.downloaded?" ✓":""]},x.id))})]})]})}function fC({className:e}){return u("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[r("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),r("circle",{cx:"12",cy:"12",r:"3"})]})}function mC({className:e}){return u("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[r("path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}),r("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),r("path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}),r("path",{d:"m2 2 20 20"})]})}function hC({className:e}){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:r("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}function Th({onLogin:e,serverUrl:t,logoSrc:n,error:o,className:s}){const[a,i]=$(""),[l,c]=$(""),[d,f]=$(!1),[p,m]=$(!1),[h,g]=$(null),b=o??h,x=async v=>{if(v.preventDefault(),!p){g(null),m(!0);try{await e(a,l)}catch(w){const y=w instanceof Error?w.message:"Login failed. Please try again.";g(y)}finally{m(!1)}}};return r("div",{className:K("flex min-h-screen items-center justify-center bg-background p-4",s),children:u("div",{className:"w-full max-w-sm",children:[n&&r("div",{className:"flex justify-center mb-8",children:r("img",{src:n,alt:"Logo",className:"h-12"})}),t&&r("p",{className:"mb-4 text-center text-xs text-foreground-subtle truncate",children:t}),u("form",{onSubmit:x,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[b&&r("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:b}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"Username"}),r("input",{type:"text",value:a,onChange:v=>i(v.target.value),autoComplete:"username",required:!0,className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary"})]}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"Password"}),u("div",{className:"relative",children:[r("input",{type:d?"text":"password",value:l,onChange:v=>c(v.target.value),autoComplete:"current-password",required:!0,className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary"}),r("button",{type:"button",onClick:()=>f(v=>!v),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",tabIndex:-1,children:d?r(mC,{className:"h-4 w-4"}):r(fC,{className:"h-4 w-4"})})]})]}),u("button",{type:"submit",disabled:p,className:"w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2",children:[p&&r(hC,{className:"h-4 w-4 animate-spin"}),p?"Logging in...":"Log in"]})]})]})})}const qi="camstack_dev_token",Rh=Oe(null);function gC(){const e=ye(Rh);if(!e)throw new Error("useDevShell must be used within a DevShell");return e}function bC(){return typeof window>"u"?null:localStorage.getItem(qi)}function xC({className:e}){return u("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[r("circle",{cx:"12",cy:"12",r:"4"}),r("path",{d:"M12 2v2"}),r("path",{d:"M12 20v2"}),r("path",{d:"m4.93 4.93 1.41 1.41"}),r("path",{d:"m17.66 17.66 1.41 1.41"}),r("path",{d:"M2 12h2"}),r("path",{d:"M20 12h2"}),r("path",{d:"m6.34 17.66-1.41 1.41"}),r("path",{d:"m19.07 4.93-1.41 1.41"})]})}function yC({className:e}){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:r("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function vC({children:e,serverUrl:t,title:n,token:o,onLogout:s}){const a=Ir(),i=Q(()=>{const m=t.replace(/^http/,"ws")+"/trpc",h=X1({url:m,connectionParams:()=>({token:o})});return[J1({condition:g=>g.type==="subscription",true:ew({client:h,transformer:_i}),false:jf({url:`${t}/trpc`,transformer:_i,headers:()=>({authorization:`Bearer ${o}`})})})]},[t,o]),l=Q(()=>Ff({links:i}),[i]),c=Q(()=>C.createClient({links:i}),[i]),d=Q(()=>Vf({serverUrl:t,token:o}),[t,o]);Y(()=>(d.init().catch(()=>{}),()=>{d.close()}),[d]);const f=Q(()=>new Of,[]),p=Q(()=>({trpc:l,token:o,logout:s}),[l,o,s]);return r(Xl,{system:d,children:r(C.Provider,{client:c,queryClient:f,children:r(zf,{client:f,children:r(Rh.Provider,{value:p,children:u("div",{className:"min-h-screen bg-background text-foreground",children:[u("div",{className:"flex items-center justify-between border-b border-border bg-surface px-4 py-2",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"rounded bg-warning/20 px-2 py-0.5 text-xs font-bold text-warning",children:"DEV MODE"}),n&&r("span",{className:"text-sm font-medium text-foreground",children:n}),r("span",{className:"text-xs text-foreground-subtle",children:t})]}),u("div",{className:"flex items-center gap-2",children:[u("button",{type:"button",onClick:a.toggleMode,className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",title:`Theme: ${a.mode}`,children:[a.resolvedMode==="dark"?r(xC,{className:"h-3.5 w-3.5"}):r(yC,{className:"h-3.5 w-3.5"}),a.mode==="dark"?"Dark":a.mode==="light"?"Light":"System"]}),r("button",{type:"button",onClick:s,className:"rounded-md px-2.5 py-1 text-xs font-medium text-danger hover:bg-danger/10 transition-colors",children:"Logout"})]})]}),r("div",{className:"p-4",children:e({trpc:l,theme:a})})]})})})})})}function Oh({children:e,serverUrl:t="https://localhost:4443",title:n}){const[o,s]=$(bC),a=q(async(l,c)=>{const p=await Ff({links:[jf({url:`${t}/trpc`,transformer:_i})]}).auth.login.mutate({username:l,password:c});if(!p.token)throw new Error("No token returned");localStorage.setItem(qi,p.token),s(p.token)},[t]),i=q(()=>{localStorage.removeItem(qi),s(null)},[]);return o?r(ws,{children:r(vC,{serverUrl:t,title:n,token:o,onLogout:i,children:e})}):r(ws,{children:r(Th,{onLogin:a,serverUrl:t})})}function wC(e,t={}){const{serverUrl:n="https://localhost:4443",title:o,rootId:s="root"}=t,a=document.getElementById(s);if(!a){console.error(`[mountAddonPage] Element #${s} not found`);return}Tf(a).render(Me(Oh,{serverUrl:n,title:o,children:({trpc:i,theme:l})=>Me(e,{trpc:i,theme:{isDark:l.resolvedMode==="dark"},navigate:c=>{console.log("[dev] navigate:",c)}})}))}const zh=un("camstack:custom-field-renderers",{});function Bh({renderers:e,children:t}){return r(zh.Provider,{value:e,children:t})}function Fh(e){return ye(zh)[e]??null}const oc=un("camstack:device-context",null);function jh({deviceId:e,device:t,children:n}){const o={deviceId:e,device:t??null};return r(oc.Provider,{value:o,children:n})}function pn(){return ye(oc)?.deviceId??null}function sc(){return ye(oc)?.device??null}const NC=C.accessories.getStatus.useQuery,ac=C.addonPages.listPages.useQuery,ra=C.addons.list.useQuery,kC=C.addons.getLogs.useQuery,SC=C.addons.listPackages.useQuery,ic=C.addons.installPackage.useMutation,CC=C.addons.installFromWorkspace.useMutation,MC=C.addons.isWorkspaceAvailable.useQuery,IC=C.addons.listWorkspacePackages.useQuery,Hh=C.addons.uninstallPackage.useMutation,Vh=C.addons.reloadPackages.useMutation,qh=C.addons.searchAvailable.useQuery,lc=C.addons.listUpdates.useQuery,Qi=C.addons.updatePackage.useMutation,AC=C.addons.rollbackPackage.useMutation,Qh=C.addons.forceRefresh.useMutation,Uh=C.addons.restartServer.useMutation,Kh=C.addons.getVersions.useQuery,oa=C.addons.restartAddon.useMutation,Gh=C.addons.retryLoad.useMutation,Wh=C.addons.getAutoUpdateSettings.useQuery,PC=C.addons.setAutoUpdateSettings.useMutation,Yh=C.addons.getAddonAutoUpdate.useQuery,Zh=C.addons.setAddonAutoUpdate.useMutation,Xh=C.addons.applyAutoUpdateToAll.useMutation,EC=C.addons.custom.useMutation,$C=C.addons.onAddonLogs.useSubscription,cc=C.addonSettings.getGlobalSettings.useQuery,Jh=C.addonSettings.updateGlobalSettings.useMutation,_C=C.addonSettings.getDeviceSettings.useQuery,eg=C.addonSettings.updateDeviceSettings.useMutation,tg=C.addonWidgets.listWidgets.useQuery,DC=C.alerts.emit.useMutation,LC=C.alerts.update.useMutation,ng=C.alerts.list.useQuery,rg=C.alerts.getUnreadCount.useQuery,og=C.alerts.markRead.useMutation,sg=C.alerts.markAllRead.useMutation,ag=C.alerts.dismiss.useMutation,TC=C.audioAnalysis.resolveDeviceSettings.useQuery,RC=C.audioAnalysis.getDeviceSettingsContribution.useQuery,OC=C.audioAnalysis.getDeviceLiveContribution.useQuery,zC=C.audioAnalysis.applyDeviceSettingsPatch.useMutation,BC=C.audioAnalyzer.analyseChunk.useMutation,FC=C.audioAnalyzer.classify.useQuery,jC=C.audioAnalyzer.isReady.useQuery,HC=C.audioAnalyzer.dispose.useMutation,ig=C.audioAnalyzer.reprobeAudioEngine.useMutation,VC=C.audioCodec.listSupportedCodecs.useQuery,qC=C.audioCodec.canHandle.useQuery,QC=C.audioCodec.createDecodeSession.useMutation,UC=C.audioCodec.createEncodeSession.useMutation,KC=C.audioCodec.closeSession.useMutation,GC=C.audioCodec.pushEncodedFrame.useMutation,WC=C.audioCodec.pullPcm.useQuery,YC=C.audioCodec.pushPcm.useMutation,ZC=C.audioCodec.pullEncoded.useQuery,XC=C.audioCodec.flushEncode.useMutation,JC=C.audioCodec.listActiveSessions.useQuery,e3=C.audioMetrics.getCurrentSnapshot.useQuery,t3=C.audioMetrics.getHistory.useQuery,dc=C.authentication.listProviders.useQuery,n3=C.authentication.setProviderEnabled.useMutation,uc=C.backup.listDestinations.useQuery,lg=C.backup.trigger.useMutation,r3=C.backup.list.useQuery,cg=C.backup.listLocations.useQuery,dg=C.backup.getEntries.useQuery,ug=C.backup.restore.useMutation,pg=C.backup.delete.useMutation,pc=C.backup.listArchives.useQuery,fg=C.backup.upsertDestinationPolicy.useMutation,mg=C.backup.previewSchedule.useQuery,o3=C.battery.getStatus.useQuery,s3=C.brightness.setBrightness.useMutation,a3=C.brightness.getStatus.useQuery,i3=C.cameraStreams.getCameraStreams.useQuery,l3=C.cameraStreams.getBrokerStreams.useQuery,c3=C.cameraStreams.getRtspEntries.useQuery,d3=C.decoder.supportsCodec.useQuery,u3=C.decoder.getInfo.useQuery,p3=C.decoder.createSession.useQuery,f3=C.decoder.destroySession.useQuery,m3=C.decoder.pushPacket.useQuery,h3=C.decoder.openStream.useQuery,g3=C.decoder.pullFrames.useQuery,b3=C.decoder.updateConfig.useQuery,x3=C.decoder.getStats.useQuery,y3=C.decoder.listActiveSessions.useQuery,hg=C.decoder.reprobeHwaccel.useMutation,v3=C.detectionPipeline.getDeviceSettingsContribution.useQuery,w3=C.detectionPipeline.getDeviceLiveContribution.useQuery,N3=C.detectionPipeline.applyDeviceSettingsPatch.useMutation,gg=C.deviceDiscovery.listDiscovered.useQuery,bg=C.deviceDiscovery.refreshDiscovery.useMutation,k3=C.deviceDiscovery.adoptDevice.useMutation,S3=C.deviceDiscovery.releaseDevice.useMutation,C3=C.deviceDiscovery.getStatus.useQuery,M3=C.deviceManager.allocateDeviceId.useMutation,I3=C.deviceManager.registerDevice.useMutation,A3=C.deviceManager.removeDevice.useMutation,P3=C.deviceManager.persistConfig.useMutation,E3=C.deviceManager.loadConfig.useQuery,$3=C.deviceManager.loadRuntimeState.useQuery,_3=C.deviceManager.loadMeta.useQuery,xg=C.deviceManager.setName.useMutation,yg=C.deviceManager.setLocation.useMutation,D3=C.deviceManager.setMetadata.useMutation,vg=C.deviceManager.listLocations.useQuery,L3=C.deviceManager.addLocation.useMutation,T3=C.deviceManager.removeLocation.useMutation,R3=C.deviceManager.setDisabled.useMutation,O3=C.deviceManager.listPersistedByAddon.useQuery,Jn=C.deviceManager.listAll.useQuery,Fn=C.deviceManager.getDevice.useQuery,wg=C.deviceManager.getChildren.useQuery,z3=C.deviceManager.getStreamSources.useQuery,B3=C.deviceManager.getConfigSchema.useQuery,F3=C.deviceManager.getSettingsSchema.useQuery,j3=C.deviceManager.updateConfig.useMutation,Ng=C.deviceManager.enable.useMutation,kg=C.deviceManager.disable.useMutation,Sg=C.deviceManager.remove.useMutation,H3=C.deviceManager.getStreamProfileMap.useQuery,V3=C.deviceManager.setStreamProfileMap.useMutation,q3=C.deviceManager.probeStreams.useMutation,Cg=C.deviceManager.getBindings.useQuery,Q3=C.deviceManager.getAllBindings.useQuery,Mg=C.deviceManager.setWrapperActive.useMutation,U3=C.deviceManager.listWrappersForCap.useQuery,Ig=C.deviceManager.listBindableCapsForDeviceType.useQuery,K3=C.deviceManager.getDeviceSettingsAggregate.useQuery,G3=C.deviceManager.getDeviceLiveInfoAggregate.useQuery,fc=C.deviceManager.getDeviceAggregate.useQuery,W3=C.deviceManager.updateDeviceField.useMutation,Ag=C.deviceManager.updateDeviceFieldsBatch.useMutation,mc=C.deviceManager.discoverDevices.useMutation,Pg=C.deviceManager.adoptDevice.useMutation,Eg=C.deviceManager.getCreationSchema.useQuery,$g=C.deviceManager.createDevice.useMutation,hc=C.deviceManager.testCreationField.useMutation,Y3=C.deviceManager.testField.useMutation,Z3=C.deviceManager.getDeviceStatusAggregate.useQuery,X3=C.deviceOps.getStreamSources.useQuery,J3=C.deviceOps.getConfigEntries.useQuery,eM=C.deviceOps.setConfig.useMutation,tM=C.deviceOps.removeDevice.useMutation,nM=C.deviceOps.getSettingsSchema.useQuery,rM=C.deviceProvider.start.useMutation,oM=C.deviceProvider.stop.useMutation,sM=C.deviceProvider.getStatus.useQuery,aM=C.deviceProvider.getDevices.useQuery,iM=C.deviceProvider.supportsDiscovery.useQuery,lM=C.deviceProvider.discoverDevices.useMutation,cM=C.deviceProvider.adoptDiscoveredDevice.useMutation,dM=C.deviceProvider.supportsManualCreation.useQuery,uM=C.deviceProvider.getChildCreationSchema.useQuery,pM=C.deviceProvider.createDevice.useMutation,fM=C.deviceProvider.testCreationField.useMutation,mM=C.deviceState.getSnapshot.useQuery,hM=C.deviceState.getCapSlice.useQuery,gM=C.deviceState.getAllSnapshots.useQuery,bM=C.deviceState.setCapSlice.useMutation,xM=C.doorbell.getStatus.useQuery,yM=C.events.getEvents.useQuery,vM=C.events.getEventThumbnail.useQuery,wM=C.events.getEventClipUrl.useQuery,sa=C.integrations.list.useQuery,_g=C.integrations.get.useQuery,Dg=C.integrations.getByAddonId.useQuery,Lg=C.integrations.create.useMutation,Tg=C.integrations.update.useMutation,Rg=C.integrations.delete.useMutation,NM=C.integrations.getSettings.useQuery,kM=C.integrations.setSettings.useMutation,Og=C.integrations.getAvailableTypes.useQuery,zg=C.integrations.testConnection.useMutation,Bg=C.intercom.startSession.useMutation,Fg=C.intercom.handleAnswer.useMutation,jg=C.intercom.stopSession.useMutation,SM=C.intercom.getStatus.useQuery,Hg=C.localNetwork.list.useQuery,CM=C.localNetwork.getPreferred.useQuery,Vg=C.localNetwork.getConnectionEndpoints.useQuery,qg=C.localNetwork.getAllowedAddresses.useQuery,Qg=C.localNetwork.setAllowedAddresses.useMutation,Ug=C.localNetwork.resetAllowlistToBestMatch.useMutation,Kg=C.meshOrchestrator.listProviders.useQuery,Gg=C.meshOrchestrator.joinProvider.useMutation,Wg=C.meshOrchestrator.leaveProvider.useMutation,MM=C.metricsProvider.collectSnapshot.useQuery,IM=C.metricsProvider.getCached.useQuery,AM=C.metricsProvider.getCurrent.useQuery,PM=C.metricsProvider.getDiskSpace.useQuery,EM=C.metricsProvider.getGpuInfo.useQuery,$M=C.metricsProvider.getCpuTemperature.useQuery,_M=C.metricsProvider.getProcessStats.useQuery,DM=C.metricsProvider.listAddonInstances.useQuery,LM=C.metricsProvider.getAddonStats.useQuery,Yg=C.metricsProvider.listNodeProcesses.useQuery,Zg=C.metricsProvider.killProcess.useMutation,TM=C.motion.isDetected.useQuery,RM=C.motion.getStatus.useQuery,OM=C.motionDetection.analyze.useMutation,zM=C.motionDetection.removeCamera.useMutation,BM=C.motionDetection.reset.useMutation,FM=C.motionDetection.getDeviceSettingsContribution.useQuery,jM=C.motionDetection.getDeviceLiveContribution.useQuery,HM=C.motionDetection.applyDeviceSettingsPatch.useMutation,VM=C.motionTrigger.setMotionTrigger.useMutation,qM=C.motionTrigger.getStatus.useQuery,QM=C.nativeObjectDetection.getStatus.useQuery,gc=C.networkQuality.getDeviceStats.useQuery,UM=C.networkQuality.getAllStats.useQuery,KM=C.networkQuality.reportClientStats.useMutation,In=C.nodes.topology.useQuery,GM=C.nodes.deployAddon.useMutation,Xg=C.nodes.undeployAddon.useMutation,aa=C.nodes.restartAddon.useMutation,Jg=C.nodes.restartProcess.useMutation,eb=C.nodes.restartNode.useMutation,WM=C.nodes.shutdownNode.useMutation,tb=C.nodes.renameNode.useMutation,nb=C.nodes.clusterAddonStatus.useQuery,rb=C.nodes.setProcessLogLevel.useMutation,YM=C.nodes.executeQuery.useMutation,ZM=C.notificationOutput.send.useMutation,XM=C.notificationOutput.sendTest.useMutation,JM=C.osd.setOverlay.useMutation,e4=C.osd.getStatus.useQuery,t4=C.pipelineAnalytics.getActiveTracks.useQuery,n4=C.pipelineAnalytics.getTrack.useQuery,r4=C.pipelineAnalytics.listTracks.useQuery,o4=C.pipelineAnalytics.clearTracks.useMutation,s4=C.pipelineAnalytics.getMotionEvents.useQuery,a4=C.pipelineAnalytics.getObjectEvents.useQuery,i4=C.pipelineAnalytics.getAudioEvents.useQuery,l4=C.pipelineAnalytics.getEventMedia.useQuery,c4=C.pipelineAnalytics.getTrackMedia.useQuery,d4=C.pipelineAnalytics.getDeviceSettingsContribution.useQuery,u4=C.pipelineAnalytics.getDeviceLiveContribution.useQuery,p4=C.pipelineAnalytics.applyDeviceSettingsPatch.useMutation,ob=C.pipelineExecutor.getAvailableEngines.useQuery,sb=C.pipelineExecutor.getSelectedEngine.useQuery,f4=C.pipelineExecutor.getDefaultSteps.useQuery,ab=C.pipelineExecutor.reprobeEngine.useMutation,m4=C.pipelineExecutor.getVideoPipelineSteps.useQuery,h4=C.pipelineExecutor.setVideoPipelineSteps.useMutation,So=C.pipelineExecutor.getSchema.useQuery,g4=C.pipelineExecutor.getGlobalSteps.useQuery,b4=C.pipelineExecutor.getGlobalPipelineConfig.useQuery,x4=C.pipelineExecutor.getOrchestratorConfigSchema.useQuery,y4=C.pipelineExecutor.listTemplates.useQuery,v4=C.pipelineExecutor.saveTemplate.useMutation,w4=C.pipelineExecutor.updateTemplate.useMutation,N4=C.pipelineExecutor.deleteTemplate.useMutation,k4=C.pipelineExecutor.getCapabilities.useQuery,S4=C.pipelineExecutor.getAddonModels.useQuery,ib=C.pipelineExecutor.downloadModel.useMutation,lb=C.pipelineExecutor.deleteModel.useMutation,C4=C.pipelineExecutor.detect.useQuery,M4=C.pipelineExecutor.runPipeline.useMutation,I4=C.pipelineExecutor.runPipelineBatch.useMutation,A4=C.pipelineExecutor.cacheFrameInPool.useMutation,P4=C.pipelineExecutor.inferCached.useMutation,E4=C.pipelineExecutor.uncacheFrame.useMutation,$4=C.pipelineExecutor.getEffectiveTuning.useQuery,cb=C.pipelineExecutor.listLoadedEngines.useQuery,_4=C.pipelineExecutor.spinEngine.useMutation,db=C.pipelineExecutor.killEngine.useMutation,D4=C.pipelineExecutor.listReferenceImages.useQuery,L4=C.pipelineExecutor.getReferenceImage.useQuery,T4=C.pipelineExecutor.getReferenceAudioFiles.useQuery,R4=C.pipelineExecutor.getReferenceAudio.useQuery,O4=C.pipelineExecutor.getAudioCapabilities.useQuery,z4=C.pipelineExecutor.runAudioTest.useMutation,B4=C.pipelineExecutor.getDetectionConfigSchema.useQuery,ub=C.pipelineOrchestrator.assignPipeline.useMutation,pb=C.pipelineOrchestrator.unassignPipeline.useMutation,fb=C.pipelineOrchestrator.rebalance.useMutation,ia=C.pipelineOrchestrator.getPipelineAssignments.useQuery,la=C.pipelineOrchestrator.getPipelineAssignment.useQuery,mb=C.pipelineOrchestrator.getAgentLoad.useQuery,F4=C.pipelineOrchestrator.getGlobalMetrics.useQuery,j4=C.pipelineOrchestrator.getCameraMetrics.useQuery,hb=C.pipelineOrchestrator.getCapabilityBindings.useQuery,gb=C.pipelineOrchestrator.setCapabilityBinding.useMutation,bb=C.pipelineOrchestrator.assignDecoder.useMutation,xb=C.pipelineOrchestrator.unassignDecoder.useMutation,yb=C.pipelineOrchestrator.getDecoderAssignments.useQuery,vb=C.pipelineOrchestrator.assignAudio.useMutation,wb=C.pipelineOrchestrator.unassignAudio.useMutation,H4=C.pipelineOrchestrator.getAudioAssignment.useQuery,Nb=C.pipelineOrchestrator.getAudioNodeLoad.useQuery,kb=C.pipelineOrchestrator.getAudioAssignments.useQuery,V4=C.pipelineOrchestrator.getDecoderAssignment.useQuery,bc=C.pipelineOrchestrator.getAgentSettings.useQuery,$r=C.pipelineOrchestrator.listAgentSettings.useQuery,xc=C.pipelineOrchestrator.setAgentAddonDefaults.useMutation,Sb=C.pipelineOrchestrator.removeAgentSettings.useMutation,yc=C.pipelineOrchestrator.getCameraSettings.useQuery,Cb=C.pipelineOrchestrator.setCameraStepToggle.useMutation,q4=C.pipelineOrchestrator.getCameraStepOverrides.useQuery,Mb=C.pipelineOrchestrator.setCameraStepOverride.useMutation,Ib=C.pipelineOrchestrator.setCameraPipelineForAgent.useMutation,Ab=C.pipelineOrchestrator.resolvePipeline.useQuery,Pb=C.pipelineOrchestrator.listTemplates.useQuery,Q4=C.pipelineOrchestrator.saveTemplate.useMutation,Eb=C.pipelineOrchestrator.updateTemplate.useMutation,$b=C.pipelineOrchestrator.deleteTemplate.useMutation,U4=C.pipelineOrchestrator.getDeviceSettingsContribution.useQuery,K4=C.pipelineOrchestrator.getDeviceLiveContribution.useQuery,G4=C.pipelineOrchestrator.applyDeviceSettingsPatch.useMutation,W4=C.pipelineRunner.attachCamera.useMutation,Y4=C.pipelineRunner.detachCamera.useMutation,Z4=C.pipelineRunner.reportMotion.useMutation,X4=C.pipelineRunner.getLocalLoad.useQuery,J4=C.pipelineRunner.getLocalMetrics.useQuery,vc=C.pipelineRunner.getCameraMetrics.useQuery,eI=C.pipelineRunner.getAllCameraMetrics.useQuery,_b=C.pipelineRunner.getLocalCameras.useQuery,tI=C.platformProbe.getCapabilities.useQuery,nI=C.platformProbe.getHardware.useQuery,rI=C.platformProbe.resolveInferenceConfig.useQuery,oI=C.platformProbe.resolveHwAccel.useQuery,sI=C.ptz.move.useMutation,aI=C.ptz.continuousMove.useMutation,iI=C.ptz.stop.useMutation,lI=C.ptz.getPresets.useQuery,cI=C.ptz.goToPreset.useMutation,dI=C.ptz.goHome.useMutation,uI=C.ptz.getPosition.useQuery,pI=C.ptz.getStatus.useQuery,Db=C.ptzAutotrack.getStatus.useQuery,Lb=C.ptzAutotrack.setEnabled.useMutation,fI=C.ptzAutotrack.getSettings.useQuery,Tb=C.ptzAutotrack.setSettings.useMutation,Rb=C.reboot.reboot.useMutation,mI=C.recording.getSegments.useQuery,hI=C.recording.getPlaybackUrl.useQuery,gI=C.recording.getThumbnailAt.useQuery,bI=C.recordingEngine.getStatus.useQuery,Ob=C.recordingEngine.enable.useMutation,zb=C.recordingEngine.disable.useMutation,Bb=C.recordingEngine.getConfig.useQuery,xI=C.recordingEngine.updateConfig.useMutation,yI=C.recordingEngine.getPlaylist.useQuery,vI=C.recordingEngine.getThumbnail.useQuery,Fb=C.recordingEngine.getSegments.useQuery,wI=C.recordingEngine.getAvailability.useQuery,NI=C.recordingEngine.estimateStorage.useQuery,kI=C.recordingEngine.estimateGlobalStorage.useQuery,jb=C.recordingEngine.getStorageUsage.useQuery,SI=C.recordingEngine.setPolicy.useMutation,CI=C.recordingEngine.getPolicy.useQuery,Hb=C.recordingEngine.getPolicyStatus.useQuery,Vb=C.recordingEngine.getRetentionConfig.useQuery,MI=C.recordingEngine.updateRetentionConfig.useMutation,II=C.recordingEngine.getMotionStats.useQuery,qb=C.remoteAccess.listProviders.useQuery,Qb=C.remoteAccess.startProvider.useMutation,Ub=C.remoteAccess.stopProvider.useMutation,AI=C.settingsStore.get.useQuery,PI=C.settingsStore.set.useMutation,EI=C.settingsStore.query.useQuery,$I=C.settingsStore.insert.useMutation,_I=C.settingsStore.update.useMutation,DI=C.settingsStore.delete.useMutation,LI=C.settingsStore.count.useQuery,TI=C.settingsStore.isEmpty.useQuery,RI=C.settingsStore.declareCollection.useMutation,OI=C.snapshot.getSnapshot.useQuery,zI=C.snapshot.invalidateCache.useMutation,BI=C.snapshot.getStatus.useQuery,FI=C.snapshot.getDeviceSettingsContribution.useQuery,jI=C.snapshot.getDeviceLiveContribution.useQuery,HI=C.snapshot.applyDeviceSettingsPatch.useMutation,VI=C.snapshotProvider.supportsDevice.useQuery,qI=C.snapshotProvider.getSnapshot.useQuery,QI=C.storage.resolve.useQuery,UI=C.storage.write.useMutation,KI=C.storage.read.useQuery,GI=C.storage.exists.useQuery,WI=C.storage.list.useQuery,YI=C.storage.delete.useMutation,ZI=C.storage.getAvailableSpace.useQuery,XI=C.storage.beginUpload.useMutation,JI=C.storage.writeChunk.useMutation,eA=C.storage.finalizeUpload.useMutation,tA=C.storage.abortUpload.useMutation,nA=C.storage.beginDownload.useMutation,rA=C.storage.readChunk.useQuery,oA=C.storage.endDownload.useMutation,Kb=C.storage.listLocations.useQuery,sA=C.storage.getDefaultLocation.useQuery,ca=C.storage.upsertLocation.useMutation,Gb=C.storage.deleteLocation.useMutation,aA=C.storage.testLocation.useQuery,wc=C.storage.listProviders.useQuery,iA=C.storage.testConfig.useQuery,lA=C.streamBroker.publishCameraStream.useMutation,cA=C.streamBroker.retractCameraStream.useMutation,dA=C.streamBroker.assignProfile.useMutation,uA=C.streamBroker.unassignProfile.useMutation,pA=C.streamBroker.listAllCameraStreams.useQuery,fA=C.streamBroker.listAllProfileSlots.useQuery,mA=C.streamBroker.getBrokerStats.useQuery,hA=C.streamBroker.listClients.useQuery,gA=C.streamBroker.killClient.useMutation,bA=C.streamBroker.restartProfile.useMutation,xA=C.streamBroker.getStreamUrl.useQuery,yA=C.streamBroker.getBroker.useQuery,vA=C.streamBroker.setPreBufferDuration.useMutation,wA=C.streamBroker.getPreBufferInfo.useQuery,NA=C.streamBroker.getRtspPort.useQuery,kA=C.streamBroker.getAllRtspEntries.useQuery,SA=C.streamBroker.getRtspEntry.useQuery,Wb=C.streamBroker.regenerateRtspToken.useMutation,CA=C.streamBroker.setRtspEnabled.useMutation,MA=C.streamBroker.isRtspEnabled.useQuery,IA=C.streamBroker.getDeviceSettingsContribution.useQuery,AA=C.streamBroker.getDeviceLiveContribution.useQuery,PA=C.streamBroker.applyDeviceSettingsPatch.useMutation,EA=C.switch.setState.useMutation,$A=C.switch.getStatus.useQuery,_A=C.system.info.useQuery,DA=C.system.health.useQuery,LA=C.system.featureFlags.useQuery,TA=C.system.networkAddresses.useQuery,RA=C.system.getRetentionConfig.useQuery,OA=C.system.setRetentionConfig.useMutation,zA=C.system.forceRetentionCleanup.useMutation,Yb=C.toast.onToast.useSubscription,Zb=C.turnOrchestrator.listProviders.useQuery,Xb=C.turnOrchestrator.getAllServers.useQuery,BA=C.turnOrchestrator.setProviderEnabled.useMutation,FA=C.turnProvider.getTurnServers.useQuery,Nc=C.userManagement.listUsers.useQuery,Jb=C.userManagement.createUser.useMutation,ex=C.userManagement.updateUser.useMutation,tx=C.userManagement.deleteUser.useMutation,kc=C.userManagement.resetPassword.useMutation,jA=C.userManagement.validateCredentials.useMutation,nx=C.userManagement.listApiKeys.useQuery,HA=C.userManagement.createApiKey.useMutation,rx=C.userManagement.revokeApiKey.useMutation,VA=C.userManagement.validateApiKey.useMutation,ox=C.userManagement.createScopedToken.useMutation,sx=C.userManagement.revokeScopedToken.useMutation,qA=C.userManagement.validateScopedToken.useQuery,ax=C.userManagement.listScopedTokens.useQuery,QA=C.webrtcSession.listStreams.useQuery,UA=C.webrtcSession.createSession.useMutation,KA=C.webrtcSession.handleAnswer.useMutation,GA=C.webrtcSession.closeSession.useMutation,WA=C.webrtcSession.hasAdaptiveBitrate.useQuery,YA=C.zoneAnalytics.getCurrentSnapshot.useQuery,ZA=C.zoneAnalytics.getZoneHistory.useQuery,XA=C.zoneAnalytics.getCameraHistory.useQuery,JA=C.zoneAnalytics.getUnzonedHistory.useQuery,eP=C.zoneRules.listRules.useQuery,tP=C.zoneRules.setRules.useMutation,nP=C.zones.listZones.useQuery,rP=C.zones.addZone.useMutation,oP=C.zones.removeZone.useMutation,sP=C.zones.updateZone.useMutation,ix=un("camstack:widget-registry",null),Ms=new Map,Bo=new Map,uu=new Set;function aP(e){if(!e||typeof e!="object")return!1;const t=e.default;return t!==null&&typeof t=="object"}function iP(e){if(!e||typeof e!="object")return typeof e;const t=e,n=Object.getPrototypeOf(t),o=n&&typeof n=="object"?n.constructor?.name:void 0;return{ownKeys:Object.keys(t),allKeys:Object.getOwnPropertyNames(t),proto:typeof o=="string"?o:void 0}}async function lP(e,t){const n=Ms.get(e);if(n)return n;const o=Bo.get(e);if(o)return o;uu.has(e)||(Dl(),fr.registerRemotes([{name:e,entry:t,type:"module"}],{force:!1}),uu.add(e));const s=fr.loadRemote(`${e}/widgets`).then(a=>{if(!aP(a)){const l=iP(a);throw new Error(`Widget remote ${e} (${t}) does not expose a default record on './widgets'. Got: ${JSON.stringify(l)}`)}const i=a.default;return Ms.set(e,i),Bo.delete(e),i}).catch(a=>{throw Bo.delete(e),a});return Bo.set(e,s),s}const cP=3e4,dP=2e3;function lx({children:e}){const t=ke(),n=ne(Date.now()),{data:o}=tg(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:l=>{const c=l.state.data;return c&&c.length>0||Date.now()-n.current>=cP?!1:dP}});dt("addon.widget-ready",()=>{t.invalidateQueries({queryKey:[["addonWidgets","listWidgets"]]})});const[s,a]=$(0);Y(()=>{if(!o)return;let l=!1;const c=new Set;for(const d of o){if(c.has(d.remoteName)||(c.add(d.remoteName),Ms.has(d.remoteName)))continue;const f=d.bundleUrl;lP(d.remoteName,f).then(()=>{l||a(p=>p+1)}).catch(p=>{const m=p instanceof Error?p.message:String(p);(typeof globalThis<"u"?globalThis.console:void 0)?.error?.("[WidgetRegistry] Failed to load widget remote",{remoteName:d.remoteName,entryUrl:f,reason:m})})}return()=>{l=!0}},[o]);const i=Q(()=>{const l=o??[],c=new Map;for(const f of l)c.set(`${f.addonId}/${f.stableId}`,f);const d=(f,p)=>({widgetId:f,addonId:p.addonId,stableId:p.stableId,label:p.label,description:p.description,icon:p.icon,remoteName:p.remoteName,bundleUrl:p.bundleUrl,hosts:p.hosts,requires:p.requires,defaultSize:p.defaultSize,allowedSizes:p.allowedSizes,defaultColumns:p.defaultColumns,defaultRows:p.defaultRows});return{resolve:f=>{const p=c.get(f);if(!p)return;const m=Ms.get(p.remoteName);if(!m)return null;const h=m[p.stableId];if(h)return h},metadata:f=>{const p=c.get(f);if(p)return d(f,p)},listAll:()=>{const f=[];for(const[p,m]of c)f.push(d(p,m));return f}}},[o,s]);return r(ix.Provider,{value:i,children:e})}function cx(e){return da().resolve(e)}function dx(e){return da().metadata(e)}function ux(){return da().listAll()}function da(){const e=px();if(!e)throw new Error("useWidgetRegistry(): no <WidgetRegistryProvider> in tree");return e}function px(){return uP(ix)}function uP(e){return ye(e)}function it(e){const{widgetId:t,host:n="device-tab",config:o,deviceId:s,integrationId:a,instanceId:i,size:l,columns:c,rows:d}=e,f=cx(t),p=dx(t),m=Q(()=>i??t,[i,t]);if(f===void 0&&p===void 0)return r(Fo,{widgetId:t,reason:"unknown"});if(f===void 0)return r(Fo,{widgetId:t,reason:"missing-export"});if(f===null)return r(pP,{});if(p){if(p.requires.deviceContext&&s===void 0)return r(Fo,{widgetId:t,reason:"missing-device-context"});if(p.requires.integrationContext&&a===void 0)return r(Fo,{widgetId:t,reason:"missing-integration-context"})}return r(f,{instanceId:m,host:n,config:o,deviceId:s,integrationId:a,size:l,columns:c,rows:d})}function pP(){return u("div",{className:"rounded-lg border border-border bg-surface/40 p-4 animate-pulse",children:[r("div",{className:"h-3 w-24 bg-foreground-subtle/20 rounded mb-2"}),r("div",{className:"h-2 w-full bg-foreground-subtle/10 rounded mb-1"}),r("div",{className:"h-2 w-3/4 bg-foreground-subtle/10 rounded"})]})}function Fo({widgetId:e,reason:t}){const n=t==="unknown"?`Widget "${e}" not registered`:t==="missing-export"?`Widget "${e}" bundle does not export this stableId`:t==="missing-device-context"?`Widget "${e}" requires a deviceId`:`Widget "${e}" requires an integrationId`;return r("div",{className:"rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",children:n})}const er="w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none disabled:opacity-50 disabled:cursor-not-allowed",ua="block text-[11px] font-medium text-foreground mb-1",fP="text-[10px] text-foreground-subtle mt-0.5";function Qe({label:e,description:t,required:n,span:o,children:s,translationFn:a}){const i=o===2?"col-span-2":o===3?"col-span-3":o===4?"col-span-4":"col-span-1",l=Tt(e,a),c=Tt(t,a);return u("div",{className:i,children:[l!==void 0&&l!==""&&u("label",{className:ua,children:[l,n&&r("span",{className:"text-danger ml-0.5",children:"*"})]}),s,c&&r("p",{className:fP,children:c})]})}function mP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){return r(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:r("input",{type:e.inputType??"text",className:er,value:t==null?"":String(t),placeholder:e.placeholder,maxLength:e.maxLength,pattern:e.pattern,disabled:o||e.disabled,onChange:a=>n(a.target.value)})})}function hP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const[a,i]=$(t==null?"":String(t)),l=ne(!1);Y(()=>{if(l.current)return;const d=t==null?"":String(t);i(d)},[t]);const c=d=>{if(i(d),d===""||d==="-"){n(void 0);return}const f=Number(d);Number.isNaN(f)||n(f)};return r(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:"flex items-center gap-1",children:[r("input",{type:"number",className:er,value:a,placeholder:e.placeholder,min:e.min,max:e.max,step:e.step,disabled:o||e.disabled,onFocus:()=>{l.current=!0},onBlur:()=>{l.current=!1},onChange:d=>c(d.target.value)}),e.unit&&r("span",{className:"text-xs text-foreground-subtle whitespace-nowrap",children:e.unit})]})})}function gP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=!!t,i=o||e.disabled;return e.style==="checkbox"?r(Qe,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[r("input",{type:"checkbox",className:"h-3.5 w-3.5 rounded border-border accent-primary",checked:a,disabled:i,onChange:l=>n(l.target.checked)}),r("span",{className:"text-xs font-medium text-foreground",children:Tt(e.label,s)}),e.required&&r("span",{className:"text-danger",children:"*"})]})}):r(Qe,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:"flex items-center justify-between",children:[u("span",{className:ua+" mb-0",children:[Tt(e.label,s),e.required&&r("span",{className:"text-danger ml-0.5",children:"*"})]}),r("button",{type:"button",role:"switch","aria-checked":a,disabled:i,onClick:()=>!i&&n(!a),className:["relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150",a?"bg-primary":"bg-foreground-subtle/30",i?"opacity-50 cursor-not-allowed":"cursor-pointer"].join(" "),children:r("span",{className:["inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150",a?"translate-x-4":"translate-x-0.5"].join(" ")})})]})})}function bP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=e.options.some(i=>i.value==="");return r(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("select",{className:er,value:t==null?"":String(t),disabled:o||e.disabled,onChange:i=>n(i.target.value),children:[!e.required&&!a&&r("option",{value:"",children:"— Select —"}),e.options.map(i=>r("option",{value:i.value,children:i.label},i.value))]})})}function xP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=Array.isArray(t)?t:[],i=l=>{if(a.includes(l))n(a.filter(c=>c!==l));else{if(e.maxItems!==void 0&&a.length>=e.maxItems)return;n([...a,l])}};return r(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:r("div",{className:"flex flex-wrap gap-2",children:e.options.map(l=>{const c=a.includes(l.value);return u("label",{className:["flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs cursor-pointer select-none transition-colors",c?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground hover:bg-surface",o||e.disabled?"opacity-50 cursor-not-allowed":""].join(" "),children:[r("input",{type:"checkbox",className:"sr-only",checked:c,disabled:o||e.disabled,onChange:()=>i(l.value)}),l.label]},l.value)})})})}function yP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const[a,i]=$(!1),l=e.showToggle!==!1;return r(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:"relative",children:[r("input",{type:a?"text":"password",className:er+(l?" pr-9":""),value:t==null?"":String(t),placeholder:e.placeholder,disabled:o||e.disabled,onChange:c=>n(c.target.value)}),l&&r("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",tabIndex:-1,onClick:()=>i(c=>!c),children:a?r(Cm,{className:"h-3.5 w-3.5"}):r(Xs,{className:"h-3.5 w-3.5"})})]})})}function vP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){return r(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:r("textarea",{className:er+" resize-y min-h-[60px]",value:t==null?"":String(t),placeholder:e.placeholder,rows:e.rows??3,maxLength:e.maxLength,disabled:o||e.disabled,onChange:a=>n(a.target.value)})})}function wP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=t==null,i=e.nullable===!0,l=a?e.default??e.min:Number(t),c=e.showValue!==!1,d=e.nullLabel??"Auto",f=o||e.disabled,p=e.displayScale??1,m=e.min/p,h=e.max/p,g=l/p,b=(e.step??1)/p;if(i&&a)return r(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("button",{className:"w-full rounded-lg border border-dashed border-border px-3 py-2 text-xs text-foreground-subtle hover:border-primary/40 hover:text-primary transition-colors text-left",disabled:f,onClick:()=>n(e.default??e.min),children:[d," — click to set manually"]})});const x=e.showStepper===!0&&c,v=y=>{const N=l+y*(e.step??1),k=Math.min(e.max,Math.max(e.min,N));k!==l&&n(k)},w="flex h-6 w-6 shrink-0 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:cursor-not-allowed disabled:opacity-40";return r(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[u("div",{className:"flex min-w-0 flex-1 basis-[160px] items-center gap-2",children:[r("span",{className:"text-[10px] text-foreground-subtle tabular-nums shrink-0",children:m}),r("input",{type:"range",className:"min-w-0 flex-1 h-1 accent-primary cursor-pointer disabled:opacity-50",min:m,max:h,step:b,value:g,disabled:f,onChange:y=>n(Number(y.target.value)*p)}),r("span",{className:"text-[10px] text-foreground-subtle tabular-nums shrink-0",children:h})]}),(c||i||e.unit)&&u("div",{className:"flex shrink-0 items-center gap-2",children:[x&&r("button",{type:"button",className:w,disabled:f||l<=e.min,onClick:()=>v(-1),title:`Decrease by ${e.step??1}`,"aria-label":"Decrement",children:r(Em,{className:"h-3 w-3"})}),c&&r("input",{type:"number",className:"w-16 rounded border border-border bg-surface px-1.5 py-0.5 text-xs text-center text-foreground tabular-nums focus:outline-none focus:ring-1 focus:ring-primary",min:m,max:h,step:b,value:g,disabled:f,onChange:y=>{if(y.target.value===""){n(i?null:e.min);return}const N=Number(y.target.value)*p,k=e.step??1,S=N-e.min,M=e.min+Math.round(S/k)*k;n(Math.min(e.max,Math.max(e.min,M)))}}),x&&r("button",{type:"button",className:w,disabled:f||l>=e.max,onClick:()=>v(1),title:`Increase by ${e.step??1}`,"aria-label":"Increment",children:r(Js,{className:"h-3 w-3"})}),e.unit&&r("span",{className:"text-[10px] text-foreground-subtle",children:e.unit}),i&&r("button",{className:"text-[10px] text-foreground-subtle hover:text-primary transition-colors",title:`Reset to ${d}`,disabled:f,onClick:()=>n(null),children:d})]})]})})}function NP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=Array.isArray(t)?t:[],[i,l]=$(""),c=ne(null),d=q(h=>{const g=h.trim();!g||a.includes(g)||e.maxTags!==void 0&&a.length>=e.maxTags||(n([...a,g]),l(""))},[a,e.maxTags,n]),f=h=>n(a.filter(g=>g!==h)),p=h=>{h.key==="Enter"||h.key===","?(h.preventDefault(),d(i)):h.key==="Backspace"&&i===""&&a.length>0&&f(a[a.length-1])},m=o||e.disabled;return r(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:["flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px] cursor-text","focus-within:border-primary focus-within:ring-1 focus-within:ring-primary/30",m?"opacity-50 cursor-not-allowed":""].join(" "),onClick:()=>!m&&c.current?.focus(),children:[a.map(h=>u("span",{className:"inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[h,!m&&r("button",{type:"button",onClick:()=>f(h),className:"hover:text-danger",children:r(Je,{className:"h-2.5 w-2.5"})})]},h)),r("input",{ref:c,type:"text",className:"flex-1 min-w-[80px] bg-transparent text-sm text-foreground outline-none placeholder:text-foreground-disabled",value:i,placeholder:a.length===0?e.placeholder??"Add tags…":"",disabled:m,list:`tags-suggestions-${e.key}`,onChange:h=>l(h.target.value),onKeyDown:p,onBlur:()=>{i.trim()&&d(i)}}),e.suggestions&&r("datalist",{id:`tags-suggestions-${e.key}`,children:e.suggestions.map(h=>r("option",{value:h},h))})]})})}function fx({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const{nodes:a}=Pr(),i=typeof t=="string"?t:"",l=e.showOffline?a:a.filter(c=>c.isOnline);return r(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("select",{className:"w-full px-3 py-2 text-sm bg-background border border-border rounded-lg text-foreground focus:outline-none focus:border-primary/50 disabled:opacity-50",value:i,onChange:c=>n(c.target.value),disabled:o,children:[r("option",{value:"",children:"Select node…"}),l.map(c=>u("option",{value:c.id,disabled:!c.isOnline,children:[c.shortName,c.isOnline?"":" (offline)"]},c.id))]})})}function mx({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const{nodes:a}=Pr(),i=new Set(Array.isArray(t)?t.map(String):[]),l=e.showOffline?a:a.filter(d=>d.isOnline),c=d=>{const f=new Set(i);f.has(d)?f.delete(d):f.add(d),n([...f])};return r(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:r("div",{className:"flex flex-wrap gap-1.5",children:l.map(d=>{const f=i.has(d.id);return r("button",{type:"button",onClick:()=>c(d.id),disabled:o||!d.isOnline,className:`px-2.5 py-1 text-xs font-medium rounded-md border transition-colors ${f?"border-primary bg-primary/10 text-primary":"border-border bg-surface text-foreground-subtle hover:bg-surface-hover"} ${d.isOnline?"":"opacity-50 cursor-not-allowed"}`,children:d.shortName},d.id)})})})}function kP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=t==null?"#000000":String(t);return u(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:[u("div",{className:"flex items-center gap-2",children:[r("input",{type:"color",className:"h-9 w-9 rounded-md border border-border bg-background cursor-pointer p-0.5 disabled:opacity-50",value:a,disabled:o||e.disabled,onChange:i=>n(i.target.value)}),r("input",{type:"text",className:er+" flex-1 font-mono",value:a,placeholder:"#000000",disabled:o||e.disabled,onChange:i=>n(i.target.value)})]}),e.presets&&e.presets.length>0&&r("div",{className:"flex gap-1.5 mt-1.5",children:e.presets.map(i=>r("button",{type:"button",className:"h-5 w-5 rounded-md border border-border hover:scale-110 transition-transform disabled:opacity-50",style:{backgroundColor:i},disabled:o||e.disabled,title:i,onClick:()=>n(i)},i))})]})}function SP({field:e,value:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:i,externalProbe:l}){const[c,d]=$("idle"),[f,p]=$(null),m=l?.status??c,h=l?.result??f,g=!!a||!!i,b=q(async()=>{if(g){d("probing"),p(null);try{const w=a?await a(e.key,t):await i("test-probe",e.key,t),y=w&&typeof w=="object"?w:{status:"error",error:"Probe handler returned no result"};p(y),d(y.status==="ok"?"ok":"error")}catch(w){p({status:"error",error:w instanceof Error?w.message:String(w)}),d("error")}}},[a,i,e.key,t,g]),x=m==="probing"?"border-primary/40 bg-primary/10 text-primary":m==="ok"?"border-success/40 bg-success/10 text-success hover:bg-success/15":m==="error"?"border-danger/40 bg-danger/10 text-danger hover:bg-danger/15":"border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover",v=m==="probing"?r(Lt,{className:"h-3 w-3 animate-spin"}):m==="ok"?r(p2,{className:"h-3 w-3"}):m==="error"?r(Zs,{className:"h-3 w-3"}):r(Rm,{className:"h-3 w-3"});return u(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:[u("div",{className:"@container flex items-center gap-2",style:{containerType:"inline-size"},children:[u("button",{type:"button",onClick:b,title:"Test",disabled:e.disabled||m==="probing"||!g||!t,className:`flex-shrink-0 inline-flex items-center gap-1.5 rounded-md border px-2 py-2 text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed @[280px]:px-3 ${x}`,children:[v,r("span",{className:"hidden @[280px]:inline",children:"Test"})]}),r("input",{type:e.inputType??"url",className:er+" flex-1 min-w-0",value:t==null?"":String(t),placeholder:e.placeholder,disabled:o||e.disabled,onChange:w=>{n(w.target.value),c!=="idle"&&(d("idle"),p(null))}})]}),m==="ok"&&h?.labels&&h.labels.length>0&&r("div",{className:"flex flex-wrap gap-1 mt-1.5",children:h.labels.map((w,y)=>r("span",{className:"text-xs bg-success/10 text-success rounded px-2 py-0.5 font-mono",children:w},y))}),m==="error"&&h?.error&&r("p",{className:"text-xs text-danger mt-1 truncate",title:h.error,children:h.error})]})}function CP({field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a}){const[i,l]=$(e.defaultCollapsed??!1),c=e.style==="accordion",d=e.span===2?"col-span-2":e.span===3?"col-span-3":e.span===4?"col-span-4":"col-span-1";return r("div",{className:d,children:u("div",{className:"rounded-lg border border-border bg-surface/50 overflow-hidden",children:[u("div",{className:["px-3 py-2 flex items-center justify-between",c?"cursor-pointer hover:bg-surface":""].join(" "),onClick:c?()=>l(f=>!f):void 0,children:[r("span",{className:"text-xs font-semibold text-foreground",children:Tt(e.label,s)}),c&&r("span",{className:"text-foreground-subtle text-xs",children:i?"▸":"▾"})]}),!i&&r("div",{className:"px-3 pb-3 grid grid-cols-2 gap-x-4 gap-y-3",children:e.fields.map(f=>r(tr,{field:f,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a},f.key))})]})})}function MP({field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:i}){const l=e.tabs[0]?.id??"",[c,d]=$(l),f=e.span===2?"col-span-2":e.span===3?"col-span-3":e.span===4?"col-span-4":"col-span-1";return e.tabs.length===0?null:u("div",{className:f,children:[e.label&&r("div",{className:ua,children:Tt(e.label,s)}),u("div",{className:"rounded-lg border border-border-subtle bg-surface-hover/40 overflow-hidden",children:[r("div",{className:"flex flex-wrap gap-1 p-1.5 border-b border-border-subtle bg-surface/40",role:"tablist",children:e.tabs.map(p=>{const m=p.id===c;return u("button",{type:"button",role:"tab","aria-selected":m,onClick:()=>d(p.id),className:`inline-flex items-center gap-1.5 whitespace-nowrap rounded-md px-2.5 py-1 text-[11px] transition-colors ${m?"bg-primary text-primary-foreground font-medium shadow-sm":"bg-transparent text-foreground-subtle hover:bg-surface hover:text-foreground"}`,children:[r("span",{children:Tt(p.label,s)}),p.badge&&r("span",{className:`text-[9px] px-1 py-0.5 rounded-full font-medium ${m?"bg-primary-foreground/20 text-primary-foreground":"bg-primary/10 text-primary"}`,children:p.badge})]},p.id)})}),e.tabs.map(p=>p.id!==c?null:r("div",{role:"tabpanel",className:"px-3 pb-3 pt-2 grid grid-cols-2 gap-x-4 gap-y-3",children:p.fields.map((m,h)=>{const g="key"in m&&typeof m.key=="string"?m.key:`__${p.id}__${h}`;return r(tr,{field:m,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:i},g)})},p.id))]})]})}function IP({span:e}){return r("div",{className:e===2?"col-span-2":e===3?"col-span-3":e===4?"col-span-4":"col-span-full",children:r("hr",{className:"border-border"})})}const pu={info:{border:"border-info",bg:"bg-info/5",text:"text-info"},warning:{border:"border-warning",bg:"bg-warning/5",text:"text-warning"},success:{border:"border-success",bg:"bg-success/5",text:"text-success"},danger:{border:"border-danger",bg:"bg-danger/5",text:"text-danger"}};function AP(e){if(typeof window>"u"||typeof DOMParser>"u")return"";const t=new Set(["A","UL","OL","LI","STRONG","EM","CODE","BR","P","SPAN"]),n=new DOMParser().parseFromString(`<div>${e}</div>`,"text/html"),o=n.body.firstElementChild;if(!o)return"";const s=a=>{const i=Array.from(a.children);for(const l of i){if(!t.has(l.tagName)){const d=n.createTextNode(l.textContent??"");l.replaceWith(d);continue}const c=l.tagName==="A"?new Set(["href"]):new Set;for(const d of Array.from(l.attributes))c.has(d.name)||l.removeAttribute(d.name);if(l.tagName==="A"){const d=l.getAttribute("href")??"";!/^https?:\/\//i.test(d)&&!d.startsWith("mailto:")?l.removeAttribute("href"):(l.setAttribute("target","_blank"),l.setAttribute("rel","noopener noreferrer"))}s(l)}};return s(o),o.innerHTML}function PP({field:e}){const t=e.variant??"info",n=pu[t]??pu.info,o=e.format==="html";return r("div",{className:"col-span-full",children:u("div",{className:`rounded-md border-l-4 px-3 py-2.5 ${n.border} ${n.bg}`,children:[e.label&&r("p",{className:`text-xs font-semibold mb-0.5 ${n.text}`,children:e.label}),o?r("div",{className:"text-xs text-foreground-subtle leading-relaxed info-html-content",dangerouslySetInnerHTML:{__html:AP(e.content)}}):r("p",{className:"text-xs text-foreground-subtle leading-relaxed whitespace-pre-line",children:e.content})]})})}const fu={ok:"bg-success",warn:"bg-amber-500",danger:"bg-danger",idle:"bg-foreground-subtle/40",unknown:"bg-foreground-subtle/40"};function EP(e){if(!Number.isFinite(e)||e<0)return"—";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),o=t%60;return o===0?`${n}m`:`${n}m ${o}s`}function $P(e){return!Number.isFinite(e)||e<=0?"—":new Date(e).toLocaleTimeString()}function _P({kind:e,value:t}){if(t==null||t==="")return r("span",{className:"text-foreground-subtle/60",children:"—"});if(e==="monospace")return r("span",{className:"font-mono text-[11px]",children:String(t)});if(e==="status"){const n=String(t).toLowerCase(),o=fu[n]??fu.unknown;return u("span",{className:"inline-flex items-center gap-1.5",children:[r("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${o}`}),r("span",{children:String(t)})]})}return e==="duration"&&typeof t=="number"?r("span",{className:"font-mono text-[11px]",children:EP(t)}):e==="timestamp"&&typeof t=="number"?r("span",{className:"font-mono text-[11px]",children:$P(t)}):r("span",{children:String(t)})}function DP({field:e}){const t=e.value??[],n=e.description;return u("div",{className:"col-span-full",children:[e.label&&r("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1",children:e.label}),n&&r("p",{className:"text-xs text-foreground-subtle mb-2",children:n}),t.length===0?r("div",{className:"rounded-md border border-border bg-surface-subtle px-3 py-2 text-xs text-foreground-subtle",children:e.emptyMessage??"No entries"}):r("div",{className:"rounded-md border border-border overflow-hidden",children:u("table",{className:"w-full text-xs",children:[r("thead",{className:"bg-surface-subtle border-b border-border",children:r("tr",{children:e.columns.map(o=>r("th",{className:"px-3 py-1.5 text-left font-medium text-foreground-subtle",style:o.width?{width:o.width}:void 0,children:o.label},o.key))})}),r("tbody",{className:"divide-y divide-border",children:t.map((o,s)=>r("tr",{className:"hover:bg-surface-hover/40",children:e.columns.map(a=>r("td",{className:"px-3 py-1.5 align-top text-foreground",children:r(_P,{kind:a.kind,value:o[a.key]})},a.key))},s))})]})})]})}function LP({field:e,value:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:i}){const l=Array.isArray(t)?t:[],c=e.minRows??0,d=e.maxRows??Number.POSITIVE_INFINITY,f=(x,v,w)=>{const y=l.slice(),N=y[x]??{};y[x]={...N,[v]:w},n(y)},p=x=>{l.length<=c||n(l.filter((v,w)=>w!==x))},m=()=>{if(l.length>=d)return;const x=e.defaultItem??{};n([...l,{...x}])},h=(x,v)=>e.rowTitleTemplate?e.rowTitleTemplate.replace(/\{(\w+)\}/g,(w,y)=>{const N=x[y];return N==null||N===""?"—":String(N)}):`Row ${v+1}`,g=l.length>c,b=l.length<d;return u("div",{className:"col-span-full space-y-2",children:[u("div",{className:"space-y-0.5",children:[e.label&&r("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle",children:Tt(e.label,s)}),e.description&&r("p",{className:"text-[11px] text-foreground-subtle",children:Tt(e.description,s)})]}),l.length===0?r("div",{className:"rounded-md border border-dashed border-border bg-background px-3 py-3 text-center text-[11px] text-foreground-subtle",children:e.emptyMessage??"No entries"}):r("div",{className:"space-y-2",children:l.map((x,v)=>u("div",{className:"rounded-md border border-border bg-background",children:[u("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[r("span",{className:"text-xs font-medium text-foreground",children:h(x,v)}),u("button",{type:"button",onClick:()=>p(v),disabled:o||!g,className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-30 disabled:cursor-not-allowed",title:g?"Remove this row":`At least ${c} row(s) required`,children:[r(Em,{className:"h-3 w-3"}),"Remove"]})]}),r("div",{className:"grid grid-cols-1 @[420px]:grid-cols-2 gap-x-3 gap-y-2 p-3",children:e.itemFields.map(w=>r(tr,{field:w,values:x,onChange:(y,N)=>f(v,y,N),disabled:o,translationFn:s,onTestField:a,allFields:e.itemFields,onAction:i},w.key))})]},v))}),u("div",{children:[u("button",{type:"button",onClick:m,disabled:o||!b,className:"inline-flex items-center gap-1 rounded border border-border bg-surface px-3 py-1 text-[11px] font-medium text-foreground hover:border-primary/40 hover:bg-primary/5 disabled:opacity-30 disabled:cursor-not-allowed",children:[r(Js,{className:"h-3 w-3"}),e.addLabel??"Add"]}),!b&&Number.isFinite(d)&&u("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["(limit: ",d,")"]})]})]})}function TP({field:e,disabled:t,onAction:n}){const[o,s]=$(!1),a=rt(),i=async()=>{if(!(e.confirmMessage&&!await a({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant==="danger"?"danger":"default"}))&&n){s(!0);try{await n(e.action,e.key)}finally{s(!1)}}},l={default:"border border-border text-foreground hover:bg-surface-hover",primary:"bg-primary text-primary-foreground hover:bg-primary/90",danger:"bg-danger text-white hover:bg-danger/90"};return r(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,children:r("button",{onClick:i,disabled:t||o,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors disabled:opacity-50 ${l[e.variant??"default"]??l.default}`,children:o?"Processing...":e.buttonLabel})})}function hx(e,t){const n={...e.paramsStatic??{}};if(e.paramsFromForm)for(const[o,s]of Object.entries(e.paramsFromForm)){const a=t[s];a!=null&&a!==""&&(n[o]=a)}return n}function RP({field:e,value:t,values:n,onChange:o,disabled:s,onAction:a}){const[i,l]=$(!1),[c,d]=$(null),[f,p]=$(null),m=hx(e,n),h=Object.keys(e.paramsFromForm??{}).some(w=>m[w]===void 0),g=(e.refreshOn??Object.values(e.paramsFromForm??{})).map(w=>`${w}=${JSON.stringify(n[w])}`).join("|");Y(()=>{if(!a||h){p(null),d(null);return}let w=!1;return l(!0),d(null),a(e.action,e.key,m).then(y=>{if(w)return;const N=y;let k=[];if(Array.isArray(N))k=N;else if(N&&typeof N=="object")for(const S of Object.keys(N)){const M=N[S];if(Array.isArray(M)){k=M;break}}p(k)}).catch(y=>{w||(d(y instanceof Error?y.message:String(y)),p([]))}).finally(()=>{w||l(!1)}),()=>{w=!0}},[g,a,e.action,e.key]);const b=e.mapOption.value,x=e.mapOption.label,v=e.mapOption.description;return r(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,children:h?r("div",{className:"text-[11px] text-foreground-subtle italic",children:e.emptyParamsMessage??"Fill the prerequisite fields above first."}):i?u("div",{className:"flex items-center gap-2 text-[11px] text-foreground-subtle",children:[r(Lt,{className:"h-3 w-3 animate-spin"})," Loading options…"]}):c?r("div",{className:"text-[11px] text-danger",children:c}):f&&f.length===0?r("div",{className:"text-[11px] text-foreground-subtle italic",children:e.emptyResultsMessage??"No options returned."}):(()=>{const w=(f??[]).some(y=>{const N=y[b];return N===""||N===void 0});return u("select",{className:"w-full rounded-md border border-border bg-surface px-2 py-1.5 text-xs text-foreground",value:typeof t=="string"?t:"",disabled:s,onChange:y=>o(y.target.value),children:[!w&&r("option",{value:"",children:"— Select —"}),(f??[]).map((y,N)=>{const k=y[b],S=y[x],M=v?y[v]:void 0,P=typeof k=="string"&&k!==""?k:`row-${N}`;return u("option",{value:typeof k=="string"?k:String(k??""),children:[typeof S=="string"?S:String(S??P),M!==void 0?` (${String(M)})`:""]},P)})]})})()})}function OP({field:e,values:t,disabled:n,onAction:o}){const[s,a]=$(!1),[i,l]=$(null),c=rt(),d=async()=>{if(e.confirmMessage&&!await c({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant==="danger"?"danger":"default"})||!o)return;const p=hx(e,t);a(!0),l(null);try{const m=await o(e.action,e.key,p),h=typeof m=="object"&&m!==null?m:null,g=e.successMessage?e.successMessage.replace(/\{(\w+)\}/g,(b,x)=>{const v=h?.[x];return v===void 0?"":String(v)}):"Done.";l({kind:"ok",text:g})}catch(m){l({kind:"error",text:m instanceof Error?m.message:String(m)})}finally{a(!1)}},f={default:"border border-border text-foreground hover:bg-surface-hover",primary:"bg-primary text-primary-foreground hover:bg-primary/90",danger:"bg-danger text-white hover:bg-danger/90"};return r(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,children:u("div",{className:"flex flex-col gap-1.5",children:[r("button",{onClick:d,disabled:n||s,className:`inline-flex w-fit items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors disabled:opacity-50 ${f[e.variant??"default"]??f.default}`,children:s?"Working…":e.buttonLabel}),i&&r("div",{className:`text-[11px] ${i.kind==="ok"?"text-emerald-700 dark:text-emerald-300":"text-danger"}`,children:i.text})]})})}function zP({field:e}){const t=pn();return r(Qe,{label:e.label,description:e.description,required:e.required,span:e.span,children:r(it,{widgetId:e.widgetId,host:"device-tab",config:e.widgetConfig,deviceId:t??void 0,instanceId:e.key})})}function BP(e,t){if(e==null)return"—";if(typeof e=="boolean")return e?"yes":"no";if(typeof e=="number"){const n=Number.isInteger(e)?String(e):e.toFixed(2);return t?`${n} ${t}`:n}return typeof e=="string"?e:JSON.stringify(e)}function FP({field:e,values:t,onAction:n,translationFn:o}){const s="key"in e?e.key:void 0;if(!s)return null;const a=t[s],i=a!==void 0?a:"default"in e?e.default:void 0,l="unit"in e?e.unit:void 0,c=BP(i,l),d="label"in e?e.label:void 0,f="description"in e?e.description:void 0,p="span"in e?e.span:void 0,m="actions"in e?e.actions??[]:[];return r(Qe,{label:d,description:f,span:p,translationFn:o,children:u("div",{className:"flex items-stretch gap-1",children:[r("div",{className:"flex-1 rounded-md border border-border bg-surface-alt px-2.5 py-1.5 text-xs text-foreground font-mono break-all",children:c}),m.length>0&&r("div",{className:"flex items-center gap-1",children:m.map(h=>r(HP,{action:h,fieldKey:s,value:i,onAction:n},h.action))})]})})}function jP({name:e}){const t="h-3.5 w-3.5";switch(e){case"copy":return r(Mn,{className:t});case"refresh-cw":return r(Ol,{className:t});case"external-link":return r(Sm,{className:t});case"trash-2":return r(rn,{className:t});case"download":return r(Oi,{className:t});case"upload":return r(Tm,{className:t});default:return r(zl,{className:t})}}function HP({action:e,fieldKey:t,value:n,onAction:o}){const s=rt(),[a,i]=$(!1),l=e.variant==="danger"?"text-danger hover:bg-danger/10 border-danger/30":e.variant==="primary"?"text-primary hover:bg-primary/10 border-primary/30":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover border-border";return r("button",{type:"button",onClick:async()=>{if(!(e.confirmMessage&&!await s({title:e.tooltip,message:e.confirmMessage,variant:e.variant==="danger"?"danger":"default"}))){if(e.action==="copy-value"){try{await navigator.clipboard.writeText(typeof n=="string"?n:String(n))}catch{}return}if(o){i(!0);try{await o(e.action,t)}finally{i(!1)}}}},disabled:a,title:e.tooltip,className:`inline-flex items-center justify-center rounded-md border px-2 py-1.5 transition-colors disabled:opacity-50 ${l}`,children:r(jP,{name:e.icon})})}function VP(e){return"multiple"in e&&e.multiple!=null}function qP({field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c}){const d=e.multiple,f=d.min,p=d.max,m=t[e.key],g=[...Array.isArray(m)?m:m!=null?[m]:[]],b=d.itemDefault!==void 0?d.itemDefault:"default"in e&&e.default!==void 0?e.default:"";for(;g.length<f;)g.push(b);const x=k=>n(e.key,[...k]),v=(k,S)=>{const M=[...g];M[k]=S,x(M)},w=()=>{g.length>=p||x([...g,b])},y=k=>{g.length<=f||x(g.filter((S,M)=>M!==k))},N=()=>{const{multiple:k,...S}=e;return{...S,...{label:void 0,description:void 0,required:!1}}};return r(Qe,{label:e.label,description:e.description,required:f>0?e.required:!1,span:e.span,translationFn:s,children:u("div",{className:"space-y-2",children:[g.map((k,S)=>{const M=d.itemLabel?.replace("${n}",String(S+1));return u("div",{className:"space-y-1",children:[M&&r("div",{className:ua,children:M}),u("div",{className:"flex items-center gap-2",children:[r("div",{className:"flex-1 min-w-0",children:r(tr,{field:N(),values:{...t,[e.key]:k},onChange:(P,I)=>v(S,I),disabled:o,translationFn:s,onTestField:a,onAction:c,allFields:l})}),g.length>f&&r("button",{type:"button",onClick:()=>y(S),disabled:o,title:"Remove",className:"flex-shrink-0 inline-flex items-center justify-center rounded-md border border-border p-1.5 text-foreground-subtle hover:text-danger hover:border-danger/50 transition-colors disabled:opacity-40",children:r(rn,{className:"h-3.5 w-3.5"})})]})]},S)}),u("div",{className:"flex items-center justify-between pt-1",children:[g.length<p?u("button",{type:"button",onClick:w,disabled:o,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40",children:[r(Js,{className:"h-3 w-3"}),d.addLabel??"Add"]}):r("span",{}),u("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[g.length,"/",p]})]})]})})}function Sc(e,t,n){if(!("showWhen"in e)||!e.showWhen)return!0;const o=e.showWhen,s=t[o.field],a=n?.find(c=>"key"in c&&c.key===o.field),i=a&&"default"in a?a.default:void 0,l=s!==void 0?s:i;return o.equals!==void 0?l===o.equals:o.notEquals!==void 0?l!==o.notEquals:o.in!==void 0?o.in.includes(l):o.notIn!==void 0?!o.notIn.includes(l):o.includes!==void 0?Array.isArray(l)&&l.includes(o.includes):o.notIncludes!==void 0?!Array.isArray(l)||!l.includes(o.notIncludes):!0}function tr({field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c}){if(VP(e))return r(qP,{field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c});if("readonlyField"in e&&e.readonlyField===!0)return r(FP,{field:e,values:t,onAction:c,translationFn:s});if(!Sc(e,t,l))return null;const d=t[e.key],f=d!==void 0?d:"default"in e?e.default:void 0,p=h=>n(e.key,h),m=Fh(e.type);switch(e.type){case"text":return r(mP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"number":return r(hP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"boolean":return r(gP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"select":return r(bP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"multiselect":return r(xP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"password":return r(yP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"textarea":return r(vP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"slider":return r(wP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"tags":return r(NP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"color":return r(kP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"node-select":return r(fx,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"node-multiselect":return r(mx,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"probe":return r(SP,{field:e,value:f,onChange:p,disabled:o,translationFn:s,onTestField:a,onAction:c,externalProbe:i});case"group":return r(CP,{field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a});case"sub-tabs":return r(MP,{field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:c});case"separator":return r(IP,{});case"info":return r(PP,{field:e});case"object-array":return r(DP,{field:e});case"editable-array":return r(LP,{field:e,value:f,onChange:p,disabled:o,translationFn:s,onTestField:a,onAction:c});case"button":return r(TP,{field:e,disabled:o,onAction:c});case"addon-action-select":return r(RP,{field:e,value:f,values:t,onChange:p,disabled:o,onAction:c});case"addon-action-button":return r(OP,{field:e,values:t,disabled:o,onAction:c});case"widget":return r(zP,{field:e});default:return m?r(m,{field:e,value:f,onChange:p,disabled:o}):null}}function QP(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Tt(e,t){if(e!==void 0)return t&&QP(e)?t(e):e}function UP({section:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,probeResults:i}){const[l,c]=$(e.defaultCollapsed??!1),d=e.style==="accordion",f=e.columns??2,p=f===1?"grid-cols-1":f===3?"grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3":f===4?"grid-cols-1 @[480px]:grid-cols-2 @[1140px]:grid-cols-4":"grid-cols-1 @[640px]:grid-cols-2";return u("div",{className:"@container rounded-lg border border-border bg-surface p-3",style:{containerType:"inline-size"},children:[u("div",{className:["flex items-center justify-between mb-2",d?"cursor-pointer":""].join(" "),onClick:d?()=>c(m=>!m):void 0,children:[u("div",{children:[r("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:Tt(e.title,s)}),e.description&&r("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:Tt(e.description,s)})]}),d&&r("span",{className:"text-foreground-subtle text-xs ml-2",children:l?"▸":"▾"})]}),!l&&r("div",{className:`grid ${p} gap-x-3 gap-y-2.5`,children:e.fields.map(m=>r(tr,{field:m,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i?.[m.key]},m.key))})]})}function gx({schema:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,probeResults:i,onClearProbe:l}){const c=(d,f)=>{n({...t,[d]:f}),l?.(d)};return r("div",{className:"space-y-4",children:e.sections.map(d=>r(UP,{section:d,values:t,onChange:c,disabled:o,translationFn:s,onTestField:a,probeResults:i},d.id))})}const KP=({open:e})=>r("svg",{className:`h-3 w-3 transition-transform ${e?"rotate-90":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:r("polyline",{points:"9 18 15 12 9 6"})});function mu(e){const t={};if(!e)return t;for(const n of e.sections)for(const o of n.fields){if(o.type==="separator"||o.type==="info"||o.type==="button"||o.type==="group")continue;const s=o.key;t[s]=o.value}return t}function GP(e){return{...e,sections:e.sections.map(t=>({...t,fields:t.fields.map(n=>{if(n.type==="separator"||n.type==="info"||n.type==="button"||n.type==="group")return n;const{value:o,...s}=n;return s})}))}}function WP({trpc:e,addonId:t,nodeId:n,title:o,disabled:s,onAfterChange:a,refreshToken:i,collapsible:l,defaultOpen:c,mode:d,onOverrideChange:f}){const p=d??"persist",[m,h]=$(null),[g,b]=$(!0),[x,v]=$(null),[w,y]=$(!1),[N,k]=$(c??!1),[S,M]=$({}),[P,I]=$(null);Y(()=>{I(null),M({})},[e,t,n,i,p]);const F=JSON.stringify(S);Y(()=>{let _=!1;b(!0),v(null);const R=p==="override"&&Object.keys(S).length>0?S:void 0;return e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n,...R?{overlay:R}:{}}).then(L=>{_||(h(L),R||I(mu(L)),b(!1))}).catch(L=>{_||(v(L instanceof Error?L.message:String(L)),b(!1))}),()=>{_=!0}},[e,t,n,i,p,F]);const E=Q(()=>mu(m),[m]),B=Q(()=>m?GP(m):null,[m]),O=async _=>{if(p==="override"){const L=P??E,z={};for(const H of Object.keys(_))_[H]!==L[H]&&(z[H]=_[H]);const j={...L,...z};M(z),f?.(z,j);return}const R={};for(const L of Object.keys(_))_[L]!==E[L]&&(R[L]=_[L]);if(Object.keys(R).length!==0){y(!0);try{await e.addonSettings.updateGlobalSettings.mutate({addonId:t,nodeId:n,patch:R});const L=await e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n});h(L),a?.()}catch(L){v(L instanceof Error?L.message:String(L))}finally{y(!1)}}};if(g)return u("div",{className:"text-xs text-foreground-subtle animate-pulse",children:["Loading ",o??t,"…"]});if(x)return u("div",{className:"text-xs text-red-400",children:[o??t,": ",x]});if(!m||!B)return u("div",{className:"text-xs text-foreground-subtle",children:[o??t," not available on ",n,"."]});const A=p==="override"?{...E,...S}:E,D=u(ve,{children:[p==="override"?r("div",{className:"mb-2 text-[11px] text-foreground-subtle",children:"Benchmark override — applies to this run only. The addon's saved settings are not changed."}):null,r(gx,{schema:B,values:A,onChange:O,disabled:s===!0||w})]});return l===!0?u("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("button",{type:"button",onClick:()=>k(_=>!_),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover text-left","aria-expanded":N,children:[r(KP,{open:N}),r("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide flex-1",children:o??t}),r("span",{className:"text-[10px] text-foreground-subtle",children:N?"hide":"edit"})]}),N?r("div",{className:"border-t border-border px-4 py-3",children:D}):null]}):o?u("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r("div",{className:"border-b border-border px-4 py-2",children:r("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:o})}),r("div",{className:"px-4 py-3",children:D})]}):r("div",{children:D})}function bx({detections:{motion:e,motionRaw:t,detection:n,phase:o},showMotionZones:s=!0,showMotionRaw:a=!0,showDetections:i=!0,showPhaseIndicator:l=!0}){const c=s&&e&&e.zones.length>0,d=a&&t&&t.boxes.length>0,f=i&&n&&n.detections.length>0;return!c&&!d&&!f&&!l?null:u("div",{className:"absolute inset-0 pointer-events-none z-10",children:[l&&r(YP,{phase:o}),d&&r(ZP,{raw:t}),c&&r(XP,{motion:e}),f&&r(JP,{detections:n.detections,frameWidth:n.frameWidth,frameHeight:n.frameHeight})]})}function YP({phase:e}){const t=Wn(e);return u("div",{className:"absolute top-2 left-2 flex items-center gap-1.5 px-2 py-1 rounded-md bg-black/60 backdrop-blur-sm",children:[r("span",{className:`w-2 h-2 rounded-full ${t.dotClass}`}),r("span",{className:"text-[10px] font-semibold text-white uppercase tracking-wider",children:t.label})]})}function ZP({raw:e}){return e.frameWidth===0||e.frameHeight===0?null:r(ve,{children:e.boxes.map((t,n)=>{const[o,s,a,i]=t.bbox,l=o/e.frameWidth*100,c=s/e.frameHeight*100,d=(a-o)/e.frameWidth*100,f=(i-s)/e.frameHeight*100,p=Math.max(.05,Math.min(.25,t.changeScore*.3));return r("div",{className:"absolute rounded-sm",style:{left:`${l}%`,top:`${c}%`,width:`${d}%`,height:`${f}%`,backgroundColor:`rgba(239, 68, 68, ${p})`}},`mr-${n}`)})})}function XP({motion:e}){if(e.frameWidth===0||e.frameHeight===0)return null;const t=e.zones.filter(n=>n.w*n.h/(e.frameWidth*e.frameHeight)<.9);return r(ve,{children:t.map((n,o)=>{const s=Math.max(.15,Math.min(.5,n.intensity/255));return r("div",{className:"absolute rounded-sm",style:{left:`${n.x/e.frameWidth*100}%`,top:`${n.y/e.frameHeight*100}%`,width:`${n.w/e.frameWidth*100}%`,height:`${n.h/e.frameHeight*100}%`,border:`1px solid rgba(250, 204, 21, ${s})`,backgroundColor:`rgba(250, 204, 21, ${s*.15})`}},`mz-${o}`)})})}function JP({detections:e,frameWidth:t,frameHeight:n}){return t===0||n===0?null:r(ve,{children:e.map(o=>{const{x:s,y:a,width:i,height:l}=o.bbox,c=s/t*100,d=a/n*100,f=i/t*100,p=l/n*100,m=ct(o.macroClass),h=[`${o.macroClass} ${(o.score*100).toFixed(0)}%`];for(const g of o.labels)h.push(g.label);return r("div",{className:"absolute border-2 rounded-sm",style:{left:`${c}%`,top:`${d}%`,width:`${f}%`,height:`${p}%`,borderColor:m},children:r("div",{className:"absolute -top-4 left-0 px-1 py-0.5 text-[9px] font-bold text-white rounded-sm whitespace-nowrap",style:{backgroundColor:m},children:h.join(" | ")})},`det-${o.id}`)})})}function eE(e){const t={};if(typeof window<"u"){if(e){const o=e.getBoundingClientRect();o.width>0&&o.height>0&&(t.viewportWidth=Math.round(o.width),t.viewportHeight=Math.round(o.height))}t.viewportWidth===void 0&&(t.viewportWidth=window.innerWidth,t.viewportHeight=window.innerHeight),t.devicePixelRatio=window.devicePixelRatio||1;const n=navigator.connection;n?.downlink&&n.downlink>0&&(t.downlinkMbps=n.downlink)}return t}const tE=3e3,nE=5;function xx({serverUrl:e,streamKey:t,label:n,autoPlay:o=!0,muted:s=!0,showControls:a=!0,className:i="",onStateChange:l,onError:c,overlay:d,createSession:f,sendAnswer:p,closeSession:m,hintsOverride:h}){const g=ne(null),b=ne(null),x=ne(null),v=ne(new Set),w=ne(null),y=ne(null),N=ne(0),k=ne(!0),[S,M]=$("idle"),[P,I]=$(""),[F,E]=$(s),[B,O]=$(!1),[A,D]=$(!1),_=ne(null),R=ne(!1);(p||f)&&(R.current=!0);const L=R.current,z=q(U=>{M(U),l?.(U)},[l]),j=q(()=>{if(w.current?.abort(),w.current=null,y.current&&(clearTimeout(y.current),y.current=null),x.current&&(x.current.close(),x.current=null),m&&v.current.size>0){for(const U of v.current)m(U).catch(()=>{});v.current.clear()}g.current&&(g.current.srcObject=null)},[m]),H=q(async()=>{if(!k.current||!f||!p)return;j(),z("connecting");const U=new AbortController;w.current=U;try{const ae={...eE(b.current),...h},{sessionId:fe,sdpOffer:he}=await f(ae);if(v.current.add(fe),!k.current||U.signal.aborted){m?.(fe).catch(()=>{}),v.current.delete(fe);return}const V=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});x.current=V;const ie=new MediaStream;V.ontrack=pe=>{console.debug("[WebRTC] ontrack",pe.track.kind,pe.track.readyState),ie.addTrack(pe.track),g.current&&(g.current.srcObject=ie,g.current.play().catch(()=>{}))},V.oniceconnectionstatechange=()=>{if(!k.current)return;const pe=V.iceConnectionState;console.debug("[WebRTC] ICE state:",pe),pe==="connected"||pe==="completed"?(N.current=0,z("playing"),g.current?.paused&&(console.debug("[WebRTC] video was paused at ICE connected — calling play()"),g.current.play().catch(()=>{}))):(pe==="failed"||pe==="disconnected"||pe==="closed")&&(z("disconnected"),ee())},V.onicecandidateerror=pe=>{console.debug("[WebRTC] ICE candidate error:",pe)},console.debug("[WebRTC] Setting remote description (server offer)..."),await V.setRemoteDescription({type:"offer",sdp:he});const ue=await V.createAnswer();if(await V.setLocalDescription(ue),console.debug("[WebRTC] Local description set, waiting for ICE gathering..."),await hu(V),!k.current)return;const de=(V.localDescription?.sdp??"").split(`
|
|
531
|
+
`).filter(pe=>pe.startsWith("a=candidate:")).length;console.debug("[WebRTC] Sending answer to server",{localCandidates:de,sessionId:fe.slice(0,8)}),await p(fe,V.localDescription?.sdp??""),console.debug("[WebRTC] Answer sent successfully");const le=V,Se=()=>{const pe=le.connectionState;if(pe==="closed"||pe==="failed")return;const Ie=g.current;Ie&&Ie.readyState===0&&console.log(`[WebRTC] no video data yet (ice=${le.iceConnectionState})`)};setTimeout(Se,3e3),setTimeout(Se,8e3)}catch(J){if(!k.current)return;const ae=J instanceof Error?J.message:String(J);I(ae),z("error"),c?.(ae),ee()}},[e,t,f,p,j,z,c,h]),T=q(async()=>{if(k.current){j(),z("connecting");try{const U=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});x.current=U,U.addTransceiver("video",{direction:"recvonly"}),U.addTransceiver("audio",{direction:"recvonly"});const J=new MediaStream;U.ontrack=ie=>{J.addTrack(ie.track),g.current&&(g.current.srcObject=J,g.current.play().catch(()=>{}))},U.oniceconnectionstatechange=()=>{if(!k.current)return;const ie=U.iceConnectionState;ie==="connected"||ie==="completed"?(N.current=0,z("playing"),g.current?.paused&&g.current.play().catch(()=>{})):(ie==="failed"||ie==="disconnected"||ie==="closed")&&(z("disconnected"),ee())};const ae=await U.createOffer();if(await U.setLocalDescription(ae),await hu(U),!k.current)return;const fe=`${e}/api/webrtc?src=${encodeURIComponent(t)}`,he=await fetch(fe,{method:"POST",headers:{"Content-Type":"application/sdp"},body:U.localDescription?.sdp??""});if(!he.ok)throw new Error(`WHEP ${he.status}: ${he.statusText}`);const V=await he.text();await U.setRemoteDescription({type:"answer",sdp:V})}catch(U){if(!k.current)return;const J=U instanceof Error?U.message:String(U);I(J),z("error"),c?.(J),ee()}}},[e,t,j,z,c]),W=L?H:T,G=ne(()=>{});G.current=W;const ee=q(()=>{k.current&&(N.current>=nE||(N.current+=1,y.current=setTimeout(()=>{k.current&&G.current()},tE)))},[]);Y(()=>(k.current=!0,N.current=0,o&&W(),()=>{k.current=!1,j()}),[e,t]);const se=ne(!1);Y(()=>{!o||!L||!f||!p||se.current||x.current||(se.current=!0,W())},[o,L,f,p,W]);const te=()=>{N.current=0,W()},X=()=>{g.current&&(g.current.muted=!g.current.muted,E(g.current.muted))},re=async()=>{if(b.current)try{document.fullscreenElement?await document.exitFullscreen():await b.current.requestFullscreen()}catch(U){console.warn(`Fullscreen toggle failed: ${U instanceof Error?U.message:U}`)}},ge=()=>{if(!g.current)return;const U=document.createElement("canvas");U.width=g.current.videoWidth||1280,U.height=g.current.videoHeight||720;const J=U.getContext("2d");if(!J)return;J.drawImage(g.current,0,0);const ae=document.createElement("a");ae.download=`${t.replace(/[/:]/g,"-")}-${Date.now()}.jpg`,ae.href=U.toDataURL("image/jpeg",.92),ae.click()};Y(()=>{const U=()=>O(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",U),()=>document.removeEventListener("fullscreenchange",U)},[]);const Z=()=>{D(!0),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>D(!1),3e3)};return u("div",{ref:b,className:`relative bg-black overflow-hidden group ${i}`,onMouseMove:Z,onMouseEnter:Z,children:[r("video",{ref:g,autoPlay:o,muted:F,playsInline:!0,className:"w-full h-full object-contain"}),n&&S==="playing"&&r("div",{className:"absolute top-2 left-2 px-2 py-0.5 rounded bg-black/60 text-[10px] text-white font-medium",children:n}),d,S==="connecting"&&u("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/70 gap-2",children:[r("svg",{className:"h-6 w-6 text-white/60 animate-spin",viewBox:"0 0 24 24",fill:"none",children:r("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"32",strokeDashoffset:"32",className:"animate-[dash_1.5s_ease-in-out_infinite]"})}),r("span",{className:"text-xs text-white/60",children:"Connecting…"})]}),(S==="error"||S==="disconnected")&&u("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/70 gap-2",children:[r("svg",{className:"h-6 w-6 text-red-400",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:r("path",{d:"M1 1l5.5 5.5M23 23l-5.5-5.5M8.11 15.89a8 8 0 0110.78-10.78M3.64 3.64A12 12 0 0020.36 20.36",strokeLinecap:"round"})}),r("span",{className:"text-xs text-red-400 text-center px-4",children:S==="error"?P||"Connection failed":"Disconnected"}),r("button",{onClick:te,className:"mt-1 inline-flex items-center gap-1.5 rounded px-3 py-1 text-xs bg-white/10 text-white hover:bg-white/20 transition-colors",children:"Reconnect"})]}),a&&S==="playing"&&u("div",{className:`absolute bottom-0 inset-x-0 flex items-center justify-between px-3 py-1.5 bg-gradient-to-t from-black/80 to-transparent transition-opacity duration-200 ${A?"opacity-100":"opacity-0"}`,children:[r("div",{className:"flex items-center gap-1",children:r(Ka,{onClick:X,title:F?"Unmute":"Mute",children:F?u("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[r("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),r("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),r("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]}):u("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[r("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),r("path",{d:"M19.07 4.93a10 10 0 010 14.14M15.54 8.46a5 5 0 010 7.07"})]})})}),u("div",{className:"flex items-center gap-1",children:[r(Ka,{onClick:ge,title:"Take snapshot",children:u("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[r("path",{d:"M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z"}),r("circle",{cx:"12",cy:"13",r:"4"})]})}),r(Ka,{onClick:re,title:B?"Exit fullscreen":"Fullscreen",children:B?r("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:r("path",{d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):r("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:r("path",{d:"M8 3H5a2 2 0 00-2 2v3m18 0V5a2 2 0 00-2-2h-3m0 18h3a2 2 0 002-2v-3M3 16v3a2 2 0 002 2h3"})})})]})]})]})}function Ka({onClick:e,title:t,children:n}){return r("button",{onClick:e,title:t,className:"rounded-full p-1.5 text-white/80 hover:text-white hover:bg-white/20 transition-colors",children:n})}async function hu(e){if(e.iceGatheringState!=="complete")return new Promise(t=>{const n=()=>{e.iceGatheringState==="complete"&&(e.removeEventListener("icegatheringstatechange",n),t())};e.addEventListener("icegatheringstatechange",n),setTimeout(t,5e3)})}const Cc=un("camstack:player-overlays-state",null),Mc=un("camstack:player-overlays-actions",null);function yx({children:e}){const[t,n]=$(()=>new Map),[o,s]=$(()=>new Map),a=q(p=>{n(m=>{const h=new Map(m);return h.set(p.id,p),h})},[]),i=q(p=>{n(m=>{if(!m.has(p))return m;const h=new Map(m);return h.delete(p),h})},[]),l=q(p=>{s(m=>{const h=new Map(m);return h.set(p.id,p),h})},[]),c=q(p=>{s(m=>{if(!m.has(p))return m;const h=new Map(m);return h.delete(p),h})},[]),d=Q(()=>({layers:t,buttons:o}),[t,o]),f=Q(()=>({setLayer:a,removeLayer:i,setButton:l,removeButton:c}),[a,i,l,c]);return r(Cc.Provider,{value:d,children:r(Mc.Provider,{value:f,children:e})})}function vx(){const e=ye(Cc);return Q(()=>e?[...e.layers.values()].sort((t,n)=>t.order-n.order):[],[e])}function wx(){const e=ye(Cc);return Q(()=>e?[...e.buttons.values()].sort((t,n)=>t.order-n.order):[],[e])}function rE(e){const t=ye(Mc);Y(()=>{if(!(!t||!e))return t.setLayer(e),()=>t.removeLayer(e.id)},[t,e])}function oE(e){const t=ye(Mc);Y(()=>{if(!(!t||!e))return t.setButton(e),()=>t.removeButton(e.id)},[t,e])}function sE(e){return e==="streaming"?"bg-emerald-500":e==="connecting"?"bg-amber-500":e==="error"?"bg-rose-500":"bg-zinc-500"}function aE(e){const t=Math.floor(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h${Math.floor(t%3600/60)}m`}function Ui({className:e}){return r("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r("polygon",{points:"5 3 19 12 5 21 5 3"})})}function iE({className:e}){return r("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})})}function lE({className:e}){return u("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"}),r("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),r("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),r("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})}function cE({className:e}){return u("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:[r("circle",{cx:"5",cy:"12",r:"2"}),r("circle",{cx:"12",cy:"12",r:"2"}),r("circle",{cx:"19",cy:"12",r:"2"})]})}function Ga({label:e,active:t,onClick:n}){return u("button",{type:"button",onClick:n,className:"w-full flex items-center justify-between gap-3 px-3 py-1.5 text-[11px] text-foreground hover:bg-surface-hover transition-colors",children:[r("span",{children:e}),r("span",{className:`inline-block h-3 w-5 rounded-full transition-colors ${t?"bg-primary":"bg-foreground-subtle/30"} relative`,children:r("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-white transition-all ${t?"left-2.5":"left-0.5"}`})})]})}function Nx({className:e}){return u("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("polyline",{points:"23 4 23 10 17 10"}),r("polyline",{points:"1 20 1 14 7 14"}),r("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]})}function dE({className:e}){return u("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),r("path",{d:"M10.41 10.41a2 2 0 11-2.83-2.83"}),r("line",{x1:"13.5",y1:"13.5",x2:"6",y2:"21"}),r("path",{d:"M18 12l-1.5-1.5"}),r("path",{d:"M21 15V5a2 2 0 00-2-2H5"}),r("path",{d:"M21 21H5a2 2 0 01-2-2V11"})]})}function Ic({serverUrl:e,createSession:t,sendAnswer:n,closeSession:o,streams:s,activeStreamId:a,onStreamChange:i,deviceName:l,phase:c,pipelineMetrics:d,detections:f,defaultShowDetections:p=!0,defaultShowMotion:m=!1,streamStats:h,autoPlay:g=!1,showPlayStop:b=!1,snapshotSrc:x,snapshotLoading:v=!1,onRefreshSnapshot:w,showStreamStats:y=!1,children:N,extraOverlay:k,ptzAvailable:S=!1,ptzShown:M=!1,ptzOverlay:P,onPtzToggle:I,intercomAvailable:F=!1,intercomShown:E=!1,onIntercomToggle:B,chromeless:O=!1,className:A}){const D=wx(),[_,R]=$(g),[L,z]=$(p),[j,H]=$(m),[T,W]=$(null),[G,ee]=$(!1),se=ne(null);Y(()=>{if(!G)return;function le(Se){se.current&&!se.current.contains(Se.target)&&ee(!1)}return document.addEventListener("mousedown",le),()=>document.removeEventListener("mousedown",le)},[G]);const te=a??T??s?.[0]?.id??"",X=s?.find(le=>le.id===te)??s?.[0],re=X?.inputFps!=null?{status:X.status??"unknown",inputFps:X.inputFps,bitrateKbps:X.bitrateKbps??0}:null,ge=le=>{W(le),i?.(le),_&&b&&(R(!1),setTimeout(()=>R(!0),50))},Z=Q(()=>{const le=X?.target;if(le)return Se=>t(le,Se)},[t,X]),U=s,J=()=>R(!0),ae=()=>R(!1),fe=d?.phase??c,he=fe==="active",V=!!f,ie=V&&(L||j),ue=S&&M&&!!P,de=b?_:!0;return u("div",{className:`overflow-hidden ${O?"":"rounded-xl border border-border bg-surface"} ${A??""}`,children:[u("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[u("div",{className:"flex items-center gap-2",children:[(h??re)&&r("span",{className:`w-2 h-2 rounded-full ${sE((h??re).status)}`}),l&&r("span",{className:"text-xs font-medium text-foreground",children:l}),U&&U.length>1&&u("div",{className:"relative",children:[r("select",{"data-testid":"stream-profile-select",value:te,onChange:le=>ge(le.target.value),className:"appearance-none cursor-pointer rounded-md border border-border bg-surface-hover hover:bg-surface text-foreground text-[11px] font-medium pl-2 pr-6 py-1 focus:outline-none focus:ring-1 focus:ring-primary transition-colors",children:U.map(le=>r("option",{value:le.id,children:le.label},le.id))}),r("span",{className:"pointer-events-none absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle",children:r("svg",{className:"h-2.5 w-2.5",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r("polyline",{points:"3 4.5 6 7.5 9 4.5"})})})]})]}),u("div",{className:"flex items-center gap-1.5",children:[F&&u("button",{"data-testid":"stream-intercom-toggle","data-intercom-shown":E?"true":"false",onClick:B,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${E?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:E?"Close intercom":"Open intercom",children:[r(lE,{className:"h-3 w-3"}),r("span",{className:"hidden xl:inline",children:"Intercom"})]}),D.map(le=>{const pe=le.tone==="primary"?"bg-primary text-primary-foreground":"bg-primary/15 text-primary";return u("button",{type:"button","data-toolbar-button-id":le.id,"data-toolbar-button-active":le.active?"true":"false",onClick:le.onClick,disabled:le.disabled,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors disabled:opacity-50 ${le.active?pe:"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:le.title??le.label,children:[le.icon,r("span",{className:"hidden xl:inline",children:le.label})]},le.id)}),b&&u("button",{"data-testid":"stream-play-toggle","data-stream-playing":de?"true":"false",onClick:de?ae:J,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${de?"bg-danger/10 text-danger hover:bg-danger/20":"bg-primary/10 text-primary hover:bg-primary/20"}`,title:de?"Stop stream":"Start stream",children:[de?r(iE,{className:"h-3 w-3"}):r(Ui,{className:"h-3 w-3"}),r("span",{className:"hidden xl:inline",children:de?"Stop":"Play"})]}),w&&u("button",{"data-testid":"stream-snapshot-refresh",onClick:w,disabled:v,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",title:"Force snapshot refresh",children:[r(Nx,{className:`h-3 w-3 ${v?"animate-spin":""}`}),r("span",{className:"hidden xl:inline",children:"Snapshot"})]}),(V||S||d||fe||h||re&&re.inputFps>0)&&u("div",{ref:se,className:"relative",children:[r("button",{onClick:()=>ee(le=>!le),title:"More controls",className:"inline-flex items-center justify-center rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:r(cE,{className:"h-3.5 w-3.5"})}),G&&u("div",{className:"absolute right-0 top-full mt-1 z-30 min-w-[200px] rounded-lg border border-border bg-surface shadow-xl py-1.5",children:[y&&h&&u("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Input"}),u("span",{className:"tabular-nums text-foreground",children:[h.inputFps.toFixed(1)," fps"]})]}),u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Decode"}),u("span",{className:"tabular-nums text-foreground",children:[h.decodeFps.toFixed(1)," fps"]})]}),u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Uptime"}),r("span",{className:"tabular-nums text-foreground",children:aE(h.uptimeMs)})]})]}),!y&&re&&re.inputFps>0&&u("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Input"}),u("span",{className:"tabular-nums text-foreground",children:[re.inputFps.toFixed(1)," fps"]})]}),re.bitrateKbps>0&&u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Bitrate"}),u("span",{className:"tabular-nums text-foreground",children:[re.bitrateKbps," kbps"]})]})]}),(d||V&&fe)&&u("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[u("div",{className:"flex justify-between gap-3 items-center",children:[r("span",{children:"Phase"}),u("span",{className:`flex items-center gap-1 font-semibold uppercase tracking-wider ${he?"text-red-400":"text-emerald-400"}`,children:[r("span",{className:`w-1.5 h-1.5 rounded-full ${he?"bg-red-500 animate-pulse":"bg-emerald-500"}`}),he?"Active":"Watching"]})]}),d&&d.detectionFps>0&&u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Detection"}),u("span",{className:"tabular-nums text-foreground",children:[d.detectionFps.toFixed(1)," det/s"]})]}),d&&d.avgInferenceMs>0&&u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Inference"}),u("span",{className:"tabular-nums text-foreground",children:[d.avgInferenceMs.toFixed(0)," ms"]})]})]}),V&&u(ve,{children:[r(Ga,{label:"Show detections",active:L,onClick:()=>z(le=>!le)}),r(Ga,{label:"Show motion",active:j,onClick:()=>H(le=>!le)})]}),S&&r(Ga,{label:"PTZ controls",active:M,onClick:()=>{I?.(),ee(!1)}})]})]})]})]}),de?r("div",{className:"aspect-video relative",children:r(xx,{serverUrl:e,streamKey:te,autoPlay:!0,className:"w-full h-full",createSession:Z,sendAnswer:n,closeSession:o,overlay:ie||k||ue?u(ve,{children:[ie&&r(bx,{detections:f,showPhaseIndicator:!1,showMotionZones:j,showMotionRaw:j,showDetections:L}),k,ue&&P]}):void 0},te)}):r(uE,{src:x??null,isLoading:v,onPlay:J,onRetry:w,extraOverlay:k||ue?u(ve,{children:[k,ue&&P]}):null,suppressPlayHover:!!k||ue}),N]})}function uE({src:e,isLoading:t,onPlay:n,onRetry:o,extraOverlay:s,suppressPlayHover:a=!1}){return e?u("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:[r("img",{src:e,alt:"Camera snapshot",className:"w-full h-full object-contain"}),!a&&r("button",{onClick:n,className:"absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 hover:opacity-100 transition-opacity cursor-pointer",children:r("div",{className:"h-14 w-14 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center",children:r(Ui,{className:"h-7 w-7 text-white ml-0.5"})})}),s]}):t?r("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:r("div",{className:"h-8 w-8 border-2 border-white/20 border-t-white/60 rounded-full animate-spin"})}):r("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:u("div",{className:"flex flex-col items-center gap-2 text-white/40",children:[r(dE,{className:"h-8 w-8"}),r("span",{className:"text-xs",children:"No snapshot available"}),u("div",{className:"flex items-center gap-2 mt-1",children:[o&&u("button",{onClick:o,className:"inline-flex items-center gap-1.5 rounded-md border border-white/20 px-3 py-1.5 text-xs font-medium text-white/60 hover:text-white hover:border-white/40 transition-colors",children:[r(Nx,{className:"h-3 w-3"}),"Retry"]}),u("button",{onClick:n,className:"inline-flex items-center gap-1.5 rounded-md bg-primary/80 px-3 py-1.5 text-xs font-medium text-white hover:bg-primary transition-colors",children:[r(Ui,{className:"h-3 w-3"}),"Play Live"]})]})]})})}function pE({samples:e,sampleRate:t=16e3,height:n=96,className:o="",color:s="#3b82f6",bgColor:a="transparent"}){const i=ne(null),l=ne(null),c=q(()=>{const p=i.current,m=l.current;if(!p||!m||!e||e.length===0)return;const h=m.clientWidth;if(h===0)return;const g=window.devicePixelRatio||1;p.width=h*g,p.height=n*g,p.style.width=`${h}px`,p.style.height=`${n}px`;const b=p.getContext("2d");if(!b)return;b.scale(g,g),a!=="transparent"?(b.fillStyle=a,b.fillRect(0,0,h,n)):b.clearRect(0,0,h,n);const x=e.length/h,v=n/2;b.fillStyle=s,b.globalAlpha=.7;for(let w=0;w<h;w++){const y=Math.floor(w*x),N=Math.min(Math.floor((w+1)*x),e.length);let k=0,S=0;for(let F=y;F<N;F++){const E=e[F];E<k&&(k=E),E>S&&(S=E)}const M=v-S*v,P=v-k*v,I=Math.max(1,P-M);b.fillRect(w,M,1,I)}b.globalAlpha=1,b.strokeStyle=s,b.globalAlpha=.2,b.lineWidth=1,b.beginPath(),b.moveTo(0,v),b.lineTo(h,v),b.stroke(),b.globalAlpha=1},[e,n,s,a]);Y(()=>{c()},[c]),Y(()=>{const p=new ResizeObserver(()=>c()),m=l.current;return m&&p.observe(m),()=>p.disconnect()},[c]);const f=((e&&t?Math.round(e.length/t*1e3):0)/1e3).toFixed(1);return u("div",{ref:l,className:`relative ${o}`,children:[r("canvas",{ref:i,className:"w-full rounded-md"}),e&&e.length>0&&u("div",{className:"absolute bottom-1 right-2 text-[10px] text-foreground-subtle/60 font-mono",children:[f,"s · ",t/1e3,"kHz · ",e.length.toLocaleString()," samples"]})]})}function fE({currentDbfs:e,durationSec:t=30,maxSamples:n=120,height:o=64,className:s="",color:a="#10b981",clipColor:i="#ef4444",clipThreshold:l=-6,minDbfs:c=-96}){const d=ne(null),f=ne(null),[p,m]=$([]);Y(()=>{e!==null&&m(b=>{const x=[...b,{dbfs:e,timestamp:Date.now()}];return x.length>n?x.slice(-n):x})},[e,n]);const h=q(()=>{const b=d.current,x=f.current;if(!b||!x)return;const v=x.clientWidth;if(v===0)return;const w=window.devicePixelRatio||1;b.width=v*w,b.height=o*w,b.style.width=`${v}px`,b.style.height=`${o}px`;const y=b.getContext("2d");if(!y||(y.scale(w,w),y.clearRect(0,0,v,o),p.length===0))return;const N=p[p.length-1].timestamp,k=t*1e3,S=N-k,M=p.filter(E=>E.timestamp>=S);if(M.length===0)return;const P=Math.max(1,Math.floor(v/(t*2))),I=Math.abs(c);for(const E of M){const B=E.timestamp-S,O=Math.floor(B/k*v),D=(Math.max(c,Math.min(0,E.dbfs))-c)/I,_=Math.max(1,D*o),R=E.dbfs>=l;y.fillStyle=R?i:a,y.globalAlpha=.8,y.fillRect(O,o-_,P,_)}y.globalAlpha=1;const F=o-(l-c)/I*o;y.strokeStyle=i,y.globalAlpha=.25,y.lineWidth=1,y.setLineDash([4,4]),y.beginPath(),y.moveTo(0,F),y.lineTo(v,F),y.stroke(),y.setLineDash([]),y.globalAlpha=1},[p,t,o,a,i,l,c]);Y(()=>{h()},[h]),Y(()=>{const b=new ResizeObserver(()=>h()),x=f.current;return x&&b.observe(x),()=>b.disconnect()},[h]);const g=p.length>0?p[p.length-1].dbfs:null;return u("div",{ref:f,className:`relative ${s}`,children:[r("canvas",{ref:d,className:"w-full rounded-md"}),u("div",{className:"absolute top-1 left-2 text-[9px] text-foreground-subtle/50 font-mono",children:[t,"s"]}),g!==null&&u("div",{className:"absolute bottom-1 right-2 text-[9px] text-foreground-subtle/50 font-mono",children:[g.toFixed(1)," dBFS · ",p.length," samples"]})]})}function mE(e){return e>=.8?"bg-emerald-500":e>=.5?"bg-amber-500":e>=.3?"bg-orange-500":"bg-zinc-500"}function hE(e){return e>=.8?"text-emerald-400":e>=.5?"text-amber-400":e>=.3?"text-orange-400":"text-zinc-400"}function gE({classifications:e,processing:t=!1,inferenceMs:n,maxItems:o=10,className:s=""}){const a=e.slice(0,o),i=a.length>0?a[0].score:1;return t?r("div",{className:`rounded-xl border border-border bg-surface p-4 text-center ${s}`,children:r("div",{className:"text-sm text-foreground-subtle animate-pulse",children:"Classifying audio..."})}):a.length===0?r("div",{className:`rounded-xl border border-border bg-surface p-4 text-center ${s}`,children:r("div",{className:"text-xs text-foreground-subtle",children:"No classifications yet"})}):u("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${s}`,children:[u("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between",children:[r("h3",{className:"text-xs font-medium text-foreground",children:"Audio Classifications"}),u("div",{className:"flex items-center gap-3 text-[10px] text-foreground-subtle",children:[a.length<e.length&&u("span",{children:["showing ",a.length," of ",e.length]}),n!==void 0&&u("span",{className:"font-mono",children:[n.toFixed(1),"ms"]})]})]}),r("div",{className:"divide-y divide-border/50",children:a.map((l,c)=>{const d=i>0?l.score/i*100:0;return u("div",{className:"px-3 py-1.5 flex items-center gap-3 hover:bg-surface-hover/30",children:[r("span",{className:"text-[10px] text-foreground-subtle w-5 text-right font-mono",children:c+1}),r("span",{className:"text-xs font-medium text-foreground min-w-[120px]",children:l.className}),r("div",{className:"flex-1 h-2 rounded-full bg-zinc-800 overflow-hidden",children:r("div",{className:`h-full rounded-full transition-all duration-300 ${mE(l.score)}`,style:{width:`${d}%`}})}),u("span",{className:`text-xs font-mono font-semibold w-14 text-right ${hE(l.score)}`,children:[(l.score*100).toFixed(1),"%"]})]},`${l.className}-${c}`)})})]})}function bE({data:e,label:t="Response",className:n=""}){const[o,s]=$(!1);if(!e)return null;const a=JSON.stringify(e,null,2);return u("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${n}`,children:[u("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between cursor-pointer select-none hover:bg-surface-hover/30",onClick:()=>s(i=>!i),children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-[10px] text-foreground-subtle",children:o?"▼":"▶"}),r("h3",{className:"text-xs font-medium text-foreground",children:t})]}),r("span",{className:"text-[10px] text-foreground-subtle font-mono",children:a.length>1e3?`${(a.length/1024).toFixed(1)} KB`:`${a.length} bytes`})]}),o&&r("div",{className:"max-h-80 overflow-y-auto overflow-x-auto",children:r("pre",{className:"p-3 text-[10px] leading-4 font-mono text-foreground-subtle whitespace-pre",children:a})})]})}const xE={Activity:yn,Eye:Xs,AlertTriangle:No,PauseCircle:x2,PowerOff:hk};function Ac({phase:e,...t}){const n=Wn(e),o=xE[n.icon];return r(o,{...t})}function On(e){const[t,n]=$([]),o=q(a=>{n(i=>{const l=[...i,a];return l.length>e?l.slice(-e):l})},[e]),s=q(()=>{n([])},[]);return Q(()=>({entries:t,append:o,reset:s}),[t,o,s])}function gu(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}const bu={error:{icon:Zs,color:"text-red-400"},warn:{icon:No,color:"text-amber-400"},info:{icon:K2,color:"text-blue-400"},debug:{icon:t2,color:"text-gray-500"}},xu={debug:0,info:1,warn:2,error:3},yE=["all","debug","info","warn","error"],vE=500;function wE(e,t){return t?(xu[e]??0)>=(xu[t]??0):!0}function Wt({agentId:e,addonId:t,deviceId:n,integrationId:o,requestId:s,level:a,maxHeight:i="max-h-96",showScope:l=!1,showFilters:c=!0,limit:d=100,liveBuffer:f,onClose:p,className:m}){const[h,g]=$(""),[b,x]=$(""),[v,w]=$(a),y=e,N=t??(h||void 0),k=n??(b?Number(b):void 0),S=o,M=s,P=Q(()=>{const V={};return y&&(V.agentId=y),N&&(V.addonId=N),k!==void 0&&Number.isFinite(k)&&(V.deviceId=k),S&&(V.integrationId=S),M&&(V.requestId=M),Object.keys(V).length>0?V:void 0},[y,N,k,S,M]),I=On(vE),F=f??I,E=F.entries,[B,O]=$(0),[A,D]=$(!1),[_,R]=$(!1),[L,z]=$(new Set),[j,H]=$(""),T=ne(null),W=`${y??""}:${N??""}:${String(k??"")}:${S??""}:${M??""}`,G=ne(W);Y(()=>{G.current!==W&&(G.current=W,F.reset(),O(0),z(new Set))},[W,F]);const{data:ee,isLoading:se}=C.logs.query.useQuery({...P?{tags:P}:{},limit:d},{staleTime:3e4});C.logs.subscribe.useSubscription({...P?{tags:P}:{}},{onData:V=>{F.append(V)}});const te=ne(E.length);Y(()=>{const V=T.current;if(!V){te.current=E.length;return}const ie=te.current;if(te.current=E.length,!(E.length<=ie)){if(A&&V.scrollTop<=8)V.scrollTo({top:0});else if(!A&&V.scrollTop>0){const ue=V.querySelector("tbody tr"),de=ue instanceof HTMLElement?ue.offsetHeight:24;V.scrollTop+=de*(E.length-ie)}}},[E.length,A]);const X=Q(()=>{const V=(ee??[]).map(pe=>({timestamp:pe.timestamp,level:pe.level,message:pe.message,scope:pe.scope,tags:pe.tags,meta:pe.meta})),ie=new Set,ue=[];for(const pe of[...E].reverse()){const Ie=`${pe.timestamp}|${pe.level}|${pe.scope??""}|${pe.message}`;ie.has(Ie)||(ie.add(Ie),ue.push(pe))}for(const pe of V){const Ie=`${pe.timestamp}|${pe.level}|${pe.scope??""}|${pe.message}`;ie.has(Ie)||(ie.add(Ie),ue.push(pe))}const le=(B>0?ue.filter(pe=>new Date(pe.timestamp).getTime()>B):ue).filter(pe=>wE(pe.level,v)),Se=j.trim().toLowerCase();return Se?le.filter(pe=>{if(pe.message.toLowerCase().includes(Se)||pe.scope&&pe.scope.toLowerCase().includes(Se))return!0;if(pe.tags){for(const Ie of Object.values(pe.tags))if(Ie!==void 0&&String(Ie).toLowerCase().includes(Se))return!0}if(pe.meta){for(const Ie of Object.values(pe.meta))if(Ie!=null&&gu(Ie).toLowerCase().includes(Se))return!0}return!1}):le},[ee,E,v,B,j]),re=q(()=>{const V=X.map(ie=>{const ue=new Date(ie.timestamp).toLocaleTimeString(),de=ie.tags?" "+Object.entries(ie.tags).filter(([,le])=>le).map(([le,Se])=>`${le}=${Se}`).join(" "):"";return`${ue} [${ie.level.toUpperCase()}]${ie.scope?` [${ie.scope}]`:""}${de} ${ie.message}`});navigator.clipboard.writeText(V.join(`
|
|
532
|
+
`)).then(()=>{R(!0),setTimeout(()=>R(!1),1500)})},[X]),ge=C.logs.clear.useMutation(),Z=q(()=>{O(Date.now()),F.reset(),ge.mutate({...P?{tags:P}:{}})},[F,ge,P]),U=q(V=>{z(ie=>{const ue=new Set(ie);return ue.has(V)?ue.delete(V):ue.add(V),ue})},[]),[J,ae]=$(null),fe=q((V,ie)=>{const ue=new Date(V.timestamp).toISOString(),de=V.tags?" "+Object.entries(V.tags).filter(([,pe])=>pe).map(([pe,Ie])=>`${pe}=${Ie}`).join(" "):"",le=V.meta&&Object.keys(V.meta).length>0?` meta=${JSON.stringify(V.meta)}`:"",Se=`${ue} [${V.level.toUpperCase()}]${V.scope?` [${V.scope}]`:""}${de} ${V.message}${le}`;navigator.clipboard.writeText(Se).then(()=>{ae(ie),setTimeout(()=>ae(pe=>pe===ie?null:pe),1200)})},[]),he=q(V=>`${V.timestamp}|${V.level}|${V.scope??""}|${V.message}`,[]);return u("div",{className:K("h-full min-h-0 flex flex-col",m),onClick:V=>V.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Logs"}),y&&r(Wa,{label:"agent",value:y}),N&&r(Wa,{label:"addon",value:N}),k!==void 0&&r(Wa,{label:"device",value:`#${k}`}),r("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:yE.map(V=>u("button",{type:"button",onClick:()=>w(V==="all"?void 0:V),className:K("px-1.5 py-0.5 capitalize transition-colors",V==="all"&&!v||v===V?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover",V!=="all"&&"border-l border-border"),children:[V,V!=="all"?"+":""]},V))}),r(Ya,{icon:Ll,label:A?"Auto":"Paused",active:!A,onClick:()=>{D(V=>!V),!A&&T.current&&T.current.scrollTo({top:0,behavior:"smooth"})}}),r(Ya,{icon:Mn,label:_?"Copied!":"Copy",onClick:re,disabled:X.length===0}),r(Ya,{icon:rn,label:"Clear",onClick:Z}),u("div",{className:"relative",children:[r("input",{type:"text",value:j,onChange:V=>H(V.target.value),placeholder:"Search…",className:"w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"}),j&&r("button",{type:"button",onClick:()=>H(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:r(Je,{className:"h-2.5 w-2.5"})})]}),E.length>0&&u("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",E.length," live"]})]}),p&&r("button",{type:"button",onClick:p,className:"text-foreground-subtle hover:text-foreground",children:r(Je,{className:"h-3.5 w-3.5"})})]}),c&&(!t||!n)&&u("div",{className:"flex items-center gap-2 px-3 py-1 border-b border-border/50 bg-surface/50 text-[10px]",children:[!t&&u("label",{className:"flex items-center gap-1",children:[r("span",{className:"text-foreground-subtle",children:"Addon:"}),r("input",{type:"text",value:h,onChange:V=>g(V.target.value),placeholder:"all",className:"w-28 px-1.5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"})]}),!n&&u("label",{className:"flex items-center gap-1",children:[r("span",{className:"text-foreground-subtle",children:"Device:"}),r("input",{type:"text",inputMode:"numeric",value:b,onChange:V=>x(V.target.value),placeholder:"all",className:"w-16 px-1.5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"})]})]}),u("div",{ref:T,className:K("flex-1 min-h-0 overflow-auto font-mono text-[10px]",i),children:[se&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[r(Lt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading logs..."]}),!se&&X.length===0&&r("div",{className:"py-4 text-center text-foreground-subtle",children:"No logs found"}),X.length>0&&r("table",{className:"w-full",children:r("tbody",{children:X.map(V=>{const ie=bu[V.level]??bu.info,ue=ie.icon,de=he(V),le=L.has(de),Se=V.tags&&Object.keys(V.tags).length>0,pe=V.meta&&Object.keys(V.meta).length>0,Ie=Se||pe;return u("tr",{className:K("hover:bg-surface-hover/30 border-b border-border/30",Ie&&"cursor-pointer"),onClick:Ie?()=>U(de):void 0,children:[r("td",{className:"px-2 py-1 text-foreground-subtle whitespace-nowrap align-top w-[70px]",children:new Date(V.timestamp).toLocaleTimeString()}),r("td",{className:K("px-1 py-1 align-top w-5",ie.color),children:r(ue,{className:"h-3 w-3"})}),l&&r("td",{className:"px-2 py-1 text-foreground-subtle align-top truncate max-w-[120px]",title:V.scope,children:V.scope?.replace(/^addon:/,"")??""}),r("td",{className:"px-2 py-1 text-foreground break-all",children:u("div",{className:"flex items-start gap-1",children:[Ie&&(le?r(Yn,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"}):r(Cn,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"})),u("div",{className:"flex-1 min-w-0",children:[V.message,le&&Ie&&u("div",{className:"mt-1 text-[9px] text-foreground-subtle bg-surface rounded px-2 py-1 space-y-0.5",children:[pe&&Object.entries(V.meta).filter(([,Te])=>Te!==void 0&&Te!=="").map(([Te,Ye])=>u("div",{children:[r("span",{className:"text-amber-400/80 font-medium",children:Te}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground break-all",children:gu(Ye)})]},`m-${Te}`)),Se&&Object.entries(V.tags).filter(([,Te])=>Te!==void 0).map(([Te,Ye])=>u("div",{children:[r("span",{className:"text-primary/70 font-medium",children:Te}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground",children:Ye})]},`t-${Te}`))]})]})]})}),r("td",{className:"px-1 py-1 align-top w-5",children:r(NE,{copied:J===de,onCopy:()=>fe(V,de)})})]},de)})})})]})]})}function kx({position:e="bottom",className:t,...n}){return r("div",{className:K(e==="bottom"?"absolute bottom-0 left-0 right-0 z-10 border-t border-border bg-surface/95 backdrop-blur-sm":"absolute inset-x-2 bottom-2 z-10 rounded-lg border border-border bg-surface/95 backdrop-blur-sm shadow-xl",t),children:r(Wt,{maxHeight:"max-h-48",...n})})}function Wa({label:e,value:t}){return u("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function NE({copied:e,onCopy:t}){return r("button",{type:"button",title:"Copy this row",onClick:n=>{n.stopPropagation(),t()},className:K("rounded p-0.5 transition-colors",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?r(wo,{className:"h-3 w-3"}):r(Mn,{className:"h-3 w-3"})})}function Ya({icon:e,label:t,onClick:n,disabled:o,active:s}){return u("button",{type:"button",onClick:n,disabled:o,className:K("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",s?"border-amber-500/30 bg-amber-500/10 text-amber-400":"border-border text-foreground-subtle hover:text-foreground",o&&"opacity-40 cursor-not-allowed"),children:[r(e,{className:"h-2.5 w-2.5"}),t]})}function kE(e,t,n,o){if(o!==void 0&&(e.source.deviceId??(e.source.type==="device"&&typeof e.source.id=="number"?e.source.id:void 0))!==o||n!==void 0&&(e.source.addonId??(e.source.type==="addon"&&typeof e.source.id=="string"?e.source.id:void 0))!==n)return!1;if(t!==void 0){const s=e.source.nodeId;if(!s||s!==t&&!s.startsWith(`${t}/`))return!1}return!0}const SE={[Ne.AddonStarted]:{icon:Bi,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Started"},[Ne.AddonInstalled]:{icon:Oi,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Installed"},[Ne.AddonRestarted]:{icon:Ol,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Restarted"},[Ne.AddonUpdated]:{icon:Tm,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Updated"},[Ne.AddonStopped]:{icon:Vd,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Stopped"},[Ne.AddonUninstalled]:{icon:rn,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Uninstalled"},[Ne.AddonCrashed]:{icon:Zs,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Crashed"},[Ne.AddonError]:{icon:No,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Error"},[Ne.DetectionPhaseTransition]:{icon:yn,color:"bg-violet-500/15 text-violet-400 border-violet-500/30",label:"Phase"},[Ne.DetectionResult]:{icon:Ck,color:"bg-purple-500/15 text-purple-400 border-purple-500/30",label:"Detection"},[Ne.DetectionEvent]:{icon:Xs,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Event"},[Ne.DetectionCameraNative]:{icon:qd,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Camera AI"},[Ne.ProviderMotion]:{icon:Qd,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[Ne.MotionOnMotionChanged]:{icon:Qd,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[Ne.MotionAnalysis]:{icon:yn,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion analysis"},[Ne.MotionZonesRaw]:{icon:yn,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion zones"},[Ne.ProviderDetection]:{icon:qd,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Provider Det"},[Ne.PipelineAudioInferenceResult]:{icon:Pm,color:"bg-pink-500/15 text-pink-400 border-pink-500/30",label:"Audio"},[Ne.AgentOnline]:{icon:Bi,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Agent Online"},[Ne.AgentOffline]:{icon:Vd,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Agent Offline"},[Ne.DeviceRegistered]:{icon:Oi,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Registered"},[Ne.DeviceUnregistered]:{icon:rn,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Unregistered"},[Ne.DeviceStateChanged]:{icon:yn,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"State"}};function Ki(e,t){const n=SE[e]??{icon:Bi,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:e.split(".").pop()??e};if(e===Ne.DeviceStateChanged&&t&&typeof t.capName=="string"){const o=t.capName;return{...n,label:o}}return n}const sr=Object.freeze([...new Set(Object.values(Ne))].sort()),CE=Object.freeze([Ne.PipelineCameraMetricsSnapshot,Ne.PipelineRunnerLoadSnapshot,Ne.PipelineEngineMetricsSnapshot,Ne.PipelineInferenceResult,Ne.PipelineTrace,Ne.PipelineProgress,Ne.StreamBrokerMetricsSnapshot,Ne.MetricsNodeResourcesSnapshot,Ne.MetricsNodeProcessesSnapshot,Ne.ClusterTopologySnapshot,Ne.MotionAnalysis,Ne.MotionZonesRaw,Ne.DetectionResult,Ne.PipelineAudioInferenceResult,Ne.PlatformProbePhase,Ne.BenchmarkProgress,Ne.ModelDownloadProgress]),ME=new Set(CE),IE=Object.freeze(sr.filter(e=>!ME.has(e)));function fs(e,t){if(e===Ne.DetectionPhaseTransition){const s=t.to,a=t.from,i=typeof t.source=="string"?t.source:null,l=typeof t.cooldownMs=="number"?t.cooldownMs:null,c=i?` (${i}${l?`, ${Math.round(l/1e3)}s cooldown`:""})`:"";return s==="active"?`Motion detected — phase active${c}`:s==="watching"?`Cooldown expired — phase watching${c}`:`Phase: ${String(a)} → ${String(s)}${c}`}if(e===Ne.DetectionResult){const a=t.frame?.detections??[];if(a.length===0)return null;const i=new Map;for(const l of a){const c=l,d=c.class??c.macroClass,f=typeof d=="string"?d:"";f&&i.set(f,(i.get(f)??0)+1)}return[...i.entries()].map(([l,c])=>c>1?`${l} ×${c}`:l).join(", ")}if(e===Ne.PipelineAudioInferenceResult){const a=t.frame?.detections??[];return a.length===0?null:a.map(i=>{const l=i,c=l.macroClass??l.class??l.label,d=typeof c=="string"?c:"",f=l.score;return f?`${d} (${Math.round(f*100)}%)`:d}).filter(Boolean).join(", ")}if(e===Ne.DetectionEvent){const s=t.label??t.class,a=t.score??t.confidence,i=[];return typeof s=="string"&&i.push(s),typeof a=="number"&&i.push(`${Math.round(a*100)}%`),i.length>0?i.join(" — "):null}if(e===Ne.ProviderMotion)return t.active===!0?"motion start":"motion stop";if(e===Ne.DeviceStateChanged){const s=t.slice;if(s&&typeof s=="object"){const a=Object.keys(s).filter(i=>i!=="lastFetchedAt"&&i!=="ts");if(a.length>0)return a.slice(0,4).join(", ")+(a.length>4?"…":"")}return null}if(e===Ne.MotionOnMotionChanged){const s=t.detected,a=typeof t.source=="string"?t.source:null,i=s===!0?"motion start":s===!1?"motion stop":"motion";return a?`${i} (${a})`:i}if(e===Ne.ProviderDetection||e===Ne.DetectionCameraNative){const s=t.detections??[];if(!Array.isArray(s)||s.length===0)return(typeof t.class=="string"?t.class:null)??null;const a=new Map;for(const i of s){const l=i,c=l.class??l.macroClass,d=typeof c=="string"?c:"";d&&a.set(d,(a.get(d)??0)+1)}return[...a.entries()].map(([i,l])=>l>1?`${i} ×${l}`:i).join(", ")}const n=t.addonId,o=t.error;return o||(n?`addon: ${n}`:null)}function AE(e){const t=e.category;return t===Ne.DetectionResult||t===Ne.PipelineAudioInferenceResult?fs(t,e.data)!==null:!0}const PE=300;function nr({agentId:e,addonId:t,deviceId:n,defaultCategories:o,categories:s,category:a,maxHeight:i="max-h-96",limit:l=50,showCategoryFilter:c=!0,showFilters:d=!1,liveBuffer:f,onClose:p,className:m}){const h=Q(()=>o??s??IE,[o,s]),g=Q(()=>[...h].sort().join(","),[h]),[b,x]=$(()=>new Set(h)),v=ne(g);Y(()=>{v.current!==g&&(v.current=g,x(new Set(h)))},[g,h]);const w=On(PE),y=f??w,N=y.entries,[k,S]=$(!0),[M,P]=$(new Set),[I,F]=$(""),[E,B]=$(!1),[O,A]=$(""),[D,_]=$(0),R=ne(null),L=ne(null),z=`${e??""}:${t??""}:${String(n??"")}:${a??""}`,j=ne(z);Y(()=>{j.current!==z&&(j.current=z,y.reset(),P(new Set),_(0))},[z,y]),Y(()=>{if(!E)return;const me=Ee=>{const _e=L.current;_e&&Ee.target instanceof Node&&!_e.contains(Ee.target)&&B(!1)};return document.addEventListener("mousedown",me),()=>{document.removeEventListener("mousedown",me)}},[E]);const H=Q(()=>{const me={};return e&&(me.agentId=e),t&&(me.addonId=t),n!==void 0&&(me.deviceId=n),a&&(me.category=a),me},[e,t,n,a]),T=Q(()=>[...b].sort(),[b]),W=Q(()=>T.join(","),[T]),G=Q(()=>{const me={...H,limit:l};return T.length>0&&T.length<sr.length&&(me.category=T),me},[H,l,W,T]),{data:ee,isLoading:se}=C.systemEvents.getRecent.useQuery(G,{staleTime:3e4}),te=ne(b);Y(()=>{te.current=b},[b]);const X=H;C.systemEvents.subscribe.useSubscription(X,{onData:me=>{const Ee=me;Ee?.id&&kE(Ee,e,t,n)&&te.current.has(Ee.category)&&y.append(Ee)}});const re=ne(N.length);Y(()=>{const me=R.current;if(!me){re.current=N.length;return}const Ee=re.current;if(re.current=N.length,!(N.length<=Ee)){if(k&&me.scrollTop<=8)me.scrollTo({top:0});else if(!k&&me.scrollTop>0){const _e=me.firstElementChild?.firstElementChild,Re=_e instanceof HTMLElement?_e.offsetHeight:28;me.scrollTop+=Re*(N.length-Ee)}}},[N.length,k]);const ge=Q(()=>{const me=new Map;for(const Re of ee??[])me.set(Re.id,Re);for(const Re of N)me.set(Re.id,Re);let Ee=[...me.values()].filter(Re=>b.has(Re.category)).filter(AE);D>0&&(Ee=Ee.filter(Re=>new Date(Re.timestamp).getTime()>D));const _e=I.trim().toLowerCase();return _e&&(Ee=Ee.filter(Re=>{if(Re.category.toLowerCase().includes(_e)||Ki(Re.category,Re.data).label.toLowerCase().includes(_e))return!0;const Pn=fs(Re.category,Re.data);if(Pn&&Pn.toLowerCase().includes(_e))return!0;try{if(new Date(Re.timestamp).toLocaleTimeString().toLowerCase().includes(_e))return!0}catch{}try{if(JSON.stringify(Re.data).toLowerCase().includes(_e)||JSON.stringify(Re.source).toLowerCase().includes(_e))return!0}catch{}return!1})),Ee.sort((Re,An)=>new Date(An.timestamp).getTime()-new Date(Re.timestamp).getTime())},[ee,N,b,I,D]),Z=q(me=>{P(Ee=>{const _e=new Set(Ee);return _e.has(me)?_e.delete(me):_e.add(me),_e})},[]),U=q(me=>{x(Ee=>{const _e=new Set(Ee);return _e.has(me)?_e.delete(me):_e.add(me),_e})},[]),J=q(()=>{x(new Set(h)),F(""),_(0)},[h]),ae=q(()=>{_(Date.now()),y.reset()},[y]),[fe,he]=$(!1),[V,ie]=$(null),ue=q(me=>{const Ee=new Date(me.timestamp).toISOString(),_e=fs(me.category,me.data)??"",Re=_e?` ${_e}`:"";return`${Ee} [${me.category}]${Re} data=${JSON.stringify(me.data)}`},[]),de=q(()=>{const me=ge.map(ue);navigator.clipboard.writeText(me.join(`
|
|
533
|
+
`)).then(()=>{he(!0),setTimeout(()=>he(!1),1500)})},[ge,ue]),le=q(me=>{navigator.clipboard.writeText(ue(me)).then(()=>{ie(me.id),setTimeout(()=>ie(Ee=>Ee===me.id?null:Ee),1200)})},[ue]),Se=q(()=>{x(new Set(sr))},[]),pe=q(()=>{x(new Set)},[]),Ie=Q(()=>{const me=O.trim().toLowerCase();return me?sr.filter(Ee=>Ee.toLowerCase().includes(me)):sr},[O]),Te=sr.length,Ye=b.size,ot=Ye===Te,rr=ot?"All":`${Ye}/${Te}`;return u("div",{className:K("h-full min-h-0 flex flex-col",m),onClick:me=>me.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Events"}),e&&r(jo,{label:"agent",value:e}),t&&r(jo,{label:"addon",value:t}),n!==void 0&&r(jo,{label:"device",value:`#${n}`}),a&&r(jo,{label:"category",value:a}),u("button",{type:"button",onClick:()=>{S(me=>!me),!k&&R.current&&R.current.scrollTo({top:0,behavior:"smooth"})},className:K("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",k?"border-border text-foreground-subtle hover:text-foreground":"border-amber-500/30 bg-amber-500/10 text-amber-400"),children:[r(Ll,{className:"h-2.5 w-2.5"}),k?"Auto":"Paused"]}),c&&u("div",{className:"relative",ref:L,children:[u("button",{type:"button",onClick:()=>B(me=>!me),className:K("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",ot?"border-border text-foreground-subtle hover:text-foreground":"border-violet-500/30 bg-violet-500/10 text-violet-400"),title:"Pick events to track",children:[r(Mm,{className:"h-2.5 w-2.5"}),"Filter (",rr,")"]}),E&&r(EE,{search:O,onSearchChange:A,categories:Ie,active:b,onToggle:U,onSelectAll:Se,onSelectNone:pe,onResetDefaults:J})]}),u("button",{type:"button",onClick:J,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Reset filters to defaults",children:[r(_m,{className:"h-2.5 w-2.5"}),"Reset"]}),u("button",{type:"button",onClick:ae,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Clear visible entries",children:[r(rn,{className:"h-2.5 w-2.5"}),"Clear"]}),u("button",{type:"button",onClick:de,disabled:ge.length===0,className:K("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",fe?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",ge.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible events",children:[r(Mn,{className:"h-2.5 w-2.5"}),fe?"Copied!":"Copy"]}),u("div",{className:"relative",children:[r("input",{type:"text",value:I,onChange:me=>F(me.target.value),placeholder:"Search…",className:"w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"}),I&&r("button",{type:"button",onClick:()=>F(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:r(Je,{className:"h-2.5 w-2.5"})})]}),N.length>0&&u("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",N.length," live"]})]}),p&&r("button",{type:"button",onClick:p,className:"text-foreground-subtle hover:text-foreground",children:r(Je,{className:"h-3.5 w-3.5"})})]}),u("div",{ref:R,className:K("flex-1 min-h-0 overflow-auto text-[10px]",i),children:[se&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[r(Lt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading events..."]}),!se&&ge.length===0&&r("div",{className:"py-4 text-center text-foreground-subtle",children:"No events found"}),ge.length>0&&r("div",{className:"divide-y divide-border/30",children:ge.map(me=>{const Ee=Ki(me.category,me.data),_e=Ee.icon,Re=fs(me.category,me.data),An=M.has(me.id);return u("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>Z(me.id),children:[r("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(me.timestamp).toLocaleTimeString()}),r(_E,{copied:V===me.id,onCopy:()=>le(me)}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5",children:[An?r(Yn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):r(Cn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),u("span",{className:K("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[9px] font-medium",Ee.color),children:[r(_e,{className:"h-2.5 w-2.5"}),Ee.label]}),me.source.nodeId&&me.source.nodeId!=="hub"&&r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-foreground-subtle/10 text-foreground-subtle font-mono",children:me.source.nodeId})]}),Re&&r("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5",children:Re}),An&&u("div",{className:"mt-1 ml-5 text-[9px] bg-surface rounded px-2 py-1.5 space-y-0.5 font-mono overflow-x-auto",children:[u("div",{children:[r("span",{className:"text-primary/70",children:"source"}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground",children:JSON.stringify(me.source)})]}),u("div",{children:[r("span",{className:"text-primary/70",children:"category"}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground",children:me.category})]}),Object.entries(me.data).map(([Pn,Or])=>u("div",{children:[r("span",{className:"text-primary/70",children:Pn}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground break-all",children:typeof Or=="object"?JSON.stringify(Or):String(Or)})]},Pn))]})]})]},me.id)})})]})]})}function EE({search:e,onSearchChange:t,categories:n,active:o,onToggle:s,onSelectAll:a,onSelectNone:i,onResetDefaults:l}){return u("div",{className:"absolute z-20 top-full mt-1 left-0 w-72 max-h-80 rounded-md border border-border bg-surface shadow-lg flex flex-col",onClick:c=>c.stopPropagation(),children:[u("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[r(oo,{className:"h-3 w-3 text-foreground-subtle"}),r("input",{type:"text",value:e,onChange:c=>t(c.target.value),placeholder:"Filter categories…",className:"flex-1 bg-transparent text-[10px] focus:outline-none text-foreground placeholder:text-foreground-subtle",autoFocus:!0}),e&&r("button",{type:"button",onClick:()=>t(""),className:"text-foreground-subtle hover:text-foreground",children:r(Je,{className:"h-2.5 w-2.5"})})]}),u("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[r("button",{type:"button",onClick:a,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"All"}),r("button",{type:"button",onClick:i,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"None"}),r("button",{type:"button",onClick:l,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"Defaults"})]}),u("div",{className:"overflow-y-auto flex-1",children:[n.length===0&&r("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-3 text-center",children:"No matches"}),n.map(c=>{const d=o.has(c),f=Ki(c),p=f.icon;return u("button",{type:"button",onClick:()=>s(c),className:"w-full flex items-center gap-2 px-2 py-1 text-left hover:bg-surface-hover/40 text-[10px]",children:[r("input",{type:"checkbox",readOnly:!0,checked:d,className:"accent-violet-500"}),u("span",{className:K("inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[9px] font-medium shrink-0",f.color),children:[r(p,{className:"h-2.5 w-2.5"}),f.label]}),r("span",{className:"text-foreground-subtle font-mono truncate",children:c})]},c)})]})]})}function $E({position:e="bottom",className:t,...n}){return r("div",{className:K(e==="bottom"?"absolute bottom-0 left-0 right-0 z-10 border-t border-border bg-surface/95 backdrop-blur-sm":"absolute inset-x-2 bottom-2 z-10 rounded-lg border border-border bg-surface/95 backdrop-blur-sm shadow-xl",t),children:r(nr,{maxHeight:"max-h-48",...n})})}function jo({label:e,value:t}){return u("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function _E({copied:e,onCopy:t}){return r("button",{type:"button",title:"Copy this event",onClick:n=>{n.stopPropagation(),t()},className:K("rounded p-0.5 transition-colors mt-0.5",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?r(wo,{className:"h-3 w-3"}):r(Mn,{className:"h-3 w-3"})})}function Sx({deviceId:e,className:t="",onOpenChild:n}){const o=C.useUtils(),s=C.deviceDiscovery.listDiscovered.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),a=C.deviceDiscovery.getStatus.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),i=C.deviceDiscovery.refreshDiscovery.useMutation({onSuccess:()=>{o.deviceDiscovery.listDiscovered.invalidate({deviceId:e}),o.deviceDiscovery.getStatus.invalidate({deviceId:e})}}),l=C.deviceDiscovery.adoptDevice.useMutation({onSuccess:()=>{o.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),c=C.deviceDiscovery.releaseDevice.useMutation({onSuccess:()=>{o.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),[d,f]=$(null),{available:p,adopted:m}=Q(()=>{const y=s.data??[],N=S=>typeof S.metadata.rtspChannel=="number"?S.metadata.rtspChannel:Number.POSITIVE_INFINITY,k=(S,M)=>{const P=N(S),I=N(M);return P!==I?P-I:S.name.localeCompare(M.name)};return{available:y.filter(S=>!S.alreadyAdopted).sort(k),adopted:y.filter(S=>S.alreadyAdopted).sort(k)}},[s.data]),h=a.data,g=h?.lastError??null,b=h?.lastDiscoveryAt??null;async function x(){await i.mutateAsync({deviceId:e}).catch(()=>{})}async function v(y){f(y.childNativeId);try{await l.mutateAsync({deviceId:e,childNativeId:y.childNativeId})}finally{f(null)}}async function w(y){if(y.adoptedDeviceId!=null){f(y.childNativeId);try{await c.mutateAsync({deviceId:e,childDeviceId:y.adoptedDeviceId})}finally{f(null)}}}return u("div",{className:`rounded-xl border border-border bg-surface ${t}`,children:[u("div",{className:"flex items-start justify-between gap-2 border-b border-border px-3 py-2 sm:px-5 sm:py-3",children:[u("div",{className:"min-w-0",children:[r("h3",{className:"text-sm font-semibold text-foreground",children:"Discovered devices"}),u("p",{className:"text-[11px] text-foreground-subtle",children:["Channels behind this hub. Click ",r("span",{className:"font-medium",children:"Add"})," to promote a channel to a managed device, or ",r("span",{className:"font-medium",children:"Remove"})," to detach."]})]}),u("button",{type:"button",onClick:x,disabled:i.isPending,className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-2 py-1.5 sm:px-3 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 shrink-0",children:[i.isPending?r(Lt,{className:"h-3.5 w-3.5 animate-spin"}):r(Ol,{className:"h-3.5 w-3.5"}),r("span",{className:"hidden sm:inline",children:"Refresh"})]})]}),g?u("div",{className:"flex items-start gap-2 border-b border-border bg-destructive/10 px-5 py-2 text-[11px] text-destructive",children:[r(No,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),u("span",{children:["Last refresh failed: ",g]})]}):null,s.isLoading?r("div",{className:"flex items-center justify-center py-8 text-foreground-subtle",children:r(Lt,{className:"h-5 w-5 animate-spin"})}):p.length===0&&m.length===0?r("div",{className:"px-5 py-8 text-center text-xs text-foreground-subtle",children:"No channels reported by the hub yet. Click Refresh to enumerate."}):u(ve,{children:[p.length>0?r(yu,{title:"Available to add",count:p.length,tone:"primary",children:p.map(y=>r(vu,{child:y,busy:d===y.childNativeId,onAdopt:v,onRelease:w,onOpenChild:n},y.childNativeId))}):null,m.length>0?r(yu,{title:"Already adopted",count:m.length,tone:"muted",children:m.map(y=>r(vu,{child:y,busy:d===y.childNativeId,onAdopt:v,onRelease:w,onOpenChild:n},y.childNativeId))}):null]}),b!=null?u("div",{className:"border-t border-border px-5 py-2 text-[10px] text-foreground-subtle",children:["Last refreshed ",new Date(b).toLocaleString()]}):null]})}function yu({title:e,count:t,tone:n,children:o}){return u("div",{className:"border-t border-border",children:[u("div",{className:`flex items-center justify-between border-b px-3 sm:px-5 py-1.5 text-[10px] uppercase tracking-wider ${n==="primary"?"bg-primary/5 text-primary border-primary/30":"bg-surface text-foreground-subtle border-border"}`,children:[r("span",{className:"font-semibold",children:e}),r("span",{className:"font-mono",children:t})]}),r("div",{className:"divide-y divide-border",children:o})]})}function vu({child:e,busy:t,onAdopt:n,onRelease:o,onOpenChild:s}){return u("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2 sm:px-5 sm:py-3 sm:flex-nowrap sm:gap-3",children:[u("div",{className:"min-w-0 flex-1",children:[u("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[r(DE,{status:e.status}),r("span",{className:"truncate text-sm font-medium text-foreground",children:e.name}),e.metadata.isDoorbell?r("span",{className:"rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle",children:"Doorbell"}):null,e.metadata.isBattery?r("span",{className:"rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle",children:"Battery"}):null,e.metadata.isMultifocal?r("span",{className:"rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle",children:"Multifocal"}):null]}),u("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-foreground-subtle",children:[typeof e.metadata.rtspChannel=="number"?u("span",{children:["ch ",r("span",{className:"font-mono",children:e.metadata.rtspChannel})]}):null,e.metadata.model?r("span",{className:"truncate max-w-[160px]",children:e.metadata.model}):null,e.metadata.uid?u("span",{className:"font-mono truncate max-w-[140px]",children:[e.metadata.uid.slice(0,12),"…"]}):null]})]}),e.alreadyAdopted?u("div",{className:"flex items-center gap-2",children:[s&&e.adoptedDeviceId!==null?u("button",{type:"button",onClick:()=>s(e.adoptedDeviceId),className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",title:"Open device detail",children:[r(Sm,{className:"h-3.5 w-3.5"}),"Open"]}):null,u("button",{type:"button",onClick:()=>{o(e)},disabled:t,className:"inline-flex items-center gap-1.5 rounded-lg border border-destructive/30 px-3 py-1.5 text-xs text-destructive hover:bg-destructive/10 transition-colors disabled:opacity-50",children:[t?r(Lt,{className:"h-3.5 w-3.5 animate-spin"}):r(rn,{className:"h-3.5 w-3.5"}),"Remove"]})]}):u("button",{type:"button",onClick:()=>{n(e)},disabled:t,className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:[t?r(Lt,{className:"h-3.5 w-3.5 animate-spin"}):r(Js,{className:"h-3.5 w-3.5"}),"Add"]})]})}function DE({status:e}){switch(e){case"online":return u("span",{className:"inline-flex items-center gap-1 rounded-full border border-emerald-500/40 bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-500",children:[r(Rm,{className:"h-2.5 w-2.5"})," online"]});case"sleeping":return u("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-500",children:[r(Rl,{className:"h-2.5 w-2.5"})," sleeping"]});case"offline":return u("span",{className:"inline-flex items-center gap-1 rounded-full border border-destructive/40 bg-destructive/10 px-2 py-0.5 text-[10px] font-medium text-destructive",children:[r(n5,{className:"h-2.5 w-2.5"})," offline"]});case"unknown":default:return u("span",{className:"inline-flex items-center gap-1 rounded-full border border-border bg-surface px-2 py-0.5 text-[10px] font-medium text-foreground-subtle",children:[r(vm,{className:"h-2.5 w-2.5"})," unknown"]})}}function LE(e,t){if(!e||typeof e!="object")return!1;const n=e;if(n.category!==Ne.DeviceStateChanged)return!1;const o=n.data;return!(!o||typeof o!="object"||o.deviceId!==t||typeof o.capName!="string"||!o.slice||typeof o.slice!="object")}function Za(e){if(!e||typeof e!="object")return null;const t=e,n=typeof t.id=="string"?t.id:null,o=typeof t.timestamp=="string"?t.timestamp:null,s=t.data;return!n||!o||!s||typeof s!="object"||typeof s.capName!="string"||!s.slice||typeof s.slice!="object"?null:{id:n,timestamp:o,capName:s.capName,slice:s.slice}}const TE=300,RE=Object.freeze([...new Set(ow.filter(e=>e.scope==="device").map(e=>e.name))].sort());function Pc({deviceId:e,defaultCaps:t,maxHeight:n="max-h-96",limit:o=50,liveBuffer:s,onClose:a,className:i}){const l=Q(()=>new Set(t??[]),[t]),[c,d]=$(l),[f,p]=$(""),[m,h]=$(!0),[g,b]=$(new Set),[x,v]=$(0),[w,y]=$(!1),[N,k]=$(""),S=ne(null),M=On(TE),P=s??M,I=P.entries,F=ne(null),E=ne(e);Y(()=>{E.current!==e&&(E.current=e,P.reset(),b(new Set),v(0))},[e,P]);const B=Q(()=>({deviceId:e,category:Ne.DeviceStateChanged,limit:o}),[e,o]),{data:O,isLoading:A}=C.systemEvents.getRecent.useQuery(B,{staleTime:3e4}),D=ne(c);Y(()=>{D.current=c},[c]),C.systemEvents.subscribe.useSubscription({deviceId:e,category:Ne.DeviceStateChanged},{onData:V=>{if(!LE(V,e))return;const ie=Za(V);if(!ie)return;const ue=D.current;ue.size>0&&!ue.has(ie.capName)||P.append(ie)}});const _=ne(I.length);Y(()=>{const V=F.current;if(!V){_.current=I.length;return}const ie=_.current;if(_.current=I.length,!(I.length<=ie)){if(m&&V.scrollTop<=8)V.scrollTo({top:0});else if(!m&&V.scrollTop>0){const ue=V.firstElementChild?.firstElementChild,de=ue instanceof HTMLElement?ue.offsetHeight:28,le=I.length-ie;V.scrollTop+=de*le}}},[I.length,m]);const R=Q(()=>{const V=new Map;for(const de of O??[]){const le=Za(de);le&&V.set(le.id,le)}for(const de of I)V.set(de.id,de);let ie=[...V.values()];x>0&&(ie=ie.filter(de=>new Date(de.timestamp).getTime()>x)),c.size>0&&(ie=ie.filter(de=>c.has(de.capName)));const ue=f.trim().toLowerCase();return ue&&(ie=ie.filter(de=>{if(de.capName.toLowerCase().includes(ue))return!0;try{if(new Date(de.timestamp).toLocaleTimeString().toLowerCase().includes(ue))return!0}catch{}try{if(Object.entries(de.slice).map(([Se,pe])=>`${Se}=${Xa(pe)}`).join(" · ").toLowerCase().includes(ue))return!0}catch{}try{if(JSON.stringify(de.slice).toLowerCase().includes(ue))return!0}catch{}return!1})),ie.sort((de,le)=>new Date(le.timestamp).getTime()-new Date(de.timestamp).getTime())},[O,I,c,f,x]),L=Q(()=>{const V=new Set(RE);for(const ie of O??[]){const ue=Za(ie);ue&&V.add(ue.capName)}for(const ie of I)V.add(ie.capName);return[...V].sort()},[O,I]),z=q(V=>{b(ie=>{const ue=new Set(ie);return ue.has(V)?ue.delete(V):ue.add(V),ue})},[]),j=q(V=>{d(ie=>{const ue=new Set(ie);return ue.has(V)?ue.delete(V):ue.add(V),ue})},[]),H=q(()=>{d(new Set(t??[])),p("")},[t]),T=q(()=>{v(Date.now()),P.reset()},[P]),[W,G]=$(!1),[ee,se]=$(null),te=q(V=>`${new Date(V.timestamp).toISOString()} [${V.capName}] slice=${JSON.stringify(V.slice)}`,[]),X=q(()=>{const V=R.map(te);navigator.clipboard.writeText(V.join(`
|
|
534
|
+
`)).then(()=>{G(!0),setTimeout(()=>G(!1),1500)})},[R,te]),re=q(V=>{navigator.clipboard.writeText(te(V)).then(()=>{se(V.id),setTimeout(()=>se(ie=>ie===V.id?null:ie),1200)})},[te]),ge=q(()=>{d(new Set(L))},[L]),Z=q(()=>{d(new Set)},[]),U=Q(()=>{const V=N.trim().toLowerCase();return V?L.filter(ie=>ie.toLowerCase().includes(V)):L},[N,L]),J=L.length,ae=c.size,fe=ae===0||ae===J,he=fe?"All":`${ae}/${J}`;return Y(()=>{if(!w)return;const V=ie=>{const ue=S.current;ue&&!ue.contains(ie.target)&&y(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[w]),u("div",{className:K("h-full min-h-0 flex flex-col",i),onClick:V=>V.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"State"}),r(OE,{label:"device",value:`#${e}`}),u("button",{type:"button",onClick:()=>{h(V=>!V),!m&&F.current&&F.current.scrollTo({top:0,behavior:"smooth"})},className:K("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",m?"border-border text-foreground-subtle hover:text-foreground":"border-amber-500/30 bg-amber-500/10 text-amber-400"),children:[r(Ll,{className:"h-2.5 w-2.5"}),m?"Auto":"Paused"]}),u("div",{className:"relative",ref:S,children:[u("button",{type:"button",onClick:()=>y(V=>!V),className:K("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",fe?"border-border text-foreground-subtle hover:text-foreground":"border-violet-500/30 bg-violet-500/10 text-violet-400"),title:"Pick caps to track",children:[r(Mm,{className:"h-2.5 w-2.5"}),"Filter (",he,")"]}),w&&r(zE,{search:N,onSearchChange:k,caps:U,active:c,onToggle:j,onSelectAll:ge,onSelectNone:Z,onResetDefaults:H})]}),u("button",{type:"button",onClick:H,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Reset filters",children:[r(_m,{className:"h-2.5 w-2.5"}),"Reset"]}),u("button",{type:"button",onClick:T,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Clear visible entries",children:[r(rn,{className:"h-2.5 w-2.5"}),"Clear"]}),u("button",{type:"button",onClick:X,disabled:R.length===0,className:K("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",W?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",R.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible state changes",children:[r(Mn,{className:"h-2.5 w-2.5"}),W?"Copied!":"Copy"]}),u("div",{className:"relative",children:[r("input",{type:"text",value:f,onChange:V=>p(V.target.value),placeholder:"Search…",className:"w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"}),f&&r("button",{type:"button",onClick:()=>p(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:r(Je,{className:"h-2.5 w-2.5"})})]}),I.length>0&&u("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",I.length," live"]})]}),a&&r("button",{type:"button",onClick:a,className:"text-foreground-subtle hover:text-foreground",children:r(Je,{className:"h-3.5 w-3.5"})})]}),u("div",{ref:F,className:K("flex-1 min-h-0 overflow-auto text-[10px]",n),children:[A&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[r(Lt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading state changes..."]}),!A&&R.length===0&&r("div",{className:"py-4 text-center text-foreground-subtle",children:"No state changes"}),R.length>0&&r("div",{className:"divide-y divide-border/30",children:R.map(V=>{const ie=g.has(V.id),ue=Object.entries(V.slice),de=ue.slice(0,3).map(([le,Se])=>`${le}=${Xa(Se)}`).join(" · ");return u("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>z(V.id),children:[r("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(V.timestamp).toLocaleTimeString()}),r(BE,{copied:ee===V.id,onCopy:()=>re(V)}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5",children:[ie?r(Yn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):r(Cn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),r("span",{className:"inline-flex items-center gap-1 rounded-full border border-violet-500/30 bg-violet-500/15 text-violet-400 px-2 py-0.5 text-[9px] font-medium",children:V.capName}),ue.length>3&&u("span",{className:"text-[9px] text-foreground-subtle",children:["+",ue.length-3," more"]})]}),de&&r("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5 truncate",children:de}),ie&&r("div",{className:"mt-1 ml-5 text-[9px] bg-surface rounded px-2 py-1.5 space-y-0.5 font-mono overflow-x-auto",children:ue.length===0?r("div",{className:"text-foreground-subtle italic",children:"empty slice"}):ue.map(([le,Se])=>u("div",{children:[r("span",{className:"text-primary/70",children:le}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground break-all",children:Xa(Se)})]},le))})]})]},V.id)})})]})]})}function Xa(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function OE({label:e,value:t}){return u("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function zE({search:e,onSearchChange:t,caps:n,active:o,onToggle:s,onSelectAll:a,onSelectNone:i,onResetDefaults:l}){return u("div",{className:"absolute z-20 top-full mt-1 left-0 w-72 max-h-80 rounded-md border border-border bg-surface shadow-lg flex flex-col",onClick:c=>c.stopPropagation(),children:[u("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[r(oo,{className:"h-3 w-3 text-foreground-subtle"}),r("input",{type:"text",value:e,onChange:c=>t(c.target.value),placeholder:"Filter caps…",className:"flex-1 bg-transparent text-[10px] focus:outline-none text-foreground placeholder:text-foreground-subtle",autoFocus:!0}),e&&r("button",{type:"button",onClick:()=>t(""),className:"text-foreground-subtle hover:text-foreground",children:r(Je,{className:"h-2.5 w-2.5"})})]}),u("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[r("button",{type:"button",onClick:a,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"All"}),r("button",{type:"button",onClick:i,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"None"}),r("button",{type:"button",onClick:l,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"Defaults"})]}),u("div",{className:"overflow-y-auto flex-1",children:[n.length===0&&r("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-3 text-center",children:"No matches"}),n.map(c=>{const d=o.has(c);return u("button",{type:"button",onClick:()=>s(c),className:"w-full flex items-center gap-2 px-2 py-1 text-left hover:bg-surface-hover/40 text-[10px]",children:[r("input",{type:"checkbox",readOnly:!0,checked:d,className:"accent-violet-500"}),r("span",{className:"inline-flex items-center gap-1 rounded-full border border-violet-500/30 bg-violet-500/15 text-violet-400 px-1.5 py-0.5 text-[9px] font-medium shrink-0",children:c})]},c)})]})]})}function BE({copied:e,onCopy:t}){return r("button",{type:"button",title:"Copy this state change",onClick:n=>{n.stopPropagation(),t()},className:K("rounded p-0.5 transition-colors mt-0.5",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?r(wo,{className:"h-3 w-3"}):r(Mn,{className:"h-3 w-3"})})}const Ja=500,FE=[{id:"logs",label:"Logs",icon:Ik},{id:"events",label:"Events",icon:Ys},{id:"state",label:"State",icon:$2}];function jE({deviceId:e,defaultEventCategories:t,defaultStateCaps:n,initialTab:o="events",className:s,maxHeight:a="max-h-96"}){const[i,l]=$(o),c=On(Ja),d=On(Ja),f=On(Ja),p=c.reset,m=d.reset,h=f.reset;return Y(()=>{p(),m(),h()},[e,p,m,h]),u("div",{className:K("flex flex-col h-full min-h-0",s),children:[r("div",{className:"flex items-center gap-1 mb-2 shrink-0",children:FE.map(({id:g,label:b,icon:x})=>u("button",{type:"button",onClick:()=>l(g),className:K("inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[11px] font-medium transition-colors",i===g?"bg-primary/15 text-primary border border-primary/30":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover border border-transparent"),children:[r(x,{className:"h-3.5 w-3.5"}),b]},g))}),u("div",{className:"flex-1 min-h-0 overflow-hidden",children:[i==="logs"&&r(Wt,{deviceId:e,maxHeight:a,showFilters:!1,liveBuffer:c}),i==="events"&&r(nr,{deviceId:e,defaultCategories:t,maxHeight:a,showCategoryFilter:!0,liveBuffer:d}),i==="state"&&r(Pc,{deviceId:e,defaultCaps:n,maxHeight:a,liveBuffer:f})]})]})}function Cx({label:e,icon:t,title:n="Confirm action",description:o,confirmLabel:s,triggerVariant:a="outline",confirmVariant:i="danger",size:l="sm",disabled:c,className:d,action:f,onSuccess:p}){const[m,h]=$(!1),[g,b]=$(!1),[x,v]=$(null),w=async()=>{v(null),b(!0);try{const y=await f();p?.(y),h(!1)}catch(y){v(y instanceof Error?y.message:String(y))}finally{b(!1)}};return u(ve,{children:[u(He,{type:"button",variant:a,size:l,disabled:c,onClick:()=>{v(null),h(!0)},className:d,children:[t&&r(t,{className:"h-3.5 w-3.5"}),e]}),r(Hm,{open:m,onOpenChange:y=>!g&&h(y),children:u(Vl,{children:[u(Vm,{children:[u(Qm,{className:"flex items-center gap-2",children:[r(No,{className:"h-4 w-4 text-amber-400"}),n]}),typeof o=="string"?r(Um,{children:o}):o]}),x&&r("div",{className:K("mt-2 px-3 py-2 rounded border border-danger/40 bg-danger/10","text-xs text-danger"),children:x}),u(qm,{children:[r(He,{type:"button",variant:"ghost",size:l,disabled:g,onClick:()=>h(!1),children:"Cancel"}),u(He,{type:"button",variant:i,size:l,disabled:g,onClick:()=>{w()},children:[g&&r(Lt,{className:"h-3.5 w-3.5 animate-spin"}),s??e]})]})]})})]})}function Ho({direction:e,icon:t,disabled:n,className:o,variant:s,onMove:a,onStart:i,onStop:l}){const[c,d]=$(null),[f,p]=$(!1),m=q(w=>{if(n)return;w.currentTarget.setPointerCapture(w.pointerId),d(Date.now()),p(!1);const y=setTimeout(()=>{p(!0),i(e)},250);w.currentTarget.dataset.timer=String(y)},[e,n,i]),h=q(w=>{const y=Number(w.currentTarget.dataset.timer);y&&clearTimeout(y),w.currentTarget.dataset.timer="",f?l():c!==null&&a(e),d(null),p(!1)},[f,e,a,l,c]),g=q(w=>{const y=Number(w.currentTarget.dataset.timer);y&&clearTimeout(y),w.currentTarget.dataset.timer="",f&&l(),d(null),p(!1)},[f,l]),b=s==="panel"?"h-9 w-9":"h-7 w-7",x=s==="panel"?"h-4 w-4":"h-3.5 w-3.5";return r("button",{type:"button",disabled:n,onPointerDown:m,onPointerUp:h,onPointerCancel:g,className:K("flex items-center justify-center rounded transition-colors disabled:opacity-40",s==="panel"?"text-foreground hover:bg-surface-hover active:bg-surface-hover/80":"text-white hover:bg-white/15 active:bg-white/25",b,o),title:e,children:r(t,{className:x})})}function Ec({controls:e,mode:t="overlay",showPresets:n,showZoom:o=!0,showHome:s=!0,className:a}){const{move:i,startContinuous:l,stopContinuous:c,zoom:d,goHome:f,goToPreset:p,presets:m,busy:h,error:g}=e,[b,x]=$(!1),v=(n??m.length>0)&&m.length>0,w=t==="panel",y=w?"flex flex-col items-stretch gap-2 w-full h-full p-3":"pointer-events-auto absolute top-3 right-3 z-10 flex flex-col items-end gap-2",N=K(w?"flex items-center gap-3 rounded-lg p-2":"flex items-center gap-2 rounded-lg border border-white/30 bg-zinc-900/90 backdrop-blur-md p-2 shadow-lg shadow-black/40",h&&"ring-1 ring-primary/40"),k=w?"h-9 w-9":"h-7 w-7",S=w?"h-4 w-4":"h-3.5 w-3.5",M=w?"text-foreground hover:bg-surface-hover":"text-white hover:bg-white/15",P=w?"h-12 w-px bg-border mx-1":"h-12 w-px bg-white/15 mx-1";return u("div",{className:K(y,a),children:[g&&u("div",{className:"rounded bg-danger/90 px-2 py-1 text-[10px] font-medium text-white shadow-lg max-w-[200px] self-center",children:["PTZ: ",g]}),u("div",{className:K(N,w&&"justify-center"),children:[u("div",{className:"grid grid-cols-3 gap-0.5",children:[r("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),r(Ho,{direction:"up",icon:VN,variant:t,onMove:i,onStart:l,onStop:c}),r("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),r(Ho,{direction:"left",icon:zN,variant:t,onMove:i,onStart:l,onStop:c}),r("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),r(Ho,{direction:"right",icon:FN,variant:t,onMove:i,onStart:l,onStop:c}),r("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),r(Ho,{direction:"down",icon:RN,variant:t,onMove:i,onStart:l,onStop:c}),r("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"})]}),(o||s)&&r("div",{className:P}),u("div",{className:"flex flex-col gap-0.5",children:[o&&u(ve,{children:[r("button",{type:"button",onClick:()=>d("in"),disabled:h,title:"Zoom in",className:K("flex items-center justify-center rounded disabled:opacity-40",k,M),children:r(l5,{className:S})}),r("button",{type:"button",onClick:()=>d("out"),disabled:h,title:"Zoom out",className:K("flex items-center justify-center rounded disabled:opacity-40",k,M),children:r(d5,{className:S})})]}),s&&r("button",{type:"button",onClick:()=>f(),disabled:h,title:"Go home",className:K("flex items-center justify-center rounded disabled:opacity-40",k,M),children:r(Im,{className:S})})]}),v&&u("div",{className:"relative",children:[u("button",{type:"button",onClick:()=>x(I=>!I),disabled:h,className:K("flex items-center gap-1 rounded px-2 text-[10px] disabled:opacity-40",w?"h-9 text-foreground hover:bg-surface-hover":"h-7 text-white hover:bg-white/15"),title:"Presets",children:["Presets",r(Yn,{className:K("h-3 w-3 transition-transform",b&&"rotate-180")})]}),b&&r("div",{className:K("absolute right-0 min-w-[140px] rounded-lg shadow-xl py-1 z-20",w?"bottom-full mb-1 bg-surface border border-border":"top-full mt-1 border border-white/30 bg-zinc-900/95 backdrop-blur-md"),children:m.map(I=>r("button",{type:"button",onClick:()=>{p(I.id),x(!1)},disabled:h,className:K("block w-full px-3 py-1.5 text-left text-[10px] disabled:opacity-40",w?"text-foreground hover:bg-surface-hover":"text-white hover:bg-white/15"),children:I.name||I.id},I.id))})]})]})]})}function HE(e,t){const n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function VE({trpc:e,deviceId:t,deviceName:n,size:o="sm",className:s}){const[a,i]=$(!1),[l,c]=$(!1),[d,f]=$(null),p=n.replace(/[^a-zA-Z0-9_.-]+/g,"_"),m=q(async k=>{i(!0),f(null),c(!1);try{const S=await e.snapshot.getSnapshot.query({deviceId:t,force:!0});if(!S)throw new Error("No snapshot available");const M=`data:${S.contentType};base64,${S.base64}`;if(k==="copy")try{await navigator.clipboard.writeText(M)}catch{throw new Error("Clipboard unavailable")}else{const P=S.contentType.includes("png")?"png":"jpg",I=new Date().toISOString().replace(/[:.]/g,"-");HE(`${p}-${I}.${P}`,M)}c(!0),setTimeout(()=>c(!1),1500)}catch(S){f(S instanceof Error?S.message:String(S))}finally{i(!1)}},[e,t,p]),h=o==="md"?"h-9 px-3 text-sm gap-2":"h-7 px-2.5 text-[11px] gap-1.5",[g,b]=$(null),[x,v]=$(!1),w=()=>{v(!1);const k=setTimeout(()=>{v(!0),m("copy")},600);b(k)},y=()=>{g&&(clearTimeout(g),b(null)),x||m("download")},N=()=>{g&&(clearTimeout(g),b(null))};return u("button",{type:"button",title:"Click to download · long-press to copy",disabled:a,onPointerDown:w,onPointerUp:y,onPointerLeave:N,onPointerCancel:N,className:K("inline-flex items-center justify-center rounded-lg font-medium border border-border","text-foreground-subtle hover:text-foreground hover:bg-surface-hover","disabled:opacity-50 transition-colors",h,d&&"border-danger/40 text-danger",s),children:[a?r(Lt,{className:"h-3.5 w-3.5 animate-spin"}):l?r(wo,{className:"h-3.5 w-3.5 text-success"}):r(Tl,{className:"h-3.5 w-3.5"}),"Snapshot"]})}function qE(e){const t=Date.now()-e;return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function $c({history:e,limit:t=5,latestIsFresh:n,className:o}){if(e.length===0)return null;const s=n?XN:Ys,a=e.slice(0,t);return u("div",{className:K("rounded-lg border border-border bg-surface px-3 py-2",o),children:[u("div",{className:"flex items-center gap-2 mb-2",children:[r(s,{className:K("h-4 w-4 text-amber-400",n&&"animate-pulse")}),r("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle",children:"Recent presses"}),r("span",{className:"ml-auto rounded-full bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle border border-border",children:e.length})]}),r("ul",{className:"space-y-1",children:a.map(i=>u("li",{className:"flex items-center justify-between text-[11px]",title:new Date(i.timestamp).toLocaleString(),children:[r("span",{className:"text-foreground",children:qE(i.timestamp)}),r("span",{className:"text-foreground-subtle font-mono text-[10px]",children:new Date(i.timestamp).toLocaleTimeString()})]},`${i.deviceId}-${i.timestamp}`))})]})}function Mx({items:e,header:t,triggerClassName:n,title:o="More actions"}){const[s,a]=$(!1),i=e.filter(l=>!l.hidden);return i.length===0?null:u(ah,{open:s,onOpenChange:a,children:[r(ih,{title:o,className:K("inline-flex items-center justify-center rounded-lg p-2","text-foreground-subtle hover:text-foreground hover:bg-surface-hover","border border-transparent transition-colors",n),children:r(km,{className:"h-4 w-4"})}),u(lh,{className:"left-auto right-0 mt-1 min-w-[200px] p-1",children:[t&&r("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wider text-foreground-subtle",children:t}),r("ul",{className:"space-y-0.5",children:i.map((l,c)=>u("li",{children:[l.separatorBefore&&c>0&&r("div",{className:"my-1 h-px bg-border"}),u("button",{type:"button",disabled:l.disabled,onClick:()=>{l.disabled||(l.onClick(),a(!1))},className:K("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left text-[12px]","transition-colors disabled:opacity-40 disabled:cursor-not-allowed",l.danger?"text-foreground hover:bg-danger/10 hover:text-danger":"text-foreground hover:bg-surface-hover"),children:[l.icon&&r(l.icon,{className:K("h-3.5 w-3.5 shrink-0 mt-0.5",l.danger&&"text-danger/80")}),u("span",{className:"flex-1 min-w-0",children:[r("span",{className:"block leading-tight",children:l.label}),l.description&&r("span",{className:"block mt-0.5 text-[10px] text-foreground-subtle leading-tight",children:l.description})]})]})]},l.id))})]})]})}const Ix=un("camstack:zone-editing",null);function Ax({children:e}){const[t,n]=$(!1),[o,s]=$(null),[a,i]=$(null),[l,c]=$(null),d=q(w=>{n(w),w||(s(null),i(null),c(null))},[]),f=q(w=>{s(w)},[]),p=q(w=>{i(w)},[]),m=q(w=>{n(!0),i(null),s(w),c(null)},[]),h=q(()=>{n(!1),s(null),i(null),c(null)},[]),g=q(w=>{i(w.id),c(w)},[]),b=q(w=>{c(y=>y===null?y:{...y,...w})},[]),x=q(()=>{c(null)},[]),v=Q(()=>({editing:t,drawingKind:o,selectedZoneId:a,editingDraft:l,setEditing:d,setDrawingKind:f,setSelectedZoneId:p,startDrawing:m,exitEditing:h,enterDraft:g,updateDraft:b,discardDraft:x}),[t,o,a,l,d,f,p,m,h,g,b,x]);return r(Ix.Provider,{value:v,children:e})}function QE(){return ye(Ix)}const wu=500,UE=800;function Vo(e,t,n){try{const o=e.live;if(!o)return null;const s=o.onEvent;return!s||typeof s.subscribe!="function"?null:s.subscribe({category:t},{onData:n})}catch{return null}}function qo(e,t){return e?.id===t}function Px(e,t){const[n,o]=$(null),[s,a]=$(null),[i,l]=$(null),[c,d]=$("watching"),f=ne(void 0),p=ne(void 0),m=ne(void 0);return Y(()=>{if(t===null)return;const h=Vo(e,"detection.motion-analysis",g=>{const b=g;if(!qo(b?.source,t))return;const x=b.data;!x?.regions||x.regions.length===0||(o({zones:x.regions.map(v=>({...v.bbox,intensity:v.intensity})),frameWidth:x.frameWidth,frameHeight:x.frameHeight}),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>o(null),wu))});return()=>{h?.unsubscribe(),f.current&&clearTimeout(f.current)}},[e,t]),Y(()=>{if(t===null)return;const h=Vo(e,"detection.motion-zones-raw",g=>{const b=g;if(!qo(b?.source,t))return;const x=b.data;x?.zones&&(a({boxes:x.zones.map(v=>({bbox:v.bbox,changeScore:v.changeScore})),frameWidth:x.frameSize?.width??0,frameHeight:x.frameSize?.height??0,motionScore:x.zones.length>0?x.zones.reduce((v,w)=>v+w.changeScore,0)/x.zones.length:0}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>a(null),wu))});return()=>{h?.unsubscribe(),p.current&&clearTimeout(p.current)}},[e,t]),Y(()=>{if(t===null)return;const h=Vo(e,"detection.result",g=>{const b=g;if(!qo(b?.source,t))return;const x=b.data?.frame;x?.detections?.length&&(l({detections:x.detections,frameWidth:x.width,frameHeight:x.height}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>l(null),UE))});return()=>{h?.unsubscribe(),m.current&&clearTimeout(m.current)}},[e,t]),Y(()=>{if(t===null)return;const h=Vo(e,"detection.phase-transition",g=>{const b=g;qo(b?.source,t)&&b.data?.to&&d(b.data.to)});return()=>{h?.unsubscribe()}},[e,t]),{motion:n,motionRaw:s,detection:i,phase:c}}function _c(e,t,n=5e3){const[o,s]=$([]);Y(()=>{if(t===null)return;let m=!1;const h=()=>{e.webrtcSession.listStreams.query({deviceId:t}).then(b=>{m||s(b)}).catch(()=>{})};h();const g=setInterval(h,n);return()=>{m=!0,clearInterval(g)}},[e,t,n]);const[a,i]=$(null);Y(()=>{if(t===null)return;let m=!1;return e.pipelineOrchestrator&&e.pipelineOrchestrator.getCameraMetrics.query({deviceId:t}).then(h=>{m||!h||i({phase:h.phase,detectionFps:h.actualFps,avgInferenceMs:h.avgInferenceTimeMs,droppedFrames:h.droppedFrames})}).catch(()=>{}),()=>{m=!0}},[e,t]),dt("pipeline.camera-metrics-snapshot",m=>{if(t===null)return;const h=m.data;h.deviceId!==t||!h.metrics||i({phase:h.metrics.phase,detectionFps:h.metrics.actualFps,avgInferenceMs:h.metrics.avgInferenceTimeMs,droppedFrames:h.metrics.droppedFrames})});const{streams:l,hasWebrtc:c}=Q(()=>t===null||o.length===0?{streams:[],hasWebrtc:!1}:{streams:o.map(h=>({id:h.id,label:h.label,target:h.target,status:h.status,inputFps:h.inputFps,decodeFps:h.decodeFps,bitrateKbps:h.bitrateKbps})),hasWebrtc:!0},[t,o]),d=q(async(m,h)=>{if(t===null)throw new Error("No device selected");const g=await e.webrtcSession.createSession.mutate({deviceId:t,target:m,hints:h});return{sessionId:g.sessionId,sdpOffer:g.sdpOffer}},[e,t]),f=q(async(m,h)=>{if(t===null)throw new Error("No device selected");await e.webrtcSession.handleAnswer.mutate({deviceId:t,sessionId:m,sdpAnswer:h})},[e,t]),p=q(async m=>{t!==null&&await e.webrtcSession.closeSession.mutate({deviceId:t,sessionId:m}).catch(()=>{})},[e,t]);return{streams:l,hasWebrtc:c,pipelineMetrics:a,createSession:d,sendAnswer:f,closeSession:p}}const Nu={up:{pan:0,tilt:1},down:{pan:0,tilt:-1},left:{pan:-1,tilt:0},right:{pan:1,tilt:0},"up-left":{pan:-1,tilt:1},"up-right":{pan:1,tilt:1},"down-left":{pan:-1,tilt:-1},"down-right":{pan:1,tilt:-1}};function Dc(e,t,n){const o=n?.defaultSpeed??.5,s=n?.pulseMs??250,a=n?.enabled??!0,l=kt(e,a?t:null)?.ptz,[c,d]=$([]),[f,p]=$(!1),[m,h]=$(null),g=q(async()=>{if(!(!a||!l))try{const S=await l.getPresets({});d(S)}catch(S){const M=S instanceof Error?S.message:String(S);if(M.includes("provider not available")||M.includes("no 'ptz' binding"))return;h(M)}},[l,a]);Y(()=>{g()},[g]);const b=q(async S=>{if(!(!a||!l)){h(null),p(!0);try{return await S()}catch(M){h(M instanceof Error?M.message:String(M));return}finally{p(!1)}}},[a,l]),x=q(async(S,M)=>{if(!l)return;const P=Nu[S],I=M??o;await b(async()=>{await l.move({pan:P.pan,tilt:P.tilt,speed:I}),await new Promise(F=>setTimeout(F,s)),await l.stop({})})},[l,o,s,b]),v=q(async(S,M)=>{if(!l)return;const P=Nu[S],I=M??o;await b(()=>l.continuousMove({pan:P.pan,tilt:P.tilt,speed:I}))},[l,o,b]),w=q(async()=>{l&&await b(()=>l.stop({}))},[l,b]),y=q(async(S,M)=>{if(!l)return;const P=S==="in"?1:-1,I=M??o;await b(async()=>{await l.move({zoom:P,speed:I}),await new Promise(F=>setTimeout(F,s)),await l.stop({})})},[l,o,s,b]),N=q(async()=>{l&&await b(()=>l.goHome({}))},[l,b]),k=q(async S=>{l&&await b(()=>l.goToPreset({presetId:S}))},[l,b]);return{move:x,startContinuous:v,stopContinuous:w,zoom:y,goHome:N,goToPreset:k,presets:c,refreshPresets:g,busy:f,error:m}}function Lc(e){const t=e?.deviceId??null,n=e?.historyLimit??20,o=Ar("doorbell.onPressed",t!==null?i=>i.deviceId===t:void 0),[s,a]=$([]);return Y(()=>{o&&a(i=>{if(i.length>0&&i[0].deviceId===o.deviceId&&i[0].timestamp===o.timestamp)return i;const l=[o,...i];return l.length>n?l.slice(0,n):l})},[o,n]),{latest:o??null,history:s}}function KE(e){const t=Le(),n=Q(()=>e?JSON.stringify(e):"",[e]),[o,s]=$(()=>t.listDevices(e));return Y(()=>{const a=()=>{s(t.listDevices(e))};a();let i=null,l=null;try{i=t.onDeviceAdded(a),l=t.onDeviceRemoved(a)}catch{}const c=t.subscribeConnectionEvents(d=>{d==="connected"&&a()});return()=>{i?.(),l?.(),c()}},[t,e,n]),o}function GE(e){const t=Le(),[n,o]=$(()=>e===null?null:t.getDevice(e));return Y(()=>{if(e===null){o(null);return}const s=()=>{o(t.getDevice(e))};s();let a=null,i=null;try{a=t.onDeviceAdded(s),i=t.onDeviceRemoved(s)}catch{}const l=t.subscribeConnectionEvents(c=>{c==="connected"&&s()});return()=>{a?.(),i?.(),l()}},[t,e]),n}function WE(e,t,n){const o=Le();return Kn({queryKey:e,queryFn:()=>t(o)(),...n})}function YE(e,t){const n=Le();return El({mutationFn:o=>e(n)(o),...t})}function ZE(e,t){const n=Le(),o=ke(),[s,a]=$(n.connectionVersion);Y(()=>n.subscribeConnectionEvents((c,d)=>{c==="connected"&&a(d)}),[n]);const i=t.join("|"),l=JSON.stringify(e);Y(()=>{const c=[],d=()=>{const f=JSON.parse(l),m=f.length===1&&Array.isArray(f[0])?f:[f];o.invalidateQueries({queryKey:m})};d();for(const f of i.split("|"))if(f)try{c.push(n.subscribeEvent(f,d))}catch{}return()=>{for(const f of c)f()}},[n,o,i,l,s])}const XE=Object.freeze(Object.defineProperty({__proto__:null,AddonGlobalSettingsForm:WP,AgentStepEditor:na,AppShell:eS,AudioClassificationList:gE,AudioLevelWaveform:fE,AudioWaveform:pE,BTN_COMPACT:mN,BTN_COMPACT_DANGER:gN,BTN_COMPACT_PRIMARY:hN,BTN_COMPACT_WARNING:bN,Badge:cr,BatteryBadge:nc,BottomSheet:Ql,Breadcrumb:Gl,Button:He,CHIP_ACTIVE:vN,CHIP_BASE:yN,CHIP_INACTIVE:wN,CLASS_COLORS:Qr,CameraStreamPlayer:xx,Card:Ge,Checkbox:Bm,CodeBlock:X5,CollapsibleCard:Om,ConfigFormBuilder:gx,ConfigFormField:tr,ConfigSchemaField:ta,ConfirmActionButton:Cx,ConfirmDialogProvider:yh,CustomFieldRenderersProvider:Bh,DEFAULT_COLOR:Lh,DataTable:uh,DetectionCanvas:nC,DetectionOverlay:bx,DetectionResultTree:aC,DevShell:Oh,DeviceActivityPanel:jE,DeviceCard:nS,DeviceContextProvider:jh,DeviceGrid:rS,DeviceItem:so,DeviceList:ao,Dialog:Hm,DialogContent:Vl,DialogDescription:Um,DialogFooter:qm,DialogHeader:Vm,DialogTitle:Qm,DialogTrigger:x5,DiscoveryPanel:Sx,DoorbellRecentPanel:$c,Dropdown:Gm,DropdownContent:Ym,DropdownItem:Zm,DropdownTrigger:Wm,EmptyState:ko,EventStream:nr,FilterBar:J5,FloatingEventStream:$E,FloatingLogStream:kx,FloatingPanel:I5,FormField:G5,GRID_GAP:hm,GRID_PAIRED:lN,GRID_QUICK_STATS:iN,INPUT_COMPACT:xN,IconButton:Bl,ImageSelector:uC,InferenceConfigSelector:pC,Input:Ss,KebabMenu:Mx,KeyValueList:Z5,LIST_ROW:gm,Label:Fl,LogStream:Wt,LoginForm:Th,MobileDrawer:Kl,NodeMultiSelectField:mx,NodePicker:gh,NodeSelectField:fx,PHASE_CONFIG:Ri,PTZOverlay:Ec,PageHeader:W5,PhaseIcon:Ac,PipelineBuilder:rc,PipelineRuntimeSelector:JS,PipelineStep:ps,PipelineTreeMatrix:Yl,PlayerOverlaysProvider:yx,Popover:ah,PopoverContent:lh,PopoverTrigger:ih,ProviderBadge:Q5,ResponseLog:bE,SECTION_BODY:aN,SECTION_CARD:oN,SECTION_HEADER:sN,SPLIT_PANEL_OUTER:cN,SPLIT_PANEL_SIDE:dN,STACK_GAP:mm,ScrollArea:Ul,Select:Cs,SemanticBadge:bh,Separator:jl,Sidebar:Vi,SidebarItem:Hi,Skeleton:zm,SlideOverPanel:Wl,SnapshotButton:VE,StatCard:Y5,StateValuesStream:Pc,StatusBadge:V5,StepTimings:dC,StepTreeMaster:fh,StreamPanel:Ic,Switch:Hl,SystemProvider:Xl,TEXT_FIELD_LABEL:pN,TEXT_HINT:ks,TEXT_METRIC:Ti,TEXT_SECTION_LABEL:uN,TEXT_VALUE:fN,Tabs:k5,TabsContent:M5,TabsList:S5,TabsTrigger:C5,ThemeProvider:ws,Tooltip:v5,TooltipContent:N5,TooltipTrigger:w5,VersionBadge:K5,WidgetRegistryProvider:lx,WidgetSlot:it,ZoneEditingProvider:Ax,buildStepTreeFromSchema:ea,cn:K,createSharedContext:un,createTheme:lw,darkColors:Uf,defaultTheme:Di,deriveDeviceKind:sS,ensureMfHostInit:Dl,getClassColor:ct,getPhaseVisual:Wn,isFieldVisible:Sc,lightColors:Kf,mirror:bm,mountAddonPage:wC,providerIcons:u5,statusIcons:p5,themeToCss:fw,trpc:C,useAccessoriesGetStatus:NC,useAddonPagesListPages:ac,useAddonSettingsGetDeviceSettings:_C,useAddonSettingsGetGlobalSettings:cc,useAddonSettingsUpdateDeviceSettings:eg,useAddonSettingsUpdateGlobalSettings:Jh,useAddonWidgetsListWidgets:tg,useAddonsApplyAutoUpdateToAll:Xh,useAddonsCustom:EC,useAddonsForceRefresh:Qh,useAddonsGetAddonAutoUpdate:Yh,useAddonsGetAutoUpdateSettings:Wh,useAddonsGetLogs:kC,useAddonsGetVersions:Kh,useAddonsInstallFromWorkspace:CC,useAddonsInstallPackage:ic,useAddonsIsWorkspaceAvailable:MC,useAddonsList:ra,useAddonsListPackages:SC,useAddonsListUpdates:lc,useAddonsListWorkspacePackages:IC,useAddonsOnAddonLogs:$C,useAddonsReloadPackages:Vh,useAddonsRestartAddon:oa,useAddonsRestartServer:Uh,useAddonsRetryLoad:Gh,useAddonsRollbackPackage:AC,useAddonsSearchAvailable:qh,useAddonsSetAddonAutoUpdate:Zh,useAddonsSetAutoUpdateSettings:PC,useAddonsUninstallPackage:Hh,useAddonsUpdatePackage:Qi,useAlertsDismiss:ag,useAlertsEmit:DC,useAlertsGetUnreadCount:rg,useAlertsList:ng,useAlertsMarkAllRead:sg,useAlertsMarkRead:og,useAlertsUpdate:LC,useAllWidgets:ux,useAudioAnalysisApplyDeviceSettingsPatch:zC,useAudioAnalysisGetDeviceLiveContribution:OC,useAudioAnalysisGetDeviceSettingsContribution:RC,useAudioAnalysisResolveDeviceSettings:TC,useAudioAnalyzerAnalyseChunk:BC,useAudioAnalyzerClassify:FC,useAudioAnalyzerDispose:HC,useAudioAnalyzerIsReady:jC,useAudioAnalyzerReprobeAudioEngine:ig,useAudioCodecCanHandle:qC,useAudioCodecCloseSession:KC,useAudioCodecCreateDecodeSession:QC,useAudioCodecCreateEncodeSession:UC,useAudioCodecFlushEncode:XC,useAudioCodecListActiveSessions:JC,useAudioCodecListSupportedCodecs:VC,useAudioCodecPullEncoded:ZC,useAudioCodecPullPcm:WC,useAudioCodecPushEncodedFrame:GC,useAudioCodecPushPcm:YC,useAudioMetricsGetCurrentSnapshot:e3,useAudioMetricsGetHistory:t3,useAuthenticationListProviders:dc,useAuthenticationSetProviderEnabled:n3,useBackupDelete:pg,useBackupGetEntries:dg,useBackupList:r3,useBackupListArchives:pc,useBackupListDestinations:uc,useBackupListLocations:cg,useBackupPreviewSchedule:mg,useBackupRestore:ug,useBackupTrigger:lg,useBackupUpsertDestinationPolicy:fg,useBatteryGetStatus:o3,useBrightnessGetStatus:a3,useBrightnessSetBrightness:s3,useCameraStreamsGetBrokerStreams:l3,useCameraStreamsGetCameraStreams:i3,useCameraStreamsGetRtspEntries:c3,useClusterNodes:Pr,useConfirm:rt,useCustomFieldRenderer:Fh,useDebouncedString:Dh,useDecoderCreateSession:p3,useDecoderDestroySession:f3,useDecoderGetInfo:u3,useDecoderGetStats:x3,useDecoderListActiveSessions:y3,useDecoderOpenStream:h3,useDecoderPullFrames:g3,useDecoderPushPacket:m3,useDecoderReprobeHwaccel:hg,useDecoderSupportsCodec:d3,useDecoderUpdateConfig:b3,useDetectionPipelineApplyDeviceSettingsPatch:N3,useDetectionPipelineGetDeviceLiveContribution:w3,useDetectionPipelineGetDeviceSettingsContribution:v3,useDevShell:gC,useDevice:GE,useDeviceBattery:ec,useDeviceCapability:Er,useDeviceDetections:Px,useDeviceDiscoveryAdoptDevice:k3,useDeviceDiscoveryGetStatus:C3,useDeviceDiscoveryListDiscovered:gg,useDeviceDiscoveryRefreshDiscovery:bg,useDeviceDiscoveryReleaseDevice:S3,useDeviceId:pn,useDeviceManagerAddLocation:L3,useDeviceManagerAdoptDevice:Pg,useDeviceManagerAllocateDeviceId:M3,useDeviceManagerCreateDevice:$g,useDeviceManagerDisable:kg,useDeviceManagerDiscoverDevices:mc,useDeviceManagerEnable:Ng,useDeviceManagerGetAllBindings:Q3,useDeviceManagerGetBindings:Cg,useDeviceManagerGetChildren:wg,useDeviceManagerGetConfigSchema:B3,useDeviceManagerGetCreationSchema:Eg,useDeviceManagerGetDevice:Fn,useDeviceManagerGetDeviceAggregate:fc,useDeviceManagerGetDeviceLiveInfoAggregate:G3,useDeviceManagerGetDeviceSettingsAggregate:K3,useDeviceManagerGetDeviceStatusAggregate:Z3,useDeviceManagerGetSettingsSchema:F3,useDeviceManagerGetStreamProfileMap:H3,useDeviceManagerGetStreamSources:z3,useDeviceManagerListAll:Jn,useDeviceManagerListBindableCapsForDeviceType:Ig,useDeviceManagerListLocations:vg,useDeviceManagerListPersistedByAddon:O3,useDeviceManagerListWrappersForCap:U3,useDeviceManagerLoadConfig:E3,useDeviceManagerLoadMeta:_3,useDeviceManagerLoadRuntimeState:$3,useDeviceManagerPersistConfig:P3,useDeviceManagerProbeStreams:q3,useDeviceManagerRegisterDevice:I3,useDeviceManagerRemove:Sg,useDeviceManagerRemoveDevice:A3,useDeviceManagerRemoveLocation:T3,useDeviceManagerSetDisabled:R3,useDeviceManagerSetLocation:yg,useDeviceManagerSetMetadata:D3,useDeviceManagerSetName:xg,useDeviceManagerSetStreamProfileMap:V3,useDeviceManagerSetWrapperActive:Mg,useDeviceManagerTestCreationField:hc,useDeviceManagerTestField:Y3,useDeviceManagerUpdateConfig:j3,useDeviceManagerUpdateDeviceField:W3,useDeviceManagerUpdateDeviceFieldsBatch:Ag,useDeviceOpsGetConfigEntries:J3,useDeviceOpsGetSettingsSchema:nM,useDeviceOpsGetStreamSources:X3,useDeviceOpsRemoveDevice:tM,useDeviceOpsSetConfig:eM,useDeviceProviderAdoptDiscoveredDevice:cM,useDeviceProviderCreateDevice:pM,useDeviceProviderDiscoverDevices:lM,useDeviceProviderGetChildCreationSchema:uM,useDeviceProviderGetDevices:aM,useDeviceProviderGetStatus:sM,useDeviceProviderStart:rM,useDeviceProviderStop:oM,useDeviceProviderSupportsDiscovery:iM,useDeviceProviderSupportsManualCreation:dM,useDeviceProviderTestCreationField:fM,useDeviceProxy:kt,useDeviceSnapshot:sc,useDeviceSnapshotImage:tc,useDeviceState:vh,useDeviceStateGetAllSnapshots:gM,useDeviceStateGetCapSlice:hM,useDeviceStateGetSnapshot:mM,useDeviceStateSetCapSlice:bM,useDeviceStateSlice:on,useDeviceWebrtc:_c,useDevices:KE,useDoorbellEvents:Lc,useDoorbellGetStatus:xM,useEventInvalidation:ZE,useEventStreamLatest:Ar,useEventStreamMap:Jl,useEventsGetEventClipUrl:wM,useEventsGetEventThumbnail:vM,useEventsGetEvents:yM,useIntegrationsCreate:Lg,useIntegrationsDelete:Rg,useIntegrationsGet:_g,useIntegrationsGetAvailableTypes:Og,useIntegrationsGetByAddonId:Dg,useIntegrationsGetSettings:NM,useIntegrationsList:sa,useIntegrationsSetSettings:kM,useIntegrationsTestConnection:zg,useIntegrationsUpdate:Tg,useIntercomGetStatus:SM,useIntercomHandleAnswer:Fg,useIntercomStartSession:Bg,useIntercomStopSession:jg,useIsMidWidth:rh,useIsMobile:Xn,useLiveBuffer:On,useLiveEvent:dt,useLocalNetworkGetAllowedAddresses:qg,useLocalNetworkGetConnectionEndpoints:Vg,useLocalNetworkGetPreferred:CM,useLocalNetworkList:Hg,useLocalNetworkResetAllowlistToBestMatch:Ug,useLocalNetworkSetAllowedAddresses:Qg,useMeshOrchestratorJoinProvider:Gg,useMeshOrchestratorLeaveProvider:Wg,useMeshOrchestratorListProviders:Kg,useMetricsProviderCollectSnapshot:MM,useMetricsProviderGetAddonStats:LM,useMetricsProviderGetCached:IM,useMetricsProviderGetCpuTemperature:$M,useMetricsProviderGetCurrent:AM,useMetricsProviderGetDiskSpace:PM,useMetricsProviderGetGpuInfo:EM,useMetricsProviderGetProcessStats:_M,useMetricsProviderKillProcess:Zg,useMetricsProviderListAddonInstances:DM,useMetricsProviderListNodeProcesses:Yg,useMotionDetectionAnalyze:OM,useMotionDetectionApplyDeviceSettingsPatch:HM,useMotionDetectionGetDeviceLiveContribution:jM,useMotionDetectionGetDeviceSettingsContribution:FM,useMotionDetectionRemoveCamera:zM,useMotionDetectionReset:BM,useMotionGetStatus:RM,useMotionIsDetected:TM,useMotionTriggerGetStatus:qM,useMotionTriggerSetMotionTrigger:VM,useNativeObjectDetectionGetStatus:QM,useNetworkQualityGetAllStats:UM,useNetworkQualityGetDeviceStats:gc,useNetworkQualityReportClientStats:KM,useNodesClusterAddonStatus:nb,useNodesDeployAddon:GM,useNodesExecuteQuery:YM,useNodesRenameNode:tb,useNodesRestartAddon:aa,useNodesRestartNode:eb,useNodesRestartProcess:Jg,useNodesSetProcessLogLevel:rb,useNodesShutdownNode:WM,useNodesTopology:In,useNodesUndeployAddon:Xg,useNotificationOutputSend:ZM,useNotificationOutputSendTest:XM,useOptionalSystem:j5,useOptionalWidgetRegistry:px,useOsdGetStatus:e4,useOsdSetOverlay:JM,usePTZ:Dc,usePipelineAnalyticsApplyDeviceSettingsPatch:p4,usePipelineAnalyticsClearTracks:o4,usePipelineAnalyticsGetActiveTracks:t4,usePipelineAnalyticsGetAudioEvents:i4,usePipelineAnalyticsGetDeviceLiveContribution:u4,usePipelineAnalyticsGetDeviceSettingsContribution:d4,usePipelineAnalyticsGetEventMedia:l4,usePipelineAnalyticsGetMotionEvents:s4,usePipelineAnalyticsGetObjectEvents:a4,usePipelineAnalyticsGetTrack:n4,usePipelineAnalyticsGetTrackMedia:c4,usePipelineAnalyticsListTracks:r4,usePipelineExecutorCacheFrameInPool:A4,usePipelineExecutorDeleteModel:lb,usePipelineExecutorDeleteTemplate:N4,usePipelineExecutorDetect:C4,usePipelineExecutorDownloadModel:ib,usePipelineExecutorGetAddonModels:S4,usePipelineExecutorGetAudioCapabilities:O4,usePipelineExecutorGetAvailableEngines:ob,usePipelineExecutorGetCapabilities:k4,usePipelineExecutorGetDefaultSteps:f4,usePipelineExecutorGetDetectionConfigSchema:B4,usePipelineExecutorGetEffectiveTuning:$4,usePipelineExecutorGetGlobalPipelineConfig:b4,usePipelineExecutorGetGlobalSteps:g4,usePipelineExecutorGetOrchestratorConfigSchema:x4,usePipelineExecutorGetReferenceAudio:R4,usePipelineExecutorGetReferenceAudioFiles:T4,usePipelineExecutorGetReferenceImage:L4,usePipelineExecutorGetSchema:So,usePipelineExecutorGetSelectedEngine:sb,usePipelineExecutorGetVideoPipelineSteps:m4,usePipelineExecutorInferCached:P4,usePipelineExecutorKillEngine:db,usePipelineExecutorListLoadedEngines:cb,usePipelineExecutorListReferenceImages:D4,usePipelineExecutorListTemplates:y4,usePipelineExecutorReprobeEngine:ab,usePipelineExecutorRunAudioTest:z4,usePipelineExecutorRunPipeline:M4,usePipelineExecutorRunPipelineBatch:I4,usePipelineExecutorSaveTemplate:v4,usePipelineExecutorSetVideoPipelineSteps:h4,usePipelineExecutorSpinEngine:_4,usePipelineExecutorUncacheFrame:E4,usePipelineExecutorUpdateTemplate:w4,usePipelineOrchestratorApplyDeviceSettingsPatch:G4,usePipelineOrchestratorAssignAudio:vb,usePipelineOrchestratorAssignDecoder:bb,usePipelineOrchestratorAssignPipeline:ub,usePipelineOrchestratorDeleteTemplate:$b,usePipelineOrchestratorGetAgentLoad:mb,usePipelineOrchestratorGetAgentSettings:bc,usePipelineOrchestratorGetAudioAssignment:H4,usePipelineOrchestratorGetAudioAssignments:kb,usePipelineOrchestratorGetAudioNodeLoad:Nb,usePipelineOrchestratorGetCameraMetrics:j4,usePipelineOrchestratorGetCameraSettings:yc,usePipelineOrchestratorGetCameraStepOverrides:q4,usePipelineOrchestratorGetCapabilityBindings:hb,usePipelineOrchestratorGetDecoderAssignment:V4,usePipelineOrchestratorGetDecoderAssignments:yb,usePipelineOrchestratorGetDeviceLiveContribution:K4,usePipelineOrchestratorGetDeviceSettingsContribution:U4,usePipelineOrchestratorGetGlobalMetrics:F4,usePipelineOrchestratorGetPipelineAssignment:la,usePipelineOrchestratorGetPipelineAssignments:ia,usePipelineOrchestratorListAgentSettings:$r,usePipelineOrchestratorListTemplates:Pb,usePipelineOrchestratorRebalance:fb,usePipelineOrchestratorRemoveAgentSettings:Sb,usePipelineOrchestratorResolvePipeline:Ab,usePipelineOrchestratorSaveTemplate:Q4,usePipelineOrchestratorSetAgentAddonDefaults:xc,usePipelineOrchestratorSetCameraPipelineForAgent:Ib,usePipelineOrchestratorSetCameraStepOverride:Mb,usePipelineOrchestratorSetCameraStepToggle:Cb,usePipelineOrchestratorSetCapabilityBinding:gb,usePipelineOrchestratorUnassignAudio:wb,usePipelineOrchestratorUnassignDecoder:xb,usePipelineOrchestratorUnassignPipeline:pb,usePipelineOrchestratorUpdateTemplate:Eb,usePipelineRunnerAttachCamera:W4,usePipelineRunnerDetachCamera:Y4,usePipelineRunnerGetAllCameraMetrics:eI,usePipelineRunnerGetCameraMetrics:vc,usePipelineRunnerGetLocalCameras:_b,usePipelineRunnerGetLocalLoad:X4,usePipelineRunnerGetLocalMetrics:J4,usePipelineRunnerReportMotion:Z4,usePlatformProbeGetCapabilities:tI,usePlatformProbeGetHardware:nI,usePlatformProbeResolveHwAccel:oI,usePlatformProbeResolveInferenceConfig:rI,usePlayerOverlayLayer:rE,usePlayerOverlayLayers:vx,usePlayerToolbarButton:oE,usePlayerToolbarButtons:wx,usePtzAutotrackGetSettings:fI,usePtzAutotrackGetStatus:Db,usePtzAutotrackSetEnabled:Lb,usePtzAutotrackSetSettings:Tb,usePtzContinuousMove:aI,usePtzGetPosition:uI,usePtzGetPresets:lI,usePtzGetStatus:pI,usePtzGoHome:dI,usePtzGoToPreset:cI,usePtzMove:sI,usePtzStop:iI,useRebootReboot:Rb,useRecordingEngineDisable:zb,useRecordingEngineEnable:Ob,useRecordingEngineEstimateGlobalStorage:kI,useRecordingEngineEstimateStorage:NI,useRecordingEngineGetAvailability:wI,useRecordingEngineGetConfig:Bb,useRecordingEngineGetMotionStats:II,useRecordingEngineGetPlaylist:yI,useRecordingEngineGetPolicy:CI,useRecordingEngineGetPolicyStatus:Hb,useRecordingEngineGetRetentionConfig:Vb,useRecordingEngineGetSegments:Fb,useRecordingEngineGetStatus:bI,useRecordingEngineGetStorageUsage:jb,useRecordingEngineGetThumbnail:vI,useRecordingEngineSetPolicy:SI,useRecordingEngineUpdateConfig:xI,useRecordingEngineUpdateRetentionConfig:MI,useRecordingGetPlaybackUrl:hI,useRecordingGetSegments:mI,useRecordingGetThumbnailAt:gI,useRemoteAccessListProviders:qb,useRemoteAccessStartProvider:Qb,useRemoteAccessStopProvider:Ub,useSettingsStoreCount:LI,useSettingsStoreDeclareCollection:RI,useSettingsStoreDelete:DI,useSettingsStoreGet:AI,useSettingsStoreInsert:$I,useSettingsStoreIsEmpty:TI,useSettingsStoreQuery:EI,useSettingsStoreSet:PI,useSettingsStoreUpdate:_I,useSnapshotApplyDeviceSettingsPatch:HI,useSnapshotGetDeviceLiveContribution:jI,useSnapshotGetDeviceSettingsContribution:FI,useSnapshotGetSnapshot:OI,useSnapshotGetStatus:BI,useSnapshotInvalidateCache:zI,useSnapshotProviderGetSnapshot:qI,useSnapshotProviderSupportsDevice:VI,useStorageAbortUpload:tA,useStorageBeginDownload:nA,useStorageBeginUpload:XI,useStorageDelete:YI,useStorageDeleteLocation:Gb,useStorageEndDownload:oA,useStorageExists:GI,useStorageFinalizeUpload:eA,useStorageGetAvailableSpace:ZI,useStorageGetDefaultLocation:sA,useStorageList:WI,useStorageListLocations:Kb,useStorageListProviders:wc,useStorageRead:KI,useStorageReadChunk:rA,useStorageResolve:QI,useStorageTestConfig:iA,useStorageTestLocation:aA,useStorageUpsertLocation:ca,useStorageWrite:UI,useStorageWriteChunk:JI,useStreamBrokerApplyDeviceSettingsPatch:PA,useStreamBrokerAssignProfile:dA,useStreamBrokerGetAllRtspEntries:kA,useStreamBrokerGetBroker:yA,useStreamBrokerGetBrokerStats:mA,useStreamBrokerGetDeviceLiveContribution:AA,useStreamBrokerGetDeviceSettingsContribution:IA,useStreamBrokerGetPreBufferInfo:wA,useStreamBrokerGetRtspEntry:SA,useStreamBrokerGetRtspPort:NA,useStreamBrokerGetStreamUrl:xA,useStreamBrokerIsRtspEnabled:MA,useStreamBrokerKillClient:gA,useStreamBrokerListAllCameraStreams:pA,useStreamBrokerListAllProfileSlots:fA,useStreamBrokerListClients:hA,useStreamBrokerPublishCameraStream:lA,useStreamBrokerRegenerateRtspToken:Wb,useStreamBrokerRestartProfile:bA,useStreamBrokerRetractCameraStream:cA,useStreamBrokerSetPreBufferDuration:vA,useStreamBrokerSetRtspEnabled:CA,useStreamBrokerUnassignProfile:uA,useSwitchGetStatus:$A,useSwitchSetState:EA,useSystem:Le,useSystemFeatureFlags:LA,useSystemForceRetentionCleanup:zA,useSystemGetRetentionConfig:RA,useSystemHealth:DA,useSystemInfo:_A,useSystemMutation:YE,useSystemNetworkAddresses:TA,useSystemQuery:WE,useSystemSetRetentionConfig:OA,useThemeMode:Ir,useToastOnToast:Yb,useTurnOrchestratorGetAllServers:Xb,useTurnOrchestratorListProviders:Zb,useTurnOrchestratorSetProviderEnabled:BA,useTurnProviderGetTurnServers:FA,useUserManagementCreateApiKey:HA,useUserManagementCreateScopedToken:ox,useUserManagementCreateUser:Jb,useUserManagementDeleteUser:tx,useUserManagementListApiKeys:nx,useUserManagementListScopedTokens:ax,useUserManagementListUsers:Nc,useUserManagementResetPassword:kc,useUserManagementRevokeApiKey:rx,useUserManagementRevokeScopedToken:sx,useUserManagementUpdateUser:ex,useUserManagementValidateApiKey:VA,useUserManagementValidateCredentials:jA,useUserManagementValidateScopedToken:qA,useWebrtcSessionCloseSession:GA,useWebrtcSessionCreateSession:UA,useWebrtcSessionHandleAnswer:KA,useWebrtcSessionHasAdaptiveBitrate:WA,useWebrtcSessionListStreams:QA,useWidget:cx,useWidgetMetadata:dx,useWidgetRegistry:da,useZoneAnalyticsGetCameraHistory:XA,useZoneAnalyticsGetCurrentSnapshot:YA,useZoneAnalyticsGetUnzonedHistory:JA,useZoneAnalyticsGetZoneHistory:ZA,useZoneEditing:QE,useZoneRulesListRules:eP,useZoneRulesSetRules:tP,useZonesAddZone:rP,useZonesListZones:nP,useZonesRemoveZone:oP,useZonesUpdateZone:sP},Symbol.toStringTag,{value:"Module"}));/**
|
|
535
|
+
* react-router v7.15.0
|
|
536
|
+
*
|
|
537
|
+
* Copyright (c) Remix Software Inc.
|
|
538
|
+
*
|
|
539
|
+
* This source code is licensed under the MIT license found in the
|
|
540
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
541
|
+
*
|
|
542
|
+
* @license MIT
|
|
543
|
+
*/var ku="popstate";function Su(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function JE(e={}){function t(o,s){let a=s.state?.masked,{pathname:i,search:l,hash:c}=a||o.location;return Gi("",{pathname:i,search:l,hash:c},s.state&&s.state.usr||null,s.state&&s.state.key||"default",a?{pathname:o.location.pathname,search:o.location.search,hash:o.location.hash}:void 0)}function n(o,s){return typeof s=="string"?s:io(s)}return t$(t,n,null,e)}function ze(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function vt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function e$(){return Math.random().toString(36).substring(2,10)}function Cu(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Gi(e,t,n=null,o,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?_r(t):t,state:n,key:t&&t.key||o||e$(),mask:s}}function io({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function _r(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let o=e.indexOf("?");o>=0&&(t.search=e.substring(o),e=e.substring(0,o)),e&&(t.pathname=e)}return t}function t$(e,t,n,o={}){let{window:s=document.defaultView,v5Compat:a=!1}=o,i=s.history,l="POP",c=null,d=f();d==null&&(d=0,i.replaceState({...i.state,idx:d},""));function f(){return(i.state||{idx:null}).idx}function p(){l="POP";let x=f(),v=x==null?null:x-d;d=x,c&&c({action:l,location:b.location,delta:v})}function m(x,v){l="PUSH";let w=Su(x)?x:Gi(b.location,x,v);d=f()+1;let y=Cu(w,d),N=b.createHref(w.mask||w);try{i.pushState(y,"",N)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;s.location.assign(N)}a&&c&&c({action:l,location:b.location,delta:1})}function h(x,v){l="REPLACE";let w=Su(x)?x:Gi(b.location,x,v);d=f();let y=Cu(w,d),N=b.createHref(w.mask||w);i.replaceState(y,"",N),a&&c&&c({action:l,location:b.location,delta:0})}function g(x){return n$(x)}let b={get action(){return l},get location(){return e(s,i)},listen(x){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(ku,p),c=x,()=>{s.removeEventListener(ku,p),c=null}},createHref(x){return t(s,x)},createURL:g,encodeLocation(x){let v=g(x);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:m,replace:h,go(x){return i.go(x)}};return b}function n$(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ze(n,"No window.location.(origin|href) available to create URL");let o=typeof e=="string"?e:io(e);return o=o.replace(/ $/,"%20"),!t&&o.startsWith("//")&&(o=n+o),new URL(o,n)}function Ex(e,t,n="/"){return r$(e,t,n,!1)}function r$(e,t,n,o,s){let a=typeof t=="string"?_r(t):t,i=sn(a.pathname||"/",n);if(i==null)return null;let l=o$(e),c=null,d=g$(i);for(let f=0;c==null&&f<l.length;++f)c=m$(l[f],d,o);return c}function o$(e){let t=$x(e);return s$(t),t}function $x(e,t=[],n=[],o="",s=!1){let a=(i,l,c=s,d)=>{let f={relativePath:d===void 0?i.path||"":d,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(o)&&c)return;ze(f.relativePath.startsWith(o),`Absolute route path "${f.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),f.relativePath=f.relativePath.slice(o.length)}let p=Dt([o,f.relativePath]),m=n.concat(f);i.children&&i.children.length>0&&(ze(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${p}".`),$x(i.children,t,m,p,c)),!(i.path==null&&!i.index)&&t.push({path:p,score:p$(p,i.index),routesMeta:m})};return e.forEach((i,l)=>{if(i.path===""||!i.path?.includes("?"))a(i,l);else for(let c of _x(i.path))a(i,l,!0,c)}),t}function _x(e){let t=e.split("/");if(t.length===0)return[];let[n,...o]=t,s=n.endsWith("?"),a=n.replace(/\?$/,"");if(o.length===0)return s?[a,""]:[a];let i=_x(o.join("/")),l=[];return l.push(...i.map(c=>c===""?a:[a,c].join("/"))),s&&l.push(...i),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function s$(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:f$(t.routesMeta.map(o=>o.childrenIndex),n.routesMeta.map(o=>o.childrenIndex)))}var a$=/^:[\w-]+$/,i$=3,l$=2,c$=1,d$=10,u$=-2,Mu=e=>e==="*";function p$(e,t){let n=e.split("/"),o=n.length;return n.some(Mu)&&(o+=u$),t&&(o+=l$),n.filter(s=>!Mu(s)).reduce((s,a)=>s+(a$.test(a)?i$:a===""?c$:d$),o)}function f$(e,t){return e.length===t.length&&e.slice(0,-1).every((o,s)=>o===t[s])?e[e.length-1]-t[t.length-1]:0}function m$(e,t,n=!1){let{routesMeta:o}=e,s={},a="/",i=[];for(let l=0;l<o.length;++l){let c=o[l],d=l===o.length-1,f=a==="/"?t:t.slice(a.length)||"/",p=Is({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},f),m=c.route;if(!p&&d&&n&&!o[o.length-1].route.index&&(p=Is({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!p)return null;Object.assign(s,p.params),i.push({params:s,pathname:Dt([a,p.pathname]),pathnameBase:v$(Dt([a,p.pathnameBase])),route:m}),p.pathnameBase!=="/"&&(a=Dt([a,p.pathnameBase]))}return i}function Is(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,o]=h$(e.path,e.caseSensitive,e.end),s=t.match(n);if(!s)return null;let a=s[0],i=a.replace(/(.)\/+$/,"$1"),l=s.slice(1);return{params:o.reduce((d,{paramName:f,isOptional:p},m)=>{if(f==="*"){let g=l[m]||"";i=a.slice(0,a.length-g.length).replace(/(.)\/+$/,"$1")}const h=l[m];return p&&!h?d[f]=void 0:d[f]=(h||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:i,pattern:e}}function h$(e,t=!1,n=!0){vt(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let o=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,c,d,f)=>{if(o.push({paramName:l,isOptional:c!=null}),c){let p=f.charAt(d+i.length);return p&&p!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(o.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),o]}function g$(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return vt(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function sn(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,o=e.charAt(n);return o&&o!=="/"?null:e.slice(n)||"/"}var b$=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function x$(e,t="/"){let{pathname:n,search:o="",hash:s=""}=typeof e=="string"?_r(e):e,a;return n?(n=Dx(n),n.startsWith("/")?a=Iu(n.substring(1),"/"):a=Iu(n,t)):a=t,{pathname:a,search:w$(o),hash:N$(s)}}function Iu(e,t){let n=As(t).split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function ei(e,t,n,o){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function y$(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Tc(e){let t=y$(e);return t.map((n,o)=>o===t.length-1?n.pathname:n.pathnameBase)}function pa(e,t,n,o=!1){let s;typeof e=="string"?s=_r(e):(s={...e},ze(!s.pathname||!s.pathname.includes("?"),ei("?","pathname","search",s)),ze(!s.pathname||!s.pathname.includes("#"),ei("#","pathname","hash",s)),ze(!s.search||!s.search.includes("#"),ei("#","search","hash",s)));let a=e===""||s.pathname==="",i=a?"/":s.pathname,l;if(i==null)l=n;else{let p=t.length-1;if(!o&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),p-=1;s.pathname=m.join("/")}l=p>=0?t[p]:"/"}let c=x$(s,l),d=i&&i!=="/"&&i.endsWith("/"),f=(a||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var Dx=e=>e.replace(/\/\/+/g,"/"),Dt=e=>Dx(e.join("/")),As=e=>e.replace(/\/+$/,""),v$=e=>As(e).replace(/^\/*/,"/"),w$=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,N$=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,k$=class{constructor(e,t,n,o=!1){this.status=e,this.statusText=t||"",this.internal=o,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function S$(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function C$(e){let t=e.map(n=>n.route.path).filter(Boolean);return Dt(t)||"/"}var Lx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Tx(e,t){let n=e;if(typeof n!="string"||!b$.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let o=n,s=!1;if(Lx)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=sn(i.pathname,t);i.origin===a.origin&&l!=null?n=l+i.search+i.hash:s=!0}catch{vt(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:s,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Rx=["POST","PUT","PATCH","DELETE"];new Set(Rx);var M$=["GET",...Rx];new Set(M$);var Dr=Oe(null);Dr.displayName="DataRouter";var fa=Oe(null);fa.displayName="DataRouterState";var Ox=Oe(!1);function I$(){return ye(Ox)}var zx=Oe({isTransitioning:!1});zx.displayName="ViewTransition";var A$=Oe(new Map);A$.displayName="Fetchers";var P$=Oe(null);P$.displayName="Await";var mt=Oe(null);mt.displayName="Navigation";var Co=Oe(null);Co.displayName="Location";var St=Oe({outlet:null,matches:[],isDataRoute:!1});St.displayName="Route";var Rc=Oe(null);Rc.displayName="RouteError";var Bx="REACT_ROUTER_ERROR",E$="REDIRECT",$$="ROUTE_ERROR_RESPONSE";function _$(e){if(e.startsWith(`${Bx}:${E$}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function D$(e){if(e.startsWith(`${Bx}:${$$}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new k$(t.status,t.statusText,t.data)}catch{}}function L$(e,{relative:t}={}){ze(Lr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:o}=ye(mt),{hash:s,pathname:a,search:i}=Mo(e,{relative:t}),l=a;return n!=="/"&&(l=a==="/"?n:Dt([n,a])),o.createHref({pathname:l,search:i,hash:s})}function Lr(){return ye(Co)!=null}function ht(){return ze(Lr(),"useLocation() may be used only in the context of a <Router> component."),ye(Co).location}var Fx="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function jx(e){ye(mt).static||Gs(e)}function et(){let{isDataRoute:e}=ye(St);return e?W$():T$()}function T$(){ze(Lr(),"useNavigate() may be used only in the context of a <Router> component.");let e=ye(Dr),{basename:t,navigator:n}=ye(mt),{matches:o}=ye(St),{pathname:s}=ht(),a=JSON.stringify(Tc(o)),i=ne(!1);return jx(()=>{i.current=!0}),q((c,d={})=>{if(vt(i.current,Fx),!i.current)return;if(typeof c=="number"){n.go(c);return}let f=pa(c,JSON.parse(a),s,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Dt([t,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,a,s,e])}var R$=Oe(null);function O$(e){let t=ye(St).outlet;return Q(()=>t&&Me(R$.Provider,{value:e},t),[t,e])}function Oc(){let{matches:e}=ye(St);return e[e.length-1]?.params??{}}function Mo(e,{relative:t}={}){let{matches:n}=ye(St),{pathname:o}=ht(),s=JSON.stringify(Tc(n));return Q(()=>pa(e,JSON.parse(s),o,t==="path"),[e,s,o,t])}function z$(e,t){return Hx(e,t)}function Hx(e,t,n){ze(Lr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=ye(mt),{matches:s}=ye(St),a=s[s.length-1],i=a?a.params:{},l=a?a.pathname:"/",c=a?a.pathnameBase:"/",d=a&&a.route;{let x=d&&d.path||"";qx(l,!d||x.endsWith("*")||x.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${x}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
544
|
+
|
|
545
|
+
Please change the parent <Route path="${x}"> to <Route path="${x==="/"?"*":`${x}/*`}">.`)}let f=ht(),p;if(t){let x=typeof t=="string"?_r(t):t;ze(c==="/"||x.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${x.pathname}" was given in the \`location\` prop.`),p=x}else p=f;let m=p.pathname||"/",h=m;if(c!=="/"){let x=c.replace(/^\//,"").split("/");h="/"+m.replace(/^\//,"").split("/").slice(x.length).join("/")}let g=n&&n.state.matches.length?n.state.matches.map(x=>Object.assign(x,{route:n.manifest[x.route.id]||x.route})):Ex(e,{pathname:h});vt(d||g!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),vt(g==null||g[g.length-1].route.element!==void 0||g[g.length-1].route.Component!==void 0||g[g.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let b=V$(g&&g.map(x=>Object.assign({},x,{params:Object.assign({},i,x.params),pathname:Dt([c,o.encodeLocation?o.encodeLocation(x.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?c:Dt([c,o.encodeLocation?o.encodeLocation(x.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathnameBase])})),s,n);return t&&b?Me(Co.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...p},navigationType:"POP"}},b):b}function B$(){let e=G$(),t=S$(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,o="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:o},a={padding:"2px 4px",backgroundColor:o},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=Me(hr,null,Me("p",null,"💿 Hey developer 👋"),Me("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",Me("code",{style:a},"ErrorBoundary")," or"," ",Me("code",{style:a},"errorElement")," prop on your route.")),Me(hr,null,Me("h2",null,"Unexpected Application Error!"),Me("h3",{style:{fontStyle:"italic"}},t),n?Me("pre",{style:s},n):null,i)}var F$=Me(B$,null),Vx=class extends K1{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=D$(e.digest);n&&(e=n)}let t=e!==void 0?Me(St.Provider,{value:this.props.routeContext},Me(Rc.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?Me(j$,{error:e},t):t}};Vx.contextType=Ox;var ti=new WeakMap;function j$({children:e,error:t}){let{basename:n}=ye(mt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let o=_$(t.digest);if(o){let s=ti.get(t);if(s)throw s;let a=Tx(o.location,n);if(Lx&&!ti.get(t))if(a.isExternal||o.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:o.replace}));throw ti.set(t,i),i}return Me("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function H$({routeContext:e,match:t,children:n}){let o=ye(Dr);return o&&o.static&&o.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=t.route.id),Me(St.Provider,{value:e},n)}function V$(e,t=[],n){let o=n?.state;if(e==null){if(!o)return null;if(o.errors)e=o.matches;else if(t.length===0&&!o.initialized&&o.matches.length>0)e=o.matches;else return null}let s=e,a=o?.errors;if(a!=null){let f=s.findIndex(p=>p.route.id&&a?.[p.route.id]!==void 0);ze(f>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),s=s.slice(0,Math.min(s.length,f+1))}let i=!1,l=-1;if(n&&o){i=o.renderFallback;for(let f=0;f<s.length;f++){let p=s[f];if((p.route.HydrateFallback||p.route.hydrateFallbackElement)&&(l=f),p.route.id){let{loaderData:m,errors:h}=o,g=p.route.loader&&!m.hasOwnProperty(p.route.id)&&(!h||h[p.route.id]===void 0);if(p.route.lazy||g){n.isStatic&&(i=!0),l>=0?s=s.slice(0,l+1):s=[s[0]];break}}}}let c=n?.onError,d=o&&c?(f,p)=>{c(f,{location:o.location,params:o.matches?.[0]?.params??{},pattern:C$(o.matches),errorInfo:p})}:void 0;return s.reduceRight((f,p,m)=>{let h,g=!1,b=null,x=null;o&&(h=a&&p.route.id?a[p.route.id]:void 0,b=p.route.errorElement||F$,i&&(l<0&&m===0?(qx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,x=null):l===m&&(g=!0,x=p.route.hydrateFallbackElement||null)));let v=t.concat(s.slice(0,m+1)),w=()=>{let y;return h?y=b:g?y=x:p.route.Component?y=Me(p.route.Component,null):p.route.element?y=p.route.element:y=f,Me(H$,{match:p,routeContext:{outlet:f,matches:v,isDataRoute:o!=null},children:y})};return o&&(p.route.ErrorBoundary||p.route.errorElement||m===0)?Me(Vx,{location:o.location,revalidation:o.revalidation,component:b,error:h,children:w(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:d}):w()},null)}function zc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function q$(e){let t=ye(Dr);return ze(t,zc(e)),t}function Q$(e){let t=ye(fa);return ze(t,zc(e)),t}function U$(e){let t=ye(St);return ze(t,zc(e)),t}function Bc(e){let t=U$(e),n=t.matches[t.matches.length-1];return ze(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function K$(){return Bc("useRouteId")}function G$(){let e=ye(Rc),t=Q$("useRouteError"),n=Bc("useRouteError");return e!==void 0?e:t.errors?.[n]}function W$(){let{router:e}=q$("useNavigate"),t=Bc("useNavigate"),n=ne(!1);return jx(()=>{n.current=!0}),q(async(s,a={})=>{vt(n.current,Fx),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:t,...a}))},[e,t])}var Au={};function qx(e,t,n){!t&&!Au[e]&&(Au[e]=!0,vt(!1,n))}Fe(Y$);function Y$({routes:e,manifest:t,future:n,state:o,isStatic:s,onError:a}){return Hx(e,void 0,{manifest:t,state:o,isStatic:s,onError:a})}function gt({to:e,replace:t,state:n,relative:o}){ze(Lr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:s}=ye(mt);vt(!s,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:a}=ye(St),{pathname:i}=ht(),l=et(),c=pa(e,Tc(a),i,o==="path"),d=JSON.stringify(c);return Y(()=>{l(JSON.parse(d),{replace:t,state:n,relative:o})},[l,d,o,t,n]),null}function Z$(e){return O$(e.context)}function De(e){ze(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function X$({basename:e="/",children:t=null,location:n,navigationType:o="POP",navigator:s,static:a=!1,useTransitions:i}){ze(!Lr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=Q(()=>({basename:l,navigator:s,static:a,useTransitions:i,future:{}}),[l,s,a,i]);typeof n=="string"&&(n=_r(n));let{pathname:d="/",search:f="",hash:p="",state:m=null,key:h="default",mask:g}=n,b=Q(()=>{let x=sn(d,l);return x==null?null:{location:{pathname:x,search:f,hash:p,state:m,key:h,mask:g},navigationType:o}},[l,d,f,p,m,h,o,g]);return vt(b!=null,`<Router basename="${l}"> is not able to match the URL "${d}${f}${p}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:Me(mt.Provider,{value:c},Me(Co.Provider,{children:t,value:b}))}function J$({children:e,location:t}){return z$(Wi(e),t)}function Wi(e,t=[]){let n=[];return Q1.forEach(e,(o,s)=>{if(!U1(o))return;let a=[...t,s];if(o.type===hr){n.push.apply(n,Wi(o.props.children,a));return}ze(o.type===De,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ze(!o.props.index||!o.props.children,"An index route cannot have child routes.");let i={id:o.props.id||a.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(i.children=Wi(o.props.children,a)),n.push(i)}),n}var ms="get",hs="application/x-www-form-urlencoded";function ma(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function e_(e){return ma(e)&&e.tagName.toLowerCase()==="button"}function t_(e){return ma(e)&&e.tagName.toLowerCase()==="form"}function n_(e){return ma(e)&&e.tagName.toLowerCase()==="input"}function r_(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function o_(e,t){return e.button===0&&(!t||t==="_self")&&!r_(e)}function Yi(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let o=e[n];return t.concat(Array.isArray(o)?o.map(s=>[n,s]):[[n,o]])},[]))}function s_(e,t){let n=Yi(e);return t&&t.forEach((o,s)=>{n.has(s)||t.getAll(s).forEach(a=>{n.append(s,a)})}),n}var Qo=null;function a_(){if(Qo===null)try{new FormData(document.createElement("form"),0),Qo=!1}catch{Qo=!0}return Qo}var i_=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ni(e){return e!=null&&!i_.has(e)?(vt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${hs}"`),null):e}function l_(e,t){let n,o,s,a,i;if(t_(e)){let l=e.getAttribute("action");o=l?sn(l,t):null,n=e.getAttribute("method")||ms,s=ni(e.getAttribute("enctype"))||hs,a=new FormData(e)}else if(e_(e)||n_(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(o=c?sn(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||ms,s=ni(e.getAttribute("formenctype"))||ni(l.getAttribute("enctype"))||hs,a=new FormData(l,e),!a_()){let{name:d,type:f,value:p}=e;if(f==="image"){let m=d?`${d}.`:"";a.append(`${m}x`,"0"),a.append(`${m}y`,"0")}else d&&a.append(d,p)}}else{if(ma(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=ms,o=null,s=hs,i=e}return a&&s==="text/plain"&&(i=a,a=void 0),{action:o,method:n.toLowerCase(),encType:s,formData:a,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Fc(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Qx(e,t,n,o){let s=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?s.pathname.endsWith("/")?s.pathname=`${s.pathname}_.${o}`:s.pathname=`${s.pathname}.${o}`:s.pathname==="/"?s.pathname=`_root.${o}`:t&&sn(s.pathname,t)==="/"?s.pathname=`${As(t)}/_root.${o}`:s.pathname=`${As(s.pathname)}.${o}`,s}async function c_(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function d_(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function u_(e,t,n){let o=await Promise.all(e.map(async s=>{let a=t.routes[s.route.id];if(a){let i=await c_(a,n);return i.links?i.links():[]}return[]}));return h_(o.flat(1).filter(d_).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function Pu(e,t,n,o,s,a){let i=(c,d)=>n[d]?c.route.id!==n[d].route.id:!0,l=(c,d)=>n[d].pathname!==c.pathname||n[d].route.path?.endsWith("*")&&n[d].params["*"]!==c.params["*"];return a==="assets"?t.filter((c,d)=>i(c,d)||l(c,d)):a==="data"?t.filter((c,d)=>{let f=o.routes[c.route.id];if(!f||!f.hasLoader)return!1;if(i(c,d)||l(c,d))return!0;if(c.route.shouldRevalidate){let p=c.route.shouldRevalidate({currentUrl:new URL(s.pathname+s.search+s.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof p=="boolean")return p}return!0}):[]}function p_(e,t,{includeHydrateFallback:n}={}){return f_(e.map(o=>{let s=t.routes[o.route.id];if(!s)return[];let a=[s.module];return s.clientActionModule&&(a=a.concat(s.clientActionModule)),s.clientLoaderModule&&(a=a.concat(s.clientLoaderModule)),n&&s.hydrateFallbackModule&&(a=a.concat(s.hydrateFallbackModule)),s.imports&&(a=a.concat(s.imports)),a}).flat(1))}function f_(e){return[...new Set(e)]}function m_(e){let t={},n=Object.keys(e).sort();for(let o of n)t[o]=e[o];return t}function h_(e,t){let n=new Set;return new Set(t),e.reduce((o,s)=>{let a=JSON.stringify(m_(s));return n.has(a)||(n.add(a),o.push({key:a,link:s})),o},[])}function jc(){let e=ye(Dr);return Fc(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function g_(){let e=ye(fa);return Fc(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Hc=Oe(void 0);Hc.displayName="FrameworkContext";function Vc(){let e=ye(Hc);return Fc(e,"You must render this element inside a <HydratedRouter> element"),e}function b_(e,t){let n=ye(Hc),[o,s]=$(!1),[a,i]=$(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:f,onTouchStart:p}=t,m=ne(null);Y(()=>{if(e==="render"&&i(!0),e==="viewport"){let b=v=>{v.forEach(w=>{i(w.isIntersecting)})},x=new IntersectionObserver(b,{threshold:.5});return m.current&&x.observe(m.current),()=>{x.disconnect()}}},[e]),Y(()=>{if(o){let b=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(b)}}},[o]);let h=()=>{s(!0)},g=()=>{s(!1),i(!1)};return n?e!=="intent"?[a,m,{}]:[a,m,{onFocus:Br(l,h),onBlur:Br(c,g),onMouseEnter:Br(d,h),onMouseLeave:Br(f,g),onTouchStart:Br(p,h)}]:[!1,m,{}]}function Br(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function x_({page:e,...t}){let n=I$(),{router:o}=jc(),s=Q(()=>Ex(o.routes,e,o.basename),[o.routes,e,o.basename]);return s?n?Me(v_,{page:e,matches:s,...t}):Me(w_,{page:e,matches:s,...t}):null}function y_(e){let{manifest:t,routeModules:n}=Vc(),[o,s]=$([]);return Y(()=>{let a=!1;return u_(e,t,n).then(i=>{a||s(i)}),()=>{a=!0}},[e,t,n]),o}function v_({page:e,matches:t,...n}){let o=ht(),{future:s}=Vc(),{basename:a}=jc(),i=Q(()=>{if(e===o.pathname+o.search+o.hash)return[];let l=Qx(e,a,s.unstable_trailingSlashAwareDataRequests,"rsc"),c=!1,d=[];for(let f of t)typeof f.route.shouldRevalidate=="function"?c=!0:d.push(f.route.id);return c&&d.length>0&&l.searchParams.set("_routes",d.join(",")),[l.pathname+l.search]},[a,s.unstable_trailingSlashAwareDataRequests,e,o,t]);return Me(hr,null,i.map(l=>Me("link",{key:l,rel:"prefetch",as:"fetch",href:l,...n})))}function w_({page:e,matches:t,...n}){let o=ht(),{future:s,manifest:a,routeModules:i}=Vc(),{basename:l}=jc(),{loaderData:c,matches:d}=g_(),f=Q(()=>Pu(e,t,d,a,o,"data"),[e,t,d,a,o]),p=Q(()=>Pu(e,t,d,a,o,"assets"),[e,t,d,a,o]),m=Q(()=>{if(e===o.pathname+o.search+o.hash)return[];let b=new Set,x=!1;if(t.forEach(w=>{let y=a.routes[w.route.id];!y||!y.hasLoader||(!f.some(N=>N.route.id===w.route.id)&&w.route.id in c&&i[w.route.id]?.shouldRevalidate||y.hasClientLoader?x=!0:b.add(w.route.id))}),b.size===0)return[];let v=Qx(e,l,s.unstable_trailingSlashAwareDataRequests,"data");return x&&b.size>0&&v.searchParams.set("_routes",t.filter(w=>b.has(w.route.id)).map(w=>w.route.id).join(",")),[v.pathname+v.search]},[l,s.unstable_trailingSlashAwareDataRequests,c,o,a,f,t,e,i]),h=Q(()=>p_(p,a),[p,a]),g=y_(p);return Me(hr,null,m.map(b=>Me("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),h.map(b=>Me("link",{key:b,rel:"modulepreload",href:b,...n})),g.map(({key:b,link:x})=>Me("link",{key:b,nonce:n.nonce,...x,crossOrigin:x.crossOrigin??n.crossOrigin})))}function N_(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var k_=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{k_&&(window.__reactRouterVersion="7.15.0")}catch{}function S_({basename:e,children:t,useTransitions:n,window:o}){let s=ne();s.current==null&&(s.current=JE({window:o,v5Compat:!0}));let a=s.current,[i,l]=$({action:a.action,location:a.location}),c=q(d=>{n===!1?l(d):Pl(()=>l(d))},[n]);return Gs(()=>a.listen(c),[a,c]),Me(X$,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a,useTransitions:n})}var Ux=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Kt=Ve(function({onClick:t,discover:n="render",prefetch:o="none",relative:s,reloadDocument:a,replace:i,mask:l,state:c,target:d,to:f,preventScrollReset:p,viewTransition:m,defaultShouldRevalidate:h,...g},b){let{basename:x,navigator:v,useTransitions:w}=ye(mt),y=typeof f=="string"&&Ux.test(f),N=Tx(f,x);f=N.to;let k=L$(f,{relative:s}),S=ht(),M=null;if(l){let D=pa(l,[],S.mask?S.mask.pathname:"/",!0);x!=="/"&&(D.pathname=D.pathname==="/"?x:Dt([x,D.pathname])),M=v.createHref(D)}let[P,I,F]=b_(o,g),E=A_(f,{replace:i,mask:l,state:c,target:d,preventScrollReset:p,relative:s,viewTransition:m,defaultShouldRevalidate:h,useTransitions:w});function B(D){t&&t(D),D.defaultPrevented||E(D)}let O=!(N.isExternal||a),A=Me("a",{...g,...F,href:(O?M:void 0)||N.absoluteURL||k,onClick:O?B:t,ref:N_(b,I),target:d,"data-discover":!y&&n==="render"?"true":void 0});return P&&!y?Me(hr,null,A,Me(x_,{page:k})):A});Kt.displayName="Link";var C_=Ve(function({"aria-current":t="page",caseSensitive:n=!1,className:o="",end:s=!1,style:a,to:i,viewTransition:l,children:c,...d},f){let p=Mo(i,{relative:d.relative}),m=ht(),h=ye(fa),{navigator:g,basename:b}=ye(mt),x=h!=null&&D_(p)&&l===!0,v=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,w=m.pathname,y=h&&h.navigation&&h.navigation.location?h.navigation.location.pathname:null;n||(w=w.toLowerCase(),y=y?y.toLowerCase():null,v=v.toLowerCase()),y&&b&&(y=sn(y,b)||y);const N=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let k=w===v||!s&&w.startsWith(v)&&w.charAt(N)==="/",S=y!=null&&(y===v||!s&&y.startsWith(v)&&y.charAt(v.length)==="/"),M={isActive:k,isPending:S,isTransitioning:x},P=k?t:void 0,I;typeof o=="function"?I=o(M):I=[o,k?"active":null,S?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let F=typeof a=="function"?a(M):a;return Me(Kt,{...d,"aria-current":P,className:I,ref:f,style:F,to:i,viewTransition:l},typeof c=="function"?c(M):c)});C_.displayName="NavLink";var M_=Ve(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:o,replace:s,state:a,method:i=ms,action:l,onSubmit:c,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m,...h},g)=>{let{useTransitions:b}=ye(mt),x=$_(),v=__(l,{relative:d}),w=i.toLowerCase()==="get"?"get":"post",y=typeof l=="string"&&Ux.test(l);return Me("form",{ref:g,method:w,action:v,onSubmit:o?c:k=>{if(c&&c(k),k.defaultPrevented)return;k.preventDefault();let S=k.nativeEvent.submitter,M=S?.getAttribute("formmethod")||i,P=()=>x(S||k.currentTarget,{fetcherKey:t,method:M,navigate:n,replace:s,state:a,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m});b&&n!==!1?Pl(()=>P()):P()},...h,"data-discover":!y&&e==="render"?"true":void 0})});M_.displayName="Form";function I_(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Kx(e){let t=ye(Dr);return ze(t,I_(e)),t}function A_(e,{target:t,replace:n,mask:o,state:s,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:c,useTransitions:d}={}){let f=et(),p=ht(),m=Mo(e,{relative:i});return q(h=>{if(o_(h,t)){h.preventDefault();let g=n!==void 0?n:io(p)===io(m),b=()=>f(e,{replace:g,mask:o,state:s,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:c});d?Pl(()=>b()):b()}},[p,f,m,n,o,s,t,e,a,i,l,c,d])}function qc(e){vt(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=ne(Yi(e)),n=ne(!1),o=ht(),s=Q(()=>s_(o.search,n.current?null:t.current),[o.search]),a=et(),i=q((l,c)=>{const d=Yi(typeof l=="function"?l(new URLSearchParams(s)):l);n.current=!0,a("?"+d,c)},[a,s]);return[s,i]}var P_=0,E_=()=>`__${String(++P_)}__`;function $_(){let{router:e}=Kx("useSubmit"),{basename:t}=ye(mt),n=K$(),o=e.fetch,s=e.navigate;return q(async(a,i={})=>{let{action:l,method:c,encType:d,formData:f,body:p}=l_(a,t);if(i.navigate===!1){let m=i.fetcherKey||E_();await o(m,n,i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:p,formMethod:i.method||c,formEncType:i.encType||d,flushSync:i.flushSync})}else await s(i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:p,formMethod:i.method||c,formEncType:i.encType||d,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[o,s,t,n])}function __(e,{relative:t}={}){let{basename:n}=ye(mt),o=ye(St);ze(o,"useFormAction must be used inside a RouteContext");let[s]=o.matches.slice(-1),a={...Mo(e||".",{relative:t})},i=ht();if(e==null){a.search=i.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(f=>f==="")){l.delete("index"),c.filter(p=>p).forEach(p=>l.append("index",p));let f=l.toString();a.search=f?`?${f}`:""}}return(!e||e===".")&&s.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Dt([n,a.pathname])),io(a)}function D_(e,{relative:t}={}){let n=ye(zx);ze(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Kx("useViewTransitionState"),s=Mo(e,{relative:t});if(!n.isTransitioning)return!1;let a=sn(n.currentLocation.pathname,o)||n.currentLocation.pathname,i=sn(n.nextLocation.pathname,o)||n.nextLocation.pathname;return Is(s.pathname,i)!=null||Is(s.pathname,a)!=null}const L_=3e4;function T_(e){const t=ne(e);t.current=e,Y(()=>{let n=null;const o=()=>{if(document.visibilityState==="hidden"){n=Date.now();return}if(document.visibilityState==="visible"&&n!==null){const i=Date.now()-n;n=null,i>=L_&&t.current()}},s=()=>{t.current()},a=i=>{i.persisted&&t.current()};return document.addEventListener("visibilitychange",o),window.addEventListener("online",s),window.addEventListener("pageshow",a),()=>{document.removeEventListener("visibilitychange",o),window.removeEventListener("online",s),window.removeEventListener("pageshow",a)}},[])}let Zi="disconnected";const Xi=new Set;function R_(){for(const e of Xi)e()}function O_(e){Zi!==e&&(Zi=e,R_())}function z_(e){return Xi.add(e),()=>{Xi.delete(e)}}function Eu(){return Zi}function B_(){return Ws(z_,Eu,Eu)}let Wr=null;function Ji(){if(!Wr){const e=window.location.origin,t=localStorage.getItem("camstack_admin_token")??void 0;Wr=Vf({serverUrl:e,token:t,onConnectionChange:n=>O_(n)})}return Wr}function Yr(){Wr?.close(),Wr=null}function F_(e){const t=pn();return t===null?r("div",{className:"rounded-md border border-warning/40 bg-warning/10 p-3 text-xs text-warning",children:"zone-editor: no DeviceContext — declare this field inside a top-tab section rendered from a device-detail page."}):r(it,{widgetId:"pipeline-orchestrator/zone-editor",host:"device-tab",deviceId:t})}function j_({deviceId:e}){return u("div",{className:mm,children:[u("div",{className:`grid ${hm}`,style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 340px), 1fr))"},children:[r(it,{widgetId:"pipeline-analytics/live-occupancy-panel",host:"device-tab",deviceId:e}),r(it,{widgetId:"pipeline-analytics/audio-metrics-panel",host:"device-tab",deviceId:e})]}),r(it,{widgetId:"pipeline-analytics/audio-history-chart",host:"device-tab",deviceId:e}),r(it,{widgetId:"pipeline-analytics/occupancy-history-chart",host:"device-tab",deviceId:e}),r(it,{widgetId:"pipeline-analytics/motion-history-chart",host:"device-tab",deviceId:e}),r(it,{widgetId:"pipeline-analytics/detection-history-chart",host:"device-tab",deviceId:e})]})}function H_(e){const t=pn();return t===null?r("div",{className:"rounded-md border border-warning/40 bg-warning/10 p-3 text-xs text-warning",children:"live-stats: no DeviceContext — declare this field inside a top-tab section rendered from a device-detail page."}):r(j_,{deviceId:t})}/**
|
|
546
|
+
* @license lucide-react v0.511.0 - ISC
|
|
547
|
+
*
|
|
548
|
+
* This source code is licensed under the ISC license.
|
|
549
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
550
|
+
*/const V_=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),q_=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase()),$u=e=>{const t=q_(e);return t.charAt(0).toUpperCase()+t.slice(1)},Gx=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim(),Q_=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/**
|
|
551
|
+
* @license lucide-react v0.511.0 - ISC
|
|
552
|
+
*
|
|
553
|
+
* This source code is licensed under the ISC license.
|
|
554
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
555
|
+
*/var U_={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
556
|
+
* @license lucide-react v0.511.0 - ISC
|
|
557
|
+
*
|
|
558
|
+
* This source code is licensed under the ISC license.
|
|
559
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
560
|
+
*/const K_=Ve(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:s="",children:a,iconNode:i,...l},c)=>Me("svg",{ref:c,...U_,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:Gx("lucide",s),...!a&&!Q_(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,f])=>Me(d,f)),...Array.isArray(a)?a:[a]]));/**
|
|
561
|
+
* @license lucide-react v0.511.0 - ISC
|
|
562
|
+
*
|
|
563
|
+
* This source code is licensed under the ISC license.
|
|
564
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
565
|
+
*/const oe=(e,t)=>{const n=Ve(({className:o,...s},a)=>Me(K_,{ref:a,iconNode:t,className:Gx(`lucide-${V_($u(e))}`,`lucide-${e}`,o),...s}));return n.displayName=$u(e),n};/**
|
|
566
|
+
* @license lucide-react v0.511.0 - ISC
|
|
567
|
+
*
|
|
568
|
+
* This source code is licensed under the ISC license.
|
|
569
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
570
|
+
*/const G_=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Io=oe("activity",G_);/**
|
|
571
|
+
* @license lucide-react v0.511.0 - ISC
|
|
572
|
+
*
|
|
573
|
+
* This source code is licensed under the ISC license.
|
|
574
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
575
|
+
*/const W_=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],Qc=oe("archive",W_);/**
|
|
576
|
+
* @license lucide-react v0.511.0 - ISC
|
|
577
|
+
*
|
|
578
|
+
* This source code is licensed under the ISC license.
|
|
579
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
580
|
+
*/const Y_=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Wx=oe("arrow-left",Y_);/**
|
|
581
|
+
* @license lucide-react v0.511.0 - ISC
|
|
582
|
+
*
|
|
583
|
+
* This source code is licensed under the ISC license.
|
|
584
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
585
|
+
*/const Z_=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Yx=oe("arrow-right",Z_);/**
|
|
586
|
+
* @license lucide-react v0.511.0 - ISC
|
|
587
|
+
*
|
|
588
|
+
* This source code is licensed under the ISC license.
|
|
589
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
590
|
+
*/const X_=[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}],["line",{x1:"10",x2:"10",y1:"11",y2:"13",key:"haxvl5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"13",key:"c6fn6x"}]],J_=oe("battery-full",X_);/**
|
|
591
|
+
* @license lucide-react v0.511.0 - ISC
|
|
592
|
+
*
|
|
593
|
+
* This source code is licensed under the ISC license.
|
|
594
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
595
|
+
*/const eD=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Ao=oe("bell",eD);/**
|
|
596
|
+
* @license lucide-react v0.511.0 - ISC
|
|
597
|
+
*
|
|
598
|
+
* This source code is licensed under the ISC license.
|
|
599
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
600
|
+
*/const tD=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],nD=oe("bot",tD);/**
|
|
601
|
+
* @license lucide-react v0.511.0 - ISC
|
|
602
|
+
*
|
|
603
|
+
* This source code is licensed under the ISC license.
|
|
604
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
605
|
+
*/const rD=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],ha=oe("box",rD);/**
|
|
606
|
+
* @license lucide-react v0.511.0 - ISC
|
|
607
|
+
*
|
|
608
|
+
* This source code is licensed under the ISC license.
|
|
609
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
610
|
+
*/const oD=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],ga=oe("boxes",oD);/**
|
|
611
|
+
* @license lucide-react v0.511.0 - ISC
|
|
612
|
+
*
|
|
613
|
+
* This source code is licensed under the ISC license.
|
|
614
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
615
|
+
*/const sD=[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],aD=oe("calendar-clock",sD);/**
|
|
616
|
+
* @license lucide-react v0.511.0 - ISC
|
|
617
|
+
*
|
|
618
|
+
* This source code is licensed under the ISC license.
|
|
619
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
620
|
+
*/const iD=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Zx=oe("calendar",iD);/**
|
|
621
|
+
* @license lucide-react v0.511.0 - ISC
|
|
622
|
+
*
|
|
623
|
+
* This source code is licensed under the ISC license.
|
|
624
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
625
|
+
*/const lD=[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],gr=oe("camera",lD);/**
|
|
626
|
+
* @license lucide-react v0.511.0 - ISC
|
|
627
|
+
*
|
|
628
|
+
* This source code is licensed under the ISC license.
|
|
629
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
630
|
+
*/const cD=[["path",{d:"M16.75 12h3.632a1 1 0 0 1 .894 1.447l-2.034 4.069a1 1 0 0 1-1.708.134l-2.124-2.97",key:"ir91b5"}],["path",{d:"M17.106 9.053a1 1 0 0 1 .447 1.341l-3.106 6.211a1 1 0 0 1-1.342.447L3.61 12.3a2.92 2.92 0 0 1-1.3-3.91L3.69 5.6a2.92 2.92 0 0 1 3.92-1.3z",key:"jlp8i1"}],["path",{d:"M2 19h3.76a2 2 0 0 0 1.8-1.1L9 15",key:"19bib8"}],["path",{d:"M2 21v-4",key:"l40lih"}],["path",{d:"M7 9h.01",key:"19b3jx"}]],Xx=oe("cctv",cD);/**
|
|
631
|
+
* @license lucide-react v0.511.0 - ISC
|
|
632
|
+
*
|
|
633
|
+
* This source code is licensed under the ISC license.
|
|
634
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
635
|
+
*/const dD=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],uD=oe("check-check",dD);/**
|
|
636
|
+
* @license lucide-react v0.511.0 - ISC
|
|
637
|
+
*
|
|
638
|
+
* This source code is licensed under the ISC license.
|
|
639
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
640
|
+
*/const pD=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ct=oe("check",pD);/**
|
|
641
|
+
* @license lucide-react v0.511.0 - ISC
|
|
642
|
+
*
|
|
643
|
+
* This source code is licensed under the ISC license.
|
|
644
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
645
|
+
*/const fD=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Rt=oe("chevron-down",fD);/**
|
|
646
|
+
* @license lucide-react v0.511.0 - ISC
|
|
647
|
+
*
|
|
648
|
+
* This source code is licensed under the ISC license.
|
|
649
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
650
|
+
*/const mD=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Uc=oe("chevron-left",mD);/**
|
|
651
|
+
* @license lucide-react v0.511.0 - ISC
|
|
652
|
+
*
|
|
653
|
+
* This source code is licensed under the ISC license.
|
|
654
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
655
|
+
*/const hD=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Mt=oe("chevron-right",hD);/**
|
|
656
|
+
* @license lucide-react v0.511.0 - ISC
|
|
657
|
+
*
|
|
658
|
+
* This source code is licensed under the ISC license.
|
|
659
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
660
|
+
*/const gD=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],bD=oe("chevron-up",gD);/**
|
|
661
|
+
* @license lucide-react v0.511.0 - ISC
|
|
662
|
+
*
|
|
663
|
+
* This source code is licensed under the ISC license.
|
|
664
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
665
|
+
*/const xD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],ba=oe("circle-alert",xD);/**
|
|
666
|
+
* @license lucide-react v0.511.0 - ISC
|
|
667
|
+
*
|
|
668
|
+
* This source code is licensed under the ISC license.
|
|
669
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
670
|
+
*/const yD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Jx=oe("circle-check",yD);/**
|
|
671
|
+
* @license lucide-react v0.511.0 - ISC
|
|
672
|
+
*
|
|
673
|
+
* This source code is licensed under the ISC license.
|
|
674
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
675
|
+
*/const vD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],ey=oe("circle-dot",vD);/**
|
|
676
|
+
* @license lucide-react v0.511.0 - ISC
|
|
677
|
+
*
|
|
678
|
+
* This source code is licensed under the ISC license.
|
|
679
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
680
|
+
*/const wD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ND=oe("circle-help",wD);/**
|
|
681
|
+
* @license lucide-react v0.511.0 - ISC
|
|
682
|
+
*
|
|
683
|
+
* This source code is licensed under the ISC license.
|
|
684
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
685
|
+
*/const kD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],SD=oe("clock",kD);/**
|
|
686
|
+
* @license lucide-react v0.511.0 - ISC
|
|
687
|
+
*
|
|
688
|
+
* This source code is licensed under the ISC license.
|
|
689
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
690
|
+
*/const CD=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],MD=oe("copy",CD);/**
|
|
691
|
+
* @license lucide-react v0.511.0 - ISC
|
|
692
|
+
*
|
|
693
|
+
* This source code is licensed under the ISC license.
|
|
694
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
695
|
+
*/const ID=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],ut=oe("cpu",ID);/**
|
|
696
|
+
* @license lucide-react v0.511.0 - ISC
|
|
697
|
+
*
|
|
698
|
+
* This source code is licensed under the ISC license.
|
|
699
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
700
|
+
*/const AD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],PD=oe("crosshair",AD);/**
|
|
701
|
+
* @license lucide-react v0.511.0 - ISC
|
|
702
|
+
*
|
|
703
|
+
* This source code is licensed under the ISC license.
|
|
704
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
705
|
+
*/const ED=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],ty=oe("database",ED);/**
|
|
706
|
+
* @license lucide-react v0.511.0 - ISC
|
|
707
|
+
*
|
|
708
|
+
* This source code is licensed under the ISC license.
|
|
709
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
710
|
+
*/const $D=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],wn=oe("download",$D);/**
|
|
711
|
+
* @license lucide-react v0.511.0 - ISC
|
|
712
|
+
*
|
|
713
|
+
* This source code is licensed under the ISC license.
|
|
714
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
715
|
+
*/const _D=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],DD=oe("ellipsis-vertical",_D);/**
|
|
716
|
+
* @license lucide-react v0.511.0 - ISC
|
|
717
|
+
*
|
|
718
|
+
* This source code is licensed under the ISC license.
|
|
719
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
720
|
+
*/const LD=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Kc=oe("external-link",LD);/**
|
|
721
|
+
* @license lucide-react v0.511.0 - ISC
|
|
722
|
+
*
|
|
723
|
+
* This source code is licensed under the ISC license.
|
|
724
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
725
|
+
*/const TD=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],ny=oe("eye-off",TD);/**
|
|
726
|
+
* @license lucide-react v0.511.0 - ISC
|
|
727
|
+
*
|
|
728
|
+
* This source code is licensed under the ISC license.
|
|
729
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
730
|
+
*/const RD=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],xa=oe("eye",RD);/**
|
|
731
|
+
* @license lucide-react v0.511.0 - ISC
|
|
732
|
+
*
|
|
733
|
+
* This source code is licensed under the ISC license.
|
|
734
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
735
|
+
*/const OD=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],Zr=oe("film",OD);/**
|
|
736
|
+
* @license lucide-react v0.511.0 - ISC
|
|
737
|
+
*
|
|
738
|
+
* This source code is licensed under the ISC license.
|
|
739
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
740
|
+
*/const zD=[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]],BD=oe("flame",zD);/**
|
|
741
|
+
* @license lucide-react v0.511.0 - ISC
|
|
742
|
+
*
|
|
743
|
+
* This source code is licensed under the ISC license.
|
|
744
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
745
|
+
*/const FD=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],ry=oe("gauge",FD);/**
|
|
746
|
+
* @license lucide-react v0.511.0 - ISC
|
|
747
|
+
*
|
|
748
|
+
* This source code is licensed under the ISC license.
|
|
749
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
750
|
+
*/const jD=[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]],el=oe("ghost",jD);/**
|
|
751
|
+
* @license lucide-react v0.511.0 - ISC
|
|
752
|
+
*
|
|
753
|
+
* This source code is licensed under the ISC license.
|
|
754
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
755
|
+
*/const HD=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],oy=oe("git-branch",HD);/**
|
|
756
|
+
* @license lucide-react v0.511.0 - ISC
|
|
757
|
+
*
|
|
758
|
+
* This source code is licensed under the ISC license.
|
|
759
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
760
|
+
*/const VD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],br=oe("globe",VD);/**
|
|
761
|
+
* @license lucide-react v0.511.0 - ISC
|
|
762
|
+
*
|
|
763
|
+
* This source code is licensed under the ISC license.
|
|
764
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
765
|
+
*/const qD=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],lo=oe("hard-drive",qD);/**
|
|
766
|
+
* @license lucide-react v0.511.0 - ISC
|
|
767
|
+
*
|
|
768
|
+
* This source code is licensed under the ISC license.
|
|
769
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
770
|
+
*/const QD=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]],UD=oe("house",QD);/**
|
|
771
|
+
* @license lucide-react v0.511.0 - ISC
|
|
772
|
+
*
|
|
773
|
+
* This source code is licensed under the ISC license.
|
|
774
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
775
|
+
*/const KD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ps=oe("info",KD);/**
|
|
776
|
+
* @license lucide-react v0.511.0 - ISC
|
|
777
|
+
*
|
|
778
|
+
* This source code is licensed under the ISC license.
|
|
779
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
780
|
+
*/const GD=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],sy=oe("key-round",GD);/**
|
|
781
|
+
* @license lucide-react v0.511.0 - ISC
|
|
782
|
+
*
|
|
783
|
+
* This source code is licensed under the ISC license.
|
|
784
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
785
|
+
*/const WD=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],YD=oe("key",WD);/**
|
|
786
|
+
* @license lucide-react v0.511.0 - ISC
|
|
787
|
+
*
|
|
788
|
+
* This source code is licensed under the ISC license.
|
|
789
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
790
|
+
*/const ZD=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],XD=oe("languages",ZD);/**
|
|
791
|
+
* @license lucide-react v0.511.0 - ISC
|
|
792
|
+
*
|
|
793
|
+
* This source code is licensed under the ISC license.
|
|
794
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
795
|
+
*/const JD=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],eL=oe("layers",JD);/**
|
|
796
|
+
* @license lucide-react v0.511.0 - ISC
|
|
797
|
+
*
|
|
798
|
+
* This source code is licensed under the ISC license.
|
|
799
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
800
|
+
*/const tL=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],ay=oe("layout-dashboard",tL);/**
|
|
801
|
+
* @license lucide-react v0.511.0 - ISC
|
|
802
|
+
*
|
|
803
|
+
* This source code is licensed under the ISC license.
|
|
804
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
805
|
+
*/const nL=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],rL=oe("lightbulb",nL);/**
|
|
806
|
+
* @license lucide-react v0.511.0 - ISC
|
|
807
|
+
*
|
|
808
|
+
* This source code is licensed under the ISC license.
|
|
809
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
810
|
+
*/const oL=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Pe=oe("loader-circle",oL);/**
|
|
811
|
+
* @license lucide-react v0.511.0 - ISC
|
|
812
|
+
*
|
|
813
|
+
* This source code is licensed under the ISC license.
|
|
814
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
815
|
+
*/const sL=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],iy=oe("lock",sL);/**
|
|
816
|
+
* @license lucide-react v0.511.0 - ISC
|
|
817
|
+
*
|
|
818
|
+
* This source code is licensed under the ISC license.
|
|
819
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
820
|
+
*/const aL=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],iL=oe("log-in",aL);/**
|
|
821
|
+
* @license lucide-react v0.511.0 - ISC
|
|
822
|
+
*
|
|
823
|
+
* This source code is licensed under the ISC license.
|
|
824
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
825
|
+
*/const lL=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],ly=oe("log-out",lL);/**
|
|
826
|
+
* @license lucide-react v0.511.0 - ISC
|
|
827
|
+
*
|
|
828
|
+
* This source code is licensed under the ISC license.
|
|
829
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
830
|
+
*/const cL=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],dL=oe("map-pin",cL);/**
|
|
831
|
+
* @license lucide-react v0.511.0 - ISC
|
|
832
|
+
*
|
|
833
|
+
* This source code is licensed under the ISC license.
|
|
834
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
835
|
+
*/const uL=[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]],Gc=oe("memory-stick",uL);/**
|
|
836
|
+
* @license lucide-react v0.511.0 - ISC
|
|
837
|
+
*
|
|
838
|
+
* This source code is licensed under the ISC license.
|
|
839
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
840
|
+
*/const pL=[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]],fL=oe("menu",pL);/**
|
|
841
|
+
* @license lucide-react v0.511.0 - ISC
|
|
842
|
+
*
|
|
843
|
+
* This source code is licensed under the ISC license.
|
|
844
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
845
|
+
*/const mL=[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]],tl=oe("mic",mL);/**
|
|
846
|
+
* @license lucide-react v0.511.0 - ISC
|
|
847
|
+
*
|
|
848
|
+
* This source code is licensed under the ISC license.
|
|
849
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
850
|
+
*/const hL=[["path",{d:"M5 12h14",key:"1ays0h"}]],gL=oe("minus",hL);/**
|
|
851
|
+
* @license lucide-react v0.511.0 - ISC
|
|
852
|
+
*
|
|
853
|
+
* This source code is licensed under the ISC license.
|
|
854
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
855
|
+
*/const bL=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],xL=oe("monitor",bL);/**
|
|
856
|
+
* @license lucide-react v0.511.0 - ISC
|
|
857
|
+
*
|
|
858
|
+
* This source code is licensed under the ISC license.
|
|
859
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
860
|
+
*/const yL=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],cy=oe("moon",yL);/**
|
|
861
|
+
* @license lucide-react v0.511.0 - ISC
|
|
862
|
+
*
|
|
863
|
+
* This source code is licensed under the ISC license.
|
|
864
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
865
|
+
*/const vL=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],wL=oe("move",vL);/**
|
|
866
|
+
* @license lucide-react v0.511.0 - ISC
|
|
867
|
+
*
|
|
868
|
+
* This source code is licensed under the ISC license.
|
|
869
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
870
|
+
*/const NL=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],an=oe("network",NL);/**
|
|
871
|
+
* @license lucide-react v0.511.0 - ISC
|
|
872
|
+
*
|
|
873
|
+
* This source code is licensed under the ISC license.
|
|
874
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
875
|
+
*/const kL=[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]],SL=oe("octagon-alert",kL);/**
|
|
876
|
+
* @license lucide-react v0.511.0 - ISC
|
|
877
|
+
*
|
|
878
|
+
* This source code is licensed under the ISC license.
|
|
879
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
880
|
+
*/const CL=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],dy=oe("package",CL);/**
|
|
881
|
+
* @license lucide-react v0.511.0 - ISC
|
|
882
|
+
*
|
|
883
|
+
* This source code is licensed under the ISC license.
|
|
884
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
885
|
+
*/const ML=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Po=oe("pencil",ML);/**
|
|
886
|
+
* @license lucide-react v0.511.0 - ISC
|
|
887
|
+
*
|
|
888
|
+
* This source code is licensed under the ISC license.
|
|
889
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
890
|
+
*/const IL=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],uy=oe("pin",IL);/**
|
|
891
|
+
* @license lucide-react v0.511.0 - ISC
|
|
892
|
+
*
|
|
893
|
+
* This source code is licensed under the ISC license.
|
|
894
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
895
|
+
*/const AL=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],Wc=oe("play",AL);/**
|
|
896
|
+
* @license lucide-react v0.511.0 - ISC
|
|
897
|
+
*
|
|
898
|
+
* This source code is licensed under the ISC license.
|
|
899
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
900
|
+
*/const PL=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],Yc=oe("plug",PL);/**
|
|
901
|
+
* @license lucide-react v0.511.0 - ISC
|
|
902
|
+
*
|
|
903
|
+
* This source code is licensed under the ISC license.
|
|
904
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
905
|
+
*/const EL=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ot=oe("plus",EL);/**
|
|
906
|
+
* @license lucide-react v0.511.0 - ISC
|
|
907
|
+
*
|
|
908
|
+
* This source code is licensed under the ISC license.
|
|
909
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
910
|
+
*/const $L=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],py=oe("power",$L);/**
|
|
911
|
+
* @license lucide-react v0.511.0 - ISC
|
|
912
|
+
*
|
|
913
|
+
* This source code is licensed under the ISC license.
|
|
914
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
915
|
+
*/const _L=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],Es=oe("puzzle",_L);/**
|
|
916
|
+
* @license lucide-react v0.511.0 - ISC
|
|
917
|
+
*
|
|
918
|
+
* This source code is licensed under the ISC license.
|
|
919
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
920
|
+
*/const DL=[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]],LL=oe("radar",DL);/**
|
|
921
|
+
* @license lucide-react v0.511.0 - ISC
|
|
922
|
+
*
|
|
923
|
+
* This source code is licensed under the ISC license.
|
|
924
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
925
|
+
*/const TL=[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]],Zc=oe("radio",TL);/**
|
|
926
|
+
* @license lucide-react v0.511.0 - ISC
|
|
927
|
+
*
|
|
928
|
+
* This source code is licensed under the ISC license.
|
|
929
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
930
|
+
*/const RL=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],pt=oe("refresh-cw",RL);/**
|
|
931
|
+
* @license lucide-react v0.511.0 - ISC
|
|
932
|
+
*
|
|
933
|
+
* This source code is licensed under the ISC license.
|
|
934
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
935
|
+
*/const OL=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],fy=oe("rotate-ccw",OL);/**
|
|
936
|
+
* @license lucide-react v0.511.0 - ISC
|
|
937
|
+
*
|
|
938
|
+
* This source code is licensed under the ISC license.
|
|
939
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
940
|
+
*/const zL=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],bt=oe("rotate-cw",zL);/**
|
|
941
|
+
* @license lucide-react v0.511.0 - ISC
|
|
942
|
+
*
|
|
943
|
+
* This source code is licensed under the ISC license.
|
|
944
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
945
|
+
*/const BL=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],FL=oe("save",BL);/**
|
|
946
|
+
* @license lucide-react v0.511.0 - ISC
|
|
947
|
+
*
|
|
948
|
+
* This source code is licensed under the ISC license.
|
|
949
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
950
|
+
*/const jL=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],Xe=oe("scroll-text",jL);/**
|
|
951
|
+
* @license lucide-react v0.511.0 - ISC
|
|
952
|
+
*
|
|
953
|
+
* This source code is licensed under the ISC license.
|
|
954
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
955
|
+
*/const HL=[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],VL=oe("search-x",HL);/**
|
|
956
|
+
* @license lucide-react v0.511.0 - ISC
|
|
957
|
+
*
|
|
958
|
+
* This source code is licensed under the ISC license.
|
|
959
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
960
|
+
*/const qL=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],my=oe("search",qL);/**
|
|
961
|
+
* @license lucide-react v0.511.0 - ISC
|
|
962
|
+
*
|
|
963
|
+
* This source code is licensed under the ISC license.
|
|
964
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
965
|
+
*/const QL=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],ln=oe("server",QL);/**
|
|
966
|
+
* @license lucide-react v0.511.0 - ISC
|
|
967
|
+
*
|
|
968
|
+
* This source code is licensed under the ISC license.
|
|
969
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
970
|
+
*/const UL=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],wt=oe("settings",UL);/**
|
|
971
|
+
* @license lucide-react v0.511.0 - ISC
|
|
972
|
+
*
|
|
973
|
+
* This source code is licensed under the ISC license.
|
|
974
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
975
|
+
*/const KL=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],xr=oe("shield-check",KL);/**
|
|
976
|
+
* @license lucide-react v0.511.0 - ISC
|
|
977
|
+
*
|
|
978
|
+
* This source code is licensed under the ISC license.
|
|
979
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
980
|
+
*/const GL=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]],WL=oe("shield-x",GL);/**
|
|
981
|
+
* @license lucide-react v0.511.0 - ISC
|
|
982
|
+
*
|
|
983
|
+
* This source code is licensed under the ISC license.
|
|
984
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
985
|
+
*/const YL=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],ZL=oe("shield",YL);/**
|
|
986
|
+
* @license lucide-react v0.511.0 - ISC
|
|
987
|
+
*
|
|
988
|
+
* This source code is licensed under the ISC license.
|
|
989
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
990
|
+
*/const XL=[["path",{d:"m12.5 17-.5-1-.5 1h1z",key:"3me087"}],["path",{d:"M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z",key:"1o5pge"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]],Uo=oe("skull",XL);/**
|
|
991
|
+
* @license lucide-react v0.511.0 - ISC
|
|
992
|
+
*
|
|
993
|
+
* This source code is licensed under the ISC license.
|
|
994
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
995
|
+
*/const JL=[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]],eT=oe("sparkles",JL);/**
|
|
996
|
+
* @license lucide-react v0.511.0 - ISC
|
|
997
|
+
*
|
|
998
|
+
* This source code is licensed under the ISC license.
|
|
999
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1000
|
+
*/const tT=[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],hy=oe("square-check-big",tT);/**
|
|
1001
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1002
|
+
*
|
|
1003
|
+
* This source code is licensed under the ISC license.
|
|
1004
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1005
|
+
*/const nT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ya=oe("square",nT);/**
|
|
1006
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1007
|
+
*
|
|
1008
|
+
* This source code is licensed under the ISC license.
|
|
1009
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1010
|
+
*/const rT=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],ri=oe("star",rT);/**
|
|
1011
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1012
|
+
*
|
|
1013
|
+
* This source code is licensed under the ISC license.
|
|
1014
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1015
|
+
*/const oT=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],sT=oe("sun",oT);/**
|
|
1016
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1017
|
+
*
|
|
1018
|
+
* This source code is licensed under the ISC license.
|
|
1019
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1020
|
+
*/const aT=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],iT=oe("table-2",aT);/**
|
|
1021
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1022
|
+
*
|
|
1023
|
+
* This source code is licensed under the ISC license.
|
|
1024
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1025
|
+
*/const lT=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],gy=oe("terminal",lT);/**
|
|
1026
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1027
|
+
*
|
|
1028
|
+
* This source code is licensed under the ISC license.
|
|
1029
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1030
|
+
*/const cT=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],We=oe("trash-2",cT);/**
|
|
1031
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1032
|
+
*
|
|
1033
|
+
* This source code is licensed under the ISC license.
|
|
1034
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1035
|
+
*/const dT=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],xt=oe("triangle-alert",dT);/**
|
|
1036
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1037
|
+
*
|
|
1038
|
+
* This source code is licensed under the ISC license.
|
|
1039
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1040
|
+
*/const uT=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Xc=oe("upload",uT);/**
|
|
1041
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1042
|
+
*
|
|
1043
|
+
* This source code is licensed under the ISC license.
|
|
1044
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1045
|
+
*/const pT=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],by=oe("users",pT);/**
|
|
1046
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1047
|
+
*
|
|
1048
|
+
* This source code is licensed under the ISC license.
|
|
1049
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1050
|
+
*/const fT=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],xy=oe("video",fT);/**
|
|
1051
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1052
|
+
*
|
|
1053
|
+
* This source code is licensed under the ISC license.
|
|
1054
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1055
|
+
*/const mT=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],yy=oe("wifi-off",mT);/**
|
|
1056
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1057
|
+
*
|
|
1058
|
+
* This source code is licensed under the ISC license.
|
|
1059
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1060
|
+
*/const hT=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],jn=oe("wifi",hT);/**
|
|
1061
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1062
|
+
*
|
|
1063
|
+
* This source code is licensed under the ISC license.
|
|
1064
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1065
|
+
*/const gT=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],qe=oe("x",gT);/**
|
|
1066
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1067
|
+
*
|
|
1068
|
+
* This source code is licensed under the ISC license.
|
|
1069
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1070
|
+
*/const bT=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]],xT=oe("wrench",bT);/**
|
|
1071
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1072
|
+
*
|
|
1073
|
+
* This source code is licensed under the ISC license.
|
|
1074
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1075
|
+
*/const yT=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Jc=oe("zap",yT);function vT(e){const t=Le();return Kn({queryKey:["field-resolver",e?.capName??"<none>",e?.methodName??"<none>",e?.input??{}],enabled:!!e,queryFn:async()=>{if(!e)throw new Error("useFieldResolver: resolver is null (enabled guard should have prevented this)");const n=i=>i!==null&&(typeof i=="object"||typeof i=="function"),o=Reflect.get(t.trpcClient,e.capName);if(!n(o))throw new Error(`useFieldResolver: no cap namespace '${e.capName}' on the tRPC client`);const s=Reflect.get(o,e.methodName);if(!n(s))throw new Error(`useFieldResolver: no method '${e.methodName}' on cap '${e.capName}'`);const a=Reflect.get(s,"query");if(typeof a!="function")throw new Error(`useFieldResolver: '${e.capName}.${e.methodName}' has no .query() (resolvers must be query methods, not mutations)`);return await a(e.input??{})}})}function wT(e){return typeof e=="string"&&e.length>0&&e!=="undefined"&&e!=="null"}function NT(e={}){const t=ke(),n=$r(void 0,{staleTime:1e4,enabled:e.enabled??!0}),o=Q(()=>(n.data??[]).filter(i=>wT(i.nodeId)),[n.data]),s=q(()=>{t.invalidateQueries({queryKey:["pipelineOrchestrator","listAgentSettings"]})},[t]);return{agents:o,isLoading:n.isLoading,isError:n.isError,error:n.error,refetch:()=>{n.refetch()},invalidate:s}}function kT({field:e,disabled:t}){const n=ke(),o=e.deviceId,s=vT(e.catalogResolver),a=bc({agentNodeId:e.nodeId}),i=yc({deviceId:o}),c=Cb({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),d=s.data,f=a.data??null,p=i.data??null,m=Q(()=>d?CT(d,f,p):[],[d,f,p]),h=Q(()=>{if(!f)return{};const g={};for(const[b,x]of Object.entries(f.addonDefaults))g[b]=x.enabled;return g},[f]);return s.error?u("div",{className:"text-xs text-red-400",children:["Failed to load pipeline catalog for ",r("code",{children:e.nodeId}),": ",String(s.error.message??s.error)]}):s.isLoading||!d||a.isLoading?u("div",{className:"text-xs text-foreground-subtle animate-pulse",children:["Loading pipeline for ",e.nodeId,"…"]}):u("div",{className:"col-span-full space-y-4",children:[u("div",{className:"flex items-center gap-2 text-[11px] text-foreground-subtle",children:["Agent: ",r("span",{className:"text-foreground",children:e.nodeId}),u("span",{className:"ml-2",children:["Engine: ",r("span",{className:"text-foreground font-mono",children:`${d.selectedEngine.runtime}/${d.selectedEngine.backend}`})]}),u("span",{className:"ml-auto text-[10px]",children:["Model + settings edited on Pipeline → ",e.nodeId,"."]})]}),r(rc,{schema:d,steps:m,onChange:()=>{},templates:[],selectedTemplateId:null,onSelectTemplate:()=>{},onSaveTemplate:()=>{},onUpdateTemplate:()=>{},onDeleteTemplate:()=>{},readOnly:t===!0,hideTemplates:!0,toggleMode:"threeState",hideModelAndSettings:!0,overrides:p?.stepToggles??{},onOverrideChange:(g,b)=>c.mutate({deviceId:o,addonId:g,enabled:b}),inheritedEnabledByAddon:h}),r(ST,{deviceId:o,currentAgentNodeId:e.nodeId,catalog:d,pipelineByAgent:p?.pipelineByAgent??{},disabled:t===!0})]})}function ST({deviceId:e,currentAgentNodeId:t,catalog:n,pipelineByAgent:o,disabled:s}){const a=ke(),[i,l]=$(!1),[c,d]=$(t),{agents:f}=NT({enabled:i}),p=Ab({deviceId:e,agentNodeId:c},{enabled:i}),h=Ib({onSuccess:()=>{a.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),a.invalidateQueries({queryKey:[["pipelineOrchestrator","resolvePipeline"]]})}}),g=o[c]??null,b=f,x=Q(()=>g?MT(g.steps,n):[],[g,n]),v=w=>{const y=g?.audio??null;h.mutate({deviceId:e,agentNodeId:c,pipeline:{steps:IT(w),audio:y?{modelId:y.modelId,enabled:y.enabled}:null}})};return u("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("button",{type:"button",onClick:()=>l(w=>!w),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover",children:[i?r(Rt,{className:"h-3 w-3"}):r(Mt,{className:"h-3 w-3"}),r("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:"Advanced — custom pipeline per agent"}),r("span",{className:"ml-auto text-[10px] text-foreground-subtle",children:Object.keys(o).length>0?`${Object.keys(o).length} override(s) active`:"None configured"})]}),i&&u("div",{className:"border-t border-border px-4 py-3 space-y-3",children:[u("div",{className:"flex items-center gap-2 text-xs",children:[r("span",{className:"text-foreground-subtle",children:"Agent:"}),u("select",{value:c,disabled:s,onChange:w=>d(w.target.value),className:"rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary",children:[typeof t=="string"&&t.length>0&&t!=="undefined"&&u("option",{value:t,children:[t," (current)"]}),b.filter(w=>w.nodeId!==t).map(w=>r("option",{value:w.nodeId,children:w.nodeId},w.nodeId))]}),o[c]&&u("button",{type:"button",onClick:()=>{window.confirm(`Remove custom pipeline override for ${c}? The camera will revert to the agent default + step toggles.`)&&h.mutate({deviceId:e,agentNodeId:c,pipeline:null})},disabled:s||h.isPending,className:"ml-auto inline-flex items-center gap-1 px-2 py-1 text-[11px] text-red-400 hover:bg-red-500/10 rounded disabled:opacity-50",children:[r(We,{className:"h-3 w-3"}),"Remove override"]})]}),g?r(rc,{schema:n,steps:x,onChange:v,templates:[],selectedTemplateId:null,onSelectTemplate:()=>{},onSaveTemplate:()=>{},onUpdateTemplate:()=>{},onDeleteTemplate:()=>{},readOnly:s,hideTemplates:!0}):u("div",{className:"text-xs text-foreground-subtle space-y-2",children:[u("p",{children:["No custom pipeline for ",r("code",{children:c}),". The camera uses the agent's default + step toggles."]}),r("button",{type:"button",onClick:()=>{const w=p.data;w&&h.mutate({deviceId:e,agentNodeId:c,pipeline:{steps:w.steps,audio:w.audio?{modelId:w.audio.modelId,enabled:w.audio.enabled}:null}})},disabled:s||h.isPending||!p.data,className:"inline-flex items-center gap-1 px-3 py-1.5 text-xs font-medium rounded bg-primary/15 text-primary hover:bg-primary/25 disabled:opacity-50",children:"Create wholesale override from current default"})]})]})]})}function CT(e,t,n){const o=d=>{for(const f of e.slots)for(const p of f.addons)if(p.id===d)return p;return null},s=d=>{const f=t?.addonDefaults[d.id],p=f?.enabled??d.enabledByDefault??!0,m=n?.stepToggles?.[d.id],h=m!==void 0?m:p;return{addonId:d.id,addonName:d.name,slot:d.slot,inputClasses:[...d.inputClasses],outputClasses:[...d.outputClasses],enabled:h,modelId:f?.modelId??d.defaultModelId,children:[],...f?.settings&&Object.keys(f.settings).length>0?{settings:f.settings}:{}}},a=new Map;for(const d of e.slots)for(const f of d.addons)a.set(f.id,s(f));const i=[],l=new Set;for(const[d,f]of a){const p=o(d);p&&p.inputClasses.length===0&&(i.push(f),l.add(d))}let c=!0;for(;c;){c=!1;for(const[d,f]of a){if(l.has(d))continue;const p=o(d);if(p)for(const[m,h]of a){if(m===d)continue;const g=o(m);if(g&&l.has(m)&&g.outputClasses.some(b=>p.inputClasses.includes(b))){h.children.push(f),l.add(d),c=!0;break}}}}return i}function MT(e,t){const n=new Map;for(const s of t.slots)for(const a of s.addons)n.set(a.id,a);const o=s=>{const a=n.get(s.addonId);return{addonId:s.addonId,addonName:a?.name??s.addonId,slot:a?.slot??"detector",inputClasses:a?.inputClasses?[...a.inputClasses]:[],outputClasses:a?.outputClasses?[...a.outputClasses]:[],enabled:s.enabled,modelId:s.modelId,children:(s.children??[]).map(o),...s.settings?{settings:{...s.settings}}:{}}};return[...e].map(o)}function IT(e){const t=n=>({addonId:n.addonId,modelId:n.modelId,enabled:n.enabled,children:n.children.map(t),...n.settings?{settings:{...n.settings}}:{}});return e.map(t)}function AT({tabs:e,active:t,onChange:n}){return r("div",{className:"flex rounded-lg border border-border bg-surface p-0.5 gap-0.5",children:e.map(o=>r("button",{type:"button",onClick:()=>n(o.id),className:["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",t===o.id?"bg-primary/12 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"].join(" "),children:o.label},o.id))})}function PT(e){const t=e.formats;if(!t)return"";const n=Object.values(t).filter(a=>a!==void 0&&a.sizeMB>0).map(a=>a.sizeMB);if(n.length===0)return"";const o=Math.min(...n),s=Math.max(...n);return o===s?`${o} MB`:`${o}-${s} MB`}function ET(e){return`${e.inputSize.width}x${e.inputSize.height}`}function $T(e){return e.formats?Object.keys(e.formats).filter(t=>e.formats[t]!==void 0):[]}function _T({entry:e,selected:t,onSelect:n,disabled:o}){const s=PT(e),a=ET(e),i=$T(e);return u("button",{type:"button",onClick:n,disabled:o,className:["w-full text-left rounded-lg border p-3 transition-all",t?"border-primary bg-primary/5 ring-1 ring-primary/30":"border-border bg-background hover:border-foreground-subtle/40 hover:bg-surface-hover/50",o?"opacity-50 cursor-not-allowed":"cursor-pointer"].join(" "),children:[r("div",{className:"flex items-start justify-between gap-2",children:u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-xs font-semibold text-foreground truncate",children:e.name}),t&&r(Ct,{className:"h-3.5 w-3.5 text-primary shrink-0"})]}),r("p",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-2",children:e.description})]})}),u("div",{className:"flex items-center gap-3 mt-2 flex-wrap",children:[u("span",{className:"inline-flex items-center gap-1 text-[10px] text-foreground-subtle",children:[r(ut,{className:"h-3 w-3"}),a]}),s&&r("span",{className:"text-[10px] text-foreground-subtle",children:s}),i.length>0&&r("div",{className:"flex gap-1",children:i.map(l=>r("span",{className:"text-[9px] uppercase rounded bg-surface border border-border px-1 py-0.5 text-foreground-subtle font-mono",children:l},l))}),e.labels.length>0&&u("span",{className:"text-[10px] text-foreground-subtle",children:[e.labels.length," label",e.labels.length!==1?"s":""]})]})]})}function DT({field:e,value:t,onChange:n,disabled:o}){const s=e.catalog??[],a=s.length>0,i=e.allowCustomPath!==!1||e.allowCustom===!0,l=[...a?[{id:"catalog",label:`Models (${s.length})`}]:[],...i?[{id:"custom",label:"Custom Path"}]:[]],[c,d]=$(a?"catalog":"custom"),f=t==null?"":String(t);return u("div",{className:"space-y-3",children:[l.length>1&&r(AT,{tabs:l,active:c,onChange:d}),c==="catalog"&&a&&r("div",{className:"space-y-1.5 max-h-[320px] overflow-y-auto pr-1",children:s.map(p=>r(_T,{entry:p,selected:f===p.id,onSelect:()=>n(p.id),disabled:o||e.disabled},p.id))}),c==="catalog"&&!a&&u("div",{className:"rounded-md border border-info/30 bg-info/5 px-3 py-2 flex items-start gap-2",children:[r(Ps,{className:"h-3.5 w-3.5 text-info shrink-0 mt-0.5"}),r("p",{className:"text-[11px] text-foreground-subtle leading-relaxed",children:"No predefined models available. Use the Custom Path tab to specify a model file path or URL."})]}),c==="custom"&&i&&u("div",{className:"space-y-2",children:[r("input",{type:"text",className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none disabled:opacity-50",placeholder:"Enter path like /data/models/custom.onnx or https://...",value:f,disabled:o||e.disabled,onChange:p=>n(p.target.value)}),e.acceptFormats&&e.acceptFormats.length>0&&u("p",{className:"text-[10px] text-foreground-subtle",children:["Accepted formats: ",e.acceptFormats.join(", ")]})]}),(e.compatibilityNote||e.conversionGuideUrl)&&u("div",{className:"flex items-start justify-between gap-3 pt-1",children:[e.compatibilityNote&&u("p",{className:"flex items-start gap-1 text-[10px] text-foreground-subtle",children:[r(Ps,{className:"h-3 w-3 mt-0.5 shrink-0"}),e.compatibilityNote]}),e.conversionGuideUrl&&u("a",{href:e.conversionGuideUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-[11px] text-primary hover:underline shrink-0",children:["How to convert your model",r(Kc,{className:"h-3 w-3"})]})]})]})}function vy(e){const t=Le();return Px(t.trpcClient,e)}function LT({deviceId:e,deviceName:t,hasPTZ:n=!1,className:o}){const s=Le(),a=typeof window<"u"?window.location.origin:"",i=Number.isFinite(e),[l,c]=$(!1),d=i&&n&&l,f=kt(s.trpcClient,i?e:null),p=ne(!1),{data:m,isLoading:h,isFetching:g,refetch:b}=Kn({queryKey:["device",e,"snapshot.getSnapshot"],queryFn:()=>{const I=p.current;return p.current=!1,f?.snapshot?.getSnapshot({force:I})??null},enabled:!!f&&i,staleTime:5e3,retry:!1}),x=()=>{p.current=!0,b()},{streams:v,pipelineMetrics:w,createSession:y,sendAnswer:N,closeSession:k}=_c(s.trpcClient,i?e:null),S=vy(i?e:null),M=Dc(s.trpcClient,i?e:0,{enabled:d}),P=m?`data:${m.contentType};base64,${m.base64}`:null;return r(Ic,{serverUrl:a,createSession:y,sendAnswer:N,closeSession:k,streams:v,pipelineMetrics:w,deviceName:t,phase:S.phase,detections:S,defaultShowDetections:!1,defaultShowMotion:!1,autoPlay:!1,showPlayStop:!0,snapshotSrc:P,snapshotLoading:h||g,onRefreshSnapshot:x,ptzAvailable:i&&n,ptzShown:d,onPtzToggle:()=>c(I=>!I),ptzOverlay:d?r(Ec,{controls:M}):void 0,className:o})}function TT(){const e=pn(),t=sc();if(e===null)return null;const n=typeof t?.name=="string"?t.name:"",s=(t?.features??[]).includes(Rn.PanTiltZoom);return r(LT,{deviceId:e,deviceName:n,hasPTZ:s})}function yt(e,t){const n=Le(),o=ke(),[s,a]=$(n.connectionVersion);Y(()=>n.subscribeConnectionEvents((c,d)=>{c==="connected"&&a(d)}),[n]);const i=t.join("|"),l=JSON.stringify(e);Y(()=>{const c=[],d=()=>{const f=JSON.parse(l),m=f.length===1&&Array.isArray(f[0])?f:[f];o.invalidateQueries({queryKey:m})};d();for(const f of i.split("|"))if(f)try{c.push(n.subscribeEvent(f,d))}catch{}return()=>{for(const f of c)f()}},[n,o,i,l,s])}function Ko({icon:e,label:t,value:n,subtext:o,color:s}){return u("div",{className:"rounded-lg border border-border bg-surface p-2 sm:p-2.5 min-w-0",children:[u("div",{className:"flex items-center gap-1.5 mb-0.5 min-w-0",children:[r(e,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),r("span",{className:`${ks} uppercase tracking-wider whitespace-nowrap overflow-hidden text-ellipsis min-w-0`,children:t})]}),r("p",{className:`${s?`${Ti.replace("text-foreground","")} ${s}`:Ti} whitespace-nowrap overflow-hidden text-ellipsis`,children:n}),o&&r("p",{className:`${ks} mt-0.5 truncate`,children:o})]})}function Go({label:e,value:t,warning:n}){return u("div",{className:"min-w-0",children:[r("p",{className:`${ks} truncate`,children:e}),r("p",{className:`text-[11px] font-medium truncate ${n?"text-warning":"text-foreground"}`,children:t})]})}function tn({label:e,value:t}){return u("div",{className:`${gm} flex items-start gap-2 sm:gap-3`,children:[r("span",{className:"w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle",children:e}),r("div",{className:"flex-1 min-w-0 text-[11px] text-foreground",children:t})]})}function RT(){const e=pn();yt(["pipelineOrchestrator","getPipelineAssignment"],["pipeline.camera-assigned","pipeline.camera-unassigned","pipeline.camera-updated"]),yt(["pipelineRunner","getCameraMetrics"],["pipeline.camera-metrics-snapshot"]);const{data:t}=la({deviceId:e??0},{enabled:e!==null,staleTime:3e4}),n=t?.agentNodeId??null,s=typeof n=="string"&&n.length>0&&!n.startsWith("addon:")?n:void 0,{data:a}=vc({deviceId:e??0,...s?{nodeId:s}:{}},{enabled:e!==null,staleTime:2e3,retry:!1}),i=Le(),l=kt(i.trpcClient,e),{data:c}=Kn({queryKey:["device",e,"pipelineAnalytics.getActiveTracks"],queryFn:()=>l?.pipelineAnalytics?.getActiveTracks({})??[],enabled:!!l&&e!==null,refetchInterval:5e3,retry:!1});if(e===null)return null;const d=a?.phase??null,f=a?.detectionMode??null,p=Number(a?.actualFps??0),m=Number(a?.configuredFps??0),h=Number(a?.avgInferenceTimeMs??0),g=Number(a?.queueDepth??0),b=Number(a?.droppedFrames??0),x=Wn(d??"watching"),v=c?.length??0;return u("div",{className:"grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4 gap-2 sm:gap-3",children:[r(Ko,{icon:Io,label:"Phase",value:x.label,color:x.textColor,subtext:f??void 0}),r(Ko,{icon:ry,label:"Detection FPS",value:`${p.toFixed(1)}`,subtext:m>0?`target: ${m}`:void 0}),r(Ko,{icon:ut,label:"Inference",value:`${h.toFixed(1)} ms`,subtext:g>0?`queue: ${g}`:void 0}),r(Ko,{icon:xa,label:"Active Tracks",value:String(v),subtext:b>0?`dropped: ${b}`:void 0})]})}function oi(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function OT(){const e=pn(),{data:t}=gc({deviceId:e??0},{enabled:e!==null,refetchInterval:5e3});if(e===null)return null;const n=t?.streams??{},o=Object.entries(n);return o.length===0?null:u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r("div",{className:"border-b border-border px-3 sm:px-4 py-2",children:r("h2",{className:"text-[11px] font-semibold text-foreground uppercase tracking-wider",children:"Stream Network"})}),r("div",{className:"divide-y divide-border",children:o.map(([s,a])=>u("div",{className:"px-3 sm:px-4 py-2",children:[u("div",{className:"flex items-center gap-1.5 mb-1.5",children:[r(jn,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),r("span",{className:"text-[11px] font-medium text-foreground truncate",children:s})]}),u("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-2",children:[r(Go,{label:"Nominal",value:oi(a.nominalBitrateKbps??0)}),r(Go,{label:"Observed",value:oi(a.observedBitrateKbps??0)}),r(Go,{label:"Peak",value:oi(a.peakBitrateKbps??0)}),r(Go,{label:"Packet Loss",value:`${(a.packetLossPercent??0).toFixed(2)}%`,warning:(a.packetLossPercent??0)>1})]})]},s))})]})}const zT=3e4;function BT({field:e}){const t=pn(),n=e.type==="doorbell-recent"&&typeof e.historyLimit=="number"?e.historyLimit:10,o=Lc({deviceId:t??void 0,historyLimit:n});if(t===null)return null;const s=o.latest?Date.now()-o.latest.timestamp<zT:!1;return r($c,{history:o.history,latestIsFresh:s})}const FT={streaming:{icon:xy,label:"Streaming"},detection:{icon:xa,label:"Detection"},recording:{icon:ey,label:"Recording"},audio:{icon:tl,label:"Audio"},snapshot:{icon:gr,label:"Snapshot"},motion:{icon:Jc,label:"Motion"},ptz:{icon:wt,label:"PTZ"},webrtc:{icon:Zc,label:"WebRTC"},onvif:{icon:ZL,label:"ONVIF"},analytics:{icon:ut,label:"Analytics"},"battery-operated":{icon:J_,label:"Battery"},"native-snapshot":{icon:gr,label:"Native Snapshot"},"pan-tilt-zoom":{icon:wt,label:"PTZ"},"two-way-audio":{icon:tl,label:"Two-way Audio"},"doorbell-button":{icon:Ao,label:"Doorbell"},rebootable:{icon:pt,label:"Rebootable"}},jT=ha;function va({capabilities:e,showLabels:t=!1}){return r("div",{className:"flex items-center gap-1 flex-wrap",children:e.map(n=>{const o=FT[n],s=o?.icon??jT,a=o?.label??n;return u("span",{className:"inline-flex items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] text-foreground-subtle",title:a,children:[r(s,{className:"h-3 w-3"}),t&&r("span",{children:a})]},n)})})}const HT={frigate:{icon:Xx,color:"#3b82f6",label:"Frigate"},scrypted:{icon:ln,color:"#a855f7",label:"Scrypted"},reolink:{icon:Zc,color:"#06b6d4",label:"Reolink"},homeassistant:{icon:UD,color:"#22d3ee",label:"Home Assistant"},rtsp:{icon:jn,color:"#78716c",label:"RTSP"},onvif:{icon:jn,color:"#78716c",label:"ONVIF"}},_u={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6"},VT={sm:"h-7 w-7",md:"h-8 w-8",lg:"h-10 w-10"};function wy(e){const t=e.toLowerCase();return t.startsWith("provider-")?t.slice(9):t}function qT(e){const t=wy(e);return HT[t]??{icon:Xx,color:"#78716c",label:e}}function QT(e){const t=wy(e);return`/api/addon-assets/${e.toLowerCase().startsWith("provider-")?e:`provider-${t}`}/assets/icon.svg`}function cn({type:e,size:t="md",showLabel:n}){const o=qT(e),s=o.icon,[a,i]=$(!1),l=QT(e);return u("div",{className:"flex items-center gap-2",children:[r("div",{className:`flex items-center justify-center rounded-lg ${VT[t]}`,style:{backgroundColor:`${o.color}15`},children:a?r(s,{className:_u[t],style:{color:o.color}}):r("img",{src:l,alt:o.label,className:_u[t],onError:()=>i(!0)})}),n&&r("span",{className:"text-xs font-medium text-foreground-subtle",children:o.label})]})}function UT({deviceId:e,initialName:t}){const n=ke(),[o,s]=$(!1),[a,i]=$(t),[l,c]=$(!1),d=ne(null);Y(()=>{o||i(t)},[t,o]),Y(()=>{o&&d.current?.focus()},[o]);const f=xg({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDevice"]]}),n.invalidateQueries({queryKey:[["deviceManager","listAll"]]}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]})}}),p=async()=>{const h=a.trim();if(h.length===0||h===t){s(!1),i(t);return}c(!0);try{await f.mutateAsync({deviceId:e,name:h}),s(!1)}catch{}finally{c(!1)}},m=()=>{i(t),s(!1)};return o?r(tn,{label:"Name",value:u("div",{className:"flex items-center gap-1",children:[r("input",{ref:d,type:"text",value:a,onChange:h=>i(h.target.value),onKeyDown:h=>{h.key==="Enter"?p():h.key==="Escape"&&m()},disabled:l,className:"flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary"}),r("button",{type:"button",onClick:()=>void p(),disabled:l,className:"p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50","aria-label":"Save",children:r(Ct,{className:"h-3 w-3"})}),r("button",{type:"button",onClick:m,disabled:l,className:"p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50","aria-label":"Cancel",children:r(qe,{className:"h-3 w-3"})})]})}):r(tn,{label:"Name",value:u("div",{className:"flex items-center gap-2 group",children:[r("span",{className:"truncate",children:t}),r("button",{type:"button",onClick:()=>s(!0),className:"opacity-0 group-hover:opacity-100 transition-opacity p-0.5 rounded hover:bg-surface-hover","aria-label":"Edit name",children:r(Po,{className:"h-3 w-3 text-foreground-subtle"})})]})})}function KT({deviceId:e,initialLocation:t}){const n=ke(),[o,s]=$(!1),[a,i]=$(t??""),[l,c]=$(!1),d=ne(null),{data:f}=vg(void 0,{staleTime:3e4,enabled:o}),p=f??[];Y(()=>{o||i(t??"")},[t,o]),Y(()=>{o&&d.current?.focus()},[o]);const m=yg({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDevice"]]}),n.invalidateQueries({queryKey:[["deviceManager","listAll"]]}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]}),n.invalidateQueries({queryKey:[["deviceManager","listLocations"]]})}}),h=Q(()=>{const v=a.trim().toLowerCase();return v.length===0?p:p.filter(w=>w.toLowerCase()!==v&&w.toLowerCase().includes(v))},[p,a]),g=a.trim().length>0&&!p.some(v=>v.toLowerCase()===a.trim().toLowerCase()),b=async v=>{const y=(v??a).trim(),N=y.length===0?null:y;if(N===(t??null)){s(!1);return}c(!0);try{await m.mutateAsync({deviceId:e,location:N}),s(!1)}catch{}finally{c(!1)}},x=()=>{i(t??""),s(!1)};return o?r(tn,{label:"Location",value:u("div",{className:"relative",children:[u("div",{className:"flex items-center gap-1",children:[r("input",{ref:d,type:"text",value:a,onChange:v=>i(v.target.value),onKeyDown:v=>{v.key==="Enter"?b():v.key==="Escape"&&x()},disabled:l,placeholder:"Room / area (or leave empty to clear)",className:"flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary"}),r("button",{type:"button",onClick:()=>void b(),disabled:l,className:"p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50","aria-label":"Save",children:r(Ct,{className:"h-3 w-3"})}),r("button",{type:"button",onClick:x,disabled:l,className:"p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50","aria-label":"Cancel",children:r(qe,{className:"h-3 w-3"})})]}),(h.length>0||g)&&u("div",{className:"absolute z-10 left-0 right-0 mt-0.5 max-h-40 overflow-y-auto rounded-md border border-border bg-surface shadow-md",children:[h.map(v=>u("button",{type:"button",onClick:()=>{i(v),b(v)},className:"w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover",children:[r(dL,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),r("span",{className:"truncate",children:v})]},v)),g&&u("button",{type:"button",onClick:()=>void b(),className:"w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover border-t border-border",children:[r("span",{className:"text-foreground-subtle",children:"Create"}),u("span",{className:"font-medium truncate",children:['"',a.trim(),'"']})]})]})]})}):r(tn,{label:"Location",value:u("div",{className:"flex items-center gap-2 group",children:[t?r("span",{className:"truncate",children:t}):r("span",{className:"italic text-foreground-subtle",children:"unset"}),r("button",{type:"button",onClick:()=>s(!0),className:"opacity-0 group-hover:opacity-100 transition-opacity p-0.5 rounded hover:bg-surface-hover","aria-label":"Edit location",children:r(Po,{className:"h-3 w-3 text-foreground-subtle"})})]})})}const Du=["manufacturer","model","hardware","firmware","serialNumber","uid","mac","itemNo"];function GT(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}function WT(e){return e==null?"—":typeof e=="string"||typeof e=="number"||typeof e=="boolean"?String(e):JSON.stringify(e)}function Ny(){const e=pn(),t=sc(),{data:n}=Fn({deviceId:e??0},{enabled:e!==null,staleTime:3e4}),o=n??t??null,[s,a]=$("identity");if(e===null||!o)return null;const i=String(o.stableId??""),l=String(o.name??""),c=String(o.type??""),d=String(o.addonId??""),f=o.features??[],p=o.location??null,m=o.metadata??null,h=m!==null&&Object.keys(m).length>0;return u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3",children:[r("h2",{className:"text-[11px] font-semibold text-foreground uppercase tracking-wider",children:"Device Info"}),h&&u("div",{className:"flex items-center gap-1 rounded-md bg-surface-hover p-0.5",children:[r(Lu,{active:s==="identity",onClick:()=>a("identity"),label:"Identity"}),r(Lu,{active:s==="hardware",onClick:()=>a("hardware"),label:"Hardware"})]})]}),(!h||s==="identity")&&u("div",{className:"divide-y divide-border",children:[r(tn,{label:"ID",value:u("span",{className:"font-mono text-[11px] text-foreground",children:[`#${e}`,u("span",{className:"ml-1.5 text-foreground-subtle",children:["(",i,")"]})]})}),r(UT,{deviceId:e,initialName:l}),r(KT,{deviceId:e,initialLocation:p}),r(tn,{label:"Type",value:c}),r(tn,{label:"Provider",value:r(cn,{type:d,size:"sm",showLabel:!0})}),r(tn,{label:"Capabilities",value:f.length>0?r(va,{capabilities:f,showLabels:!0}):r("span",{className:"text-[11px] text-foreground-subtle",children:"None"})})]}),h&&s==="hardware"&&r(YT,{metadata:m})]})}function Lu({active:e,onClick:t,label:n}){return r("button",{type:"button",onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${e?"bg-surface text-foreground shadow-sm":"text-foreground-subtle hover:text-foreground"}`,children:n})}function YT({metadata:e}){const t=Du.filter(s=>s in e),n=Object.keys(e).filter(s=>!Du.includes(s)).sort(),o=[...t,...n];return u("div",{children:[r("div",{className:"px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border bg-surface-subtle/40",children:"Auto-populated by the driver on every connect. Read-only."}),r("div",{className:"divide-y divide-border",children:o.map(s=>r(tn,{label:GT(s),value:r("span",{className:"font-mono text-[11px] text-foreground break-all",children:WT(e[s])})},s))})]})}function nl(e){try{const t=e.split(".");if(t.length<2||!t[1])return null;const n=JSON.parse(atob(t[1]));return{id:String(n.userId??""),username:String(n.username??"unknown"),role:String(n.role??"viewer"),exp:Number(n.exp??0)}}catch{return null}}function ZT(e){const t=nl(e);return t?t.exp*1e3<Date.now():!0}const XT="changeme",ky=Oe(null);function JT({children:e}){const[t,n]=$(null),[o,s]=$(!0),[a,i]=$(!1);Y(()=>{if(typeof window<"u"&&window.location.hash.startsWith("#token=")){const b=new URLSearchParams(window.location.hash.slice(1)).get("token");b&&(localStorage.setItem("camstack_admin_token",b),window.history.replaceState({},"","/admin"))}const f=localStorage.getItem("camstack_admin_token");if(!f){s(!1);return}if(ZT(f)){localStorage.removeItem("camstack_admin_token"),s(!1);return}const p=nl(f);if(!p){localStorage.removeItem("camstack_admin_token"),s(!1);return}Ji().trpcClient.system.info.query().then(()=>n(p)).catch(g=>{const b=g?.data?.code;b==="UNAUTHORIZED"||b==="FORBIDDEN"?(localStorage.removeItem("camstack_admin_token"),Yr()):n(p)}).finally(()=>s(!1))},[]);const l=q(async(f,p)=>{const g=(await Ji().login(f,p)).token;localStorage.setItem("camstack_admin_token",g),Yr(),n(nl(g)),i(p===XT)},[]),c=q(()=>{localStorage.removeItem("camstack_admin_token"),Yr(),n(null),i(!1)},[]),d=q(()=>{i(!1)},[]);return r(ky.Provider,{value:{user:t,loading:o,mustChangePassword:a,login:l,logout:c,clearMustChangePassword:d},children:e})}function Tr(){const e=ye(ky);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}function jt({children:e,requiredRole:t}){const{user:n,loading:o,mustChangePassword:s}=Tr(),a=ht();return o?r("div",{className:"flex h-screen items-center justify-center bg-background text-foreground-subtle",children:"Loading..."}):n?s&&a.pathname!=="/change-password"?r(gt,{to:"/change-password",replace:!0}):t==="admin"&&n.role!=="admin"&&n.role!=="super_admin"?r(gt,{to:"/access-denied",replace:!0}):r(ve,{children:e}):r(gt,{to:"/login",replace:!0})}var si={};const Ce=e=>typeof e=="string",Fr=()=>{let e,t;const n=new Promise((o,s)=>{e=o,t=s});return n.resolve=e,n.reject=t,n},Tu=e=>e==null?"":""+e,eR=(e,t,n)=>{e.forEach(o=>{t[o]&&(n[o]=t[o])})},tR=/###/g,Ru=e=>e&&e.indexOf("###")>-1?e.replace(tR,"."):e,Ou=e=>!e||Ce(e),Xr=(e,t,n)=>{const o=Ce(t)?t.split("."):t;let s=0;for(;s<o.length-1;){if(Ou(e))return{};const a=Ru(o[s]);!e[a]&&n&&(e[a]=new n),Object.prototype.hasOwnProperty.call(e,a)?e=e[a]:e={},++s}return Ou(e)?{}:{obj:e,k:Ru(o[s])}},zu=(e,t,n)=>{const{obj:o,k:s}=Xr(e,t,Object);if(o!==void 0||t.length===1){o[s]=n;return}let a=t[t.length-1],i=t.slice(0,t.length-1),l=Xr(e,i,Object);for(;l.obj===void 0&&i.length;)a=`${i[i.length-1]}.${a}`,i=i.slice(0,i.length-1),l=Xr(e,i,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},nR=(e,t,n,o)=>{const{obj:s,k:a}=Xr(e,t,Object);s[a]=s[a]||[],s[a].push(n)},$s=(e,t)=>{const{obj:n,k:o}=Xr(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,o))return n[o]},rR=(e,t,n)=>{const o=$s(e,n);return o!==void 0?o:$s(t,n)},Sy=(e,t,n)=>{for(const o in t)o!=="__proto__"&&o!=="constructor"&&(o in e?Ce(e[o])||e[o]instanceof String||Ce(t[o])||t[o]instanceof String?n&&(e[o]=t[o]):Sy(e[o],t[o],n):e[o]=t[o]);return e},$n=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var oR={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const sR=e=>Ce(e)?e.replace(/[&<>"'\/]/g,t=>oR[t]):e;class aR{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const n=this.regExpMap.get(t);if(n!==void 0)return n;const o=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,o),this.regExpQueue.push(t),o}}const iR=[" ",",","?","!",";"],lR=new aR(20),cR=(e,t,n)=>{t=t||"",n=n||"";const o=iR.filter(i=>t.indexOf(i)<0&&n.indexOf(i)<0);if(o.length===0)return!0;const s=lR.getRegExp(`(${o.map(i=>i==="?"?"\\?":i).join("|")})`);let a=!s.test(e);if(!a){const i=e.indexOf(n);i>0&&!s.test(e.substring(0,i))&&(a=!0)}return a},rl=(e,t,n=".")=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;const o=t.split(n);let s=e;for(let a=0;a<o.length;){if(!s||typeof s!="object")return;let i,l="";for(let c=a;c<o.length;++c)if(c!==a&&(l+=n),l+=o[c],i=s[l],i!==void 0){if(["string","number","boolean"].indexOf(typeof i)>-1&&c<o.length-1)continue;a+=c-a+1;break}s=i}return s},co=e=>e?.replace(/_/g,"-"),dR={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class _s{constructor(t,n={}){this.init(t,n)}init(t,n={}){this.prefix=n.prefix||"i18next:",this.logger=t||dR,this.options=n,this.debug=n.debug}log(...t){return this.forward(t,"log","",!0)}warn(...t){return this.forward(t,"warn","",!0)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,o,s){return s&&!this.debug?null:(Ce(t[0])&&(t[0]=`${o}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new _s(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new _s(this.logger,t)}}var Qt=new _s;class wa{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(o=>{this.observers[o]||(this.observers[o]=new Map);const s=this.observers[o].get(n)||0;this.observers[o].set(n,s+1)}),this}off(t,n){if(this.observers[t]){if(!n){delete this.observers[t];return}this.observers[t].delete(n)}}emit(t,...n){this.observers[t]&&Array.from(this.observers[t].entries()).forEach(([s,a])=>{for(let i=0;i<a;i++)s(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([s,a])=>{for(let i=0;i<a;i++)s.apply(s,[t,...n])})}}class Bu extends wa{constructor(t,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,o,s={}){const a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,i=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;t.indexOf(".")>-1?l=t.split("."):(l=[t,n],o&&(Array.isArray(o)?l.push(...o):Ce(o)&&a?l.push(...o.split(a)):l.push(o)));const c=$s(this.data,l);return!c&&!n&&!o&&t.indexOf(".")>-1&&(t=l[0],n=l[1],o=l.slice(2).join(".")),c||!i||!Ce(o)?c:rl(this.data?.[t]?.[n],o,a)}addResource(t,n,o,s,a={silent:!1}){const i=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let l=[t,n];o&&(l=l.concat(i?o.split(i):o)),t.indexOf(".")>-1&&(l=t.split("."),s=n,n=l[1]),this.addNamespaces(n),zu(this.data,l,s),a.silent||this.emit("added",t,n,o,s)}addResources(t,n,o,s={silent:!1}){for(const a in o)(Ce(o[a])||Array.isArray(o[a]))&&this.addResource(t,n,a,o[a],{silent:!0});s.silent||this.emit("added",t,n,o)}addResourceBundle(t,n,o,s,a,i={silent:!1,skipCopy:!1}){let l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),s=o,o=n,n=l[1]),this.addNamespaces(n);let c=$s(this.data,l)||{};i.skipCopy||(o=JSON.parse(JSON.stringify(o))),s?Sy(c,o,a):c={...c,...o},zu(this.data,l,c),i.silent||this.emit("added",t,n,o)}removeResourceBundle(t,n){this.hasResourceBundle(t,n)&&delete this.data[t][n],this.removeNamespaces(n),this.emit("removed",t,n)}hasResourceBundle(t,n){return this.getResource(t,n)!==void 0}getResourceBundle(t,n){return n||(n=this.options.defaultNS),this.getResource(t,n)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const n=this.getDataByLanguage(t);return!!(n&&Object.keys(n)||[]).find(s=>n[s]&&Object.keys(n[s]).length>0)}toJSON(){return this.data}}var Cy={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,o,s){return e.forEach(a=>{t=this.processors[a]?.process(t,n,o,s)??t}),t}};const My=Symbol("i18next/PATH_KEY");function uR(){const e=[],t=Object.create(null);let n;return t.get=(o,s)=>(n?.revoke?.(),s===My?e:(e.push(s),n=Proxy.revocable(o,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function dr(e,t){const{[My]:n}=e(uR()),o=t?.keySeparator??".",s=t?.nsSeparator??":";if(n.length>1&&s){const a=t?.ns,i=Array.isArray(a)?a:null;if(i&&i.length>1&&i.slice(1).includes(n[0]))return`${n[0]}${s}${n.slice(1).join(o)}`}return n.join(o)}const Fu={},ai=e=>!Ce(e)&&typeof e!="boolean"&&typeof e!="number";class Ds extends wa{constructor(t,n={}){super(),eR(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Qt.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t,n={interpolation:{}}){const o={...n};if(t==null)return!1;const s=this.resolve(t,o);if(s?.res===void 0)return!1;const a=ai(s.res);return!(o.returnObjects===!1&&a)}extractFromKey(t,n){let o=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;o===void 0&&(o=":");const s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const i=o&&t.indexOf(o)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!cR(t,o,s);if(i&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:Ce(a)?[a]:a};const d=t.split(o);(o!==s||o===s&&this.options.ns.indexOf(d[0])>-1)&&(a=d.shift()),t=d.join(s)}return{key:t,namespaces:Ce(a)?[a]:a}}translate(t,n,o){let s=typeof n=="object"?{...n}:n;if(typeof s!="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),typeof s=="object"&&(s={...s}),s||(s={}),t==null)return"";typeof t=="function"&&(t=dr(t,{...this.options,...s})),Array.isArray(t)||(t=[String(t)]),t=t.map(O=>typeof O=="function"?dr(O,{...this.options,...s}):String(O));const a=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,i=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(t[t.length-1],s),d=c[c.length-1];let f=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;f===void 0&&(f=":");const p=s.lng||this.language,m=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p?.toLowerCase()==="cimode")return m?a?{res:`${d}${f}${l}`,usedKey:l,exactUsedKey:l,usedLng:p,usedNS:d,usedParams:this.getUsedParamsDetails(s)}:`${d}${f}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:p,usedNS:d,usedParams:this.getUsedParamsDetails(s)}:l;const h=this.resolve(t,s);let g=h?.res;const b=h?.usedKey||l,x=h?.exactUsedKey||l,v=["[object Number]","[object Function]","[object RegExp]"],w=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,N=s.count!==void 0&&!Ce(s.count),k=Ds.hasDefaultValue(s),S=N?this.pluralResolver.getSuffix(p,s.count,s):"",M=s.ordinal&&N?this.pluralResolver.getSuffix(p,s.count,{ordinal:!1}):"",P=N&&!s.ordinal&&s.count===0,I=P&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${S}`]||s[`defaultValue${M}`]||s.defaultValue;let F=g;y&&!g&&k&&(F=I);const E=ai(F),B=Object.prototype.toString.apply(F);if(y&&F&&E&&v.indexOf(B)<0&&!(Ce(w)&&Array.isArray(F))){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const O=this.options.returnedObjectHandler?this.options.returnedObjectHandler(b,F,{...s,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(h.res=O,h.usedParams=this.getUsedParamsDetails(s),h):O}if(i){const O=Array.isArray(F),A=O?[]:{},D=O?x:b;for(const _ in F)if(Object.prototype.hasOwnProperty.call(F,_)){const R=`${D}${i}${_}`;k&&!g?A[_]=this.translate(R,{...s,defaultValue:ai(I)?I[_]:void 0,joinArrays:!1,ns:c}):A[_]=this.translate(R,{...s,joinArrays:!1,ns:c}),A[_]===R&&(A[_]=F[_])}g=A}}else if(y&&Ce(w)&&Array.isArray(g))g=g.join(w),g&&(g=this.extendTranslation(g,t,s,o));else{let O=!1,A=!1;!this.isValidLookup(g)&&k&&(O=!0,g=I),this.isValidLookup(g)||(A=!0,g=l);const _=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&A?void 0:g,R=k&&I!==g&&this.options.updateMissing;if(A||O||R){if(this.logger.log(R?"updateKey":"missingKey",p,d,l,R?I:g),i){const H=this.resolve(l,{...s,keySeparator:!1});H&&H.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let L=[];const z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&z&&z[0])for(let H=0;H<z.length;H++)L.push(z[H]);else this.options.saveMissingTo==="all"?L=this.languageUtils.toResolveHierarchy(s.lng||this.language):L.push(s.lng||this.language);const j=(H,T,W)=>{const G=k&&W!==g?W:_;this.options.missingKeyHandler?this.options.missingKeyHandler(H,d,T,G,R,s):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(H,d,T,G,R,s),this.emit("missingKey",H,d,T,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?L.forEach(H=>{const T=this.pluralResolver.getSuffixes(H,s);P&&s[`defaultValue${this.options.pluralSeparator}zero`]&&T.indexOf(`${this.options.pluralSeparator}zero`)<0&&T.push(`${this.options.pluralSeparator}zero`),T.forEach(W=>{j([H],l+W,s[`defaultValue${W}`]||I)})}):j(L,l,I))}g=this.extendTranslation(g,t,s,h,o),A&&g===l&&this.options.appendNamespaceToMissingKey&&(g=`${d}${f}${l}`),(A||O)&&this.options.parseMissingKeyHandler&&(g=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${f}${l}`:l,O?g:void 0,s))}return a?(h.res=g,h.usedParams=this.getUsedParamsDetails(s),h):g}extendTranslation(t,n,o,s,a){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...o},o.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!o.skipInterpolation){o.interpolation&&this.interpolator.init({...o,interpolation:{...this.options.interpolation,...o.interpolation}});const c=Ce(t)&&(o?.interpolation?.skipOnVariables!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let d;if(c){const p=t.match(this.interpolator.nestingRegexp);d=p&&p.length}let f=o.replace&&!Ce(o.replace)?o.replace:o;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),t=this.interpolator.interpolate(t,f,o.lng||this.language||s.usedLng,o),c){const p=t.match(this.interpolator.nestingRegexp),m=p&&p.length;d<m&&(o.nest=!1)}!o.lng&&s&&s.res&&(o.lng=this.language||s.usedLng),o.nest!==!1&&(t=this.interpolator.nest(t,(...p)=>a?.[0]===p[0]&&!o.context?(this.logger.warn(`It seems you are nesting recursively key: ${p[0]} in key: ${n[0]}`),null):this.translate(...p,n),o)),o.interpolation&&this.interpolator.reset()}const i=o.postProcess||this.options.postProcess,l=Ce(i)?[i]:i;return t!=null&&l?.length&&o.applyPostProcessor!==!1&&(t=Cy.handle(l,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(o)},...o}:o,this)),t}resolve(t,n={}){let o,s,a,i,l;return Ce(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(c=>typeof c=="function"?dr(c,{...this.options,...n}):c)),t.forEach(c=>{if(this.isValidLookup(o))return;const d=this.extractFromKey(c,n),f=d.key;s=f;let p=d.namespaces;this.options.fallbackNS&&(p=p.concat(this.options.fallbackNS));const m=n.count!==void 0&&!Ce(n.count),h=m&&!n.ordinal&&n.count===0,g=n.context!==void 0&&(Ce(n.context)||typeof n.context=="number")&&n.context!=="",b=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);p.forEach(x=>{this.isValidLookup(o)||(l=x,!Fu[`${b[0]}-${x}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(Fu[`${b[0]}-${x}`]=!0,this.logger.warn(`key "${s}" for languages "${b.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),b.forEach(v=>{if(this.isValidLookup(o))return;i=v;const w=[f];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(w,f,v,x,n);else{let N;m&&(N=this.pluralResolver.getSuffix(v,n.count,n));const k=`${this.options.pluralSeparator}zero`,S=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(n.ordinal&&N.indexOf(S)===0&&w.push(f+N.replace(S,this.options.pluralSeparator)),w.push(f+N),h&&w.push(f+k)),g){const M=`${f}${this.options.contextSeparator||"_"}${n.context}`;w.push(M),m&&(n.ordinal&&N.indexOf(S)===0&&w.push(M+N.replace(S,this.options.pluralSeparator)),w.push(M+N),h&&w.push(M+k))}}let y;for(;y=w.pop();)this.isValidLookup(o)||(a=y,o=this.getResource(v,x,y,n))}))})}),{res:o,usedKey:s,exactUsedKey:a,usedLng:i,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,o,s={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,n,o,s):this.resourceStore.getResource(t,n,o,s)}getUsedParamsDetails(t={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],o=t.replace&&!Ce(t.replace);let s=o?t.replace:t;if(o&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!o){s={...s};for(const a of n)delete s[a]}return s}static hasDefaultValue(t){const n="defaultValue";for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&n===o.substring(0,n.length)&&t[o]!==void 0)return!0;return!1}}class ju{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Qt.create("languageUtils")}getScriptPartFromCode(t){if(t=co(t),!t||t.indexOf("-")<0)return null;const n=t.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(t){if(t=co(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(Ce(t)&&t.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(t)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let n;return t.forEach(o=>{if(n)return;const s=this.formatLanguageCode(o);(!this.options.supportedLngs||this.isSupportedCode(s))&&(n=s)}),!n&&this.options.supportedLngs&&t.forEach(o=>{if(n)return;const s=this.getScriptPartFromCode(o);if(this.isSupportedCode(s))return n=s;const a=this.getLanguagePartFromCode(o);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(i=>{if(i===a)return i;if(!(i.indexOf("-")<0&&a.indexOf("-")<0)&&(i.indexOf("-")>0&&a.indexOf("-")<0&&i.substring(0,i.indexOf("-"))===a||i.indexOf(a)===0&&a.length>1))return i})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),Ce(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let o=t[n];return o||(o=t[this.getScriptPartFromCode(n)]),o||(o=t[this.formatLanguageCode(n)]),o||(o=t[this.getLanguagePartFromCode(n)]),o||(o=t.default),o||[]}toResolveHierarchy(t,n){const o=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],t),s=[],a=i=>{i&&(this.isSupportedCode(i)?s.push(i):this.logger.warn(`rejecting language code not found in supportedLngs: ${i}`))};return Ce(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(t))):Ce(t)&&a(this.formatLanguageCode(t)),o.forEach(i=>{s.indexOf(i)<0&&a(this.formatLanguageCode(i))}),s}}const Hu={zero:0,one:1,two:2,few:3,many:4,other:5},Vu={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class pR{constructor(t,n={}){this.languageUtils=t,this.options=n,this.logger=Qt.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,n={}){const o=co(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:o,type:s});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let i;try{i=new Intl.PluralRules(o,{type:s})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),Vu;if(!t.match(/-|_/))return Vu;const c=this.languageUtils.getLanguagePartFromCode(t);i=this.getRule(c,n)}return this.pluralRulesCache[a]=i,i}needsPlural(t,n={}){let o=this.getRule(t,n);return o||(o=this.getRule("dev",n)),o?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,n,o={}){return this.getSuffixes(t,o).map(s=>`${n}${s}`)}getSuffixes(t,n={}){let o=this.getRule(t,n);return o||(o=this.getRule("dev",n)),o?o.resolvedOptions().pluralCategories.sort((s,a)=>Hu[s]-Hu[a]).map(s=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(t,n,o={}){const s=this.getRule(t,o);return s?`${this.options.prepend}${o.ordinal?`ordinal${this.options.prepend}`:""}${s.select(n)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",n,o))}}const qu=(e,t,n,o=".",s=!0)=>{let a=rR(e,t,n);return!a&&s&&Ce(n)&&(a=rl(e,n,o),a===void 0&&(a=rl(t,n,o))),a},ii=e=>e.replace(/\$/g,"$$$$");class Qu{constructor(t={}){this.logger=Qt.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(n=>n),this.init(t)}init(t={}){t.interpolation||(t.interpolation={escapeValue:!0});const{escape:n,escapeValue:o,useRawValueToEscape:s,prefix:a,prefixEscaped:i,suffix:l,suffixEscaped:c,formatSeparator:d,unescapeSuffix:f,unescapePrefix:p,nestingPrefix:m,nestingPrefixEscaped:h,nestingSuffix:g,nestingSuffixEscaped:b,nestingOptionsSeparator:x,maxReplaces:v,alwaysFormat:w}=t.interpolation;this.escape=n!==void 0?n:sR,this.escapeValue=o!==void 0?o:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=a?$n(a):i||"{{",this.suffix=l?$n(l):c||"}}",this.formatSeparator=d||",",this.unescapePrefix=f?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=m?$n(m):h||$n("$t("),this.nestingSuffix=g?$n(g):b||$n(")"),this.nestingOptionsSeparator=x||",",this.maxReplaces=v||1e3,this.alwaysFormat=w!==void 0?w:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,o)=>n?.source===o?(n.lastIndex=0,n):new RegExp(o,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,n,o,s){let a,i,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=h=>{if(h.indexOf(this.formatSeparator)<0){const v=qu(n,c,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,o,{...s,...n,interpolationkey:h}):v}const g=h.split(this.formatSeparator),b=g.shift().trim(),x=g.join(this.formatSeparator).trim();return this.format(qu(n,c,b,this.options.keySeparator,this.options.ignoreJSONStructure),x,o,{...s,...n,interpolationkey:b})};this.resetRegExp();const f=s?.missingInterpolationHandler||this.options.missingInterpolationHandler,p=s?.interpolation?.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>ii(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?ii(this.escape(h)):ii(h)}].forEach(h=>{for(l=0;a=h.regex.exec(t);){const g=a[1].trim();if(i=d(g),i===void 0)if(typeof f=="function"){const x=f(t,a,s);i=Ce(x)?x:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))i="";else if(p){i=a[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`),i="";else!Ce(i)&&!this.useRawValueToEscape&&(i=Tu(i));const b=h.safeValue(i);if(t=t.replace(a[0],b),p?(h.regex.lastIndex+=i.length,h.regex.lastIndex-=a[0].length):h.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n,o={}){let s,a,i;const l=(c,d)=>{const f=this.nestingOptionsSeparator;if(c.indexOf(f)<0)return c;const p=c.split(new RegExp(`${$n(f)}[ ]*{`));let m=`{${p[1]}`;c=p[0],m=this.interpolate(m,i);const h=m.match(/'/g),g=m.match(/"/g);((h?.length??0)%2===0&&!g||(g?.length??0)%2!==0)&&(m=m.replace(/'/g,'"'));try{i=JSON.parse(m),d&&(i={...d,...i})}catch(b){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,b),`${c}${f}${m}`}return i.defaultValue&&i.defaultValue.indexOf(this.prefix)>-1&&delete i.defaultValue,c};for(;s=this.nestingRegexp.exec(t);){let c=[];i={...o},i=i.replace&&!Ce(i.replace)?i.replace:i,i.applyPostProcessor=!1,delete i.defaultValue;const d=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(d!==-1&&(c=s[1].slice(d).split(this.formatSeparator).map(f=>f.trim()).filter(Boolean),s[1]=s[1].slice(0,d)),a=n(l.call(this,s[1].trim(),i),i),a&&s[0]===t&&!Ce(a))return a;Ce(a)||(a=Tu(a)),a||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),a=""),c.length&&(a=c.reduce((f,p)=>this.format(f,p,o.lng,{...o,interpolationkey:s[1].trim()}),a.trim())),t=t.replace(s[0],a),this.regexp.lastIndex=0}return t}}const fR=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const o=e.split("(");t=o[0].toLowerCase().trim();const s=o[1].substring(0,o[1].length-1);t==="currency"&&s.indexOf(":")<0?n.currency||(n.currency=s.trim()):t==="relativetime"&&s.indexOf(":")<0?n.range||(n.range=s.trim()):s.split(";").forEach(i=>{if(i){const[l,...c]=i.split(":"),d=c.join(":").trim().replace(/^'+|'+$/g,""),f=l.trim();n[f]||(n[f]=d),d==="false"&&(n[f]=!1),d==="true"&&(n[f]=!0),isNaN(d)||(n[f]=parseInt(d,10))}})}return{formatName:t,formatOptions:n}},Uu=e=>{const t={};return(n,o,s)=>{let a=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(a={...a,[s.interpolationkey]:void 0});const i=o+JSON.stringify(a);let l=t[i];return l||(l=e(co(o),s),t[i]=l),l(n)}},mR=e=>(t,n,o)=>e(co(n),o)(t);class hR{constructor(t={}){this.logger=Qt.create("formatter"),this.options=t,this.init(t)}init(t,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const o=n.cacheInBuiltFormats?Uu:mR;this.formats={number:o((s,a)=>{const i=new Intl.NumberFormat(s,{...a});return l=>i.format(l)}),currency:o((s,a)=>{const i=new Intl.NumberFormat(s,{...a,style:"currency"});return l=>i.format(l)}),datetime:o((s,a)=>{const i=new Intl.DateTimeFormat(s,{...a});return l=>i.format(l)}),relativetime:o((s,a)=>{const i=new Intl.RelativeTimeFormat(s,{...a});return l=>i.format(l,a.range||"day")}),list:o((s,a)=>{const i=new Intl.ListFormat(s,{...a});return l=>i.format(l)})}}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=Uu(n)}format(t,n,o,s={}){const a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(l=>l.indexOf(")")>-1)){const l=a.findIndex(c=>c.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,l)].join(this.formatSeparator)}return a.reduce((l,c)=>{const{formatName:d,formatOptions:f}=fR(c);if(this.formats[d]){let p=l;try{const m=s?.formatParams?.[s.interpolationkey]||{},h=m.locale||m.lng||s.locale||s.lng||o;p=this.formats[d](l,h,{...f,...s,...m})}catch(m){this.logger.warn(m)}return p}else this.logger.warn(`there was no format function for ${d}`);return l},t)}}const gR=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class bR extends wa{constructor(t,n,o,s={}){super(),this.backend=t,this.store=n,this.services=o,this.languageUtils=o.languageUtils,this.options=s,this.logger=Qt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(o,s.backend,s)}queueLoad(t,n,o,s){const a={},i={},l={},c={};return t.forEach(d=>{let f=!0;n.forEach(p=>{const m=`${d}|${p}`;!o.reload&&this.store.hasResourceBundle(d,p)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?i[m]===void 0&&(i[m]=!0):(this.state[m]=1,f=!1,i[m]===void 0&&(i[m]=!0),a[m]===void 0&&(a[m]=!0),c[p]===void 0&&(c[p]=!0)))}),f||(l[d]=!0)}),(Object.keys(a).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(a),pending:Object.keys(i),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(t,n,o){const s=t.split("|"),a=s[0],i=s[1];n&&this.emit("failedLoading",a,i,n),!n&&o&&this.store.addResourceBundle(a,i,o,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&o&&(this.state[t]=0);const l={};this.queue.forEach(c=>{nR(c.loaded,[a],i),gR(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(d=>{l[d]||(l[d]={});const f=c.loaded[d];f.length&&f.forEach(p=>{l[d][p]===void 0&&(l[d][p]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,o,s=0,a=this.retryTimeout,i){if(!t.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:o,tried:s,wait:a,callback:i});return}this.readingCalls++;const l=(d,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const p=this.waitingReads.shift();this.read(p.lng,p.ns,p.fcName,p.tried,p.wait,p.callback)}if(d&&f&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,o,s+1,a*2,i)},a);return}i(d,f)},c=this.backend[o].bind(this.backend);if(c.length===2){try{const d=c(t,n);d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}return}return c(t,n,l)}prepareLoading(t,n,o={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();Ce(t)&&(t=this.languageUtils.toResolveHierarchy(t)),Ce(n)&&(n=[n]);const a=this.queueLoad(t,n,o,s);if(!a.toLoad.length)return a.pending.length||s(),null;a.toLoad.forEach(i=>{this.loadOne(i)})}load(t,n,o){this.prepareLoading(t,n,{},o)}reload(t,n,o){this.prepareLoading(t,n,{reload:!0},o)}loadOne(t,n=""){const o=t.split("|"),s=o[0],a=o[1];this.read(s,a,"read",void 0,void 0,(i,l)=>{i&&this.logger.warn(`${n}loading namespace ${a} for language ${s} failed`,i),!i&&l&&this.logger.log(`${n}loaded namespace ${a} for language ${s}`,l),this.loaded(t,i,l)})}saveMissing(t,n,o,s,a,i={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${o}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(o==null||o==="")){if(this.backend?.create){const c={...i,isUpdate:a},d=this.backend.create.bind(this.backend);if(d.length<6)try{let f;d.length===5?f=d(t,n,o,s,c):f=d(t,n,o,s),f&&typeof f.then=="function"?f.then(p=>l(null,p)).catch(l):l(null,f)}catch(f){l(f)}else d(t,n,o,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,o,s)}}}const li=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),Ce(e[1])&&(t.defaultValue=e[1]),Ce(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(o=>{t[o]=n[o]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),Ku=e=>(Ce(e.ns)&&(e.ns=[e.ns]),Ce(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),Ce(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),typeof e.initImmediate=="boolean"&&(e.initAsync=e.initImmediate),e),Wo=()=>{},xR=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})},Iy="__i18next_supportNoticeShown",yR=()=>!!(typeof globalThis<"u"&&globalThis[Iy]||typeof process<"u"&&si&&si.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&si),vR=()=>{typeof globalThis<"u"&&(globalThis[Iy]=!0)},wR=e=>!!(e?.modules?.backend?.name?.indexOf("Locize")>0||e?.modules?.backend?.constructor?.name?.indexOf("Locize")>0||e?.options?.backend?.backends&&e.options.backend.backends.some(t=>t?.name?.indexOf("Locize")>0||t?.constructor?.name?.indexOf("Locize")>0)||e?.options?.backend?.projectId||e?.options?.backend?.backendOptions&&e.options.backend.backendOptions.some(t=>t?.projectId));class Jr extends wa{constructor(t={},n){if(super(),this.options=Ku(t),this.services={},this.logger=Qt,this.modules={external:[]},xR(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(t={},n){this.isInitializing=!0,typeof t=="function"&&(n=t,t={}),t.defaultNS==null&&t.ns&&(Ce(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const o=li();this.options={...o,...this.options,...Ku(t)},this.options.interpolation={...o.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=o.overloadTranslationOptionHandler),this.options.showSupportNotice!==!1&&!wR(this)&&!yR()&&(typeof console<"u"&&typeof console.info<"u"&&console.info("🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙"),vR());const s=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Qt.init(s(this.modules.logger),this.options):Qt.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=hR;const f=new ju(this.options);this.store=new Bu(this.options.resources,this.options);const p=this.services;p.logger=Qt,p.resourceStore=this.store,p.languageUtils=f,p.pluralResolver=new pR(f,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==o.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),d&&(!this.options.interpolation.format||this.options.interpolation.format===o.interpolation.format)&&(p.formatter=s(d),p.formatter.init&&p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new Qu(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new bR(s(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",(h,...g)=>{this.emit(h,...g)}),this.modules.languageDetector&&(p.languageDetector=s(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=s(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new Ds(this.services,this.options),this.translator.on("*",(h,...g)=>{this.emit(h,...g)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Wo),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(d=>{this[d]=(...f)=>this.store[d](...f)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=(...f)=>(this.store[d](...f),this)});const l=Fr(),c=()=>{const d=(f,p)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(p),n(f,p)};if(this.languages&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(t,n=Wo){let o=n;const s=Ce(t)?t:this.language;if(typeof t=="function"&&(o=t),!this.options.resources||this.options.partialBundledLanguages){if(s?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return o();const a=[],i=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(d=>{d!=="cimode"&&a.indexOf(d)<0&&a.push(d)})};s?i(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>i(c)),this.options.preload?.forEach?.(l=>i(l)),this.services.backendConnector.load(a,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),o(l)})}else o(null)}reloadResources(t,n,o){const s=Fr();return typeof t=="function"&&(o=t,t=void 0),typeof n=="function"&&(o=n,n=void 0),t||(t=this.languages),n||(n=this.options.ns),o||(o=Wo),this.services.backendConnector.reload(t,n,a=>{s.resolve(),o(a)}),s}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&Cy.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!(["cimode","dev"].indexOf(t)>-1)){for(let n=0;n<this.languages.length;n++){const o=this.languages[n];if(!(["cimode","dev"].indexOf(o)>-1)&&this.store.hasLanguageSomeTranslations(o)){this.resolvedLanguage=o;break}}!this.resolvedLanguage&&this.languages.indexOf(t)<0&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t))}}changeLanguage(t,n){this.isLanguageChangingTo=t;const o=Fr();this.emit("languageChanging",t);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},a=(l,c)=>{c?this.isLanguageChangingTo===t&&(s(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,o.resolve((...d)=>this.t(...d)),n&&n(l,(...d)=>this.t(...d))},i=l=>{!t&&!l&&this.services.languageDetector&&(l=[]);const c=Ce(l)?l:l&&l[0],d=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(Ce(l)?[l]:l);d&&(this.language||s(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector?.cacheUserLanguage?.(d)),this.loadResources(d,f=>{a(f,d)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?i(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(i):this.services.languageDetector.detect(i):i(t),o}getFixedT(t,n,o){const s=(a,i,...l)=>{let c;typeof i!="object"?c=this.options.overloadTranslationOptionHandler([a,i].concat(l)):c={...i},c.lng=c.lng||s.lng,c.lngs=c.lngs||s.lngs,c.ns=c.ns||s.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||o||s.keyPrefix);const d={...this.options,...c};typeof c.keyPrefix=="function"&&(c.keyPrefix=dr(c.keyPrefix,d));const f=this.options.keySeparator||".";let p;return c.keyPrefix&&Array.isArray(a)?p=a.map(m=>(typeof m=="function"&&(m=dr(m,d)),`${c.keyPrefix}${f}${m}`)):(typeof a=="function"&&(a=dr(a,d)),p=c.keyPrefix?`${c.keyPrefix}${f}${a}`:a),this.t(p,c)};return Ce(t)?s.lng=t:s.lngs=t,s.ns=n,s.keyPrefix=o,s}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const o=n.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(o.toLowerCase()==="cimode")return!0;const i=(l,c)=>{const d=this.services.backendConnector.state[`${l}|${c}`];return d===-1||d===0||d===2};if(n.precheck){const l=n.precheck(this,i);if(l!==void 0)return l}return!!(this.hasResourceBundle(o,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(o,t)&&(!s||i(a,t)))}loadNamespaces(t,n){const o=Fr();return this.options.ns?(Ce(t)&&(t=[t]),t.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{o.resolve(),n&&n(s)}),o):(n&&n(),Promise.resolve())}loadLanguages(t,n){const o=Fr();Ce(t)&&(t=[t]);const s=this.options.preload||[],a=t.filter(i=>s.indexOf(i)<0&&this.services.languageUtils.isSupportedCode(i));return a.length?(this.options.preload=s.concat(a),this.loadResources(i=>{o.resolve(),n&&n(i)}),o):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return"rtl";try{const s=new Intl.Locale(t);if(s&&s.getTextInfo){const a=s.getTextInfo();if(a&&a.direction)return a.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],o=this.services?.languageUtils||new ju(li());return t.toLowerCase().indexOf("-latn")>1?"ltr":n.indexOf(o.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},n){const o=new Jr(t,n);return o.createInstance=Jr.createInstance,o}cloneInstance(t={},n=Wo){const o=t.forkResourceStore;o&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},a=new Jr(s);if((t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),["store","services","language"].forEach(l=>{a[l]=this[l]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},o){const l=Object.keys(this.store.data).reduce((c,d)=>(c[d]={...this.store.data[d]},c[d]=Object.keys(c[d]).reduce((f,p)=>(f[p]={...c[d][p]},f),c[d]),c),{});a.store=new Bu(l,s),a.services.resourceStore=a.store}if(t.interpolation){const c={...li().interpolation,...this.options.interpolation,...t.interpolation},d={...s,interpolation:c};a.services.interpolator=new Qu(d)}return a.translator=new Ds(a.services,s),a.translator.on("*",(l,...c)=>{a.emit(l,...c)}),a.init(s,n),a.translator.options=s,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Ze=Jr.createInstance();Ze.createInstance;Ze.dir;Ze.init;Ze.loadResources;Ze.reloadResources;Ze.use;Ze.changeLanguage;Ze.getFixedT;Ze.t;Ze.exists;Ze.setDefaultNamespace;Ze.hasLoadedNamespace;Ze.loadNamespaces;Ze.loadLanguages;const NR=(e,t,n,o)=>{const s=[n,{code:t,...o||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(s,"warn","react-i18next::",!0);Hn(s[0])&&(s[0]=`react-i18next:: ${s[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...s):console?.warn&&console.warn(...s)},Gu={},ol=(e,t,n,o)=>{Hn(n)&&Gu[n]||(Hn(n)&&(Gu[n]=new Date),NR(e,t,n,o))},Ay=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}},sl=(e,t,n)=>{e.loadNamespaces(t,Ay(e,n))},Wu=(e,t,n,o)=>{if(Hn(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return sl(e,n,o);n.forEach(s=>{e.options.ns.indexOf(s)<0&&e.options.ns.push(s)}),e.loadLanguages(t,Ay(e,o))},kR=(e,t,n={})=>!t.languages||!t.languages.length?(ol(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(o,s)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&o.services.backendConnector.backend&&o.isLanguageChangingTo&&!s(o.isLanguageChangingTo,e))return!1}}),Hn=e=>typeof e=="string",SR=e=>typeof e=="object"&&e!==null,CR=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,MR={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},IR=e=>MR[e],AR=e=>e.replace(CR,IR);let al={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:AR,transDefaultProps:void 0};const PR=(e={})=>{al={...al,...e}},ER=()=>al;let Py;const $R=e=>{Py=e},_R=()=>Py,DR={type:"3rdParty",init(e){PR(e.options.react),$R(e)}},LR=Oe();class TR{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var Ey={exports:{}},$y={};/**
|
|
1076
|
+
* @license React
|
|
1077
|
+
* use-sync-external-store-shim.production.js
|
|
1078
|
+
*
|
|
1079
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1080
|
+
*
|
|
1081
|
+
* This source code is licensed under the MIT license found in the
|
|
1082
|
+
* LICENSE file in the root directory of this source tree.
|
|
1083
|
+
*/var yr=qf;function RR(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var OR=typeof Object.is=="function"?Object.is:RR,zR=yr.useState,BR=yr.useEffect,FR=yr.useLayoutEffect,jR=yr.useDebugValue;function HR(e,t){var n=t(),o=zR({inst:{value:n,getSnapshot:t}}),s=o[0].inst,a=o[1];return FR(function(){s.value=n,s.getSnapshot=t,ci(s)&&a({inst:s})},[e,n,t]),BR(function(){return ci(s)&&a({inst:s}),e(function(){ci(s)&&a({inst:s})})},[e]),jR(n),n}function ci(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!OR(e,n)}catch{return!0}}function VR(e,t){return t()}var qR=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?VR:HR;$y.useSyncExternalStore=yr.useSyncExternalStore!==void 0?yr.useSyncExternalStore:qR;Ey.exports=$y;var _y=Ey.exports;const QR=(e,t)=>{if(Hn(t))return t;if(SR(t)&&Hn(t.defaultValue))return t.defaultValue;if(typeof e=="function")return"";if(Array.isArray(e)){const n=e[e.length-1];return typeof n=="function"?"":n}return e},UR={t:QR,ready:!1},KR=()=>()=>{},zt=(e,t={})=>{const{i18n:n}=t,{i18n:o,defaultNS:s}=ye(LR)||{},a=n||o||_R();a&&!a.reportNamespaces&&(a.reportNamespaces=new TR),a||ol(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const i=Q(()=>({...ER(),...a?.options?.react,...t}),[a,t]),{useSuspense:l,keyPrefix:c}=i,d=s||a?.options?.defaultNS,f=Hn(d)?[d]:d||["translation"],p=Q(()=>f,f);a?.reportNamespaces?.addUsedNamespaces?.(p);const m=ne(0),h=q(I=>{if(!a)return KR;const{bindI18n:F,bindI18nStore:E}=i,B=()=>{m.current+=1,I()};return F&&a.on(F,B),E&&a.store.on(E,B),()=>{F&&F.split(" ").forEach(O=>a.off(O,B)),E&&E.split(" ").forEach(O=>a.store.off(O,B))}},[a,i]),g=ne(),b=q(()=>{if(!a)return UR;const I=!!(a.isInitialized||a.initializedStoreOnce)&&p.every(D=>kR(D,a,i)),F=t.lng||a.language,E=m.current,B=g.current;if(B&&B.ready===I&&B.lng===F&&B.keyPrefix===c&&B.revision===E)return B;const A={t:a.getFixedT(F,i.nsMode==="fallback"?p:p[0],c),ready:I,lng:F,keyPrefix:c,revision:E};return g.current=A,A},[a,p,c,i,t.lng]),[x,v]=$(0),{t:w,ready:y}=_y.useSyncExternalStore(h,b,b);Y(()=>{if(a&&!y&&!l){const I=()=>v(F=>F+1);t.lng?Wu(a,t.lng,p,I):sl(a,p,I)}},[a,t.lng,p,y,l,x]);const N=a||{},k=ne(null),S=ne(),M=I=>{const F=Object.getOwnPropertyDescriptors(I);F.__original&&delete F.__original;const E=Object.create(Object.getPrototypeOf(I),F);if(!Object.prototype.hasOwnProperty.call(E,"__original"))try{Object.defineProperty(E,"__original",{value:I,writable:!1,enumerable:!1,configurable:!1})}catch{}return E},P=Q(()=>{const I=N,F=I?.language;let E=I;I&&(k.current&&k.current.__original===I?S.current!==F?(E=M(I),k.current=E,S.current=F):E=k.current:(E=M(I),k.current=E,S.current=F));const B=!y&&!l?(...A)=>(ol(a,"USE_T_BEFORE_READY","useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."),w(...A)):w,O=[B,E,y];return O.t=B,O.i18n=E,O.ready=y,O},[w,N,y,N.resolvedLanguage,N.language,N.languages]);if(a&&l&&!y)throw new Promise(I=>{const F=()=>I();t.lng?Wu(a,t.lng,p,F):sl(a,p,F)});return P},Yu={info:Ps,success:Jx,warning:xt,error:ba},GR={info:"text-blue-400",success:"text-green-400",warning:"text-amber-400",error:"text-red-400"},Zu={active:"border-l-blue-400","in-progress":"border-l-amber-400",completed:"border-l-green-400",failed:"border-l-red-400",dismissed:"border-l-foreground-subtle/30"};function WR(e){const t=Math.floor((Date.now()-e)/1e3);if(t<60)return"just now";const n=Math.floor(t/60);if(n<60)return`${String(n)}m ago`;const o=Math.floor(n/60);if(o<24)return`${String(o)}h ago`;const s=Math.floor(o/24);return`${String(s)}d ago`}function Xu({alert:e,onMarkRead:t,onDismiss:n}){const o=e.severity in Yu?e.severity:"info",s=e.status in Zu?e.status:"active",a=Yu[o],i=GR[o],l=Zu[s];return u("div",{className:`flex items-start gap-2.5 px-3 py-2.5 border-l-2 ${l} ${e.read?"opacity-60":""} hover:bg-surface-hover transition-colors`,children:[r(a,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${i}`}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:`text-[11px] font-semibold ${e.read?"text-foreground-subtle":"text-foreground"}`,children:e.title}),!e.read&&r("span",{className:"h-1.5 w-1.5 rounded-full bg-primary shrink-0"})]}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-2",children:e.message}),e.status==="in-progress"&&e.progress!==void 0&&u("div",{className:"mt-1.5 flex items-center gap-2",children:[r("div",{className:"flex-1 h-1 bg-surface-hover rounded-full overflow-hidden",children:r("div",{className:"h-full bg-primary rounded-full transition-all duration-300",style:{width:`${String(Math.min(100,Math.max(0,e.progress)))}%`}})}),u("span",{className:"text-[9px] text-foreground-subtle font-mono shrink-0",children:[String(Math.round(e.progress)),"%"]})]}),r("div",{className:"text-[9px] text-foreground-subtle/60 mt-1",children:WR(e.updatedAt)})]}),u("div",{className:"flex items-center gap-0.5 shrink-0",children:[!e.read&&r("button",{type:"button",onClick:c=>{c.stopPropagation(),t(e.id)},className:"p-1 rounded hover:bg-surface-hover transition-colors",title:"Mark as read",children:r(Ct,{className:"h-3 w-3 text-foreground-subtle"})}),e.status!=="in-progress"&&r("button",{type:"button",onClick:c=>{c.stopPropagation(),n(e.id)},className:"p-1 rounded hover:bg-surface-hover transition-colors",title:"Dismiss",children:r(qe,{className:"h-3 w-3 text-foreground-subtle"})})]})]})}function Ju({variant:e="icon",compact:t=!1}={}){const[n,o]=$(!1),[s,a]=$(!1),i=ne(null),l=ne(null),c=ke(),{data:d=0}=rg(void 0,{staleTime:1e4,refetchInterval:3e4}),{data:f=[],isLoading:p}=ng({limit:50},{enabled:n,staleTime:5e3}),m=s?f:f.filter(I=>!I.read),h=f.filter(I=>I.read).length,g=()=>{c.invalidateQueries({queryKey:[["alerts"]]})},b=og({onSuccess:g}),x=sg({onSuccess:g}),v=ag({onSuccess:g});dt("alert.created",()=>{c.invalidateQueries({queryKey:[["alerts"]]})}),dt("alert.updated",()=>{c.invalidateQueries({queryKey:[["alerts"]]})}),Y(()=>{if(!n)return;const I=F=>{const E=F.target;i.current&&!i.current.contains(E)&&l.current&&!l.current.contains(E)&&o(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[n]);const w=q(I=>{b.mutate({alertId:I})},[b]),y=q(I=>{I&&v.mutate({alertId:I})},[v]),N=q(()=>{x.mutate(void 0),o(!1)},[x]),k=m.filter(I=>I.status==="in-progress"),S=m.filter(I=>I.status!=="in-progress"),[M,P]=$({});return Y(()=>{if(n&&l.current){const I=l.current.getBoundingClientRect();P({position:"fixed",left:I.left,bottom:window.innerHeight-I.top+4,zIndex:9999})}},[n]),u("div",{children:[e==="sidebar"?u("button",{ref:l,type:"button",onClick:()=>o(!n),className:`flex w-full items-center gap-2.5 rounded-md ${t?"justify-center px-0 py-2":"px-2.5 py-1.5"} text-[12px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,title:t?`Alerts${d>0?` (${d})`:""}`:void 0,children:[u("span",{className:"relative inline-flex shrink-0",children:[r(Xe,{className:"h-3.5 w-3.5"}),t&&d>0&&r("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary"})]}),!t&&r("span",{className:"flex-1 text-left",children:"Alerts"}),!t&&d>0&&r("span",{className:"flex items-center justify-center h-4 min-w-4 px-1 rounded-full bg-primary text-primary-foreground text-[9px] font-bold leading-none",children:d>99?"99+":String(d)})]}):u("button",{ref:l,type:"button",onClick:()=>o(!n),className:"relative p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors","aria-label":"Alerts",children:[r(Xe,{className:"h-4.5 w-4.5"}),d>0&&r("span",{className:"absolute -top-0.5 -right-0.5 flex items-center justify-center h-4 min-w-4 px-0.5 rounded-full bg-primary text-primary-foreground text-[9px] font-bold leading-none",children:d>99?"99+":String(d)})]}),n&&vo(u("div",{ref:i,style:M,className:"w-80 max-h-[28rem] bg-surface border border-border rounded-lg shadow-xl flex flex-col overflow-hidden",children:[u("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border shrink-0",children:[r("span",{className:"text-[12px] font-semibold text-foreground",children:"Alerts"}),u("div",{className:"flex items-center gap-2",children:[h>0&&u("label",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle cursor-pointer select-none",children:[r("input",{type:"checkbox",checked:s,onChange:I=>a(I.target.checked),className:"h-3 w-3 rounded border-border accent-primary cursor-pointer"}),"Show read"]}),d>0&&u("button",{type:"button",onClick:N,className:"flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors",children:[r(uD,{className:"h-3 w-3"}),"Mark all read"]})]})]}),u("div",{className:"flex-1 overflow-y-auto",children:[p&&r("div",{className:"flex items-center justify-center py-8",children:r(Pe,{className:"h-4 w-4 animate-spin text-foreground-subtle"})}),!p&&m.length===0&&u("div",{className:"flex flex-col items-center justify-center py-8 text-foreground-subtle",children:[r(Xe,{className:"h-6 w-6 mb-2 opacity-40"}),r("span",{className:"text-[11px]",children:f.length>0?"No unread alerts":"No alerts"}),f.length>0&&!s&&u("button",{type:"button",onClick:()=>a(!0),className:"text-[10px] text-primary mt-1 hover:underline",children:["Show ",h," read alert",h!==1?"s":""]})]}),k.length>0&&u("div",{className:"border-b border-border",children:[r("div",{className:"px-3 py-1.5 bg-surface-hover/50",children:r("span",{className:"text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:"In Progress"})}),k.map(I=>r(Xu,{alert:I,onMarkRead:w,onDismiss:y},I.id))]}),S.map(I=>r(Xu,{alert:I,onMarkRead:w,onDismiss:y},I.id))]})]}),document.body)]})}function Dy(e){return e.map(t=>({id:t.page.id,addonId:t.addonId,label:t.page.label,icon:t.page.icon,path:t.page.path,remoteName:t.page.remoteName,bundle:t.page.bundle,bundleUrl:t.bundleUrl}))}const ep=new Map,Yo=new Map,tp=new Set;function YR(e){return!e||typeof e!="object"?!1:typeof e.default=="function"}async function ZR(e,t){const n=ep.get(e);if(n)return n;const o=Yo.get(e);if(o)return o;tp.has(e)||(Dl(),fr.registerRemotes([{name:e,entry:t,type:"module"}],{force:!1}),tp.add(e));const s=fr.loadRemote(`${e}/page`).then(a=>{if(!YR(a))throw new Error(`Addon page remote ${e} (${t}) does not expose a default React component on './page'`);return ep.set(e,a.default),Yo.delete(e),a.default}).catch(a=>{throw Yo.delete(e),a});return Yo.set(e,s),s}function XR(){const{pagePath:e}=Oc(),t=Le(),{data:n}=ac(void 0,{staleTime:6e4}),o=Q(()=>n?Dy(n):void 0,[n]),s=o?.find(d=>d.path===`/addon/${e}`),[a,i]=$(null),[l,c]=$(null);return Y(()=>{if(!s)return;c(null),i(null);let d=!1;return ZR(s.remoteName,s.bundleUrl).then(f=>{d||i(()=>f)}).catch(f=>{if(d)return;const p=f instanceof Error?f.message:String(f);c(`Failed to load addon page: ${p}`)}),()=>{d=!0}},[s]),o?s?l?r("div",{className:"flex items-center justify-center h-full text-red-400 text-sm",children:l}):a?r(a,{trpc:t.trpcClient,theme:{isDark:document.documentElement.classList.contains("dark")},navigate:d=>{window.location.href=d}}):r("div",{className:"flex items-center justify-center h-full",children:r("div",{className:"animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full"})}):r("div",{className:"flex items-center justify-center h-full text-foreground-subtle",children:"Addon page not found"}):r("div",{className:"flex items-center justify-center h-full",children:r("div",{className:"animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full"})})}const JR={dark:cy,light:sT,system:xL},e6={gauge:ry,puzzle:Es,bot:nD,cpu:ut,terminal:gy,box:ha,wrench:xT,activity:Io,plug:Yc};function t6(){const e=ht(),t=et(),{user:n,logout:o}=Tr(),s=Ir(),{t:a,i18n:i}=zt(),l=Xn(),c=rh(),d=B_(),f=d!=="connected",p=d==="connecting",[m,h]=$(!1),[g,b]=$(()=>typeof window>"u"?!1:window.localStorage.getItem("camstack:sidebar-collapsed")==="1");Y(()=>{typeof window>"u"||window.localStorage.setItem("camstack:sidebar-collapsed",g?"1":"0")},[g]);const[x,v]=$(()=>{if(typeof window>"u")return new Set;try{const T=window.localStorage.getItem("camstack:sidebar-collapsed-groups");if(!T)return new Set;const W=JSON.parse(T);return Array.isArray(W)?new Set(W.filter(G=>typeof G=="string")):new Set}catch{return new Set}});Y(()=>{typeof window>"u"||window.localStorage.setItem("camstack:sidebar-collapsed-groups",JSON.stringify([...x]))},[x]),Y(()=>{c&&window.localStorage.getItem("camstack:sidebar-collapsed")===null&&b(!0)},[c]);const{data:w=[]}=lc(void 0,{staleTime:3e4,refetchInterval:3e4}),y=w.length,N=ke(),k=ne(Date.now()),S=3e4,M=2e3,{data:P}=ac(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:T=>{const W=T.state.data;return W&&W.length>0||Date.now()-k.current>=S?!1:M}}),I=Q(()=>P?Dy(P):[],[P]);dt("addon.page-ready",()=>{N.invalidateQueries({queryKey:[["addonPages","listPages"]]})});const F=()=>{o(),t("/login")},E=T=>!!(e.pathname===T||e.pathname.startsWith(T+"/")),O=["/pipeline","/timeline"].some(T=>e.pathname===T||e.pathname.startsWith(T+"/")),A=()=>{const T=i.language==="en"?"it":"en";i.changeLanguage(T)},D=[{label:a("nav.devices","Devices"),icon:gr,path:"/devices"},{label:a("nav.integrations"),icon:Yc,path:"/integrations"},{label:a("nav.timeline","Timeline"),icon:SD,path:"/timeline"},{label:a("nav.pipeline","Pipeline"),icon:oy,path:"/pipeline"}],_=[{label:a("system.identity","Identity & Access"),icon:iy,path:"/system/identity"},{label:a("system.network","Network"),icon:br,path:"/system/network"},{label:a("system.data","Data"),icon:ty,path:"/system/data"},{label:a("system.cluster","Cluster"),icon:an,path:"/system/cluster"},{label:a("system.addons"),icon:Es,path:"/system/addons"},{label:a("system.addonSettings","Addon Settings"),icon:wt,path:"/system/settings"},{label:a("system.logs","Logs"),icon:Xe,path:"/system/logs"}],R=s?.mode??"system",L={dark:a("theme.dark"),light:a("theme.light"),system:a("theme.system")},z=g&&!l,j=(T,W="md")=>`flex w-full items-center gap-2.5 rounded-md ${z?"justify-center px-0 py-2":"px-2.5 py-1.5"} ${W==="lg"?"text-[13px] font-medium":"text-[12px]"} transition-all ${T?W==="lg"?"bg-primary/12 text-primary shadow-sm shadow-primary/5":"bg-primary/12 text-primary":"text-foreground-subtle hover:bg-surface-hover hover:text-foreground"}`,H=u(ve,{children:[u("div",{className:`flex h-14 items-center border-b border-border ${z?"justify-center px-1":"pl-3 pr-4 gap-2"}`,children:[!z&&r("img",{src:s?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack Admin",className:"h-9 flex-1 min-w-0"}),!l&&r("button",{onClick:()=>b(T=>!T),className:`p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle transition-colors flex-shrink-0 ${z?"":"mr-2"}`,"aria-label":g?"Expand sidebar":"Collapse sidebar",title:g?"Expand sidebar":"Collapse sidebar",children:g?r(Mt,{className:"h-4 w-4"}):r(Uc,{className:"h-4 w-4"})})]}),u("nav",{className:`flex-1 overflow-y-auto py-3 ${z?"px-1.5":"px-2"} space-y-0.5`,children:[(()=>{const T=E("/dashboard");return u("button",{"data-testid":"nav-dashboard",onClick:()=>{t("/dashboard"),h(!1)},className:j(T,"lg"),title:z?a("nav.dashboard"):void 0,children:[r(ay,{className:`h-4 w-4 shrink-0 ${T?"text-primary":""}`}),!z&&a("nav.dashboard")]})})(),!z&&r("div",{className:"pt-4 pb-1.5 px-2.5",children:r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("nav.camerasSection","Cameras")})}),z&&r("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),D.map(T=>{const W=T.icon,G=E(T.path),ee=`nav-${T.path.replace(/^\//,"").replace(/\//g,"-")}`;return u("button",{"data-testid":ee,onClick:()=>{t(T.path),h(!1)},className:j(G),title:z?T.label:void 0,children:[r(W,{className:`h-3.5 w-3.5 shrink-0 ${G?"text-primary":""}`}),!z&&T.label]},T.path)}),!z&&r("div",{className:"pt-4 pb-1.5 px-2.5",children:r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("system.title")})}),z&&r("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),_.map(T=>{const W=T.icon,G=E(T.path),ee=T.path==="/system/addons",se=`nav-${T.path.replace(/^\//,"").replace(/\//g,"-")}`;return u("button",{"data-testid":se,onClick:()=>{t(T.path),h(!1)},className:j(G),title:z?T.label:void 0,children:[r(W,{className:`h-3.5 w-3.5 shrink-0 ${G?"text-primary":""}`}),!z&&u(ve,{children:[r("span",{className:"flex-1 text-left",children:T.label}),ee&&y>0&&r("span",{className:"ml-auto rounded-full bg-primary px-1.5 py-0.5 text-[9px] font-bold text-primary-foreground leading-none",children:y})]}),z&&ee&&y>0&&r("span",{className:"absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary"})]},T.path)}),I&&I.length>0&&!z&&r("div",{className:"pt-4 pb-1.5 px-2.5",children:r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("nav.addonPages","Addon Pages")})}),z&&I&&I.length>0&&r("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),I?.map(T=>{const W=E(T.path),G=e6[T.icon]??Es;return u("button",{onClick:()=>{t(T.path),h(!1)},className:j(W),title:z?T.label:void 0,children:[r(G,{className:`h-3.5 w-3.5 shrink-0 ${W?"text-primary":""}`}),!z&&T.label]},T.id)})]}),u("div",{className:`border-t border-border ${z?"p-1.5":"p-2"} space-y-0.5`,children:[u("button",{onClick:A,title:a("language.select"),className:j(!1),children:[r(XD,{className:"h-3.5 w-3.5 shrink-0"}),!z&&r("span",{children:i.language==="en"?a("language.en"):a("language.it")})]}),u("button",{onClick:()=>s?.toggleMode(),className:j(!1),title:z?L[R]:void 0,children:[(()=>{const T=JR[R];return r(T,{className:"h-3.5 w-3.5 shrink-0"})})(),!z&&r("span",{children:L[R]})]}),r(Ju,{variant:"sidebar",compact:z}),u("button",{onClick:F,className:j(!1).replace("hover:text-foreground","hover:text-danger"),title:z?n?.username??"Logout":void 0,children:[r(ly,{className:"h-3.5 w-3.5 shrink-0"}),!z&&r("span",{className:"truncate",children:n?.username??"User"})]})]})]});return u("div",{className:"flex h-screen bg-background text-foreground",children:[!l&&r("aside",{className:`flex flex-col border-r border-border bg-surface/80 backdrop-blur-sm shrink-0 transition-[width] duration-150 ease-out ${z?"w-12":"w-48"}`,children:H}),l&&r(Kl,{open:m,onClose:()=>h(!1),width:"w-64",children:H}),u("div",{className:"flex flex-1 flex-col min-w-0",children:[f&&u("div",{className:"flex items-center justify-center gap-2 bg-danger/90 px-3 py-2 text-[12px] font-medium text-white shrink-0",children:[r(yy,{className:"h-3.5 w-3.5"}),r("span",{children:p?a("connection.reconnecting","Reconnecting…"):a("connection.disconnected","Server unreachable — reconnecting…")}),r(Pe,{className:"h-3.5 w-3.5 animate-spin"})]}),l&&u("header",{className:"flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm",children:[r("button",{onClick:()=>h(!0),className:"p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors","aria-label":"Open menu",children:r(fL,{className:"h-5 w-5"})}),r("div",{className:"flex-1 flex justify-center",children:r("img",{src:s?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack",className:"h-7"})}),r(Ju,{})]}),u("main",{className:`relative flex-1 min-h-0 bg-background ${O?"overflow-hidden":"overflow-auto"}`,children:[f&&r("div",{className:"absolute inset-0 z-40 bg-background/60 backdrop-blur-[2px]"}),r(Z$,{})]})]})]})}function n6(){const{login:e}=Tr(),t=Ir(),n=et(),[o,s]=$(""),[a,i]=$(""),[l,c]=$(!1),[d,f]=$(""),[p,m]=$(!1),h=async g=>{g.preventDefault(),f(""),m(!0);try{await e(o,a),n(a==="changeme"?"/change-password":"/dashboard",{replace:!0})}catch(b){f(b instanceof Error?b.message:"Login failed")}finally{m(!1)}};return r("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:u("div",{className:"w-full max-w-sm",children:[r("div",{className:"flex justify-center mb-8",children:r("img",{src:t?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack Admin",className:"h-12"})}),u("form",{onSubmit:h,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[d&&r("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:d}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"Username"}),r("input",{"data-testid":"login-username",type:"text",placeholder:"Username",value:o,onChange:g=>s(g.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all",autoFocus:!0})]}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"Password"}),u("div",{className:"relative",children:[r("input",{"data-testid":"login-password",type:l?"text":"password",placeholder:"Password",value:a,onChange:g=>i(g.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all"}),r("button",{type:"button",onClick:()=>c(!l),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors",tabIndex:-1,children:l?r(ny,{className:"h-4 w-4"}):r(xa,{className:"h-4 w-4"})})]})]}),r("button",{"data-testid":"login-submit",type:"submit",disabled:p||!o||!a,className:"w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all",children:p?u("span",{className:"flex items-center justify-center gap-2",children:[r("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground/30 border-t-primary-foreground"}),"Logging in..."]}):"Log in"})]}),r(r6,{}),r("p",{className:"mt-6 text-center text-[10px] text-foreground-subtle/50",children:"CamStack v0.1.0"})]})})}function r6(){const t=(dc().data??[]).filter(n=>n.enabled&&n.hasRedirectFlow&&n.kind!=="local");return t.length===0?null:u("div",{className:"mt-6 space-y-3",children:[u("div",{className:"flex items-center gap-3",children:[r("div",{className:"h-px flex-1 bg-border"}),r("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"Or continue with"}),r("div",{className:"h-px flex-1 bg-border"})]}),r("div",{className:"space-y-2",children:t.map(n=>u("a",{href:`/addon/${encodeURIComponent(n.addonId)}/start`,className:"flex items-center justify-center gap-2 w-full rounded-lg border border-border bg-surface px-4 py-2.5 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors",children:[r(xr,{className:"h-4 w-4 text-primary"}),n.displayName]},n.addonId))})]})}const np=8;function o6(){const{user:e,mustChangePassword:t,clearMustChangePassword:n,logout:o}=Tr(),s=Ir(),a=et(),[i,l]=$(""),[c,d]=$(""),[f,p]=$(!1),[m,h]=$(""),g=kc({onSuccess:()=>{n(),a("/dashboard",{replace:!0})},onError:x=>{h(x instanceof Error?x.message:"Could not change password")}}),b=async x=>{if(x.preventDefault(),h(""),!e){h("Not signed in");return}if(i.length<np){h(`Password must be at least ${np} characters`);return}if(i!==c){h("The two passwords do not match");return}if(i==="changeme"){h("Choose a password different from the seed default");return}g.mutate({id:e.id,newPassword:i})};return r("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:u("div",{className:"w-full max-w-sm",children:[r("div",{className:"flex justify-center mb-8",children:r("img",{src:s?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack Admin",className:"h-12"})}),u("form",{onSubmit:b,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[u("div",{className:"space-y-1",children:[r("h1",{className:"text-sm font-semibold text-foreground",children:"Set a new password"}),r("p",{className:"text-xs text-foreground-subtle",children:t?"You must rotate the seed password before continuing.":"Choose a new password for your account."})]}),m&&r("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:m}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"New password"}),u("div",{className:"relative",children:[r("input",{"data-testid":"change-password-new",type:f?"text":"password",value:i,onChange:x=>l(x.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all",autoFocus:!0}),r("button",{type:"button",onClick:()=>p(!f),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors",tabIndex:-1,children:f?r(ny,{className:"h-4 w-4"}):r(xa,{className:"h-4 w-4"})})]})]}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"Confirm new password"}),r("input",{"data-testid":"change-password-confirm",type:f?"text":"password",value:c,onChange:x=>d(x.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all"})]}),r("button",{"data-testid":"change-password-submit",type:"submit",disabled:g.isPending||!i||!c,className:"w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all",children:g.isPending?"Saving…":"Save and continue"}),t&&r("button",{type:"button",onClick:()=>{o(),a("/login",{replace:!0})},className:"w-full text-xs text-foreground-subtle hover:text-foreground transition-colors",children:"Sign out instead"})]})]})})}function s6(){const e=et();return u("div",{className:"flex min-h-screen flex-col items-center justify-center bg-background text-foreground p-4",children:[r("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-danger/10 mb-4",children:r(WL,{className:"h-8 w-8 text-danger"})}),r("h1",{className:"text-xl font-bold",children:"Access Denied"}),r("p",{className:"mt-2 text-sm text-foreground-subtle",children:"You don't have permission to access this page."}),r("button",{onClick:()=>e("/dashboard"),className:"mt-6 rounded-lg bg-primary px-5 py-2.5 text-sm font-medium text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg transition-all",children:"Go to Dashboard"})]})}const Ly="camstack:dashboard-layout",di={version:1,widgets:[]};function a6(){try{const e=localStorage.getItem(Ly);if(!e)return di;const t=JSON.parse(e);return t&&t.version===1&&Array.isArray(t.widgets)?{version:1,widgets:t.widgets}:di}catch{return di}}function i6(e){try{localStorage.setItem(Ly,JSON.stringify(e))}catch{}}function l6(){const e=typeof crypto<"u"?crypto:void 0;return e?.randomUUID?e.randomUUID():`widget-${Date.now().toString(36)}-${Math.floor(Math.random()*1e6).toString(36)}`}function c6(){const[e,t]=$(a6),[n,o]=$(!1),s=ux(),a=Q(()=>s.filter(d=>d.hosts.includes("dashboard")),[s]),i=q(d=>{t(d),i6(d)},[]),l=q(d=>{i({version:1,widgets:[...e.widgets,d]})},[e,i]),c=q(d=>{i({version:1,widgets:e.widgets.filter(f=>f.instanceId!==d)})},[e,i]);return u("div",{className:"p-4",children:[u("div",{className:"flex items-center justify-between mb-4",children:[r("h1",{className:"text-lg font-semibold text-foreground",children:"Dashboard"}),u("button",{onClick:()=>o(!0),className:"flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors",children:[r(Ot,{className:"h-3.5 w-3.5"}),"Add widget"]})]}),e.widgets.length===0?r(d6,{onAdd:()=>o(!0)}):r("div",{className:"grid grid-cols-12 gap-3 auto-rows-[minmax(80px,_auto)]",children:e.widgets.map(d=>r(u6,{entry:d,onRemove:()=>c(d.instanceId)},d.instanceId))}),n&&r(f6,{widgets:a,onClose:()=>o(!1),onAdd:d=>{l(d),o(!1)}})]})}function d6({onAdd:e}){return u("div",{className:"flex flex-col items-center justify-center py-24 text-foreground-subtle",children:[r("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-surface border border-border mb-4",children:r(ay,{className:"h-8 w-8 text-foreground-subtle/40"})}),r("p",{className:"text-sm font-medium text-foreground/70",children:"Your dashboard is empty"}),r("p",{className:"text-xs text-foreground-subtle mt-1 mb-4",children:"Add widgets to monitor your cameras and system"}),u("button",{onClick:e,className:"flex items-center gap-1.5 rounded-lg bg-primary px-4 py-2 text-xs font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg transition-all",children:[r(Ot,{className:"h-3.5 w-3.5"}),"Add your first widget"]})]})}function u6({entry:e,onRemove:t}){const n=p6(e.columns),o=Math.max(1,Math.min(12,e.rows));return u("div",{className:"relative group rounded-lg border border-border bg-surface overflow-hidden flex flex-col",style:{gridColumn:`span ${n} / span ${n}`,gridRow:`span ${o} / span ${o}`},children:[r("button",{type:"button",onClick:t,title:"Remove widget",className:"absolute right-1.5 top-1.5 z-10 inline-flex h-5 w-5 items-center justify-center rounded-md border border-border/60 bg-surface/80 text-foreground-subtle opacity-0 group-hover:opacity-100 hover:bg-danger/10 hover:text-danger hover:border-danger/40 transition-all",children:r(qe,{className:"h-3 w-3"})}),r("div",{className:"flex-1 min-h-0 overflow-auto p-2",children:r(it,{widgetId:e.widgetId,host:"dashboard",instanceId:e.instanceId,config:e.config,deviceId:e.deviceId,size:e.size,columns:e.columns,rows:e.rows})})]})}function p6(e){return!Number.isFinite(e)||e<1?6:Math.min(12,Math.floor(e))}function f6({widgets:e,onClose:t,onAdd:n}){const[o,s]=$(null);return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:t,children:u("div",{className:"w-full max-w-2xl rounded-xl border border-border bg-surface p-5 shadow-2xl shadow-black/20",onClick:a=>a.stopPropagation(),children:[u("div",{className:"flex items-center justify-between mb-4",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:o?`Configure: ${o.label}`:"Add widget"}),r("button",{onClick:t,className:"p-1 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",children:r(qe,{className:"h-4 w-4"})})]}),o===null?r(m6,{widgets:e,onSelect:s}):r(h6,{widget:o,onCancel:()=>s(null),onAdd:n})]})})}function m6({widgets:e,onSelect:t}){return e.length===0?r("div",{className:"text-center py-8 text-xs text-foreground-subtle italic",children:"No dashboard-host widgets registered. Make sure the contributing addons are enabled and have rebuilt their widget bundles."}):r("div",{className:"grid grid-cols-2 gap-2 max-h-96 overflow-auto",children:e.map(n=>u("button",{onClick:()=>t(n),className:"flex flex-col rounded-lg border border-border p-3 text-left hover:bg-surface-hover hover:border-primary/30 transition-all group",children:[r("span",{className:"text-xs font-medium text-foreground block",children:n.label}),r("span",{className:"text-[10px] text-foreground-subtle truncate",title:n.widgetId,children:n.widgetId}),n.description&&r("span",{className:"text-[10px] text-foreground-subtle mt-1 line-clamp-2",children:n.description})]},n.widgetId))})}function h6({widget:e,onCancel:t,onAdd:n}){const[o,s]=$(e.defaultSize),[a,i]=$(e.defaultColumns),[l,c]=$(e.defaultRows),[d,f]=$(null),{data:p}=Jn({},{enabled:e.requires.deviceContext,staleTime:3e4}),m=!e.requires.deviceContext||d!==null&&d>0,h=()=>{if(!m)return;const g={instanceId:l6(),widgetId:e.widgetId,size:o,columns:a,rows:l,...e.requires.deviceContext&&d!==null?{deviceId:d}:{}};n(g)};return u("div",{className:"space-y-3",children:[u("div",{children:[r("label",{className:"block text-[11px] font-medium text-foreground-subtle mb-1",children:"Size"}),r("div",{className:"flex items-center gap-1",children:e.allowedSizes.map(g=>r("button",{onClick:()=>s(g),className:`px-3 py-1 rounded-md text-[11px] font-medium border transition-colors ${o===g?"bg-primary/10 text-primary border-primary/30":"border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground"}`,children:g.toUpperCase()},g))})]}),u("div",{className:"grid grid-cols-2 gap-3",children:[r(rp,{label:"Columns (1-12)",value:a,min:1,max:12,onChange:i}),r(rp,{label:"Rows (1-12)",value:l,min:1,max:12,onChange:c})]}),e.requires.deviceContext&&u("div",{children:[r("label",{className:"block text-[11px] font-medium text-foreground-subtle mb-1",children:"Device"}),u("select",{value:d??"",onChange:g=>f(g.target.value===""?null:Number(g.target.value)),className:"w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none",children:[r("option",{value:"",children:"— select a device —"}),(p??[]).map(g=>u("option",{value:g.id,children:[g.name??g.stableId," (#",g.id,")"]},g.id))]})]}),u("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-border",children:[r("button",{onClick:t,className:"px-3 py-1.5 rounded-md text-xs font-medium border border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors",children:"Back"}),r("button",{disabled:!m,onClick:h,className:"px-3 py-1.5 rounded-md text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Add to dashboard"})]})]})}function rp({label:e,value:t,min:n,max:o,onChange:s}){return u("div",{children:[r("label",{className:"block text-[11px] font-medium text-foreground-subtle mb-1",children:e}),r("input",{type:"number",min:n,max:o,value:t,onChange:a=>{const i=Number(a.target.value);Number.isFinite(i)&&s(Math.max(n,Math.min(o,Math.floor(i))))},className:"w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none"})]})}function g6(){return r(c6,{})}function It({icon:e,title:t,subtitle:n,actions:o,children:s}){return u("div",{className:"p-6 space-y-4",children:[u("div",{className:"flex items-center justify-between gap-4",children:[u("div",{className:"min-w-0",children:[u("h1",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e&&r(e,{className:"h-4 w-4 text-foreground-subtle"}),t]}),n&&r("p",{className:"text-xs text-foreground-subtle mt-0.5",children:n})]}),o&&r("div",{className:"shrink-0 flex items-center gap-2",children:o})]}),s]})}const op=["camera","hub","nvr","light","siren","switch","sensor","thermostat","button","generic"];function b6(){const{t:e}=zt(),t=et(),n=Le();yt(["deviceManager"],["device.registered","device.unregistered","device.online","device.offline","device.disabled","device.enabled"]),yt(["integrations"],["integration.enabled","integration.disabled","integration.deleted","provider.started","provider.stopped","addon.installed","addon.uninstalled","addon.started","addon.stopped"]);const{data:o}=Jn({},{staleTime:3e4}),{data:s}=sa(void 0,{staleTime:3e4}),a=Q(()=>o??[],[o]),{activeDevices:i,orphanDevices:l}=Q(()=>{const h=new Set((s??[]).map(k=>k.addonId)),g=k=>typeof k.addonId=="string"&&k.addonId.length>0&&!h.has(k.addonId),b=new Set;for(const k of a)g(k)&&b.add(k.id);const x=new Set(b),v=new Map;for(const k of a)v.set(k.id,k);const w=(k,S=0)=>{if(S>32)return!1;if(b.has(k.id))return!0;if(k.parentDeviceId==null)return!1;const M=v.get(k.parentDeviceId);return M?w(M,S+1):!1};for(const k of a)w(k)&&x.add(k.id);const y=[],N=[];for(const k of a)x.has(k.id)?N.push(k):y.push(k);return{activeDevices:y,orphanDevices:N}},[a,s]),c=Q(()=>{const h=new Map;for(const g of a)h.set(g.id,{id:g.id,name:g.name??g.stableId??`#${String(g.id)}`});return h},[a]),d=q(h=>c.get(h)??null,[c]),f=Q(()=>(s??[]).map(h=>({id:h.addonId,name:h.name??h.addonId,icon:r(cn,{type:h.addonId,size:"sm"})})),[s]),p=q(h=>r(cn,{type:h,size:"sm"}),[]),m=q(h=>t(`/devices/${String(h)}`),[t]);return u(It,{icon:gr,title:e("nav.devices","Devices"),children:[r(ao,{devices:i,trpc:n.trpcClient,filters:{types:op,addons:f},resolveIntegrationIcon:p,resolveParent:d,onNavigate:m}),l.length>0&&u("div",{className:"mt-6 space-y-2",children:[u("div",{className:"flex items-baseline gap-2",children:[r(xt,{className:"h-3.5 w-3.5 text-warning shrink-0"}),r("h2",{className:"text-sm font-semibold text-foreground",children:"Orphan devices"}),u("span",{className:"text-[10px] text-foreground-subtle",children:[l.length," device",l.length===1?"":"s"," pointing at integrations no longer registered"]})]}),u("div",{className:"rounded-lg border border-warning/30 bg-warning/5 p-2",children:[r("p",{className:"text-[11px] text-foreground-subtle px-2 pb-2",children:"These devices reference an addonId that has no matching integration. Delete them, or re-install the missing integration to bring them back online. The provider scope (`addonId`) shown beside each row is what's failing to resolve."}),r(ao,{devices:l,trpc:n.trpcClient,filters:{types:op,addons:f},urlScope:"nested",lsKey:"devices:orphan",resolveIntegrationIcon:p,resolveParent:d,onNavigate:m})]})]})]})}function x6({onSelect:e,onClose:t,pendingAddonId:n=null}){const{t:o}=zt(),s=et(),{data:a,isLoading:i}=Og();if(i)return r("div",{className:"space-y-2 p-2",children:[1,2,3].map(c=>r("div",{className:"h-14 rounded-lg bg-surface animate-pulse"},c))});const l=n!==null;return u("div",{className:"space-y-2",children:[(a??[]).map(c=>{const d=c.instanceMode==="unique"&&c.existingInstances.length>0,f=n===c.addonId,p=l;return u("button",{disabled:p,onClick:()=>{if(!p)if(d){const m=c.existingInstances[0].id;t(),s(`/integrations/${m}`)}else e(c.addonId,c.instanceMode,c.discoveryMode,c.name)},className:"flex w-full items-center gap-3 rounded-lg border border-border bg-surface p-3 text-left hover:border-foreground-subtle/30 transition-colors disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-border",children:[c.iconUrl?r("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0",style:{backgroundColor:`${c.color}15`},children:r("img",{src:c.iconUrl,alt:"",className:"h-5 w-5"})}):r("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0",style:{backgroundColor:`${c.color}15`},children:r("span",{className:"text-sm",style:{color:c.color},children:"◉"})}),u("div",{className:"flex-1 min-w-0",children:[r("p",{className:"text-xs font-semibold text-foreground",children:c.name}),c.description&&r("p",{className:"text-[10px] text-foreground-subtle mt-0.5 truncate",children:c.description})]}),f?r(Pe,{className:"h-4 w-4 animate-spin text-primary flex-shrink-0"}):d?u("span",{className:"flex items-center gap-1 text-[10px] font-medium text-foreground-subtle",children:[r(wt,{className:"h-3 w-3"}),o("integrations.manage")]}):r(Mt,{className:"h-4 w-4 text-foreground-subtle flex-shrink-0"})]},c.addonId)}),(a??[]).length===0&&r("div",{className:"py-8 text-center text-xs text-foreground-subtle",children:o("integrations.noProviders")})]})}function y6(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function sp(e,t){if(e!==void 0)return t&&y6(e)?t(e):e}function v6({section:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,probeResults:i,onAction:l}){const[c,d]=$(e.defaultCollapsed??!1),f=e.style==="accordion";if(e.fields.reduce((b,x)=>b+(Sc(x,t,e.fields)?1:0),0)===0)return null;const m=e.columns??2,h=m===1?"grid-cols-1":m===3?"grid-cols-1 @[420px]:grid-cols-2 @[680px]:grid-cols-3":m===4?"grid-cols-1 @[420px]:grid-cols-2 @[900px]:grid-cols-4":"grid-cols-1 @[480px]:grid-cols-2",g=!e.title&&!e.description;return u("div",{className:"@container rounded-lg border border-border bg-surface p-3",style:{containerType:"inline-size"},children:[!g&&u("div",{className:["flex items-center justify-between mb-2",f?"cursor-pointer":""].join(" "),onClick:f?()=>d(b=>!b):void 0,children:[u("div",{children:[e.title&&r("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:sp(e.title,s)}),e.description&&r("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:sp(e.description,s)})]}),f&&r("span",{className:"text-foreground-subtle text-xs ml-2",children:c?"▸":"▾"})]}),!c&&r("div",{className:`grid ${h} gap-x-3 gap-y-2.5`,children:e.fields.map(b=>r(tr,{field:b,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i?.[b.key],allFields:e.fields,onAction:l},b.key))})]})}function Nn({schema:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,probeResults:i,onClearProbe:l,onAction:c}){const d=(f,p)=>{n({...t,[f]:p}),l?.(f)};return r("div",{className:"space-y-4",children:e.sections.map((f,p)=>r(v6,{section:f,values:t,onChange:d,disabled:o,translationFn:s,onTestField:a,probeResults:i,onAction:c},`${f.id}-${p}`))})}function w6({addonId:e,configSchema:t,onSave:n,onBack:o}){const{t:s}=zt(),[a,i]=$(""),[l,c]=$({}),[d,f]=$(null),p=zg({onSuccess:m=>f(m),onError:m=>f({success:!1,error:String(m)})});return u("div",{className:"space-y-4",children:[u("div",{children:[r("label",{className:"block text-[11px] font-medium text-foreground mb-1",children:s("integrations.integrationName")}),r("input",{type:"text",value:a,onChange:m=>i(m.target.value),placeholder:s("integrations.integrationNamePlaceholder"),className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:border-primary/50"})]}),t&&r(Nn,{schema:t,values:l,onChange:c}),d&&r("div",{className:`rounded-lg border px-3 py-2 text-xs ${d.success?"border-success/30 bg-success/5 text-success":"border-danger/30 bg-danger/5 text-danger"}`,children:d.success?s("integrations.connectionSuccess"):`${s("integrations.errorPrefix")} ${d.error}`}),u("div",{className:"flex items-center justify-between pt-2",children:[r("button",{onClick:o,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors",children:s("integrations.back")}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>p.mutate({addonId:e,settings:l}),disabled:p.isPending,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:p.isPending?s("integrations.testing"):s("integrations.testConnection")}),r("button",{onClick:()=>n({name:a,config:l}),disabled:!a.trim(),className:"rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:s("integrations.forward")})]})]})]})}function N6({providerId:e,onImport:t,onSkip:n}){const{t:o}=zt(),[s,a]=$(new Set),i=mc(),l=i.data,c=i.isPending||!i.data&&!i.isError;Y(()=>{e&&(i.isPending||i.data||i.mutate({addonId:e}))},[e,i]);function d(p){a(m=>{const h=new Set(m);return h.has(p)?h.delete(p):h.add(p),h})}if(c)return u("div",{className:"flex flex-col items-center py-12",children:[r("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"}),r("p",{className:"mt-3 text-xs text-foreground-subtle",children:o("integrations.searchingDevices")})]});const f=l??[];return u("div",{className:"space-y-4",children:[r("p",{className:"text-xs text-foreground-subtle",children:f.length>0?o("integrations.foundDevices",{count:f.length}):o("integrations.noDevicesFound")}),f.length>0&&r("div",{className:"space-y-1.5 max-h-64 overflow-y-auto",children:f.map(p=>{const m=p.stableId,h=p.suggestedName??m,g=s.has(m);return u("button",{onClick:()=>d(m),className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${g?"border-primary/40 bg-primary/5":"border-border bg-surface hover:border-foreground-subtle/30"}`,children:[r("div",{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${g?"border-primary bg-primary":"border-border"}`,children:g&&r(Ct,{className:"h-3 w-3 text-primary-foreground"})}),r(gr,{className:"h-3.5 w-3.5 text-foreground-subtle flex-shrink-0"}),r("span",{className:"text-xs font-medium text-foreground truncate",children:h})]},m)})}),u("div",{className:"flex items-center justify-between pt-2",children:[r("button",{onClick:n,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors",children:o("integrations.skip")}),f.length>0&&u("button",{onClick:()=>t(Array.from(s)),disabled:s.size===0,className:"rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:[o("integrations.importSelected")," (",s.size,")"]})]})]})}function k6(e){const t=n=>{if(n.type==="separator"||n.type==="info"||n.type==="button")return n;if(n.type==="group")return{...n,fields:n.fields.map(i=>t(i))};const o=n,{value:s,...a}=o;return a};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(n=>({...n,fields:n.fields.map(t)}))}}function S6({open:e,onClose:t}){const{t:n}=zt(),o=et(),s=ke(),[a,i]=$("picker"),[l,c]=$(null),[d,f]=$(null),[p,m]=$("manual"),{data:h}=cc({addonId:l??"",nodeId:"hub"},{enabled:l!=null}),g=Q(()=>h?k6(h):null,[h]),b=Lg({onSuccess:()=>s.invalidateQueries({queryKey:[["integrations"]]})}),x=mc(),v=x.data;Y(()=>{a!=="discovery"||!d||!l||x.isPending||x.data||x.mutate({addonId:l})},[a,d,l,x]);const w=Pg({onSuccess:()=>s.invalidateQueries({queryKey:[["deviceManager"]]})});async function y(O,A,D,_){if(!b.isPending){if(c(O),m(D),A==="unique"){try{const R=await b.mutateAsync({addonId:O,name:_,settings:{}});t(),M(),o(`/integrations/${R.id}`)}catch{}return}i("config")}}async function N(O){if(l)try{const A=await b.mutateAsync({addonId:l,name:O.name,settings:O.config});f(A.id),p==="auto"||p==="both"?i("discovery"):S(A.id)}catch{}}async function k(O){if(l){for(const A of O){const D=v?.find(_=>_.stableId===A);D&&await w.mutateAsync({addonId:l,candidate:D})}S()}}function S(O){const A=O??d??l;t(),M(),A&&o(`/integrations/${A}`)}function M(){i("picker"),c(null),f(null),m("manual")}function P(){t(),M()}if(!e)return null;const I={picker:n("integrations.newIntegration"),config:n("integrations.configureIntegration"),discovery:n("integrations.importDevices")},F=b.isPending,E=F?l:null,B=b.error;return u("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[r("div",{className:"absolute inset-0 bg-black/60",onClick:F?void 0:P}),u("div",{className:"relative z-10 w-full max-w-lg rounded-xl border border-border bg-background shadow-2xl",children:[u("div",{className:"flex items-center justify-between border-b border-border px-5 py-4",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:I[a]}),r("button",{onClick:P,disabled:F,className:"rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:r(qe,{className:"h-4 w-4"})})]}),u("div",{className:"relative px-5 py-4",children:[B&&!F&&r("div",{className:"mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:B instanceof Error?B.message:String(B)}),a==="picker"&&r(x6,{onSelect:y,onClose:P,pendingAddonId:E}),a==="config"&&l&&r(w6,{addonId:l,configSchema:g??null,onSave:N,onBack:()=>i("picker")}),a==="discovery"&&d&&r(N6,{providerId:d,onImport:k,onSkip:S}),F&&u("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background/85 backdrop-blur-sm",children:[r(Pe,{className:"h-6 w-6 animate-spin text-primary"}),r("p",{className:"text-xs font-medium text-foreground",children:n("integrations.creating",{defaultValue:"Creating integration…"})}),r("p",{className:"text-[10px] text-foreground-subtle",children:n("integrations.creatingHint",{defaultValue:"Waiting for the addon to restart and register"})})]})]})]})]})}const ap={running:{bg:"bg-success/10",text:"text-success",dot:"bg-success",label:"Running"},stopped:{bg:"bg-foreground-subtle/10",text:"text-foreground-subtle",dot:"bg-foreground-subtle",label:"Stopped"},error:{bg:"bg-danger/10",text:"text-danger",dot:"bg-danger",label:"Error"},online:{bg:"bg-success/10",text:"text-success",dot:"bg-success",label:"Online"},offline:{bg:"bg-foreground-subtle/10",text:"text-foreground-subtle",dot:"bg-foreground-subtle",label:"Offline"},idle:{bg:"bg-info/10",text:"text-info",dot:"bg-info",label:"Idle"},disabled:{bg:"bg-warning/10",text:"text-warning",dot:"bg-warning",label:"Disabled"},enabled:{bg:"bg-success/10",text:"text-success",dot:"bg-success",label:"Enabled"}};function Na({status:e}){const t=ap[e]??ap.stopped;return u("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[10px] font-medium ${t.bg} ${t.text}`,children:[r("span",{className:`h-1.5 w-1.5 rounded-full ${t.dot}`}),t.label]})}const ui="px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle";function C6({integrations:e,expandedAddonId:t,onToggleExpand:n,onOpenSettings:o,renderExpanded:s}){const a=q(i=>n(i),[n]);return r("div",{className:"overflow-hidden rounded-lg border border-border bg-surface",children:u("table",{className:"w-full table-fixed text-xs",children:[r("thead",{className:"bg-surface-hover/40",children:u("tr",{children:[r("th",{className:K(ui,"w-[60%]"),children:"Integration"}),r("th",{className:K(ui,"w-[15%]"),children:"Devices"}),r("th",{className:K(ui,"w-[25%]"),children:"Status"})]})}),r("tbody",{children:e.map(i=>{const l=t===i.addonId;return r(M6,{integration:i,isExpanded:l,onClick:a,onOpenSettings:o,renderExpanded:s},i.id)})})]})})}function M6({integration:e,isExpanded:t,onClick:n,onOpenSettings:o,renderExpanded:s}){const a=q(c=>{c.stopPropagation(),o(e.id)},[e.id,o]),i=q(()=>{n(e.addonId)},[e.addonId,n]),l=q(c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),i())},[i]);return u(ve,{children:[u("tr",{role:"button",tabIndex:0,"aria-expanded":t,className:K("cursor-pointer border-t border-border transition-colors hover:bg-surface-hover","focus:outline-none focus-visible:ring-1 focus-visible:ring-primary/40",t&&"bg-surface-hover/60"),onClick:i,onKeyDown:l,children:[r("td",{className:"px-3 py-2.5",children:u("div",{className:"flex items-center gap-2.5",children:[t?r(Rt,{className:"h-3.5 w-3.5 flex-shrink-0 text-foreground-subtle"}):r(Mt,{className:"h-3.5 w-3.5 flex-shrink-0 text-foreground-subtle"}),r(cn,{type:e.addonId,size:"sm"}),u("div",{className:"flex min-w-0 flex-col",children:[r("span",{className:"truncate text-xs font-semibold text-foreground",children:e.name}),r("span",{className:"truncate text-[10px] text-foreground-subtle",children:e.addonId})]})]})}),u("td",{className:"px-3 py-2.5 text-[11px] text-foreground-subtle",children:[e.deviceCount," device",e.deviceCount!==1?"s":""]}),r("td",{className:"px-3 py-2.5",children:u("div",{className:"flex items-center justify-between gap-2",children:[r(Na,{status:e.status}),u("button",{type:"button",onClick:a,className:"flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary",title:"Open integration settings",children:[r(wt,{className:"h-3 w-3"}),"Settings"]})]})})]}),t&&r("tr",{className:"border-t border-border bg-surface",children:r("td",{colSpan:3,className:"px-3 py-3",children:s(e.addonId)})})]})}function I6(e){if(!e.enabled)return"disabled";switch(e.processState){case"running":return"running";case"stopped":case"crashed":case"unknown":default:return"stopped"}}const Zo="expand";function A6(){const{t:e}=zt(),t=et(),n=Le(),[o]=qc(),[s,a]=$(!1),i=q(()=>a(!0),[]),l=q(()=>a(!1),[]);yt(["integrations"],["integration.enabled","integration.disabled","integration.deleted","provider.started","provider.stopped","addon.installed","addon.uninstalled","addon.started","addon.stopped","addon.updated"]),yt(["deviceManager"],["device.registered","device.unregistered","device.online","device.offline","device.disabled","device.enabled"]);const{data:c,isLoading:d,refetch:f}=sa(void 0,{staleTime:3e4}),{data:p,isLoading:m,refetch:h}=Jn({},{staleTime:3e4}),g=Q(()=>p??[],[p]),b=Q(()=>c??[],[c]),x=Q(()=>{const O=new Map;for(const A of g)O.set(A.id,{id:A.id,name:A.name??A.stableId??`#${String(A.id)}`});return O},[g]),v=Q(()=>{const O=new Map;for(const A of g){if(A.parentDeviceId!==null&&A.parentDeviceId!==void 0&&!!A.role)continue;const _=A.addonId??"";_&&O.set(_,(O.get(_)??0)+1)}return O},[g]),w=Q(()=>b.map(O=>({id:O.id,addonId:O.addonId,name:O.name,enabled:O.enabled,status:I6(O),deviceCount:v.get(O.addonId)??0})),[b,v]),y=o.get(Zo),N=q(O=>{const A=new URLSearchParams(window.location.search);A.get(Zo)===O?A.delete(Zo):A.set(Zo,O);const _=A.toString(),R=`${window.location.pathname}${_?`?${_}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",R),window.dispatchEvent(new PopStateEvent("popstate"))},[]),k=q(O=>t(`/integrations/${O}`),[t]),S=q(O=>x.get(O)??null,[x]),M=q(O=>r(cn,{type:O,size:"sm"}),[]),P=q(O=>t(`/devices/${String(O)}`),[t]),I=q(O=>r(ao,{devices:g,trpc:n.trpcClient,forceAddon:O,urlScope:"nested",lsKey:`integrations:nested:${O}`,resolveIntegrationIcon:M,resolveParent:S,onNavigate:P}),[g,n.trpcClient,M,S,P]),F=q(()=>{f(),h()},[f,h]),E=d||m,B=b.length>0;return u(It,{icon:Yc,title:e("nav.integrations","Integrations"),actions:u(ve,{children:[r("button",{onClick:F,disabled:E,className:"flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",title:"Refresh",children:r(pt,{className:K("h-3.5 w-3.5",E&&"animate-spin")})}),u("button",{onClick:i,className:"flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm",children:[r(Ot,{className:"h-3.5 w-3.5"}),"New Integration"]})]}),children:[E&&r("div",{className:"space-y-2",children:[1,2,3].map(O=>r("div",{className:"h-12 rounded-lg border border-border bg-surface animate-pulse"},O))}),!E&&!B&&u("div",{className:"flex flex-col items-center py-20 text-foreground-subtle",children:[r("p",{className:"text-sm",children:"No integrations configured."}),r("p",{className:"text-xs mt-1",children:'Click "New Integration" to connect cameras and devices.'})]}),!E&&B&&r(C6,{integrations:w,expandedAddonId:y,onToggleExpand:N,onOpenSettings:k,renderExpanded:I}),r(S6,{open:s,onClose:l})]})}function Ty(e){const t=[];for(const n of e)n.type==="probe"&&t.push(n.key),n.type==="group"&&"fields"in n&&t.push(...Ty(n.fields));return t}function P6(e,t,n){const[o,s]=$("idle"),[a,i]=$({}),l=Q(()=>{const p=[];for(const m of e.sections)p.push(...Ty(m.fields));return p},[e]),c=l.length>0&&n!==void 0,d=q(p=>{i(m=>{if(!m[p])return m;const h={...m};return delete h[p],h})},[]),f=q(async()=>{if(!n)return;const p=l.filter(b=>{const x=t[b];return x!=null&&String(x).trim()!==""});if(p.length===0)return;s("testing");const m={};for(const b of p)m[b]={status:"probing"};i(m);const h=await Promise.allSettled(p.map(async b=>{try{const x=await n(b,t[b]);return{key:b,result:x}}catch(x){const w={status:"error",error:x instanceof Error?x.message:String(x)};return{key:b,result:w}}})),g={};for(const b of h)if(b.status==="fulfilled"){const{key:x,result:v}=b.value;g[x]={status:v.status==="ok"?"ok":"error",result:v}}i(g),s("idle")},[n,l,t]);return{testAllStatus:o,hasProbeFields:c,probeResults:a,handleTestAll:f,clearProbeResult:d}}function Ry(e){const t=[];for(const n of e)"required"in n&&n.required===!0&&"key"in n&&n.key&&t.push(n.key),n.type==="group"&&"fields"in n&&t.push(...Ry(n.fields));return t}function pi(e){return e==null?!0:typeof e=="string"?e.trim()==="":!1}function il(e,t={}){for(const n of e){if(n.type==="group"&&"fields"in n){il(n.fields,t);continue}"key"in n&&n.key&&"default"in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function ip(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function E6({open:e,integrationId:t,addonId:n,onClose:o}){const{t:s}=zt(),a=ke(),[i,l]=$({}),[c,d]=$(!1),[f,p]=$(null),[m,h]=$(ip),g=Eg({addonId:n,type:at.Camera},{enabled:e}),b=g.data??null;Y(()=>{if(e){const A=b?il(b.sections.flatMap(D=>D.fields)):{};l(A),h(ip()),d(!1),p(null)}},[e,t,b]);const x=Q(()=>({...i,_probeRequestId:m}),[i,m]),v=$g({onSuccess:()=>{a.invalidateQueries({queryKey:[["deviceManager"]]})}}),w=hc(),y=q(async(A,D)=>{d(!0);const _=await w.mutateAsync({addonId:n,type:at.Camera,key:A,value:D,formValues:x});return _.status==="ok"&&_.suggestedValues&&l(R=>{let L=!1;const z={...R};for(const[j,H]of Object.entries(_.suggestedValues??{}))pi(R[j])&&!pi(H)&&(z[j]=H,L=!0);return L?z:R}),_},[w,n,x]),{testAllStatus:N,hasProbeFields:k,probeResults:S,handleTestAll:M,clearProbeResult:P}=P6(b??{sections:[]},i,y);async function I(A){p(null);try{if(await v.mutateAsync({addonId:n,type:at.Camera,config:i}),A){const D=b?il(b.sections.flatMap(_=>_.fields)):{};l(D)}else o()}catch(D){p(D instanceof Error?D.message:String(D))}}if(!e)return null;const E=Ry((b?.sections??[]).flatMap(A=>A.fields)).filter(A=>pi(i[A])),B=E.length===0,O=!g.isLoading&&(g.isError||b===null);return u("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[r("div",{className:"absolute inset-0 bg-black/60",onClick:o}),u("div",{className:"relative z-10 flex w-full max-w-2xl flex-col max-h-[90vh] rounded-xl border border-border bg-background shadow-2xl",children:[u("div",{className:"flex items-center justify-between border-b border-border px-5 py-4 shrink-0",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:s("integrations.addDevice")}),r("button",{onClick:o,className:"rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:r(qe,{className:"h-4 w-4"})})]}),r("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-3",children:g.isLoading?r("div",{className:"flex items-center justify-center py-8",children:r(Pe,{className:"h-5 w-5 animate-spin text-primary"})}):O?u("div",{className:"flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3",children:[r(xt,{className:"h-4 w-4 text-destructive mt-0.5 shrink-0"}),u("div",{className:"space-y-1",children:[r("p",{className:"text-xs font-medium text-destructive",children:"Provider unavailable"}),u("p",{className:"text-xs text-foreground-subtle",children:["The addon ",r("span",{className:"font-mono",children:n})," is not ready or does not support manual device creation. Check that the integration is online and try again."]})]})]}):r(Nn,{schema:b,values:i,onChange:l,onTestField:y,probeResults:S,onClearProbe:P})}),!O&&!g.isLoading&&u("div",{className:"border-t border-border bg-surface/50 shrink-0",children:[u("button",{type:"button",onClick:()=>d(A=>!A),className:"flex w-full items-center justify-between px-5 py-2 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:[u("span",{className:"flex items-center gap-2",children:[r(Xe,{className:"h-3.5 w-3.5"}),"Test logs",r("span",{className:"font-mono text-[9px] opacity-60",children:m.slice(0,14)})]}),r(Rt,{className:`h-3.5 w-3.5 transition-transform ${c?"rotate-180":""}`})]}),c&&r("div",{className:"border-t border-border max-h-64 overflow-hidden",children:r(Wt,{addonId:n,requestId:m,limit:50,maxHeight:"max-h-64",showFilters:!1,showScope:!1,className:"border-0 rounded-none"})})]}),!O&&!g.isLoading&&(f||E.length>0)&&r("div",{className:"border-t border-destructive/30 bg-destructive/5 px-5 py-2 shrink-0",children:u("div",{className:"flex items-start gap-2",children:[r(xt,{className:"h-3.5 w-3.5 text-destructive mt-0.5 shrink-0"}),r("p",{className:"text-[11px] text-destructive",children:f||`Required: ${E.join(", ")}`})]})}),u("div",{className:"flex items-center justify-between border-t border-border px-5 py-3 shrink-0",children:[u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:o,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors",children:s("integrations.cancel")}),!O&&k&&u("button",{type:"button",onClick:M,disabled:N==="testing",className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:[N==="testing"?r(Pe,{className:"h-3.5 w-3.5 animate-spin"}):r(jn,{className:"h-3.5 w-3.5"}),"Test All"]})]}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>I(!0),disabled:O||!B||v.isPending,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:s("integrations.saveAndNew")}),r("button",{onClick:()=>I(!1),disabled:O||!B||v.isPending,className:"rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:v.isPending?s("integrations.saving"):s("integrations.save")})]})]})]})]})}function $6(){const{t:e}=zt(),{integrationId:t}=Oc(),n=ke(),o=et(),s=Le(),[a,i]=$(!1),[l,c]=$(!1),[d,f]=$(!1),[p,m]=$(!1),{data:h,isLoading:g}=_g({id:t??""},{enabled:!!t}),{data:b}=cc({addonId:h?.addonId??"",nodeId:"hub"},{enabled:!!h?.addonId}),x=b!=null&&Array.isArray(b.sections)&&b.sections.some(B=>B.fields.length>0),{data:v}=Jn({},{refetchInterval:5e3}),w=[["integrations","get"],{input:{id:t??""},type:"query"}],y=Tg({onMutate:async B=>{await n.cancelQueries({queryKey:w});const O=n.getQueryData(w);return O!=null&&n.setQueryData(w,{...O,enabled:B.enabled}),{previous:O}},onError:(B,O,A)=>{const D=A;D?.previous!=null&&n.setQueryData(w,D.previous)},onSettled:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),N=Rg({onSuccess:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]}),f(!1),o("/integrations")}}),k=oa({onSuccess:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),S=Q(()=>v??[],[v]),M=Q(()=>{const B=new Map;for(const O of S)B.set(O.id,{id:O.id,name:O.name??O.stableId??`#${String(O.id)}`});return B},[S]),P=q(B=>M.get(B)??null,[M]),I=q(B=>r(cn,{type:B,size:"sm"}),[]),F=q(B=>o(`/devices/${String(B)}`),[o]),E=Q(()=>{const B=h?.addonId;if(!B)return 0;let O=0;for(const A of S)A.addonId!==B||A.parentDeviceId!==null&&A.parentDeviceId!==void 0&&A.role||(O+=1);return O},[S,h?.addonId]);return g?u("div",{className:"p-6",children:[r("div",{className:"h-16 rounded-lg bg-surface animate-pulse mb-4"}),r("div",{className:"h-40 rounded-lg bg-surface animate-pulse"})]}):h?u("div",{className:"p-6 space-y-5",children:[r(Gl,{items:[{label:"Integrations",onClick:()=>o("/integrations")},{label:h.name}]}),u("div",{className:"flex items-center justify-between",children:[u("div",{className:"flex items-center gap-3",children:[r("img",{src:`/api/addon-assets/${h.addonId}/assets/icon.svg`,alt:"",className:"h-8 w-8 rounded-lg",onError:B=>{B.target.style.display="none"}}),u("div",{children:[r("h1",{className:"text-lg font-semibold text-foreground",children:h.name}),u("p",{className:"text-[11px] text-foreground-subtle mt-0.5",children:[h.addonId," · ",E," ",e("integrations.devices")]})]})]}),u("div",{className:"flex items-center gap-3",children:[u("div",{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${y.isPending?"opacity-60":""} ${h.enabled?"border-success/30 bg-success/5":"border-border bg-surface"}`,title:e("integrations.toggleHint",{defaultValue:"Click to toggle"}),children:[r(Hl,{checked:h.enabled,onCheckedChange:B=>y.mutate({id:t,enabled:B}),disabled:y.isPending,"aria-label":h.enabled?"Disable integration":"Enable integration"}),r("span",{className:`text-[11px] font-medium ${h.enabled?"text-success":"text-foreground-subtle"}`,children:h.enabled?"Enabled":"Disabled"}),y.isPending&&r(Pe,{className:"h-3 w-3 animate-spin text-foreground-subtle"})]}),x&&u("button",{onClick:()=>c(!0),className:"flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:[r(wt,{className:"h-3 w-3"}),e("integrations.config")]}),u("button",{onClick:()=>m(!0),className:"flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",title:e("integrations.logs",{defaultValue:"View logs"}),children:[r(Xe,{className:"h-3 w-3"}),e("integrations.logs",{defaultValue:"Logs"})]}),r(Cx,{label:"Restart",icon:pt,title:`Restart "${h.name}"?`,description:`Restarting the addon will briefly disconnect every device backed by it (${E} active). Streams will reconnect automatically.`,confirmLabel:"Restart",triggerVariant:"outline",confirmVariant:"danger",disabled:k.isPending,action:()=>k.mutateAsync({addonId:h.addonId})}),u("button",{onClick:()=>f(!0),className:"flex items-center gap-1.5 rounded-lg border border-danger bg-danger/10 px-3 py-1.5 text-[11px] font-medium text-danger hover:bg-danger hover:text-background transition-colors",title:e("integrations.delete",{defaultValue:"Delete integration"}),children:[r(We,{className:"h-3 w-3"}),e("integrations.delete",{defaultValue:"Delete"})]})]})]}),r(ao,{devices:S,trpc:s.trpcClient,defaultView:"cards",forceAddon:h.addonId,urlScope:"root",lsKey:`integration-detail:${h.addonId}`,resolveIntegrationIcon:I,resolveParent:P,onNavigate:F}),r("button",{onClick:()=>i(!0),className:"fixed bottom-6 right-6 flex h-12 w-12 items-center justify-center rounded-full bg-primary shadow-lg shadow-primary/30 hover:shadow-primary/40 transition-shadow",title:e("integrations.addDevice"),children:r(Ot,{className:"h-5 w-5 text-primary-foreground"})}),a&&t&&r(E6,{open:a,integrationId:t,addonId:h.addonId,onClose:()=>i(!1)}),l&&r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>c(!1),children:u("div",{className:"rounded-xl border border-border bg-surface p-6 shadow-xl w-80",onClick:B=>B.stopPropagation(),children:[r("h2",{className:"text-sm font-semibold text-foreground mb-2",children:e("integrations.providerConfig")}),r("p",{className:"text-[11px] text-foreground-subtle",children:e("integrations.configComingSoon")}),r("button",{onClick:()=>c(!1),className:"mt-4 w-full rounded-lg bg-primary px-3 py-1.5 text-[11px] text-primary-foreground hover:bg-primary/90 transition-colors",children:"Close"})]})}),p&&r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6",onClick:()=>m(!1),children:u("div",{className:"flex flex-col rounded-xl border border-border bg-surface shadow-xl w-full max-w-5xl h-[80vh]",onClick:B=>B.stopPropagation(),children:[u("div",{className:"flex items-center justify-between border-b border-border px-4 py-2.5",children:[u("div",{className:"flex items-center gap-2 min-w-0",children:[r(Xe,{className:"h-4 w-4 text-primary shrink-0"}),r("h2",{className:"text-sm font-semibold text-foreground truncate",children:h.name}),u("span",{className:"text-[10px] text-foreground-subtle font-mono truncate",children:[h.addonId,t?` · ${t}`:""]})]}),r("button",{onClick:()=>m(!1),className:"flex h-7 w-7 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors","aria-label":"Close logs",children:r(qe,{className:"h-4 w-4"})})]}),r("div",{className:"flex-1 min-h-0 overflow-hidden",children:r(Wt,{addonId:h.addonId,limit:200,maxHeight:"max-h-full",showScope:!1,className:"h-full border-0 rounded-none"})})]})}),d&&r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>!N.isPending&&f(!1),children:u("div",{className:"rounded-xl border border-border bg-background p-5 shadow-2xl w-96 space-y-3",onClick:B=>B.stopPropagation(),children:[u("div",{className:"flex items-start gap-3",children:[r("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-danger/10 shrink-0",children:r(xt,{className:"h-4 w-4 text-danger"})}),u("div",{className:"min-w-0",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:e("integrations.deleteTitle",{defaultValue:"Delete integration?"})}),r("p",{className:"mt-1 text-[11px] text-foreground-subtle",children:e("integrations.deleteWarning",{defaultValue:'This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.',name:h.name,count:E})})]})]}),N.error&&r("div",{className:"rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger",children:N.error instanceof Error?N.error.message:String(N.error)}),u("div",{className:"flex items-center justify-end gap-2 pt-1",children:[r("button",{onClick:()=>f(!1),disabled:N.isPending,className:"rounded-lg border border-border px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:e("integrations.cancel",{defaultValue:"Cancel"})}),r("button",{onClick:()=>N.mutate({id:t}),disabled:N.isPending,className:"inline-flex items-center gap-1.5 rounded-lg bg-danger px-3 py-1.5 text-[11px] font-medium text-background hover:bg-danger/90 transition-colors disabled:opacity-60 disabled:cursor-not-allowed",children:N.isPending?u(ve,{children:[r(Pe,{className:"h-3 w-3 animate-spin"}),e("integrations.deleting",{defaultValue:"Deleting…"})]}):u(ve,{children:[r(We,{className:"h-3 w-3"}),e("integrations.confirmDelete",{defaultValue:"Delete integration"})]})})]})]})})]}):u("div",{className:"flex flex-col items-center justify-center py-20 px-6 text-center gap-4",children:[r("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10",children:r(VL,{className:"h-6 w-6 text-foreground-subtle"})}),u("div",{className:"space-y-1 max-w-sm",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:e("integrations.integrationNotFound",{defaultValue:"Integration not found"})}),r("p",{className:"text-[11px] text-foreground-subtle",children:e("integrations.integrationNotFoundHint",{defaultValue:'The integration "{{id}}" does not exist. It may have been deleted, or the URL may be wrong.',id:t??""})})]}),u("button",{onClick:()=>o("/integrations"),className:"inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors",children:[r(Wx,{className:"h-3 w-3"}),e("integrations.backToList",{defaultValue:"Back to integrations"})]})]})}function _6({label:e,color:t,title:n,style:o}){return u("div",{className:"absolute top-1/2 -translate-y-1/2 -translate-x-1/2 z-10 group cursor-pointer",style:o,title:n,children:[r("div",{className:"h-2.5 w-2.5 rounded-full border-2 border-background shadow-sm transition-transform group-hover:scale-150",style:{backgroundColor:t}}),n&&r("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-1.5 hidden group-hover:block z-20 pointer-events-none",children:u("div",{className:"bg-surface border border-border rounded px-2 py-1 text-[10px] text-foreground whitespace-nowrap shadow-lg",children:[r("span",{className:"inline-block h-1.5 w-1.5 rounded-full mr-1 align-middle",style:{backgroundColor:t}}),e]})})]})}const fi=36e5;function D6(e){return String(e).padStart(2,"0")}function L6(e){const t=new Date(e);return`${D6(t.getHours())}:00`}function T6({startMs:e,endMs:t,segments:n,events:o,playheadMs:s,onSeek:a}){const i=ne(null),l=t-e,c=q(h=>Math.max(0,Math.min(100,(h-e)/l*100)),[e,l]);function d(h){if(!i.current)return;const g=i.current.getBoundingClientRect(),b=Math.max(0,Math.min(1,(h.clientX-g.left)/g.width));a(Math.round(e+b*l))}const f=[],p=Math.floor(e/fi),m=Math.ceil(t/fi);for(let h=p;h<=m;h++){const g=h*fi;g<e||g>t||f.push({percent:c(g),label:L6(g)})}return u("div",{className:"select-none",children:[r("div",{className:"relative h-5 mb-1",children:f.map(({percent:h,label:g})=>r("span",{className:"absolute -translate-x-1/2 text-[10px] text-foreground-subtle",style:{left:`${h}%`},children:g},g))}),u("div",{ref:i,className:"relative h-8 rounded bg-surface-hover cursor-pointer overflow-hidden border border-border",onClick:d,onPointerMove:h=>{h.buttons===1&&d(h)},children:[n.map((h,g)=>{const b=c(h.startMs),x=c(h.endMs)-b;return r("div",{className:"absolute top-1 bottom-1 rounded-sm bg-success/60",style:{left:`${b}%`,width:`${Math.max(x,.1)}%`}},g)}),o.map(h=>r(_6,{label:h.label,color:h.color,title:`${h.label} — ${new Date(h.timestampMs).toLocaleTimeString()}`,style:{left:`${c(h.timestampMs)}%`}},h.id)),r("div",{className:"absolute top-0 bottom-0 w-0.5 bg-danger z-20 pointer-events-none",style:{left:`${c(s)}%`},children:r("div",{className:"absolute -top-0.5 left-1/2 -translate-x-1/2 w-2.5 h-2.5 bg-danger rotate-45"})})]})]})}const lp={person:"#f59e0b",vehicle:"#3b82f6",car:"#3b82f6",face:"#a855f7",plate:"#ec4899",animal:"#10b981",motion:"#ef4444",unknown:"#6b7280"};function ll(e){return lp[e.toLowerCase()]??lp.unknown}function R6(e){const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function O6(e){return new Date(e).toISOString().slice(0,10)}function z6(e){return new Date(e+"T00:00:00").getTime()}function B6(e){return[{startMs:e+0*36e5,endMs:e+4*36e5},{startMs:e+6*36e5,endMs:e+10*36e5},{startMs:e+12*36e5,endMs:e+16*36e5},{startMs:e+18*36e5,endMs:e+23*36e5}]}function F6(e){const t=["person","vehicle","face","motion"];return Array.from({length:24},(n,o)=>({id:`placeholder-${o}`,timestampMs:e+Math.floor(Math.random()*24*36e5),label:t[o%t.length],color:ll(t[o%t.length])})).sort((n,o)=>n.timestampMs-o.timestampMs)}function j6(){const{t:e}=zt(),t=R6(new Date),[n,o]=$(t),[s,a]=$(null),[i,l]=$(t+12*36e5),c=n,d=n+24*36e5,{data:f,isLoading:p}=Jn({},{staleTime:3e4}),m=f??[],h=Q(()=>m.filter(N=>{const k=N.type.toLowerCase();return k==="camera"||k.includes("camera")||N.features.some(S=>S.toLowerCase().includes("video")||S.toLowerCase().includes("stream"))}).map(N=>({id:N.id,name:N.name??N.stableId})),[m]),g=s??h[0]?.id??null,{data:b}=Kn({queryKey:["events",g,c],queryFn:()=>Promise.resolve(null),enabled:!!g,staleTime:6e4}),x=Q(()=>{const y=Array.isArray(b)?b:(()=>{const k=Pd(b)?.events;return Array.isArray(k)?k:[]})();return y.length===0?g?F6(c):[]:y.flatMap((N,k)=>{const S=Pd(N);if(!S)return[];const M=String(S.class??S.type??S.label??"unknown").toLowerCase(),P=typeof S.timestamp=="number"?S.timestamp:c;return[{id:String(S.id??k),timestampMs:P,label:M,color:ll(M)}]})},[b,g,c]),v=Q(()=>g?B6(c):[],[g,c]);function w(y){o(N=>N+y*24*36e5),l(N=>N+y*24*36e5)}return u("div",{className:"flex flex-col h-full p-6 gap-5 overflow-hidden",children:[u("div",{className:"flex items-center justify-between gap-4 shrink-0",children:[r("h1",{className:"text-lg font-semibold text-foreground",children:e("nav.timeline","Timeline")}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>w(-1),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",children:r(Uc,{className:"h-4 w-4"})}),u("div",{className:"relative flex items-center",children:[r(Zx,{className:"absolute left-2 h-3.5 w-3.5 text-foreground-subtle pointer-events-none"}),r("input",{type:"date",value:O6(n),onChange:y=>{if(y.target.value){const N=z6(y.target.value);o(N),l(N+12*36e5)}},className:"rounded-lg border border-border bg-surface pl-7 pr-3 py-1.5 text-xs text-foreground focus:outline-none focus:border-primary/50"})]}),r("button",{onClick:()=>w(1),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",disabled:n>=t,children:r(Mt,{className:"h-4 w-4"})})]})]}),u("div",{className:"flex gap-1.5 shrink-0 overflow-x-auto pb-1",children:[p&&r("div",{className:"h-8 w-48 rounded-lg bg-surface animate-pulse"}),!p&&h.length===0&&r("span",{className:"text-xs text-foreground-subtle",children:"No cameras found"}),h.map(y=>{const N=y.id===g;return r("button",{onClick:()=>a(y.id),className:`shrink-0 rounded-lg px-3 py-1.5 text-[12px] font-medium transition-all border ${N?"bg-primary/12 text-primary border-primary/30":"bg-surface text-foreground-subtle border-border hover:bg-surface-hover hover:text-foreground"}`,children:y.name},y.id)})]}),u("div",{className:"relative w-full aspect-video rounded-xl border border-border bg-black shrink-0 overflow-hidden max-h-[45vh]",children:[u("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 text-foreground-subtle",children:[r(Zr,{className:"h-12 w-12 opacity-20"}),r("p",{className:"text-sm opacity-50",children:g?`${h.find(y=>y.id===g)?.name??g} — seek to play`:"Select a camera"})]}),r("div",{className:"absolute top-3 left-3 rounded bg-black/60 px-2 py-1 text-[11px] text-white font-mono",children:new Date(i).toLocaleTimeString()})]}),u("div",{className:"rounded-xl border border-border bg-surface px-4 pt-3 pb-4 shrink-0",children:[u("div",{className:"flex flex-wrap items-center gap-4 mb-3",children:[r("span",{className:"text-[10px] font-semibold text-foreground-subtle uppercase tracking-wider",children:"Timeline"}),u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"inline-block h-2 w-4 rounded-sm bg-success/60"}),r("span",{className:"text-[10px] text-foreground-subtle",children:"Recording"})]}),Array.from(new Set(x.map(y=>y.label))).slice(0,5).map(y=>u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{backgroundColor:ll(y)}}),r("span",{className:"text-[10px] text-foreground-subtle capitalize",children:y})]},y))]}),g?r(T6,{startMs:c,endMs:d,segments:v,events:x,playheadMs:i,onSeek:l}):r("div",{className:"h-8 rounded bg-surface-hover flex items-center justify-center text-xs text-foreground-subtle",children:"Select a camera to view timeline"})]})]})}function H6({selectedNodeId:e,onSelect:t,refreshToken:n}){const{data:o}=In(void 0,{staleTime:3e4}),{data:s}=ia(void 0,{staleTime:3e4}),a=new Map;for(const d of s??[])a.set(d.agentNodeId,(a.get(d.agentNodeId)??0)+1);const i=o??[],l=i.filter(d=>d.isOnline).length,c=i.filter(d=>!d.isOnline).length;return u("div",{className:"flex flex-col h-full",children:[u("button",{type:"button",onClick:()=>t(eo),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===eo?"bg-primary/10 text-primary":"text-foreground hover:bg-surface-hover"}`,children:[r(br,{className:"h-4 w-4 flex-shrink-0"}),u("div",{className:"min-w-0 flex-1",children:[r("div",{className:"text-xs font-semibold truncate",children:"Cluster"}),r("div",{className:"text-[10px] text-foreground-subtle",children:"Balancer + failover + assignments"})]})]}),r("div",{className:"flex-1 overflow-y-auto",children:i.map(d=>{const f=e===d.id,p=a.get(d.id)??0,m=d.isHub?ln:ut;return u("button",{type:"button",onClick:()=>t(d.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${f?"bg-primary/10 text-primary":"text-foreground hover:bg-surface-hover"}`,children:[r(m,{className:"h-4 w-4 flex-shrink-0"}),u("div",{className:"min-w-0 flex-1",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-xs font-semibold truncate",children:d.name}),d.isHub&&r("span",{className:"text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5",children:"hub"}),!d.isOnline&&r("span",{className:"h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0"}),d.isOnline&&r("span",{className:"h-1.5 w-1.5 rounded-full bg-success flex-shrink-0"})]}),u("div",{className:"text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5",children:[u("span",{children:[d.cpuCores," cores"]}),r("span",{children:"•"}),u("span",{children:[Math.round(d.memoryMB/1024)," GB"]}),p>0&&u(ve,{children:[r("span",{children:"•"}),u("span",{className:"inline-flex items-center gap-0.5 text-foreground",children:[r(xy,{className:"h-2.5 w-2.5"}),p]})]})]})]})]},d.id)})}),u("div",{className:"px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between",children:[u("span",{children:[l," online"]}),c>0&&u("span",{className:"text-destructive",children:[c," offline"]})]})]})}function V6({nodeId:e,refreshToken:t}){const{data:n}=In(void 0,{staleTime:3e4}),o=n?.find(i=>i.id===e),a=Ar("pipeline.runner-load-snapshot",i=>i.nodeId===e)?.load??null;return o?u("div",{className:"px-6 py-4 border-b border-border",children:[u("div",{className:"flex items-center gap-2 mb-1",children:[r("h2",{className:"text-base font-semibold text-foreground",children:o.name}),o.isOnline?r("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success",children:"online"}):r("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:"offline"}),o.isHub&&r("span",{className:"text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5",children:"hub"})]}),u("div",{className:"text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap",children:[r("span",{children:o.cpuModel??"CPU"}),r("span",{children:"•"}),u("span",{children:[o.cpuCores," cores"]}),r("span",{children:"•"}),u("span",{children:[Math.round(o.memoryMB/1024)," GB"]}),a&&u(ve,{children:[r("span",{children:"•"}),u("span",{children:[a.attachedCameras," cameras (",a.activeCameras," active)"]}),r("span",{children:"•"}),u("span",{children:[a.avgInferenceTimeMs.toFixed(0),"ms avg inference"]}),r("span",{children:"•"}),u("span",{children:["queue ",a.queueDepthTotal]}),a.hardware.hasGpu&&u(ve,{children:[r("span",{children:"•"}),r("span",{className:"text-success",children:"GPU"})]})]})]})]}):r("div",{className:"px-6 py-4 border-b border-border",children:u("div",{className:"text-xs text-foreground-subtle",children:["Node not found: ",e]})})}function Oy({refreshToken:e,nodeId:t}){const[n,o]=$(new Map),{nodes:s}=Pr();dt("pipeline.camera-metrics-snapshot",p=>{const m=p.data;typeof m?.deviceId=="number"&&o(h=>{const g=new Map(h);return g.set(m.deviceId,m),g})});const{data:a}=Nb(void 0,{staleTime:5e3}),i=Q(()=>{const p=new Map;for(const m of a??[])p.set(m.nodeId,m.deviceCount);return p},[a]),l=Q(()=>{const p=new Map,m=Date.now()-3e4;for(const h of n.values()){if(h.timestamp<m)continue;const g=h.nodeId??"hub",b=p.get(g)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};b.attachedCameras++,h.metrics.phase==="active"&&b.activeCameras++,b.totalFps+=h.metrics.actualFps,b.totalInferenceWeighted+=h.metrics.avgInferenceTimeMs,b.queueDepth+=h.metrics.queueDepth,p.set(g,b)}return p},[n]),c=Q(()=>{const p=new Map;for(const m of s)p.set(m.id,m.shortName);return p},[s]),d=Q(()=>{let p=0,m=0,h=0,g=0,b=0;for(const v of l.values())p+=v.attachedCameras,m+=v.activeCameras,h+=v.totalFps,g+=v.totalInferenceWeighted,b+=v.queueDepth;const x=p>0?g/p:0;return{totalAgents:s.length,onlineAgents:s.filter(v=>v.isOnline).length,attachedCameras:p,activeCameras:m,avgInferenceTimeMs:x,queueDepth:b,totalFps:h}},[l,s]);if(t){const p=l.get(t);return u("div",{className:"@container/liveload",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-2",children:"Live load"}),u("div",{className:"grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3",children:[r(Ht,{label:"FPS",value:p?p.totalFps.toFixed(1):"—"}),r(Ht,{label:"Cameras",value:p?`${p.activeCameras}/${p.attachedCameras}`:"—"}),r(Ht,{label:"Avg infer ms",value:p&&p.attachedCameras>0?(p.totalInferenceWeighted/p.attachedCameras).toFixed(0):"—"}),r(Ht,{label:"Queue",value:p?String(p.queueDepth):"—"}),r(Ht,{label:"Audio",value:String(i.get(t)??"—")})]})]})}const f=[...l.entries()].sort(([p],[m])=>p==="hub"?-1:m==="hub"?1:p.localeCompare(m));return u("div",{className:"@container/liveload",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-2",children:"Live load"}),u("div",{className:"grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3",children:[r(Ht,{label:"Total agents",value:`${d.onlineAgents}/${d.totalAgents}`}),r(Ht,{label:"Cameras",value:`${d.activeCameras}/${d.attachedCameras}`}),r(Ht,{label:"Total FPS",value:d.totalFps.toFixed(1)}),r(Ht,{label:"Avg inference ms",value:d.avgInferenceTimeMs.toFixed(0)}),r(Ht,{label:"Queue depth",value:String(d.queueDepth)})]}),r("div",{className:"rounded-lg border border-border overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[480px]",children:[r("thead",{className:"bg-surface",children:u("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[r("th",{className:"text-left px-3 py-2",children:"Agent"}),r("th",{className:"text-right px-3 py-2",children:"FPS"}),r("th",{className:"text-right px-3 py-2",children:"Cameras"}),r("th",{className:"text-right px-3 py-2",children:"Inference ms"}),r("th",{className:"text-right px-3 py-2",children:"Queue"}),r("th",{className:"text-right px-3 py-2",children:"Audio"})]})}),u("tbody",{children:[f.map(([p,m])=>u("tr",{className:"border-t border-border",children:[r("td",{className:"px-3 py-2 text-foreground font-medium",children:c.get(p)??p}),r("td",{className:"px-3 py-2 text-right text-foreground",children:m.totalFps.toFixed(1)}),r("td",{className:"px-3 py-2 text-right text-foreground",children:m.attachedCameras}),r("td",{className:"px-3 py-2 text-right text-foreground",children:m.attachedCameras>0?(m.totalInferenceWeighted/m.attachedCameras).toFixed(0):"—"}),r("td",{className:"px-3 py-2 text-right text-foreground",children:m.queueDepth}),r("td",{className:"px-3 py-2 text-right text-foreground",children:i.get(p)??"—"})]},p)),f.length===0&&r("tr",{children:r("td",{colSpan:6,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:"No camera metrics received yet"})})]})]})})]})}function Ht({label:e,value:t}){return u("div",{className:"rounded-lg border border-border bg-surface/60 p-3",children:[r("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle mb-1",children:e}),r("div",{className:"text-lg font-semibold text-foreground",children:t})]})}function zy(e){return Jn({addonId:e})}function q6(e){return Fn({deviceId:e},{enabled:Number.isFinite(e)})}const Q6=3e4,U6=2e3;function By(e){const t=ne(0);return t.current===0&&(t.current=Date.now()),wg({parentDeviceId:e},{enabled:Number.isFinite(e),staleTime:0,refetchOnMount:"always",refetchInterval:n=>{const o=n.state.data;return o&&o.length>0||Date.now()-t.current>=Q6?!1:U6}})}const mi={active:!1,pinned:!1,nodeId:null,reason:""},hi=["pipeline.camera-assigned","pipeline.camera-unassigned","pipeline.camera-updated","agent.online","agent.offline"],K6={pipeline:ut,decoder:Zr,audio:tl},cp={pipeline:"Pipeline",decoder:"Decoder",audio:"Audio"};function Fy({mode:e,nodeId:t,compact:n=!1}){if(e==="agent"&&!t)throw new Error('CameraAssignmentsTable: nodeId is required when mode === "agent"');const o=ke(),[s,a]=$(null),[i,l]=$(null),[c,d]=$(new Map);yt(["pipelineOrchestrator","getPipelineAssignments"],hi),yt(["pipelineOrchestrator","getDecoderAssignments"],hi),yt(["pipelineOrchestrator","getAudioAssignments"],hi);const{data:f}=ia(void 0,{staleTime:3e4}),{data:p}=yb(void 0,{staleTime:3e4}),{data:m}=kb(void 0,{staleTime:3e4}),{nodes:h}=Pr(),{data:g}=zy();dt("pipeline.camera-metrics-snapshot",E=>{const B=E.data;typeof B.deviceId=="number"&&d(O=>{const A=new Map(O);return A.set(B.deviceId,B),A})}),Y(()=>{if(c.size===0)return;const E=setInterval(()=>{d(B=>{const O=Date.now()-1e4;let A=!1;const D=new Map(B);for(const[_,R]of B)R.timestamp<O&&(D.delete(_),A=!0);return A?D:B})},5e3);return()=>clearInterval(E)},[c.size]);const b=Q(()=>{const E=new Map;for(const B of g??[])E.set(B.id,B.name);return E},[g]),x=Q(()=>{const E=new Map,B=A=>{const D=E.get(A);if(D)return D;const _={deviceId:A,deviceName:b.get(A)??`Device ${A}`,pipeline:mi,decoder:mi,audio:mi};return E.set(A,_),_};for(const A of f??[]){const D=B(A.deviceId);E.set(A.deviceId,{...D,pipeline:{active:e==="cluster"?!0:A.agentNodeId===t,pinned:A.pinned,nodeId:A.agentNodeId,reason:A.reason??""}})}for(const A of p??[]){const D=B(A.deviceId);E.set(A.deviceId,{...D,decoder:{active:e==="cluster"?!0:A.decoderNodeId===t,pinned:A.pinned,nodeId:A.decoderNodeId,reason:A.reason??""}})}for(const A of m??[]){const D=B(A.deviceId);E.set(A.deviceId,{...D,audio:{active:e==="cluster"?!0:A.nodeId===t,pinned:A.pinned,nodeId:A.nodeId,reason:"capacity"}})}let O=[...E.values()];return e==="agent"&&(O=O.filter(A=>A.pipeline.active||A.decoder.active||A.audio.active)),O.sort((A,D)=>A.deviceId-D.deviceId),O},[f,p,m,b,e,t]),v=Q(()=>(h??[]).filter(E=>E.isOnline).map(E=>({id:E.id,name:E.name})),[h]),w=()=>{o.invalidateQueries({queryKey:[["pipelineOrchestrator","getPipelineAssignments"]]}),o.invalidateQueries({queryKey:[["pipelineOrchestrator","getDecoderAssignments"]]}),o.invalidateQueries({queryKey:[["pipelineOrchestrator","getAudioAssignments"]]})},y=ub({onSuccess:w}),N=pb({onSuccess:w}),k=bb({onSuccess:w}),S=xb({onSuccess:w}),M=vb({onSuccess:w}),P=wb({onSuccess:w}),I=(E,B,O)=>{B==="pipeline"?y.mutate({deviceId:E,agentNodeId:O}):B==="decoder"?k.mutate({deviceId:E,nodeId:O}):M.mutate({deviceId:E,nodeId:O}),a(null)},F=(E,B)=>{B==="pipeline"?N.mutate({deviceId:E}):B==="decoder"?S.mutate({deviceId:E}):P.mutate({deviceId:E}),a(null)};return r("div",{className:"rounded-lg border border-border overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[640px]",children:[r("thead",{className:"bg-surface",children:u("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[!n&&r("th",{className:"w-6"}),r("th",{className:"text-left px-3 py-2 align-middle",children:"Camera"}),r("th",{className:"text-left px-3 py-2 align-middle",children:"Pipeline"}),r("th",{className:"text-left px-3 py-2 align-middle",children:"Decoder"}),r("th",{className:"text-left px-3 py-2 align-middle",children:"Audio"}),r("th",{className:"text-left px-3 py-2 align-middle",children:"Status"})]})}),u("tbody",{children:[x.map(E=>{const B=c.get(E.deviceId),O=i===E.deviceId;return u(Al.Fragment,{children:[u("tr",{className:"border-t border-border align-middle relative",children:[!n&&r("td",{className:"px-2 py-2 align-middle",children:r("button",{type:"button",onClick:()=>l(O?null:E.deviceId),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle","aria-label":O?"Collapse broker details":"Expand broker details",children:O?r(Rt,{className:"h-3.5 w-3.5"}):r(Mt,{className:"h-3.5 w-3.5"})})}),u("td",{className:"px-3 py-2 align-middle",children:[r("div",{className:"text-foreground font-medium leading-tight",children:E.deviceName}),u("div",{className:"text-[10px] text-foreground-subtle leading-tight",children:["#",E.deviceId]})]}),r(gi,{role:"pipeline",state:E.pipeline,mode:e,deviceId:E.deviceId,onlineNodes:v,isMenuOpen:s?.deviceId===E.deviceId&&s.role==="pipeline",onToggleMenu:()=>a(s?.deviceId===E.deviceId&&s.role==="pipeline"?null:{deviceId:E.deviceId,role:"pipeline"}),onCloseMenu:()=>a(null),onMove:A=>I(E.deviceId,"pipeline",A),onUnpin:()=>F(E.deviceId,"pipeline")}),r(gi,{role:"decoder",state:E.decoder,mode:e,deviceId:E.deviceId,onlineNodes:v,isMenuOpen:s?.deviceId===E.deviceId&&s.role==="decoder",onToggleMenu:()=>a(s?.deviceId===E.deviceId&&s.role==="decoder"?null:{deviceId:E.deviceId,role:"decoder"}),onCloseMenu:()=>a(null),onMove:A=>I(E.deviceId,"decoder",A),onUnpin:()=>F(E.deviceId,"decoder")}),r(gi,{role:"audio",state:E.audio,mode:e,deviceId:E.deviceId,onlineNodes:v,isMenuOpen:s?.deviceId===E.deviceId&&s.role==="audio",onToggleMenu:()=>a(s?.deviceId===E.deviceId&&s.role==="audio"?null:{deviceId:E.deviceId,role:"audio"}),onCloseMenu:()=>a(null),onMove:A=>I(E.deviceId,"audio",A),onUnpin:()=>F(E.deviceId,"audio")}),r("td",{className:"px-3 py-2 align-middle",children:r(Y6,{snap:B})})]}),O&&!n&&u("tr",{className:"bg-surface/50",children:[r("td",{}),r("td",{colSpan:5,className:"px-3 py-2",children:r(it,{widgetId:"stream-broker/stream-broker-panel",host:"device-tab",deviceId:E.deviceId,instanceId:`pipeline-row/${E.deviceId}`,config:{variant:"compact",title:"Stream brokers & clients"}})})]})]},E.deviceId)}),x.length===0&&r("tr",{children:r("td",{colSpan:n?5:6,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:e==="agent"?"No cameras assigned to this node":"No cameras currently assigned"})})]})]})})}function gi({role:e,state:t,mode:n,onlineNodes:o,isMenuOpen:s,onToggleMenu:a,onCloseMenu:i,onMove:l,onUnpin:c}){const d=K6[e],f=o.filter(h=>h.id!==(t.nodeId??"")),m=(t.active||n==="cluster")&&(f.length>0||t.pinned);return u("td",{className:"px-3 py-2 align-middle relative",children:[u("div",{className:"flex items-center gap-2",children:[n==="agent"?r(G6,{state:t,Icon:d}):r(W6,{state:t,Icon:d}),r("div",{className:"ml-auto",children:m&&r("button",{type:"button",onClick:a,className:"p-1 rounded hover:bg-surface-hover","aria-label":`${cp[e]} actions`,children:r(DD,{className:"h-3 w-3 text-foreground-subtle"})})})]}),s&&m&&r(Z6,{title:cp[e],targets:f,pinned:t.pinned,onMove:l,onUnpin:c,onClose:i})]})}function G6({state:e,Icon:t}){const n=e.active?hy:ya;return u("div",{className:"flex items-center gap-1.5",children:[r(n,{className:`h-3.5 w-3.5 ${e.active?"text-success":"text-foreground-subtle/50"}`}),r(t,{className:`h-3 w-3 ${e.active?"text-foreground-subtle":"text-foreground-subtle/40"}`}),e.pinned&&r(uy,{className:"h-2.5 w-2.5 text-amber-400"})]})}function W6({state:e,Icon:t}){return!e.active||!e.nodeId?u("div",{className:"flex items-center gap-1.5 text-foreground-subtle/60",children:[r(t,{className:"h-3 w-3"}),r("span",{className:"text-[10px] italic",children:"—"})]}):u("div",{className:"flex items-center gap-1.5 min-w-0",children:[r(t,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),u("div",{className:"flex flex-col leading-tight min-w-0",children:[r("span",{className:"font-mono text-[11px] text-foreground truncate",children:e.nodeId}),r("span",{className:"flex items-center gap-1 text-[10px]",children:e.pinned?u("span",{className:"inline-flex items-center gap-0.5 text-amber-400",children:[r(uy,{className:"h-2.5 w-2.5"})," manual"]}):u("span",{className:"text-foreground-subtle truncate",children:["auto · ",e.reason||"capacity"]})})]})]})}function Y6({snap:e}){if(!e)return r("span",{className:"text-[10px] text-foreground-subtle italic",children:"—"});const{phase:t,actualFps:n,avgInferenceTimeMs:o,queueDepth:s,configuredFps:a}=e.metrics,i=Wn(t);return u("div",{className:"flex flex-col gap-0.5 font-mono text-[10px] tabular-nums leading-tight",children:[u("span",{className:`inline-flex items-center gap-1 ${i.textColor}`,children:[r(Ac,{phase:t,className:"h-2.5 w-2.5"}),r("span",{className:"font-semibold uppercase tracking-wider",children:i.label})]}),u("span",{className:"text-foreground-subtle",children:[r("span",{className:"text-foreground",children:n.toFixed(1)}),u("span",{children:["/",a.toFixed(0)," fps"]})]}),u("span",{className:"text-foreground-subtle",children:[r("span",{className:"text-foreground",children:o.toFixed(0)}),r("span",{children:" ms"}),s>0&&u("span",{className:"text-warning ml-1",children:["q",s]})]})]})}function Z6({title:e,targets:t,pinned:n,onMove:o,onUnpin:s,onClose:a}){const i=ne(null);return Y(()=>{const l=c=>{i.current?.contains(c.target)||a()};return window.addEventListener("mousedown",l),()=>window.removeEventListener("mousedown",l)},[a]),u("div",{ref:i,className:"absolute right-2 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-lg z-20 text-left",children:[r("div",{className:"px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border",children:e}),t.length>0&&r("div",{className:"py-1",children:t.map(l=>u("button",{type:"button",onClick:()=>o(l.id),className:"block w-full text-left px-3 py-1 text-[11px] text-foreground hover:bg-surface-hover",children:["Move to ",l.name]},l.id))}),n&&u("button",{type:"button",onClick:s,className:"block w-full text-left px-3 py-1.5 text-[11px] text-destructive hover:bg-destructive/10 border-t border-border",children:["Unpin ",e.toLowerCase()]}),t.length===0&&!n&&r("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle italic",children:"Already auto · no other nodes online"})]})}function X6({nodeId:e,refreshToken:t}){return u("div",{className:"space-y-6",children:[r(Oy,{refreshToken:t,nodeId:e}),u("div",{children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Cameras on this node"}),u("p",{className:"text-[11px] text-foreground-subtle",children:["Checkboxes mark the roles currently running on ",e,". Use the kebab to move a role to another node or unpin it; live KPIs come from the runner snapshot stream."]})]}),r(Fy,{mode:"agent",nodeId:e,compact:!0})]})}function J6(e,t){const n=Math.max(0,t-e),o=Math.floor(e/1e3),s=Math.floor(n/1e3);return`${o}s idle · ${s}s left`}function eO({nodeId:e,refreshToken:t}){const n=ke(),o=db({onSettled:()=>{n.invalidateQueries({queryKey:["pipelineExecutor","listLoadedEngines"]})}}),{data:s}=cb({nodeId:e},{staleTime:5e3}),i=Ar("pipeline.engine-metrics-snapshot",m=>m.nodeId===e)?.engines??s??null,l=i===null;yt(["pipelineRunner","getLocalCameras"],["pipeline.camera-assigned","pipeline.camera-unassigned"]);const{data:c}=_b({nodeId:e},{staleTime:3e4}),{values:d}=Jl("pipeline.camera-metrics-snapshot",m=>m.deviceId,m=>m.nodeId===e),f=Q(()=>d.filter(m=>m.metrics.phase==="active").length,[d]),p=m=>{const h=c??[];h.length>0&&!window.confirm(`${h.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||o.mutate({nodeId:e,engine:m,force:h.length>0})};return u("div",{className:"space-y-6",children:[u("div",{children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Inference engines on this node"}),u("p",{className:"text-[11px] text-foreground-subtle",children:[(i??[]).length," engine(s) resident in RAM. ",(c??[]).length," camera(s) attached, ",f," actively dispatching frames. Refreshes every 5s."]})]}),r("div",{className:"rounded-lg border border-border overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[640px]",children:[r("thead",{className:"bg-surface",children:u("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[r("th",{className:"text-left px-3 py-2 whitespace-nowrap",children:"Kind"}),r("th",{className:"text-left px-3 py-2 whitespace-nowrap",children:"Runtime / Backend / Device"}),r("th",{className:"text-left px-3 py-2",children:"Models"}),r("th",{className:"text-right px-3 py-2 whitespace-nowrap",children:"Pool PID"}),r("th",{className:"text-right px-3 py-2 whitespace-nowrap",children:"Auto-kill"}),r("th",{className:"text-right px-3 py-2 whitespace-nowrap",children:"In use"}),r("th",{className:"w-20"})]})}),u("tbody",{children:[l&&r("tr",{children:r("td",{colSpan:7,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:"Loading…"})}),!l&&(i??[]).map(m=>{const h=m.kind==="warm-override";return u("tr",{className:`border-t border-border ${h?"bg-amber-500/5":""}`,children:[r("td",{className:"px-3 py-2",children:u("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${h?"bg-amber-500/15 text-amber-400":"bg-success/15 text-success"}`,children:[h?r(BD,{className:"h-3 w-3"}):r(ut,{className:"h-3 w-3"}),h?"warm":"runtime"]})}),r("td",{className:"px-3 py-2",children:u("span",{className:"inline-flex items-center gap-1 text-[11px] text-sky-400",children:[r(Jc,{className:"h-3 w-3"}),m.engine.runtime,"/",m.engine.backend,m.engine.device?`/${m.engine.device}`:"",m.engine.format?` · ${m.engine.format}`:""]})}),r("td",{className:"px-3 py-2",children:m.modelsLoaded.length===0?r("span",{className:"text-foreground-subtle text-[11px]",children:"—"}):r("div",{className:"flex flex-wrap gap-1",children:m.modelsLoaded.map(g=>r("span",{className:"inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle",children:g},g))})}),r("td",{className:"px-3 py-2 text-right font-mono text-foreground",children:m.poolPid??"—"}),r("td",{className:"px-3 py-2 text-right text-[11px]",children:m.idleMs!==null&&m.idleTtlMs!==null?r("span",{className:"text-foreground-subtle",children:J6(m.idleMs,m.idleTtlMs)}):r("span",{className:"text-foreground-subtle/50",children:"never"})}),r("td",{className:"px-3 py-2 text-right text-foreground",children:h?"—":(c??[]).length}),r("td",{className:"px-3 py-2 text-right",children:u("button",{type:"button",disabled:o.isPending,onClick:()=>p(m.engine),className:"inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50",children:[r(We,{className:"h-3 w-3"}),"Kill"]})})]},m.engineKey)}),!l&&(i??[]).length===0&&r("tr",{children:r("td",{colSpan:7,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:"No engines resident — the factory spins up on the first pipeline run."})})]})]})}),u("div",{className:"text-[10px] text-foreground-subtle leading-relaxed",children:[r("strong",{className:"text-foreground",children:"runtime"}),": main camera-serving engine; never auto-killed while cameras attached. ",r("strong",{className:"text-foreground",children:"warm"}),": benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL."]}),o.isError&&u("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive",children:["Kill failed: ",o.error instanceof Error?o.error.message:"unknown"]})]})}function Nt(e){if(!Number.isFinite(e)||e<0)return"—";if(e<1024)return`${Math.round(e)} B`;const t=["KB","MB","GB","TB","PB"];let n=e/1024,o="KB";for(const a of t){if(o=a,n<1024)break;n/=1024}return`${n>=100?Math.round(n).toString():n.toFixed(1)} ${o}`}function jy(e){return Nt(e*1024*1024)}const tO=new Set(rw);function dp(e){return tO.has(e)}function bi(e,t,n){return`${e}/${t}/${n}`}function cl(e){return{coreml:"CoreML",openvino:"OpenVINO",onnx:"ONNX"}[e.format]??e.format.toUpperCase()}function up(e){return{coreml:"Apple Neural Engine / GPU — .mlpackage",openvino:"Intel CPU / GPU / NPU — .xml",onnx:"CPU, CUDA, Node.js — .onnx"}[e.format]??`.${e.format}`}function _n(e){return e.format}function nO(e,t){let n=0,o=0,s=0;for(const a of e)for(const i of a.addons)for(const l of i.models){const c=l.formats[t];c&&(n++,c.downloaded&&(o++,s+=c.sizeMB))}return{total:n,downloaded:o,downloadedSizeMB:s}}function rO({addonId:e,model:t,format:n,isActive:o,progress:s,errorMsg:a,onDownload:i,onDelete:l}){const c=t.formats[n];return c?u("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/50 last:border-b-0 hover:bg-surface-hover/30 transition-colors",children:[r("div",{className:`h-2 w-2 rounded-full shrink-0 ${c.downloaded?"bg-success":"bg-foreground-subtle/30"}`}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-sm font-medium text-foreground",children:t.name}),u("span",{className:"text-[10px] text-foreground-subtle font-mono",children:["(",t.id,")"]})]}),s&&s.progress>=0&&s.progress<100&&u("div",{className:"mt-1.5 flex items-center gap-2 max-w-xs",children:[r("div",{className:"flex-1 h-1 bg-surface-hover rounded-full overflow-hidden",children:r("div",{className:"bg-primary h-full rounded-full transition-all duration-300",style:{width:`${s.progress}%`}})}),u("span",{className:"text-[9px] text-primary font-mono tabular-nums shrink-0",children:[Math.round(s.progress),"%"]})]})]}),r("span",{className:"text-xs text-foreground-subtle tabular-nums shrink-0",children:jy(c.sizeMB)}),a&&u("span",{className:"flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0",title:a,children:[r(ba,{className:"h-3 w-3 shrink-0"}),a]}),c.downloaded?u("button",{onClick:l,disabled:o,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md border border-danger/30 text-danger hover:bg-danger/10 disabled:opacity-50 transition-colors shrink-0",children:[o?r(Pe,{className:"h-3 w-3 animate-spin"}):r(We,{className:"h-3 w-3"}),o?"Deleting...":"Delete"]}):u("button",{onClick:i,disabled:o,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0",children:[o?r(Pe,{className:"h-3 w-3 animate-spin"}):r(wn,{className:"h-3 w-3"}),o?"Downloading...":"Download"]})]}):null}function oO({engines:e,activeEngine:t,viewEngine:n,onSelect:o}){const[s,a]=$(!1);return u("div",{className:"relative",children:[u("button",{type:"button",onClick:()=>a(!s),className:"flex items-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 w-full text-left hover:bg-surface-hover transition-colors",children:[r(ut,{className:"h-4 w-4 text-primary shrink-0"}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-sm font-medium text-foreground",children:cl(n)}),_n(n)===_n(t)&&r("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium",children:"Active"})]}),r("div",{className:"text-[10px] text-foreground-subtle",children:up(n)})]}),r(Rt,{className:`h-4 w-4 text-foreground-subtle transition-transform ${s?"rotate-180":""}`})]}),s&&r("div",{className:"absolute top-full left-0 right-0 mt-1 rounded-lg border border-border bg-surface shadow-lg z-50 overflow-hidden",children:e.map(i=>{const l=_n(i)===_n(n),c=_n(i)===_n(t);return u("button",{type:"button",onClick:()=>{o(i),a(!1)},className:`flex items-center gap-3 px-4 py-2.5 w-full text-left transition-colors ${l?"bg-primary/5":"hover:bg-surface-hover"}`,children:[r(ut,{className:`h-4 w-4 shrink-0 ${l?"text-primary":"text-foreground-subtle"}`}),u("div",{className:"flex-1",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:`text-sm font-medium ${l?"text-primary":"text-foreground"}`,children:cl(i)}),c&&r("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium",children:"Active"})]}),r("div",{className:"text-[10px] text-foreground-subtle",children:up(i)})]}),l&&r(Jx,{className:"h-4 w-4 text-primary shrink-0"})]},_n(i))})})]})}function sO({embedded:e=!1,nodeId:t}={}){const n=ke(),o=t??"hub",[s,a]=$(null),[i,l]=$(new Set),[c,d]=$(new Map),[f,p]=$(new Map),[m,h]=$(""),{data:g=[]}=ob({nodeId:o},{staleTime:6e4}),x=g.filter((R,L,z)=>z.findIndex(j=>j.format===R.format)===L),{data:v}=sb({nodeId:o},{staleTime:3e4}),w=v,{data:y,isLoading:N}=So({nodeId:o},{staleTime:1e4}),k=ib(),S=lb();dt("model.download.progress",R=>{const L=R.data,z=typeof L.modelId=="string"?L.modelId:void 0,j=typeof L.progress=="number"?L.progress:void 0,H=typeof L.totalMB=="number"?L.totalMB:0;z===void 0||j===void 0||(d(T=>{const W=new Map(T);return j===100||j===-1?W.delete(z):W.set(z,{modelId:z,progress:j,totalMB:H}),W}),j===100&&n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]}))});const M=w??{runtime:"node",backend:"cpu",format:"onnx"},P=x.find(R=>R.format===s)??M,I=P.format,F=y?.slots??[],E=F.map(R=>({...R,addons:R.addons.map(L=>({...L,models:L.models.filter(z=>z.formats[I]!==void 0)})).filter(L=>L.models.length>0)})).filter(R=>R.addons.length>0),B=nO(E,I),O=q(async(R,L,z)=>{if(!dp(z))return;const j=bi(R,L,z);l(H=>new Set([...H,j])),p(H=>{const T=new Map(H);return T.delete(j),T});try{await k.mutateAsync({addonId:R,modelId:L,format:z,nodeId:o}),n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]})}catch(H){p(T=>new Map([...T,[j,H instanceof Error?H.message:"Download failed"]]))}finally{l(H=>{const T=new Set(H);return T.delete(j),T})}},[k,n,o]),A=q(async(R,L,z)=>{if(!dp(z))return;const j=bi(R,L,z);l(H=>new Set([...H,j])),p(H=>{const T=new Map(H);return T.delete(j),T});try{await S.mutateAsync({addonId:R,modelId:L,format:z,nodeId:o}),n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]})}catch(H){p(T=>new Map([...T,[j,H instanceof Error?H.message:"Delete failed"]]))}finally{l(H=>{const T=new Set(H);return T.delete(j),T})}},[S,n,o]),D=q(R=>{a(R.format)},[]),_=m.trim()?E.map(R=>({...R,addons:R.addons.map(L=>({...L,models:L.models.filter(z=>z.name.toLowerCase().includes(m.toLowerCase())||z.id.toLowerCase().includes(m.toLowerCase())||L.name.toLowerCase().includes(m.toLowerCase()))})).filter(L=>L.models.length>0)})).filter(R=>R.addons.length>0):E;return u("div",{className:e?"space-y-4":"p-6 space-y-6 max-w-5xl mx-auto",children:[!e&&u("div",{children:[r("h1",{className:"text-lg font-bold text-foreground",children:"Models"}),r("p",{className:"text-xs text-foreground-subtle mt-0.5",children:"Manage ML models for the detection pipeline. Select an engine to see its compatible models."})]}),N&&r("div",{className:"flex items-center justify-center py-16",children:r(Pe,{className:"h-5 w-5 animate-spin text-foreground-subtle"})}),!N&&F.length===0&&u("div",{className:"flex flex-col items-center justify-center py-16 text-foreground-subtle",children:[r(lo,{className:"h-8 w-8 mb-3 opacity-30"}),r("span",{className:"text-sm",children:"No pipeline steps available"}),r("span",{className:"text-xs mt-1",children:"Configure the detection pipeline to see available models."})]}),!N&&F.length>0&&u(ve,{children:[r(oO,{engines:x,activeEngine:M,viewEngine:P,onSelect:D}),u("div",{className:"flex items-center gap-4 text-xs text-foreground-subtle",children:[u("span",{children:[r("span",{className:"font-semibold text-foreground tabular-nums",children:B.total}),r("span",{className:"ml-1",children:"compatible models"})]}),r("span",{className:"text-border",children:"|"}),u("span",{children:[r("span",{className:"font-semibold text-success tabular-nums",children:B.downloaded}),r("span",{className:"ml-1",children:"downloaded"})]}),r("span",{className:"text-border",children:"|"}),u("span",{className:"tabular-nums",children:[jy(B.downloadedSizeMB),r("span",{className:"ml-1",children:"on disk"})]})]}),B.total>5&&u("div",{className:"relative",children:[r(my,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle"}),r("input",{type:"text",value:m,onChange:R=>h(R.target.value),placeholder:"Search models...",className:"w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-border bg-surface text-foreground placeholder:text-foreground-subtle/50 focus:outline-none focus:ring-1 focus:ring-primary"})]}),_.map(R=>{const L=R.addons.reduce((j,H)=>j+H.models.length,0),z=R.addons.reduce((j,H)=>j+H.models.filter(T=>T.formats[I]?.downloaded).length,0);return u("div",{children:[u("div",{className:"flex items-center gap-2 mb-2",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:R.label}),r("div",{className:"flex-1 h-px bg-border"}),u("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[z,"/",L]})]}),r("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:R.addons.map(j=>j.models.map(H=>{const T=bi(j.id,H.id,I);return r(rO,{addonId:j.id,model:H,format:I,isActive:i.has(T),progress:c.get(H.id),errorMsg:f.get(T),onDownload:()=>O(j.id,H.id,I),onDelete:()=>A(j.id,H.id,I)},`${j.id}/${H.id}`)}))})]},R.id)}),_.length===0&&r("div",{className:"text-center py-8 text-sm text-foreground-subtle",children:m.trim()?u(ve,{children:["No models matching “",m,"”"]}):u(ve,{children:["No models available for ",cl(P)," format"]})})]})]})}function aO({nodeId:e,refreshToken:t}){return r(sO,{embedded:!0,nodeId:e})}function Hy({nodeId:e,title:t}){const{data:n}=zy(),{data:o}=ia(void 0,{staleTime:3e4}),s=Q(()=>{const d=new Map;for(const f of n??[])d.set(f.id,f.name);return d},[n]),a=Q(()=>{if(!e)return null;const d=new Set;for(const f of o??[])f.agentNodeId===e&&d.add(f.deviceId);return d},[e,o]),[i,l]=$(new Map);dt("pipeline.camera-metrics-snapshot",d=>{const f=d.data;typeof f.deviceId=="number"&&(e&&f.nodeId!==e||l(p=>{const m=new Map(p);return m.set(f.deviceId,f),m}))}),Y(()=>{if(i.size===0)return;const d=setInterval(()=>{l(f=>{const p=Date.now()-1e4;let m=!1;const h=new Map(f);for(const[g,b]of f)b.timestamp<p&&(h.delete(g),m=!0);return m?h:f})},5e3);return()=>clearInterval(d)},[i.size]);const c=Q(()=>{const d=[];for(const f of i.values())a&&!a.has(f.deviceId)||d.push(f);return d.sort((f,p)=>f.deviceId-p.deviceId),d},[i,a]);return c.length===0?u("div",{className:"rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic",children:[t??"Cameras",": no live snapshots yet"]}):u("div",{className:"rounded-md border border-border bg-surface px-3 py-2",children:[u("div",{className:"flex items-center gap-2 mb-1.5",children:[r("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:t??"Cameras"}),r("span",{className:"text-[10px] text-foreground-subtle",children:c.length})]}),r("div",{className:"flex flex-wrap gap-1.5",children:c.map(d=>{const f=s.get(d.deviceId)??`#${d.deviceId}`,p=Wn(d.metrics.phase);return u("div",{title:`${f} · ${p.label} · ${d.metrics.actualFps.toFixed(1)} fps · ${d.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${d.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${p.badgeClass}`,children:[r(Ac,{phase:d.metrics.phase,className:"h-2.5 w-2.5"}),r("span",{className:"font-medium text-foreground/90 max-w-[120px] truncate",children:f}),r("span",{className:"font-mono tabular-nums",children:d.metrics.actualFps.toFixed(1)}),r("span",{className:"opacity-60",children:"fps"})]},d.deviceId)})})]})}function xi(e,t){if(!e)return null;for(const n of e.slots)for(const o of n.addons)if(o.id===t)return o;return null}function iO({nodeId:e,refreshToken:t}){const n=ke(),[o,s]=$(null),[a,i]=$(null),l=So({nodeId:e},{refetchOnMount:"always"}),c=bc({agentNodeId:e},{refetchOnMount:"always"}),d=xc({onSuccess:()=>{n.invalidateQueries({queryKey:[["addonSettings"]]}),n.invalidateQueries({queryKey:[["pipelineOrchestrator"]]}),n.invalidateQueries({queryKey:[["pipelineExecutor"]]})}}),f=l.data??null,p=c.data,m=f?.selectedEngine.format??"coreml",h=Q(()=>f?ea(f):[],[f]),g=Q(()=>[{agentNodeId:e,engineLabel:m}],[e,m]),b=(S,M)=>{const P=p?.addonDefaults[S];return xi(f,S)?.models.some(E=>!!E.formats[m])?P?P.enabled?{kind:"enabled",modelId:P.modelId}:{kind:"disabled"}:{kind:"na"}:{kind:"na"}},x=o&&f?xi(f,o.addonId):null,v=S=>{const M=p?.addonDefaults[S]??null;s({addonId:S,agentNodeId:e}),i(M)},w=(S,M)=>{if(!p)return;const P=p.addonDefaults[S],I=xi(f,S);if(!P&&!I)return;const F={enabled:M,modelId:P?.modelId??I?.defaultModelId??"",settings:P?.settings??{}};d.mutate({agentNodeId:e,defaults:{...p.addonDefaults,[S]:F}})},y=()=>{s(null),i(null)},N=()=>{!a||!o||!p||d.mutate({agentNodeId:e,defaults:{...p.addonDefaults,[o.addonId]:a}},{onSuccess:y})};if(l.isLoading||c.isLoading)return r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading pipeline…"});if(l.error)return u("div",{className:"text-xs text-red-400",children:["Failed to load catalog: ",String(l.error)]});if(!f)return r("div",{className:"text-xs text-foreground-subtle",children:"Catalog unavailable for this node (runner offline?)."});const k=o!==null&&x!==null&&a!==null;return u("div",{className:"relative h-full w-full space-y-3",children:[r(Hy,{nodeId:e}),r("div",{className:k?"pr-[360px]":"",children:h.length>0?r(Yl,{tree:h,agents:g,getCellState:b,onCellClick:v,selectedCell:o,onToggleEnabled:w}):r("div",{className:"text-xs text-foreground-subtle",children:"Catalog empty."})}),r(Wl,{open:k,onClose:y,title:x?.name??"",subtitle:o?`${o.agentNodeId} · ${m}`:"",footer:u(ve,{children:[r("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:y,children:"Cancel"}),r("button",{type:"button",disabled:!a||!o||d.isPending,className:"px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50",onClick:N,children:d.isPending?"Saving…":"Save"})]}),children:x&&a&&o&&r(na,{mode:"agent",addon:x,agentDefault:a,agentNodeId:o.agentNodeId,engineFormat:m,onChangeAgentConfig:S=>i(S)})})]})}function Vy({pendingCount:e,onSave:t,onDiscard:n,saving:o=!1,saveLabel:s="Save",discardLabel:a="Discard"}){return e<=0?null:u("div",{className:"sticky bottom-0 -mb-3 flex items-center justify-between gap-3 rounded-lg border border-primary/40 bg-primary/5 px-3 py-2 shadow-sm z-10",children:[u("span",{className:"text-xs text-foreground",children:[e," unsaved change",e===1?"":"s"]}),u("div",{className:"flex items-center gap-2",children:[r("button",{type:"button",onClick:n,disabled:o,className:"inline-flex items-center rounded-md border border-border px-2.5 py-1 text-xs text-foreground-subtle hover:bg-surface-hover disabled:opacity-50",children:a}),r("button",{type:"button",onClick:t,disabled:o,className:"inline-flex items-center rounded-md bg-primary px-3 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:o?"Saving…":s})]})]})}function qy({tabs:e,activeId:t,onChange:n,countByTab:o,pendingByTab:s}){return e.length===0?null:r("div",{className:"flex flex-wrap items-center gap-1 border-b border-border shrink-0",children:e.map(a=>{const i=a.id===t,l=o?.get(a.id)??0,c=s?.get(a.id)??0;return u("button",{type:"button",onClick:()=>n(a.id),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${i?"text-primary border-primary bg-primary/5":"text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover"}`,children:[a.label,l>0&&u("span",{className:"ml-1.5 text-[10px] opacity-60",children:["(",l,")"]}),c>0&&r("span",{className:"ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-primary"})]},a.id)})})}function lO(e,t){for(const n of e)for(const o of n.fields){if(!("key"in o)||o.key!==t)continue;if(o.type==="button"||o.type==="separator"||o.type==="info")return!0;const s=o.immediate;return s===!0?!0:s===!1?!1:n.immediate===!0}return!1}function Qy({schema:e,serverValues:t,onImmediateSave:n,onDeferredSave:o}){const[s,a]=$({}),[i,l]=$(!1),c=ne(null),d=e?.sections??[],f=Object.keys(s).length>0,p=Q(()=>({...t,...s}),[t,s]);Y(()=>{if(f){l(!0);return}c.current&&clearTimeout(c.current),c.current=setTimeout(()=>l(!1),500)},[f]);const m=q(()=>{l(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>l(!1),2e3)},[]),h=q(v=>{m();const w={},y={},N={...t,...s};for(const[k,S]of Object.entries(v))N[k]!==S&&(lO(d,k)?w[k]=S:y[k]=S);Object.keys(w).length>0&&n(w),a(k=>{const S={...k};for(const M of Object.keys(w))delete S[M];for(const[M,P]of Object.entries(y))S[M]=P;return S})},[m,t,s,d,n]),g=q(v=>{const w={},y={};for(const[N,k]of Object.entries(s))v.includes(N)?w[N]=k:y[N]=k;a(y),Object.keys(w).length>0&&o(w)},[s,o]),b=q(v=>{a(w=>{const y={...w};for(const N of v)delete y[N];return y})},[]),x=q(()=>{a({})},[]);return{values:p,pendingKeys:Object.keys(s),hasPendingEdits:f,editingPaused:i,handleChange:h,handleSave:g,handleDiscard:b,resetAll:x}}const cO=Ve(function({addonId:t,schema:n,serverValues:o,onImmediateSave:s,onStateChange:a,onAction:i,disabled:l},c){const d=Qy({schema:n,serverValues:o,onImmediateSave:q(b=>s(t,b),[t,s]),onDeferredSave:q(()=>{},[])});G1(c,()=>({flush:()=>{const b={};for(const x of d.pendingKeys)b[x]=d.values[x];return d.handleDiscard(d.pendingKeys),b},discard:()=>d.resetAll()}),[d]);const f=d.pendingKeys,p=f.join("|"),m=Q(()=>f.map(b=>`${b}=${JSON.stringify(d.values[b])}`).join(","),[f,d.values]),h=ne(a);Y(()=>{h.current=a},[a]),Y(()=>{const b={};for(const x of f)b[x]=d.values[x];h.current({addonId:t,pendingKeys:f,pendingValues:b})},[t,p,m]);const g=Q(()=>{if(i)return(b,x,v)=>i(t,b,x,v)},[t,i]);return r(Nn,{schema:n,values:d.values,onChange:d.handleChange,disabled:l,onAction:g})});function Uy(e,t){if(e.type==="separator"||e.type==="info"||e.type==="button")return e;if(e.type==="group"){const a=e.fields.map(i=>Uy(i,t));return{...e,fields:a}}const n=e;t[e.key]=n.value;const{value:o,...s}=n;return s}function dO(e,t){return{...e,fields:e.fields.map(n=>Uy(n,t))}}function uO(e){const t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(o=>dO(o,t))},values:t}}function Rr({nodeId:e,addonIds:t,level:n,deviceId:o,sectionIds:s,sectionTab:a,extraTabs:i,title:l,description:c}){const d=ke(),f=Le().trpcClient,p=Jh(),m=eg(),h=ab(),g=hg(),b=ig(),x=!!(i&&i.length>0),[v,w]=$(null);if(n==="device"&&!o)throw new Error('NodeAddonsSettingsPanel: deviceId is required when level === "device"');const y=e??"hub",N=Z1({queries:t.map(Z=>({queryKey:[["addonSettings",n==="global"?"getGlobalSettings":"getDeviceSettings"],{addonId:Z,nodeId:y,deviceId:o??null}],queryFn:async()=>{if(n==="global"){const J=await f.addonSettings.getGlobalSettings.query({addonId:Z,nodeId:y});return{addonId:Z,result:J}}const U=await f.addonSettings.getDeviceSettings.query({addonId:Z,deviceId:o,nodeId:y});return{addonId:Z,result:U}},staleTime:3e4}))}),k=N.some(Z=>Z.isLoading),S=N.map(Z=>{if(!Z.data)return"-";if(Z.data.result===null)return`${Z.data.addonId}:n`;const U=[];for(const J of Z.data.result.sections){U.push(`s:${J.id}:${J.tab??"general"}`);for(const ae of J.fields){if(!("key"in ae))continue;const fe="options"in ae&&Array.isArray(ae.options)?ae.options.map(ie=>ie.value).join(","):"",he=ae.value,V=he===void 0?"":typeof he=="string"?he:JSON.stringify(he);U.push(`f:${ae.key}:${fe}:${V}`)}}return`${Z.data.addonId}:${U.join("|")}`}).join("||"),M=Q(()=>{const Z=new Set;for(const U of N){const J=U.data?.result?.sections;if(J)for(const ae of J)Z.add(ae.tab??"general")}return[...Z]},[S+"::"+N.map(Z=>(Z.data?.result?.sections??[]).map(U=>U.tab??"general").join(",")).join("::")]),P=Q(()=>new Map((i??[]).map(Z=>[Z.id,Z])),[i]),I=Q(()=>{if(!x)return[];const Z=[...new Set([...M,...(i??[]).map(J=>J.id)])],U=J=>{const ae=P.get(J);if(ae?.order!==void 0)return ae.order;const fe=$i[J];return fe?fe.order:50};return Z.sort((J,ae)=>{const fe=U(J),he=U(ae);return fe!==he?fe-he:J.localeCompare(ae)})},[x,M,i,P]),F=Q(()=>{const Z=new Map;for(const U of M){const J=$i[U];Z.set(U,J?.label??U.charAt(0).toUpperCase()+U.slice(1))}for(const U of i??[])Z.set(U.id,U.label);return Z},[M,i]),E=x?v&&I.includes(v)?v:I[0]??null:null,B=E!==null&&P.has(E),O=x?E&&!B?E:void 0:a,{data:A}=ra(void 0,{staleTime:6e4}),D=Q(()=>{const Z=new Map;for(const U of A??[]){const J=U.manifest?.id;if(!J)continue;const ae=U.manifest?.name??U.manifest?.packageDisplayName??J;Z.set(J,ae)}return Z},[A]),_=Q(()=>{const Z=s?new Set(s):null,U=[];for(const J of N){if(!J.data||J.data.result===null)continue;const{schema:ae,values:fe}=uO(J.data.result),he=ae.sections.filter(ue=>Z?Z.has(ue.id):!0);if(he.length===0)continue;const V={...J.data.result,sections:J.data.result.sections.filter(ue=>Z?Z.has(ue.id):!0)},ie={...ae,sections:he};U.push({addonId:J.data.addonId,schemaWithValues:V,schema:ie,serverValues:fe})}return U},[S,s]),[R,L]=$(new Map),z=q(Z=>{L(U=>{const J=new Map(U);return J.set(Z.addonId,Z),J})},[]),j=ne(new Map),H=q(Z=>U=>{U?j.current.set(Z,U):j.current.delete(Z)},[]),T=q(async(Z,U)=>{n==="global"?await p.mutateAsync({addonId:Z,nodeId:y,patch:U}):await m.mutateAsync({addonId:Z,deviceId:o,nodeId:y,patch:U}),d.invalidateQueries({queryKey:[["addonSettings"]]})},[p,m,y,n,o,d]),W=q(async(Z,U,J,ae)=>{const fe=y;try{switch(U){case"reprobe-engine":await h.mutateAsync({nodeId:fe}),d.invalidateQueries({queryKey:[["addonSettings"]]});return;case"reprobe-hwaccel":await g.mutateAsync({nodeId:fe}),d.invalidateQueries({queryKey:[["addonSettings"]]});return;case"reprobe-audio-engine":await b.mutateAsync({nodeId:fe}),d.invalidateQueries({queryKey:[["addonSettings"]]});return;default:{const he=await f.addons.custom.mutate({addonId:Z,action:U,input:ae});return d.invalidateQueries({queryKey:[["addonSettings"]]}),he}}}catch(he){throw console.error("[NodeAddonsSettingsPanel] action failed",{addonId:Z,action:U,err:he}),he}},[h,g,b,y,d,f]),G=q((Z,U)=>{T(Z,U)},[T]),ee=El({mutationFn:async()=>{const Z=[];for(const J of _){const ae=R.get(J.addonId);!ae||ae.pendingKeys.length===0||Z.push({addonId:J.addonId,patch:ae.pendingValues})}return Z.length===0?{saved:[]}:{saved:await Promise.all(Z.map(async({addonId:J,patch:ae})=>(n==="global"?await p.mutateAsync({addonId:J,nodeId:y,patch:ae}):await m.mutateAsync({addonId:J,deviceId:o,nodeId:y,patch:ae}),J)))}},onSuccess:({saved:Z})=>{for(const U of Z)j.current.get(U)?.discard();d.invalidateQueries({queryKey:[["addonSettings"]]})}}),se=q(()=>{for(const Z of j.current.values())Z.discard()},[]),te=Q(()=>{let Z=0;for(const U of _){const J=R.get(U.addonId);J&&(Z+=J.pendingKeys.length)}return Z},[_,R]),X=Q(()=>{const Z=new Map;for(const U of _){const J=R.get(U.addonId);if(!J||J.pendingKeys.length===0)continue;const ae=new Set(J.pendingKeys);for(const fe of U.schema.sections){const he=fe.tab??"general";for(const V of fe.fields)"key"in V&&ae.has(V.key)&&Z.set(he,(Z.get(he)??0)+1)}}return Z},[_,R]);if(k)return r("div",{className:"h-24 rounded-lg border border-border bg-surface animate-pulse"});const re=E&&B?P.get(E):void 0;if(!x&&_.length===0)return u("div",{className:"text-[11px] text-foreground-subtle italic",children:["No addons in ",t.length>0?`[${t.join(", ")}]`:"the current selection"," ","expose ",n,"-level settings on this node."]});const ge=ee.isPending;return u("div",{className:"space-y-4",children:[(l||c)&&u("div",{className:"border-b border-border pb-2",children:[l&&r("h2",{className:"text-sm font-semibold text-foreground",children:l}),c&&r("p",{className:"text-[11px] text-foreground-subtle mt-0.5",children:c})]}),x&&r(qy,{tabs:I.map(Z=>({id:Z,label:F.get(Z)??Z})),activeId:E,onChange:w,pendingByTab:X}),ee.isError&&u("div",{className:"rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400",children:["Save failed: ",String(ee.error?.message??ee.error)]}),re?re.content:(()=>{const Z=O?_.reduce((ae,fe)=>ae+fe.schemaWithValues.sections.filter(he=>(he.tab??"general")===O).length,0):0,U=O!==null&&Z<=1,J=_.map(ae=>({...ae,renderedWithValues:{...ae.schemaWithValues,sections:ae.schemaWithValues.sections.filter(fe=>O?(fe.tab??"general")===O:!0).map(fe=>U?{...fe,title:"",description:void 0}:fe)}})).filter(ae=>ae.renderedWithValues.sections.length>0).sort((ae,fe)=>{const he=ue=>{let de=Number.POSITIVE_INFINITY;for(const le of ue)typeof le.order=="number"&&le.order<de&&(de=le.order);return de},V=he(ae.renderedWithValues.sections),ie=he(fe.renderedWithValues.sections);return V!==ie?V-ie:0});return J.length===0?r("div",{className:"text-[11px] text-foreground-subtle italic",children:"Nothing to configure here for this node."}):r(pO,{entries:J,paneStates:R,displayNames:D,disabled:ge,setPaneRef:H,onPaneStateChange:z,onImmediateSave:G,onAction:W,inline:x||!!a})})(),!k&&r(Vy,{pendingCount:te,onSave:()=>ee.mutate(),onDiscard:se,saving:ge})]})}function pO({entries:e,paneStates:t,displayNames:n,disabled:o,setPaneRef:s,onPaneStateChange:a,onImmediateSave:i,onAction:l,inline:c}){const d=Q(()=>[...e].sort((x,v)=>{if(x.addonId==="system-config")return-1;if(v.addonId==="system-config")return 1;const w=n.get(x.addonId)??x.addonId,y=n.get(v.addonId)??v.addonId;return w.localeCompare(y)}),[e,n]),f=d[0]?.addonId??"",[p,m]=$(f);Y(()=>{d.length!==0&&(d.find(x=>x.addonId===p)||m(d[0].addonId))},[d,p]);const h=d.find(x=>x.addonId===p)??d[0];if(!h)return null;const g=Q(()=>l?(x,v,w,y)=>l(x,v,w,y):void 0,[l]),b=x=>r(cO,{ref:s(x.addonId),addonId:x.addonId,schema:x.renderedWithValues,serverValues:x.serverValues,onImmediateSave:i,onStateChange:a,onAction:g,disabled:o},x.addonId);return d.length===1||c?r("div",{className:"flex flex-col gap-4",children:d.map(b)}):u("div",{className:"flex flex-col gap-3",children:[r("div",{className:"flex flex-wrap items-center gap-1 border-b border-border shrink-0",children:d.map(x=>{const v=n.get(x.addonId)??x.addonId,w=x.addonId===h.addonId,y=(t.get(x.addonId)?.pendingKeys.length??0)>0;return u("button",{type:"button",onClick:()=>m(x.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${w?"text-primary border-primary bg-primary/5":"text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover"}`,children:[v,y&&r("span",{className:"ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400"})]},x.addonId)})}),r("div",{className:"space-y-2",children:d.map(x=>r("div",{style:x.addonId===h.addonId?void 0:{display:"none"},children:b(x)},x.addonId))})]})}const fO=["detection-pipeline","decoder-nodeav","audio-analyzer","pipeline-runner"];function mO({nodeId:e,refreshToken:t}){return u("div",{className:"flex flex-col h-full",children:[r(V6,{nodeId:e,refreshToken:t}),r("div",{className:"flex-1 min-h-0 overflow-y-auto p-6",children:r(Rr,{nodeId:e,addonIds:fO,level:"global",extraTabs:[{id:"assignments",label:"Assignments",order:-10,content:r(X6,{nodeId:e,refreshToken:t})},{id:"tree",label:"Pipeline",order:39,content:r(iO,{nodeId:e,refreshToken:t})},{id:"engines",label:"Warm instances",order:180,content:r(eO,{nodeId:e,refreshToken:t})},{id:"models",label:"Models",order:200,content:r(aO,{nodeId:e,refreshToken:t})}]})})]})}function hO({refreshToken:e}){const t=ke(),n=fb({onSuccess:()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","getPipelineAssignments"]]}),t.invalidateQueries({queryKey:[["pipelineOrchestrator","getDecoderAssignments"]]}),t.invalidateQueries({queryKey:[["pipelineOrchestrator","getAudioAssignments"]]})}});return u("div",{className:"space-y-6",children:[r(Oy,{refreshToken:e}),u("div",{className:"flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between",children:[u("div",{className:"min-w-0",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Placement matrix"}),r("p",{className:"text-[11px] text-foreground-subtle",children:"Pipeline · decoder · audio assignments per camera. Click the kebab to pin / unpin / move any role; expand the chevron for the per-camera broker drill-down."})]}),u("button",{type:"button",onClick:()=>n.mutate(void 0),disabled:n.isPending,className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-white hover:bg-primary/90 disabled:opacity-50 shrink-0 self-start @md/clustertab:self-auto whitespace-nowrap",children:[r(Jc,{className:"h-3.5 w-3.5"}),n.isPending?"Rebalancing…":"Rebalance pipelines"]})]}),r(Fy,{mode:"cluster"})]})}const gO=["pipeline-orchestrator"];function bO({refreshToken:e}){return r("div",{className:"space-y-4 max-w-3xl",children:r(Rr,{nodeId:"hub",addonIds:gO,level:"global",title:"Cluster settings",description:"Cluster-wide orchestration knobs: enabled nodes, load balancer thresholds, and failover policy. Per-camera pipelines live in Device Overrides; live cluster load is on the Assignments tab."})})}function xO({refreshToken:e}){const t=ke(),{data:n,isLoading:o}=Pb(),[s,a]=$(null),[i,l]=$(""),[c,d]=$(""),f=()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","listTemplates"]]})},p=Eb({onSuccess:()=>{a(null),f()}}),m=$b({onSuccess:f}),h=v=>{a(v.id),l(v.name),d(v.description??"")},g=()=>{a(null),l(""),d("")},b=()=>{if(!s)return;const v=c.trim();p.mutate({id:s,name:i.trim()||"Untitled",...v?{description:v}:{}})};if(o)return r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading templates…"});const x=[...n??[]].sort((v,w)=>v.name.localeCompare(w.name));return r("div",{className:"space-y-6 max-w-4xl",children:u("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"border-b border-border px-4 py-3 flex items-center justify-between",children:[u("div",{children:[r("h3",{className:"text-sm font-semibold text-foreground",children:"Templates"}),r("p",{className:"text-[11px] text-foreground-subtle mt-0.5",children:"Curated pipeline presets operators can apply to any camera. Apply-time is a copy — future edits to a template don't retroactively change cameras that were seeded from it. Save a template from the device Pipeline tab."})]}),u("div",{className:"text-[11px] text-foreground-subtle",children:[x.length," template",x.length===1?"":"s"]})]}),x.length===0?u("div",{className:"px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2",children:[r(Ot,{className:"h-6 w-6 opacity-40"}),r("div",{children:'No templates yet. Create one from a device Pipeline tab ("Save as template").'})]}):r("ul",{className:"divide-y divide-border",children:x.map(v=>{const w=s===v.id;return r("li",{className:"px-4 py-3 text-xs",children:u("div",{className:"flex items-start gap-3",children:[r("div",{className:"flex-1 min-w-0",children:w?u("div",{className:"space-y-2",children:[r("input",{className:"w-full rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary",value:i,onChange:y=>l(y.target.value),placeholder:"Template name",autoFocus:!0}),r("input",{className:"w-full rounded border border-border bg-surface-hover px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary",value:c,onChange:y=>d(y.target.value),placeholder:"Description (optional)"})]}):u(ve,{children:[r("div",{className:"font-medium text-foreground",children:v.name}),v.description&&r("div",{className:"text-foreground-subtle mt-0.5",children:v.description}),u("div",{className:"mt-1 font-mono text-[10px] text-foreground-subtle",children:["engine ",v.config.engine.runtime,"/",v.config.engine.backend," · ",v.config.steps.length," step(s)",v.config.audio?.enabled?" · audio":"",u("span",{className:"ml-2",children:["updated ",new Date(v.updatedAt).toLocaleString()]})]})]})}),r("div",{className:"flex items-center gap-1 shrink-0",children:w?u(ve,{children:[u("button",{type:"button",onClick:b,disabled:p.isPending,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-50",children:[r(Ct,{className:"h-3 w-3"}),"Save"]}),u("button",{type:"button",onClick:g,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover",children:[r(qe,{className:"h-3 w-3"}),"Cancel"]})]}):u(ve,{children:[r("button",{type:"button",onClick:()=>h(v),title:"Rename",className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover",children:r(Po,{className:"h-3 w-3"})}),r("button",{type:"button",onClick:()=>{confirm(`Delete template "${v.name}"?`)&&m.mutate({id:v.id})},disabled:m.isPending,title:"Delete",className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-red-400 hover:bg-surface-hover disabled:opacity-50",children:r(We,{className:"h-3 w-3"})})]})})]})},v.id)})})]})})}function pp(e,t){if(!e)return null;for(const n of e.slots)for(const o of n.addons)if(o.id===t)return o;return null}function yO({nodeId:e,refreshToken:t}){const n=ke(),o=Le().trpcClient,[s,a]=$(null),[i,l]=$(null),c=$r(void 0,{refetchOnMount:"always"});yt(["nodes","topology"],["agent.online","agent.offline","agent.unregistered","addon.installed","addon.uninstalled","addon.updated"]);const d=In(void 0,{staleTime:3e4,refetchOnMount:"always"}),f=Q(()=>{const I=new Set;for(const F of d.data??[])F.isOnline&&I.add(F.id);return I},[d.data]),p=So({nodeId:e},{refetchOnMount:"always"}),m=Q(()=>(c.data??[]).filter(I=>f.has(I.nodeId)).map(I=>I.nodeId),[c.data,f]),h=Kn({enabled:m.length>0,queryKey:[["pipelineExecutor","getSchema"],"schema-by-agent",m.join(","),t],queryFn:async()=>{const I={};for(const F of m)try{const E=await o.pipelineExecutor.getSchema.query({nodeId:F});I[F]=E.selectedEngine.format}catch{I[F]="coreml"}return I}}),g=xc({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator"]]}),n.invalidateQueries({queryKey:[["pipelineExecutor"]]}),n.invalidateQueries({queryKey:[["addonSettings"]]})}}),b=Q(()=>p.data?ea(p.data):[],[p.data]),x=Q(()=>{const I=c.data??[],F=f;return(F.size===0?[]:I.filter(B=>F.has(B.nodeId))).map(B=>{const O=h.data?.[B.nodeId];return{agentNodeId:B.nodeId,engineLabel:O??"(engine unknown)"}})},[c.data,h.data,f]),v=(I,F)=>{const B=c.data?.find(_=>_.nodeId===F)?.settings.addonDefaults[I],O=h.data?.[F];return pp(p.data??null,I)?.models.some(_=>O!==void 0&&!!_.formats[O])?B?B.enabled?{kind:"enabled",modelId:B.modelId}:{kind:"disabled"}:{kind:"na"}:{kind:"na"}},w=s?c.data?.find(I=>I.nodeId===s.agentNodeId)??null:null,y=s&&p.data?pp(p.data,s.addonId):null,N=s?h.data?.[s.agentNodeId]??"coreml":"coreml",k=()=>{a(null),l(null)},S=(I,F)=>{const B=c.data?.find(O=>O.nodeId===F)?.settings.addonDefaults[I]??null;a({addonId:I,agentNodeId:F}),l(B)},M=()=>{!i||!s||!w||g.mutate({agentNodeId:s.agentNodeId,defaults:{...w.settings.addonDefaults,[s.addonId]:i}},{onSuccess:k})};if(c.isLoading||p.isLoading)return r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading agents…"});if(!p.data)return u("div",{className:"text-xs text-foreground-subtle",children:["Catalog unavailable for ",e,"."]});const P=s!==null&&y!==null&&i!==null;return u("div",{className:"relative h-full w-full space-y-3",children:[r(Hy,{title:"Cluster cameras"}),r("div",{className:P?"pr-[360px]":"",children:b.length>0&&x.length>0?r(Yl,{tree:b,agents:x,getCellState:v,onCellClick:S,selectedCell:s}):r("div",{className:"text-xs text-foreground-subtle",children:"No agents or catalog empty."})}),r(Wl,{open:P,onClose:k,title:y?.name??"",subtitle:s?`${s.agentNodeId} · ${N}`:"",footer:u(ve,{children:[r("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:k,children:"Cancel"}),r("button",{type:"button",disabled:!i||!s||g.isPending,className:"px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50",onClick:M,children:g.isPending?"Saving…":"Save"})]}),children:y&&i&&s&&r(na,{mode:"agent",addon:y,agentDefault:i,agentNodeId:s.agentNodeId,engineFormat:N,onChangeAgentConfig:I=>l(I)})})]})}const vO=[{id:"assignments",label:"Assignments"},{id:"pipeline",label:"Pipeline"},{id:"settings",label:"Settings"},{id:"templates",label:"Templates"}];function wO({refreshToken:e}){const[t,n]=$("assignments"),{data:o}=In(void 0,{staleTime:3e4}),s=o?.find(a=>a.isHub&&a.isOnline)?.id??o?.find(a=>a.isOnline)?.id??null;return u("div",{className:"flex flex-col h-full",children:[u("div",{className:"px-6 py-4 border-b border-border",children:[r("h2",{className:"text-base font-semibold text-foreground",children:"Cluster Orchestration"}),r("div",{className:"text-[11px] text-foreground-subtle mt-1",children:"Assignments with live load, cluster-wide settings, pipeline template library, per-camera pipeline overrides."})]}),r("div",{className:"flex items-center gap-1 px-6 border-b border-border",children:vO.map(a=>r("button",{type:"button",onClick:()=>n(a.id),className:`px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===a.id?"border-primary text-primary":"border-transparent text-foreground-subtle hover:text-foreground"}`,children:a.label},a.id))}),u("div",{className:"flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab",children:[t==="assignments"&&r(hO,{refreshToken:e}),t==="pipeline"&&(s?r(yO,{nodeId:s,refreshToken:e}):r("div",{className:"text-xs text-foreground-subtle",children:"No online node available — schema unreachable."})),t==="settings"&&r(bO,{refreshToken:e}),t==="templates"&&r(xO,{refreshToken:e})]})]})}const eo="__cluster__";function NO(){const[e,t]=qc(),n=e.get("node")??eo,[o,s]=$(0);return Y(()=>{e.get("node")||t({node:eo},{replace:!0})},[e,t]),u("div",{className:"flex flex-col h-full overflow-hidden",children:[u("div",{className:"flex items-center justify-between gap-4 px-6 py-4 border-b border-border shrink-0",children:[u("div",{className:"flex items-center gap-2",children:[r(oy,{className:"h-4 w-4 text-foreground-subtle"}),r("h1",{className:"text-lg font-semibold text-foreground",children:"Pipeline"})]}),u("button",{type:"button",onClick:()=>s(i=>i+1),title:"Refresh",className:"inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:[r(pt,{className:"h-3.5 w-3.5"}),"Refresh"]})]}),u("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden min-h-0",children:[r("aside",{className:"w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border overflow-y-auto",children:r(H6,{selectedNodeId:n,onSelect:i=>{t({node:i},{replace:!0})},refreshToken:o})}),r("section",{className:"flex-1 min-h-0 overflow-hidden",children:n===eo?r(wO,{refreshToken:o}):r(mO,{nodeId:n,refreshToken:o})})]})]})}function kO(e){const[t,n]=$("idle"),[o,s]=$(null),a=ne(null),i=ne(null),l=ne(null),c=ne(!0),d=Bg(),f=Fg(),p=jg(),m=q(()=>{if(a.current){try{a.current.close()}catch{}a.current=null}if(i.current){for(const b of i.current.getTracks())try{b.stop()}catch{}i.current=null}l.current=null},[]),h=q(async()=>{if(t==="idle")return;n("stopping");const b=l.current;if(b&&e!==null)try{await Promise.race([p.mutateAsync({deviceId:e,sessionId:b}),new Promise((v,w)=>setTimeout(()=>w(new Error("server stopSession timeout")),2e3))])}catch(v){console.warn("[intercom] server stopSession failed (continuing teardown)",v)}m(),c.current&&(n("idle"),s(null))},[t,e,p,m]),g=q(async()=>{if(e===null||t!=="idle"&&t!=="error")return;s(null);let b=null,x=null,v=null;try{n("requesting-mic"),b=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),i.current=b,n("starting");const w=await d.mutateAsync({deviceId:e});v=w.sessionId,l.current=v,n("connecting"),x=new RTCPeerConnection,a.current=x,x.oniceconnectionstatechange=()=>{if(!c.current)return;const k=x.iceConnectionState;k==="connected"||k==="completed"?n("talking"):(k==="failed"||k==="closed"||k==="disconnected")&&c.current&&(s(k==="failed"?"WebRTC connection failed":null),h())};for(const k of b.getAudioTracks())x.addTrack(k,b);await x.setRemoteDescription({type:"offer",sdp:w.sdpOffer});const y=await x.createAnswer();await x.setLocalDescription(y);const N=x.localDescription?.sdp??y.sdp??"";await f.mutateAsync({deviceId:e,sessionId:v,sdpAnswer:N})}catch(w){const y=w instanceof Error?w.message:String(w);if(console.warn("[intercom] start failed",w),x)try{x.close()}catch{}if(b)for(const N of b.getTracks())try{N.stop()}catch{}if(a.current=null,i.current=null,v!==null)try{await p.mutateAsync({deviceId:e,sessionId:v})}catch{}l.current=null,c.current&&(s(y),n("error"))}},[e,t,d,f,p,h]);return Y(()=>(c.current=!0,()=>{c.current=!1;const b=l.current;if(b!==null&&e!==null&&p.mutate({deviceId:e,sessionId:b}),a.current){try{a.current.close()}catch{}a.current=null}if(i.current){for(const x of i.current.getTracks())try{x.stop()}catch{}i.current=null}l.current=null}),[e]),{state:t,error:o,start:g,stop:h,isTalking:t==="talking"}}let SO=0;function st(){return++SO}function yi(e){switch(e.type){case"system":return"system";case"device":return`#${e.deviceId}`;case"provider":return e.providerId;case"addon":return e.addonId}}function CO(e){return["","Commands"," help Show this help"," examples Show usage examples for the current scope"," context Show every available variable + full API surface"," clear Clear terminal (also Ctrl+L)","","Shortcuts"," Enter Execute expression"," Arrow Up/Down Navigate command history"," Ctrl+L Clear terminal","",`Try: ${{system:" sm.summary() // fleet overview",device:" device.state.battery.value?.sleeping // sync read",provider:" devices.map(d => d.name)",addon:" manifest.version"}[e.type]}`,"","Top-level objects: sm (SystemMirror), DeviceType, Math, JSON, Date, …"]}function MO(e){switch(e.type){case"device":return["","── State (sync, zero round-trip) ─────────────────────────"," device.state.battery.value"," device.state.battery.value?.percentage"," device.state.motion.value?.detected","","── Actions (async, through wrapper chain) ────────────────"," await device.snapshot.getSnapshot({})"," await device.ptz.move({ direction: 'left', steps: 1 })"," await device.switch.setState({ on: true })","","── Wait for condition ───────────────────────────────────"," await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)","","── Subscribe to changes ─────────────────────────────────"," const off = device.state.battery.subscribe(s => console.log(s))","","── Quick info ───────────────────────────────────────────"," info.name device name"," info.addonId owning addon"," sm.dump(deviceId) full debug dump"];case"system":return["","── Lookups ──────────────────────────────────────────────"," sm.getDeviceById(8)"," sm.getDeviceByName('Sala da pranzo')"," sm.getDevicesByAddon('reolink')"," sm.getDevicesByType(DeviceType.Camera)","","── Filters (typed query) ────────────────────────────────"," sm.query({ addonId: 'reolink', online: true })"," sm.query({ caps: ['battery', 'snapshot'] })"," sm.query({ name: /^Cam-/ })","","── Cross-device ─────────────────────────────────────────"," sm.whereState('battery', s => s.percentage < 20).length"," sm.mapState('battery', s => s.percentage)"," sm.countByCap('snapshot')","","── Batch action ─────────────────────────────────────────"," await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })","","── Listen ───────────────────────────────────────────────"," sm.listenCap('motion', (id, s) => console.log(id, s))"," sm.onDeviceAdded((id, info) => console.log('+', info.name))","","── Diagnostics ──────────────────────────────────────────"," sm.summary()"," sm.dump(8)"];case"provider":return[""," devices.map(d => d.name)"," await getIntegration()"," sm.getDevicesByAddon('<this-addon-id>').length"];case"addon":return[""," manifest.name"," manifest.version"," declaration"]}}function IO(e){const t=["",`Scope: ${e.type}`,""];switch(e.type){case"system":return[...t,"Primary API — sm (SystemMirror):"," sm.getDeviceById(id) DeviceProxy | null (sync)"," sm.getDeviceByName(name) DeviceProxy | null"," sm.getDeviceByStableId(sid) DeviceProxy | null"," sm.getAllDevices() readonly DeviceProxy[]"," sm.getDeviceInfo(id) DeviceInfo | null"," sm.summary() fleet stats","","Filters — sm.query({...}):"," sm.query({ addonId: 'reolink', online: true })"," sm.query({ caps: ['battery', 'snapshot'] }) // ALL caps required"," sm.query({ anyCap: ['ptz', 'motion'] }) // ANY cap"," sm.query({ name: { contains: 'sala' } }) // case-insensitive"," sm.query({ name: /^Cam-\\d+$/ })"," sm.query({ type: DeviceType.Camera })"," sm.query({ parentDeviceId: 8 }) // accessories of cam 8"," sm.query({ where: (info, dev) => dev.state.battery.value?.sleeping })","","State queries:"," sm.whereState('battery', s => s.percentage < 20)"," sm.mapState('battery', s => s.percentage)"," sm.findState('motion', s => s.detected)"," sm.countByCap('snapshot')","","Listeners (return unsubscribe fn):"," sm.listen((id, cap, slice) => …) // every state change"," sm.listenCap('motion', (id, slice) => …)"," sm.listenDevice(8, (id, cap, slice) => …)"," sm.onDeviceAdded((id, info) => …)"," sm.onDeviceRemoved((id, info) => …)","","Wait primitives:"," await sm.waitForState(8, 'battery', s => !s.sleeping, 30_000)"," await sm.waitForDevice(99, 30_000)","","Batch:"," await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })"," await sm.forEachCap('reboot', d => d.reboot.reboot({}))","","Diagnostics:"," sm.dump(8) debug dump (one device)"," sm.dump() full fleet dump"," sm.summary() breakdown by cap/addon/type","","Legacy: deviceRegistry, addonRegistry, eventBus, devices(), addons()"];case"device":return[...t,"Pre-bound variables:"," device DeviceProxy for this device (sync state + async methods)"," deviceId number"," info DeviceInfo metadata (name, addonId, type, online, …)"," sm SystemMirror (full cluster view)"," rawDevice legacy IDevice instance (escape hatch)","","Reactive state (sync, zero round-trip):"," device.state.battery.value BatteryStatus | undefined"," device.state.battery.value?.sleeping"," device.state.battery.value?.percentage"," device.state.motion.value?.detected"," device.state.switch.value?.on"," device.state.brightness.value?.percentage"," device.state.doorbell.value?.lastPressedAt","","Cap actions (async, through wrapper chain):"," await device.snapshot.getSnapshot({})"," await device.snapshot.getSnapshot({ streamId: 'high' })"," await device.ptz.move({ direction: 'left', steps: 1 })"," await device.ptz.goToPreset({ presetId: 'home' })"," await device.switch.setState({ on: true })"," await device.brightness.setBrightness({ percentage: 60 })"," await device.reboot.reboot({})","","Subscribe to slice changes:"," const off = device.state.battery.subscribe(s => console.log(s))"," // off() to unsubscribe","","Wait for a state condition:"," await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)","","Diagnostics:"," info.name device name"," info.addonId which addon owns it"," info.online transport health"," sm.dump(deviceId) full debug dump (binding + state + info)"];case"provider":return[...t,"Pre-bound variables:"," devices Devices belonging to this provider (raw IDevice[])"," getIntegration() Integration metadata","","For typed device access use the SystemMirror:"," await getSystemMirror()"," sm.getDevicesByAddon('this-addon-id')"];case"addon":return[...t,"Pre-bound variables:"," manifest { name, version, ... }"," declaration addon declaration"," source addon source location","","Examples:"," manifest.name"," manifest.version"]}}function AO({scope:e,greeting:t,className:n}){const o=Le(),[s,a]=$(()=>{const y=[];return t&&y.push({id:st(),kind:"info",text:t}),y.push({id:st(),kind:"info",text:`scope: ${yi(e)} — type help or context for available commands`}),y}),[i,l]=$(""),[c,d]=$([]),[f,p]=$(-1),m=ne(null),h=ne(null);Y(()=>{const y=h.current;y&&(y.scrollTop=y.scrollHeight)},[s]);const g=q(()=>{m.current?.focus()},[]),b=El({mutationFn:y=>o.trpcClient.repl.execute.mutate({code:y,scope:e}),onSuccess:y=>{const N=y??{},k=typeof N.output=="string"?N.output:y==null?"undefined":typeof y=="string"?y:JSON.stringify(y,null,2),S=N.type==="error";a(M=>[...M,{id:st(),kind:S?"error":"result",text:k}])},onError:y=>{const N=y instanceof Error?y.message:String(y);a(k=>[...k,{id:st(),kind:"error",text:N}])}});function x(y){const N=y.trim();if(N){if(N==="clear"){a([{id:st(),kind:"info",text:`scope: ${yi(e)}`}]),l("");return}if(N==="help"){a(k=>[...k,{id:st(),kind:"input",text:`> ${N}`},...CO(e).map(S=>({id:st(),kind:"info",text:S}))]),l("");return}if(N==="context"){a(k=>[...k,{id:st(),kind:"input",text:`> ${N}`},...IO(e).map(S=>({id:st(),kind:"info",text:S}))]),l("");return}if(N==="examples"){a(k=>[...k,{id:st(),kind:"input",text:`> ${N}`},...MO(e).map(S=>({id:st(),kind:"info",text:S}))]),l("");return}d(k=>[...k,N]),p(-1),a(k=>[...k,{id:st(),kind:"input",text:`> ${N}`}]),l(""),b.mutate(N)}}function v(y){if(y.key==="Enter"){y.preventDefault(),x(i);return}if(y.key==="ArrowUp"){if(y.preventDefault(),c.length===0)return;const N=f===-1?c.length-1:Math.max(0,f-1);p(N),l(c[N]??"");return}if(y.key==="ArrowDown"){if(y.preventDefault(),f===-1)return;const N=f+1;N>=c.length?(p(-1),l("")):(p(N),l(c[N]??""));return}y.ctrlKey&&y.key==="l"&&(y.preventDefault(),a([{id:st(),kind:"info",text:`scope: ${yi(e)}`}]))}const w={input:"text-zinc-300",result:"text-emerald-300",error:"text-red-300",info:"text-zinc-400"};return u("div",{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${n??""}`,onClick:g,children:[u("div",{ref:h,className:"flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]",children:[s.map(y=>r("pre",{className:`whitespace-pre-wrap break-words leading-relaxed ${w[y.kind]}`,children:y.text},y.id)),b.isPending&&r("span",{className:"text-zinc-500 animate-pulse",children:"…thinking"})]}),u("div",{className:"flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]",children:[r("span",{className:"text-emerald-400 flex-shrink-0 select-none font-bold",children:">"}),r("input",{ref:m,value:i,onChange:y=>l(y.target.value),onKeyDown:v,disabled:b.isPending,placeholder:"device.state.battery.value",autoFocus:!0,className:"flex-1 bg-transparent text-zinc-100 placeholder:text-zinc-600 focus:outline-none caret-emerald-400 disabled:opacity-50",spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"})]})]})}function PO(e){const t=ke(),n=e!==null&&Number.isFinite(e),o=Db({deviceId:e??0},{enabled:n,refetchInterval:5e3,retry:1}),s=Lb({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),a=Tb({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),i=q(async d=>{e!==null&&await s.mutateAsync({deviceId:e,enabled:d})},[e,s]),l=q(async d=>{e!==null&&await a.mutateAsync({deviceId:e,settings:d})},[e,a]),c=o.error?o.error.message:s.error?s.error.message:a.error?a.error.message:null;return{status:o.data??null,isLoading:o.isLoading,isPending:s.isPending||a.isPending,error:c,setEnabled:i,setSettings:l}}function EO({deviceId:e}){const{status:t,isLoading:n,isPending:o,error:s,setEnabled:a,setSettings:i}=PO(Number.isFinite(e)?e:null),[l,c]=$({targetType:"",stopDelaySeconds:30,disappearDelaySeconds:15}),[d,f]=$(!1);return Y(()=>{if(d)return;const p=t?.currentSettings;p&&c({targetType:p.targetType,stopDelaySeconds:p.stopDelaySeconds,disappearDelaySeconds:p.disappearDelaySeconds})},[t,d]),n&&!t?u("div",{className:"flex items-center gap-2 px-3 py-2 text-[10.5px] text-foreground-subtle",children:[r(Pe,{className:"h-3 w-3 animate-spin"}),"Loading autotrack…"]}):u("div",{className:"border-t border-border/40 mt-2 pt-2 px-1 space-y-2",children:[u("div",{className:"flex items-center justify-between px-2",children:[u("div",{className:"flex items-center gap-1.5 text-[10.5px] font-semibold text-foreground",children:[r(PD,{className:"h-3 w-3 text-primary"}),"Autotracking"]}),u("button",{type:"button",onClick:()=>{a(!(t?.enabled??!1))},disabled:o,className:`flex items-center gap-1.5 rounded-md px-2 py-1 text-[10px] font-medium transition-colors ${t?.enabled?"bg-success/15 text-success hover:bg-success/25":"bg-surface-elevated/40 text-foreground-subtle hover:bg-surface-hover hover:text-foreground"} disabled:opacity-50`,"aria-pressed":t?.enabled??!1,children:[r("span",{className:`h-1.5 w-1.5 rounded-full ${t?.enabled?"bg-success":"bg-foreground-subtle/40"}`}),t?.enabled?"Enabled":"Disabled"]})]}),s&&u("div",{className:"flex items-start gap-1.5 rounded-md border border-danger/30 bg-danger/5 px-2 py-1.5 text-[10px] text-danger",children:[r(ba,{className:"h-3 w-3 flex-shrink-0 mt-0.5"}),r("span",{className:"leading-snug break-words",children:s})]}),u("div",{className:"grid grid-cols-2 gap-2 px-2",children:[(t?.supportedTargetTypes?.length??0)>0&&u("label",{className:"col-span-2 flex flex-col gap-1",children:[r("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Target type"}),r("select",{value:l.targetType,onFocus:()=>f(!0),onChange:p=>c(m=>({...m,targetType:p.target.value})),onBlur:()=>{f(!1);const p=t?.currentSettings?.targetType??"";l.targetType!==p&&i({targetType:l.targetType})},disabled:o,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50",children:(t?.supportedTargetTypes??[]).map(p=>r("option",{value:p.value,children:p.label},p.value))})]}),u("label",{className:"flex flex-col gap-1",children:[r("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Stop delay (s)"}),r("input",{type:"number",min:0,max:300,value:l.stopDelaySeconds,onFocus:()=>f(!0),onChange:p=>c(m=>({...m,stopDelaySeconds:Number(p.target.value)||0})),onBlur:()=>{f(!1);const p=t?.currentSettings?.stopDelaySeconds??30;l.stopDelaySeconds!==p&&i({stopDelaySeconds:l.stopDelaySeconds})},disabled:o,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50"})]}),u("label",{className:"flex flex-col gap-1",children:[r("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Disappear delay (s)"}),r("input",{type:"number",min:0,max:300,value:l.disappearDelaySeconds,onFocus:()=>f(!0),onChange:p=>c(m=>({...m,disappearDelaySeconds:Number(p.target.value)||0})),onBlur:()=>{f(!1);const p=t?.currentSettings?.disappearDelaySeconds??15;l.disappearDelaySeconds!==p&&i({disappearDelaySeconds:l.disappearDelaySeconds})},disabled:o,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50"})]})]}),r("p",{className:"px-2 text-[9.5px] text-foreground-subtle leading-snug italic",children:"Settings save on blur. Vendor support varies — Reolink honours all three; Hikvision honours target type + stop delay only (disappear delay is accepted but ignored at firmware push)."})]})}function $O({deviceId:e,intercomAvailable:t=!1}){const n=Le(),o=typeof window<"u"?window.location.origin:"",s=Number.isFinite(e),a=vy(s?e:null),{streams:i,pipelineMetrics:l,createSession:c,sendAnswer:d,closeSession:f}=_c(n.trpcClient,s?e:null),p=tc(n.trpcClient,s?e:null),m=kO(s&&t?e:null),h=m.state==="requesting-mic"||m.state==="starting"||m.state==="connecting"||m.state==="stopping",g=m.isTalking||h,b=()=>{m.state==="idle"||m.state==="error"?m.start():m.state!=="stopping"&&m.stop()},x=vx(),v=x.length>0?r(ve,{children:x.map(w=>r("div",{className:"absolute inset-0",children:w.node},w.id))}):null;return r(Ic,{serverUrl:o,createSession:c,sendAnswer:d,closeSession:f,streams:i,pipelineMetrics:l,phase:a.phase,detections:a,defaultShowDetections:!0,defaultShowMotion:!0,showPlayStop:!0,snapshotSrc:p.src,snapshotLoading:p.loading,onRefreshSnapshot:p.refresh,intercomAvailable:t,intercomShown:g,onIntercomToggle:b,extraOverlay:v,chromeless:!0,className:"h-full"})}function _O({deviceId:e}){return Number.isFinite(e)?r("div",{className:"flex flex-col h-full",children:r(Wt,{deviceId:e,limit:50,maxHeight:"max-h-full",showScope:!1,showFilters:!1})}):u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function DO({deviceId:e}){if(!Number.isFinite(e))return u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]});const t=[`CamStack REPL — device #${e}`,""," device.state.battery.value sync state read"," await device.snapshot.getSnapshot({}) cap action",""," type 'examples' for more, 'context' for the full API"].join(`
|
|
1084
|
+
`);return r(AO,{scope:{type:"device",deviceId:e},greeting:t,className:"h-full border-0 rounded-none"})}function LO({deviceId:e}){const t=Le(),n=Number.isFinite(e),o=Dc(t.trpcClient,n?e:0,{enabled:n}),{data:s}=q6(n?e:0);if(!n)return u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]});const a=(s?.features??[]).includes(Rn.PtzAutotrack);return u("div",{className:"flex flex-col h-full overflow-y-auto",children:[r(Ec,{controls:o,mode:"panel"}),a&&r(EO,{deviceId:e})]})}function TO({deviceId:e}){return Number.isFinite(e)?r("div",{className:"flex flex-col h-full overflow-y-auto",children:r(nr,{deviceId:e,limit:50,maxHeight:"max-h-full"})}):u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function RO({deviceId:e}){return Number.isFinite(e)?r("div",{className:"flex flex-col h-full overflow-y-auto",children:r(Pc,{deviceId:e,limit:50,maxHeight:"max-h-full"})}):u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function OO({parentDeviceId:e}){const{t}=zt(),n=et(),o=Le(),{data:s,isLoading:a,isError:i}=By(e);if(a)return r("div",{className:"rounded-lg border border-border bg-surface p-3",children:r("p",{className:"text-[10px] text-foreground-subtle",children:t("common.loading",{defaultValue:"Loading…"})})});if(i)return r("div",{className:"rounded-lg border border-border bg-surface p-3",children:r("p",{className:"text-[10px] text-warning",children:t("integrations.childrenLoadError",{defaultValue:"Failed to load children"})})});const l=s??[];if(l.length===0)return null;const c=l.some(p=>!!p.role),d=l.some(p=>!p.role),f=c&&!d?t("device.accessories",{defaultValue:"Accessories"}):!c&&d?t("device.adoptedDevices",{defaultValue:"Adopted devices"}):t("device.children",{defaultValue:"Children"});return u("div",{className:"rounded-lg border border-border bg-surface p-3",children:[r("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5",children:f}),r("div",{className:"space-y-1",children:l.map(p=>r(so,{trpc:o.trpcClient,device:p,variant:"minimal",onNavigate:m=>n(`/devices/${String(m)}`)},p.id))})]})}function vi(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function zO({device:e}){const t=et(),n=typeof e.id=="number"?e.id:null,o=String(e.type??""),s=o===at.Camera,a=o===at.Hub,i=e.features??[],{data:l}=gc({deviceId:n??0},{enabled:n!==null&&s,refetchInterval:5e3}),c=l?.streams??{},d=Object.entries(c),f=i.includes(Rn.DoorbellButton),p=Lc(f?{deviceId:n??void 0,historyLimit:10}:void 0),m=p.latest?Date.now()-p.latest.timestamp<3e4:!1;return u("div",{className:"space-y-5",children:[a&&n!==null&&r(Sx,{deviceId:n,onOpenChild:h=>t(`/devices/${h}`)}),s&&n!==null&&r(it,{widgetId:"pipeline-orchestrator/pipeline-quick-stats",host:"device-tab",deviceId:n}),f&&r($c,{history:p.history,latestIsFresh:m}),s&&n!==null&&r(it,{widgetId:"stream-broker/stream-broker-panel",host:"device-tab",deviceId:n}),s&&d.length>0&&u("div",{className:"@container rounded-lg border border-border bg-surface overflow-hidden",style:{containerType:"inline-size"},children:[r("div",{className:"border-b border-border px-4 py-2",children:r("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:"Stream Network"})}),r("div",{className:"divide-y divide-border",children:d.map(([h,g])=>u("div",{className:"px-4 py-2.5",children:[u("div",{className:"flex items-center gap-2 mb-2",children:[r(jn,{className:"h-3 w-3 text-foreground-subtle"}),r("span",{className:"text-[11px] font-medium text-foreground",children:h})]}),u("div",{className:"grid grid-cols-2 @[640px]:grid-cols-4 gap-2",children:[r(Xo,{label:"Nominal",value:vi(g.nominalBitrateKbps??0)}),r(Xo,{label:"Observed",value:vi(g.observedBitrateKbps??0)}),r(Xo,{label:"Peak",value:vi(g.peakBitrateKbps??0)}),r(Xo,{label:"Packet Loss",value:`${(g.packetLossPercent??0).toFixed(2)}%`,warning:(g.packetLossPercent??0)>1})]})]},h))})]}),r(Ny,{})]})}function Xo({label:e,value:t,warning:n}){return u("div",{children:[r("p",{className:"text-[10px] text-foreground-subtle",children:e}),r("p",{className:`text-xs font-medium ${n?"text-warning":"text-foreground"}`,children:t})]})}function BO({schema:e,values:t,pendingKeys:n,onChange:o,onAction:s,onSave:a,onDiscard:i,disabled:l}){const c=e.tabs??[],d=Q(()=>{const k=new Map;for(const S of e.sections){const M=S.tab??"general",P=k.get(M)??[];P.push(S),k.set(M,P)}return k},[e.sections]),f=new Set(c.map(k=>k.id)),p=[...c,...[...d.keys()].filter(k=>!f.has(k)).map(k=>({id:k,label:k,icon:"wrench",order:100}))],m=p[0]?.id??"general",[h,g]=$(m),b=d.get(h)??[],v={sections:b.length<=1?b.length===1?[{...b[0],title:""}]:b:b.every(S=>!S.title)?[{...b[0],title:"",fields:b.flatMap(S=>S.fields)}]:b},w=r(Vy,{pendingCount:n.length,onSave:()=>a(n),onDiscard:()=>i(n),saving:l});if(p.length<=1)return u("div",{className:"flex flex-col gap-3",children:[r(Nn,{schema:e,values:t,onChange:o,onAction:s,disabled:l}),w]});const y=new Map,N=new Map;for(const[k,S]of d){y.set(k,S.length);const M=new Set,P=F=>{for(const E of F)if("key"in E&&typeof E.key=="string"&&M.add(E.key),E.type==="group")P(E.fields);else if(E.type==="sub-tabs")for(const B of E.tabs)P(B.fields)};for(const F of S)P(F.fields);const I=n.filter(F=>M.has(F)).length;I>0&&N.set(k,I)}return u("div",{className:"flex flex-col gap-3",children:[r(qy,{tabs:p.map(k=>({id:k.id,label:k.label})),activeId:h,onChange:g,countByTab:y,pendingByTab:N}),r(Nn,{schema:v,values:t,onChange:o,onAction:s,disabled:l}),w]})}const fp={viewer:10,admin:20,super_admin:30};function FO(e,t){if(!t)return!0;const n=fp[t];return n===void 0?!0:(e?fp[e]??0:0)>=n}function jO(e){if(!e)return null;const n={sections:[...e.sections].sort((o,s)=>{const a=o.tab??"general",i=s.tab??"general";return a!==i?a.localeCompare(i):(o.order??0)-(s.order??0)})};return e.tabs?{...n,tabs:e.tabs}:n}function Ky(e){return e.type==="separator"||e.type==="info"||e.type==="button"||e.type==="widget"||e.type==="addon-action-button"}function Gy(e){return e.key}function HO(e){if(!Ky(e))return e.value}function Wy(e){return Ky(e)?null:e}function Ls(e,t){for(const n of e)if(t(n),n.type==="group")Ls(n.fields,t);else if(n.type==="sub-tabs")for(const o of n.tabs)Ls(o.fields,t)}function VO(e){if(!e)return{};const t={};for(const n of e.sections)Ls(n.fields,o=>{const s=Gy(o);s!==null&&(t[s]=HO(o))});return t}function mp(e,t){if(!e)return null;let n=null;for(const o of e.sections)if(Ls(o.fields,s=>{if(n!==null||Gy(s)!==t)return;const a=Wy(s);a&&a.writerCapName&&a.writerAddonId&&(n={capName:a.writerCapName,addonId:a.writerAddonId})}),n!==null)break;return n}function qO(e){return{...e,fields:e.fields.map(Yy)}}function Yy(e){return e.type==="separator"||e.type==="info"||e.type==="button"||e.type==="object-array"?e:{...e,readonlyField:!0}}function QO(e,t){return e&&{...e,sections:e.sections.map(n=>({...n,fields:n.fields.map(o=>{const s=Wy(o);return s?FO(t,s.minRole)?o:Yy(o):o})}))}}function Zy({deviceId:e,sectionFilter:t}){const n=ke(),{user:o}=Tr(),s=o?.role,a=ne(!1),{data:i,isLoading:l}=fc({deviceId:e},{refetchInterval:()=>a.current?!1:2500,staleTime:6e4,enabled:Number.isFinite(e)}),{data:c}=Fn({deviceId:e},{staleTime:6e4,enabled:Number.isFinite(e)}),d=i?.settings??null,f=i?.live??null,p=Q(()=>{if(!d&&!f)return null;const B=d?.sections??[],O=(f?.sections??[]).map(qO),A=[...B,...O],D=t?A.filter(t):A.filter(z=>z.location!=="top-tab");if(D.length===0)return null;const _=new Set;for(const z of D)_.add(z.tab??"general");const L=[...d?.tabs??[],...(f?.tabs??[]).filter(z=>!(d?.tabs??[]).some(j=>j.id===z.id))].filter(z=>_.has(z.id));return L.length>0?{tabs:L,sections:D}:{sections:D}},[d,f,t]),m=Q(()=>jO(p),[p]),h=Q(()=>QO(m,s),[m,s]),g=Q(()=>VO(h),[h]),b=Wb(),x=hc(),v=Ag({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]})}}),w={isPending:v.isPending,mutate:B=>{v.mutate({deviceId:e,changes:[...B]})}},y=q(B=>{const O=Object.entries(B).map(([A,D])=>{const _=mp(h,A);return _?{writerCapName:_.capName,writerAddonId:_.addonId,key:A,value:D}:null}).filter(A=>A!==null);O.length>0&&w.mutate(O)},[h,w]),N=q(B=>{const O=Object.entries(B).map(([A,D])=>{const _=mp(h,A);return _?{writerCapName:_.capName,writerAddonId:_.addonId,key:A,value:D}:null}).filter(A=>A!==null);O.length>0&&w.mutate(O)},[h,w]),k=Qy({schema:h,serverValues:g,onImmediateSave:y,onDeferredSave:N}),{values:S,pendingKeys:M,handleChange:P,handleSave:I,handleDiscard:F}=k;if(a.current=k.editingPaused,l)return u("div",{className:"flex items-center justify-center py-12 text-foreground-subtle",children:[r(Pe,{className:"h-4 w-4 animate-spin mr-2"}),r("span",{className:"text-xs",children:"Loading device aggregate…"})]});if(!h||h.sections.length===0)return r("div",{className:"text-xs text-foreground-subtle italic py-4 text-center",children:"No aggregate contributions for this device."});async function E(B,O,A){if(B==="regenerate-rtsp-token"){const D=["rtspUrl:","regenerateToken:"].find(L=>O.startsWith(L));if(!D)throw new Error(`regenerate-rtsp-token: unrecognised key "${O}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);const _=O.slice(D.length);if(!_)throw new Error(`regenerate-rtsp-token: key "${O}" has no streamId after prefix`);const R=`${e}/${_}`;await b.mutateAsync({brokerId:R}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]});return}if(B==="test-probe"){if(!c)return{status:"error",error:"Device metadata not loaded yet"};try{return await x.mutateAsync({addonId:c.addonId,type:c.type,key:O,value:A})}catch(D){return{status:"error",error:D instanceof Error?D.message:String(D)}}}if(B==="refresh-driver-data"){await v.mutateAsync({deviceId:e,changes:[{writerCapName:"device-manager",writerAddonId:"device-manager",key:O,value:Date.now()}]});return}throw new Error(`[device-aggregate] unknown action "${B}"`)}return r(BO,{schema:h,values:S,pendingKeys:M,onChange:P,onAction:E,onSave:I,onDiscard:F,disabled:w.isPending})}function UO({deviceId:e}){return r(Zy,{deviceId:e})}const Xy=6e4,dl=60*Xy,hp=24*dl;function ka(e){if(e==null||e<=0)return"—";const t=Date.now()-e;return t<0||t<3e4?"just now":t<dl?`${String(Math.floor(t/Xy))}m ago`:t<hp?`${String(Math.floor(t/dl))}h ago`:`${String(Math.floor(t/hp))}d ago`}function KO(e,t=new Date){const n=new Date(e);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()}function Jy({dev:e,busy:t,setBusy:n}){const o=e?.motionTrigger,s=on(e?.state.motionTrigger),[a,i]=$(!1);if(!o)return null;const l=s?.enabled===!0,c=s!==void 0,d=async()=>{if(t||!c)return;const p=!l;n(!0),i(!0);try{await o.setMotionTrigger({enabled:p})}finally{n(!1),i(!1)}};return u("button",{type:"button",onClick:()=>{d()},disabled:t||!c,title:c?l?"Disable trigger on motion":"Enable trigger on motion":"Awaiting state…","aria-pressed":l,className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${l?"border-primary/50 bg-primary/15 text-primary":"border-border bg-surface text-foreground-subtle hover:text-foreground"}`,children:[r(Io,{className:"h-3 w-3"}),r("span",{children:a?l?"Disabling…":"Enabling…":c?l?"On motion: on":"On motion: off":"On motion: …"})]})}function e0({deviceId:e,deviceName:t,useSiren:n=!1}){const o=Le(),s=kt(o.trpcClient,e),a=on(s?.state.switch),[i,l]=$(!1),c=a?.on??!1,d=a?.lastChangedAt??null,f=a!==void 0,p=n?Ao:py,m=async()=>{if(!(i||!f||!s?.switch)){l(!0);try{await s.switch.setState({on:!c})}finally{l(!1)}}};return u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[r("button",{type:"button",onClick:()=>{m()},disabled:i||!f||!s?.switch,title:f?c?`Turn off ${t}`:`Turn on ${t}`:"Awaiting state…","aria-pressed":c,className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all disabled:cursor-not-allowed disabled:opacity-50 ${c?"border-success bg-success/20 text-success shadow-lg shadow-success/20":"border-border bg-surface text-foreground-subtle hover:border-foreground-subtle hover:text-foreground"}`,children:r(p,{className:"h-10 w-10"})}),r(Jy,{dev:s,busy:i,setBusy:l}),u("div",{className:"text-center",children:[r("div",{className:`text-sm font-semibold ${c?"text-success":"text-foreground-subtle"}`,children:f?c?"On":"Off":"Unknown"}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:f?`Changed ${ka(d)}`:"Awaiting state…"})]})]})}function GO({deviceId:e,deviceName:t}){const n=Le(),o=kt(n.trpcClient,e),s=on(o?.state.switch),a=on(o?.state.brightness),i=s?.on??!1,l=s?.lastChangedAt??null,c=s!==void 0,d=a!==void 0,f=o?.brightness!==void 0,[p,m]=$(!1),[h,g]=$(a?.percentage??0);Y(()=>{a?.percentage!==void 0&&g(a.percentage)},[a?.percentage]);const b=async()=>{if(!(p||!c||!o?.switch)){m(!0);try{await o.switch.setState({on:!i})}finally{m(!1)}}},x=async()=>{if(!(p||!d||!o?.brightness)){m(!0);try{await o.brightness.setBrightness({percentage:h})}finally{m(!1)}}};return u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[r("button",{type:"button",onClick:()=>{b()},disabled:p||!c||!o?.switch,title:c?i?`Turn off ${t}`:`Turn on ${t}`:"Awaiting state…","aria-pressed":i,className:`flex h-20 w-20 items-center justify-center rounded-full border-2 transition-all disabled:cursor-not-allowed disabled:opacity-50 ${i?"border-warning bg-warning/20 text-warning shadow-lg shadow-warning/30":"border-border bg-surface text-foreground-subtle hover:border-foreground-subtle hover:text-foreground"}`,children:r(rL,{className:"h-9 w-9"})}),f?u("div",{className:"flex w-full max-w-xs flex-col items-center gap-1",children:[r("input",{type:"range",min:0,max:100,step:1,value:h,disabled:p||!i||!d,onChange:v=>g(Number(v.currentTarget.value)),onPointerUp:()=>{x()},onKeyUp:v=>{v.key==="Enter"&&x()},"aria-label":"Brightness",className:"w-full accent-warning disabled:cursor-not-allowed disabled:opacity-50"}),r("div",{className:"text-[10px] text-foreground-subtle tabular-nums",children:d?`${String(h)}%`:"Brightness unavailable"})]}):null,r(Jy,{dev:o,busy:p,setBusy:m}),u("div",{className:"text-center",children:[r("div",{className:`text-sm font-semibold ${i?"text-warning":"text-foreground-subtle"}`,children:c?i?"On":"Off":"Unknown"}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:c?`Changed ${ka(l)}`:"Awaiting state…"})]})]})}function WO({deviceId:e}){const t=Le(),n=kt(t.trpcClient,e),o=on(n?.state.motion),s=o?.detected??!1,a=o?.lastDetectedAt??null,i=o!==void 0;return u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[r("div",{className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all ${s?"border-danger bg-danger/20 text-danger shadow-lg shadow-danger/30 animate-pulse":"border-border bg-surface text-foreground-subtle"}`,"aria-live":"polite",title:s?"Motion detected":"Idle",children:s?r(LL,{className:"h-10 w-10"}):r(Io,{className:"h-10 w-10"})}),u("div",{className:"text-center",children:[r("div",{className:`text-sm font-semibold ${s?"text-danger":"text-foreground-subtle"}`,children:i?s?"Triggered":"Idle":"Unknown"}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:i?`Last trip ${ka(a)}`:"Awaiting state…"})]})]})}function YO({deviceId:e}){const t=Le(),n=kt(t.trpcClient,e),o=on(n?.state.doorbell),s=o?.lastPressedAt??null,a=o!==void 0,i=s!==null&&Date.now()-s<6e4,[l,c]=$(0),[d,f]=$(null);return Y(()=>{s===null||s===d||(f(s),KO(s)&&c(p=>p+1))},[s,d]),u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[r("div",{className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all ${i?"border-primary bg-primary/20 text-primary shadow-lg shadow-primary/30 animate-pulse":"border-border bg-surface text-foreground-subtle"}`,"aria-live":"polite",title:i?"Just pressed":"Idle",children:r(Ao,{className:"h-10 w-10"})}),u("div",{className:"text-center",children:[r("div",{className:`text-sm font-semibold ${i?"text-primary":"text-foreground-subtle"}`,children:a?`Last press ${ka(s)}`:"Unknown"}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5 tabular-nums",children:a?`${String(l)} ring${l===1?"":"s"} today`:"Awaiting state…"})]})]})}function ZO({deviceName:e,deviceType:t,provider:n,isOnline:o,features:s}){return u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border bg-surface p-6 text-center",children:[r(cn,{type:n,size:"lg"}),u("div",{children:[r("div",{className:"text-sm font-semibold text-foreground",children:e}),r("div",{className:"text-[10px] text-foreground-subtle uppercase tracking-wider mt-0.5",children:t})]}),u("div",{className:"flex items-center gap-2 flex-wrap justify-center",children:[r(Na,{status:o?"online":"offline"}),s.length>0&&r(va,{capabilities:s})]}),r("div",{className:"text-[10px] text-foreground-subtle italic max-w-xs mt-1",children:"No live view for this device type. Use the Config tab or the shortcut row to interact."})]})}function XO({deviceId:e}){const t=ke(),n=gg({deviceId:e},{refetchInterval:1e4,retry:!1}),o=bg({onSuccess:()=>{t.invalidateQueries({queryKey:[["deviceDiscovery","listDiscovered"]]}),t.invalidateQueries({queryKey:[["deviceDiscovery","getStatus"]]})}}),s=Q(()=>JO(n.data??[]),[n.data]);return u("div",{className:"flex h-full w-full flex-col gap-3 p-3 sm:p-4",children:[u("div",{className:"flex flex-wrap items-stretch gap-2 sm:gap-3",children:[r(wi,{label:"Discovered",value:s.total,icon:r(an,{className:"h-3.5 w-3.5"})}),r(wi,{label:"Adopted",value:s.adopted,accent:"success"}),r(wi,{label:"Available",value:s.available,accent:s.available>0?"primary":void 0}),u("button",{type:"button",onClick:()=>{o.mutateAsync({deviceId:e}).catch(()=>{})},disabled:o.isPending,className:"inline-flex items-center justify-center gap-1.5 rounded-lg border border-border px-3 py-2 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 self-stretch shrink-0",children:[o.isPending?r(Pe,{className:"h-3.5 w-3.5 animate-spin"}):r(pt,{className:"h-3.5 w-3.5"}),r("span",{className:"hidden sm:inline",children:"Discover"})]})]}),u("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-foreground-subtle border-t border-border-subtle pt-2",children:[r(Jo,{icon:r(jn,{className:"h-3 w-3 text-emerald-500"}),label:`${s.online} online`}),r(Jo,{icon:r(cy,{className:"h-3 w-3 text-amber-500"}),label:`${s.sleeping} sleeping`}),r(Jo,{icon:r(yy,{className:"h-3 w-3 text-destructive"}),label:`${s.offline} offline`}),s.unknown>0?r(Jo,{icon:r(ND,{className:"h-3 w-3 text-foreground-subtle"}),label:`${s.unknown} unknown`}):null]})]})}function JO(e){const t={total:e.length,adopted:0,available:0,online:0,sleeping:0,offline:0,unknown:0};for(const n of e)n.alreadyAdopted?t.adopted+=1:t.available+=1,t[n.status]+=1;return t}function wi({label:e,value:t,icon:n,accent:o}){return u("div",{className:`flex flex-1 basis-[140px] min-w-0 flex-col gap-1 rounded-lg border px-2 py-1.5 sm:px-3 sm:py-2 ${o==="success"?"bg-emerald-500/10 border-emerald-500/30 text-emerald-500":o==="primary"?"bg-primary/10 border-primary/30 text-primary":"bg-surface-hover border-border text-foreground"}`,children:[u("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider opacity-70 truncate",children:[n,r("span",{className:"truncate",children:e})]}),r("div",{className:"text-xl sm:text-2xl font-semibold tabular-nums leading-none",children:t})]})}function Jo({icon:e,label:t}){return u("span",{className:"inline-flex items-center gap-1",children:[e,r("span",{children:t})]})}const e8=e=>r(e0,{...e,useSiren:!0}),t8={[at.Switch]:e0,[at.Siren]:e8,[at.Light]:GO,[at.Sensor]:WO,[at.Button]:YO,[at.Hub]:XO};function n8(e){const t=t8[e.deviceType]??ZO;return r(t,{...e})}function ed(e){if(e<60)return`${Math.round(e)}s`;const t=Math.floor(e/60),n=Math.round(e%60);if(t<60)return n>0?`${t}m ${n}s`:`${t}m`;const o=Math.floor(t/60),s=t%60;return s>0?`${o}h ${s}m`:`${o}h`}function Ts(e){return new Date(e).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Rs(e){return e.toISOString().slice(0,10)}function r8(e,t){return Rs(e)===Rs(t)}function Ur(e){const t=new Date(e);return t.setHours(0,0,0,0),t}function o8(e){const t=new Date(e);return t.setHours(23,59,59,999),t}function At({className:e=""}){return r("div",{className:`animate-pulse rounded bg-foreground-subtle/10 ${e}`})}function Dn(){return u("div",{className:"flex items-center gap-3 px-4 py-3",children:[r(At,{className:"h-4 w-4"}),r(At,{className:"h-3 w-24"}),r(At,{className:"h-3 w-16 ml-auto"})]})}function jr({children:e,actions:t}){return u("div",{className:"border-b border-border px-4 py-2.5 flex items-center justify-between",children:[r("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:e}),t]})}function gp({icon:e,label:t,value:n}){return u("div",{className:"flex items-center gap-2",children:[r(e,{className:"h-3.5 w-3.5 text-foreground-subtle flex-shrink-0"}),u("div",{className:"min-w-0",children:[r("p",{className:"text-[10px] text-foreground-subtle leading-tight",children:t}),r("p",{className:"text-xs font-medium text-foreground leading-tight",children:n})]})]})}function s8({segments:e,selectedDate:t}){const n=Ur(t).getTime(),o=1440*60*1e3,s=Array.from({length:25},(a,i)=>i);return u("div",{className:"space-y-1",children:[r("div",{className:"flex justify-between px-0.5",children:s.filter(a=>a%3===0).map(a=>r("span",{className:"text-[9px] text-foreground-subtle font-mono",children:String(a).padStart(2,"0")},a))}),u("div",{className:"relative h-6 rounded bg-background border border-border overflow-hidden",children:[e.map(a=>{const i=new Date(a.startTime).getTime()-n,l=new Date(a.endTime).getTime()-n,c=Math.max(0,i/o*100),d=Math.min(100-c,(l-i)/o*100);return d<=0?null:r("div",{className:"absolute top-0 bottom-0 bg-primary/60 hover:bg-primary/80 transition-colors",style:{left:`${c}%`,width:`${Math.max(d,.3)}%`},title:`${Ts(a.startTime)} - ${Ts(a.endTime)} (${ed(a.duration)})`},a.id)}),s.slice(1,-1).map(a=>r("div",{className:"absolute top-0 bottom-0 w-px bg-border/50",style:{left:`${a/24*100}%`}},a))]})]})}function a8({segment:e,selected:t,onToggle:n,onPlay:o,onDownload:s,onDelete:a}){return u("div",{className:`flex items-center gap-3 px-4 py-2 border-b border-border last:border-b-0 hover:bg-background/50 transition-colors ${t?"bg-primary/5":""}`,children:[r("button",{onClick:n,className:"flex-shrink-0 text-foreground-subtle hover:text-foreground",children:t?r(hy,{className:"h-4 w-4 text-primary"}):r(ya,{className:"h-4 w-4"})}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-xs font-mono text-foreground",children:[Ts(e.startTime)," - ",Ts(e.endTime)]}),u("p",{className:"text-[10px] text-foreground-subtle",children:[ed(e.duration),e.sizeBytes!=null&&` · ${Nt(e.sizeBytes)}`]})]}),u("div",{className:"flex items-center gap-1 flex-shrink-0",children:[r("button",{onClick:o,title:"Play",className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:r(Wc,{className:"h-3.5 w-3.5"})}),r("button",{onClick:s,title:"Download",className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:r(wn,{className:"h-3.5 w-3.5"})}),r("button",{onClick:a,title:"Delete",className:"p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger transition-colors",children:r(We,{className:"h-3.5 w-3.5"})})]})]})}function i8({deviceId:e}){const t=ke(),[n,o]=$(()=>Ur(new Date)),[s,a]=$(new Set),i=Hb({deviceId:e},{refetchInterval:5e3}),l=Bb({deviceId:e}),c=l.data?.streams[0]?.streamId??"stream0",d=Fb({deviceId:e,streamId:c,startTime:Ur(n).getTime(),endTime:o8(n).getTime()}),f=jb({deviceId:e,streamId:c},{refetchInterval:3e4}),p=Vb({deviceId:e,dataCategory:"recording:main"}),m=q(()=>{t.invalidateQueries({queryKey:["recordingEngine","getPolicyStatus"]}),t.invalidateQueries({queryKey:["recordingEngine","getSegments"]}),t.invalidateQueries({queryKey:["recordingEngine","getStorageUsage"]})},[t]),h=Ob({onSuccess:m}),g={isPending:h.isPending,error:h.error,mutate:()=>{const _=l.data,R=_?{mode:_.mode,streams:_.streams,enabled:!0,preBufferSec:_.preBufferSec,postBufferSec:_.postBufferSec,scheduleRules:_.scheduleRules}:{mode:"continuous",streams:[{streamId:c,mode:"always"}],enabled:!0,preBufferSec:10,postBufferSec:5};h.mutate({deviceId:e,policy:R})}},b=zb({onSuccess:m}),x=i.data??void 0,v=l.data??void 0,w=d.data??[],y=f.data,N=p.data??void 0,k=(x?.enabled??!1)&&(x?.activeStreams??0)>0,S=g.isPending||b.isPending,M=r8(n,new Date),P=Q(()=>[...w].sort((_,R)=>new Date(R.startTime).getTime()-new Date(_.startTime).getTime()),[w]),I=Q(()=>w.reduce((_,R)=>_+(R.duration??0),0),[w]),F=Q(()=>w.reduce((_,R)=>_+(R.sizeBytes??0),0),[w]);function E(){k?b.mutate({deviceId:e}):g.mutate()}function B(){o(_=>{const R=new Date(_);return R.setDate(R.getDate()-1),Ur(R)}),a(new Set)}function O(){M||(o(_=>{const R=new Date(_);return R.setDate(R.getDate()+1),Ur(R)}),a(new Set))}function A(_){a(R=>{const L=new Set(R);return L.has(_)?L.delete(_):L.add(_),L})}function D(){s.size===P.length?a(new Set):a(new Set(P.map(_=>_.id)))}return i.isLoading&&l.isLoading?u("div",{className:"space-y-4",children:[u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(jr,{children:"Recording Status"}),u("div",{className:"px-4 py-4 space-y-3",children:[r(At,{className:"h-10 w-full"}),r(At,{className:"h-4 w-48"})]})]}),u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(jr,{children:"Segments"}),u("div",{className:"divide-y divide-border",children:[r(Dn,{}),r(Dn,{}),r(Dn,{})]})]})]}):u("div",{className:"space-y-4",children:[u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(jr,{children:"Recording Status"}),u("div",{className:"px-4 py-4 flex items-center justify-between gap-4",children:[u("div",{className:"flex items-center gap-3 min-w-0",children:[r("div",{className:`flex items-center justify-center rounded-full p-2 flex-shrink-0 ${k?"bg-danger/10":"bg-foreground-subtle/10"}`,children:r(ey,{className:`h-5 w-5 ${k?"text-danger animate-pulse":"text-foreground-subtle"}`})}),u("div",{className:"min-w-0",children:[r("p",{className:`text-sm font-medium ${k?"text-danger":"text-foreground-subtle"}`,children:k?"Recording":"Not Recording"}),r("p",{className:"text-[11px] text-foreground-subtle mt-0.5 truncate",children:k&&x?`${x.mode} – ${x.activeStreams} stream(s)`:"No active recording session"})]})]}),r("button",{onClick:E,disabled:S,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors flex-shrink-0 disabled:opacity-50 ${k?"bg-danger/10 text-danger hover:bg-danger/20":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:k?u(ve,{children:[r(ya,{className:"h-3.5 w-3.5"}),S?"Stopping...":"Stop Recording"]}):u(ve,{children:[r(Wc,{className:"h-3.5 w-3.5"}),S?"Starting...":"Start Recording"]})})]}),k&&x&&u("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-[11px] text-foreground-subtle",children:[r(Zr,{className:"h-3.5 w-3.5 text-primary flex-shrink-0"}),u("span",{children:[x.activeStreams," active stream",x.activeStreams!==1?"s":""," · mode: ",x.mode]})]})]}),u("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(jr,{children:u("span",{className:"flex items-center gap-1.5",children:[r(wt,{className:"h-3.5 w-3.5"}),"Settings"]})}),l.isLoading?u("div",{className:"px-4 py-3 space-y-2",children:[r(At,{className:"h-3 w-32"}),r(At,{className:"h-3 w-40"}),r(At,{className:"h-3 w-28"})]}):u("div",{className:"divide-y divide-border",children:[r(Hr,{label:"Stream",value:c}),r(Hr,{label:"Pre-buffer",value:v?`${v.preBufferSec}s`:"N/A"}),r(Hr,{label:"Mode",value:v?.mode??"continuous"}),r(Hr,{label:"Retention",value:N?.retentionDays!=null?`${N.retentionDays} days`:"N/A"}),N?.retentionGb!=null&&r(Hr,{label:"Max Storage",value:`${N.retentionGb} GB`})]})]}),u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(jr,{children:u("span",{className:"flex items-center gap-1.5",children:[r(lo,{className:"h-3.5 w-3.5"}),"Storage"]})}),f.isLoading?u("div",{className:"px-4 py-3 space-y-2",children:[r(At,{className:"h-3 w-28"}),r(At,{className:"h-3 w-36"}),r(At,{className:"h-3 w-24"})]}):f.error?u("div",{className:"px-4 py-4 flex items-center gap-2 text-xs text-danger",children:[r(xt,{className:"h-4 w-4"}),"Failed to load storage info"]}):u("div",{className:"px-4 py-3 grid grid-cols-2 gap-3",children:[r(gp,{icon:lo,label:"Total",value:y?.totalBytes!=null?Nt(y.totalBytes):"N/A"}),r(gp,{icon:Zr,label:"Segments",value:y?.segmentCount!=null?String(y.segmentCount):"N/A"})]})]})]}),u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"border-b border-border px-4 py-2.5 flex items-center justify-between",children:[r("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:"Segment Browser"}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:B,className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:r(Uc,{className:"h-4 w-4"})}),u("div",{className:"flex items-center gap-1.5 text-xs text-foreground font-medium",children:[r(Zx,{className:"h-3.5 w-3.5 text-foreground-subtle"}),M?"Today":Rs(n)]}),r("button",{onClick:O,disabled:M,className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:r(Mt,{className:"h-4 w-4"})})]})]}),u("div",{className:"px-4 py-3 border-b border-border",children:[r(s8,{segments:w,selectedDate:n}),u("div",{className:"flex items-center gap-4 mt-2 text-[10px] text-foreground-subtle",children:[u("span",{children:[w.length," segment",w.length!==1?"s":""]}),I>0&&u("span",{children:[ed(I)," recorded"]}),F>0&&r("span",{children:Nt(F)})]})]}),P.length>0&&u("div",{className:"border-b border-border px-4 py-2 flex items-center justify-between",children:[r("button",{onClick:D,className:"text-[11px] text-foreground-subtle hover:text-foreground transition-colors",children:s.size===P.length?"Deselect All":"Select All"}),s.size>0&&u("div",{className:"flex items-center gap-2",children:[u("span",{className:"text-[10px] text-foreground-subtle",children:[s.size," selected"]}),u("button",{className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-medium bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",title:"Download selected",children:[r(wn,{className:"h-3 w-3"}),"Download"]}),u("button",{className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-medium bg-danger/10 text-danger hover:bg-danger/20 transition-colors",title:"Delete selected",children:[r(We,{className:"h-3 w-3"}),"Delete"]})]})]}),d.isLoading?u("div",{className:"divide-y divide-border",children:[r(Dn,{}),r(Dn,{}),r(Dn,{}),r(Dn,{})]}):P.length===0?u("div",{className:"flex flex-col items-center justify-center py-12 text-foreground-subtle",children:[r(Zr,{className:"h-8 w-8 mb-3 opacity-30"}),r("p",{className:"text-sm",children:"No recorded segments"}),r("p",{className:"text-xs mt-1 opacity-70",children:M?"Recorded clips will appear here as they are created":`No recordings found for ${Rs(n)}`})]}):r("div",{className:"max-h-[400px] overflow-y-auto",children:P.map(_=>r(a8,{segment:_,selected:s.has(_.id),onToggle:()=>A(_.id),onPlay:()=>{},onDownload:()=>{},onDelete:()=>{}},_.id))})]}),i.error&&u("div",{className:"rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 flex items-center gap-2 text-xs text-danger",children:[r(xt,{className:"h-4 w-4 flex-shrink-0"}),"Failed to load recording status. Will retry automatically."]}),(g.error||b.error)&&u("div",{className:"rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 flex items-center gap-2 text-xs text-danger",children:[r(xt,{className:"h-4 w-4 flex-shrink-0"}),g.error?`Failed to start recording: ${g.error instanceof Error?g.error.message:"Unknown error"}`:`Failed to stop recording: ${b.error instanceof Error?b.error.message:"Unknown error"}`]})]})}function Hr({label:e,value:t}){return u("div",{className:"flex items-center justify-between px-4 py-2.5",children:[r("span",{className:"text-xs text-foreground-subtle",children:e}),r("span",{className:"text-xs font-medium text-foreground",children:t})]})}function l8({deviceId:e}){const t=ke(),n=Number.isFinite(e),{data:o}=Fn({deviceId:e},{enabled:n}),s=typeof o?.type=="string"?o.type:"camera";yt(["deviceManager","getBindings"],["capability.binding-changed"]);const{data:a,isLoading:i,isError:l,error:c}=Cg({deviceId:e},{staleTime:3e4,enabled:n}),{data:d}=Ig({deviceType:s},{staleTime:3e4,enabled:!!s}),f=Mg({onSuccess:()=>{t.invalidateQueries({queryKey:[["deviceManager","getBindings"]]})}});if(i)return r("div",{className:"p-4",children:r("div",{className:"h-20 rounded-lg border border-border bg-surface animate-pulse"})});if(l)return u("div",{className:"p-4 text-xs text-red-400",children:["Failed to load bindings: ",c instanceof Error?c.message:String(c)]});const p=new Map,m={};for(const b of d??[])m[b.capName]=b.wrappers;for(const b of a?.entries??[])p.set(b.capName,{...b,wrappers:m[b.capName]??[]});for(const b of d??[])p.has(b.capName)||p.set(b.capName,{capName:b.capName,kind:"unbound",providerAddonId:"",providerNodeId:"",nativeAddonId:"",wrappers:b.wrappers});const h=[...p.values()].sort((b,x)=>b.capName.localeCompare(x.capName));if(h.length===0)return u("div",{className:"flex flex-col items-center justify-center gap-2 p-8 text-foreground-subtle",children:[r(ga,{className:"h-8 w-8 opacity-40"}),r("p",{className:"text-xs",children:"No capability providers applicable to this device yet."}),r("p",{className:"text-[10px] opacity-60",children:"Native providers show up here as soon as the owning addon registers them."})]});const g=h.filter(b=>b.kind!=="unbound").length;return u("div",{className:"flex flex-col gap-3 p-1",children:[u("div",{className:"text-[11px] text-foreground-subtle",children:[r("span",{className:"font-medium text-foreground",children:g})," ","of ",h.length," capabilit",h.length===1?"y":"ies"," bound — rows marked ",r("em",{children:"unbound"})," have a wrapper available you can activate."]}),r("div",{className:"overflow-hidden rounded-lg border border-border bg-surface",children:u("table",{className:"w-full border-collapse text-[11px]",children:[r("thead",{children:u("tr",{className:"bg-surface-hover/50 text-left text-[10px] uppercase tracking-wide text-foreground-subtle",children:[r("th",{className:"px-3 py-2 font-medium",children:"Capability"}),r("th",{className:"px-3 py-2 font-medium",children:"Kind"}),r("th",{className:"px-3 py-2 font-medium",children:"Active Provider"}),r("th",{className:"px-3 py-2 font-medium",children:"Node"}),r("th",{className:"px-3 py-2 font-medium",children:"Native"}),r("th",{className:"px-3 py-2 font-medium",children:"Wrapper"})]})}),r("tbody",{children:h.map(b=>{const x=b.kind==="wrapped"?b.providerAddonId:null;return u("tr",{className:"border-t border-border align-middle",children:[r("td",{className:"px-3 py-2 font-mono text-foreground",children:b.capName}),r("td",{className:"px-3 py-2",children:r(c8,{kind:b.kind})}),r("td",{className:"px-3 py-2 font-mono text-foreground-subtle",children:b.providerAddonId||r("span",{className:"opacity-40",children:"—"})}),r("td",{className:"px-3 py-2",children:b.providerNodeId?r(d8,{nodeId:b.providerNodeId}):r("span",{className:"text-[10px] opacity-40",children:"—"})}),r("td",{className:"px-3 py-2 font-mono text-foreground-subtle",children:b.nativeAddonId||r("span",{className:"opacity-40",children:"—"})}),r("td",{className:"px-3 py-2",children:r(u8,{wrappers:b.wrappers,activeWrapperId:x,disabled:f.isPending,onPick:v=>{const w=x===v;f.mutate({deviceId:e,capName:b.capName,wrapperAddonId:v,active:!w})}})})]},b.capName)})})]})})]})}function c8({kind:e}){return e==="native"?u("span",{className:"inline-flex items-center gap-1 rounded-md border border-success/30 text-success bg-success/5 px-1.5 py-0.5 text-[10px] font-medium",children:[r(ln,{className:"h-3 w-3"}),"native"]}):e==="wrapped"?u("span",{className:"inline-flex items-center gap-1 rounded-md border border-primary/30 text-primary bg-primary/5 px-1.5 py-0.5 text-[10px] font-medium",children:[r(eL,{className:"h-3 w-3"}),"wrapped"]}):u("span",{className:"inline-flex items-center gap-1 rounded-md border border-border text-foreground-subtle/70 px-1.5 py-0.5 text-[10px] font-medium",children:[r(gL,{className:"h-3 w-3"}),"unbound"]})}function d8({nodeId:e}){return r("span",{className:`inline-flex items-center rounded-md border border-border px-1.5 py-0.5 font-mono text-[10px] ${e==="hub"?"text-foreground-subtle":"text-foreground"}`,children:e})}function u8({wrappers:e,activeWrapperId:t,disabled:n,onPick:o}){return e.length===0?r("span",{className:"text-[10px] opacity-40",children:"none available"}):r("div",{className:"flex flex-wrap gap-1",children:e.map(s=>{const a=s===t;return u("button",{disabled:n,onClick:()=>o(s),title:a?"Click to deactivate (revert to native)":`Activate wrapper ${s}`,className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-[10px] transition-colors disabled:opacity-50 ${a?"border-primary/40 bg-primary/10 text-primary":"border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,children:[a?r(Ct,{className:"h-3 w-3"}):r(fy,{className:"h-3 w-3"}),s]},s)})})}function p8(e,t){if(!e)return null;for(const n of e.slots)for(const o of n.addons)if(o.id===t)return o;return null}function f8(e,t,n){const o=e?.stepOverridesByAgent?.[t]?.[n];if(o)return o.enabled===!1?"off":(o.enabled===!0,"on");const s=e?.stepToggles?.[n];return s===!1?"off":s===!0?"on":"inherit"}function m8({agents:e,currentAgent:t,onPick:n}){const[o,s]=$(!1);return u("div",{className:"relative",children:[r("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:()=>s(a=>!a),children:"Mirror from ▾"}),o&&r("div",{className:"absolute top-full left-0 mt-1 min-w-[140px] bg-surface border border-border rounded shadow-lg z-10",children:e.filter(a=>a!==t).map(a=>r("button",{type:"button",className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted",onClick:()=>{s(!1),n(a)},children:a},a))})]})}function h8({deviceId:e,refreshToken:t}){const n=ke(),[o,s]=$(null),[a,i]=$(null),[l,c]=$(null),[d,f]=$(null),p=yc({deviceId:e}),m=$r(),h=la({deviceId:e}),g=mb(),b=Q(()=>{const D=h.data?.agentNodeId;if(D)return D;const _=g.data?.find(R=>R.online)?.nodeId;return _||"hub"},[h.data?.agentNodeId,g.data]),x=a??b,v=So({nodeId:x??""},{enabled:!!x}),w=Mb({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),c(null)}}),y=Q(()=>v.data?ea(v.data):[],[v.data]),N=Q(()=>{const D=p.data??null,_={};for(const R of m.data??[])for(const L of Object.keys(R.settings.addonDefaults)){const z=_[L]??[];z.push({agentNodeId:R.nodeId,state:f8(D,R.nodeId,L)}),_[L]=z}return _},[p.data,m.data]),k=o?p8(v.data??null,o):null,S=x?m.data?.find(D=>D.nodeId===x)??null:null,M=o&&S?S.settings.addonDefaults[o]??null:null,P=o&&x?p.data?.stepOverridesByAgent?.[x]?.[o]??null:null,I=v.data?.selectedEngine.format??"coreml",F=D=>{i(D),c(null),f(null)},E=D=>{s(D),c(null),f(null)},B=D=>{if(!x||!o||!v.data||!m.data)return;const _=m.data.find(z=>z.nodeId===D),R=m.data.find(z=>z.nodeId===x);if(!_||!R)return;const[L]=bm({source:{nodeId:_.nodeId,engine:{format:I},defaults:_.settings.addonDefaults},target:{nodeId:R.nodeId,engine:{format:I},defaults:R.settings.addonDefaults},catalog:v.data,addonIds:[o]});if(!L){f("no mirror result");return}if(L.outcome==="skip"){f(`skipped: ${L.reason??"no candidate"}`);return}c(L.patch),f(`${L.outcome} from ${D}`)},O=()=>{!x||!o||w.mutate({deviceId:e,agentNodeId:x,addonId:o,patch:l})},A=()=>{!x||!o||w.mutate({deviceId:e,agentNodeId:x,addonId:o,patch:null})};return m.isLoading||v.isLoading?r("div",{className:"text-xs text-foreground-subtle animate-pulse p-4",children:"Loading pipeline…"}):v.data?r("div",{className:"@container h-full",style:{containerType:"inline-size"},children:u("div",{className:"flex flex-col @[720px]:flex-row h-full",children:[r("aside",{className:"w-full @[720px]:w-[300px] @[720px]:flex-shrink-0 border-b @[720px]:border-b-0 @[720px]:border-r border-border overflow-y-auto max-h-[40vh] @[720px]:max-h-none",children:r(fh,{tree:y,selectedAddonId:o,onSelect:E,agentDots:N})}),r("section",{className:"flex-1 min-w-0 p-4 overflow-y-auto",children:!o||!k?r("div",{className:"text-sm text-foreground-subtle",children:"Select a step on the left to configure it for this camera."}):u("div",{className:"space-y-4",children:[u("div",{children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Selected step"}),r("div",{className:"text-base font-semibold",children:k.name})]}),u("div",{className:"flex items-end gap-3 flex-wrap",children:[u("div",{children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle mb-1",children:"Agent"}),r("div",{className:"flex rounded border border-border overflow-hidden",children:(m.data??[]).map(D=>r("button",{type:"button",onClick:()=>F(D.nodeId),className:`px-3 py-1 text-xs ${x===D.nodeId?"bg-primary text-primary-foreground":"bg-surface hover:bg-muted"}`,children:D.nodeId},D.nodeId))})]}),r(m8,{agents:(m.data??[]).map(D=>D.nodeId),currentAgent:x,onPick:B}),d&&r("div",{className:"text-[10px] text-foreground-subtle",children:d})]}),M&&r(na,{mode:"device",addon:k,agentDefault:M,agentNodeId:x??"",currentPatch:l??P,engineFormat:I,onChangePatch:c}),u("div",{className:"flex items-center justify-between gap-2 pt-4 border-t border-border",children:[r("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted text-foreground-subtle",disabled:!P||w.isPending,onClick:A,children:"Clear override"}),u("div",{className:"flex items-center gap-2",children:[r("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:()=>c(null),children:"Reset draft"}),r("button",{type:"button",className:"px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50",disabled:!x||!o||w.isPending,onClick:O,children:w.isPending?"Saving…":"Save"})]})]})]})})]})}):r("div",{className:"text-xs text-foreground-subtle p-4",children:"Catalog unavailable."})}const g8=[{id:"overview",label:"Overview",cameraOnly:!1},{id:"config",label:"Config",cameraOnly:!1},{id:"pipeline",label:"Pipeline",cameraOnly:!0},{id:"bindings",label:"Bindings",cameraOnly:!0},{id:"recording",label:"Recording",cameraOnly:!0}];function b8(e){const t=e===at.Camera;return g8.filter(n=>t||!n.cameraOnly).map(({id:n,label:o})=>({id:n,label:o}))}const x8=[{id:"logs",icon:Xe,label:"Logs"},{id:"repl",icon:gy,label:"REPL"},{id:"events",icon:Ao,label:"Events"},{id:"state",icon:ty,label:"State"},{id:"ptz",icon:wL,label:"PTZ",featureGate:Rn.PanTiltZoom}];function y8(){const e=Oc(),t=Number(e.deviceId),n=Number.isFinite(t),o=et(),s=ke(),a=rt(),i=Le(),[l,c]=$("overview"),[d,f]=$("logs"),p="device-detail.left-col-width-px",[m,h]=$(()=>{if(typeof window>"u")return null;const de=window.localStorage.getItem(p),le=de?Number(de):NaN;return Number.isFinite(le)&&le>0?le:null}),g=ne(m);g.current=m;function b(de){de.preventDefault();const le=de.clientX,Se=de.currentTarget.previousElementSibling?.getBoundingClientRect().width??m??0,pe=280,Ie=Math.max(pe+50,Math.floor(window.innerWidth*.7)),Te=ot=>{const rr=Math.max(pe,Math.min(Ie,Se+(ot.clientX-le)));h(rr)},Ye=()=>{document.removeEventListener("mousemove",Te),document.removeEventListener("mouseup",Ye);const ot=g.current;if(ot!==null)try{window.localStorage.setItem(p,String(Math.round(ot)))}catch{}document.body.style.userSelect="",document.body.style.cursor=""};document.body.style.userSelect="none",document.body.style.cursor="col-resize",document.addEventListener("mousemove",Te),document.addEventListener("mouseup",Ye)}const{data:x,isLoading:v,isError:w}=Fn({deviceId:t},{enabled:n,refetchInterval:5e3,retry:1}),{data:y}=fc({deviceId:t},{enabled:n,staleTime:3e4}),N=Q(()=>{const de=y?.settings?.sections??[],le=y?.live?.sections??[],Se=[...de,...le],pe=new Set;for(const Ie of Se)Ie.location==="top-tab"&&Ie.tab&&pe.add(Ie.tab);return[...pe].map(Ie=>{const Te=$i[Ie];return{id:Ie,label:Te?.label??Ie,isAddonContrib:!0}})},[y]),k=x,S=String(k?.name??e.deviceId??"Device"),M=k?.online===!0,P=M?"online":"offline",I=String(k?.addonId??"rtsp"),F=k?.features??[],E=k?.type,B=E===at.Camera,O=typeof k?.parentDeviceId=="number"?k.parentDeviceId:null,{data:A}=Fn({deviceId:O??0},{enabled:O!==null,staleTime:3e4}),D=Xn(),_=Q(()=>[...b8(E),...N],[E,N]),{data:R}=By(n?t:0),L=(R??[]).length>0,z=Q(()=>x8.filter(({featureGate:de})=>!de||F.includes(de)),[F]),{data:j}=Dg({addonId:I},{enabled:!!I&&I!=="rtsp"}),H=Sg({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]}),o(j?.id?`/integrations/${j.id}`:"/integrations")}}),T=Ng({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),W=kg({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),G=Rb(),ee=oa({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),se=F.includes(Rn.Rebootable),te=F.includes(Rn.BatteryOperated),X=ec(i.trpcClient,te&&n?t:null),[re,ge]=$(!1),Z=kt(i.trpcClient,n?t:null),U=async()=>{if(!(re||!Z)){ge(!0);try{await Z.snapshot?.invalidateCache({});const de=await Z.snapshot?.getSnapshot({});if(!de)return;const le=`data:${de.contentType};base64,${de.base64}`,Se=de.contentType.includes("png")?"png":"jpg",pe=S.replace(/[^a-zA-Z0-9_.-]+/g,"_"),Ie=new Date().toISOString().replace(/[:.]/g,"-"),Te=document.createElement("a");Te.href=le,Te.download=`${pe}-${Ie}.${Se}`,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te)}finally{ge(!1)}}},J=T.isPending||W.isPending,{data:ae}=la({deviceId:t},{enabled:n,refetchInterval:1e4}),fe=ae?.agentNodeId??null,V=typeof fe=="string"&&fe.length>0&&!fe.startsWith("addon:")?fe:void 0,{data:ie}=vc({deviceId:t,...V?{nodeId:V}:{}},{enabled:n,refetchInterval:3e3,retry:!1});function ue(){if(!n)return null;switch(l){case"overview":return r(zO,{device:k??{}});case"config":return r(UO,{deviceId:t});case"pipeline":return r(h8,{deviceId:t,refreshToken:0});case"bindings":return r(l8,{deviceId:t});case"recording":return r(i8,{deviceId:t});default:{const de=l;return N.some(Se=>Se.id===de)?r(Zy,{deviceId:t,sectionFilter:Se=>Se.location==="top-tab"&&Se.tab===de}):null}}}return n?v?u("div",{className:"flex flex-col h-full",children:[u("div",{className:"border-b border-border bg-surface px-6 py-4",children:[r("div",{className:"h-4 w-48 rounded bg-surface-hover animate-pulse mb-3"}),r("div",{className:"h-8 w-64 rounded bg-surface-hover animate-pulse"})]}),r("div",{className:"flex-1 p-6",children:r("div",{className:"h-40 rounded-lg border border-border bg-surface animate-pulse"})})]}):w||!x?u("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle",children:[r("p",{className:"text-lg font-semibold text-foreground",children:"Device not found"}),u("p",{className:"text-xs",children:["No device with ID ",u("code",{className:"font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]",children:["#",t]})]}),r("button",{onClick:()=>o("/integrations"),className:"mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors",children:"Back to Integrations"})]}):u("div",{className:"absolute inset-0 flex flex-col overflow-hidden",children:[u("div",{className:"border-b border-border bg-surface px-6 py-3 flex-shrink-0",children:[r("div",{className:"mb-2",children:r(Gl,{items:[{label:"Integrations",onClick:()=>o("/integrations")},{label:j?.name??I,onClick:()=>j?.id&&o(`/integrations/${j.id}`)},{label:S}]})}),u("div",{className:"flex items-center gap-2 sm:gap-3",children:[r(cn,{type:I,size:"lg"}),u("div",{className:"min-w-0 flex-1",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("h1",{className:"text-sm sm:text-base font-semibold text-foreground truncate",children:S}),r(Na,{status:P}),te&&r(nc,{status:X,variant:"full"})]}),O!==null&&A&&u("button",{type:"button",onClick:()=>o(`/devices/${O}`),className:"text-[10px] text-foreground-subtle hover:text-primary transition-colors mt-0.5 inline-flex items-center gap-1",title:`Open parent device ${A.name}`,children:[r("span",{children:"↑"}),r("span",{className:"truncate",children:String(A.name??`Device #${O}`)})]}),r("div",{className:"hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle",children:F.length>0&&r(va,{capabilities:F})})]}),ie&&r("div",{className:"hidden lg:flex",children:r(v8,{metrics:ie})}),u("div",{className:"flex items-center gap-1 shrink-0",children:[u("button",{onClick:async()=>{await a({title:`Disable "${S}"?`,message:"The device will stop processing streams and events. You can re-enable it later.",confirmLabel:"Disable",variant:"danger"})&&W.mutate({deviceId:t})},disabled:J,title:"Disable device",className:"inline-flex items-center gap-1.5 rounded-lg px-2 sm:px-2.5 py-1.5 text-[11px] font-medium border transition-colors disabled:opacity-50 border-success/30 text-success hover:bg-success/10",children:[r(py,{className:"h-3.5 w-3.5"}),r("span",{className:"hidden sm:inline",children:J?"Updating…":"Enabled"})]}),r("div",{className:"hidden sm:block h-5 w-px bg-border mx-1"}),r(Mx,{triggerClassName:"ml-1",items:[{id:"snapshot",label:"Take snapshot",description:"Fetch a fresh frame and download it.",icon:gr,disabled:re,onClick:()=>{U()}},{id:"reboot",label:"Reboot device",description:"Camera goes offline for ~30 seconds.",icon:bt,hidden:!se,disabled:G.isPending,danger:!0,onClick:async()=>{await a({title:`Reboot "${S}"?`,message:"The camera will go offline for around 30 seconds while the firmware reboots.",confirmLabel:"Reboot",variant:"danger"})&&G.mutate({deviceId:t})}},{id:"restart-addon",label:"Restart addon",description:`Bounces every device served by ${j?.name??I}.`,icon:pt,disabled:ee.isPending,danger:!0,onClick:async()=>{await a({title:`Restart "${j?.name??I}"?`,message:`Restarting the addon will briefly disconnect every device served by it (not just "${S}"). Streams will reconnect automatically.`,confirmLabel:"Restart",variant:"danger"})&&ee.mutate({addonId:I})}},{id:"delete",label:"Delete device",description:"Remove the device and all its settings.",icon:We,separatorBefore:!0,disabled:H.isPending,danger:!0,onClick:async()=>{await a({title:`Delete "${S}"?`,message:"This will remove the device and all its settings. This action cannot be undone.",confirmLabel:"Delete",variant:"danger"})&&H.mutate({deviceId:t})}}]})]})]})]}),r(jh,{deviceId:t,device:k??void 0,children:r(yx,{children:r(Ax,{children:u("main",{className:D?"flex-1 overflow-y-auto flex flex-col":"flex-1 min-h-0 overflow-hidden flex flex-row",children:[u("div",{className:D?"flex flex-col bg-surface":`${m===null?"w-1/2 lg:w-1/3":""} flex-shrink-0 flex flex-col bg-surface min-h-0 overflow-hidden`,style:!D&&m!==null?{width:`${String(m)}px`}:void 0,children:[r("div",{className:`flex-shrink-0 border-b border-border-subtle ${B?"aspect-video bg-black":"bg-surface"}`,children:B?r($O,{deviceId:t,intercomAvailable:F.includes(Rn.TwoWayAudio)}):r(n8,{deviceId:t,deviceName:S,deviceType:E??"unknown",provider:I,isOnline:M,features:F})}),u("div",{className:D?"flex flex-col border-b border-border":"flex-1 min-h-0 flex flex-col overflow-hidden",children:[r("div",{className:"flex-shrink-0 border-b border-border-subtle px-2 py-1.5",children:r("div",{className:"flex gap-1 overflow-x-auto -mx-1 px-1 pb-0.5",children:z.map(({id:de,label:le,icon:Se})=>u("button",{onClick:()=>f(de),title:le,className:`flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors flex-shrink-0 ${d===de?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,children:[r(Se,{className:"h-3 w-3"}),le]},de))})}),u("div",{className:D?"h-72 overflow-hidden":"flex-1 min-h-0 overflow-hidden",children:[d==="logs"&&r(_O,{deviceId:t}),d==="repl"&&r(DO,{deviceId:t}),d==="events"&&r(TO,{deviceId:t}),d==="state"&&r(RO,{deviceId:t}),d==="ptz"&&r(LO,{deviceId:t})]})]})]}),!D&&r("div",{role:"separator","aria-orientation":"vertical",title:"Drag to resize",onMouseDown:b,className:"flex-shrink-0 w-1 cursor-col-resize bg-border hover:bg-primary/40 transition-colors group relative z-10",children:r("span",{className:"absolute inset-y-0 -left-1 -right-1"})}),u("div",{className:D?"flex flex-col":"flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden",children:[r("div",{className:"flex-shrink-0 border-b border-border bg-surface px-4",children:r("div",{className:"flex flex-wrap items-center gap-0",children:_.map(de=>{const le=l===de.id;return u("button",{onClick:()=>c(de.id),className:`relative flex-shrink-0 px-3 py-2 text-xs font-medium transition-colors ${le?"text-primary":"text-foreground-subtle hover:text-foreground"}`,children:[de.label,le&&r("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 rounded-full bg-primary"})]},de.id)})})}),u("div",{className:D?"p-3 flex flex-col gap-3":"flex-1 min-h-0 overflow-y-auto p-4 flex flex-col gap-3",children:[l==="overview"&&L&&r(OO,{parentDeviceId:t}),ue()]})]})]})})})})]}):u("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle",children:[r("p",{className:"text-lg font-semibold text-foreground",children:"Invalid device id"}),u("p",{className:"text-xs",children:["The URL segment ",r("code",{className:"font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]",children:e.deviceId})," is not a number."]}),r("button",{onClick:()=>o("/integrations"),className:"mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors",children:"Back to Integrations"})]})}function v8({metrics:e}){const t=e.phase??"idle",n=Wn(t);return u("div",{className:"flex items-center gap-3 flex-shrink-0",children:[u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:`h-1.5 w-1.5 rounded-full ${n.dotClass}`}),r("span",{className:`text-[10px] font-medium ${n.textColor}`,children:n.label})]}),r("div",{className:"h-3 w-px bg-border"}),u("div",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle",children:[r(Io,{className:"h-3 w-3"}),r("span",{className:"text-foreground tabular-nums",children:(e.actualFps??0).toFixed(1)}),r("span",{children:"fps"})]}),u("div",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle",children:[r(ut,{className:"h-3 w-3"}),r("span",{className:"text-foreground tabular-nums",children:(e.avgInferenceTimeMs??0).toFixed(0)}),r("span",{children:"ms"})]}),(e.queueDepth??0)>0&&u("span",{className:"text-[10px] text-warning tabular-nums",children:["q:",e.queueDepth]})]})}function w8({packageName:e,currentVersion:t,onInstall:n,onClose:o}){const{data:s,isLoading:a}=Kh({name:e},{staleTime:3e5});return u("div",{className:"fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden",style:{top:"auto",bottom:"auto"},ref:i=>{if(!i)return;const l=i.parentElement?.getBoundingClientRect();if(!l)return;const c=window.innerHeight-l.bottom,d=l.top;c<280&&d>c?(i.style.bottom=`${window.innerHeight-l.top+4}px`,i.style.top="auto"):(i.style.top=`${l.bottom+4}px`,i.style.bottom="auto"),i.style.right=`${window.innerWidth-l.right}px`},onClick:i=>i.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Versions"}),r("button",{type:"button",onClick:o,className:"text-foreground-subtle hover:text-foreground",children:r(qe,{className:"h-3 w-3"})})]}),a&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle",children:[r(Pe,{className:"h-3.5 w-3.5 animate-spin"}),"Loading versions..."]}),s&&r("div",{className:"max-h-64 overflow-auto divide-y divide-border",children:s.map(i=>{const l=i.version===t,c=/-(alpha|beta|rc|dev|canary|next)/i.test(i.version);return u("div",{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${l?"bg-primary/5":"hover:bg-surface-hover"} transition-colors`,children:[r("span",{className:`font-mono flex-1 ${l?"text-primary font-semibold":c?"text-amber-400":"text-foreground"}`,children:i.version}),i.distTags.map(d=>r("span",{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${d==="latest"?"bg-emerald-500/15 text-emerald-400":d==="beta"?"bg-amber-500/15 text-amber-400":"bg-gray-500/15 text-gray-400"}`,children:d},d)),i.deprecated&&r("span",{className:"text-[9px] text-red-400 line-through",children:"deprecated"}),r("span",{className:"text-[9px] text-foreground-subtle shrink-0",children:new Date(i.publishedAt).toLocaleDateString()}),l?r(Ct,{className:"h-3 w-3 text-primary shrink-0"}):r("button",{type:"button",onClick:()=>n(i.version),className:"shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors",title:`Install ${i.version}`,children:r(wn,{className:"h-3 w-3"})})]},i.version)})}),s&&s.length===0&&r("div",{className:"py-4 text-center text-[10px] text-foreground-subtle",children:"No versions found"})]})}function N8({isBundle:e,installSource:t}){return u("div",{className:"relative flex-shrink-0",children:[r("div",{className:`h-9 w-9 rounded-lg flex items-center justify-center ${e?"bg-indigo-500/20 text-indigo-700 dark:text-indigo-300":"bg-purple-500/20 text-purple-700 dark:text-purple-300"}`,children:e?r(dy,{className:"h-4 w-4"}):r(Es,{className:"h-4 w-4"})}),t==="local"&&r("span",{className:"absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm",children:"DEV"}),t==="npm"&&r("span",{className:"absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm",children:r("svg",{viewBox:"0 0 780 250",className:"w-[11px] h-[11px]",children:r("path",{fill:"#fff",d:"M240 250h100V50h100v200h340V0H0v250z"})})}),t==="upload"&&r("span",{className:"absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm",children:r(Xc,{className:"h-2.5 w-2.5 text-white"})})]})}function k8({addonId:e}){const t=ke(),{data:n="inherit"}=Yh({addonId:e},{staleTime:3e4}),o=Zh({onSuccess:()=>{t.invalidateQueries({queryKey:[["addons","getAddonAutoUpdate"]]})}});return r("div",{className:"flex rounded-lg border border-border overflow-hidden text-[10px] font-medium",children:["inherit","off","latest","beta"].map(s=>r("button",{type:"button",onClick:a=>{a.stopPropagation(),o.mutate({addonId:e,channel:s})},disabled:o.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===s?s==="inherit"?"bg-gray-700/50 text-gray-700 dark:text-gray-300":s==="off"?"bg-gray-700 text-gray-700 dark:text-gray-300":s==="latest"?"bg-blue-500/20 text-blue-400":"bg-amber-500/20 text-amber-400":"bg-transparent text-foreground-subtle hover:bg-surface-hover"} ${s!=="inherit"?"border-l border-border":""}`,children:s},s))})}function ul({addon:e,agents:t=[],clusterStatus:n,hideVersion:o,availableUpdate:s,onUpdate:a,isUpdating:i,bundle:l}){const[c,d]=$(!1),[f,p]=$(!1),[m,h]=$(!1),[g,b]=$(!1),[x,v]=$(!1),[w,y]=$("logs"),N=ke(),k=rt(),{manifest:S}=e,M=e.installedOn??[],P=!l&&!S.protected&&S.removable!==!1,I=!!l,F=l?.displayName??S.name,E=l?.packageName??S.packageName,B=l?.version??S.packageVersion??S.version,O=l?.installSource??e.installSource,A=l?l.bundle?.description??l.addons[0]?.manifest.description:S.description;!l&&(S.components&&S.components.length>0||t.length>=2);const D=Hh({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["addonPages"]]}),N.invalidateQueries({queryKey:[["capabilities"]]})}}),_=oa({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]})}}),R=ic({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["addonPages"]]}),N.invalidateQueries({queryKey:[["capabilities"]]}),N.invalidateQueries({queryKey:[["integrations"]]})}}),L=Gh({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["alerts"]]})}}),z=e.health,j=z?.phase==="failed"&&!z.inGracePeriod,H=j&&z?.nextRetryAt&&!z.retrying;return u("div",{className:`rounded-lg border bg-surface overflow-hidden ${j?"border-red-500/50":"border-border"}`,children:[j&&z&&u("div",{className:"bg-danger/10 border-b border-danger/30 px-4 py-2.5 flex items-start gap-2.5",children:[r(SL,{className:"h-4 w-4 text-danger shrink-0 mt-0.5"}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"text-xs font-semibold text-danger",children:["Failed to load (attempt #",z.retryCount,")"]}),r("div",{className:"text-[11px] text-foreground mt-0.5 break-words font-mono",children:z.lastError?.message??"Unknown error"}),H&&z.nextRetryAt&&u("div",{className:"text-[10px] text-foreground-subtle mt-1",children:["Auto-retry at ",new Date(z.nextRetryAt).toLocaleTimeString()]})]}),u("button",{type:"button",disabled:L.isPending||z.retrying,onClick:T=>{T.stopPropagation(),L.mutate({packageName:E})},className:"inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0",title:"Reset retry counter and force immediate reload",children:[r(pt,{className:`h-3 w-3 ${L.isPending||z.retrying?"animate-spin":""}`}),"Retry now"]})]}),u("div",{className:"flex items-start gap-3 px-4 py-3",children:[r(N8,{isBundle:I||!!S.components&&S.components.length>1,installSource:O}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-sm font-semibold text-foreground truncate",children:F}),u("span",{className:"text-[10px] text-foreground-subtle font-mono shrink-0",children:["(",E,")"]}),I&&u("span",{className:"text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1",children:[r(dy,{className:"h-3 w-3"}),l.addons.length]})]}),A&&r("p",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-1",children:A}),!I&&e.process&&u("div",{className:"flex items-center gap-1.5 mt-1",children:[r("span",{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode==="forked"?"bg-blue-500/15 text-blue-400":"bg-gray-500/15 text-gray-400"}`,children:e.process.mode==="forked"?"forked":"in-process"}),e.process.pid!=null&&u("span",{className:"text-[9px] font-mono text-foreground-subtle",children:["PID ",e.process.pid]}),r("span",{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state==="running"?"bg-emerald-500/15 text-emerald-400":e.process.state==="crashed"?"bg-red-500/15 text-red-400":"bg-gray-500/15 text-gray-400"}`,children:e.process.state})]})]}),!o&&u("div",{className:"relative inline-flex items-center gap-1.5 shrink-0 pt-0.5",children:[i?u("span",{className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400",children:[r(Pe,{className:"h-3 w-3 animate-spin"}),"Updating to ",s,"…"]}):s&&a?u("button",{type:"button",onClick:T=>{T.stopPropagation(),a()},className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-semibold border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors animate-pulse",title:`Update to ${s}`,children:[r(wn,{className:"h-3 w-3"}),s]}):null,u("button",{type:"button",onClick:T=>{T.stopPropagation(),h(W=>!W)},className:["inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-bold font-mono border transition-colors",O==="local"?"border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20":s?"border-amber-500/30 bg-amber-500/10 text-amber-400 hover:bg-amber-500/20":"border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20"].join(" "),title:s?`Current ${B} — newer ${s} available`:"View all versions",children:[B,r(Rt,{className:"h-3 w-3 opacity-50"})]}),m&&r(w8,{packageName:E,currentVersion:B,onInstall:T=>{h(!1),R.mutate({packageName:E,version:T})},onClose:()=>h(!1)})]})]}),!I&&u("div",{className:"flex items-center gap-1 px-4 py-1.5 border-t border-border/50 bg-surface-hover/20",children:[u("button",{type:"button",onClick:T=>{T.stopPropagation(),_.mutate({addonId:S.id})},disabled:_.isPending,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors",children:[r(pt,{className:`h-3 w-3 ${_.isPending?"animate-spin":""}`}),"Restart"]}),u("button",{type:"button",onClick:T=>{T.stopPropagation(),b(W=>!W)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${g?"border-primary/30 bg-primary/10 text-primary":"border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10"}`,children:[r(Xe,{className:"h-3 w-3"}),"Logs"]}),!I&&u("button",{type:"button",onClick:T=>{T.stopPropagation(),v(!0)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${x?"border-primary/30 bg-primary/10 text-primary":"border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10"}`,children:[r(wt,{className:"h-3 w-3"}),"Settings"]}),r("div",{className:"flex-1"}),P&&u("button",{type:"button",onClick:async T=>{T.stopPropagation(),await k({title:`Uninstall ${S.name}?`,message:"This will remove the addon package and all its data. This action cannot be undone.",confirmLabel:"Uninstall",variant:"danger"})&&D.mutate({packageName:S.packageName})},disabled:D.isPending,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-red-400 hover:border-red-500/30 hover:bg-red-500/10 disabled:opacity-50 transition-colors",children:[r(We,{className:"h-3 w-3"}),D.isPending?"Removing...":"Uninstall"]})]}),n&&n.nodes.length>1&&!I&&u("div",{className:"border-t border-border px-4 py-2 bg-muted/10",children:[r("div",{className:"text-[10px] font-medium text-foreground-subtle mb-1.5",children:"Cluster Deployment"}),r("div",{className:"space-y-1",children:n.nodes.map(T=>u("div",{className:"flex items-center gap-2 text-[10px]",children:[r("div",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${T.status==="offline"?"bg-muted-foreground/30":T.synced?"bg-success":"bg-amber-500"}`}),r("span",{className:"font-medium text-foreground min-w-[60px]",children:T.name}),r("span",{className:"font-mono text-foreground-subtle",children:T.version}),!T.synced&&T.status!=="offline"&&r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"outdated"}),T.status==="offline"&&r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground",children:"offline"}),T.synced&&T.status!=="offline"&&r("span",{className:"text-[9px] text-success",children:"synced"})]},T.nodeId))})]}),g&&!I&&u("div",{className:"border-t border-border",children:[u("div",{className:"flex items-center px-4 py-1 bg-surface-hover/20 border-b border-border/50",children:[u("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:[r("button",{type:"button",onClick:()=>y("logs"),className:`px-2 py-0.5 transition-colors ${w==="logs"?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover"}`,children:"Logs"}),r("button",{type:"button",onClick:()=>y("events"),className:`px-2 py-0.5 border-l border-border transition-colors ${w==="events"?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover"}`,children:"Events"})]}),r("div",{className:"flex-1"}),r("button",{type:"button",onClick:T=>{T.stopPropagation(),b(!1)},className:"text-foreground-subtle hover:text-foreground",children:r(qe,{className:"h-3.5 w-3.5"})})]}),w==="logs"&&r(Wt,{addonId:S.id,maxHeight:"max-h-64",showFilters:!1}),w==="events"&&r(nr,{addonId:S.id,category:"addon.*",maxHeight:"max-h-64"})]}),I&&u(ve,{children:[r("button",{type:"button",onClick:()=>d(T=>!T),className:"w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors",children:c?r(bD,{className:"h-3.5 w-3.5 text-foreground-subtle"}):r(Rt,{className:"h-3.5 w-3.5 text-foreground-subtle"})}),c&&r("div",{className:"border-t border-border px-3 py-2 space-y-2",children:l.addons.map(T=>r(ul,{addon:T,agents:t,hideVersion:!0},T.manifest.id))})]}),x&&!I&&r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",onClick:()=>v(!1),children:u("div",{className:"w-full max-w-lg max-h-[80vh] rounded-xl border border-border bg-surface shadow-2xl flex flex-col overflow-hidden",onClick:T=>T.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border flex-shrink-0",children:[u("div",{className:"flex items-center gap-2",children:[r(wt,{className:"h-4 w-4 text-primary"}),u("h2",{className:"text-sm font-semibold text-foreground",children:[F," Settings"]})]}),r("button",{onClick:()=>v(!1),className:"text-foreground-subtle hover:text-foreground transition-colors p-1 rounded",children:r(qe,{className:"h-4 w-4"})})]}),u("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[r(Rr,{nodeId:"hub",addonIds:[S.id],level:"global"}),O==="npm"&&u("div",{children:[r("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:"Auto-Update"}),r(k8,{addonId:S.id})]}),S.components&&S.components.length>0&&u("div",{children:[u("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Components (",S.components.length,")"]}),r("div",{className:"flex flex-wrap gap-1",children:S.components.map(T=>r("span",{className:"text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono",children:T},T))})]}),t.length>=2&&u("div",{children:[r("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:"Installed on"}),u("div",{className:"flex items-center gap-1.5 flex-wrap",children:[M.length===0&&r("span",{className:"text-[10px] text-foreground-subtle",children:"Hub (local)"}),M.map(T=>r("span",{className:"rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle",children:T},T)),u("div",{className:"relative",children:[u("button",{type:"button",onClick:T=>{T.stopPropagation(),p(W=>!W)},className:"inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:border-primary transition-colors",title:"Install on more agents",children:[r(Ot,{className:"h-3 w-3"}),"Add agent"]}),f&&u("div",{className:"absolute left-0 top-full mt-1 z-10 min-w-[160px] rounded-md border border-border bg-surface shadow-lg overflow-hidden",children:[t.filter(T=>!T.isHub&&!M.includes(T.name)).map(T=>r("button",{type:"button",onClick:W=>{W.stopPropagation(),p(!1)},className:"w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors",children:T.name},T.id)),t.filter(T=>!T.isHub&&!M.includes(T.name)).length===0&&r("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle",children:"No available agents"})]})]})]})]})]}),r("div",{className:"flex items-center justify-end px-5 py-3 border-t border-border flex-shrink-0",children:r("button",{type:"button",onClick:()=>v(!1),className:"rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:"Close"})})]})})]})}const S8=".tgz,.tar.gz,.zip";function C8({onUploadSuccess:e}){const[t,n]=$(!1),o=ne(null),s=q(async i=>{n(!0);const l=new FormData;l.append("file",i);const c=localStorage.getItem("camstack_admin_token")??"";try{(await(await fetch("/api/addons/upload",{method:"POST",headers:{Authorization:`Bearer ${c}`},body:l})).json()).success&&e()}finally{n(!1)}},[e]),a=q(i=>{const l=i.target.files?.[0];l&&s(l),i.target.value=""},[s]);return u(ve,{children:[r("input",{ref:o,type:"file",accept:S8,onChange:a,className:"hidden"}),u("button",{type:"button",onClick:()=>o.current?.click(),disabled:t,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors",children:[t?r(Pe,{className:"w-3.5 h-3.5 animate-spin"}):r(Xc,{className:"w-3.5 h-3.5"}),t?"Uploading...":"Upload"]})]})}function M8(e,t){const n=e??"hub-only";return n==="any-node"?!0:n==="hub-only"?t:!t}function I8(e){const t=e;if(!t?.manifest)return null;const n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??"0.0.0",capabilities:t.manifest.capabilities??[]},o=t.process,s=o?{pid:o.pid,mode:o.mode==="forked"?"forked":"in-process",state:o.state??"unknown"}:void 0,a=t.health;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...s?{process:s}:{},hasBackup:t.hasBackup,...a?{health:a}:{}}}function A8(e){const t=new Map,n=[];for(const s of e){const a=s.manifest.packageName;if(!a){n.push(s);continue}const i=t.get(a);if(i)i.addons.push(s);else{const l=s.manifest.bundle,c={packageName:a,displayName:l?.displayName??s.manifest.packageDisplayName??s.manifest.name,version:s.manifest.packageVersion,addons:[s],...s.installSource!==void 0?{installSource:s.installSource}:{},...l!==void 0?{bundle:l}:{}};t.set(a,c)}}const o=[];for(const s of t.values())s.bundle!==void 0||s.addons.length>=2?o.push({bundle:s,representative:s.addons[0]}):o.push(s.addons[0]);return o.push(...n),o}function Xt(e){return"bundle"in e}function P8({addons:e,clusterStatus:t,selectedNode:n,onRefresh:o,isRefreshing:s}){const a=ke(),[i,l]=$(""),c=W1(i),[d,f]=$(!1),p=ne(null);Y(()=>{if(!d)return;const L=z=>{p.current&&!p.current.contains(z.target)&&f(!1)};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[d]);const{data:m}=lc(void 0,{staleTime:5*6e4}),h=Q(()=>{const L=new Map;for(const z of m??[])L.set(z.name,z.latestVersion);return L},[m]),[g,b]=$(null),[x,v]=$(null),w=Qi({onMutate:L=>{b(L.name),v(null)},onSuccess:(L,z)=>{b(null);const j=L;if(j&&j.success===!1){v({name:z.name,message:j.error??"Update failed (no error message returned by server)"});return}a.invalidateQueries({queryKey:[["addons"]]}),a.invalidateQueries({queryKey:[["addons","listUpdates"]]})},onError:(L,z)=>{b(null),v({name:z.name,message:L instanceof Error?L.message:String(L)})}}),{data:y}=Wh(void 0,{staleTime:3e4}),N=Xh({onSuccess:()=>{a.invalidateQueries({queryKey:[["addons","getAutoUpdateSettings"]]})}}),{data:k,isFetching:S}=qh({query:c||void 0},{enabled:d,staleTime:6e4}),M=Qi(),P=async()=>{const L=m??[];for(const z of L)await M.mutateAsync({name:z.name,version:z.latestVersion});a.invalidateQueries({queryKey:[["addons"]]})},I=ic({onSuccess:()=>{a.invalidateQueries({queryKey:[["addons"]]}),a.invalidateQueries({queryKey:[["addonPages"]]}),a.invalidateQueries({queryKey:[["capabilities"]]}),a.invalidateQueries({queryKey:[["integrations"]]})}}),[F,E]=$("type"),[B,O]=$(()=>typeof window>"u"?"grouped":window.localStorage.getItem("camstack.addons.viewMode")==="flat"?"flat":"grouped"),A=L=>{O(L),typeof window<"u"&&window.localStorage.setItem("camstack.addons.viewMode",L)},D=Q(()=>n.isHub?e:e.filter(L=>{const z=L.manifest.execution;return M8(z?.placement,n.isHub)}),[e,n.isHub]),_=B==="flat"?D:A8(D),R=Q(()=>{const L=[..._];switch(F){case"type":L.sort((z,j)=>{const H=Xt(z)?0:1,T=Xt(j)?0:1;if(H!==T)return H-T;const W=Xt(z)?z.bundle.displayName:z.manifest.name,G=Xt(j)?j.bundle.displayName:j.manifest.name;return W.localeCompare(G)});break;case"name":L.sort((z,j)=>{const H=Xt(z)?z.bundle.displayName:z.manifest.name,T=Xt(j)?j.bundle.displayName:j.manifest.name;return H.localeCompare(T)});break;case"source":L.sort((z,j)=>{const H=Xt(z)?z.bundle.installSource??"":z.installSource??"",T=Xt(j)?j.bundle.installSource??"":j.installSource??"";return H.localeCompare(T)});break}return L},[_,F]);return u("div",{className:"space-y-4",children:[x&&r("div",{className:"rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px]",children:u("div",{className:"flex items-start justify-between gap-3",children:[u("div",{className:"space-y-0.5",children:[u("div",{className:"font-medium text-danger",children:["Failed to update ",x.name]}),r("div",{className:"text-foreground-subtle font-mono",children:x.message})]}),r("button",{type:"button",onClick:()=>v(null),className:"text-foreground-subtle hover:text-foreground text-[10px]",children:"dismiss"})]})}),u("div",{className:"flex items-center gap-2 flex-wrap",children:[u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"text-[10px] text-foreground-subtle",children:"Sort:"}),u("select",{value:F,onChange:L=>E(L.target.value),className:"rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] text-foreground focus:outline-none focus:border-primary/50",children:[r("option",{value:"type",children:"Bundles first"}),r("option",{value:"name",children:"Name"}),r("option",{value:"source",children:"Install source"})]})]}),u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"text-[10px] text-foreground-subtle",children:"View:"}),r("div",{className:"flex rounded-md border border-border overflow-hidden text-[10px] font-medium",children:["grouped","flat"].map(L=>r("button",{type:"button",onClick:()=>A(L),className:`px-2.5 py-1.5 transition-colors capitalize ${B===L?"bg-primary/10 text-primary":"bg-transparent text-foreground-subtle hover:bg-surface-hover"}`,title:L==="grouped"?"Group multi-addon packages into a bundle card":"Show every addon as its own card",children:L},L))})]}),u("div",{className:"flex items-center gap-1.5",children:[r(pt,{className:"h-3 w-3 text-foreground-subtle"}),r("span",{className:"text-[10px] text-foreground-subtle",children:"Auto-Update:"}),r("div",{className:"flex rounded-md border border-border overflow-hidden text-[10px] font-medium",children:["off","latest","beta"].map(L=>r("button",{type:"button",onClick:()=>N.mutate({channel:L}),disabled:N.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${y?.channel===L?L==="off"?"bg-gray-700 text-gray-200":L==="latest"?"bg-blue-500/20 text-blue-400":"bg-amber-500/20 text-amber-400":"bg-transparent text-foreground-subtle hover:bg-surface-hover"} ${L!=="off"?"border-l border-border":""}`,children:L},L))})]}),(m?.length??0)>0&&u("button",{type:"button",onClick:()=>void P(),disabled:M.isPending,className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/30 disabled:opacity-50 transition-colors font-medium",children:[r(wn,{className:`w-3 h-3 ${M.isPending?"animate-bounce":""}`}),"Update All (",m.length,")"]}),u("button",{type:"button",onClick:o,disabled:s,className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors",children:[r(pt,{className:`w-3 h-3 ${s?"animate-spin":""}`}),"Refresh"]})]}),u("div",{className:"flex items-center gap-3",children:[u("div",{className:"relative flex-1 min-w-[200px]",ref:p,children:[r(my,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle"}),r("input",{type:"text",value:i,onChange:L=>{l(L.target.value),f(!0)},onFocus:()=>f(!0),placeholder:"Search addons on npm...",className:"w-full rounded-lg border border-border bg-background pl-9 pr-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"}),S&&r(Pe,{className:"absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin"}),d&&k&&k.length>0&&u("div",{className:"absolute left-0 right-0 top-full mt-1 z-40 rounded-lg border border-border bg-surface shadow-xl overflow-hidden",children:[k.length>0&&u("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border",children:["npm results (",k.length,")"]}),k&&k.length>0&&r("div",{className:"max-h-72 overflow-auto divide-y divide-border",children:k.map(L=>u("div",{className:"flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors",children:[r("div",{className:"w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0",children:L.name.replace("@camstack/addon-","").charAt(0).toUpperCase()}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-[11px] font-semibold truncate",children:L.name}),u("span",{className:"text-[10px] text-foreground-subtle",children:["v",L.version]})]}),L.description&&r("div",{className:"text-[10px] text-foreground-subtle truncate",children:L.description})]}),L.installed?u("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md border border-emerald-500/30 bg-emerald-500/10 text-emerald-400 shrink-0",children:[r(Ct,{className:"h-3 w-3"}),L.installedVersion??"Installed"]}):u("button",{type:"button",onClick:()=>I.mutate({packageName:L.name}),disabled:I.isPending,className:"inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0",children:[I.isPending?r(Pe,{className:"h-3 w-3 animate-spin"}):r(wn,{className:"h-3 w-3"}),"Install"]})]},L.name))})]})]}),r(C8,{onUploadSuccess:()=>{a.invalidateQueries({queryKey:[["addons"]]}),o()}})]}),D.length===0&&r("div",{className:"text-xs text-foreground-subtle",children:e.length===0?"No addons installed":`No addons compatible with ${n.name} (placement filter active)`}),r("div",{className:"space-y-2",children:R.map(L=>{if(Xt(L)){const H=L.bundle.packageName,T=h.get(H);return r(ul,{addon:L.representative,clusterStatus:t?.[L.representative.manifest.id],bundle:L.bundle,availableUpdate:T,isUpdating:g===H,onUpdate:T?()=>w.mutate({name:H,version:T}):void 0},H)}const z=L.manifest.packageName,j=h.get(z);return r(ul,{addon:L,clusterStatus:t?.[L.manifest.id],availableUpdate:j,isUpdating:g===z,onUpdate:j?()=>w.mutate({name:L.manifest.packageName,version:j}):void 0},L.manifest.id)})})]})}function E8(){const e=ke(),{data:t,isLoading:n,isError:o}=ra(),{data:s}=nb(void 0,{staleTime:15e3}),{data:a}=In(void 0,{staleTime:3e4,refetchInterval:1e4}),i=Q(()=>{const x=new Map;x.set("hub",{id:"hub",name:"Hub",isHub:!0});for(const v of a??[]){const w=String(v.id??"");w&&x.set(w,{id:w,name:String(v.name??w),isHub:!!v.isHub})}return[...x.values()]},[a]),[l,c]=$("hub"),d=i.find(x=>x.id===l)??i[0],f=Qh(),p=Vh(),m=f.isPending||p.isPending,h=async()=>{await f.mutateAsync(),await p.mutateAsync(),e.invalidateQueries({queryKey:[["addons"]]})},g=ne(f);g.current=f,Y(()=>{g.current.mutate()},[]);const b=(t??[]).map(I8).filter(x=>x!==null);return u("div",{className:"p-6 space-y-5",children:[u("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[u("div",{children:[r("h1",{className:"text-lg font-semibold text-foreground",children:"Addons"}),r("p",{className:"text-xs text-foreground-subtle mt-0.5",children:"Manage installed addons and explore capability providers."})]}),u("div",{className:"flex items-center gap-3 flex-wrap",children:[r(gh,{selectedNodeId:l,onSelect:c}),!n&&!o&&u("span",{className:"text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium",children:[b.length," installed"]}),u("button",{type:"button",onClick:()=>void h(),disabled:m,className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors",title:"Re-fetch addons + check npm for new versions",children:[r(pt,{className:`w-3 h-3 ${m?"animate-spin":""}`}),"Check for updates"]})]})]}),!d.isHub&&u("div",{className:"rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle",children:["Showing only addons compatible with"," ",r("span",{className:"font-medium text-foreground",children:d.name})," ","— agents only run ",r("code",{className:"font-mono",children:"agent-only"})," and"," ",r("code",{className:"font-mono",children:"any-node"})," addons. Install / uninstall is hub-driven; agents auto-sync from the hub."]}),n&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading…"}),o&&r("div",{className:"text-xs text-danger",children:"Failed to load addons"}),!n&&!o&&r(P8,{addons:b,clusterStatus:s,selectedNode:d,onRefresh:()=>void h(),isRefreshing:m})]})}function $8(){return r(It,{icon:Xe,title:"Logs",children:r("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:r(Wt,{limit:500,maxHeight:"max-h-[calc(100vh-250px)]",showScope:!0,showFilters:!0})})})}function td({tabs:e,defaultTab:t}){const[n,o]=qc(),s=n.get("tab"),a=t??e[0]?.id??"",i=e.some(d=>d.id===s)?s:a,l=e.find(d=>d.id===i)??e[0],c=d=>{const f=new URLSearchParams(n);f.set("tab",d),o(f,{replace:!0})};return u("div",{className:"space-y-3",children:[r("div",{className:"flex border-b border-border",children:e.map(d=>{const f=d.icon,p=d.id===i;return u("button",{onClick:()=>c(d.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium border-b-2 transition-colors ${p?"border-primary text-primary":"border-transparent text-foreground-subtle hover:text-foreground"}`,children:[f&&r(f,{className:"h-3.5 w-3.5"}),d.label]},d.id)})}),r("div",{children:l?.content})]})}const bp={super_admin:"bg-danger/10 text-danger",admin:"bg-primary/10 text-primary",viewer:"bg-foreground-subtle/10 text-foreground-subtle"};function _8(){const e=ke(),[t,n]=$(!1),[o,s]=$(""),[a,i]=$(""),[l,c]=$("viewer"),[d,f]=$(null),{data:p,isLoading:m,isError:h}=Nc(),g=rt(),b=()=>e.invalidateQueries({queryKey:[["userManagement","listUsers"]]}),x=Jb({onSuccess:()=>{b(),n(!1),s(""),i(""),c("viewer"),f(null)},onError:I=>{f(I instanceof Error?I.message:"Failed to create user")}}),v=tx({onSuccess:b}),w=ex({onSuccess:b}),y=kc({onSuccess:b}),N=p??[];async function k(I){await g({title:"Delete user",message:`Permanently delete user "${I.username}"? This cannot be undone — any active sessions will be revoked on next request.`,confirmLabel:"Delete",variant:"danger"})&&v.mutate({id:I.id})}async function S(I){const F=window.prompt(`New password for "${I.username}":`);if(!F)return;if(F.length<8){window.alert("Password must be at least 8 characters.");return}await g({title:"Reset password",message:`Reset the password for "${I.username}"? They will need to use the new password on their next login.`,confirmLabel:"Reset"})&&y.mutate({id:I.id,newPassword:F})}function M(I,F){F!==I.role&&w.mutate({id:I.id,role:F})}function P(I){return I?new Date(typeof I=="number"?I:String(I)).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}):"—"}return u(It,{icon:by,title:"Users",actions:u("button",{onClick:()=>n(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm hover:bg-primary/90",children:[r(Ot,{className:"h-3.5 w-3.5"}),"Create User"]}),children:[t&&u("div",{className:"rounded-lg border border-border bg-surface p-4 space-y-3",children:[u("div",{className:"flex items-center justify-between",children:[r("span",{className:"text-xs font-medium text-foreground",children:"New User"}),r("button",{onClick:()=>n(!1),className:"text-foreground-subtle hover:text-foreground",children:r(qe,{className:"h-4 w-4"})})]}),u("div",{className:"grid grid-cols-3 gap-3",children:[u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Username"}),r("input",{type:"text",value:o,onChange:I=>s(I.target.value),placeholder:"john",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Password"}),r("input",{type:"password",value:a,onChange:I=>i(I.target.value),placeholder:"••••••••",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Role"}),u("select",{value:l,onChange:I=>c(I.target.value),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary",children:[r("option",{value:"viewer",children:"Viewer"}),r("option",{value:"admin",children:"Admin"}),r("option",{value:"super_admin",children:"Super Admin"})]})]})]}),d&&r("p",{className:"text-[10px] text-danger",children:d}),u("div",{className:"flex justify-end gap-2",children:[r("button",{onClick:()=>n(!1),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),r("button",{onClick:()=>x.mutate({username:o,password:a,role:l}),disabled:x.isPending||!o||!a,className:"rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:x.isPending?"Creating...":"Create"})]})]}),m&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading..."}),h&&r("div",{className:"text-xs text-danger",children:"Failed to load"}),!m&&!h&&N.length===0&&r("div",{className:"text-xs text-foreground-subtle",children:"No data"}),(()=>{const I=E=>v.isPending&&v.variables?.id===E.id||w.isPending&&w.variables?.id===E.id||y.isPending&&y.variables?.id===E.id;return r(uh,{columns:[{key:"username",header:"Username",render:E=>E.username},{key:"role",header:"Role",render:E=>{const B=E.role??"viewer",O=bp[B]??bp.viewer;return u("select",{value:B,onChange:A=>M(E,A.target.value),disabled:I(E),className:`rounded border border-border bg-background px-2 py-0.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 ${O}`,title:"Change role",children:[r("option",{value:"viewer",children:"Viewer"}),r("option",{value:"admin",children:"Admin"}),r("option",{value:"super_admin",children:"Super Admin"})]})}},{key:"createdAt",header:"Created",render:E=>r("span",{className:"text-foreground-subtle",children:P(E.createdAt)})},{key:"actions",header:"Actions",align:"right",render:E=>{const B=I(E);return u("div",{className:"flex items-center justify-end gap-1",children:[u("button",{onClick:()=>S(E),disabled:B,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground disabled:opacity-50",title:"Reset password",children:[r(YD,{className:"h-3 w-3"}),"Reset password"]}),u("button",{onClick:()=>k(E),disabled:B,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50",title:"Delete user",children:[B?r(Pe,{className:"h-3 w-3 animate-spin"}):r(We,{className:"h-3 w-3"}),"Delete"]})]})}}],rows:N,rowKey:E=>E.id,minWidthPx:560})})()]})}const D8={super_admin:"bg-danger/10 text-danger",admin:"bg-primary/10 text-primary",viewer:"bg-foreground-subtle/10 text-foreground-subtle",agent:"bg-warning/10 text-warning"};function to(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString()}function L8(e){return e?e==="*"?"*":e.join(", "):""}function T8(e){return e.type==="integration"?{type:"addon",target:e.target}:{type:e.type,target:e.target}}function R8(){const e=ke(),t=rt(),{data:n,isLoading:o}=nx(),{data:s}=Nc(),a=Q(()=>n??[],[n]),i=Q(()=>s??[],[s]),l=()=>e.invalidateQueries({queryKey:[["userManagement","listApiKeys"]]}),c=()=>e.invalidateQueries({queryKey:[["userManagement","listScopedTokens"]]}),[d,f]=$(!1),[p,m]=$(null),h=rx({onSuccess:l}),g=ox({onSuccess:({token:w,record:y})=>{c(),f(!1),m({token:w,label:y.name})}}),b=sx({onSuccess:c}),x=async(w,y)=>{await t({title:`Revoke "${y}"?`,message:"Any client using this token will lose access immediately. This cannot be undone.",confirmLabel:"Revoke",variant:"danger"})&&h.mutate({id:w})},v=async(w,y)=>{await t({title:`Revoke "${y}"?`,message:"The scoped token will be invalid on its next use.",confirmLabel:"Revoke",variant:"danger"})&&b.mutate({id:w})};return u(It,{icon:sy,title:"Tokens",subtitle:"Issue scoped tokens to grant a user a narrow surface — a specific addon, integration, route prefix, or capability. Every token MUST be scoped: revoking it has predictable blast radius.",actions:u("button",{onClick:()=>f(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",disabled:i.length===0,title:i.length===0?"Create a user first":"Issue a scoped token",children:[r(xr,{className:"h-3.5 w-3.5"}),"New token"]}),children:[u(xp,{title:"Scoped tokens",subtitle:"Grouped per user",children:[i.length===0&&r(z8,{text:"No users yet — scoped tokens are issued on behalf of an existing user."}),i.map(w=>r(B8,{userId:w.id,username:w.username,onRevoke:(y,N)=>{v(y,N)},revokePending:b.isPending,revokeId:b.variables?.id},w.id))]}),a.length>0&&r(xp,{title:"Legacy API keys",subtitle:`${a.length} pre-existing — revoke only`,children:r(t0,{headers:["Label","Role","Prefix","Allowed providers","Created","Last used",""],rows:a.map(w=>{const y=w.role??"viewer",N=h.isPending&&h.variables?.id===w.id;return u("tr",{className:"hover:bg-primary/5",children:[r("td",{className:"px-3 py-2 text-foreground border-b border-border font-medium",children:w.label}),r("td",{className:"px-3 py-2 text-foreground border-b border-border",children:r("span",{className:`inline-block rounded px-2 py-0.5 text-[10px] uppercase tracking-wide ${D8[y]}`,children:y})}),u("td",{className:"px-3 py-2 text-foreground border-b border-border font-mono text-[11px]",children:[w.tokenPrefix,"…"]}),r("td",{className:"px-3 py-2 text-foreground border-b border-border text-foreground-subtle",children:L8(w.allowedProviders)||"all"}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:to(w.createdAt)}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:to(w.lastUsedAt)}),r("td",{className:"px-3 py-2 border-b border-border text-right",children:u("button",{onClick:()=>{x(w.id,w.label)},disabled:N,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50",title:"Revoke",children:[N?r(Pe,{className:"h-3 w-3 animate-spin"}):r(We,{className:"h-3 w-3"}),"Revoke"]})})]},w.id)})})}),o&&r(O8,{}),d&&r(F8,{users:i.map(w=>({id:w.id,username:w.username})),onClose:()=>f(!1),onSubmit:w=>g.mutate({name:w.name,scopes:w.scopes,...w.expiresAt!==void 0?{expiresAt:w.expiresAt}:{}}),submitting:g.isPending}),p&&r(H8,{token:p.token,label:p.label,onClose:()=>m(null)})]})}function xp({title:e,subtitle:t,children:n}){return u("div",{className:"space-y-2",children:[u("div",{className:"flex items-baseline justify-between",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:e}),t&&r("span",{className:"text-[10px] text-foreground-subtle",children:t})]}),n]})}function O8(){return r("div",{className:"space-y-2",children:[1,2].map(e=>r("div",{className:"h-10 rounded border border-border bg-surface animate-pulse"},e))})}function z8({text:e}){return r("div",{className:"rounded border border-dashed border-border bg-surface px-3 py-4 text-xs text-foreground-subtle text-center",children:e})}function t0({headers:e,rows:t}){return r("div",{className:"rounded-lg border border-border bg-surface overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[640px]",children:[r("thead",{children:r("tr",{children:e.map((n,o)=>r("th",{className:`px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border whitespace-nowrap ${o===e.length-1?"text-right":"text-left"}`,children:n},o))})}),r("tbody",{children:t})]})})}function B8({userId:e,username:t,onRevoke:n,revokePending:o,revokeId:s}){const{data:a,isLoading:i}=ax({userId:e}),l=a??[];return i||l.length===0?null:u("div",{className:"space-y-1.5",children:[r("div",{className:"text-[11px] font-medium text-foreground",children:t}),r(t0,{headers:["Name","Prefix","Scopes","Expires","Last used","Created",""],rows:l.map(c=>{const d=o&&s===c.id;return u("tr",{className:"hover:bg-primary/5",children:[r("td",{className:"px-3 py-2 text-foreground border-b border-border font-medium",children:c.name}),u("td",{className:"px-3 py-2 text-foreground border-b border-border font-mono text-[11px]",children:[c.tokenPrefix,"…"]}),r("td",{className:"px-3 py-2 text-foreground border-b border-border",children:r("div",{className:"flex flex-wrap gap-1",children:c.scopes.map((f,p)=>u("span",{className:"inline-block rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-mono",children:[f.type,":",f.target]},p))})}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:to(c.expiresAt)}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:to(c.lastUsedAt)}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:to(c.createdAt)}),r("td",{className:"px-3 py-2 border-b border-border text-right",children:u("button",{onClick:()=>n(c.id,c.name),disabled:d,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50",children:[d?r(Pe,{className:"h-3 w-3 animate-spin"}):r(We,{className:"h-3 w-3"}),"Revoke"]})})]},c.id)})})]})}function F8({users:e,onClose:t,onSubmit:n,submitting:o}){const[s,a]=$(e[0]?.id??""),[i,l]=$(""),[c,d]=$([{type:"addon",target:""}]),[f,p]=$(""),{data:m=[]}=ra(),{data:h=[]}=sa(),g=(w,y)=>{d(N=>N.map((k,S)=>{if(S!==w)return k;const M={...k,...y};return y.type!==void 0&&y.type!==k.type&&(M.target=""),M}))},b=c.filter(w=>w.target.trim().length>0).map(T8),x=s!==""&&i.trim().length>0&&b.length>0&&!o,v=()=>{const w=parseInt(f,10),y=Number.isFinite(w)&&w>0?Date.now()+w*864e5:void 0;n({userId:s,name:i.trim(),scopes:b,expiresAt:y})};return u(n0,{title:"Create scoped token",onClose:t,children:[u("div",{className:"space-y-3",children:[r(es,{label:"On behalf of user",children:r("select",{value:s,onChange:w=>a(w.target.value),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary",children:e.map(w=>r("option",{value:w.id,children:w.username},w.id))})}),r(es,{label:"Name",children:r("input",{value:i,onChange:w=>l(w.target.value),placeholder:"cloudflare-tunnel-route",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary"})}),r(es,{label:"Scopes",hint:"Each scope picks a concrete surface. The token can access ONLY what's listed.",children:u("div",{className:"space-y-1.5",children:[c.map((w,y)=>r(j8,{scope:w,addons:m,integrations:h,onChange:N=>g(y,N),onRemove:c.length>1?()=>d(N=>N.filter((k,S)=>S!==y)):void 0},y)),u("button",{onClick:()=>d(w=>[...w,{type:"addon",target:""}]),className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-foreground-subtle hover:text-foreground hover:bg-foreground-subtle/10",children:[r(Ot,{className:"h-3 w-3"}),"Add scope"]})]})}),r(es,{label:"Expires in (days)",hint:"Leave blank for non-expiring.",children:r("input",{type:"number",min:1,value:f,onChange:w=>p(w.target.value),placeholder:"30",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary"})})]}),u(r0,{children:[r("button",{onClick:t,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),u("button",{onClick:v,disabled:!x,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[o?r(Pe,{className:"h-3.5 w-3.5 animate-spin"}):r(xr,{className:"h-3.5 w-3.5"}),"Issue token"]})]})]})}function j8({scope:e,addons:t,integrations:n,onChange:o,onRemove:s}){const a=t.map(l=>({id:l.manifest.id})),i=()=>{switch(e.type){case"addon":return u("select",{value:e.target,onChange:l=>o({target:l.target.value}),className:"flex-1 rounded border border-border bg-background px-2 py-1.5 text-xs font-mono focus:outline-none focus:ring-1 focus:ring-primary",children:[r("option",{value:"",children:"— pick addon —"}),a.map(l=>r("option",{value:l.id,children:l.id},l.id))]});case"integration":return u("select",{value:e.target,onChange:l=>o({target:l.target.value}),className:"flex-1 rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary",children:[r("option",{value:"",children:"— pick integration —"}),n.map(l=>u("option",{value:l.addonId,children:[l.name," (",l.addonId,")"]},l.id))]});case"capability":return u("select",{value:e.target,onChange:l=>o({target:l.target.value}),className:"flex-1 rounded border border-border bg-background px-2 py-1.5 text-xs font-mono focus:outline-none focus:ring-1 focus:ring-primary",children:[r("option",{value:"",children:"— pick capability —"}),Object.values(sw).sort().map(l=>r("option",{value:l,children:l},l))]});case"route-prefix":return r("input",{value:e.target,onChange:l=>o({target:l.target.value}),placeholder:"/api/cloudflare",className:"flex-1 rounded border border-border bg-background px-2 py-1.5 text-xs font-mono focus:outline-none focus:ring-1 focus:ring-primary"})}};return u("div",{className:"flex items-center gap-1.5",children:[u("select",{value:e.type,onChange:l=>o({type:l.target.value}),className:"rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary",children:[r("option",{value:"addon",children:"addon"}),r("option",{value:"integration",children:"integration"}),r("option",{value:"capability",children:"capability"}),r("option",{value:"route-prefix",children:"route-prefix"})]}),i(),s&&r("button",{onClick:s,className:"rounded p-1 text-foreground-subtle hover:text-danger hover:bg-danger/10",title:"Remove scope",children:r(qe,{className:"h-3 w-3"})})]})}function H8({token:e,label:t,onClose:n}){const[o,s]=$(!1),a=async()=>{try{await navigator.clipboard.writeText(e),s(!0)}catch{}};return u(n0,{title:`Token: ${t}`,onClose:n,children:[u("div",{className:"space-y-3",children:[r("div",{className:"rounded border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",children:"Copy this token now. Once you close this dialog the secret cannot be displayed again."}),r("div",{className:"rounded border border-border bg-background p-2 font-mono text-[11px] break-all select-all",children:e})]}),u(r0,{children:[u("button",{onClick:()=>{a()},className:"inline-flex items-center gap-1.5 rounded bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30",children:[o?r(Ct,{className:"h-3.5 w-3.5 text-primary"}):r(MD,{className:"h-3.5 w-3.5"}),o?"Copied":"Copy"]}),r("button",{onClick:n,className:"rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:"Done"})]})]})}function n0({title:e,onClose:t,children:n}){return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:t,children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:o=>o.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:e}),r("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:r(qe,{className:"h-4 w-4"})})]}),r("div",{className:"p-4",children:n})]})})}function r0({children:e}){return r("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:e})}function es({label:e,hint:t,children:n}){return u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:e}),n,t&&r("p",{className:"text-[10px] text-foreground-subtle",children:t})]})}const V8={local:"Local (username + password)",oidc:"OpenID Connect",saml:"SAML 2.0",ldap:"LDAP / Active Directory",other:"Custom"},yp={local:"bg-foreground-subtle/10 text-foreground",oidc:"bg-blue-500/15 text-blue-700 dark:text-blue-300",saml:"bg-purple-500/15 text-purple-700 dark:text-purple-300",ldap:"bg-amber-500/15 text-amber-700 dark:text-amber-300",other:"bg-slate-500/15 text-slate-700 dark:text-slate-300"};function q8(){const e=dc(),t=e.data??[];return r(It,{icon:xr,title:"Authentication",subtitle:"Login providers exposed to the admin UI. Local username + password is always available; OIDC / SAML / LDAP can be added by installing a provider addon.",actions:r(Kt,{to:"/system/addons",children:r(He,{variant:"primary",size:"sm",children:"Add provider"})}),children:e.isLoading?r(Ge,{children:r("div",{className:"p-6 text-sm text-foreground-subtle",children:"Loading providers…"})}):t.length===0?r(Ge,{children:r(ko,{title:"No authentication providers registered",description:"Local auth should always be available — if this list is empty, the local-auth builtin failed to register. Check the Addons page for load errors."})}):r(Ge,{children:r("div",{className:"divide-y divide-border",children:t.map(n=>u("div",{className:"flex items-center gap-4 p-4",children:[r("div",{className:"h-10 w-10 rounded-lg bg-primary/10 text-primary flex items-center justify-center shrink-0",children:r(xr,{className:"h-5 w-5"})}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"font-semibold text-foreground",children:n.displayName}),r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${yp[n.kind]??yp.other}`,children:V8[n.kind]??n.kind}),!n.enabled&&r("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-red-500/15 text-red-700 dark:text-red-300",children:"Disabled"})]}),u("div",{className:"text-xs text-foreground-subtle mt-1 flex items-center gap-3",children:[r("span",{className:"font-mono",children:n.addonId}),n.hasCredentialFlow&&r("span",{children:"· username + password"}),n.hasRedirectFlow&&r("span",{children:"· redirect (SSO)"})]}),n.status&&r("div",{className:"text-xs text-foreground-subtle mt-1",children:n.status})]}),u(Kt,{to:`/system/addons?addon=${encodeURIComponent(n.addonId)}`,className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[r(wt,{className:"h-3.5 w-3.5"}),"Configure",r(Yx,{className:"h-3.5 w-3.5"})]})]},n.addonId))})})})}function Q8(){return r("div",{className:"flex flex-col",children:r("div",{className:"px-6 pt-6",children:r(td,{tabs:[{id:"users",label:"Users",icon:by,content:r(_8,{})},{id:"api-keys",label:"Tokens",icon:sy,content:r(R8,{})},{id:"authentication",label:"Authentication",icon:xr,content:r(q8,{})}]})})})}function nd({addonId:e,defaultActivity:t,showActivity:n=!0,maxHeight:o="max-h-64",defaultTab:s}){const a=t??(s==="events"?"events":"logs"),[i,l]=$(a);return u("div",{className:"flex flex-col gap-4",children:[r(Rr,{nodeId:"hub",addonIds:[e],level:"global"}),n&&u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border bg-surface-hover/20",children:[r("span",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Activity"}),u("div",{className:"flex items-center gap-1",children:[r(vp,{kind:"logs",active:i==="logs",onClick:()=>l("logs")}),r(vp,{kind:"events",active:i==="events",onClick:()=>l("events")})]})]}),i==="logs"?r(Wt,{addonId:e,maxHeight:o,showFilters:!1}):r(nr,{addonId:e,category:"addon.*",maxHeight:o})]})]})}function vp({kind:e,active:t,onClick:n}){return u("button",{onClick:n,className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${t?"bg-primary/10 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,children:[r(e==="logs"?Xe:Ao,{className:"h-3 w-3"}),e==="logs"?"Logs":"Events"]})}const U8={"cloudflare-tunnel":"Cloudflare Tunnel",ngrok:"ngrok",tailscale:"Tailscale",other:"Custom"};function K8(){const e=ke(),t=qb(void 0,{refetchInterval:5e3}),n=t.data??[],[o,s]=$(null),a=()=>{e.invalidateQueries({queryKey:[["remoteAccess"]]}),s(null)},i=Qb({onSuccess:a,onError:()=>s(null)}),l=Ub({onSuccess:a,onError:()=>s(null)});return r(It,{icon:br,title:"Remote Access",subtitle:"Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …). Settings, Logs and Events are docked under every provider.",actions:r(Kt,{to:"/system/addons",children:r(He,{variant:"primary",size:"sm",children:"Add tunnel"})}),children:t.isLoading?r(Ge,{children:r("div",{className:"p-6 text-sm text-foreground-subtle",children:"Loading providers…"})}):n.length===0?r(Ge,{children:r(ko,{title:"No remote-access providers installed",description:"Install a tunnel addon (e.g. @camstack/addon-cloudflare-tunnel) to expose this hub publicly.",action:r(Kt,{to:"/system/addons",children:r(He,{variant:"primary",size:"sm",children:"Browse addons"})})})}):r("div",{className:"flex flex-col gap-4",children:n.map(c=>{const d=o===c.addonId;return u(Ge,{children:[u("div",{className:"flex items-center gap-4 p-4 border-b border-border",children:[r("div",{className:`h-10 w-10 rounded-lg flex items-center justify-center shrink-0 ${c.connected?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:r(br,{className:"h-5 w-5"})}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"font-semibold text-foreground",children:c.displayName}),r("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-blue-500/15 text-blue-700 dark:text-blue-300",children:U8[c.kind]??c.kind}),r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${c.connected?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:c.connected?"Connected":"Disconnected"})]}),r("div",{className:"text-xs text-foreground-subtle mt-1 font-mono",children:c.addonId}),c.endpoint&&u("div",{className:"text-xs text-emerald-700 dark:text-emerald-300 mt-1 flex items-center gap-1",children:[r(Kc,{className:"h-3 w-3"}),r("a",{href:c.endpoint.url,target:"_blank",rel:"noopener noreferrer",className:"hover:underline break-all",children:c.endpoint.url})]}),c.error&&r("div",{className:"text-xs text-danger mt-1",children:c.error})]}),r("div",{className:"flex items-center gap-1 shrink-0",children:c.connected?u(He,{size:"sm",variant:"secondary",disabled:d,onClick:()=>{s(c.addonId),l.mutate({addonId:c.addonId})},children:[d?r(Pe,{className:"h-3 w-3 animate-spin"}):r(ya,{className:"h-3 w-3"}),"Stop"]}):u(He,{size:"sm",variant:"primary",disabled:d,onClick:()=>{s(c.addonId),i.mutate({addonId:c.addonId})},children:[d?r(Pe,{className:"h-3 w-3 animate-spin"}):r(Wc,{className:"h-3 w-3"}),"Start"]})})]}),r("div",{className:"p-4",children:r(nd,{addonId:c.addonId,maxHeight:"max-h-72"})})]},c.addonId)})})})}const G8={cloudflare:"Cloudflare TURN",coturn:"coturn (self-hosted)",twilio:"Twilio NTS",other:"Custom"};function W8(){const e=Zb(void 0,{refetchInterval:3e4}),t=Xb(),n=e.data??[],o=t.data??[];return r(It,{icon:an,title:"TURN Servers",subtitle:"ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.",actions:r(Kt,{to:"/system/addons",children:r(He,{variant:"primary",size:"sm",children:"Add provider"})}),children:e.isLoading?r(Ge,{children:r("div",{className:"p-6 text-sm text-foreground-subtle",children:"Loading providers…"})}):n.length===0?r(Ge,{children:r(ko,{title:"No TURN providers installed",description:"Install a TURN addon (e.g. @camstack/addon-cloudflare-turn) to enable WebRTC behind restrictive NATs.",action:r(Kt,{to:"/system/addons",children:r(He,{variant:"primary",size:"sm",children:"Browse addons"})})})}):u("div",{className:"flex flex-col gap-4",children:[n.map(s=>u(Ge,{children:[u("div",{className:"flex items-center gap-4 p-4 border-b border-border",children:[r("div",{className:`h-10 w-10 rounded-lg flex items-center justify-center shrink-0 ${s.error?"bg-danger/15 text-danger":"bg-violet-500/15 text-violet-700 dark:text-violet-300"}`,children:r(an,{className:"h-5 w-5"})}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"font-semibold text-foreground",children:s.displayName}),r("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-violet-500/15 text-violet-700 dark:text-violet-300",children:G8[s.kind]??s.kind}),!s.enabled&&r("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-danger/15 text-danger",children:"Disabled"})]}),u("div",{className:"text-xs text-foreground-subtle mt-1 flex items-center gap-3",children:[r("span",{className:"font-mono",children:s.addonId}),u("span",{children:["· ",s.serverCount," server",s.serverCount===1?"":"s"]})]}),s.error&&r("div",{className:"text-xs text-danger mt-1",children:s.error})]})]}),r("div",{className:"p-4",children:r(nd,{addonId:s.addonId,maxHeight:"max-h-72"})})]},s.addonId)),u(Ge,{children:[u("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[u("div",{children:[r("div",{className:"text-sm font-semibold",children:"Combined ICE server list"}),r("div",{className:"text-xs text-foreground-subtle",children:"What the WebRTC layer fetches per-session."})]}),r(He,{size:"sm",variant:"secondary",onClick:()=>t.refetch(),disabled:t.isFetching,children:"Refresh"})]}),r("div",{className:"p-4",children:o.length===0?r("div",{className:"text-xs text-foreground-subtle",children:"No servers from enabled providers."}):r("ul",{className:"space-y-1 font-mono text-xs",children:o.map((s,a)=>{const i=Array.isArray(s.urls)?s.urls.join(", "):s.urls;return u("li",{className:"text-foreground",children:[i,s.username&&u("span",{className:"text-foreground-subtle",children:[" (user: ",s.username,")"]})]},a)})})})]})]})})}const Y8={lan:an,wifi:jn,docker:ga,vpn:iy,loopback:ln,other:ln},Z8={lan:"LAN",wifi:"Wi-Fi",docker:"Docker",vpn:"VPN",loopback:"Loopback",other:"Other"},X8=["lan","wifi","vpn","docker","other","loopback"];function J8(e){const{interfaces:t,disabled:n,hideLoopback:o,ipv4Only:s,emptyMessage:a}=e,i=Q(()=>t.filter(f=>!(o&&f.kind==="loopback"||s&&f.family!=="IPv4")),[t,o,s]),l=Q(()=>{const f=new Map;for(const p of i){const m=f.get(p.kind)??[];m.push(p),f.set(p.kind,m)}return X8.filter(p=>f.has(p)).map(p=>({kind:p,items:f.get(p)}))},[i]),c=f=>e.mode==="single"?e.value===f:e.value.includes(f),d=f=>{if(n||f.kind==="loopback")return;if(e.mode==="single"){e.onChange(e.value===f.address?null:f.address);return}const p=new Set(e.value);p.has(f.address)?p.delete(f.address):p.add(f.address),e.onChange([...p])};return i.length===0?r("div",{className:"text-xs text-foreground-subtle italic",children:a??"No addresses available."}):r("div",{className:"flex flex-col gap-3",children:l.map(({kind:f,items:p})=>{const m=Y8[f]??ln;return u("div",{className:"rounded-md border border-border overflow-hidden",children:[u("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border",children:[r(m,{className:"h-3.5 w-3.5 text-foreground-subtle"}),r("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle",children:Z8[f]??f}),u("span",{className:"text-[10px] text-foreground-subtle",children:["· ",p.length]})]}),r("ul",{className:"divide-y divide-border",children:p.map(h=>{const g=c(h.address),b=h.kind==="loopback",x=!h.plausible&&!b;return u("li",{className:`flex items-center gap-3 px-3 py-2 ${b?"opacity-60 cursor-not-allowed":n?"opacity-60":x?"cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]":"cursor-pointer hover:bg-surface-hover/30"}`,onClick:()=>d(h),children:[r("span",{className:`flex items-center justify-center h-4 w-4 rounded ${e.mode==="single"?"rounded-full":"rounded"} border ${g?"border-primary bg-primary text-primary-foreground":"border-border bg-surface"}`,children:g&&r(Ct,{className:"h-3 w-3"})}),u("div",{className:`flex-1 min-w-0 ${x?"text-foreground-subtle":""}`,children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:`font-mono text-xs font-semibold ${x?"text-foreground-subtle":"text-foreground"}`,children:h.name}),r("span",{className:"text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono",children:h.family}),h.preferred&&r("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary",children:"Auto-preferred"}),b&&r("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle",children:"Always included"}),x&&u("span",{className:"inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300",title:h.plausibleReason||void 0,children:[r(xt,{className:"h-2.5 w-2.5"}),"Unlikely usable"]})]}),u("div",{className:"text-xs text-foreground-subtle mt-0.5 font-mono break-all",children:[h.address,h.cidr&&h.cidr!==h.address?` (${h.cidr})`:""]})]})]},`${h.name}-${h.family}-${h.address}`)})})]},f)})})}const wp={"lan-ipv4":"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300","lan-ipv6":"bg-violet-500/15 text-violet-700 dark:text-violet-300",public:"bg-blue-500/15 text-blue-700 dark:text-blue-300",loopback:"bg-foreground-subtle/15 text-foreground-subtle"};function e9(){const e=ke(),t=Le(),n=Hg(void 0,{refetchInterval:3e4}),o=qg(void 0),s=Qg({onSuccess:()=>{e.invalidateQueries({queryKey:[["localNetwork"]]})}}),a=Ug({onSuccess:S=>{p(S.addresses),e.invalidateQueries({queryKey:[["localNetwork"]]})}}),i=Q(()=>n.data?.interfaces??[],[n.data]),l=typeof window<"u"?Number(window.location.port)||(window.location.protocol==="https:"?443:80):4e3,c=typeof window<"u"&&window.location.protocol==="https:"?"https":"http",d=Vg({port:l,scheme:c},{refetchInterval:3e4}),[f,p]=$([]),[m,h]=$(!1);Y(()=>{!m&&o.data&&(p(o.data.addresses),h(!0))},[o.data,m]);const g=o.data?.addresses??[],b=Q(()=>{if(f.length!==g.length)return!0;const S=[...f].sort(),M=[...g].sort();return S.some((P,I)=>P!==M[I])},[f,g]),x=()=>{s.mutate({addresses:[...f]})},v=()=>{p(g)},w=()=>{p([])},y=()=>{n.refetch(),d.refetch(),o.refetch()},N=async()=>{try{const S=await t.raceConnectionEndpoints({perCandidateTimeoutMs:1500});console.info("[network-addresses] race result",S)}catch(S){console.warn("[network-addresses] race failed",S)}},k=d.data?.endpoints??[];return r(It,{icon:an,title:"Network Addresses",subtitle:"Pick the local addresses SDK clients should race for the fastest path to this hub. Empty selection (auto) lets every non-loopback / non-link-local interface participate.",actions:u("div",{className:"flex items-center gap-2",children:[u(He,{size:"sm",variant:"secondary",onClick:y,disabled:n.isLoading,children:[r(pt,{className:`h-3 w-3 ${n.isLoading?"animate-spin":""}`}),"Refresh"]}),r(He,{size:"sm",variant:"secondary",onClick:N,children:"Probe race"})]}),children:u("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[u(Ge,{children:[u("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[u("div",{children:[r("div",{className:"text-sm font-semibold",children:"Allowed addresses"}),r("div",{className:"text-xs text-foreground-subtle",children:f.length===0?"Auto — every non-loopback / non-link-local interface participates.":`${f.length} pinned`})]}),u("div",{className:"flex items-center gap-1",children:[u(He,{size:"sm",variant:"secondary",onClick:()=>a.mutate(void 0),disabled:a.isPending||s.isPending,title:"Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.",children:[r(eT,{className:"h-3 w-3"}),a.isPending?"Detecting…":"Best match"]}),u(He,{size:"sm",variant:"secondary",onClick:w,disabled:f.length===0||s.isPending,children:[r(fy,{className:"h-3 w-3"}),"Clear"]}),b&&r(He,{size:"sm",variant:"secondary",onClick:v,disabled:s.isPending,children:"Discard"}),u(He,{size:"sm",variant:"primary",onClick:x,disabled:!b||s.isPending,children:[r(FL,{className:"h-3 w-3"}),s.isPending?"Saving…":"Save"]})]})]}),r("div",{className:"p-4",children:r(J8,{mode:"multiple",interfaces:i,value:f,onChange:p,disabled:s.isPending,emptyMessage:n.isLoading?"Loading interfaces…":"No interfaces detected."})})]}),u(Ge,{children:[u("div",{className:"px-4 py-3 border-b border-border",children:[r("div",{className:"text-sm font-semibold",children:"Connection endpoints — priority order"}),r("div",{className:"text-xs text-foreground-subtle",children:"Live preview of the ranked candidate list the SDK would race against. Updates with each Save."})]}),r("div",{className:"p-4",children:k.length===0?r("div",{className:"text-xs text-foreground-subtle italic",children:d.isLoading?"Loading…":"No endpoints available."}):r("ul",{className:"space-y-1 text-xs",children:k.map(S=>u("li",{className:`flex items-center gap-2 flex-wrap ${S.plausible?"":"opacity-80"}`,children:[r("span",{className:"font-mono text-[10px] w-10 text-foreground-subtle",children:String(S.priority).padStart(4,"0")}),r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${wp[S.kind]??wp.loopback}`,children:S.kind}),S.interfaceKind!=="lan"&&S.interfaceKind!=="public"&&r("span",{className:"text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-medium uppercase",children:S.interfaceKind}),!S.plausible&&S.interfaceKind!=="loopback"&&u("span",{className:"inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300",title:S.plausibleReason||void 0,children:[r(xt,{className:"h-2.5 w-2.5"}),"Unlikely usable"]}),r("span",{className:`font-mono break-all ${S.plausible?"text-foreground":"text-foreground-subtle"}`,children:S.baseUrl}),u("span",{className:"text-foreground-subtle",children:["— ",S.label]})]},`${S.priority}-${S.baseUrl}`))})})]})]})})}const t9={tailscale:"Tailscale",headscale:"Headscale",zerotier:"ZeroTier",other:"Custom"},n9={mesh:"bg-violet-500/15 text-violet-700 dark:text-violet-300",public:"bg-blue-500/15 text-blue-700 dark:text-blue-300"};function r9(){const e=ke(),t=Kg(void 0,{refetchInterval:5e3}),n=t.data??[],[o,s]=$(null),[a,i]=$({}),[l,c]=$({}),d=()=>{e.invalidateQueries({queryKey:[["meshOrchestrator"]]}),s(null)},f=Gg({onSuccess:d,onError:()=>s(null)}),p=Wg({onSuccess:d,onError:()=>s(null)});return r(It,{icon:ga,title:"Mesh Networks",subtitle:"Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).",actions:r(Kt,{to:"/system/addons",children:r(He,{variant:"primary",size:"sm",children:"Add mesh"})}),children:t.isLoading?r(Ge,{children:r("div",{className:"p-6 text-sm text-foreground-subtle",children:"Loading providers…"})}):n.length===0?r(Ge,{children:r(ko,{title:"No mesh-network providers installed",description:"Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.",action:r(Kt,{to:"/system/addons",children:r(He,{variant:"primary",size:"sm",children:"Browse addons"})})})}):r("div",{className:"flex flex-col gap-4",children:n.map(m=>{const h=o===m.addonId,g=a[m.addonId]??"",b=l[m.addonId]??"",x=g.trim().length>=8;return u(Ge,{children:[u("div",{className:"flex items-start gap-4 p-4 border-b border-border",children:[r("div",{className:`h-10 w-10 rounded-lg flex items-center justify-center shrink-0 ${m.joined?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:r(an,{className:"h-5 w-5"})}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"font-semibold text-foreground",children:m.displayName}),r("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-blue-500/15 text-blue-700 dark:text-blue-300",children:t9[m.kind]??m.kind}),r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${m.joined?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:m.joined?"Joined":"Not joined"}),m.joined&&u("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle",children:[m.peerCount," peer",m.peerCount===1?"":"s"]})]}),r("div",{className:"text-xs text-foreground-subtle mt-1 font-mono",children:m.addonId}),m.joined&&u("div",{className:"mt-2 grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[m.meshIp&&u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"text-foreground-subtle",children:"Mesh IP:"}),r("span",{className:"font-mono text-foreground",children:m.meshIp})]}),m.magicDnsHostname&&u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"text-foreground-subtle",children:"MagicDNS:"}),r("span",{className:"font-mono text-foreground break-all",children:m.magicDnsHostname})]})]}),m.joined&&m.endpoints.length>0&&u("div",{className:"mt-3 flex flex-col gap-1",children:[r("div",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Endpoints"}),m.endpoints.map(v=>u("div",{className:"flex items-center gap-2 text-xs",children:[u("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${n9[v.scope]??"bg-foreground-subtle/15 text-foreground-subtle"}`,children:[v.scope==="public"?r(br,{className:"inline h-2.5 w-2.5 mr-0.5"}):null,v.label]}),u("a",{href:v.url,target:"_blank",rel:"noopener noreferrer",className:"text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1",children:[r(Kc,{className:"h-3 w-3 shrink-0"}),v.url]})]},v.id))]}),m.error&&r("div",{className:"text-xs text-danger mt-2",children:m.error})]}),r("div",{className:"flex flex-col items-end gap-2 shrink-0",children:m.joined?u(He,{size:"sm",variant:"secondary",disabled:h,onClick:()=>{s(m.addonId),p.mutate({addonId:m.addonId})},children:[h?r(Pe,{className:"h-3 w-3 animate-spin"}):r(ly,{className:"h-3 w-3"}),"Leave"]}):u("div",{className:"flex flex-col gap-1.5 items-stretch w-64",children:[r("input",{type:"password",autoComplete:"off",placeholder:"Auth key (tskey-auth-…)",value:g,onChange:v=>i(w=>({...w,[m.addonId]:v.target.value})),className:"rounded-md border border-border bg-surface px-2 py-1 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"}),r("input",{type:"text",placeholder:"Hostname (optional)",value:b,onChange:v=>c(w=>({...w,[m.addonId]:v.target.value})),className:"rounded-md border border-border bg-surface px-2 py-1 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"}),u(He,{size:"sm",variant:"primary",disabled:h||!x,onClick:()=>{s(m.addonId),f.mutate({addonId:m.addonId,authKey:g.trim(),hostname:b.trim()?b.trim():void 0})},children:[h?r(Pe,{className:"h-3 w-3 animate-spin"}):r(iL,{className:"h-3 w-3"}),"Join"]})]})})]}),r("div",{className:"p-4",children:r(nd,{addonId:m.addonId,maxHeight:"max-h-72"})})]},m.addonId)})})})}function o9(){return r("div",{className:"flex flex-col",children:r("div",{className:"px-6 pt-6",children:r(td,{tabs:[{id:"addresses",label:"Network Addresses",icon:ln,content:r(e9,{})},{id:"remote-access",label:"Remote Access",icon:br,content:r(K8,{})},{id:"mesh",label:"Mesh Networks",icon:ga,content:r(r9,{})},{id:"turn",label:"TURN Servers",icon:an,content:r(W8,{})}]})})})}function s9(e){const t=e.basePath;if(typeof t=="string"&&t.length>0)return t;const n=Object.keys(e);return n.length===0?"":n.join(", ")}function a9({location:e,onEdit:t,onDelete:n,onSetDefault:o}){const s=s9(e.config);return u("div",{className:"flex items-center gap-3 px-3 py-2 border-t border-border first:border-t-0 hover:bg-primary/5",children:[u("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[r("div",{className:"w-[88px] shrink-0",children:e.isDefault?u("span",{className:"inline-flex items-center gap-0.5 rounded bg-primary/10 border border-primary/20 px-1.5 py-0.5 text-[10px] font-semibold text-primary uppercase tracking-wide",title:"Default location for this type",children:[r(ri,{className:"h-2.5 w-2.5 fill-primary"}),"Default"]}):u("button",{onClick:()=>o(e),className:"inline-flex items-center gap-0.5 rounded border border-border px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 hover:border-primary/30 uppercase tracking-wide",title:"Promote to default for this type",children:[r(ri,{className:"h-2.5 w-2.5"}),"Set default"]})}),r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono",children:e.providerId}),e.isSystem&&r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5",title:"System-managed location — cannot be deleted; edit config to relocate",children:"system"}),u("div",{className:"min-w-0",children:[r("div",{className:"text-xs font-medium text-foreground truncate",children:e.displayName}),s&&r("div",{className:"text-[10px] text-foreground-subtle truncate font-mono",children:s})]})]}),u("div",{className:"flex items-center gap-1 shrink-0",children:[!e.isDefault&&u("button",{onClick:()=>o(e),className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10",title:"Set as default for this type",children:[r(ri,{className:"h-3 w-3"}),"Set default"]}),u("button",{onClick:()=>t(e),className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10",children:[r(Po,{className:"h-3 w-3"}),"Edit"]}),!e.isSystem&&us[e.type]!=="singleton"&&r("button",{onClick:()=>n(e),className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10",title:"Delete location",children:r(We,{className:"h-3 w-3"})})]})]})}function i9({type:e,displayName:t,description:n,locations:o,onAdd:s,onEdit:a,onDelete:i,onSetDefault:l}){const c=Q(()=>{const d=[...o];return d.sort((f,p)=>f.isDefault!==p.isDefault?f.isDefault?-1:1:f.displayName.localeCompare(p.displayName)),d},[o]);return u("div",{className:"rounded-lg border border-border bg-surface",children:[u("div",{className:"flex items-start justify-between border-b border-border px-3 py-2",children:[u("div",{className:"space-y-0.5",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-sm font-semibold text-foreground capitalize",children:t}),r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono",children:e})]}),n&&r("p",{className:"text-[11px] text-foreground-subtle",children:n}),us[e]==="singleton"&&r("p",{className:"text-[10px] text-foreground-subtle italic",children:"Singleton — one location per type. Edit the existing entry; it can't be split."})]}),us[e]==="multi"&&u("button",{onClick:()=>s(e),className:"inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90",children:[r(Ot,{className:"h-3 w-3"}),"Add"]})]}),c.length===0?r("div",{className:"px-3 py-4 text-center text-[11px] text-foreground-subtle italic",children:us[e]==="multi"?'No location registered. Click "Add" to register one.':"No location registered yet — should be auto-seeded at next boot."}):r("div",{children:c.map(d=>r(a9,{location:d,onEdit:a,onDelete:i,onSetDefault:l},d.id))})]})}function l9(e){const t=e.trim().toLowerCase();return t.length===0?"":t.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Np(e,t){const n=l9(t),o=n.length>0?n:"default";return`${e}:${o}`}function o0({initialType:e,onClose:t,onCreated:n}){const o=ke(),s=Le().trpcClient,[a,i]=$("picker"),[l,c]=$(e),[d,f]=$(null),[p,m]=$({}),[h,g]=$(""),[b,x]=$(null),[v,w]=$(!1),[y,N]=$(null),[k,S]=$(!1),M=wc(),P=Q(()=>{const D=M.data;return Array.isArray(D)?D.filter(R=>R.supportedLocationTypes.includes(l)):[]},[M.data,l]),I=M.isLoading,F=ca({onSuccess:()=>{o.invalidateQueries({queryKey:[["storage","listLocations"]]}),n()}}),E=Q(()=>b!==null&&b.length>0?b:Np(l,h),[l,h,b]),B=async()=>{if(d){S(!0),N(null);try{const R=await(L=>s.storage.testConfig.query(L))({providerId:d.providerId,config:p});N(R)}catch(D){N({ok:!1,error:D instanceof Error?D.message:String(D)})}finally{S(!1)}}},O=()=>{d&&F.mutate({id:E,type:l,displayName:h.trim(),providerId:d.providerId,config:p,isDefault:v})},A={picker:"Add Location — Pick provider",config:`Add Location — ${d?.displayName??""}`,naming:"Add Location — Name & defaults"};return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:t,children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:D=>D.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:A[a]}),u("p",{className:"text-xs text-foreground-subtle",children:["Type: ",r("span",{className:"font-mono",children:l})]})]}),r("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:r(qe,{className:"h-4 w-4"})})]}),a==="picker"&&u("div",{className:"p-4 space-y-2",children:[I&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading providers…"}),!I&&P.length===0&&u("div",{className:"rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle",children:['No storage-provider supports type "',l,'". Install a compatible addon (e.g. ',r("code",{className:"font-mono",children:"remote-storage"}),") to enable it."]}),P.map(D=>u("button",{onClick:()=>{f(D),i("config")},className:"flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors",children:[u("div",{className:"flex-1 min-w-0",children:[r("p",{className:"text-xs font-semibold text-foreground",children:D.displayName}),r("p",{className:"text-[10px] text-foreground-subtle font-mono mt-0.5 truncate",children:D.providerId})]}),r(Mt,{className:"h-4 w-4 text-foreground-subtle flex-shrink-0"})]},D.providerId))]}),a==="config"&&d&&u("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[r(Nn,{schema:d.configSchema,values:p,onChange:m}),y&&r("div",{className:`rounded border px-3 py-2 text-[11px] ${y.ok?"border-success/30 bg-success/5 text-success":"border-danger/30 bg-danger/5 text-danger"}`,children:y.ok?"Connection OK.":`Test failed: ${y.error??"unknown error"}`}),u("div",{className:"flex items-center justify-between pt-1",children:[r("button",{onClick:()=>i("picker"),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Back"}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>{B()},disabled:k,className:"rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50",children:k?"Testing…":"Test connection"}),r("button",{onClick:()=>i("naming"),className:"rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:"Next"})]})]})]}),a==="naming"&&d&&u("div",{className:"p-4 space-y-3",children:[u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Display name"}),r("input",{type:"text",value:h,onChange:D=>g(D.target.value),placeholder:`${l} on ${d.displayName}`,className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary"})]}),u("div",{className:"space-y-1",children:[u("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:["Id ",r("span",{className:"lowercase tracking-normal text-foreground-subtle",children:"— auto-derived; override if needed"})]}),r("input",{type:"text",value:E,onChange:D=>x(D.target.value),placeholder:Np(l,h),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-1 focus:ring-primary"}),u("p",{className:"text-[10px] text-foreground-subtle",children:["Format: ",r("code",{className:"font-mono",children:"<type>:<slug>"}),". Lowercase letters, digits, and hyphens only."]})]}),u("label",{className:"flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5",children:[r("input",{type:"checkbox",checked:v,onChange:D=>w(D.target.checked),className:"accent-primary mt-0.5"}),u("div",{className:"space-y-0.5",children:[u("div",{className:"text-xs font-medium text-foreground",children:['Mark as default for type "',l,'"']}),u("div",{className:"text-[10px] text-foreground-subtle",children:["Setting this as default will demote the current default for this type. References like"," ",u("code",{className:"font-mono",children:['"',l,'"']})," resolve to whichever location is the default."]})]})]}),F.isError&&r("div",{className:"rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]",children:F.error instanceof Error?F.error.message:String(F.error)}),u("div",{className:"flex items-center justify-between pt-1",children:[r("button",{onClick:()=>i("config"),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Back"}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>{c(e),f(null),m({}),g(""),x(null),w(!1),N(null),i("picker")},className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Reset"}),u("button",{onClick:O,disabled:F.isPending||h.trim().length===0,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[F.isPending?r(Pe,{className:"h-3.5 w-3.5 animate-spin"}):null,F.isPending?"Saving…":"Save"]})]})]})]})]})})}function c9({location:e,onClose:t,onSaved:n}){const o=ke(),s=Le().trpcClient,[a,i]=$({...e.config}),[l,c]=$(e.displayName),[d,f]=$(null),[p,m]=$(!1),h=wc(),g=Q(()=>{const w=h.data;return Array.isArray(w)?w.find(N=>N.providerId===e.providerId)??null:null},[h.data,e.providerId]),b=ca({onSuccess:()=>{o.invalidateQueries({queryKey:[["storage","listLocations"]]}),n()}}),x=async()=>{m(!0),f(null);try{const y=await(N=>s.storage.testConfig.query(N))({providerId:e.providerId,config:a});f(y)}catch(w){f({ok:!1,error:w instanceof Error?w.message:String(w)})}finally{m(!1)}},v=()=>{b.mutate({id:e.id,type:e.type,providerId:e.providerId,isDefault:e.isDefault,displayName:l.trim(),config:a})};return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:t,children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:w=>w.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[u("h2",{className:"text-sm font-semibold text-foreground",children:["Edit ",e.displayName]}),u("p",{className:"text-xs text-foreground-subtle",children:[r("span",{className:"font-mono",children:e.id})," · ",g?.displayName??e.providerId]})]}),r("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:r(qe,{className:"h-4 w-4"})})]}),u("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Display name"}),r("input",{type:"text",value:l,onChange:w=>c(w.target.value),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary"})]}),g&&r(Nn,{schema:g.configSchema,values:a,onChange:i}),!g&&!h.isLoading&&u("div",{className:"rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300",children:["Provider ",r("code",{className:"font-mono",children:e.providerId})," is no longer registered. Field schema unavailable; raw config is preserved on save."]}),d&&r("div",{className:`rounded border px-3 py-2 text-[11px] ${d.ok?"border-success/30 bg-success/5 text-success":"border-danger/30 bg-danger/5 text-danger"}`,children:d.ok?"Connection OK.":`Test failed: ${d.error??"unknown error"}`}),b.isError&&r("div",{className:"rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]",children:b.error instanceof Error?b.error.message:String(b.error)})]}),u("div",{className:"flex items-center justify-between gap-2 border-t border-border px-4 py-3",children:[r("button",{onClick:t,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>{x()},disabled:p||!g,className:"rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50",children:p?"Testing…":"Test connection"}),u("button",{onClick:v,disabled:b.isPending||l.trim().length===0,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[b.isPending?r(Pe,{className:"h-3.5 w-3.5 animate-spin"}):null,b.isPending?"Saving…":"Save"]})]})]})]})})}const d9={data:"Data",media:"Media",recordings:"Recordings","recordings-high":"Recordings (High)","recordings-low":"Recordings (Low)","recordings-clips":"Recordings (Clips)","event-images":"Event Images",models:"Models","addons-data":"Addons Data",cache:"Cache",logs:"Logs",backups:"Backups"},u9={backups:"Snapshot archives. Default landing for `backup-orchestrator`.",recordings:"Continuous recordings (combined high + low + clips when no slot is specified).","recordings-high":"High-quality continuous recordings.","recordings-low":"Low-quality continuous recordings.","recordings-clips":"Event clips (motion / detection triggers).","event-images":"Detection snapshots, thumbnails, and crops.",models:"ML model files. Read by inference-engine addons.",logs:"Long-term log archives."};function p9(){const e=ke(),t=rt(),{data:n,isLoading:o,isError:s}=Kb({}),[a,i]=$(null),[l,c]=$(null),d=Gb({onSuccess:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]})}}),f=ca({onSuccess:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]})}}),p=g=>{g.isDefault||f.mutate({id:g.id,type:g.type,providerId:g.providerId,displayName:g.displayName,config:g.config,isDefault:!0})},m=async g=>{if(g.isDefault){await t({title:"Cannot delete default location",message:`"${g.displayName}" is the default for type "${g.type}". Mark another location as default first, then delete this one.`,confirmLabel:"OK",variant:"warning"});return}await t({title:`Delete location "${g.displayName}"?`,message:"This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.",confirmLabel:"Delete",variant:"danger"})&&d.mutate({id:g.id})},h=Q(()=>{const g=new Map;for(const b of Ed)g.set(b,[]);for(const b of n??[]){const x=g.get(b.type);x?x.push(b):g.set(b.type,[b])}return g},[n]);return u(It,{icon:lo,title:"Storage Locations",subtitle:u(ve,{children:["Register where each kind of data lives. Each type can have multiple locations — one is the default, the rest are addressable by their fully-qualified id (",r("code",{className:"font-mono",children:"<type>:<slug>"}),")."]}),children:[o&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading locations…"}),s&&r("div",{className:"text-xs text-danger",children:"Failed to load storage locations."}),!o&&!s&&r("div",{className:"space-y-3",children:Ed.map(g=>r(i9,{type:g,displayName:d9[g],description:u9[g],locations:h.get(g)??[],onAdd:b=>i(b),onEdit:b=>c(b),onDelete:b=>{m(b)},onSetDefault:b=>p(b)},g))}),a!==null&&r(o0,{initialType:a,onClose:()=>i(null),onCreated:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]}),i(null)}}),l!==null&&r(c9,{location:l,onClose:()=>c(null),onSaved:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]}),c(null)}})]})}const f9=[["backup","listDestinations"]],m9=["backup","listArchives"];function h9({destinationId:e,restoreSupported:t,onOpenRestoreWizard:n}){const o=ke(),s=rt(),{data:a,isLoading:i,isError:l}=pc({destinationId:e}),c=a??[],d=pg({onSuccess:()=>{o.invalidateQueries({queryKey:[[...m9]]}),o.invalidateQueries({queryKey:f9})}}),f=q(async b=>{await s({title:"Delete this archive?",message:`Permanently deletes "${b.label??b.id}" and frees ${Nt(b.sizeBytes)}.`,confirmLabel:"Delete",variant:"danger"})&&d.mutate({destinationId:e,backupId:b.id})},[s,e,d]),[p,m]=$(null),h=q(async b=>{m(b.id);try{const x=localStorage.getItem("camstack_admin_token"),v={};x&&(v.Authorization=`Bearer ${x}`);const w=await fetch(g9(e,b.id),{headers:v});if(!w.ok)throw new Error(`download failed: ${w.status} ${w.statusText}`);const y=await w.blob(),N=URL.createObjectURL(y),k=document.createElement("a");k.href=N,k.download=`${b.label??b.id}.tar.gz`,document.body.appendChild(k),k.click(),k.remove(),URL.revokeObjectURL(N)}finally{m(null)}},[e]),g=Q(()=>[...c].sort((b,x)=>x.createdAt-b.createdAt),[c]);return i?r("div",{className:"text-xs text-foreground-subtle animate-pulse py-2",children:"Loading archives…"}):l?r("div",{className:"text-xs text-danger py-2",children:"Failed to read manifest for this destination"}):g.length===0?r("div",{className:"text-xs text-foreground-subtle italic py-2",children:"No archives at this destination yet."}):r("div",{className:"rounded border border-border bg-surface overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[640px]",children:[r("thead",{children:u("tr",{className:"text-foreground-subtle bg-background/30",children:[r("th",{className:"text-left px-3 py-1.5 font-medium",children:"When"}),r("th",{className:"text-left px-3 py-1.5 font-medium",children:"Label"}),r("th",{className:"text-left px-3 py-1.5 font-medium",children:"Includes"}),r("th",{className:"text-right px-3 py-1.5 font-medium",children:"Size"}),r("th",{className:"text-right px-3 py-1.5 font-medium w-52",children:"Actions"})]})}),r("tbody",{children:g.map(b=>u("tr",{className:"border-t border-border hover:bg-primary/5",children:[r("td",{className:"px-3 py-1.5 text-foreground tabular-nums",children:b9(b.createdAt)}),r("td",{className:"px-3 py-1.5 text-foreground",children:b.label??r("span",{className:"text-foreground-subtle italic",children:"—"})}),r("td",{className:"px-3 py-1.5 text-foreground-subtle",children:b.locations.join(", ")}),r("td",{className:"px-3 py-1.5 text-foreground text-right tabular-nums",children:Nt(b.sizeBytes)}),r("td",{className:"px-3 py-1.5",children:u("div",{className:"flex items-center justify-end gap-1",children:[u("button",{onClick:()=>{h(b)},disabled:p===b.id,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 disabled:opacity-50",title:"Download archive",children:[p===b.id?r(Pe,{className:"h-3 w-3 animate-spin"}):r(wn,{className:"h-3 w-3"}),"Download"]}),t&&n&&u("button",{onClick:()=>n({destinationId:e,archiveId:b.id}),className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-primary hover:bg-primary/10",title:"Restore from this archive",children:[r(bt,{className:"h-3 w-3"}),"Restore"]}),r("button",{onClick:()=>{f(b)},disabled:d.isPending,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50",title:"Delete archive",children:d.isPending?r(Pe,{className:"h-3 w-3 animate-spin"}):r(We,{className:"h-3 w-3"})})]})})]},b.id))})]})})}function g9(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function b9(e){return new Date(e).toLocaleString(void 0,{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}const s0=[{id:"manual",label:"Manual only",cron:""},{id:"hourly",label:"Every hour",cron:"0 * * * *",description:"On the hour"},{id:"every-3h",label:"Every 3 hours",cron:"0 */3 * * *",description:"00:00, 03:00, 06:00, 09:00 …"},{id:"every-6h",label:"Every 6 hours",cron:"0 */6 * * *",description:"00:00, 06:00, 12:00, 18:00"},{id:"daily-3am",label:"Daily at 03:00",cron:"0 3 * * *",description:"Every night at 3 AM"},{id:"weekly-sun",label:"Weekly Sunday 03:00",cron:"0 3 * * 0",description:"Sunday morning at 3 AM"}];function x9(e){const t=e.trim();for(const n of s0)if(n.cron===t)return n.id;return"custom"}function y9({value:e,onChange:t,previewCount:n=5,disabled:o=!1}){const s=x9(e),[a,i]=$(s==="custom");Y(()=>{s!=="custom"&&i(!1)},[s]);const l=N9(e,250),c=mg({cron:l,count:n},{enabled:l.trim().length>0}),d=c.data??null,f=m=>{i(!1),t(m.cron)},p=a||s==="custom";return u("div",{className:"space-y-3",children:[u("div",{className:"space-y-1",children:[r("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Schedule preset"}),u("div",{className:"flex flex-wrap gap-1.5",children:[s0.map(m=>{const h=!a&&s===m.id;return r("button",{type:"button",onClick:()=>f(m),disabled:o,className:"rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 "+(h?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground"),title:m.description??m.label,children:m.label},m.id)}),r("button",{type:"button",onClick:()=>{i(!0),e.trim().length===0&&t("0 3 * * *")},disabled:o,className:"rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 "+(p?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground"),children:"Custom…"})]})]}),p&&u("div",{className:"space-y-1",children:[r("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Cron expression (5-field POSIX)"}),r("input",{type:"text",value:e,onChange:m=>t(m.target.value),disabled:o,placeholder:"0 3 * * *",spellCheck:!1,className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"}),u("p",{className:"text-[10px] text-foreground-subtle",children:["Format: ",r("span",{className:"font-mono",children:"minute hour day-of-month month day-of-week"})," · all times server-local"]})]}),r(v9,{cron:l,preview:d,loading:c.isFetching})]})}function v9({cron:e,preview:t,loading:n}){return n&&t===null?u("div",{className:"flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle",children:[r(Pe,{className:"h-3 w-3 animate-spin"}),"Validating…"]}):t===null?null:t.ok?t.nextRuns.length===0?r("div",{className:"rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle",children:"No future runs match this expression."}):u("div",{className:"space-y-1",children:[r("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Next runs"}),r("ul",{className:"rounded border border-border bg-background/40 divide-y divide-border",children:t.nextRuns.map((o,s)=>u("li",{className:"flex items-center justify-between px-3 py-1.5 text-[11px]",children:[r("span",{className:"text-foreground tabular-nums",children:new Date(o).toLocaleString()}),r("span",{className:"text-foreground-subtle text-[10px] tabular-nums",children:w9(o)})]},`${o}-${s}`))})]}):r("div",{className:"rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger",children:t.error??"Invalid cron expression"})}function w9(e){const t=e-Date.now();if(t<=0)return"now";const n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;const o=Math.floor(n/60);if(o<60)return`in ${o}m`;const s=Math.floor(o/60);return s<24?`in ${s}h`:`in ${Math.floor(s/24)}d`}function N9(e,t){const[n,o]=$(e),s=Q(()=>e,[e]);return Y(()=>{const a=setTimeout(()=>o(s),t);return()=>clearTimeout(a)},[s,t]),n}const k9=[["backup","listDestinations"]];function S9({onCreateAt:e,onOpenRestoreWizard:t}){const{data:n,isLoading:o,isError:s}=uc(),a=n??[],[i,l]=$(null),c=f=>{l(p=>p===f?null:f)},d=P9();return o?r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading destinations…"}):s?r("div",{className:"text-xs text-danger",children:"Failed to load destinations"}):a.length===0?r("div",{className:"rounded-lg border border-border bg-surface px-4 py-8 text-center",children:r("p",{className:"text-xs text-foreground-subtle",children:"No `backups`-typed storage locations registered. Add one in Settings → Storage to begin."})}):r("div",{className:"rounded-lg border border-border bg-surface overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[720px]",children:[r("thead",{children:u("tr",{className:"text-foreground-subtle border-b border-border bg-background/40",children:[r("th",{className:"text-left px-3 py-2 font-medium w-6"}),r("th",{className:"text-left px-3 py-2 font-medium",children:"Destination"}),r("th",{className:"text-left px-3 py-2 font-medium w-20",children:"Enabled"}),r("th",{className:"text-left px-3 py-2 font-medium w-28",children:"Retention"}),r("th",{className:"text-left px-3 py-2 font-medium w-56",children:"Schedule"}),r("th",{className:"text-left px-3 py-2 font-medium w-44",children:"Last success"}),r("th",{className:"text-right px-3 py-2 font-medium w-44",children:"Actions"})]})}),r("tbody",{children:a.map(f=>{const p=d.get(f.id);return r(C9,{row:f,isOpen:i===f.id,onToggle:()=>c(f.id),onCreateAt:e,liveLastSuccessAt:p?.at,liveLastSuccessSizeBytes:p?.sizeBytes,...t?{onOpenRestoreWizard:t}:{}},f.id)})})]})})}function C9({row:e,isOpen:t,onToggle:n,onCreateAt:o,onOpenRestoreWizard:s,liveLastSuccessAt:a,liveLastSuccessSizeBytes:i}){const l=ke(),c=fg({onSuccess:()=>{l.invalidateQueries({queryKey:k9})}}),[d,f]=$(String(e.retentionCount));Y(()=>{f(String(e.retentionCount))},[e.retentionCount]);const[p,m]=$(!1),h=q(x=>{c.mutate({locationId:e.id,enabled:x,retentionCount:e.retentionCount,...e.label!==void 0?{label:e.label}:{},...e.cron!==void 0?{cron:e.cron}:{}})},[c,e.id,e.retentionCount,e.label,e.cron]),g=q(()=>{const x=Number.parseInt(d,10);if(Number.isNaN(x)||x<1){f(String(e.retentionCount));return}x!==e.retentionCount&&c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:x,...e.label!==void 0?{label:e.label}:{},...e.cron!==void 0?{cron:e.cron}:{}})},[c,d,e.id,e.enabled,e.retentionCount,e.label,e.cron]),b=q(x=>{c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:e.retentionCount,...e.label!==void 0?{label:e.label}:{},cron:x},{onSuccess:()=>{m(!1)}})},[c,e.id,e.enabled,e.retentionCount,e.label]);return u(ve,{children:[u("tr",{className:"border-t border-border first:border-t-0 hover:bg-primary/5",children:[r("td",{className:"px-2 py-2",children:r("button",{onClick:n,className:"inline-flex items-center justify-center rounded p-1 text-foreground-subtle hover:bg-primary/10 hover:text-foreground",title:t?"Hide archives":"Show archives",children:t?r(Rt,{className:"h-3.5 w-3.5"}):r(Mt,{className:"h-3.5 w-3.5"})})}),r("td",{className:"px-3 py-2",children:u("button",{onClick:n,className:"text-left hover:underline focus:outline-none",title:"View archives",children:[r("div",{className:"text-foreground font-medium",children:e.displayName}),u("div",{className:"flex items-center gap-1.5 mt-0.5",children:[r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5",children:e.kind}),r("span",{className:"text-[10px] text-foreground-subtle font-mono",children:e.id})]})]})}),r("td",{className:"px-3 py-2",children:r("label",{className:"inline-flex items-center cursor-pointer",children:r("input",{type:"checkbox",className:"accent-primary",checked:e.enabled,disabled:c.isPending,onChange:x=>h(x.target.checked)})})}),r("td",{className:"px-3 py-2",children:r("input",{type:"number",min:1,max:1e3,value:d,disabled:c.isPending,onChange:x=>f(x.target.value),onBlur:g,onKeyDown:x=>{x.key==="Enter"&&x.target.blur(),x.key==="Escape"&&f(String(e.retentionCount))},className:"w-16 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary"})}),r("td",{className:"px-3 py-2",children:r(M9,{cron:e.cron,nextRunAt:e.nextRunAt,onEdit:()=>m(!0),disabled:c.isPending})}),r("td",{className:"px-3 py-2 text-foreground-subtle",children:(()=>{const x=E9(a,e.lastSuccessAt),v=x===a?i:e.lastSuccessSizeBytes;return x!==void 0?r($9,{at:x,sizeBytes:v}):r("span",{className:"italic",children:"Never"})})()}),r("td",{className:"px-3 py-2",children:r("div",{className:"flex items-center justify-end gap-1.5",children:e.triggerSupported&&u("button",{onClick:()=>o(e),className:"inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90",children:[r(Ot,{className:"h-3 w-3"}),"Create here"]})})})]}),t&&r("tr",{className:"border-t border-border bg-background/30",children:r("td",{colSpan:7,className:"px-4 py-3",children:r(h9,{destinationId:e.id,restoreSupported:e.restoreSupported,...s?{onOpenRestoreWizard:s}:{}})})}),p&&r(A9,{destinationName:e.displayName,currentCron:e.cron??"",onSave:b,onClose:()=>m(!1),saving:c.isPending,saveError:c.error instanceof Error?c.error.message:null})]})}function M9({cron:e,nextRunAt:t,onEdit:n,disabled:o}){const s=typeof e=="string"&&e.trim().length>0;return u("button",{type:"button",onClick:n,disabled:o,className:"group flex flex-col items-start gap-0.5 text-left rounded px-1.5 py-1 -mx-1.5 hover:bg-primary/5 disabled:opacity-50",title:"Edit schedule",children:[u("div",{className:"flex items-center gap-1.5",children:[r(aD,{className:"h-3 w-3 text-foreground-subtle group-hover:text-foreground"}),r("span",{className:s?"font-mono text-foreground":"italic text-foreground-subtle",children:s?e:"Manual"})]}),s&&t!==void 0&&u("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:["next ",I9(t)]})]})}function I9(e){const t=e-Date.now();if(t<=0)return"imminent";const n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;const o=Math.floor(n/60);if(o<60)return`in ${o}m`;const s=Math.floor(o/60);return s<24?`in ${s}h`:`in ${Math.floor(s/24)}d`}function A9({destinationName:e,currentCron:t,onSave:n,onClose:o,saving:s,saveError:a}){const[i,l]=$(t);return r("tr",{children:r("td",{colSpan:7,className:"p-0",children:r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:o,children:u("div",{className:"w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl",onClick:c=>c.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:"Schedule"}),u("p",{className:"text-xs text-foreground-subtle",children:["→ ",e]})]}),r("button",{onClick:o,className:"text-foreground-subtle hover:text-foreground",title:"Close",children:r(qe,{className:"h-4 w-4"})})]}),u("div",{className:"p-4",children:[r(y9,{value:i,onChange:l,disabled:s}),a!==null&&r("div",{className:"mt-3 rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger",children:a})]}),u("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:[r("button",{onClick:o,disabled:s,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground disabled:opacity-50",children:"Cancel"}),r("button",{onClick:()=>n(i.trim()),disabled:s||i.trim()===t.trim(),className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:s?"Saving…":"Save"})]})]})})})})}function P9(){const{map:e}=Jl(Ne.BackupCompleted,t=>t.destinationId);return Q(()=>{const t=new Map;for(const[n,o]of e)t.set(n,{at:Date.now(),sizeBytes:o.sizeMB*1024*1024});return t},[e])}function E9(e,t){return e===void 0?t:t===void 0||e>t?e:t}function $9({at:e,sizeBytes:t}){const n=_9(e),o=Q(()=>new Date(e).toLocaleString(),[e]);return u("span",{title:o,className:"text-foreground tabular-nums",children:[n,t!==void 0&&u("span",{className:"ml-1 text-foreground-subtle",children:["· ",Nt(t)]})]})}function _9(e){const[,t]=$(0);return Y(()=>{const n=setInterval(()=>t(o=>o+1),3e4);return()=>clearInterval(n)},[]),D9(e)}function D9(e){const t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const o=Math.floor(n/60);if(o<60)return`${o}m ago`;const s=Math.floor(o/60);if(s<24)return`${s}h ago`;const a=Math.floor(s/24);if(a<30)return`${a}d ago`;const i=Math.floor(a/30);return i<12?`${i}mo ago`:`${Math.floor(a/365)}y ago`}const L9=[["backup","list"]];function T9({initialDestinationId:e,initialArchiveId:t,onClose:n,onScheduled:o}){const s=ke(),[a,i]=$(e&&t?2:1),[l,c]=$(e),[d,f]=$(t),[p,m]=$(new Set),{data:h}=uc(),g=h??[],{data:b,isLoading:x}=pc({destinationId:l??""},{enabled:!!l}),v=b??[];Y(()=>{if(l!==void 0)return;const F=g.filter(E=>E.restoreSupported);F.length===1&&c(F[0].id)},[l,g]);const{data:w}=dg({destinationId:l??"",backupId:d??""},{enabled:!!l&&!!d}),y=Q(()=>w?.locations??[],[w]);Y(()=>{y.length!==0&&m(F=>F.size===0?new Set(y):F)},[y]);const N=ug({onSuccess:()=>{s.invalidateQueries({queryKey:L9}),o(),n()}}),k=F=>{m(E=>{const B=new Set(E);return B.has(F)?B.delete(F):B.add(F),B})},S=!!l&&!!d,M=p.size>0,P=S&&M&&!N.isPending,I=()=>{!l||!d||N.mutate({destinationId:l,backupId:d,locations:[...p]})};return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:n,children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:F=>F.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:"Restore Backup"}),u("p",{className:"text-xs text-foreground-subtle",children:["Step ",a," of 3 — ",a===1?"pick source":a===2?"pick locations":"confirm"]})]}),r("button",{onClick:n,className:"text-foreground-subtle hover:text-foreground",children:r(qe,{className:"h-4 w-4"})})]}),a===1&&r(R9,{destinations:g,destinationId:l,onPickDestination:F=>{c(F),f(void 0),m(new Set)},archives:v,archivesLoading:x,archiveId:d,onPickArchive:f}),a===2&&r(O9,{locations:y,picked:p,onToggle:k}),a===3&&r(z9,{destinationName:g.find(F=>F.id===l)?.displayName??l??"",archive:v.find(F=>F.id===d),picked:[...p]}),u("div",{className:"flex justify-between gap-2 border-t border-border px-4 py-3",children:[r("div",{children:a>1&&u("button",{onClick:()=>i(F=>F===3?2:1),className:"inline-flex items-center gap-1 rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:[r(Wx,{className:"h-3 w-3"}),"Back"]})}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:n,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),a<3?u("button",{disabled:a===1&&!S||a===2&&!M,onClick:()=>i(F=>F===1?2:3),className:"inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:["Next",r(Yx,{className:"h-3 w-3"})]}):u("button",{onClick:I,disabled:!P,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[N.isPending?r(Pe,{className:"h-3.5 w-3.5 animate-spin"}):r(bt,{className:"h-3.5 w-3.5"}),"Schedule Restore"]})]})]})]})})}function R9({destinations:e,destinationId:t,onPickDestination:n,archives:o,archivesLoading:s,archiveId:a,onPickArchive:i}){const l=e.filter(c=>c.restoreSupported);return u("div",{className:"p-4 space-y-3",children:[u("div",{className:"space-y-1.5",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Destination"}),u("select",{value:t??"",onChange:c=>n(c.target.value),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary",children:[r("option",{value:"",disabled:!0,children:"Select destination…"}),l.map(c=>u("option",{value:c.id,children:[c.displayName," (",c.kind,")"]},c.id))]})]}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Archive"}),!t&&r("div",{className:"text-xs text-foreground-subtle italic",children:"Pick a destination first."}),t&&s&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Reading archives…"}),t&&!s&&o.length===0&&r("div",{className:"text-xs text-foreground-subtle italic",children:"No archives available at this destination."}),t&&o.length>0&&r("div",{className:"rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto",children:o.map(c=>{const d=a===c.id;return u("label",{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${d?"bg-primary/10":"hover:bg-primary/5"}`,children:[u("div",{className:"flex items-center gap-2",children:[r("input",{type:"radio",name:"archive",checked:d,onChange:()=>i(c.id),className:"accent-primary"}),u("div",{children:[r("div",{className:"font-medium text-foreground",children:c.label??c.id}),r("div",{className:"text-[10px] text-foreground-subtle",children:new Date(c.createdAt).toLocaleString()})]})]}),r("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:Nt(c.sizeBytes)})]},c.id)})})]})]})}function O9({locations:e,picked:t,onToggle:n}){return e.length===0?r("div",{className:"p-4",children:r("div",{className:"text-xs text-foreground-subtle",children:"Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball."})}):u("div",{className:"p-4 space-y-3",children:[r("div",{className:"rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300",children:"Selected entries will overwrite live data on the next server restart. Unchecked entries stay current."}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Apply"}),r("div",{className:"rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto",children:e.map(o=>u("label",{className:"flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer",children:[r("input",{type:"checkbox",checked:t.has(o),onChange:()=>n(o),className:"accent-primary"}),r("span",{className:"font-mono text-foreground",children:o}),r("span",{className:"ml-auto text-[10px] text-foreground-subtle",children:F9(o)})]},o))})]})]})}function z9({destinationName:e,archive:t,picked:n}){return u("div",{className:"p-4 space-y-3 text-xs",children:[r("div",{className:"rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-300",children:"Restore is applied at next server boot. Active connections will drop when you restart."}),u("dl",{className:"space-y-1.5",children:[r(ts,{term:"Destination",value:e}),r(ts,{term:"Archive",value:t?.label??t?.id??"—"}),t&&r(ts,{term:"Created",value:`${new Date(t.createdAt).toLocaleString()} · ${Nt(t.sizeBytes)}`}),r(ts,{term:"Locations",value:n.length>0?n.join(", "):"— (full archive)"})]})]})}function ts({term:e,value:t}){return u("div",{className:"flex justify-between gap-3",children:[r("dt",{className:"text-foreground-subtle",children:e}),r("dd",{className:"text-foreground font-mono text-right truncate",children:t})]})}const B9={db:"Database",addons:"Addon configs","addons-data":"Addon data",tls:"TLS certificates",cache:"Cache",data:"Top-level data"};function F9(e){return B9[e]??""}const j9=[["backup","list"]],H9=[["backup","listLocations"]];function V9(){const e=ke(),t=rt(),{data:n}=cg(),o=lg({onSuccess:()=>{e.invalidateQueries({queryKey:j9}),e.invalidateQueries({queryKey:[["backup","listDestinations"]]}),e.invalidateQueries({queryKey:[["backup","listArchives"]]})}}),s=Uh(),[a,i]=$(null),[l,c]=$(null),[d,f]=$(!1),[p,m]=$(!1),[h,g]=$(!1),b=async()=>{await t({title:"Restart server now?",message:"Active connections will drop and the apply-backup hook will run before boot.",confirmLabel:"Restart",variant:"warning"})&&s.mutate({confirm:!0})};return u(It,{icon:Qc,title:"Backup & Restore",subtitle:"Schedule + per-destination retention live in the orchestrator. Each `backups` storage location is a destination.",actions:u(ve,{children:[u("button",{onClick:()=>g(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:[r(Ot,{className:"h-3.5 w-3.5"}),"Add destination"]}),u("button",{onClick:()=>f(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30",children:[r(bt,{className:"h-3.5 w-3.5"}),"Restore…"]})]}),children:[p&&r("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs text-amber-700 dark:text-amber-300",children:u("div",{className:"flex items-center justify-between gap-3",children:[u("div",{className:"flex items-center gap-2",children:[r(bt,{className:"h-3.5 w-3.5"}),r("span",{children:"Restore scheduled. Restart the server to apply."})]}),u("button",{onClick:()=>{b()},disabled:s.isPending,className:"inline-flex items-center gap-1.5 rounded bg-amber-500/20 px-2 py-1 font-medium text-amber-800 dark:text-amber-200 hover:bg-amber-500/30 disabled:opacity-50",children:[s.isPending?r(Pe,{className:"h-3.5 w-3.5 animate-spin"}):r(bt,{className:"h-3.5 w-3.5"}),"Restart Now"]})]})}),r(S9,{onCreateAt:x=>i(x),onOpenRestoreWizard:x=>c(x)}),a&&r(q9,{destination:a,locations:n??[],onClose:()=>i(null),onSubmit:(x,v)=>{o.mutate({destinations:[a.id],locations:x,label:v||void 0},{onSuccess:()=>{i(null),e.invalidateQueries({queryKey:H9})}})},submitting:o.isPending}),(l||d)&&r(T9,{...l?{initialDestinationId:l.destinationId,initialArchiveId:l.archiveId}:{},onClose:()=>{c(null),f(!1)},onScheduled:()=>m(!0)}),h&&r(o0,{initialType:"backups",onClose:()=>g(!1),onCreated:()=>{g(!1),e.invalidateQueries({queryKey:[["backup","listDestinations"]]})}})]})}function q9({destination:e,locations:t,onClose:n,onSubmit:o,submitting:s}){const a=t.filter(p=>p.present),[i,l]=$(""),[c,d]=$(()=>new Set(a.map(p=>p.name))),f=p=>{d(m=>{const h=new Set(m);return h.has(p)?h.delete(p):h.add(p),h})};return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:n,children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:p=>p.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:"Create Backup"}),u("p",{className:"text-xs text-foreground-subtle",children:["→ ",e.displayName]})]}),r("button",{onClick:n,className:"text-foreground-subtle hover:text-foreground",children:r(qe,{className:"h-4 w-4"})})]}),u("div",{className:"p-4 space-y-3",children:[u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Label (optional)"}),r("input",{type:"text",value:i,onChange:p=>l(p.target.value),placeholder:"pre-upgrade",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Include"}),u("div",{className:"rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto",children:[a.length===0&&r("div",{className:"px-3 py-2 text-xs text-foreground-subtle italic",children:"Nothing to back up."}),a.map(p=>u("label",{className:"flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer",children:[u("div",{className:"flex items-center gap-2",children:[r("input",{type:"checkbox",checked:c.has(p.name),onChange:()=>f(p.name),className:"accent-primary"}),r("span",{className:"font-mono text-foreground",children:p.name})]}),u("div",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[Nt(p.sizeBytes)," · ",p.fileCount," files"]})]},p.name))]})]})]}),u("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:[r("button",{onClick:n,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),u("button",{onClick:()=>o(Array.from(c),i.trim()),disabled:s||c.size===0,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[s?r(Pe,{className:"h-3.5 w-3.5 animate-spin"}):r(Qc,{className:"h-3.5 w-3.5"}),s?"Creating…":"Create"]})]})]})})}function Q9(){return r("div",{className:"flex flex-col",children:r("div",{className:"px-6 pt-6",children:r(td,{tabs:[{id:"storage",label:"Storage",icon:lo,content:r(p9,{})},{id:"backup",label:"Backup",icon:Qc,content:r(V9,{})}]})})})}function U9(){const{data:e,isLoading:t}=In(void 0,{staleTime:3e4}),n=(e??[]).find(s=>s.isHub&&s.isOnline),o=n?.addons.map(s=>s.id)??[];return u("div",{className:"flex flex-col h-full gap-4 p-4",children:[u("div",{className:"flex items-center gap-3",children:[r(wt,{className:"h-5 w-5 text-muted-foreground"}),r("h1",{className:"text-xl font-semibold",children:"Settings"}),n&&u("span",{className:"text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground",children:["hub: ",n.name]})]}),t?r("div",{className:"flex items-center justify-center flex-1 text-muted-foreground text-sm",children:"Loading hub topology…"}):n?o.length===0?r("div",{className:"flex items-center justify-center flex-1 text-muted-foreground text-sm",children:"No addons installed on the hub yet."}):r("div",{className:"w-full",children:r(Rr,{nodeId:n.id,addonIds:o,level:"global"})}):u("div",{className:"flex flex-col items-center justify-center flex-1 text-muted-foreground text-sm gap-2",children:[r(wt,{className:"h-8 w-8 opacity-30"}),r("p",{children:"No online hub node found."}),r("p",{className:"text-xs",children:"Settings will appear once the hub is reachable."})]})]})}function K9(e){const t=new FormData;return t.append("file",e.file,e.file.name),t.append("nodeId",e.nodeId),e.addonId&&t.append("addonId",e.addonId),new Promise((n,o)=>{const s=new XMLHttpRequest;s.open("POST","/api/addons/upload"),e.token&&s.setRequestHeader("Authorization",`Bearer ${e.token}`),s.upload.addEventListener("progress",a=>{a.lengthComputable&&e.onProgress(Math.round(a.loaded/a.total*100))}),s.addEventListener("load",()=>{let a;try{a=JSON.parse(s.responseText)}catch{o(new Error(`HTTP ${s.status}`));return}s.status>=200&&s.status<300?n(a):o(new Error(a.error??`HTTP ${s.status}`))}),s.addEventListener("error",()=>o(new Error("Network error during upload"))),s.addEventListener("abort",()=>o(new Error("Upload aborted"))),s.send(t)})}function G9({nodeId:e,addons:t,isHub:n}){const o=ke(),s=rt(),[a,i]=$(null),[l,c]=$(null),[d,f]=$(!1),[p,m]=$(null),[h,g]=$(0),b=ne(null),x=aa(),v=Xg(),w=()=>{o.invalidateQueries({queryKey:[["nodes","topology"]]})},y=async M=>{i(M);try{await x.mutateAsync({nodeId:e,addonId:M}),w()}catch(P){console.error("Failed to restart addon:",P)}finally{i(null)}},N=async M=>{if(await s({title:"Uninstall addon",message:`Remove "${M}" from ${e}? The addon directory will be deleted on disk.`,confirmLabel:"Uninstall",variant:"danger"})){c(M);try{await v.mutateAsync({nodeId:e,addonId:M}),w()}catch(I){console.error("Failed to uninstall addon:",I)}finally{c(null)}}},S=u("div",{className:"flex items-center gap-2 mb-2",children:[r("input",{ref:b,type:"file",accept:".tgz,.tar.gz",className:"hidden",onChange:async M=>{const P=M.target.files?.[0];if(P){M.target.value="",m(null),f(!0),g(0);try{const I=localStorage.getItem("camstack_admin_token");await K9({file:P,nodeId:e,token:I,onProgress:g}),w()}catch(I){m(I instanceof Error?I.message:String(I))}finally{f(!1),g(0)}}}}),u("button",{onClick:()=>b.current?.click(),disabled:d,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:[d?r(Pe,{className:"h-3 w-3 animate-spin"}):r(Xc,{className:"h-3 w-3"}),d?`Uploading… ${h}%`:"Upload addon (.tgz)"]}),d&&r("div",{className:"flex-1 h-1 rounded-full bg-muted overflow-hidden max-w-[140px]",children:r("div",{className:"h-full bg-primary transition-all",style:{width:`${h}%`}})}),p&&r("span",{className:"text-[10px] text-destructive",children:p})]});return t.length===0?u("div",{children:[S,r("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No addons on this node"})]}):u("div",{children:[S,u("table",{className:"w-full text-xs",children:[r("thead",{children:u("tr",{className:"text-muted-foreground text-left",children:[r("th",{className:"py-2 font-medium",children:"Addon"}),r("th",{className:"py-2 font-medium",children:"Capabilities"}),r("th",{className:"py-2 font-medium",children:"Status"}),r("th",{className:"py-2 font-medium w-16"})]})}),r("tbody",{children:t.map(M=>u("tr",{className:"border-t border-border/50",children:[r("td",{className:"py-2 font-medium",children:M.id}),r("td",{className:"py-2",children:r("div",{className:"flex flex-wrap gap-1",children:M.capabilities.length>0?M.capabilities.map(P=>r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400",children:P},P)):r("span",{className:"text-muted-foreground",children:"—"})})}),r("td",{className:"py-2",children:r("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full ${M.status==="running"?"bg-success/10 text-success":M.status==="error"?"bg-destructive/10 text-destructive":"bg-muted text-muted-foreground"}`,children:M.status})}),r("td",{className:"py-2",children:u("div",{className:"flex items-center gap-1 justify-end",children:[r("button",{onClick:()=>y(M.id),disabled:a===M.id||l===M.id,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:`Restart ${M.id}`,children:r(bt,{className:`h-3 w-3 ${a===M.id?"animate-spin":""}`})}),r("button",{onClick:()=>N(M.id),disabled:a===M.id||l===M.id,className:"p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50",title:`Uninstall ${M.id}`,children:l===M.id?r(Pe,{className:"h-3 w-3 animate-spin"}):r(We,{className:"h-3 w-3"})})]})})]},M.id))})]})]})}function W9(e){if(e<60)return`${e}s`;const t=Math.floor(e/60);if(t<60)return`${t}m`;const n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function Y9({state:e}){return r("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e==="running"?"bg-success/10 text-success":e==="crashed"?"bg-destructive/10 text-destructive":"bg-muted text-muted-foreground"}`,children:e})}const Z9=["trace","debug","info","warn","error"];function X9({proc:e,nodeId:t,defaultExpanded:n,activePanel:o,onTogglePanel:s}){const a=e.services??[],i=a.length===1,[l,c]=$(i||n),[d,f]=$(null),[p,m]=$("info"),h=e.name.includes("(core)"),g=aa(),b=Jg(),x=rb(),v=async N=>{f(N);try{await g.mutateAsync({nodeId:t,addonId:N})}catch(k){console.error("Failed to restart addon:",k)}finally{f(null)}},w=async()=>{f(e.name);try{await b.mutateAsync({nodeId:t,processName:e.name})}catch(N){console.error("Failed to restart process:",N)}finally{f(null)}},y=async N=>{const k=`${t}/${e.name}`;try{await x.mutateAsync({nodeId:k,level:N}),m(N)}catch(S){console.error("Failed to set log level:",S)}};return u("div",{className:"border border-border/50 rounded-lg overflow-hidden",children:[u("div",{role:i?void 0:"button",tabIndex:i?void 0:0,onClick:i?void 0:()=>c(!l),onKeyDown:i?void 0:N=>{(N.key==="Enter"||N.key===" ")&&c(!l)},className:`flex items-center gap-2 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${i?"":"hover:bg-muted/40 cursor-pointer"}`,children:[i?r("span",{className:"h-3 w-3 shrink-0"}):l?r(Rt,{className:"h-3 w-3 text-muted-foreground shrink-0"}):r(Mt,{className:"h-3 w-3 text-muted-foreground shrink-0"}),h?r(ln,{className:"h-3.5 w-3.5 text-primary shrink-0"}):r(ha,{className:"h-3.5 w-3.5 text-amber-500 shrink-0"}),r("span",{className:"text-xs font-semibold flex-1",children:e.name}),u("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:["PID ",e.pid]}),r(Y9,{state:e.state}),u("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[e.cpuPercent,"% CPU"]}),r("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:Nt(e.memoryRss)}),r("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:W9(e.uptimeSeconds)}),!h&&u("div",{className:"flex items-center gap-1",onClick:N=>N.stopPropagation(),children:[u(Gm,{children:[r(Wm,{className:"text-[9px] px-1.5 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors font-mono",title:"Set log level",children:p}),r(Ym,{align:"end",className:"min-w-[70px] py-0.5",children:Z9.map(N=>r(Zm,{onClick:()=>y(N),className:`h-auto px-2 py-1 text-[10px] font-mono ${N===p?"text-primary font-semibold":""}`,children:N},N))})]}),r("button",{onClick:w,disabled:d===e.name,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:"Restart process",children:r(bt,{className:`h-3 w-3 ${d===e.name?"animate-spin":""}`})})]})]}),l&&a.length>0&&r("div",{className:"divide-y divide-border/30",children:a.map(N=>u("div",{children:[u("div",{className:"flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors",children:[r("div",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${N.status==="running"?"bg-success":"bg-muted-foreground/30"}`}),r("span",{className:"text-xs font-medium flex-1 min-w-0 truncate",children:N.addonId}),N.capabilities.length>0&&u("div",{className:"flex gap-1 flex-shrink-0",children:[N.capabilities.slice(0,3).map(k=>r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400 truncate max-w-[80px]",children:k},k)),N.capabilities.length>3&&u("span",{className:"text-[9px] text-muted-foreground",children:["+",N.capabilities.length-3]})]}),u("div",{className:"flex items-center gap-1 shrink-0",children:[r("button",{onClick:()=>s(N.addonId,"logs"),className:`p-0.5 rounded transition-colors ${o?.addonId===N.addonId&&o.type==="logs"?"bg-primary/10 text-primary":"hover:bg-muted text-muted-foreground hover:text-foreground"}`,title:`Show logs for ${N.addonId}`,children:r(Xe,{className:"h-3 w-3"})}),r("button",{onClick:()=>s(N.addonId,"events"),className:`p-0.5 rounded transition-colors ${o?.addonId===N.addonId&&o.type==="events"?"bg-primary/10 text-primary":"hover:bg-muted text-muted-foreground hover:text-foreground"}`,title:`Show events for ${N.addonId}`,children:r(Zc,{className:"h-3 w-3"})}),r("button",{onClick:()=>v(N.addonId),disabled:d===N.addonId,className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:`Restart ${N.addonId}`,children:r(bt,{className:`h-3 w-3 ${d===N.addonId?"animate-spin":""}`})})]})]}),o?.addonId===N.addonId&&o.type==="logs"&&r("div",{className:"border-t border-border/40 bg-muted/5",children:r(Wt,{addonId:N.addonId,agentId:t,maxHeight:"max-h-48",showFilters:!1,onClose:()=>s(N.addonId,"logs")})}),o?.addonId===N.addonId&&o.type==="events"&&r("div",{className:"border-t border-border/40 bg-muted/5",children:r(nr,{addonId:N.addonId,category:"addon.*",maxHeight:"max-h-48",onClose:()=>s(N.addonId,"events")})})]},N.addonId))}),l&&a.length===0&&r("div",{className:"px-3 py-2 pl-9 text-[10px] text-muted-foreground",children:"No services"})]})}function J9({nodeId:e,processes:t}){const[n,o]=$(null),s=(a,i)=>{o(l=>l?.addonId===a&&l.type===i?null:{addonId:a,type:i})};return t.length===0?r("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No processes on this node"}):r("div",{className:"space-y-2 py-1",children:t.map((a,i)=>r(X9,{proc:a,nodeId:e,defaultExpanded:i===0,activePanel:n,onTogglePanel:s},a.name))})}function e7(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:`${Math.floor(e/86400)}d ${Math.floor(e%86400/3600)}h`}function t7(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function n7({nodeId:e}){const t=ke(),n=rt(),[o,s]=$("all"),a=Ar("metrics.node-processes-snapshot",k=>k.nodeId===e),{data:i}=Yg({nodeId:e},{staleTime:6e4}),l=a?.processes??i,c=Q(()=>l?[...l]:[],[l]),d=Q(()=>o==="ghost"?c.filter(k=>k.classification==="ghost"):c,[c,o]),f=Q(()=>{const k=c.filter(M=>M.classification==="ghost"),S=new Map;for(const M of k)S.has(M.ppid)||S.set(M.ppid,[]),S.get(M.ppid).push(M);return[...S.entries()].filter(([,M])=>M.length>1).map(([M,P])=>({ppid:M,children:P})).sort((M,P)=>P.children.length-M.children.length)},[c]),p=Zg({onSettled:()=>{t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]})}}),m=Q(()=>{const k=new Map;for(const S of c)k.set(S.pid,S.classification);return k},[c]),h=async(k,S)=>{if(k.classification==="root"||k.classification==="system")return;const M=k.classification==="ghost"?"ghost":k.addonId??"process",P=S?"SIGKILL":"SIGTERM";await n({title:`Send ${P}?`,message:`Target pid ${k.pid} (${M}) on node ${e}.`,confirmLabel:`Send ${P}`,variant:"danger"})&&p.mutate({nodeId:e,pid:k.pid,force:S})},g=async(k,S)=>{try{await p.mutateAsync({nodeId:e,pid:k,force:S})}catch{}},b=async k=>{const S=m.get(k.ppid);if(S==="root"||S==="system"){await n({title:"Cannot kill protected ancestor",message:S==="root"?`pid ${k.ppid} is the current node supervisor. Restart the node via the cluster page instead.`:`pid ${k.ppid} is a system ancestor (concurrently / vite / npm wrapper). Killing it would tear down the dev tree.`,confirmLabel:"OK",cancelLabel:"Close",variant:"warning"});return}await n({title:`Kill ghost parent + ${k.children.length} child(ren)?`,message:`SIGKILL parent pid ${k.ppid} and SIGTERM ${k.children.length} ghost child(ren) on node ${e}.`,confirmLabel:"Kill all",variant:"danger"})&&(await Promise.all([g(k.ppid,!0),...k.children.map(P=>g(P.pid,!1))]),t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]}))},x=async()=>{const k=c.filter(M=>M.classification==="ghost");k.length===0||!await n({title:`Kill all ${k.length} ghost process(es)?`,message:`SIGKILL ${k.length} ghost process(es) on node ${e}. This is irreversible.`,confirmLabel:"Kill all",variant:"danger"})||(await Promise.all(k.map(M=>g(M.pid,!0))),t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]}))},v=c.filter(k=>k.classification==="ghost").length,w=c.filter(k=>k.classification==="managed").length,y=c.filter(k=>k.classification==="root").length,N=c.filter(k=>k.classification==="system").length;return u("div",{className:"space-y-4",children:[u("div",{className:"flex items-start justify-between gap-4",children:[u("p",{className:"text-[11px] text-foreground-subtle",children:["ps"," scan + kernel `$process.list` cross-reference. Ghosts = camstack-shaped commands with no managed binding (usually orphaned to ppid=1). Refreshes every 10s."]}),u("button",{type:"button",onClick:()=>t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]}),className:"inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover",children:[r(pt,{className:"h-3 w-3"})," Refresh"]})]}),u("div",{className:"grid grid-cols-4 gap-3",children:[u("div",{className:"rounded-lg border border-border p-3",children:[r("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"Root"}),r("div",{className:"text-xl font-semibold text-foreground",children:y})]}),u("div",{className:"rounded-lg border border-border p-3",children:[r("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"Managed"}),r("div",{className:"text-xl font-semibold text-foreground",children:w})]}),u("div",{className:"rounded-lg border border-border p-3",children:[r("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"System"}),r("div",{className:"text-xl font-semibold text-foreground",children:N})]}),u("div",{className:`rounded-lg border p-3 ${v>0?"border-destructive/40 bg-destructive/5":"border-border"}`,children:[u("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle flex items-center gap-1",children:[v>0&&r(Uo,{className:"h-3 w-3 text-destructive"})," Ghosts"]}),r("div",{className:`text-xl font-semibold ${v>0?"text-destructive":"text-foreground"}`,children:v})]})]}),f.length>0&&u("div",{className:"rounded-lg border border-amber-500/40 bg-amber-500/5 p-3",children:[u("div",{className:"flex items-center gap-1 text-[11px] font-semibold text-amber-400 mb-2",children:[r(xt,{className:"h-3 w-3"})," Recurring ghost parents (",f.length,")"]}),r("div",{className:"space-y-1.5",children:f.map(k=>u("div",{className:"text-[11px] text-foreground flex items-center justify-between gap-2",children:[u("div",{className:"flex items-center gap-2",children:[u("span",{className:"font-mono text-foreground-subtle",children:["ppid ",k.ppid]}),u("span",{children:["→ ",k.children.length," ghost(s)"]})]}),u("button",{type:"button",disabled:p.isPending,onClick:()=>{b(k)},className:"inline-flex items-center gap-1 rounded border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] text-amber-400 hover:bg-amber-500/20 disabled:opacity-30",children:[r(Uo,{className:"h-3 w-3"})," Kill parent + ",k.children.length]})]},k.ppid))})]}),u("div",{className:"flex items-center justify-between gap-2 text-[11px]",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-foreground-subtle",children:"Filter:"}),u("button",{type:"button",className:`px-2 py-0.5 rounded ${o==="all"?"bg-primary text-primary-foreground":"border border-border text-foreground hover:bg-surface-hover"}`,onClick:()=>s("all"),children:["All (",c.length,")"]}),u("button",{type:"button",className:`px-2 py-0.5 rounded ${o==="ghost"?"bg-destructive text-destructive-foreground":"border border-border text-foreground hover:bg-surface-hover"}`,onClick:()=>s("ghost"),children:["Ghost only (",v,")"]})]}),v>0&&u("button",{type:"button",disabled:p.isPending,onClick:()=>{x()},className:"inline-flex items-center gap-1 rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive/20 disabled:opacity-30",children:[r(Uo,{className:"h-3 w-3"})," Kill all ",v," ghost(s)"]})]}),r("div",{className:"rounded-lg border border-border overflow-hidden",children:u("table",{className:"w-full text-xs",children:[r("thead",{className:"bg-surface",children:u("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[r("th",{className:"text-left px-3 py-2",children:"Class"}),r("th",{className:"text-right px-3 py-2",children:"PID"}),r("th",{className:"text-right px-3 py-2",children:"PPID"}),r("th",{className:"text-left px-3 py-2",children:"Addon"}),r("th",{className:"text-left px-3 py-2",children:"Command"}),r("th",{className:"text-right px-3 py-2",children:"CPU%"}),r("th",{className:"text-right px-3 py-2",children:"RSS"}),r("th",{className:"text-right px-3 py-2",children:"Uptime"}),r("th",{className:"w-44"})]})}),u("tbody",{children:[d.length===0&&r("tr",{children:r("td",{colSpan:9,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:o==="ghost"?"No ghost processes detected.":"Scanning…"})}),d.map(k=>u("tr",{className:`border-t border-border ${k.classification==="ghost"?"bg-destructive/5":""}`,children:[r("td",{className:"px-3 py-2",children:r("span",{className:`inline-block rounded-full px-1.5 py-0.5 text-[10px] font-medium ${k.classification==="ghost"?"bg-destructive/20 text-destructive":k.classification==="root"?"bg-sky-500/20 text-sky-400":k.classification==="system"?"bg-foreground-subtle/20 text-foreground-subtle":"bg-success/20 text-success"}`,children:k.classification})}),r("td",{className:"px-3 py-2 text-right font-mono text-foreground",children:k.pid}),u("td",{className:"px-3 py-2 text-right font-mono text-foreground-subtle",children:[k.ppid,k.orphaned?" ⚠":""]}),r("td",{className:"px-3 py-2 text-foreground-subtle text-[11px]",children:k.addonId??"—"}),r("td",{className:"px-3 py-2 font-mono text-[10px] text-foreground-subtle break-all",children:t7(k.command)}),r("td",{className:"px-3 py-2 text-right text-foreground",children:k.cpuPercent.toFixed(1)}),r("td",{className:"px-3 py-2 text-right text-foreground",children:Nt(k.memoryRssBytes)}),r("td",{className:"px-3 py-2 text-right text-foreground-subtle",children:e7(k.uptimeSec)}),r("td",{className:"px-3 py-2 text-right",children:u("div",{className:"inline-flex gap-1",children:[u("button",{type:"button",disabled:p.isPending||k.classification==="root"||k.classification==="system",onClick:()=>{h(k,!1)},title:"SIGTERM",className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-border text-[10px] text-foreground hover:bg-surface-hover disabled:opacity-30",children:[r(We,{className:"h-3 w-3"})," Term"]}),u("button",{type:"button",disabled:p.isPending||k.classification==="root"||k.classification==="system",onClick:()=>{h(k,!0)},title:"SIGKILL",className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-destructive/30 text-[10px] text-destructive hover:bg-destructive/10 disabled:opacity-30",children:[r(Uo,{className:"h-3 w-3"})," Kill"]})]})})]},k.pid))]})]})}),p.isError&&u("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive",children:["Kill failed: ",p.error instanceof Error?p.error.message:"unknown"]})]})}function r7({nodeId:e,addonIds:t}){return t.length===0?r("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No addons on this node"}):r("div",{className:"w-full py-2",children:r(Rr,{nodeId:e,addonIds:t,level:"global"})})}function o7({nodeId:e,addons:t}){const n=ke(),{data:o,isLoading:s}=hb({nodeId:e}),a=Q(()=>{const l=new Map;for(const c of t)for(const d of c.capabilities){const f=l.get(d)??[];f.push(c.id),l.set(d,f)}return[...l.entries()].sort(([c],[d])=>c.localeCompare(d)).map(([c,d])=>({capName:c,providers:d}))},[t]),i=gb({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCapabilityBindings"]]})}});return a.length===0?r("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No capabilities on this node"}):u("table",{className:"w-full text-xs",children:[r("thead",{children:u("tr",{className:"text-muted-foreground text-left",children:[r("th",{className:"py-2 font-medium w-1/2",children:"Capability"}),r("th",{className:"py-2 font-medium",children:"Bound provider"})]})}),r("tbody",{children:a.map(({capName:l,providers:c})=>{const f=o?.[l]??c[0]??"",p=c.length===1;return u("tr",{className:"border-t border-border/50",children:[r("td",{className:"py-2 font-medium",children:l}),r("td",{className:"py-2",children:r("select",{value:f,onChange:m=>i.mutate({nodeId:e,capName:l,addonId:m.target.value}),disabled:p||i.isPending||s,className:"w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-60",title:p?"Only one provider installed — choice becomes available once a second addon registers this capability":void 0,children:c.map(m=>r("option",{value:m,children:m},m))})})]},l)})})]})}function s7(e){if(e==null)return"—";const t=Math.floor(e/1e3),n=Math.floor(t/86400),o=Math.floor(t%86400/3600),s=Math.floor(t%3600/60);return n>0?`${n}d ${o}h ${s}m`:o>0?`${o}h ${s}m`:`${s}m`}function a7(e){const[t,n]=$(!1),[o,s]=$(e.name),a=ke(),i=tb({onSuccess:()=>{a.invalidateQueries({queryKey:[["nodes","topology"]]})}}),l=(e.localIps??[]).filter(p=>!p.includes(":")),c=(e.localIps??[]).filter(p=>p.includes(":")),d=async()=>{if(!o.trim()||o===e.name){n(!1);return}try{await i.mutateAsync({nodeId:e.nodeId,name:o.trim()}),n(!1)}catch(p){console.error("Rename failed:",p)}},f=[["Node ID",r("span",{className:"font-mono text-xs",children:e.nodeId})],["Display Name",t?u("div",{className:"flex items-center gap-1.5",children:[r("input",{type:"text",className:"flex-1 px-2 py-0.5 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary",value:o,onChange:p=>s(p.target.value),onKeyDown:p=>{p.key==="Enter"&&d(),p.key==="Escape"&&n(!1)},disabled:i.isPending,autoFocus:!0}),r("button",{onClick:()=>void d(),disabled:i.isPending,className:"p-0.5 text-success hover:bg-success/10 rounded",title:"Save",children:r(Ct,{className:"h-3.5 w-3.5"})}),r("button",{onClick:()=>n(!1),className:"p-0.5 text-muted-foreground hover:bg-muted rounded",title:"Cancel",children:r(qe,{className:"h-3.5 w-3.5"})})]}):u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"text-xs",children:e.name}),!e.isHub&&r("button",{onClick:()=>{s(e.name),n(!0)},className:"p-0.5 text-muted-foreground hover:text-primary rounded",title:"Rename",children:r(Po,{className:"h-3 w-3"})})]})],["Hostname",r("span",{className:"text-xs",children:e.hostname})],["Role",e.isHub?r("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium",children:"Hub"}):r("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium",children:"Agent"})],["Platform",u("span",{className:"text-xs",children:[e.platform," / ",e.arch]})],["CPU",u("span",{className:"text-xs",children:[e.cpuModel??"—"," (",e.cpuCores," cores)"]})],["Memory",r("span",{className:"text-xs",children:e.memoryMB>0?`${(e.memoryMB/1024).toFixed(1)} GB`:"—"})],["Uptime",r("span",{className:"text-xs",children:s7(e.uptime)})],["Engines",e.engines.length>0?r("div",{className:"flex flex-wrap gap-1",children:e.engines.map(p=>r("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:p},p))}):r("span",{className:"text-xs text-muted-foreground",children:"—"})]];return l.length>0&&f.push(["IPv4",r("div",{className:"flex flex-wrap gap-1.5",children:l.map((p,m)=>r("span",{className:"font-mono text-xs px-1.5 py-0.5 rounded bg-muted",children:p},`${p}-${m}`))})]),c.length>0&&f.push(["IPv6",r("div",{className:"flex flex-wrap gap-1.5",children:c.map((p,m)=>r("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]",title:p,children:p},`${p}-${m}`))})]),r("div",{className:"py-2",children:r("table",{className:"w-full text-sm",children:r("tbody",{children:f.map(([p,m],h)=>u("tr",{className:h%2===0?"bg-muted/20":"",children:[r("td",{className:"py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap",children:p}),r("td",{className:"py-1.5 px-2",children:m})]},p))})})})}function i7({node:e}){const[t,n]=$("info"),o=e.processes??[],s=e.addons.map(a=>a.id);return e.isOnline?u("div",{className:"border border-border rounded-xl overflow-hidden",children:[u("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/30 border-b border-border",children:[r("div",{className:"w-2.5 h-2.5 rounded-full bg-success"}),r("span",{className:"text-sm font-semibold",children:e.name}),u("span",{className:"text-xs text-muted-foreground",children:[e.cpuModel??e.platform," · ",e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:""," · ",e.arch]}),e.engines.map(a=>r("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:a},a)),u("div",{className:"ml-auto flex gap-3 text-xs text-muted-foreground",children:[u("span",{className:"flex items-center gap-1",children:[r(ut,{className:"h-3 w-3"})," ",e.cpuPercent,"%"]}),u("span",{className:"flex items-center gap-1",children:[r(Gc,{className:"h-3 w-3"})," ",e.memoryPercent,"%"]})]})]}),r("div",{className:"flex border-b border-border px-4",children:["info","addons","forks","processes","settings","capabilities"].map(a=>r("button",{onClick:()=>n(a),className:`px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===a?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:a==="info"?"Info":a==="addons"?`Addons (${e.addons.length})`:a==="forks"?`Forks (${o.length})`:a==="processes"?"Processes":a==="settings"?"Settings":"Capabilities"},a))}),u("div",{className:"px-4 py-2",children:[t==="info"&&r(a7,{nodeId:e.id,name:e.name,hostname:e.hostname,platform:e.platform,arch:e.arch,cpuModel:e.cpuModel,cpuCores:e.cpuCores,memoryMB:e.memoryMB,engines:e.engines,isHub:e.isHub,uptime:e.uptime,localIps:e.localIps}),t==="addons"&&r(G9,{nodeId:e.id,addons:e.addons,isHub:e.isHub}),t==="forks"&&r(J9,{nodeId:e.id,processes:o}),t==="processes"&&r(n7,{nodeId:e.id}),t==="settings"&&r(r7,{nodeId:e.id,addonIds:s}),t==="capabilities"&&r(o7,{nodeId:e.id,addons:e.addons})]})]}):u("div",{className:"border border-border rounded-xl overflow-hidden opacity-60",children:[u("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/30",children:[r("div",{className:"w-2.5 h-2.5 rounded-full bg-destructive"}),r("span",{className:"text-sm font-semibold",children:e.name}),u("span",{className:"text-xs text-muted-foreground",children:[e.cpuModel??e.platform," · ",e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:""," · ",e.arch]}),e.engines.map(a=>r("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:a},a)),r("span",{className:"ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:"offline"})]}),u("div",{className:"px-4 py-3 text-xs text-muted-foreground",children:[e.addons.length," addon",e.addons.length!==1?"s":""," assigned — will resume when node reconnects"]})]})}function l7({nodes:e}){const t=[...e].sort((n,o)=>n.isHub?-1:o.isHub?1:n.isOnline&&!o.isOnline?-1:!n.isOnline&&o.isOnline?1:n.name.localeCompare(o.name));return r("div",{className:"flex flex-col gap-4",children:t.map(n=>r(i7,{node:n},n.id))})}function Ue(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=Ue(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var c7={value:()=>{}};function Sa(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new gs(n)}function gs(e){this._=e}function d7(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",s=n.indexOf(".");if(s>=0&&(o=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}gs.prototype=Sa.prototype={constructor:gs,on:function(e,t){var n=this._,o=d7(e+"",n),s,a=-1,i=o.length;if(arguments.length<2){for(;++a<i;)if((s=(e=o[a]).type)&&(s=u7(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++a<i;)if(s=(e=o[a]).type)n[s]=kp(n[s],e.name,t);else if(t==null)for(s in n)n[s]=kp(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new gs(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),o=0,s,a;o<s;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],o=0,s=a.length;o<s;++o)a[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],s=0,a=o.length;s<a;++s)o[s].value.apply(t,n)}};function u7(e,t){for(var n=0,o=e.length,s;n<o;++n)if((s=e[n]).name===t)return s.value}function kp(e,t,n){for(var o=0,s=e.length;o<s;++o)if(e[o].name===t){e[o]=c7,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var pl="http://www.w3.org/1999/xhtml";const Sp={svg:"http://www.w3.org/2000/svg",xhtml:pl,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ca(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Sp.hasOwnProperty(t)?{space:Sp[t],local:e}:e}function p7(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===pl&&t.documentElement.namespaceURI===pl?t.createElement(e):t.createElementNS(n,e)}}function f7(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function a0(e){var t=Ca(e);return(t.local?f7:p7)(t)}function m7(){}function rd(e){return e==null?m7:function(){return this.querySelector(e)}}function h7(e){typeof e!="function"&&(e=rd(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=o[s]=new Array(i),c,d,f=0;f<i;++f)(c=a[f])&&(d=e.call(c,c.__data__,f,a))&&("__data__"in c&&(d.__data__=c.__data__),l[f]=d);return new ft(o,this._parents)}function g7(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function b7(){return[]}function i0(e){return e==null?b7:function(){return this.querySelectorAll(e)}}function x7(e){return function(){return g7(e.apply(this,arguments))}}function y7(e){typeof e=="function"?e=x7(e):e=i0(e);for(var t=this._groups,n=t.length,o=[],s=[],a=0;a<n;++a)for(var i=t[a],l=i.length,c,d=0;d<l;++d)(c=i[d])&&(o.push(e.call(c,c.__data__,d,i)),s.push(c));return new ft(o,s)}function l0(e){return function(){return this.matches(e)}}function c0(e){return function(t){return t.matches(e)}}var v7=Array.prototype.find;function w7(e){return function(){return v7.call(this.children,e)}}function N7(){return this.firstElementChild}function k7(e){return this.select(e==null?N7:w7(typeof e=="function"?e:c0(e)))}var S7=Array.prototype.filter;function C7(){return Array.from(this.children)}function M7(e){return function(){return S7.call(this.children,e)}}function I7(e){return this.selectAll(e==null?C7:M7(typeof e=="function"?e:c0(e)))}function A7(e){typeof e!="function"&&(e=l0(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=o[s]=[],c,d=0;d<i;++d)(c=a[d])&&e.call(c,c.__data__,d,a)&&l.push(c);return new ft(o,this._parents)}function d0(e){return new Array(e.length)}function P7(){return new ft(this._enter||this._groups.map(d0),this._parents)}function Os(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Os.prototype={constructor:Os,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function E7(e){return function(){return e}}function $7(e,t,n,o,s,a){for(var i=0,l,c=t.length,d=a.length;i<d;++i)(l=t[i])?(l.__data__=a[i],o[i]=l):n[i]=new Os(e,a[i]);for(;i<c;++i)(l=t[i])&&(s[i]=l)}function _7(e,t,n,o,s,a,i){var l,c,d=new Map,f=t.length,p=a.length,m=new Array(f),h;for(l=0;l<f;++l)(c=t[l])&&(m[l]=h=i.call(c,c.__data__,l,t)+"",d.has(h)?s[l]=c:d.set(h,c));for(l=0;l<p;++l)h=i.call(e,a[l],l,a)+"",(c=d.get(h))?(o[l]=c,c.__data__=a[l],d.delete(h)):n[l]=new Os(e,a[l]);for(l=0;l<f;++l)(c=t[l])&&d.get(m[l])===c&&(s[l]=c)}function D7(e){return e.__data__}function L7(e,t){if(!arguments.length)return Array.from(this,D7);var n=t?_7:$7,o=this._parents,s=this._groups;typeof e!="function"&&(e=E7(e));for(var a=s.length,i=new Array(a),l=new Array(a),c=new Array(a),d=0;d<a;++d){var f=o[d],p=s[d],m=p.length,h=T7(e.call(f,f&&f.__data__,d,o)),g=h.length,b=l[d]=new Array(g),x=i[d]=new Array(g),v=c[d]=new Array(m);n(f,p,b,x,v,h,t);for(var w=0,y=0,N,k;w<g;++w)if(N=b[w]){for(w>=y&&(y=w+1);!(k=x[y])&&++y<g;);N._next=k||null}}return i=new ft(i,o),i._enter=l,i._exit=c,i}function T7(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function R7(){return new ft(this._exit||this._groups.map(d0),this._parents)}function O7(e,t,n){var o=this.enter(),s=this,a=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?a.remove():n(a),o&&s?o.merge(s).order():s}function z7(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,s=n.length,a=o.length,i=Math.min(s,a),l=new Array(s),c=0;c<i;++c)for(var d=n[c],f=o[c],p=d.length,m=l[c]=new Array(p),h,g=0;g<p;++g)(h=d[g]||f[g])&&(m[g]=h);for(;c<s;++c)l[c]=n[c];return new ft(l,this._parents)}function B7(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],s=o.length-1,a=o[s],i;--s>=0;)(i=o[s])&&(a&&i.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(i,a),a=i);return this}function F7(e){e||(e=j7);function t(p,m){return p&&m?e(p.__data__,m.__data__):!p-!m}for(var n=this._groups,o=n.length,s=new Array(o),a=0;a<o;++a){for(var i=n[a],l=i.length,c=s[a]=new Array(l),d,f=0;f<l;++f)(d=i[f])&&(c[f]=d);c.sort(t)}return new ft(s,this._parents).order()}function j7(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function H7(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function V7(){return Array.from(this)}function q7(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],s=0,a=o.length;s<a;++s){var i=o[s];if(i)return i}return null}function Q7(){let e=0;for(const t of this)++e;return e}function U7(){return!this.node()}function K7(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var s=t[n],a=0,i=s.length,l;a<i;++a)(l=s[a])&&e.call(l,l.__data__,a,s);return this}function G7(e){return function(){this.removeAttribute(e)}}function W7(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Y7(e,t){return function(){this.setAttribute(e,t)}}function Z7(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function X7(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function J7(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function ez(e,t){var n=Ca(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?W7:G7:typeof t=="function"?n.local?J7:X7:n.local?Z7:Y7)(n,t))}function u0(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function tz(e){return function(){this.style.removeProperty(e)}}function nz(e,t,n){return function(){this.style.setProperty(e,t,n)}}function rz(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function oz(e,t,n){return arguments.length>1?this.each((t==null?tz:typeof t=="function"?rz:nz)(e,t,n??"")):vr(this.node(),e)}function vr(e,t){return e.style.getPropertyValue(t)||u0(e).getComputedStyle(e,null).getPropertyValue(t)}function sz(e){return function(){delete this[e]}}function az(e,t){return function(){this[e]=t}}function iz(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function lz(e,t){return arguments.length>1?this.each((t==null?sz:typeof t=="function"?iz:az)(e,t)):this.node()[e]}function p0(e){return e.trim().split(/^|\s+/)}function od(e){return e.classList||new f0(e)}function f0(e){this._node=e,this._names=p0(e.getAttribute("class")||"")}f0.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function m0(e,t){for(var n=od(e),o=-1,s=t.length;++o<s;)n.add(t[o])}function h0(e,t){for(var n=od(e),o=-1,s=t.length;++o<s;)n.remove(t[o])}function cz(e){return function(){m0(this,e)}}function dz(e){return function(){h0(this,e)}}function uz(e,t){return function(){(t.apply(this,arguments)?m0:h0)(this,e)}}function pz(e,t){var n=p0(e+"");if(arguments.length<2){for(var o=od(this.node()),s=-1,a=n.length;++s<a;)if(!o.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?uz:t?cz:dz)(n,t))}function fz(){this.textContent=""}function mz(e){return function(){this.textContent=e}}function hz(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function gz(e){return arguments.length?this.each(e==null?fz:(typeof e=="function"?hz:mz)(e)):this.node().textContent}function bz(){this.innerHTML=""}function xz(e){return function(){this.innerHTML=e}}function yz(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function vz(e){return arguments.length?this.each(e==null?bz:(typeof e=="function"?yz:xz)(e)):this.node().innerHTML}function wz(){this.nextSibling&&this.parentNode.appendChild(this)}function Nz(){return this.each(wz)}function kz(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Sz(){return this.each(kz)}function Cz(e){var t=typeof e=="function"?e:a0(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Mz(){return null}function Iz(e,t){var n=typeof e=="function"?e:a0(e),o=t==null?Mz:typeof t=="function"?t:rd(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Az(){var e=this.parentNode;e&&e.removeChild(this)}function Pz(){return this.each(Az)}function Ez(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function $z(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function _z(e){return this.select(e?$z:Ez)}function Dz(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Lz(e){return function(t){e.call(this,t,this.__data__)}}function Tz(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Rz(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,s=t.length,a;n<s;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++o]=a;++o?t.length=o:delete this.__on}}}function Oz(e,t,n){return function(){var o=this.__on,s,a=Lz(t);if(o){for(var i=0,l=o.length;i<l;++i)if((s=o[i]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=a,s.options=n),s.value=t;return}}this.addEventListener(e.type,a,n),s={type:e.type,name:e.name,value:t,listener:a,options:n},o?o.push(s):this.__on=[s]}}function zz(e,t,n){var o=Tz(e+""),s,a=o.length,i;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,d=l.length,f;c<d;++c)for(s=0,f=l[c];s<a;++s)if((i=o[s]).type===f.type&&i.name===f.name)return f.value}return}for(l=t?Oz:Rz,s=0;s<a;++s)this.each(l(o[s],t,n));return this}function g0(e,t,n){var o=u0(e),s=o.CustomEvent;typeof s=="function"?s=new s(t,n):(s=o.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function Bz(e,t){return function(){return g0(this,e,t)}}function Fz(e,t){return function(){return g0(this,e,t.apply(this,arguments))}}function jz(e,t){return this.each((typeof t=="function"?Fz:Bz)(e,t))}function*Hz(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],s=0,a=o.length,i;s<a;++s)(i=o[s])&&(yield i)}var b0=[null];function ft(e,t){this._groups=e,this._parents=t}function Eo(){return new ft([[document.documentElement]],b0)}function Vz(){return this}ft.prototype=Eo.prototype={constructor:ft,select:h7,selectAll:y7,selectChild:k7,selectChildren:I7,filter:A7,data:L7,enter:P7,exit:R7,join:O7,merge:z7,selection:Vz,order:B7,sort:F7,call:H7,nodes:V7,node:q7,size:Q7,empty:U7,each:K7,attr:ez,style:oz,property:lz,classed:pz,text:gz,html:vz,raise:Nz,lower:Sz,append:Cz,insert:Iz,remove:Pz,clone:_z,datum:Dz,on:zz,dispatch:jz,[Symbol.iterator]:Hz};function lt(e){return typeof e=="string"?new ft([[document.querySelector(e)]],[document.documentElement]):new ft([[e]],b0)}function qz(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Pt(e,t){if(e=qz(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const Qz={passive:!1},uo={capture:!0,passive:!1};function Ni(e){e.stopImmediatePropagation()}function ur(e){e.preventDefault(),e.stopImmediatePropagation()}function x0(e){var t=e.document.documentElement,n=lt(e).on("dragstart.drag",ur,uo);"onselectstart"in t?n.on("selectstart.drag",ur,uo):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function y0(e,t){var n=e.document.documentElement,o=lt(e).on("dragstart.drag",null);t&&(o.on("click.drag",ur,uo),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const ns=e=>()=>e;function fl(e,{sourceEvent:t,subject:n,target:o,identifier:s,active:a,x:i,y:l,dx:c,dy:d,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:f}})}fl.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Uz(e){return!e.ctrlKey&&!e.button}function Kz(){return this.parentNode}function Gz(e,t){return t??{x:e.x,y:e.y}}function Wz(){return navigator.maxTouchPoints||"ontouchstart"in this}function v0(){var e=Uz,t=Kz,n=Gz,o=Wz,s={},a=Sa("start","drag","end"),i=0,l,c,d,f,p=0;function m(N){N.on("mousedown.drag",h).filter(o).on("touchstart.drag",x).on("touchmove.drag",v,Qz).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(N,k){if(!(f||!e.call(this,N,k))){var S=y(this,t.call(this,N,k),N,k,"mouse");S&&(lt(N.view).on("mousemove.drag",g,uo).on("mouseup.drag",b,uo),x0(N.view),Ni(N),d=!1,l=N.clientX,c=N.clientY,S("start",N))}}function g(N){if(ur(N),!d){var k=N.clientX-l,S=N.clientY-c;d=k*k+S*S>p}s.mouse("drag",N)}function b(N){lt(N.view).on("mousemove.drag mouseup.drag",null),y0(N.view,d),ur(N),s.mouse("end",N)}function x(N,k){if(e.call(this,N,k)){var S=N.changedTouches,M=t.call(this,N,k),P=S.length,I,F;for(I=0;I<P;++I)(F=y(this,M,N,k,S[I].identifier,S[I]))&&(Ni(N),F("start",N,S[I]))}}function v(N){var k=N.changedTouches,S=k.length,M,P;for(M=0;M<S;++M)(P=s[k[M].identifier])&&(ur(N),P("drag",N,k[M]))}function w(N){var k=N.changedTouches,S=k.length,M,P;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),M=0;M<S;++M)(P=s[k[M].identifier])&&(Ni(N),P("end",N,k[M]))}function y(N,k,S,M,P,I){var F=a.copy(),E=Pt(I||S,k),B,O,A;if((A=n.call(N,new fl("beforestart",{sourceEvent:S,target:m,identifier:P,active:i,x:E[0],y:E[1],dx:0,dy:0,dispatch:F}),M))!=null)return B=A.x-E[0]||0,O=A.y-E[1]||0,function D(_,R,L){var z=E,j;switch(_){case"start":s[P]=D,j=i++;break;case"end":delete s[P],--i;case"drag":E=Pt(L||R,k),j=i;break}F.call(_,N,new fl(_,{sourceEvent:R,subject:A,target:m,identifier:P,active:j,x:E[0]+B,y:E[1]+O,dx:E[0]-z[0],dy:E[1]-z[1],dispatch:F}),M)}}return m.filter=function(N){return arguments.length?(e=typeof N=="function"?N:ns(!!N),m):e},m.container=function(N){return arguments.length?(t=typeof N=="function"?N:ns(N),m):t},m.subject=function(N){return arguments.length?(n=typeof N=="function"?N:ns(N),m):n},m.touchable=function(N){return arguments.length?(o=typeof N=="function"?N:ns(!!N),m):o},m.on=function(){var N=a.on.apply(a,arguments);return N===a?m:N},m.clickDistance=function(N){return arguments.length?(p=(N=+N)*N,m):Math.sqrt(p)},m}function sd(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function w0(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function $o(){}var po=.7,zs=1/po,pr="\\s*([+-]?\\d+)\\s*",fo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ut="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Yz=/^#([0-9a-f]{3,8})$/,Zz=new RegExp(`^rgb\\(${pr},${pr},${pr}\\)$`),Xz=new RegExp(`^rgb\\(${Ut},${Ut},${Ut}\\)$`),Jz=new RegExp(`^rgba\\(${pr},${pr},${pr},${fo}\\)$`),eB=new RegExp(`^rgba\\(${Ut},${Ut},${Ut},${fo}\\)$`),tB=new RegExp(`^hsl\\(${fo},${Ut},${Ut}\\)$`),nB=new RegExp(`^hsla\\(${fo},${Ut},${Ut},${fo}\\)$`),Cp={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};sd($o,Vn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Mp,formatHex:Mp,formatHex8:rB,formatHsl:oB,formatRgb:Ip,toString:Ip});function Mp(){return this.rgb().formatHex()}function rB(){return this.rgb().formatHex8()}function oB(){return N0(this).formatHsl()}function Ip(){return this.rgb().formatRgb()}function Vn(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Yz.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Ap(t):n===3?new nt(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?rs(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?rs(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Zz.exec(e))?new nt(t[1],t[2],t[3],1):(t=Xz.exec(e))?new nt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Jz.exec(e))?rs(t[1],t[2],t[3],t[4]):(t=eB.exec(e))?rs(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=tB.exec(e))?$p(t[1],t[2]/100,t[3]/100,1):(t=nB.exec(e))?$p(t[1],t[2]/100,t[3]/100,t[4]):Cp.hasOwnProperty(e)?Ap(Cp[e]):e==="transparent"?new nt(NaN,NaN,NaN,0):null}function Ap(e){return new nt(e>>16&255,e>>8&255,e&255,1)}function rs(e,t,n,o){return o<=0&&(e=t=n=NaN),new nt(e,t,n,o)}function sB(e){return e instanceof $o||(e=Vn(e)),e?(e=e.rgb(),new nt(e.r,e.g,e.b,e.opacity)):new nt}function ml(e,t,n,o){return arguments.length===1?sB(e):new nt(e,t,n,o??1)}function nt(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}sd(nt,ml,w0($o,{brighter(e){return e=e==null?zs:Math.pow(zs,e),new nt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?po:Math.pow(po,e),new nt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new nt(zn(this.r),zn(this.g),zn(this.b),Bs(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Pp,formatHex:Pp,formatHex8:aB,formatRgb:Ep,toString:Ep}));function Pp(){return`#${Tn(this.r)}${Tn(this.g)}${Tn(this.b)}`}function aB(){return`#${Tn(this.r)}${Tn(this.g)}${Tn(this.b)}${Tn((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ep(){const e=Bs(this.opacity);return`${e===1?"rgb(":"rgba("}${zn(this.r)}, ${zn(this.g)}, ${zn(this.b)}${e===1?")":`, ${e})`}`}function Bs(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function zn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Tn(e){return e=zn(e),(e<16?"0":"")+e.toString(16)}function $p(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Et(e,t,n,o)}function N0(e){if(e instanceof Et)return new Et(e.h,e.s,e.l,e.opacity);if(e instanceof $o||(e=Vn(e)),!e)return new Et;if(e instanceof Et)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,s=Math.min(t,n,o),a=Math.max(t,n,o),i=NaN,l=a-s,c=(a+s)/2;return l?(t===a?i=(n-o)/l+(n<o)*6:n===a?i=(o-t)/l+2:i=(t-n)/l+4,l/=c<.5?a+s:2-a-s,i*=60):l=c>0&&c<1?0:i,new Et(i,l,c,e.opacity)}function iB(e,t,n,o){return arguments.length===1?N0(e):new Et(e,t,n,o??1)}function Et(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}sd(Et,iB,w0($o,{brighter(e){return e=e==null?zs:Math.pow(zs,e),new Et(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?po:Math.pow(po,e),new Et(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,s=2*n-o;return new nt(ki(e>=240?e-240:e+120,s,o),ki(e,s,o),ki(e<120?e+240:e-120,s,o),this.opacity)},clamp(){return new Et(_p(this.h),os(this.s),os(this.l),Bs(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Bs(this.opacity);return`${e===1?"hsl(":"hsla("}${_p(this.h)}, ${os(this.s)*100}%, ${os(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _p(e){return e=(e||0)%360,e<0?e+360:e}function os(e){return Math.max(0,Math.min(1,e||0))}function ki(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const ad=e=>()=>e;function lB(e,t){return function(n){return e+n*t}}function cB(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function dB(e){return(e=+e)==1?k0:function(t,n){return n-t?cB(t,n,e):ad(isNaN(t)?n:t)}}function k0(e,t){var n=t-e;return n?lB(e,n):ad(isNaN(e)?t:e)}const Fs=(function e(t){var n=dB(t);function o(s,a){var i=n((s=ml(s)).r,(a=ml(a)).r),l=n(s.g,a.g),c=n(s.b,a.b),d=k0(s.opacity,a.opacity);return function(f){return s.r=i(f),s.g=l(f),s.b=c(f),s.opacity=d(f),s+""}}return o.gamma=e,o})(1);function uB(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),s;return function(a){for(s=0;s<n;++s)o[s]=e[s]*(1-a)+t[s]*a;return o}}function pB(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function fB(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,s=new Array(o),a=new Array(n),i;for(i=0;i<o;++i)s[i]=no(e[i],t[i]);for(;i<n;++i)a[i]=t[i];return function(l){for(i=0;i<o;++i)a[i]=s[i](l);return a}}function mB(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function Vt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function hB(e,t){var n={},o={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=no(e[s],t[s]):o[s]=t[s];return function(a){for(s in n)o[s]=n[s](a);return o}}var hl=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Si=new RegExp(hl.source,"g");function gB(e){return function(){return e}}function bB(e){return function(t){return e(t)+""}}function S0(e,t){var n=hl.lastIndex=Si.lastIndex=0,o,s,a,i=-1,l=[],c=[];for(e=e+"",t=t+"";(o=hl.exec(e))&&(s=Si.exec(t));)(a=s.index)>n&&(a=t.slice(n,a),l[i]?l[i]+=a:l[++i]=a),(o=o[0])===(s=s[0])?l[i]?l[i]+=s:l[++i]=s:(l[++i]=null,c.push({i,x:Vt(o,s)})),n=Si.lastIndex;return n<t.length&&(a=t.slice(n),l[i]?l[i]+=a:l[++i]=a),l.length<2?c[0]?bB(c[0].x):gB(t):(t=c.length,function(d){for(var f=0,p;f<t;++f)l[(p=c[f]).i]=p.x(d);return l.join("")})}function no(e,t){var n=typeof t,o;return t==null||n==="boolean"?ad(t):(n==="number"?Vt:n==="string"?(o=Vn(t))?(t=o,Fs):S0:t instanceof Vn?Fs:t instanceof Date?mB:pB(t)?uB:Array.isArray(t)?fB:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?hB:Vt)(e,t)}var Dp=180/Math.PI,gl={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function C0(e,t,n,o,s,a){var i,l,c;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(c=e*n+t*o)&&(n-=e*c,o-=t*c),(l=Math.sqrt(n*n+o*o))&&(n/=l,o/=l,c/=l),e*o<t*n&&(e=-e,t=-t,c=-c,i=-i),{translateX:s,translateY:a,rotate:Math.atan2(t,e)*Dp,skewX:Math.atan(c)*Dp,scaleX:i,scaleY:l}}var ss;function xB(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?gl:C0(t.a,t.b,t.c,t.d,t.e,t.f)}function yB(e){return e==null||(ss||(ss=document.createElementNS("http://www.w3.org/2000/svg","g")),ss.setAttribute("transform",e),!(e=ss.transform.baseVal.consolidate()))?gl:(e=e.matrix,C0(e.a,e.b,e.c,e.d,e.e,e.f))}function M0(e,t,n,o){function s(d){return d.length?d.pop()+" ":""}function a(d,f,p,m,h,g){if(d!==p||f!==m){var b=h.push("translate(",null,t,null,n);g.push({i:b-4,x:Vt(d,p)},{i:b-2,x:Vt(f,m)})}else(p||m)&&h.push("translate("+p+t+m+n)}function i(d,f,p,m){d!==f?(d-f>180?f+=360:f-d>180&&(d+=360),m.push({i:p.push(s(p)+"rotate(",null,o)-2,x:Vt(d,f)})):f&&p.push(s(p)+"rotate("+f+o)}function l(d,f,p,m){d!==f?m.push({i:p.push(s(p)+"skewX(",null,o)-2,x:Vt(d,f)}):f&&p.push(s(p)+"skewX("+f+o)}function c(d,f,p,m,h,g){if(d!==p||f!==m){var b=h.push(s(h)+"scale(",null,",",null,")");g.push({i:b-4,x:Vt(d,p)},{i:b-2,x:Vt(f,m)})}else(p!==1||m!==1)&&h.push(s(h)+"scale("+p+","+m+")")}return function(d,f){var p=[],m=[];return d=e(d),f=e(f),a(d.translateX,d.translateY,f.translateX,f.translateY,p,m),i(d.rotate,f.rotate,p,m),l(d.skewX,f.skewX,p,m),c(d.scaleX,d.scaleY,f.scaleX,f.scaleY,p,m),d=f=null,function(h){for(var g=-1,b=m.length,x;++g<b;)p[(x=m[g]).i]=x.x(h);return p.join("")}}}var vB=M0(xB,"px, ","px)","deg)"),wB=M0(yB,", ",")",")"),NB=1e-12;function Lp(e){return((e=Math.exp(e))+1/e)/2}function kB(e){return((e=Math.exp(e))-1/e)/2}function SB(e){return((e=Math.exp(2*e))-1)/(e+1)}const bs=(function e(t,n,o){function s(a,i){var l=a[0],c=a[1],d=a[2],f=i[0],p=i[1],m=i[2],h=f-l,g=p-c,b=h*h+g*g,x,v;if(b<NB)v=Math.log(m/d)/t,x=function(M){return[l+M*h,c+M*g,d*Math.exp(t*M*v)]};else{var w=Math.sqrt(b),y=(m*m-d*d+o*b)/(2*d*n*w),N=(m*m-d*d-o*b)/(2*m*n*w),k=Math.log(Math.sqrt(y*y+1)-y),S=Math.log(Math.sqrt(N*N+1)-N);v=(S-k)/t,x=function(M){var P=M*v,I=Lp(k),F=d/(n*w)*(I*SB(t*P+k)-kB(k));return[l+F*h,c+F*g,d*I/Lp(t*P+k)]}}return x.duration=v*1e3*t/Math.SQRT2,x}return s.rho=function(a){var i=Math.max(.001,+a),l=i*i,c=l*l;return e(i,l,c)},s})(Math.SQRT2,2,4);var wr=0,Kr=0,Vr=0,I0=1e3,js,Gr,Hs=0,qn=0,Ma=0,mo=typeof performance=="object"&&performance.now?performance:Date,A0=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function id(){return qn||(A0(CB),qn=mo.now()+Ma)}function CB(){qn=0}function Vs(){this._call=this._time=this._next=null}Vs.prototype=P0.prototype={constructor:Vs,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?id():+n)+(t==null?0:+t),!this._next&&Gr!==this&&(Gr?Gr._next=this:js=this,Gr=this),this._call=e,this._time=n,bl()},stop:function(){this._call&&(this._call=null,this._time=1/0,bl())}};function P0(e,t,n){var o=new Vs;return o.restart(e,t,n),o}function MB(){id(),++wr;for(var e=js,t;e;)(t=qn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--wr}function Tp(){qn=(Hs=mo.now())+Ma,wr=Kr=0;try{MB()}finally{wr=0,AB(),qn=0}}function IB(){var e=mo.now(),t=e-Hs;t>I0&&(Ma-=t,Hs=e)}function AB(){for(var e,t=js,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:js=n);Gr=e,bl(o)}function bl(e){if(!wr){Kr&&(Kr=clearTimeout(Kr));var t=e-qn;t>24?(e<1/0&&(Kr=setTimeout(Tp,e-mo.now()-Ma)),Vr&&(Vr=clearInterval(Vr))):(Vr||(Hs=mo.now(),Vr=setInterval(IB,I0)),wr=1,A0(Tp))}}function Rp(e,t,n){var o=new Vs;return t=t==null?0:+t,o.restart(s=>{o.stop(),e(s+t)},t,n),o}var PB=Sa("start","end","cancel","interrupt"),EB=[],E0=0,Op=1,xl=2,xs=3,zp=4,yl=5,ys=6;function Ia(e,t,n,o,s,a){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;$B(e,n,{name:t,index:o,group:s,on:PB,tween:EB,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:E0})}function ld(e,t){var n=Bt(e,t);if(n.state>E0)throw new Error("too late; already scheduled");return n}function Yt(e,t){var n=Bt(e,t);if(n.state>xs)throw new Error("too late; already running");return n}function Bt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function $B(e,t,n){var o=e.__transition,s;o[t]=n,n.timer=P0(a,0,n.time);function a(d){n.state=Op,n.timer.restart(i,n.delay,n.time),n.delay<=d&&i(d-n.delay)}function i(d){var f,p,m,h;if(n.state!==Op)return c();for(f in o)if(h=o[f],h.name===n.name){if(h.state===xs)return Rp(i);h.state===zp?(h.state=ys,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[f]):+f<t&&(h.state=ys,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[f])}if(Rp(function(){n.state===xs&&(n.state=zp,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=xl,n.on.call("start",e,e.__data__,n.index,n.group),n.state===xl){for(n.state=xs,s=new Array(m=n.tween.length),f=0,p=-1;f<m;++f)(h=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(s[++p]=h);s.length=p+1}}function l(d){for(var f=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(c),n.state=yl,1),p=-1,m=s.length;++p<m;)s[p].call(e,f);n.state===yl&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=ys,n.timer.stop(),delete o[t];for(var d in o)return;delete e.__transition}}function vs(e,t){var n=e.__transition,o,s,a=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((o=n[i]).name!==t){a=!1;continue}s=o.state>xl&&o.state<yl,o.state=ys,o.timer.stop(),o.on.call(s?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[i]}a&&delete e.__transition}}function _B(e){return this.each(function(){vs(this,e)})}function DB(e,t){var n,o;return function(){var s=Yt(this,e),a=s.tween;if(a!==n){o=n=a;for(var i=0,l=o.length;i<l;++i)if(o[i].name===t){o=o.slice(),o.splice(i,1);break}}s.tween=o}}function LB(e,t,n){var o,s;if(typeof n!="function")throw new Error;return function(){var a=Yt(this,e),i=a.tween;if(i!==o){s=(o=i).slice();for(var l={name:t,value:n},c=0,d=s.length;c<d;++c)if(s[c].name===t){s[c]=l;break}c===d&&s.push(l)}a.tween=s}}function TB(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=Bt(this.node(),n).tween,s=0,a=o.length,i;s<a;++s)if((i=o[s]).name===e)return i.value;return null}return this.each((t==null?DB:LB)(n,e,t))}function cd(e,t,n){var o=e._id;return e.each(function(){var s=Yt(this,o);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Bt(s,o).value[t]}}function $0(e,t){var n;return(typeof t=="number"?Vt:t instanceof Vn?Fs:(n=Vn(t))?(t=n,Fs):S0)(e,t)}function RB(e){return function(){this.removeAttribute(e)}}function OB(e){return function(){this.removeAttributeNS(e.space,e.local)}}function zB(e,t,n){var o,s=n+"",a;return function(){var i=this.getAttribute(e);return i===s?null:i===o?a:a=t(o=i,n)}}function BB(e,t,n){var o,s=n+"",a;return function(){var i=this.getAttributeNS(e.space,e.local);return i===s?null:i===o?a:a=t(o=i,n)}}function FB(e,t,n){var o,s,a;return function(){var i,l=n(this),c;return l==null?void this.removeAttribute(e):(i=this.getAttribute(e),c=l+"",i===c?null:i===o&&c===s?a:(s=c,a=t(o=i,l)))}}function jB(e,t,n){var o,s,a;return function(){var i,l=n(this),c;return l==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),c=l+"",i===c?null:i===o&&c===s?a:(s=c,a=t(o=i,l)))}}function HB(e,t){var n=Ca(e),o=n==="transform"?wB:$0;return this.attrTween(e,typeof t=="function"?(n.local?jB:FB)(n,o,cd(this,"attr."+e,t)):t==null?(n.local?OB:RB)(n):(n.local?BB:zB)(n,o,t))}function VB(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function qB(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function QB(e,t){var n,o;function s(){var a=t.apply(this,arguments);return a!==o&&(n=(o=a)&&qB(e,a)),n}return s._value=t,s}function UB(e,t){var n,o;function s(){var a=t.apply(this,arguments);return a!==o&&(n=(o=a)&&VB(e,a)),n}return s._value=t,s}function KB(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=Ca(e);return this.tween(n,(o.local?QB:UB)(o,t))}function GB(e,t){return function(){ld(this,e).delay=+t.apply(this,arguments)}}function WB(e,t){return t=+t,function(){ld(this,e).delay=t}}function YB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?GB:WB)(t,e)):Bt(this.node(),t).delay}function ZB(e,t){return function(){Yt(this,e).duration=+t.apply(this,arguments)}}function XB(e,t){return t=+t,function(){Yt(this,e).duration=t}}function JB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ZB:XB)(t,e)):Bt(this.node(),t).duration}function eF(e,t){if(typeof t!="function")throw new Error;return function(){Yt(this,e).ease=t}}function tF(e){var t=this._id;return arguments.length?this.each(eF(t,e)):Bt(this.node(),t).ease}function nF(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Yt(this,e).ease=n}}function rF(e){if(typeof e!="function")throw new Error;return this.each(nF(this._id,e))}function oF(e){typeof e!="function"&&(e=l0(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=o[s]=[],c,d=0;d<i;++d)(c=a[d])&&e.call(c,c.__data__,d,a)&&l.push(c);return new dn(o,this._parents,this._name,this._id)}function sF(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,s=n.length,a=Math.min(o,s),i=new Array(o),l=0;l<a;++l)for(var c=t[l],d=n[l],f=c.length,p=i[l]=new Array(f),m,h=0;h<f;++h)(m=c[h]||d[h])&&(p[h]=m);for(;l<o;++l)i[l]=t[l];return new dn(i,this._parents,this._name,this._id)}function aF(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function iF(e,t,n){var o,s,a=aF(t)?ld:Yt;return function(){var i=a(this,e),l=i.on;l!==o&&(s=(o=l).copy()).on(t,n),i.on=s}}function lF(e,t){var n=this._id;return arguments.length<2?Bt(this.node(),n).on.on(e):this.each(iF(n,e,t))}function cF(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function dF(){return this.on("end.remove",cF(this._id))}function uF(e){var t=this._name,n=this._id;typeof e!="function"&&(e=rd(e));for(var o=this._groups,s=o.length,a=new Array(s),i=0;i<s;++i)for(var l=o[i],c=l.length,d=a[i]=new Array(c),f,p,m=0;m<c;++m)(f=l[m])&&(p=e.call(f,f.__data__,m,l))&&("__data__"in f&&(p.__data__=f.__data__),d[m]=p,Ia(d[m],t,n,m,d,Bt(f,n)));return new dn(a,this._parents,t,n)}function pF(e){var t=this._name,n=this._id;typeof e!="function"&&(e=i0(e));for(var o=this._groups,s=o.length,a=[],i=[],l=0;l<s;++l)for(var c=o[l],d=c.length,f,p=0;p<d;++p)if(f=c[p]){for(var m=e.call(f,f.__data__,p,c),h,g=Bt(f,n),b=0,x=m.length;b<x;++b)(h=m[b])&&Ia(h,t,n,b,m,g);a.push(m),i.push(f)}return new dn(a,i,t,n)}var fF=Eo.prototype.constructor;function mF(){return new fF(this._groups,this._parents)}function hF(e,t){var n,o,s;return function(){var a=vr(this,e),i=(this.style.removeProperty(e),vr(this,e));return a===i?null:a===n&&i===o?s:s=t(n=a,o=i)}}function _0(e){return function(){this.style.removeProperty(e)}}function gF(e,t,n){var o,s=n+"",a;return function(){var i=vr(this,e);return i===s?null:i===o?a:a=t(o=i,n)}}function bF(e,t,n){var o,s,a;return function(){var i=vr(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),vr(this,e))),i===c?null:i===o&&c===s?a:(s=c,a=t(o=i,l))}}function xF(e,t){var n,o,s,a="style."+t,i="end."+a,l;return function(){var c=Yt(this,e),d=c.on,f=c.value[a]==null?l||(l=_0(t)):void 0;(d!==n||s!==f)&&(o=(n=d).copy()).on(i,s=f),c.on=o}}function yF(e,t,n){var o=(e+="")=="transform"?vB:$0;return t==null?this.styleTween(e,hF(e,o)).on("end.style."+e,_0(e)):typeof t=="function"?this.styleTween(e,bF(e,o,cd(this,"style."+e,t))).each(xF(this._id,e)):this.styleTween(e,gF(e,o,t),n).on("end.style."+e,null)}function vF(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function wF(e,t,n){var o,s;function a(){var i=t.apply(this,arguments);return i!==s&&(o=(s=i)&&vF(e,i,n)),o}return a._value=t,a}function NF(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,wF(e,t,n??""))}function kF(e){return function(){this.textContent=e}}function SF(e){return function(){var t=e(this);this.textContent=t??""}}function CF(e){return this.tween("text",typeof e=="function"?SF(cd(this,"text",e)):kF(e==null?"":e+""))}function MF(e){return function(t){this.textContent=e.call(this,t)}}function IF(e){var t,n;function o(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&MF(s)),t}return o._value=e,o}function AF(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,IF(e))}function PF(){for(var e=this._name,t=this._id,n=D0(),o=this._groups,s=o.length,a=0;a<s;++a)for(var i=o[a],l=i.length,c,d=0;d<l;++d)if(c=i[d]){var f=Bt(c,t);Ia(c,e,n,d,i,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new dn(o,this._parents,e,n)}function EF(){var e,t,n=this,o=n._id,s=n.size();return new Promise(function(a,i){var l={value:i},c={value:function(){--s===0&&a()}};n.each(function(){var d=Yt(this,o),f=d.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),d.on=t}),s===0&&a()})}var $F=0;function dn(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function D0(){return++$F}var Jt=Eo.prototype;dn.prototype={constructor:dn,select:uF,selectAll:pF,selectChild:Jt.selectChild,selectChildren:Jt.selectChildren,filter:oF,merge:sF,selection:mF,transition:PF,call:Jt.call,nodes:Jt.nodes,node:Jt.node,size:Jt.size,empty:Jt.empty,each:Jt.each,on:lF,attr:HB,attrTween:KB,style:yF,styleTween:NF,text:CF,textTween:AF,remove:dF,tween:TB,delay:YB,duration:JB,ease:tF,easeVarying:rF,end:EF,[Symbol.iterator]:Jt[Symbol.iterator]};function _F(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var DF={time:null,delay:0,duration:250,ease:_F};function LF(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function TF(e){var t,n;e instanceof dn?(t=e._id,e=e._name):(t=D0(),(n=DF).time=id(),e=e==null?null:e+"");for(var o=this._groups,s=o.length,a=0;a<s;++a)for(var i=o[a],l=i.length,c,d=0;d<l;++d)(c=i[d])&&Ia(c,e,t,d,i,n||LF(c,t));return new dn(o,this._parents,e,t)}Eo.prototype.interrupt=_B;Eo.prototype.transition=TF;const as=e=>()=>e;function RF(e,{sourceEvent:t,target:n,transform:o,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:s}})}function nn(e,t,n){this.k=e,this.x=t,this.y=n}nn.prototype={constructor:nn,scale:function(e){return e===1?this:new nn(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new nn(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Aa=new nn(1,0,0);L0.prototype=nn.prototype;function L0(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Aa;return e.__zoom}function Ci(e){e.stopImmediatePropagation()}function qr(e){e.preventDefault(),e.stopImmediatePropagation()}function OF(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function zF(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Bp(){return this.__zoom||Aa}function BF(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function FF(){return navigator.maxTouchPoints||"ontouchstart"in this}function jF(e,t,n){var o=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s),i>a?(a+i)/2:Math.min(0,a)||Math.max(0,i))}function T0(){var e=OF,t=zF,n=jF,o=BF,s=FF,a=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,c=bs,d=Sa("start","zoom","end"),f,p,m,h=500,g=150,b=0,x=10;function v(A){A.property("__zoom",Bp).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",F).filter(s).on("touchstart.zoom",E).on("touchmove.zoom",B).on("touchend.zoom touchcancel.zoom",O).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(A,D,_,R){var L=A.selection?A.selection():A;L.property("__zoom",Bp),A!==L?k(A,D,_,R):L.interrupt().each(function(){S(this,arguments).event(R).start().zoom(null,typeof D=="function"?D.apply(this,arguments):D).end()})},v.scaleBy=function(A,D,_,R){v.scaleTo(A,function(){var L=this.__zoom.k,z=typeof D=="function"?D.apply(this,arguments):D;return L*z},_,R)},v.scaleTo=function(A,D,_,R){v.transform(A,function(){var L=t.apply(this,arguments),z=this.__zoom,j=_==null?N(L):typeof _=="function"?_.apply(this,arguments):_,H=z.invert(j),T=typeof D=="function"?D.apply(this,arguments):D;return n(y(w(z,T),j,H),L,i)},_,R)},v.translateBy=function(A,D,_,R){v.transform(A,function(){return n(this.__zoom.translate(typeof D=="function"?D.apply(this,arguments):D,typeof _=="function"?_.apply(this,arguments):_),t.apply(this,arguments),i)},null,R)},v.translateTo=function(A,D,_,R,L){v.transform(A,function(){var z=t.apply(this,arguments),j=this.__zoom,H=R==null?N(z):typeof R=="function"?R.apply(this,arguments):R;return n(Aa.translate(H[0],H[1]).scale(j.k).translate(typeof D=="function"?-D.apply(this,arguments):-D,typeof _=="function"?-_.apply(this,arguments):-_),z,i)},R,L)};function w(A,D){return D=Math.max(a[0],Math.min(a[1],D)),D===A.k?A:new nn(D,A.x,A.y)}function y(A,D,_){var R=D[0]-_[0]*A.k,L=D[1]-_[1]*A.k;return R===A.x&&L===A.y?A:new nn(A.k,R,L)}function N(A){return[(+A[0][0]+ +A[1][0])/2,(+A[0][1]+ +A[1][1])/2]}function k(A,D,_,R){A.on("start.zoom",function(){S(this,arguments).event(R).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(R).end()}).tween("zoom",function(){var L=this,z=arguments,j=S(L,z).event(R),H=t.apply(L,z),T=_==null?N(H):typeof _=="function"?_.apply(L,z):_,W=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),G=L.__zoom,ee=typeof D=="function"?D.apply(L,z):D,se=c(G.invert(T).concat(W/G.k),ee.invert(T).concat(W/ee.k));return function(te){if(te===1)te=ee;else{var X=se(te),re=W/X[2];te=new nn(re,T[0]-X[0]*re,T[1]-X[1]*re)}j.zoom(null,te)}})}function S(A,D,_){return!_&&A.__zooming||new M(A,D)}function M(A,D){this.that=A,this.args=D,this.active=0,this.sourceEvent=null,this.extent=t.apply(A,D),this.taps=0}M.prototype={event:function(A){return A&&(this.sourceEvent=A),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(A,D){return this.mouse&&A!=="mouse"&&(this.mouse[1]=D.invert(this.mouse[0])),this.touch0&&A!=="touch"&&(this.touch0[1]=D.invert(this.touch0[0])),this.touch1&&A!=="touch"&&(this.touch1[1]=D.invert(this.touch1[0])),this.that.__zoom=D,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(A){var D=lt(this.that).datum();d.call(A,this.that,new RF(A,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:d}),D)}};function P(A,...D){if(!e.apply(this,arguments))return;var _=S(this,D).event(A),R=this.__zoom,L=Math.max(a[0],Math.min(a[1],R.k*Math.pow(2,o.apply(this,arguments)))),z=Pt(A);if(_.wheel)(_.mouse[0][0]!==z[0]||_.mouse[0][1]!==z[1])&&(_.mouse[1]=R.invert(_.mouse[0]=z)),clearTimeout(_.wheel);else{if(R.k===L)return;_.mouse=[z,R.invert(z)],vs(this),_.start()}qr(A),_.wheel=setTimeout(j,g),_.zoom("mouse",n(y(w(R,L),_.mouse[0],_.mouse[1]),_.extent,i));function j(){_.wheel=null,_.end()}}function I(A,...D){if(m||!e.apply(this,arguments))return;var _=A.currentTarget,R=S(this,D,!0).event(A),L=lt(A.view).on("mousemove.zoom",T,!0).on("mouseup.zoom",W,!0),z=Pt(A,_),j=A.clientX,H=A.clientY;x0(A.view),Ci(A),R.mouse=[z,this.__zoom.invert(z)],vs(this),R.start();function T(G){if(qr(G),!R.moved){var ee=G.clientX-j,se=G.clientY-H;R.moved=ee*ee+se*se>b}R.event(G).zoom("mouse",n(y(R.that.__zoom,R.mouse[0]=Pt(G,_),R.mouse[1]),R.extent,i))}function W(G){L.on("mousemove.zoom mouseup.zoom",null),y0(G.view,R.moved),qr(G),R.event(G).end()}}function F(A,...D){if(e.apply(this,arguments)){var _=this.__zoom,R=Pt(A.changedTouches?A.changedTouches[0]:A,this),L=_.invert(R),z=_.k*(A.shiftKey?.5:2),j=n(y(w(_,z),R,L),t.apply(this,D),i);qr(A),l>0?lt(this).transition().duration(l).call(k,j,R,A):lt(this).call(v.transform,j,R,A)}}function E(A,...D){if(e.apply(this,arguments)){var _=A.touches,R=_.length,L=S(this,D,A.changedTouches.length===R).event(A),z,j,H,T;for(Ci(A),j=0;j<R;++j)H=_[j],T=Pt(H,this),T=[T,this.__zoom.invert(T),H.identifier],L.touch0?!L.touch1&&L.touch0[2]!==T[2]&&(L.touch1=T,L.taps=0):(L.touch0=T,z=!0,L.taps=1+!!f);f&&(f=clearTimeout(f)),z&&(L.taps<2&&(p=T[0],f=setTimeout(function(){f=null},h)),vs(this),L.start())}}function B(A,...D){if(this.__zooming){var _=S(this,D).event(A),R=A.changedTouches,L=R.length,z,j,H,T;for(qr(A),z=0;z<L;++z)j=R[z],H=Pt(j,this),_.touch0&&_.touch0[2]===j.identifier?_.touch0[0]=H:_.touch1&&_.touch1[2]===j.identifier&&(_.touch1[0]=H);if(j=_.that.__zoom,_.touch1){var W=_.touch0[0],G=_.touch0[1],ee=_.touch1[0],se=_.touch1[1],te=(te=ee[0]-W[0])*te+(te=ee[1]-W[1])*te,X=(X=se[0]-G[0])*X+(X=se[1]-G[1])*X;j=w(j,Math.sqrt(te/X)),H=[(W[0]+ee[0])/2,(W[1]+ee[1])/2],T=[(G[0]+se[0])/2,(G[1]+se[1])/2]}else if(_.touch0)H=_.touch0[0],T=_.touch0[1];else return;_.zoom("touch",n(y(j,H,T),_.extent,i))}}function O(A,...D){if(this.__zooming){var _=S(this,D).event(A),R=A.changedTouches,L=R.length,z,j;for(Ci(A),m&&clearTimeout(m),m=setTimeout(function(){m=null},h),z=0;z<L;++z)j=R[z],_.touch0&&_.touch0[2]===j.identifier?delete _.touch0:_.touch1&&_.touch1[2]===j.identifier&&delete _.touch1;if(_.touch1&&!_.touch0&&(_.touch0=_.touch1,delete _.touch1),_.touch0)_.touch0[1]=this.__zoom.invert(_.touch0[0]);else if(_.end(),_.taps===2&&(j=Pt(j,this),Math.hypot(p[0]-j[0],p[1]-j[1])<x)){var H=lt(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return v.wheelDelta=function(A){return arguments.length?(o=typeof A=="function"?A:as(+A),v):o},v.filter=function(A){return arguments.length?(e=typeof A=="function"?A:as(!!A),v):e},v.touchable=function(A){return arguments.length?(s=typeof A=="function"?A:as(!!A),v):s},v.extent=function(A){return arguments.length?(t=typeof A=="function"?A:as([[+A[0][0],+A[0][1]],[+A[1][0],+A[1][1]]]),v):t},v.scaleExtent=function(A){return arguments.length?(a[0]=+A[0],a[1]=+A[1],v):[a[0],a[1]]},v.translateExtent=function(A){return arguments.length?(i[0][0]=+A[0][0],i[1][0]=+A[1][0],i[0][1]=+A[0][1],i[1][1]=+A[1][1],v):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},v.constrain=function(A){return arguments.length?(n=A,v):n},v.duration=function(A){return arguments.length?(l=+A,v):l},v.interpolate=function(A){return arguments.length?(c=A,v):c},v.on=function(){var A=d.on.apply(d,arguments);return A===d?v:A},v.clickDistance=function(A){return arguments.length?(b=(A=+A)*A,v):Math.sqrt(b)},v.tapDistance=function(A){return arguments.length?(x=+A,v):x},v}const Gt={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ho=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],R0=["Enter"," ","Escape"],O0={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Nr;(function(e){e.Strict="strict",e.Loose="loose"})(Nr||(Nr={}));var Bn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Bn||(Bn={}));var go;(function(e){e.Partial="partial",e.Full="full"})(go||(go={}));const z0={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var xn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(xn||(xn={}));var qs;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(qs||(qs={}));var we;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(we||(we={}));const Fp={[we.Left]:we.Right,[we.Right]:we.Left,[we.Top]:we.Bottom,[we.Bottom]:we.Top};function B0(e){return e===null?null:e?"valid":"invalid"}const F0=e=>"id"in e&&"source"in e&&"target"in e,HF=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),dd=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),_o=(e,t=[0,0])=>{const{width:n,height:o}=fn(e),s=e.origin??t,a=n*s[0],i=o*s[1];return{x:e.position.x-a,y:e.position.y-i}},VF=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,s)=>{const a=typeof s=="string";let i=!t.nodeLookup&&!a?s:void 0;t.nodeLookup&&(i=a?t.nodeLookup.get(s):dd(s)?s:t.nodeLookup.get(s.id));const l=i?Qs(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Pa(o,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Ea(n)},Do=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=Pa(n,Qs(s)),o=!0)}),o?Ea(n):{x:0,y:0,width:0,height:0}},ud=(e,t,[n,o,s]=[0,0,1],a=!1,i=!1)=>{const l={...To(t,[n,o,s]),width:t.width/s,height:t.height/s},c=[];for(const d of e.values()){const{measured:f,selectable:p=!0,hidden:m=!1}=d;if(i&&!p||m)continue;const h=f.width??d.width??d.initialWidth??null,g=f.height??d.height??d.initialHeight??null,b=bo(l,Sr(d)),x=(h??0)*(g??0),v=a&&b>0;(!d.internals.handleBounds||v||b>=x||d.dragging)&&c.push(d)}return c},qF=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function QF(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&(t?.includeHiddenNodes||!s.hidden)&&(!o||o.has(s.id))&&n.set(s.id,s)}),n}async function UF({nodes:e,width:t,height:n,panZoom:o,minZoom:s,maxZoom:a},i){if(e.size===0)return Promise.resolve(!0);const l=QF(e,i),c=Do(l),d=pd(c,t,n,i?.minZoom??s,i?.maxZoom??a,i?.padding??.1);return await o.setViewport(d,{duration:i?.duration,ease:i?.ease,interpolate:i?.interpolate}),Promise.resolve(!0)}function j0({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:s,onError:a}){const i=n.get(e),l=i.parentId?n.get(i.parentId):void 0,{x:c,y:d}=l?l.internals.positionAbsolute:{x:0,y:0},f=i.origin??o;let p=i.extent||s;if(i.extent==="parent"&&!i.expandParent)if(!l)a?.("005",Gt.error005());else{const h=l.measured.width,g=l.measured.height;h&&g&&(p=[[c,d],[c+h,d+g]])}else l&&Cr(i.extent)&&(p=[[i.extent[0][0]+c,i.extent[0][1]+d],[i.extent[1][0]+c,i.extent[1][1]+d]]);const m=Cr(p)?Qn(t,p,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&a?.("015",Gt.error015()),{position:{x:m.x-c+(i.measured.width??0)*f[0],y:m.y-d+(i.measured.height??0)*f[1]},positionAbsolute:m}}async function KF({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:s}){const a=new Set(e.map(m=>m.id)),i=[];for(const m of n){if(m.deletable===!1)continue;const h=a.has(m.id),g=!h&&m.parentId&&i.find(b=>b.id===m.parentId);(h||g)&&i.push(m)}const l=new Set(t.map(m=>m.id)),c=o.filter(m=>m.deletable!==!1),f=qF(i,c);for(const m of c)l.has(m.id)&&!f.find(g=>g.id===m.id)&&f.push(m);if(!s)return{edges:f,nodes:i};const p=await s({nodes:i,edges:f});return typeof p=="boolean"?p?{edges:f,nodes:i}:{edges:[],nodes:[]}:p}const kr=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Qn=(e={x:0,y:0},t,n)=>({x:kr(e.x,t[0][0],t[1][0]-(n?.width??0)),y:kr(e.y,t[0][1],t[1][1]-(n?.height??0))});function H0(e,t,n){const{width:o,height:s}=fn(n),{x:a,y:i}=n.internals.positionAbsolute;return Qn(e,[[a,i],[a+o,i+s]],t)}const jp=(e,t,n)=>e<t?kr(Math.abs(e-t),1,t)/t:e>n?-kr(Math.abs(e-n),1,t)/t:0,V0=(e,t,n=15,o=40)=>{const s=jp(e.x,o,t.width-o)*n,a=jp(e.y,o,t.height-o)*n;return[s,a]},Pa=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),vl=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),Ea=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Sr=(e,t=[0,0])=>{const{x:n,y:o}=dd(e)?e.internals.positionAbsolute:_o(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Qs=(e,t=[0,0])=>{const{x:n,y:o}=dd(e)?e.internals.positionAbsolute:_o(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},q0=(e,t)=>Ea(Pa(vl(e),vl(t))),bo=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},Hp=e=>$t(e.width)&&$t(e.height)&&$t(e.x)&&$t(e.y),$t=e=>!isNaN(e)&&isFinite(e),GF=(e,t)=>{},Lo=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),To=({x:e,y:t},[n,o,s],a=!1,i=[1,1])=>{const l={x:(e-n)/s,y:(t-o)/s};return a?Lo(l,i):l},Us=({x:e,y:t},[n,o,s])=>({x:e*s+n,y:t*s+o});function or(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function WF(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=or(e,n),s=or(e,t);return{top:o,right:s,bottom:o,left:s,x:s*2,y:o*2}}if(typeof e=="object"){const o=or(e.top??e.y??0,n),s=or(e.bottom??e.y??0,n),a=or(e.left??e.x??0,t),i=or(e.right??e.x??0,t);return{top:o,right:i,bottom:s,left:a,x:a+i,y:o+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function YF(e,t,n,o,s,a){const{x:i,y:l}=Us(e,[t,n,o]),{x:c,y:d}=Us({x:e.x+e.width,y:e.y+e.height},[t,n,o]),f=s-c,p=a-d;return{left:Math.floor(i),top:Math.floor(l),right:Math.floor(f),bottom:Math.floor(p)}}const pd=(e,t,n,o,s,a)=>{const i=WF(a,t,n),l=(t-i.x)/e.width,c=(n-i.y)/e.height,d=Math.min(l,c),f=kr(d,o,s),p=e.x+e.width/2,m=e.y+e.height/2,h=t/2-p*f,g=n/2-m*f,b=YF(e,h,g,f,t,n),x={left:Math.min(b.left-i.left,0),top:Math.min(b.top-i.top,0),right:Math.min(b.right-i.right,0),bottom:Math.min(b.bottom-i.bottom,0)};return{x:h-x.left+x.right,y:g-x.top+x.bottom,zoom:f}},xo=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Cr(e){return e!=null&&e!=="parent"}function fn(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Q0(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function U0(e,t={width:0,height:0},n,o,s){const a={...e},i=o.get(n);if(i){const l=i.origin||s;a.x+=i.internals.positionAbsolute.x-(t.width??0)*l[0],a.y+=i.internals.positionAbsolute.y-(t.height??0)*l[1]}return a}function Vp(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function ZF(){let e,t;return{promise:new Promise((o,s)=>{e=o,t=s}),resolve:e,reject:t}}function XF(e){return{...O0,...e||{}}}function ro(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:s}){const{x:a,y:i}=_t(e),l=To({x:a-(s?.left??0),y:i-(s?.top??0)},o),{x:c,y:d}=n?Lo(l,t):l;return{xSnapped:c,ySnapped:d,...l}}const fd=e=>({width:e.offsetWidth,height:e.offsetHeight}),K0=e=>e?.getRootNode?.()||window?.document,JF=["INPUT","SELECT","TEXTAREA"];function G0(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:JF.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const W0=e=>"clientX"in e,_t=(e,t)=>{const n=W0(e),o=n?e.clientX:e.touches?.[0].clientX,s=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:s-(t?.top??0)}},qp=(e,t,n,o,s)=>{const a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(i=>{const l=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:e,nodeId:s,position:i.getAttribute("data-handlepos"),x:(l.left-n.left)/o,y:(l.top-n.top)/o,...fd(i)}})};function Y0({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:s,sourceControlY:a,targetControlX:i,targetControlY:l}){const c=e*.125+s*.375+i*.375+n*.125,d=t*.125+a*.375+l*.375+o*.125,f=Math.abs(c-e),p=Math.abs(d-t);return[c,d,f,p]}function is(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Qp({pos:e,x1:t,y1:n,x2:o,y2:s,c:a}){switch(e){case we.Left:return[t-is(t-o,a),n];case we.Right:return[t+is(o-t,a),n];case we.Top:return[t,n-is(n-s,a)];case we.Bottom:return[t,n+is(s-n,a)]}}function Z0({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:o,targetY:s,targetPosition:a=we.Top,curvature:i=.25}){const[l,c]=Qp({pos:n,x1:e,y1:t,x2:o,y2:s,c:i}),[d,f]=Qp({pos:a,x1:o,y1:s,x2:e,y2:t,c:i}),[p,m,h,g]=Y0({sourceX:e,sourceY:t,targetX:o,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:f});return[`M${e},${t} C${l},${c} ${d},${f} ${o},${s}`,p,m,h,g]}function X0({sourceX:e,sourceY:t,targetX:n,targetY:o}){const s=Math.abs(n-e)/2,a=n<e?n+s:n-s,i=Math.abs(o-t)/2,l=o<t?o+i:o-i;return[a,l,s,i]}function ej({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:s=!1,zIndexMode:a="basic"}){if(a==="manual")return o;const i=s&&n?o+1e3:o,l=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return i+l}function tj({sourceNode:e,targetNode:t,width:n,height:o,transform:s}){const a=Pa(Qs(e),Qs(t));a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1);const i={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:o/s[2]};return bo(i,Ea(a))>0}const nj=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,rj=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),oj=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||nj;let s;return F0(e)?s={...e}:s={...e,id:o(e)},rj(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function J0({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[s,a,i,l]=X0({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,s,a,i,l]}const Up={[we.Left]:{x:-1,y:0},[we.Right]:{x:1,y:0},[we.Top]:{x:0,y:-1},[we.Bottom]:{x:0,y:1}},sj=({source:e,sourcePosition:t=we.Bottom,target:n})=>t===we.Left||t===we.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Kp=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function aj({source:e,sourcePosition:t=we.Bottom,target:n,targetPosition:o=we.Top,center:s,offset:a,stepPosition:i}){const l=Up[t],c=Up[o],d={x:e.x+l.x*a,y:e.y+l.y*a},f={x:n.x+c.x*a,y:n.y+c.y*a},p=sj({source:d,sourcePosition:t,target:f}),m=p.x!==0?"x":"y",h=p[m];let g=[],b,x;const v={x:0,y:0},w={x:0,y:0},[,,y,N]=X0({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[m]*c[m]===-1){m==="x"?(b=s.x??d.x+(f.x-d.x)*i,x=s.y??(d.y+f.y)/2):(b=s.x??(d.x+f.x)/2,x=s.y??d.y+(f.y-d.y)*i);const P=[{x:b,y:d.y},{x:b,y:f.y}],I=[{x:d.x,y:x},{x:f.x,y:x}];l[m]===h?g=m==="x"?P:I:g=m==="x"?I:P}else{const P=[{x:d.x,y:f.y}],I=[{x:f.x,y:d.y}];if(m==="x"?g=l.x===h?I:P:g=l.y===h?P:I,t===o){const A=Math.abs(e[m]-n[m]);if(A<=a){const D=Math.min(a-1,a-A);l[m]===h?v[m]=(d[m]>e[m]?-1:1)*D:w[m]=(f[m]>n[m]?-1:1)*D}}if(t!==o){const A=m==="x"?"y":"x",D=l[m]===c[A],_=d[A]>f[A],R=d[A]<f[A];(l[m]===1&&(!D&&_||D&&R)||l[m]!==1&&(!D&&R||D&&_))&&(g=m==="x"?P:I)}const F={x:d.x+v.x,y:d.y+v.y},E={x:f.x+w.x,y:f.y+w.y},B=Math.max(Math.abs(F.x-g[0].x),Math.abs(E.x-g[0].x)),O=Math.max(Math.abs(F.y-g[0].y),Math.abs(E.y-g[0].y));B>=O?(b=(F.x+E.x)/2,x=g[0].y):(b=g[0].x,x=(F.y+E.y)/2)}const k={x:d.x+v.x,y:d.y+v.y},S={x:f.x+w.x,y:f.y+w.y};return[[e,...k.x!==g[0].x||k.y!==g[0].y?[k]:[],...g,...S.x!==g[g.length-1].x||S.y!==g[g.length-1].y?[S]:[],n],b,x,y,N]}function ij(e,t,n,o){const s=Math.min(Kp(e,t)/2,Kp(t,n)/2,o),{x:a,y:i}=t;if(e.x===a&&a===n.x||e.y===i&&i===n.y)return`L${a} ${i}`;if(e.y===i){const d=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${a+s*d},${i}Q ${a},${i} ${a},${i+s*f}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${a},${i+s*c}Q ${a},${i} ${a+s*l},${i}`}function wl({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:o,targetY:s,targetPosition:a=we.Top,borderRadius:i=5,centerX:l,centerY:c,offset:d=20,stepPosition:f=.5}){const[p,m,h,g,b]=aj({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:s},targetPosition:a,center:{x:l,y:c},offset:d,stepPosition:f});let x=`M${p[0].x} ${p[0].y}`;for(let v=1;v<p.length-1;v++)x+=ij(p[v-1],p[v],p[v+1],i);return x+=`L${p[p.length-1].x} ${p[p.length-1].y}`,[x,m,h,g,b]}function Gp(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function lj(e){const{sourceNode:t,targetNode:n}=e;if(!Gp(t)||!Gp(n))return null;const o=t.internals.handleBounds||Wp(t.handles),s=n.internals.handleBounds||Wp(n.handles),a=Yp(o?.source??[],e.sourceHandle),i=Yp(e.connectionMode===Nr.Strict?s?.target??[]:(s?.target??[]).concat(s?.source??[]),e.targetHandle);if(!a||!i)return e.onError?.("008",Gt.error008(a?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=a?.position||we.Bottom,c=i?.position||we.Top,d=Un(t,a,l),f=Un(n,i,c);return{sourceX:d.x,sourceY:d.y,targetX:f.x,targetY:f.y,sourcePosition:l,targetPosition:c}}function Wp(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function Un(e,t,n=we.Left,o=!1){const s=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:i,height:l}=t??fn(e);if(o)return{x:s+i/2,y:a+l/2};switch(t?.position??n){case we.Top:return{x:s+i/2,y:a};case we.Right:return{x:s+i,y:a+l/2};case we.Bottom:return{x:s+i/2,y:a+l};case we.Left:return{x:s,y:a+l/2}}}function Yp(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Nl(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function cj(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:s}){const a=new Set;return e.reduce((i,l)=>([l.markerStart||o,l.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const d=Nl(c,t);a.has(d)||(i.push({id:d,color:c.color||n,...c}),a.add(d))}}),i),[]).sort((i,l)=>i.id.localeCompare(l.id))}const ev=1e3,dj=10,md={nodeOrigin:[0,0],nodeExtent:ho,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},uj={...md,checkEquality:!0};function hd(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function pj(e,t,n){const o=hd(md,n);for(const s of e.values())if(s.parentId)bd(s,e,t,o);else{const a=_o(s,o.nodeOrigin),i=Cr(s.extent)?s.extent:o.nodeExtent,l=Qn(a,i,fn(s));s.internals.positionAbsolute=l}}function fj(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const s of e.handles){const a={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(a):s.type==="target"&&o.push(a)}return{source:n,target:o}}function gd(e){return e==="manual"}function kl(e,t,n,o={}){const s=hd(uj,o),a={i:0},i=new Map(t),l=s?.elevateNodesOnSelect&&!gd(s.zIndexMode)?ev:0;let c=e.length>0,d=!1;t.clear(),n.clear();for(const f of e){let p=i.get(f.id);if(s.checkEquality&&f===p?.internals.userNode)t.set(f.id,p);else{const m=_o(f,s.nodeOrigin),h=Cr(f.extent)?f.extent:s.nodeExtent,g=Qn(m,h,fn(f));p={...s.defaults,...f,measured:{width:f.measured?.width,height:f.measured?.height},internals:{positionAbsolute:g,handleBounds:fj(f,p),z:tv(f,l,s.zIndexMode),userNode:f}},t.set(f.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(c=!1),f.parentId&&bd(p,t,n,o,a),d||=f.selected??!1}return{nodesInitialized:c,hasSelectedNodes:d}}function mj(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function bd(e,t,n,o,s){const{elevateNodesOnSelect:a,nodeOrigin:i,nodeExtent:l,zIndexMode:c}=hd(md,o),d=e.parentId,f=t.get(d);if(!f){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}mj(e,n),s&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++s.i,f.internals.z=f.internals.z+s.i*dj),s&&f.internals.rootParentIndex!==void 0&&(s.i=f.internals.rootParentIndex);const p=a&&!gd(c)?ev:0,{x:m,y:h,z:g}=hj(e,f,i,l,p,c),{positionAbsolute:b}=e.internals,x=m!==b.x||h!==b.y;(x||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:m,y:h}:b,z:g}})}function tv(e,t,n){const o=$t(e.zIndex)?e.zIndex:0;return gd(n)?o:o+(e.selected?t:0)}function hj(e,t,n,o,s,a){const{x:i,y:l}=t.internals.positionAbsolute,c=fn(e),d=_o(e,n),f=Cr(e.extent)?Qn(d,e.extent,c):d;let p=Qn({x:i+f.x,y:l+f.y},o,c);e.extent==="parent"&&(p=H0(p,c,t));const m=tv(e,s,a),h=t.internals.z??0;return{x:p.x,y:p.y,z:h>=m?h+1:m}}function xd(e,t,n,o=[0,0]){const s=[],a=new Map;for(const i of e){const l=t.get(i.parentId);if(!l)continue;const c=a.get(i.parentId)?.expandedRect??Sr(l),d=q0(c,i.rect);a.set(i.parentId,{expandedRect:d,parent:l})}return a.size>0&&a.forEach(({expandedRect:i,parent:l},c)=>{const d=l.internals.positionAbsolute,f=fn(l),p=l.origin??o,m=i.x<d.x?Math.round(Math.abs(d.x-i.x)):0,h=i.y<d.y?Math.round(Math.abs(d.y-i.y)):0,g=Math.max(f.width,Math.round(i.width)),b=Math.max(f.height,Math.round(i.height)),x=(g-f.width)*p[0],v=(b-f.height)*p[1];(m>0||h>0||x||v)&&(s.push({id:c,type:"position",position:{x:l.position.x-m+x,y:l.position.y-h+v}}),n.get(c)?.forEach(w=>{e.some(y=>y.id===w.id)||s.push({id:w.id,type:"position",position:{x:w.position.x+m,y:w.position.y+h}})})),(f.width<i.width||f.height<i.height||m||h)&&s.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:g+(m?p[0]*m-x:0),height:b+(h?p[1]*h-v:0)}})}),s}function gj(e,t,n,o,s,a,i){const l=o?.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const d=[],f=window.getComputedStyle(l),{m22:p}=new window.DOMMatrixReadOnly(f.transform),m=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const b=fd(h.nodeElement),x=g.measured.width!==b.width||g.measured.height!==b.height;if(!!(b.width&&b.height&&(x||!g.internals.handleBounds||h.force))){const w=h.nodeElement.getBoundingClientRect(),y=Cr(g.extent)?g.extent:a;let{positionAbsolute:N}=g.internals;g.parentId&&g.extent==="parent"?N=H0(N,b,t.get(g.parentId)):y&&(N=Qn(N,y,b));const k={...g,measured:b,internals:{...g.internals,positionAbsolute:N,handleBounds:{source:qp("source",h.nodeElement,w,p,g.id),target:qp("target",h.nodeElement,w,p,g.id)}}};t.set(g.id,k),g.parentId&&bd(k,t,n,{nodeOrigin:s,zIndexMode:i}),c=!0,x&&(d.push({id:g.id,type:"dimensions",dimensions:b}),g.expandParent&&g.parentId&&m.push({id:g.id,parentId:g.parentId,rect:Sr(k,s)}))}}if(m.length>0){const h=xd(m,t,n,s);d.push(...h)}return{changes:d,updatedInternals:c}}async function bj({delta:e,panZoom:t,transform:n,translateExtent:o,width:s,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,a]],o),l=!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2]);return Promise.resolve(l)}function Zp(e,t,n,o,s,a){let i=s;const l=o.get(i)||new Map;o.set(i,l.set(n,t)),i=`${s}-${e}`;const c=o.get(i)||new Map;if(o.set(i,c.set(n,t)),a){i=`${s}-${e}-${a}`;const d=o.get(i)||new Map;o.set(i,d.set(n,t))}}function nv(e,t,n){e.clear(),t.clear();for(const o of n){const{source:s,target:a,sourceHandle:i=null,targetHandle:l=null}=o,c={edgeId:o.id,source:s,target:a,sourceHandle:i,targetHandle:l},d=`${s}-${i}--${a}-${l}`,f=`${a}-${l}--${s}-${i}`;Zp("source",c,f,e,s,i),Zp("target",c,d,e,a,l),t.set(o.id,o)}}function rv(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:rv(n,t):!1}function Xp(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function xj(e,t,n,o){const s=new Map;for(const[a,i]of e)if((i.selected||i.id===o)&&(!i.parentId||!rv(i,e))&&(i.draggable||t&&typeof i.draggable>"u")){const l=e.get(a);l&&s.set(a,{id:a,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return s}function Mi({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const s=[];for(const[i,l]of t){const c=n.get(i)?.internals.userNode;c&&s.push({...c,position:l.position,dragging:o})}if(!e)return[s[0],s];const a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:o}:s[0],s]}function yj({dragItems:e,snapGrid:t,x:n,y:o}){const s=e.values().next().value;if(!s)return null;const a={x:n-s.distance.x,y:o-s.distance.y},i=Lo(a,t);return{x:i.x-a.x,y:i.y-a.y}}function vj({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:s}){let a={x:null,y:null},i=0,l=new Map,c=!1,d={x:0,y:0},f=null,p=!1,m=null,h=!1,g=!1,b=null;function x({noDragClassName:w,handleSelector:y,domNode:N,isSelectable:k,nodeId:S,nodeClickDistance:M=0}){m=lt(N);function P({x:B,y:O}){const{nodeLookup:A,nodeExtent:D,snapGrid:_,snapToGrid:R,nodeOrigin:L,onNodeDrag:z,onSelectionDrag:j,onError:H,updateNodePositions:T}=t();a={x:B,y:O};let W=!1;const G=l.size>1,ee=G&&D?vl(Do(l)):null,se=G&&R?yj({dragItems:l,snapGrid:_,x:B,y:O}):null;for(const[te,X]of l){if(!A.has(te))continue;let re={x:B-X.distance.x,y:O-X.distance.y};R&&(re=se?{x:Math.round(re.x+se.x),y:Math.round(re.y+se.y)}:Lo(re,_));let ge=null;if(G&&D&&!X.extent&&ee){const{positionAbsolute:J}=X.internals,ae=J.x-ee.x+D[0][0],fe=J.x+X.measured.width-ee.x2+D[1][0],he=J.y-ee.y+D[0][1],V=J.y+X.measured.height-ee.y2+D[1][1];ge=[[ae,he],[fe,V]]}const{position:Z,positionAbsolute:U}=j0({nodeId:te,nextPosition:re,nodeLookup:A,nodeExtent:ge||D,nodeOrigin:L,onError:H});W=W||X.position.x!==Z.x||X.position.y!==Z.y,X.position=Z,X.internals.positionAbsolute=U}if(g=g||W,!!W&&(T(l,!0),b&&(o||z||!S&&j))){const[te,X]=Mi({nodeId:S,dragItems:l,nodeLookup:A});o?.(b,l,te,X),z?.(b,te,X),S||j?.(b,X)}}async function I(){if(!f)return;const{transform:B,panBy:O,autoPanSpeed:A,autoPanOnNodeDrag:D}=t();if(!D){c=!1,cancelAnimationFrame(i);return}const[_,R]=V0(d,f,A);(_!==0||R!==0)&&(a.x=(a.x??0)-_/B[2],a.y=(a.y??0)-R/B[2],await O({x:_,y:R})&&P(a)),i=requestAnimationFrame(I)}function F(B){const{nodeLookup:O,multiSelectionActive:A,nodesDraggable:D,transform:_,snapGrid:R,snapToGrid:L,selectNodesOnDrag:z,onNodeDragStart:j,onSelectionDragStart:H,unselectNodesAndEdges:T}=t();p=!0,(!z||!k)&&!A&&S&&(O.get(S)?.selected||T()),k&&z&&S&&e?.(S);const W=ro(B.sourceEvent,{transform:_,snapGrid:R,snapToGrid:L,containerBounds:f});if(a=W,l=xj(O,D,W,S),l.size>0&&(n||j||!S&&H)){const[G,ee]=Mi({nodeId:S,dragItems:l,nodeLookup:O});n?.(B.sourceEvent,l,G,ee),j?.(B.sourceEvent,G,ee),S||H?.(B.sourceEvent,ee)}}const E=v0().clickDistance(M).on("start",B=>{const{domNode:O,nodeDragThreshold:A,transform:D,snapGrid:_,snapToGrid:R}=t();f=O?.getBoundingClientRect()||null,h=!1,g=!1,b=B.sourceEvent,A===0&&F(B),a=ro(B.sourceEvent,{transform:D,snapGrid:_,snapToGrid:R,containerBounds:f}),d=_t(B.sourceEvent,f)}).on("drag",B=>{const{autoPanOnNodeDrag:O,transform:A,snapGrid:D,snapToGrid:_,nodeDragThreshold:R,nodeLookup:L}=t(),z=ro(B.sourceEvent,{transform:A,snapGrid:D,snapToGrid:_,containerBounds:f});if(b=B.sourceEvent,(B.sourceEvent.type==="touchmove"&&B.sourceEvent.touches.length>1||S&&!L.has(S))&&(h=!0),!h){if(!c&&O&&p&&(c=!0,I()),!p){const j=_t(B.sourceEvent,f),H=j.x-d.x,T=j.y-d.y;Math.sqrt(H*H+T*T)>R&&F(B)}(a.x!==z.xSnapped||a.y!==z.ySnapped)&&l&&p&&(d=_t(B.sourceEvent,f),P(z))}}).on("end",B=>{if(!(!p||h)&&(c=!1,p=!1,cancelAnimationFrame(i),l.size>0)){const{nodeLookup:O,updateNodePositions:A,onNodeDragStop:D,onSelectionDragStop:_}=t();if(g&&(A(l,!1),g=!1),s||D||!S&&_){const[R,L]=Mi({nodeId:S,dragItems:l,nodeLookup:O,dragging:!1});s?.(B.sourceEvent,l,R,L),D?.(B.sourceEvent,R,L),S||_?.(B.sourceEvent,L)}}}).filter(B=>{const O=B.target;return!B.button&&(!w||!Xp(O,`.${w}`,N))&&(!y||Xp(O,y,N))});m.call(E)}function v(){m?.on(".drag",null)}return{update:x,destroy:v}}function wj(e,t,n){const o=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const a of t.values())bo(s,Sr(a))>0&&o.push(a);return o}const Nj=250;function kj(e,t,n,o){let s=[],a=1/0;const i=wj(e,n,t+Nj);for(const l of i){const c=[...l.internals.handleBounds?.source??[],...l.internals.handleBounds?.target??[]];for(const d of c){if(o.nodeId===d.nodeId&&o.type===d.type&&o.id===d.id)continue;const{x:f,y:p}=Un(l,d,d.position,!0),m=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(p-e.y,2));m>t||(m<a?(s=[{...d,x:f,y:p}],a=m):m===a&&s.push({...d,x:f,y:p}))}}if(!s.length)return null;if(s.length>1){const l=o.type==="source"?"target":"source";return s.find(c=>c.type===l)??s[0]}return s[0]}function ov(e,t,n,o,s,a=!1){const i=o.get(e);if(!i)return null;const l=s==="strict"?i.internals.handleBounds?.[t]:[...i.internals.handleBounds?.source??[],...i.internals.handleBounds?.target??[]],c=(n?l?.find(d=>d.id===n):l?.[0])??null;return c&&a?{...c,...Un(i,c,c.position,!0)}:c}function sv(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Sj(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const av=()=>!0;function Cj(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:s,edgeUpdaterType:a,isTarget:i,domNode:l,nodeLookup:c,lib:d,autoPanOnConnect:f,flowId:p,panBy:m,cancelConnection:h,onConnectStart:g,onConnect:b,onConnectEnd:x,isValidConnection:v=av,onReconnectEnd:w,updateConnection:y,getTransform:N,getFromHandle:k,autoPanSpeed:S,dragThreshold:M=1,handleDomNode:P}){const I=K0(e.target);let F=0,E;const{x:B,y:O}=_t(e),A=sv(a,P),D=l?.getBoundingClientRect();let _=!1;if(!D||!A)return;const R=ov(s,A,o,c,t);if(!R)return;let L=_t(e,D),z=!1,j=null,H=!1,T=null;function W(){if(!f||!D)return;const[Z,U]=V0(L,D,S);m({x:Z,y:U}),F=requestAnimationFrame(W)}const G={...R,nodeId:s,type:A,position:R.position},ee=c.get(s);let te={inProgress:!0,isValid:null,from:Un(ee,G,we.Left,!0),fromHandle:G,fromPosition:G.position,fromNode:ee,to:L,toHandle:null,toPosition:Fp[G.position],toNode:null,pointer:L};function X(){_=!0,y(te),g?.(e,{nodeId:s,handleId:o,handleType:A})}M===0&&X();function re(Z){if(!_){const{x:V,y:ie}=_t(Z),ue=V-B,de=ie-O;if(!(ue*ue+de*de>M*M))return;X()}if(!k()||!G){ge(Z);return}const U=N();L=_t(Z,D),E=kj(To(L,U,!1,[1,1]),n,c,G),z||(W(),z=!0);const J=iv(Z,{handle:E,connectionMode:t,fromNodeId:s,fromHandleId:o,fromType:i?"target":"source",isValidConnection:v,doc:I,lib:d,flowId:p,nodeLookup:c});T=J.handleDomNode,j=J.connection,H=Sj(!!E,J.isValid);const ae=c.get(s),fe=ae?Un(ae,G,we.Left,!0):te.from,he={...te,from:fe,isValid:H,to:J.toHandle&&H?Us({x:J.toHandle.x,y:J.toHandle.y},U):L,toHandle:J.toHandle,toPosition:H&&J.toHandle?J.toHandle.position:Fp[G.position],toNode:J.toHandle?c.get(J.toHandle.nodeId):null,pointer:L};y(he),te=he}function ge(Z){if(!("touches"in Z&&Z.touches.length>0)){if(_){(E||T)&&j&&H&&b?.(j);const{inProgress:U,...J}=te,ae={...J,toPosition:te.toHandle?te.toPosition:null};x?.(Z,ae),a&&w?.(Z,ae)}h(),cancelAnimationFrame(F),z=!1,H=!1,j=null,T=null,I.removeEventListener("mousemove",re),I.removeEventListener("mouseup",ge),I.removeEventListener("touchmove",re),I.removeEventListener("touchend",ge)}}I.addEventListener("mousemove",re),I.addEventListener("mouseup",ge),I.addEventListener("touchmove",re),I.addEventListener("touchend",ge)}function iv(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:s,fromType:a,doc:i,lib:l,flowId:c,isValidConnection:d=av,nodeLookup:f}){const p=a==="target",m=t?i.querySelector(`.${l}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:g}=_t(e),b=i.elementFromPoint(h,g),x=b?.classList.contains(`${l}-flow__handle`)?b:m,v={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const w=sv(void 0,x),y=x.getAttribute("data-nodeid"),N=x.getAttribute("data-handleid"),k=x.classList.contains("connectable"),S=x.classList.contains("connectableend");if(!y||!w)return v;const M={source:p?y:o,sourceHandle:p?N:s,target:p?o:y,targetHandle:p?s:N};v.connection=M;const I=k&&S&&(n===Nr.Strict?p&&w==="source"||!p&&w==="target":y!==o||N!==s);v.isValid=I&&d(M),v.toHandle=ov(y,w,N,f,n,!0)}return v}const Sl={onPointerDown:Cj,isValid:iv};function Mj({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const s=lt(e);function a({translateExtent:l,width:c,height:d,zoomStep:f=1,pannable:p=!0,zoomable:m=!0,inversePan:h=!1}){const g=y=>{if(y.sourceEvent.type!=="wheel"||!t)return;const N=n(),k=y.sourceEvent.ctrlKey&&xo()?10:1,S=-y.sourceEvent.deltaY*(y.sourceEvent.deltaMode===1?.05:y.sourceEvent.deltaMode?1:.002)*f,M=N[2]*Math.pow(2,S*k);t.scaleTo(M)};let b=[0,0];const x=y=>{(y.sourceEvent.type==="mousedown"||y.sourceEvent.type==="touchstart")&&(b=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY])},v=y=>{const N=n();if(y.sourceEvent.type!=="mousemove"&&y.sourceEvent.type!=="touchmove"||!t)return;const k=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY],S=[k[0]-b[0],k[1]-b[1]];b=k;const M=o()*Math.max(N[2],Math.log(N[2]))*(h?-1:1),P={x:N[0]-S[0]*M,y:N[1]-S[1]*M},I=[[0,0],[c,d]];t.setViewportConstrained({x:P.x,y:P.y,zoom:N[2]},I,l)},w=T0().on("start",x).on("zoom",p?v:null).on("zoom.wheel",m?g:null);s.call(w,{})}function i(){s.on("zoom",null)}return{update:a,destroy:i,pointer:Pt}}const $a=e=>({x:e.x,y:e.y,zoom:e.k}),Ii=({x:e,y:t,zoom:n})=>Aa.translate(e,t).scale(n),ar=(e,t)=>e.target.closest(`.${t}`),lv=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Ij=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ai=(e,t=0,n=Ij,o=()=>{})=>{const s=typeof t=="number"&&t>0;return s||o(),s?e.transition().duration(t).ease(n).on("end",o):e},cv=e=>{const t=e.ctrlKey&&xo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Aj({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:s,panOnScrollSpeed:a,zoomOnPinch:i,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:d}){return f=>{if(ar(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(f.ctrlKey&&i){const x=Pt(f),v=cv(f),w=p*Math.pow(2,v);o.scaleTo(n,w,x,f);return}const m=f.deltaMode===1?20:1;let h=s===Bn.Vertical?0:f.deltaX*m,g=s===Bn.Horizontal?0:f.deltaY*m;!xo()&&f.shiftKey&&s!==Bn.Vertical&&(h=f.deltaY*m,g=0),o.translateBy(n,-(h/p)*a,-(g/p)*a,{internal:!0});const b=$a(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(f,b),e.panScrollTimeout=setTimeout(()=>{d?.(f,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(f,b))}}function Pj({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,s){const a=o.type==="wheel",i=!t&&a&&!o.ctrlKey,l=ar(o,e);if(o.ctrlKey&&a&&l&&o.preventDefault(),i||l)return null;o.preventDefault(),n.call(this,o,s)}}function Ej({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const s=$a(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=s,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,s)}}function $j({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:s}){return a=>{e.usedRightMouseButton=!!(n&&lv(t,e.mouseButton??0)),a.sourceEvent?.sync||o([a.transform.x,a.transform.y,a.transform.k]),s&&!a.sourceEvent?.internal&&s?.(a.sourceEvent,$a(a.transform))}}function _j({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:s,onPaneContextMenu:a}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&lv(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&a(i.sourceEvent),e.usedRightMouseButton=!1,o(!1),s)){const l=$a(i.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s?.(i.sourceEvent,l)},n?150:0)}}}function Dj({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:s,zoomOnDoubleClick:a,userSelectionActive:i,noWheelClassName:l,noPanClassName:c,lib:d,connectionInProgress:f}){return p=>{const m=e||t,h=n&&p.ctrlKey,g=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(ar(p,`${d}-flow__node`)||ar(p,`${d}-flow__edge`)))return!0;if(!o&&!m&&!s&&!a&&!n||i||f&&!g||ar(p,l)&&g||ar(p,c)&&(!g||s&&g&&!e)||!n&&p.ctrlKey&&g)return!1;if(!n&&p.type==="touchstart"&&p.touches?.length>1)return p.preventDefault(),!1;if(!m&&!s&&!h&&g||!o&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(o)&&!o.includes(p.button)&&p.type==="mousedown")return!1;const b=Array.isArray(o)&&o.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||g)&&b}}function Lj({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:s,onPanZoom:a,onPanZoomStart:i,onPanZoomEnd:l,onDraggingChange:c}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),p=T0().scaleExtent([t,n]).translateExtent(o),m=lt(e).call(p);w({x:s.x,y:s.y,zoom:kr(s.zoom,t,n)},[[0,0],[f.width,f.height]],o);const h=m.on("wheel.zoom"),g=m.on("dblclick.zoom");p.wheelDelta(cv);function b(E,B){return m?new Promise(O=>{p?.interpolate(B?.interpolate==="linear"?no:bs).transform(Ai(m,B?.duration,B?.ease,()=>O(!0)),E)}):Promise.resolve(!1)}function x({noWheelClassName:E,noPanClassName:B,onPaneContextMenu:O,userSelectionActive:A,panOnScroll:D,panOnDrag:_,panOnScrollMode:R,panOnScrollSpeed:L,preventScrolling:z,zoomOnPinch:j,zoomOnScroll:H,zoomOnDoubleClick:T,zoomActivationKeyPressed:W,lib:G,onTransformChange:ee,connectionInProgress:se,paneClickDistance:te,selectionOnDrag:X}){A&&!d.isZoomingOrPanning&&v();const re=D&&!W&&!A;p.clickDistance(X?1/0:!$t(te)||te<0?0:te);const ge=re?Aj({zoomPanValues:d,noWheelClassName:E,d3Selection:m,d3Zoom:p,panOnScrollMode:R,panOnScrollSpeed:L,zoomOnPinch:j,onPanZoomStart:i,onPanZoom:a,onPanZoomEnd:l}):Pj({noWheelClassName:E,preventScrolling:z,d3ZoomHandler:h});if(m.on("wheel.zoom",ge,{passive:!1}),!A){const U=Ej({zoomPanValues:d,onDraggingChange:c,onPanZoomStart:i});p.on("start",U);const J=$j({zoomPanValues:d,panOnDrag:_,onPaneContextMenu:!!O,onPanZoom:a,onTransformChange:ee});p.on("zoom",J);const ae=_j({zoomPanValues:d,panOnDrag:_,panOnScroll:D,onPaneContextMenu:O,onPanZoomEnd:l,onDraggingChange:c});p.on("end",ae)}const Z=Dj({zoomActivationKeyPressed:W,panOnDrag:_,zoomOnScroll:H,panOnScroll:D,zoomOnDoubleClick:T,zoomOnPinch:j,userSelectionActive:A,noPanClassName:B,noWheelClassName:E,lib:G,connectionInProgress:se});p.filter(Z),T?m.on("dblclick.zoom",g):m.on("dblclick.zoom",null)}function v(){p.on("zoom",null)}async function w(E,B,O){const A=Ii(E),D=p?.constrain()(A,B,O);return D&&await b(D),new Promise(_=>_(D))}async function y(E,B){const O=Ii(E);return await b(O,B),new Promise(A=>A(O))}function N(E){if(m){const B=Ii(E),O=m.property("__zoom");(O.k!==E.zoom||O.x!==E.x||O.y!==E.y)&&p?.transform(m,B,null,{sync:!0})}}function k(){const E=m?L0(m.node()):{x:0,y:0,k:1};return{x:E.x,y:E.y,zoom:E.k}}function S(E,B){return m?new Promise(O=>{p?.interpolate(B?.interpolate==="linear"?no:bs).scaleTo(Ai(m,B?.duration,B?.ease,()=>O(!0)),E)}):Promise.resolve(!1)}function M(E,B){return m?new Promise(O=>{p?.interpolate(B?.interpolate==="linear"?no:bs).scaleBy(Ai(m,B?.duration,B?.ease,()=>O(!0)),E)}):Promise.resolve(!1)}function P(E){p?.scaleExtent(E)}function I(E){p?.translateExtent(E)}function F(E){const B=!$t(E)||E<0?0:E;p?.clickDistance(B)}return{update:x,destroy:v,setViewport:y,setViewportConstrained:w,getViewport:k,scaleTo:S,scaleBy:M,setScaleExtent:P,setTranslateExtent:I,syncViewport:N,setClickDistance:F}}var Mr;(function(e){e.Line="line",e.Handle="handle"})(Mr||(Mr={}));function Tj({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:s,affectsY:a}){const i=e-t,l=n-o,c=[i>0?1:i<0?-1:0,l>0?1:l<0?-1:0];return i&&s&&(c[0]=c[0]*-1),l&&a&&(c[1]=c[1]*-1),c}function Jp(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:s}}function gn(e,t){return Math.max(0,t-e)}function bn(e,t){return Math.max(0,e-t)}function ls(e,t,n){return Math.max(0,t-e,e-n)}function ef(e,t){return e?!t:t}function Rj(e,t,n,o,s,a,i,l){let{affectsX:c,affectsY:d}=t;const{isHorizontal:f,isVertical:p}=t,m=f&&p,{xSnapped:h,ySnapped:g}=n,{minWidth:b,maxWidth:x,minHeight:v,maxHeight:w}=o,{x:y,y:N,width:k,height:S,aspectRatio:M}=e;let P=Math.floor(f?h-e.pointerX:0),I=Math.floor(p?g-e.pointerY:0);const F=k+(c?-P:P),E=S+(d?-I:I),B=-a[0]*k,O=-a[1]*S;let A=ls(F,b,x),D=ls(E,v,w);if(i){let L=0,z=0;c&&P<0?L=gn(y+P+B,i[0][0]):!c&&P>0&&(L=bn(y+F+B,i[1][0])),d&&I<0?z=gn(N+I+O,i[0][1]):!d&&I>0&&(z=bn(N+E+O,i[1][1])),A=Math.max(A,L),D=Math.max(D,z)}if(l){let L=0,z=0;c&&P>0?L=bn(y+P,l[0][0]):!c&&P<0&&(L=gn(y+F,l[1][0])),d&&I>0?z=bn(N+I,l[0][1]):!d&&I<0&&(z=gn(N+E,l[1][1])),A=Math.max(A,L),D=Math.max(D,z)}if(s){if(f){const L=ls(F/M,v,w)*M;if(A=Math.max(A,L),i){let z=0;!c&&!d||c&&!d&&m?z=bn(N+O+F/M,i[1][1])*M:z=gn(N+O+(c?P:-P)/M,i[0][1])*M,A=Math.max(A,z)}if(l){let z=0;!c&&!d||c&&!d&&m?z=gn(N+F/M,l[1][1])*M:z=bn(N+(c?P:-P)/M,l[0][1])*M,A=Math.max(A,z)}}if(p){const L=ls(E*M,b,x)/M;if(D=Math.max(D,L),i){let z=0;!c&&!d||d&&!c&&m?z=bn(y+E*M+B,i[1][0])/M:z=gn(y+(d?I:-I)*M+B,i[0][0])/M,D=Math.max(D,z)}if(l){let z=0;!c&&!d||d&&!c&&m?z=gn(y+E*M,l[1][0])/M:z=bn(y+(d?I:-I)*M,l[0][0])/M,D=Math.max(D,z)}}}I=I+(I<0?D:-D),P=P+(P<0?A:-A),s&&(m?F>E*M?I=(ef(c,d)?-P:P)/M:P=(ef(c,d)?-I:I)*M:f?(I=P/M,d=c):(P=I*M,c=d));const _=c?y+P:y,R=d?N+I:N;return{width:k+(c?-P:P),height:S+(d?-I:I),x:a[0]*P*(c?-1:1)+_,y:a[1]*I*(d?-1:1)+R}}const dv={width:0,height:0,x:0,y:0},Oj={...dv,pointerX:0,pointerY:0,aspectRatio:1};function zj(e){return[[0,0],[e.measured.width,e.measured.height]]}function Bj(e,t,n){const o=t.position.x+e.position.x,s=t.position.y+e.position.y,a=e.measured.width??0,i=e.measured.height??0,l=n[0]*a,c=n[1]*i;return[[o-l,s-c],[o+a-l,s+i-c]]}function Fj({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:s}){const a=lt(e);let i={controlDirection:Jp("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:d,boundaries:f,keepAspectRatio:p,resizeDirection:m,onResizeStart:h,onResize:g,onResizeEnd:b,shouldResize:x}){let v={...dv},w={...Oj};i={boundaries:f,resizeDirection:m,keepAspectRatio:p,controlDirection:Jp(d)};let y,N=null,k=[],S,M,P,I=!1;const F=v0().on("start",E=>{const{nodeLookup:B,transform:O,snapGrid:A,snapToGrid:D,nodeOrigin:_,paneDomNode:R}=n();if(y=B.get(t),!y)return;N=R?.getBoundingClientRect()??null;const{xSnapped:L,ySnapped:z}=ro(E.sourceEvent,{transform:O,snapGrid:A,snapToGrid:D,containerBounds:N});v={width:y.measured.width??0,height:y.measured.height??0,x:y.position.x??0,y:y.position.y??0},w={...v,pointerX:L,pointerY:z,aspectRatio:v.width/v.height},S=void 0,y.parentId&&(y.extent==="parent"||y.expandParent)&&(S=B.get(y.parentId),M=S&&y.extent==="parent"?zj(S):void 0),k=[],P=void 0;for(const[j,H]of B)if(H.parentId===t&&(k.push({id:j,position:{...H.position},extent:H.extent}),H.extent==="parent"||H.expandParent)){const T=Bj(H,y,H.origin??_);P?P=[[Math.min(T[0][0],P[0][0]),Math.min(T[0][1],P[0][1])],[Math.max(T[1][0],P[1][0]),Math.max(T[1][1],P[1][1])]]:P=T}h?.(E,{...v})}).on("drag",E=>{const{transform:B,snapGrid:O,snapToGrid:A,nodeOrigin:D}=n(),_=ro(E.sourceEvent,{transform:B,snapGrid:O,snapToGrid:A,containerBounds:N}),R=[];if(!y)return;const{x:L,y:z,width:j,height:H}=v,T={},W=y.origin??D,{width:G,height:ee,x:se,y:te}=Rj(w,i.controlDirection,_,i.boundaries,i.keepAspectRatio,W,M,P),X=G!==j,re=ee!==H,ge=se!==L&&X,Z=te!==z&&re;if(!ge&&!Z&&!X&&!re)return;if((ge||Z||W[0]===1||W[1]===1)&&(T.x=ge?se:v.x,T.y=Z?te:v.y,v.x=T.x,v.y=T.y,k.length>0)){const fe=se-L,he=te-z;for(const V of k)V.position={x:V.position.x-fe+W[0]*(G-j),y:V.position.y-he+W[1]*(ee-H)},R.push(V)}if((X||re)&&(T.width=X&&(!i.resizeDirection||i.resizeDirection==="horizontal")?G:v.width,T.height=re&&(!i.resizeDirection||i.resizeDirection==="vertical")?ee:v.height,v.width=T.width,v.height=T.height),S&&y.expandParent){const fe=W[0]*(T.width??0);T.x&&T.x<fe&&(v.x=fe,w.x=w.x-(T.x-fe));const he=W[1]*(T.height??0);T.y&&T.y<he&&(v.y=he,w.y=w.y-(T.y-he))}const U=Tj({width:v.width,prevWidth:j,height:v.height,prevHeight:H,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),J={...v,direction:U};x?.(E,J)!==!1&&(I=!0,g?.(E,J),o(T,R))}).on("end",E=>{I&&(b?.(E,{...v}),s?.({...v}),I=!1)});a.call(F)}function c(){a.on(".drag",null)}return{update:l,destroy:c}}var uv={exports:{}},pv={};/**
|
|
1085
|
+
* @license React
|
|
1086
|
+
* use-sync-external-store-shim/with-selector.production.js
|
|
1087
|
+
*
|
|
1088
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1089
|
+
*
|
|
1090
|
+
* This source code is licensed under the MIT license found in the
|
|
1091
|
+
* LICENSE file in the root directory of this source tree.
|
|
1092
|
+
*/var _a=qf,jj=_y;function Hj(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Vj=typeof Object.is=="function"?Object.is:Hj,qj=jj.useSyncExternalStore,Qj=_a.useRef,Uj=_a.useEffect,Kj=_a.useMemo,Gj=_a.useDebugValue;pv.useSyncExternalStoreWithSelector=function(e,t,n,o,s){var a=Qj(null);if(a.current===null){var i={hasValue:!1,value:null};a.current=i}else i=a.current;a=Kj(function(){function c(h){if(!d){if(d=!0,f=h,h=o(h),s!==void 0&&i.hasValue){var g=i.value;if(s(g,h))return p=g}return p=h}if(g=p,Vj(f,h))return g;var b=o(h);return s!==void 0&&s(g,b)?(f=h,g):(f=h,p=b)}var d=!1,f,p,m=n===void 0?null:n;return[function(){return c(t())},m===null?void 0:function(){return c(m())}]},[t,n,o,s]);var l=qj(e,a[0],a[1]);return Uj(function(){i.hasValue=!0,i.value=l},[l]),Gj(l),l};uv.exports=pv;var Wj=uv.exports;const Yj=q1(Wj),Zj={},tf=e=>{let t;const n=new Set,o=(f,p)=>{const m=typeof f=="function"?f(t):f;if(!Object.is(m,t)){const h=t;t=p??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(g=>g(t,h))}},s=()=>t,c={setState:o,getState:s,getInitialState:()=>d,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(Zj?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(o,s,c);return c},Xj=e=>e?tf(e):tf,{useDebugValue:Jj}=Al,{useSyncExternalStoreWithSelector:eH}=Yj,tH=e=>e;function fv(e,t=tH,n){const o=eH(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Jj(o),o}const nf=(e,t)=>{const n=Xj(e),o=(s,a=t)=>fv(n,s,a);return Object.assign(o,n),o},nH=(e,t)=>e?nf(e,t):nf;function Be(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,s]of e)if(!Object.is(s,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const Da=Oe(null),rH=Da.Provider,mv=Gt.error001();function $e(e,t){const n=ye(Da);if(n===null)throw new Error(mv);return fv(n,e,t)}function je(){const e=ye(Da);if(e===null)throw new Error(mv);return Q(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const rf={display:"none"},oH={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},hv="react-flow__node-desc",gv="react-flow__edge-desc",sH="react-flow__aria-live",aH=e=>e.ariaLiveMessage,iH=e=>e.ariaLabelConfig;function lH({rfId:e}){const t=$e(aH);return r("div",{id:`${sH}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:oH,children:t})}function cH({rfId:e,disableKeyboardA11y:t}){const n=$e(iH);return u(ve,{children:[r("div",{id:`${hv}-${e}`,style:rf,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),r("div",{id:`${gv}-${e}`,style:rf,children:n["edge.a11yDescription.default"]}),!t&&r(lH,{rfId:e})]})}const La=Ve(({position:e="top-left",children:t,className:n,style:o,...s},a)=>{const i=`${e}`.split("-");return r("div",{className:Ue(["react-flow__panel",n,...i]),style:o,ref:a,...s,children:t})});La.displayName="Panel";function dH({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:r(La,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:r("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const uH=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},cs=e=>e.id;function pH(e,t){return Be(e.selectedNodes.map(cs),t.selectedNodes.map(cs))&&Be(e.selectedEdges.map(cs),t.selectedEdges.map(cs))}function fH({onSelectionChange:e}){const t=je(),{selectedNodes:n,selectedEdges:o}=$e(uH,pH);return Y(()=>{const s={nodes:n,edges:o};e?.(s),t.getState().onSelectionChangeHandlers.forEach(a=>a(s))},[n,o,e]),null}const mH=e=>!!e.onSelectionChangeHandlers;function hH({onSelectionChange:e}){const t=$e(mH);return e||t?r(fH,{onSelectionChange:e}):null}const Cl=typeof window<"u"?Gs:Y,bv=[0,0],gH={x:0,y:0,zoom:1},bH=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],of=[...bH,"rfId"],xH=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),sf={translateExtent:ho,nodeOrigin:bv,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function yH(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:s,setTranslateExtent:a,setNodeExtent:i,reset:l,setDefaultNodesAndEdges:c}=$e(xH,Be),d=je();Cl(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=sf,l()}),[]);const f=ne(sf);return Cl(()=>{for(const p of of){const m=e[p],h=f.current[p];m!==h&&(typeof e[p]>"u"||(p==="nodes"?t(m):p==="edges"?n(m):p==="minZoom"?o(m):p==="maxZoom"?s(m):p==="translateExtent"?a(m):p==="nodeExtent"?i(m):p==="ariaLabelConfig"?d.setState({ariaLabelConfig:XF(m)}):p==="fitView"?d.setState({fitViewQueued:m}):p==="fitViewOptions"?d.setState({fitViewOptions:m}):d.setState({[p]:m})))}f.current=e},of.map(p=>e[p])),null}function af(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function vH(e){const[t,n]=$(e==="system"?null:e);return Y(()=>{if(e!=="system"){n(e);return}const o=af(),s=()=>n(o?.matches?"dark":"light");return s(),o?.addEventListener("change",s),()=>{o?.removeEventListener("change",s)}},[e]),t!==null?t:af()?.matches?"dark":"light"}const lf=typeof document<"u"?document:null;function yo(e=null,t={target:lf,actInsideInputWithModifier:!0}){const[n,o]=$(!1),s=ne(!1),a=ne(new Set([])),[i,l]=Q(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",`
|
|
1093
|
+
`).replace(`
|
|
1094
|
+
|
|
1095
|
+
`,`
|
|
1096
|
+
+`).split(`
|
|
1097
|
+
`)),f=d.reduce((p,m)=>p.concat(...m),[]);return[d,f]}return[[],[]]},[e]);return Y(()=>{const c=t?.target??lf,d=t?.actInsideInputWithModifier??!0;if(e!==null){const f=h=>{if(s.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!s.current||s.current&&!d)&&G0(h))return!1;const b=df(h.code,l);if(a.current.add(h[b]),cf(i,a.current,!1)){const x=h.composedPath?.()?.[0]||h.target,v=x?.nodeName==="BUTTON"||x?.nodeName==="A";t.preventDefault!==!1&&(s.current||!v)&&h.preventDefault(),o(!0)}},p=h=>{const g=df(h.code,l);cf(i,a.current,!0)?(o(!1),a.current.clear()):a.current.delete(h[g]),h.key==="Meta"&&a.current.clear(),s.current=!1},m=()=>{a.current.clear(),o(!1)};return c?.addEventListener("keydown",f),c?.addEventListener("keyup",p),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{c?.removeEventListener("keydown",f),c?.removeEventListener("keyup",p),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[e,o]),n}function cf(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(s=>t.has(s)))}function df(e,t){return t.includes(e)?"code":"key"}const wH=()=>{const e=je();return Q(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[o,s,a],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??o,y:t.y??s,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{const{width:o,height:s,minZoom:a,maxZoom:i,panZoom:l}=e.getState(),c=pd(t,o,s,a,i,n?.padding??.1);return l?(await l.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:o,snapGrid:s,snapToGrid:a,domNode:i}=e.getState();if(!i)return t;const{x:l,y:c}=i.getBoundingClientRect(),d={x:t.x-l,y:t.y-c},f=n.snapGrid??s,p=n.snapToGrid??a;return To(d,o,p,f)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:s,y:a}=o.getBoundingClientRect(),i=Us(t,n);return{x:i.x+s,y:i.y+a}}}),[])};function xv(e,t){const n=[],o=new Map,s=[];for(const a of e)if(a.type==="add"){s.push(a);continue}else if(a.type==="remove"||a.type==="replace")o.set(a.id,[a]);else{const i=o.get(a.id);i?i.push(a):o.set(a.id,[a])}for(const a of t){const i=o.get(a.id);if(!i){n.push(a);continue}if(i[0].type==="remove")continue;if(i[0].type==="replace"){n.push({...i[0].item});continue}const l={...a};for(const c of i)NH(c,l);n.push(l)}return s.length&&s.forEach(a=>{a.index!==void 0?n.splice(a.index,0,{...a.item}):n.push({...a.item})}),n}function NH(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function kH(e,t){return xv(e,t)}function SH(e,t){return xv(e,t)}function Ln(e,t){return{id:e,type:"select",selected:t}}function ir(e,t=new Set,n=!1){const o=[];for(const[s,a]of e){const i=t.has(s);!(a.selected===void 0&&!i)&&a.selected!==i&&(n&&(a.selected=i),o.push(Ln(a.id,i)))}return o}function uf({items:e=[],lookup:t}){const n=[],o=new Map(e.map(s=>[s.id,s]));for(const[s,a]of e.entries()){const i=t.get(a.id),l=i?.internals?.userNode??i;l!==void 0&&l!==a&&n.push({id:a.id,item:a,type:"replace"}),l===void 0&&n.push({item:a,type:"add",index:s})}for(const[s]of t)o.get(s)===void 0&&n.push({id:s,type:"remove"});return n}function pf(e){return{id:e.id,type:"remove"}}const ff=e=>HF(e),CH=e=>F0(e);function yv(e){return Ve(e)}function mf(e){const[t,n]=$(BigInt(0)),[o]=$(()=>MH(()=>n(s=>s+BigInt(1))));return Cl(()=>{const s=o.get();s.length&&(e(s),o.reset())},[t]),o}function MH(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const vv=Oe(null);function IH({children:e}){const t=je(),n=q(l=>{const{nodes:c=[],setNodes:d,hasDefaultNodes:f,onNodesChange:p,nodeLookup:m,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let b=c;for(const v of l)b=typeof v=="function"?v(b):v;let x=uf({items:b,lookup:m});for(const v of g.values())x=v(x);f&&d(b),x.length>0?p?.(x):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:v,nodes:w,setNodes:y}=t.getState();v&&y(w)})},[]),o=mf(n),s=q(l=>{const{edges:c=[],setEdges:d,hasDefaultEdges:f,onEdgesChange:p,edgeLookup:m}=t.getState();let h=c;for(const g of l)h=typeof g=="function"?g(h):g;f?d(h):p&&p(uf({items:h,lookup:m}))},[]),a=mf(s),i=Q(()=>({nodeQueue:o,edgeQueue:a}),[]);return r(vv.Provider,{value:i,children:e})}function AH(){const e=ye(vv);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const PH=e=>!!e.panZoom;function yd(){const e=wH(),t=je(),n=AH(),o=$e(PH),s=Q(()=>{const a=p=>t.getState().nodeLookup.get(p),i=p=>{n.nodeQueue.push(p)},l=p=>{n.edgeQueue.push(p)},c=p=>{const{nodeLookup:m,nodeOrigin:h}=t.getState(),g=ff(p)?p:m.get(p.id),b=g.parentId?U0(g.position,g.measured,g.parentId,m,h):g.position,x={...g,position:b,width:g.measured?.width??g.width,height:g.measured?.height??g.height};return Sr(x)},d=(p,m,h={replace:!1})=>{i(g=>g.map(b=>{if(b.id===p){const x=typeof m=="function"?m(b):m;return h.replace&&ff(x)?x:{...b,...x}}return b}))},f=(p,m,h={replace:!1})=>{l(g=>g.map(b=>{if(b.id===p){const x=typeof m=="function"?m(b):m;return h.replace&&CH(x)?x:{...b,...x}}return b}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>a(p)?.internals.userNode,getInternalNode:a,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(m=>({...m}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:i,setEdges:l,addNodes:p=>{const m=Array.isArray(p)?p:[p];n.nodeQueue.push(h=>[...h,...m])},addEdges:p=>{const m=Array.isArray(p)?p:[p];n.edgeQueue.push(h=>[...h,...m])},toObject:()=>{const{nodes:p=[],edges:m=[],transform:h}=t.getState(),[g,b,x]=h;return{nodes:p.map(v=>({...v})),edges:m.map(v=>({...v})),viewport:{x:g,y:b,zoom:x}}},deleteElements:async({nodes:p=[],edges:m=[]})=>{const{nodes:h,edges:g,onNodesDelete:b,onEdgesDelete:x,triggerNodeChanges:v,triggerEdgeChanges:w,onDelete:y,onBeforeDelete:N}=t.getState(),{nodes:k,edges:S}=await KF({nodesToRemove:p,edgesToRemove:m,nodes:h,edges:g,onBeforeDelete:N}),M=S.length>0,P=k.length>0;if(M){const I=S.map(pf);x?.(S),w(I)}if(P){const I=k.map(pf);b?.(k),v(I)}return(P||M)&&y?.({nodes:k,edges:S}),{deletedNodes:k,deletedEdges:S}},getIntersectingNodes:(p,m=!0,h)=>{const g=Hp(p),b=g?p:c(p),x=h!==void 0;return b?(h||t.getState().nodes).filter(v=>{const w=t.getState().nodeLookup.get(v.id);if(w&&!g&&(v.id===p.id||!w.internals.positionAbsolute))return!1;const y=Sr(x?v:w),N=bo(y,b);return m&&N>0||N>=y.width*y.height||N>=b.width*b.height}):[]},isNodeIntersecting:(p,m,h=!0)=>{const b=Hp(p)?p:c(p);if(!b)return!1;const x=bo(b,m);return h&&x>0||x>=m.width*m.height||x>=b.width*b.height},updateNode:d,updateNodeData:(p,m,h={replace:!1})=>{d(p,g=>{const b=typeof m=="function"?m(g):m;return h.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},h)},updateEdge:f,updateEdgeData:(p,m,h={replace:!1})=>{f(p,g=>{const b=typeof m=="function"?m(g):m;return h.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},h)},getNodesBounds:p=>{const{nodeLookup:m,nodeOrigin:h}=t.getState();return VF(p,{nodeLookup:m,nodeOrigin:h})},getHandleConnections:({type:p,id:m,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}-${p}${m?`-${m}`:""}`)?.values()??[]),getNodeConnections:({type:p,handleId:m,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}${p?m?`-${p}-${m}`:`-${p}`:""}`)?.values()??[]),fitView:async p=>{const m=t.getState().fitViewResolver??ZF();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:m}),n.nodeQueue.push(h=>[...h]),m.promise}}},[]);return Q(()=>({...s,...e,viewportInitialized:o}),[o])}const hf=e=>e.selected,EH=typeof window<"u"?window:void 0;function $H({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=je(),{deleteElements:o}=yd(),s=yo(e,{actInsideInputWithModifier:!1}),a=yo(t,{target:EH});Y(()=>{if(s){const{edges:i,nodes:l}=n.getState();o({nodes:l.filter(hf),edges:i.filter(hf)}),n.setState({nodesSelectionActive:!1})}},[s]),Y(()=>{n.setState({multiSelectionActive:a})},[a])}function _H(e){const t=je();Y(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const o=fd(e.current);(o.height===0||o.width===0)&&t.getState().onError?.("004",Gt.error004()),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);const o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}const Ta={position:"absolute",width:"100%",height:"100%",top:0,left:0},DH=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function LH({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panOnScrollSpeed:s=.5,panOnScrollMode:a=Bn.Free,zoomOnDoubleClick:i=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:d,minZoom:f,maxZoom:p,zoomActivationKeyCode:m,preventScrolling:h=!0,children:g,noWheelClassName:b,noPanClassName:x,onViewportChange:v,isControlledViewport:w,paneClickDistance:y,selectionOnDrag:N}){const k=je(),S=ne(null),{userSelectionActive:M,lib:P,connectionInProgress:I}=$e(DH,Be),F=yo(m),E=ne();_H(S);const B=q(O=>{v?.({x:O[0],y:O[1],zoom:O[2]}),w||k.setState({transform:O})},[v,w]);return Y(()=>{if(S.current){E.current=Lj({domNode:S.current,minZoom:f,maxZoom:p,translateExtent:d,viewport:c,onDraggingChange:_=>k.setState(R=>R.paneDragging===_?R:{paneDragging:_}),onPanZoomStart:(_,R)=>{const{onViewportChangeStart:L,onMoveStart:z}=k.getState();z?.(_,R),L?.(R)},onPanZoom:(_,R)=>{const{onViewportChange:L,onMove:z}=k.getState();z?.(_,R),L?.(R)},onPanZoomEnd:(_,R)=>{const{onViewportChangeEnd:L,onMoveEnd:z}=k.getState();z?.(_,R),L?.(R)}});const{x:O,y:A,zoom:D}=E.current.getViewport();return k.setState({panZoom:E.current,transform:[O,A,D],domNode:S.current.closest(".react-flow")}),()=>{E.current?.destroy()}}},[]),Y(()=>{E.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panOnScrollSpeed:s,panOnScrollMode:a,zoomOnDoubleClick:i,panOnDrag:l,zoomActivationKeyPressed:F,preventScrolling:h,noPanClassName:x,userSelectionActive:M,noWheelClassName:b,lib:P,onTransformChange:B,connectionInProgress:I,selectionOnDrag:N,paneClickDistance:y})},[e,t,n,o,s,a,i,l,F,h,x,M,b,P,B,I,N,y]),r("div",{className:"react-flow__renderer",ref:S,style:Ta,children:g})}const TH=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function RH(){const{userSelectionActive:e,userSelectionRect:t}=$e(TH,Be);return e&&t?r("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Pi=(e,t)=>n=>{n.target===t.current&&e?.(n)},OH=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function zH({isSelecting:e,selectionKeyPressed:t,selectionMode:n=go.Full,panOnDrag:o,paneClickDistance:s,selectionOnDrag:a,onSelectionStart:i,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:d,onPaneScroll:f,onPaneMouseEnter:p,onPaneMouseMove:m,onPaneMouseLeave:h,children:g}){const b=je(),{userSelectionActive:x,elementsSelectable:v,dragging:w,connectionInProgress:y}=$e(OH,Be),N=v&&(e||x),k=ne(null),S=ne(),M=ne(new Set),P=ne(new Set),I=ne(!1),F=L=>{if(I.current||y){I.current=!1;return}c?.(L),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},E=L=>{if(Array.isArray(o)&&o?.includes(2)){L.preventDefault();return}d?.(L)},B=f?L=>f(L):void 0,O=L=>{I.current&&(L.stopPropagation(),I.current=!1)},A=L=>{const{domNode:z}=b.getState();if(S.current=z?.getBoundingClientRect(),!S.current)return;const j=L.target===k.current;if(!j&&!!L.target.closest(".nokey")||!e||!(a&&j||t)||L.button!==0||!L.isPrimary)return;L.target?.setPointerCapture?.(L.pointerId),I.current=!1;const{x:W,y:G}=_t(L.nativeEvent,S.current);b.setState({userSelectionRect:{width:0,height:0,startX:W,startY:G,x:W,y:G}}),j||(L.stopPropagation(),L.preventDefault())},D=L=>{const{userSelectionRect:z,transform:j,nodeLookup:H,edgeLookup:T,connectionLookup:W,triggerNodeChanges:G,triggerEdgeChanges:ee,defaultEdgeOptions:se,resetSelectedElements:te}=b.getState();if(!S.current||!z)return;const{x:X,y:re}=_t(L.nativeEvent,S.current),{startX:ge,startY:Z}=z;if(!I.current){const he=t?0:s;if(Math.hypot(X-ge,re-Z)<=he)return;te(),i?.(L)}I.current=!0;const U={startX:ge,startY:Z,x:X<ge?X:ge,y:re<Z?re:Z,width:Math.abs(X-ge),height:Math.abs(re-Z)},J=M.current,ae=P.current;M.current=new Set(ud(H,U,j,n===go.Partial,!0).map(he=>he.id)),P.current=new Set;const fe=se?.selectable??!0;for(const he of M.current){const V=W.get(he);if(V)for(const{edgeId:ie}of V.values()){const ue=T.get(ie);ue&&(ue.selectable??fe)&&P.current.add(ie)}}if(!Vp(J,M.current)){const he=ir(H,M.current,!0);G(he)}if(!Vp(ae,P.current)){const he=ir(T,P.current);ee(he)}b.setState({userSelectionRect:U,userSelectionActive:!0,nodesSelectionActive:!1})},_=L=>{L.button===0&&(L.target?.releasePointerCapture?.(L.pointerId),!x&&L.target===k.current&&b.getState().userSelectionRect&&F?.(L),b.setState({userSelectionActive:!1,userSelectionRect:null}),I.current&&(l?.(L),b.setState({nodesSelectionActive:M.current.size>0})))},R=o===!0||Array.isArray(o)&&o.includes(0);return u("div",{className:Ue(["react-flow__pane",{draggable:R,dragging:w,selection:e}]),onClick:N?void 0:Pi(F,k),onContextMenu:Pi(E,k),onWheel:Pi(B,k),onPointerEnter:N?void 0:p,onPointerMove:N?D:m,onPointerUp:N?_:void 0,onPointerDownCapture:N?A:void 0,onClickCapture:N?O:void 0,onPointerLeave:h,ref:k,style:Ta,children:[g,r(RH,{})]})}function Ml({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:s,unselectNodesAndEdges:a,multiSelectionActive:i,nodeLookup:l,onError:c}=t.getState(),d=l.get(e);if(!d){c?.("012",Gt.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&i)&&(a({nodes:[d],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):s([e])}function wv({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:s,isSelectable:a,nodeClickDistance:i}){const l=je(),[c,d]=$(!1),f=ne();return Y(()=>{f.current=vj({getStoreItems:()=>l.getState(),onNodeMouseDown:p=>{Ml({id:p,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),Y(()=>{if(!(t||!e.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:a,nodeId:s,nodeClickDistance:i}),()=>{f.current?.destroy()}},[n,o,t,a,e,s,i]),c}const BH=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Nv(){const e=je();return q(n=>{const{nodeExtent:o,snapToGrid:s,snapGrid:a,nodesDraggable:i,onError:l,updateNodePositions:c,nodeLookup:d,nodeOrigin:f}=e.getState(),p=new Map,m=BH(i),h=s?a[0]:5,g=s?a[1]:5,b=n.direction.x*h*n.factor,x=n.direction.y*g*n.factor;for(const[,v]of d){if(!m(v))continue;let w={x:v.internals.positionAbsolute.x+b,y:v.internals.positionAbsolute.y+x};s&&(w=Lo(w,a));const{position:y,positionAbsolute:N}=j0({nodeId:v.id,nextPosition:w,nodeLookup:d,nodeExtent:o,nodeOrigin:f,onError:l});v.position=y,v.internals.positionAbsolute=N,p.set(v.id,v)}c(p)},[])}const vd=Oe(null),FH=vd.Provider;vd.Consumer;const kv=()=>ye(vd),jH=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),HH=(e,t,n)=>o=>{const{connectionClickStartHandle:s,connectionMode:a,connection:i}=o,{fromHandle:l,toHandle:c,isValid:d}=i,f=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:l?.nodeId===e&&l?.id===t&&l?.type===n,connectingTo:f,clickConnecting:s?.nodeId===e&&s?.id===t&&s?.type===n,isPossibleEndHandle:a===Nr.Strict?l?.type!==n:e!==l?.nodeId||t!==l?.id,connectionInProcess:!!l,clickConnectionInProcess:!!s,valid:f&&d}};function VH({type:e="source",position:t=we.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:s=!0,isConnectableEnd:a=!0,id:i,onConnect:l,children:c,className:d,onMouseDown:f,onTouchStart:p,...m},h){const g=i||null,b=e==="target",x=je(),v=kv(),{connectOnClick:w,noPanClassName:y,rfId:N}=$e(jH,Be),{connectingFrom:k,connectingTo:S,clickConnecting:M,isPossibleEndHandle:P,connectionInProcess:I,clickConnectionInProcess:F,valid:E}=$e(HH(v,g,e),Be);v||x.getState().onError?.("010",Gt.error010());const B=D=>{const{defaultEdgeOptions:_,onConnect:R,hasDefaultEdges:L}=x.getState(),z={..._,...D};if(L){const{edges:j,setEdges:H}=x.getState();H(oj(z,j))}R?.(z),l?.(z)},O=D=>{if(!v)return;const _=W0(D.nativeEvent);if(s&&(_&&D.button===0||!_)){const R=x.getState();Sl.onPointerDown(D.nativeEvent,{handleDomNode:D.currentTarget,autoPanOnConnect:R.autoPanOnConnect,connectionMode:R.connectionMode,connectionRadius:R.connectionRadius,domNode:R.domNode,nodeLookup:R.nodeLookup,lib:R.lib,isTarget:b,handleId:g,nodeId:v,flowId:R.rfId,panBy:R.panBy,cancelConnection:R.cancelConnection,onConnectStart:R.onConnectStart,onConnectEnd:(...L)=>x.getState().onConnectEnd?.(...L),updateConnection:R.updateConnection,onConnect:B,isValidConnection:n||((...L)=>x.getState().isValidConnection?.(...L)??!0),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:R.autoPanSpeed,dragThreshold:R.connectionDragThreshold})}_?f?.(D):p?.(D)},A=D=>{const{onClickConnectStart:_,onClickConnectEnd:R,connectionClickStartHandle:L,connectionMode:z,isValidConnection:j,lib:H,rfId:T,nodeLookup:W,connection:G}=x.getState();if(!v||!L&&!s)return;if(!L){_?.(D.nativeEvent,{nodeId:v,handleId:g,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:v,type:e,id:g}});return}const ee=K0(D.target),se=n||j,{connection:te,isValid:X}=Sl.isValid(D.nativeEvent,{handle:{nodeId:v,id:g,type:e},connectionMode:z,fromNodeId:L.nodeId,fromHandleId:L.id||null,fromType:L.type,isValidConnection:se,flowId:T,doc:ee,lib:H,nodeLookup:W});X&&te&&B(te);const re=structuredClone(G);delete re.inProgress,re.toPosition=re.toHandle?re.toHandle.position:null,R?.(D,re),x.setState({connectionClickStartHandle:null})};return r("div",{"data-handleid":g,"data-nodeid":v,"data-handlepos":t,"data-id":`${N}-${v}-${g}-${e}`,className:Ue(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",y,d,{source:!b,target:b,connectable:o,connectablestart:s,connectableend:a,clickconnecting:M,connectingfrom:k,connectingto:S,valid:E,connectionindicator:o&&(!I||P)&&(I||F?a:s)}]),onMouseDown:O,onTouchStart:O,onClick:w?A:void 0,ref:h,...m,children:c})}const kn=Fe(yv(VH));function qH({data:e,isConnectable:t,sourcePosition:n=we.Bottom}){return u(ve,{children:[e?.label,r(kn,{type:"source",position:n,isConnectable:t})]})}function QH({data:e,isConnectable:t,targetPosition:n=we.Top,sourcePosition:o=we.Bottom}){return u(ve,{children:[r(kn,{type:"target",position:n,isConnectable:t}),e?.label,r(kn,{type:"source",position:o,isConnectable:t})]})}function UH(){return null}function KH({data:e,isConnectable:t,targetPosition:n=we.Top}){return u(ve,{children:[r(kn,{type:"target",position:n,isConnectable:t}),e?.label]})}const Ks={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},gf={input:qH,default:QH,output:KH,group:UH};function GH(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const WH=e=>{const{width:t,height:n,x:o,y:s}=Do(e.nodeLookup,{filter:a=>!!a.selected});return{width:$t(t)?t:null,height:$t(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${s}px)`}};function YH({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=je(),{width:s,height:a,transformString:i,userSelectionActive:l}=$e(WH,Be),c=Nv(),d=ne(null);Y(()=>{n||d.current?.focus({preventScroll:!0})},[n]);const f=!l&&s!==null&&a!==null;if(wv({nodeRef:d,disabled:!f}),!f)return null;const p=e?h=>{const g=o.getState().nodes.filter(b=>b.selected);e(h,g)}:void 0,m=h=>{Object.prototype.hasOwnProperty.call(Ks,h.key)&&(h.preventDefault(),c({direction:Ks[h.key],factor:h.shiftKey?4:1}))};return r("div",{className:Ue(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:r("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:m,style:{width:s,height:a}})})}const bf=typeof window<"u"?window:void 0,ZH=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Sv({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:i,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:d,selectionOnDrag:f,selectionMode:p,onSelectionStart:m,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:b,zoomActivationKeyCode:x,elementsSelectable:v,zoomOnScroll:w,zoomOnPinch:y,panOnScroll:N,panOnScrollSpeed:k,panOnScrollMode:S,zoomOnDoubleClick:M,panOnDrag:P,defaultViewport:I,translateExtent:F,minZoom:E,maxZoom:B,preventScrolling:O,onSelectionContextMenu:A,noWheelClassName:D,noPanClassName:_,disableKeyboardA11y:R,onViewportChange:L,isControlledViewport:z}){const{nodesSelectionActive:j,userSelectionActive:H}=$e(ZH,Be),T=yo(d,{target:bf}),W=yo(b,{target:bf}),G=W||P,ee=W||N,se=f&&G!==!0,te=T||H||se;return $H({deleteKeyCode:c,multiSelectionKeyCode:g}),r(LH,{onPaneContextMenu:a,elementsSelectable:v,zoomOnScroll:w,zoomOnPinch:y,panOnScroll:ee,panOnScrollSpeed:k,panOnScrollMode:S,zoomOnDoubleClick:M,panOnDrag:!T&&G,defaultViewport:I,translateExtent:F,minZoom:E,maxZoom:B,zoomActivationKeyCode:x,preventScrolling:O,noWheelClassName:D,noPanClassName:_,onViewportChange:L,isControlledViewport:z,paneClickDistance:l,selectionOnDrag:se,children:u(zH,{onSelectionStart:m,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:i,panOnDrag:G,isSelecting:!!te,selectionMode:p,selectionKeyPressed:T,paneClickDistance:l,selectionOnDrag:se,children:[e,j&&r(YH,{onSelectionContextMenu:A,noPanClassName:_,disableKeyboardA11y:R})]})})}Sv.displayName="FlowRenderer";const XH=Fe(Sv),JH=e=>t=>e?ud(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function eV(e){return $e(q(JH(e),[e]),Be)}const tV=e=>e.updateNodeInternals;function nV(){const e=$e(tV),[t]=$(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const o=new Map;n.forEach(s=>{const a=s.target.getAttribute("data-id");o.set(a,{id:a,nodeElement:s.target,force:!0})}),e(o)}));return Y(()=>()=>{t?.disconnect()},[t]),t}function rV({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const s=je(),a=ne(null),i=ne(null),l=ne(e.sourcePosition),c=ne(e.targetPosition),d=ne(t),f=n&&!!e.internals.handleBounds;return Y(()=>{a.current&&!e.hidden&&(!f||i.current!==a.current)&&(i.current&&o?.unobserve(i.current),o?.observe(a.current),i.current=a.current)},[f,e.hidden]),Y(()=>()=>{i.current&&(o?.unobserve(i.current),i.current=null)},[]),Y(()=>{if(a.current){const p=d.current!==t,m=l.current!==e.sourcePosition,h=c.current!==e.targetPosition;(p||m||h)&&(d.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function oV({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:s,onContextMenu:a,onDoubleClick:i,nodesDraggable:l,elementsSelectable:c,nodesConnectable:d,nodesFocusable:f,resizeObserver:p,noDragClassName:m,noPanClassName:h,disableKeyboardA11y:g,rfId:b,nodeTypes:x,nodeClickDistance:v,onError:w}){const{node:y,internals:N,isParent:k}=$e(X=>{const re=X.nodeLookup.get(e),ge=X.parentLookup.has(e);return{node:re,internals:re.internals,isParent:ge}},Be);let S=y.type||"default",M=x?.[S]||gf[S];M===void 0&&(w?.("003",Gt.error003(S)),S="default",M=x?.default||gf.default);const P=!!(y.draggable||l&&typeof y.draggable>"u"),I=!!(y.selectable||c&&typeof y.selectable>"u"),F=!!(y.connectable||d&&typeof y.connectable>"u"),E=!!(y.focusable||f&&typeof y.focusable>"u"),B=je(),O=Q0(y),A=rV({node:y,nodeType:S,hasDimensions:O,resizeObserver:p}),D=wv({nodeRef:A,disabled:y.hidden||!P,noDragClassName:m,handleSelector:y.dragHandle,nodeId:e,isSelectable:I,nodeClickDistance:v}),_=Nv();if(y.hidden)return null;const R=fn(y),L=GH(y),z=I||P||t||n||o||s,j=n?X=>n(X,{...N.userNode}):void 0,H=o?X=>o(X,{...N.userNode}):void 0,T=s?X=>s(X,{...N.userNode}):void 0,W=a?X=>a(X,{...N.userNode}):void 0,G=i?X=>i(X,{...N.userNode}):void 0,ee=X=>{const{selectNodesOnDrag:re,nodeDragThreshold:ge}=B.getState();I&&(!re||!P||ge>0)&&Ml({id:e,store:B,nodeRef:A}),t&&t(X,{...N.userNode})},se=X=>{if(!(G0(X.nativeEvent)||g)){if(R0.includes(X.key)&&I){const re=X.key==="Escape";Ml({id:e,store:B,unselect:re,nodeRef:A})}else if(P&&y.selected&&Object.prototype.hasOwnProperty.call(Ks,X.key)){X.preventDefault();const{ariaLabelConfig:re}=B.getState();B.setState({ariaLiveMessage:re["node.a11yDescription.ariaLiveMessage"]({direction:X.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),_({direction:Ks[X.key],factor:X.shiftKey?4:1})}}},te=()=>{if(g||!A.current?.matches(":focus-visible"))return;const{transform:X,width:re,height:ge,autoPanOnNodeFocus:Z,setCenter:U}=B.getState();if(!Z)return;ud(new Map([[e,y]]),{x:0,y:0,width:re,height:ge},X,!0).length>0||U(y.position.x+R.width/2,y.position.y+R.height/2,{zoom:X[2]})};return r("div",{className:Ue(["react-flow__node",`react-flow__node-${S}`,{[h]:P},y.className,{selected:y.selected,selectable:I,parent:k,draggable:P,dragging:D}]),ref:A,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:z?"all":"none",visibility:O?"visible":"hidden",...y.style,...L},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:j,onMouseMove:H,onMouseLeave:T,onContextMenu:W,onClick:ee,onDoubleClick:G,onKeyDown:E?se:void 0,tabIndex:E?0:void 0,onFocus:E?te:void 0,role:y.ariaRole??(E?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${hv}-${b}`,"aria-label":y.ariaLabel,...y.domAttributes,children:r(FH,{value:e,children:r(M,{id:e,data:y.data,type:S,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:y.selected??!1,selectable:I,draggable:P,deletable:y.deletable??!0,isConnectable:F,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:D,dragHandle:y.dragHandle,zIndex:N.z,parentId:y.parentId,...R})})})}var sV=Fe(oV);const aV=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Cv(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:s,onError:a}=$e(aV,Be),i=eV(e.onlyRenderVisibleElements),l=nV();return r("div",{className:"react-flow__nodes",style:Ta,children:i.map(c=>r(sV,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:a},c))})}Cv.displayName="NodeRenderer";const iV=Fe(Cv);function lV(e){return $e(q(n=>{if(!e)return n.edges.map(s=>s.id);const o=[];if(n.width&&n.height)for(const s of n.edges){const a=n.nodeLookup.get(s.source),i=n.nodeLookup.get(s.target);a&&i&&tj({sourceNode:a,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&o.push(s.id)}return o},[e]),Be)}const cV=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return r("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},dV=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return r("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},xf={[qs.Arrow]:cV,[qs.ArrowClosed]:dV};function uV(e){const t=je();return Q(()=>Object.prototype.hasOwnProperty.call(xf,e)?xf[e]:(t.getState().onError?.("009",Gt.error009(e)),null),[e])}const pV=({id:e,type:t,color:n,width:o=12.5,height:s=12.5,markerUnits:a="strokeWidth",strokeWidth:i,orient:l="auto-start-reverse"})=>{const c=uV(t);return c?r("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:l,refX:"0",refY:"0",children:r(c,{color:n,strokeWidth:i})}):null},Mv=({defaultColor:e,rfId:t})=>{const n=$e(a=>a.edges),o=$e(a=>a.defaultEdgeOptions),s=Q(()=>cj(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return s.length?r("svg",{className:"react-flow__marker","aria-hidden":"true",children:r("defs",{children:s.map(a=>r(pV,{id:a.id,type:a.type,color:a.color,width:a.width,height:a.height,markerUnits:a.markerUnits,strokeWidth:a.strokeWidth,orient:a.orient},a.id))})}):null};Mv.displayName="MarkerDefinitions";var fV=Fe(Mv);function Iv({x:e,y:t,label:n,labelStyle:o,labelShowBg:s=!0,labelBgStyle:a,labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...f}){const[p,m]=$({x:1,y:0,width:0,height:0}),h=Ue(["react-flow__edge-textwrapper",d]),g=ne(null);return Y(()=>{if(g.current){const b=g.current.getBBox();m({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?u("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:h,visibility:p.width?"visible":"hidden",...f,children:[s&&r("rect",{width:p.width+2*i[0],x:-i[0],y:-i[1],height:p.height+2*i[1],className:"react-flow__edge-textbg",style:a,rx:l,ry:l}),r("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:g,style:o,children:n}),c]}):null}Iv.displayName="EdgeText";const mV=Fe(Iv);function Ra({path:e,labelX:t,labelY:n,label:o,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:d=20,...f}){return u(ve,{children:[r("path",{...f,d:e,fill:"none",className:Ue(["react-flow__edge-path",f.className])}),d?r("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,o&&$t(t)&&$t(n)?r(mV,{x:t,y:n,label:o,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function yf({pos:e,x1:t,y1:n,x2:o,y2:s}){return e===we.Left||e===we.Right?[.5*(t+o),n]:[t,.5*(n+s)]}function Av({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:o,targetY:s,targetPosition:a=we.Top}){const[i,l]=yf({pos:n,x1:e,y1:t,x2:o,y2:s}),[c,d]=yf({pos:a,x1:o,y1:s,x2:e,y2:t}),[f,p,m,h]=Y0({sourceX:e,sourceY:t,targetX:o,targetY:s,sourceControlX:i,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${i},${l} ${c},${d} ${o},${s}`,f,p,m,h]}function Pv(e){return Fe(({id:t,sourceX:n,sourceY:o,targetX:s,targetY:a,sourcePosition:i,targetPosition:l,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:x,interactionWidth:v})=>{const[w,y,N]=Av({sourceX:n,sourceY:o,sourcePosition:i,targetX:s,targetY:a,targetPosition:l}),k=e.isInternal?void 0:t;return r(Ra,{id:k,path:w,labelX:y,labelY:N,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:x,interactionWidth:v})})}const hV=Pv({isInternal:!1}),Ev=Pv({isInternal:!0});hV.displayName="SimpleBezierEdge";Ev.displayName="SimpleBezierEdgeInternal";function $v(e){return Fe(({id:t,sourceX:n,sourceY:o,targetX:s,targetY:a,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,sourcePosition:h=we.Bottom,targetPosition:g=we.Top,markerEnd:b,markerStart:x,pathOptions:v,interactionWidth:w})=>{const[y,N,k]=wl({sourceX:n,sourceY:o,sourcePosition:h,targetX:s,targetY:a,targetPosition:g,borderRadius:v?.borderRadius,offset:v?.offset,stepPosition:v?.stepPosition}),S=e.isInternal?void 0:t;return r(Ra,{id:S,path:y,labelX:N,labelY:k,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:b,markerStart:x,interactionWidth:w})})}const _v=$v({isInternal:!1}),Dv=$v({isInternal:!0});_v.displayName="SmoothStepEdge";Dv.displayName="SmoothStepEdgeInternal";function Lv(e){return Fe(({id:t,...n})=>{const o=e.isInternal?void 0:t;return r(_v,{...n,id:o,pathOptions:Q(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const gV=Lv({isInternal:!1}),Tv=Lv({isInternal:!0});gV.displayName="StepEdge";Tv.displayName="StepEdgeInternal";function Rv(e){return Fe(({id:t,sourceX:n,sourceY:o,targetX:s,targetY:a,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:b})=>{const[x,v,w]=J0({sourceX:n,sourceY:o,targetX:s,targetY:a}),y=e.isInternal?void 0:t;return r(Ra,{id:y,path:x,labelX:v,labelY:w,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:b})})}const bV=Rv({isInternal:!1}),Ov=Rv({isInternal:!0});bV.displayName="StraightEdge";Ov.displayName="StraightEdgeInternal";function zv(e){return Fe(({id:t,sourceX:n,sourceY:o,targetX:s,targetY:a,sourcePosition:i=we.Bottom,targetPosition:l=we.Top,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:x,pathOptions:v,interactionWidth:w})=>{const[y,N,k]=Z0({sourceX:n,sourceY:o,sourcePosition:i,targetX:s,targetY:a,targetPosition:l,curvature:v?.curvature}),S=e.isInternal?void 0:t;return r(Ra,{id:S,path:y,labelX:N,labelY:k,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:x,interactionWidth:w})})}const xV=zv({isInternal:!1}),Bv=zv({isInternal:!0});xV.displayName="BezierEdge";Bv.displayName="BezierEdgeInternal";const vf={default:Bv,straight:Ov,step:Tv,smoothstep:Dv,simplebezier:Ev},wf={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},yV=(e,t,n)=>n===we.Left?e-t:n===we.Right?e+t:e,vV=(e,t,n)=>n===we.Top?e-t:n===we.Bottom?e+t:e,Nf="react-flow__edgeupdater";function kf({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:s,onMouseEnter:a,onMouseOut:i,type:l}){return r("circle",{onMouseDown:s,onMouseEnter:a,onMouseOut:i,className:Ue([Nf,`${Nf}-${l}`]),cx:yV(t,o,e),cy:vV(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function wV({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:s,targetX:a,targetY:i,sourcePosition:l,targetPosition:c,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,setReconnecting:m,setUpdateHover:h}){const g=je(),b=(N,k)=>{if(N.button!==0)return;const{autoPanOnConnect:S,domNode:M,connectionMode:P,connectionRadius:I,lib:F,onConnectStart:E,cancelConnection:B,nodeLookup:O,rfId:A,panBy:D,updateConnection:_}=g.getState(),R=k.type==="target",L=(H,T)=>{m(!1),p?.(H,n,k.type,T)},z=H=>d?.(n,H),j=(H,T)=>{m(!0),f?.(N,n,k.type),E?.(H,T)};Sl.onPointerDown(N.nativeEvent,{autoPanOnConnect:S,connectionMode:P,connectionRadius:I,domNode:M,handleId:k.id,nodeId:k.nodeId,nodeLookup:O,isTarget:R,edgeUpdaterType:k.type,lib:F,flowId:A,cancelConnection:B,panBy:D,isValidConnection:(...H)=>g.getState().isValidConnection?.(...H)??!0,onConnect:z,onConnectStart:j,onConnectEnd:(...H)=>g.getState().onConnectEnd?.(...H),onReconnectEnd:L,updateConnection:_,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},x=N=>b(N,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),v=N=>b(N,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),w=()=>h(!0),y=()=>h(!1);return u(ve,{children:[(e===!0||e==="source")&&r(kf,{position:l,centerX:o,centerY:s,radius:t,onMouseDown:x,onMouseEnter:w,onMouseOut:y,type:"source"}),(e===!0||e==="target")&&r(kf,{position:c,centerX:a,centerY:i,radius:t,onMouseDown:v,onMouseEnter:w,onMouseOut:y,type:"target"})]})}function NV({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:s,onDoubleClick:a,onContextMenu:i,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,reconnectRadius:f,onReconnect:p,onReconnectStart:m,onReconnectEnd:h,rfId:g,edgeTypes:b,noPanClassName:x,onError:v,disableKeyboardA11y:w}){let y=$e(U=>U.edgeLookup.get(e));const N=$e(U=>U.defaultEdgeOptions);y=N?{...N,...y}:y;let k=y.type||"default",S=b?.[k]||vf[k];S===void 0&&(v?.("011",Gt.error011(k)),k="default",S=b?.default||vf.default);const M=!!(y.focusable||t&&typeof y.focusable>"u"),P=typeof p<"u"&&(y.reconnectable||n&&typeof y.reconnectable>"u"),I=!!(y.selectable||o&&typeof y.selectable>"u"),F=ne(null),[E,B]=$(!1),[O,A]=$(!1),D=je(),{zIndex:_,sourceX:R,sourceY:L,targetX:z,targetY:j,sourcePosition:H,targetPosition:T}=$e(q(U=>{const J=U.nodeLookup.get(y.source),ae=U.nodeLookup.get(y.target);if(!J||!ae)return{zIndex:y.zIndex,...wf};const fe=lj({id:e,sourceNode:J,targetNode:ae,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:U.connectionMode,onError:v});return{zIndex:ej({selected:y.selected,zIndex:y.zIndex,sourceNode:J,targetNode:ae,elevateOnSelect:U.elevateEdgesOnSelect,zIndexMode:U.zIndexMode}),...fe||wf}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),Be),W=Q(()=>y.markerStart?`url('#${Nl(y.markerStart,g)}')`:void 0,[y.markerStart,g]),G=Q(()=>y.markerEnd?`url('#${Nl(y.markerEnd,g)}')`:void 0,[y.markerEnd,g]);if(y.hidden||R===null||L===null||z===null||j===null)return null;const ee=U=>{const{addSelectedEdges:J,unselectNodesAndEdges:ae,multiSelectionActive:fe}=D.getState();I&&(D.setState({nodesSelectionActive:!1}),y.selected&&fe?(ae({nodes:[],edges:[y]}),F.current?.blur()):J([e])),s&&s(U,y)},se=a?U=>{a(U,{...y})}:void 0,te=i?U=>{i(U,{...y})}:void 0,X=l?U=>{l(U,{...y})}:void 0,re=c?U=>{c(U,{...y})}:void 0,ge=d?U=>{d(U,{...y})}:void 0,Z=U=>{if(!w&&R0.includes(U.key)&&I){const{unselectNodesAndEdges:J,addSelectedEdges:ae}=D.getState();U.key==="Escape"?(F.current?.blur(),J({edges:[y]})):ae([e])}};return r("svg",{style:{zIndex:_},children:u("g",{className:Ue(["react-flow__edge",`react-flow__edge-${k}`,y.className,x,{selected:y.selected,animated:y.animated,inactive:!I&&!s,updating:E,selectable:I}]),onClick:ee,onDoubleClick:se,onContextMenu:te,onMouseEnter:X,onMouseMove:re,onMouseLeave:ge,onKeyDown:M?Z:void 0,tabIndex:M?0:void 0,role:y.ariaRole??(M?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":M?`${gv}-${g}`:void 0,ref:F,...y.domAttributes,children:[!O&&r(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:I,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:R,sourceY:L,targetX:z,targetY:j,sourcePosition:H,targetPosition:T,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:W,markerEnd:G,pathOptions:"pathOptions"in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),P&&r(wV,{edge:y,isReconnectable:P,reconnectRadius:f,onReconnect:p,onReconnectStart:m,onReconnectEnd:h,sourceX:R,sourceY:L,targetX:z,targetY:j,sourcePosition:H,targetPosition:T,setUpdateHover:B,setReconnecting:A})]})})}var kV=Fe(NV);const SV=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Fv({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:s,onReconnect:a,onEdgeContextMenu:i,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeClick:f,reconnectRadius:p,onEdgeDoubleClick:m,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:b}){const{edgesFocusable:x,edgesReconnectable:v,elementsSelectable:w,onError:y}=$e(SV,Be),N=lV(t);return u("div",{className:"react-flow__edges",children:[r(fV,{defaultColor:e,rfId:n}),N.map(k=>r(kV,{id:k,edgesFocusable:x,edgesReconnectable:v,elementsSelectable:w,noPanClassName:s,onReconnect:a,onContextMenu:i,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onClick:f,reconnectRadius:p,onDoubleClick:m,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:y,edgeTypes:o,disableKeyboardA11y:b},k))]})}Fv.displayName="EdgeRenderer";const CV=Fe(Fv),MV=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function IV({children:e}){const t=$e(MV);return r("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function AV(e){const t=yd(),n=ne(!1);Y(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const PV=e=>e.panZoom?.syncViewport;function EV(e){const t=$e(PV),n=je();return Y(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function $V(e){return e.connection.inProgress?{...e.connection,to:To(e.connection.to,e.transform)}:{...e.connection}}function _V(e){return $V}function DV(e){const t=_V();return $e(t,Be)}const LV=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function TV({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:s,width:a,height:i,isValid:l,inProgress:c}=$e(LV,Be);return!(a&&s&&c)?null:r("svg",{style:e,width:a,height:i,className:"react-flow__connectionline react-flow__container",children:r("g",{className:Ue(["react-flow__connection",B0(l)]),children:r(jv,{style:t,type:n,CustomComponent:o,isValid:l})})})}const jv=({style:e,type:t=xn.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:s,from:a,fromNode:i,fromHandle:l,fromPosition:c,to:d,toNode:f,toHandle:p,toPosition:m,pointer:h}=DV();if(!s)return;if(n)return r(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:l,fromX:a.x,fromY:a.y,toX:d.x,toY:d.y,fromPosition:c,toPosition:m,connectionStatus:B0(o),toNode:f,toHandle:p,pointer:h});let g="";const b={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:d.x,targetY:d.y,targetPosition:m};switch(t){case xn.Bezier:[g]=Z0(b);break;case xn.SimpleBezier:[g]=Av(b);break;case xn.Step:[g]=wl({...b,borderRadius:0});break;case xn.SmoothStep:[g]=wl(b);break;default:[g]=J0(b)}return r("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};jv.displayName="ConnectionLine";const RV={};function Sf(e=RV){ne(e),je(),Y(()=>{},[e])}function OV(){je(),ne(!1),Y(()=>{},[])}function Hv({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:s,onNodeDoubleClick:a,onEdgeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,onSelectionContextMenu:p,onSelectionStart:m,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:b,connectionLineComponent:x,connectionLineContainerStyle:v,selectionKeyCode:w,selectionOnDrag:y,selectionMode:N,multiSelectionKeyCode:k,panActivationKeyCode:S,zoomActivationKeyCode:M,deleteKeyCode:P,onlyRenderVisibleElements:I,elementsSelectable:F,defaultViewport:E,translateExtent:B,minZoom:O,maxZoom:A,preventScrolling:D,defaultMarkerColor:_,zoomOnScroll:R,zoomOnPinch:L,panOnScroll:z,panOnScrollSpeed:j,panOnScrollMode:H,zoomOnDoubleClick:T,panOnDrag:W,onPaneClick:G,onPaneMouseEnter:ee,onPaneMouseMove:se,onPaneMouseLeave:te,onPaneScroll:X,onPaneContextMenu:re,paneClickDistance:ge,nodeClickDistance:Z,onEdgeContextMenu:U,onEdgeMouseEnter:J,onEdgeMouseMove:ae,onEdgeMouseLeave:fe,reconnectRadius:he,onReconnect:V,onReconnectStart:ie,onReconnectEnd:ue,noDragClassName:de,noWheelClassName:le,noPanClassName:Se,disableKeyboardA11y:pe,nodeExtent:Ie,rfId:Te,viewport:Ye,onViewportChange:ot}){return Sf(e),Sf(t),OV(),AV(n),EV(Ye),r(XH,{onPaneClick:G,onPaneMouseEnter:ee,onPaneMouseMove:se,onPaneMouseLeave:te,onPaneContextMenu:re,onPaneScroll:X,paneClickDistance:ge,deleteKeyCode:P,selectionKeyCode:w,selectionOnDrag:y,selectionMode:N,onSelectionStart:m,onSelectionEnd:h,multiSelectionKeyCode:k,panActivationKeyCode:S,zoomActivationKeyCode:M,elementsSelectable:F,zoomOnScroll:R,zoomOnPinch:L,zoomOnDoubleClick:T,panOnScroll:z,panOnScrollSpeed:j,panOnScrollMode:H,panOnDrag:W,defaultViewport:E,translateExtent:B,minZoom:O,maxZoom:A,onSelectionContextMenu:p,preventScrolling:D,noDragClassName:de,noWheelClassName:le,noPanClassName:Se,disableKeyboardA11y:pe,onViewportChange:ot,isControlledViewport:!!Ye,children:u(IV,{children:[r(CV,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:i,onReconnect:V,onReconnectStart:ie,onReconnectEnd:ue,onlyRenderVisibleElements:I,onEdgeContextMenu:U,onEdgeMouseEnter:J,onEdgeMouseMove:ae,onEdgeMouseLeave:fe,reconnectRadius:he,defaultMarkerColor:_,noPanClassName:Se,disableKeyboardA11y:pe,rfId:Te}),r(TV,{style:b,type:g,component:x,containerStyle:v}),r("div",{className:"react-flow__edgelabel-renderer"}),r(iV,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,nodeClickDistance:Z,onlyRenderVisibleElements:I,noPanClassName:Se,noDragClassName:de,disableKeyboardA11y:pe,nodeExtent:Ie,rfId:Te}),r("div",{className:"react-flow__viewport-portal"})]})})}Hv.displayName="GraphView";const zV=Fe(Hv),Cf=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c=.5,maxZoom:d=2,nodeOrigin:f,nodeExtent:p,zIndexMode:m="basic"}={})=>{const h=new Map,g=new Map,b=new Map,x=new Map,v=o??t??[],w=n??e??[],y=f??[0,0],N=p??ho;nv(b,x,v);const{nodesInitialized:k}=kl(w,h,g,{nodeOrigin:y,nodeExtent:N,zIndexMode:m});let S=[0,0,1];if(i&&s&&a){const M=Do(h,{filter:E=>!!((E.width||E.initialWidth)&&(E.height||E.initialHeight))}),{x:P,y:I,zoom:F}=pd(M,s,a,c,d,l?.padding??.1);S=[P,I,F]}return{rfId:"1",width:s??0,height:a??0,transform:S,nodes:w,nodesInitialized:k,nodeLookup:h,parentLookup:g,edges:v,edgeLookup:x,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:c,maxZoom:d,translateExtent:ho,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Nr.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:i??!1,fitViewOptions:l,fitViewResolver:null,connection:{...z0},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:GF,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:O0,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},BV=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:p,zIndexMode:m})=>nH((h,g)=>{async function b(){const{nodeLookup:x,panZoom:v,fitViewOptions:w,fitViewResolver:y,width:N,height:k,minZoom:S,maxZoom:M}=g();v&&(await UF({nodes:x,width:N,height:k,panZoom:v,minZoom:S,maxZoom:M},w),y?.resolve(!0),h({fitViewResolver:null}))}return{...Cf({nodes:e,edges:t,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:p,defaultNodes:n,defaultEdges:o,zIndexMode:m}),setNodes:x=>{const{nodeLookup:v,parentLookup:w,nodeOrigin:y,elevateNodesOnSelect:N,fitViewQueued:k,zIndexMode:S,nodesSelectionActive:M}=g(),{nodesInitialized:P,hasSelectedNodes:I}=kl(x,v,w,{nodeOrigin:y,nodeExtent:p,elevateNodesOnSelect:N,checkEquality:!0,zIndexMode:S}),F=M&&I;k&&P?(b(),h({nodes:x,nodesInitialized:P,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:F})):h({nodes:x,nodesInitialized:P,nodesSelectionActive:F})},setEdges:x=>{const{connectionLookup:v,edgeLookup:w}=g();nv(v,w,x),h({edges:x})},setDefaultNodesAndEdges:(x,v)=>{if(x){const{setNodes:w}=g();w(x),h({hasDefaultNodes:!0})}if(v){const{setEdges:w}=g();w(v),h({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:v,nodeLookup:w,parentLookup:y,domNode:N,nodeOrigin:k,nodeExtent:S,debug:M,fitViewQueued:P,zIndexMode:I}=g(),{changes:F,updatedInternals:E}=gj(x,w,y,N,k,S,I);E&&(pj(w,y,{nodeOrigin:k,nodeExtent:S,zIndexMode:I}),P?(b(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),F?.length>0&&(M&&console.log("React Flow: trigger node changes",F),v?.(F)))},updateNodePositions:(x,v=!1)=>{const w=[];let y=[];const{nodeLookup:N,triggerNodeChanges:k,connection:S,updateConnection:M,onNodesChangeMiddlewareMap:P}=g();for(const[I,F]of x){const E=N.get(I),B=!!(E?.expandParent&&E?.parentId&&F?.position),O={id:I,type:"position",position:B?{x:Math.max(0,F.position.x),y:Math.max(0,F.position.y)}:F.position,dragging:v};if(E&&S.inProgress&&S.fromNode.id===E.id){const A=Un(E,S.fromHandle,we.Left,!0);M({...S,from:A})}B&&E.parentId&&w.push({id:I,parentId:E.parentId,rect:{...F.internals.positionAbsolute,width:F.measured.width??0,height:F.measured.height??0}}),y.push(O)}if(w.length>0){const{parentLookup:I,nodeOrigin:F}=g(),E=xd(w,N,I,F);y.push(...E)}for(const I of P.values())y=I(y);k(y)},triggerNodeChanges:x=>{const{onNodesChange:v,setNodes:w,nodes:y,hasDefaultNodes:N,debug:k}=g();if(x?.length){if(N){const S=kH(x,y);w(S)}k&&console.log("React Flow: trigger node changes",x),v?.(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:v,setEdges:w,edges:y,hasDefaultEdges:N,debug:k}=g();if(x?.length){if(N){const S=SH(x,y);w(S)}k&&console.log("React Flow: trigger edge changes",x),v?.(x)}},addSelectedNodes:x=>{const{multiSelectionActive:v,edgeLookup:w,nodeLookup:y,triggerNodeChanges:N,triggerEdgeChanges:k}=g();if(v){const S=x.map(M=>Ln(M,!0));N(S);return}N(ir(y,new Set([...x]),!0)),k(ir(w))},addSelectedEdges:x=>{const{multiSelectionActive:v,edgeLookup:w,nodeLookup:y,triggerNodeChanges:N,triggerEdgeChanges:k}=g();if(v){const S=x.map(M=>Ln(M,!0));k(S);return}k(ir(w,new Set([...x]))),N(ir(y,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:v}={})=>{const{edges:w,nodes:y,nodeLookup:N,triggerNodeChanges:k,triggerEdgeChanges:S}=g(),M=x||y,P=v||w,I=[];for(const E of M){if(!E.selected)continue;const B=N.get(E.id);B&&(B.selected=!1),I.push(Ln(E.id,!1))}const F=[];for(const E of P)E.selected&&F.push(Ln(E.id,!1));k(I),S(F)},setMinZoom:x=>{const{panZoom:v,maxZoom:w}=g();v?.setScaleExtent([x,w]),h({minZoom:x})},setMaxZoom:x=>{const{panZoom:v,minZoom:w}=g();v?.setScaleExtent([w,x]),h({maxZoom:x})},setTranslateExtent:x=>{g().panZoom?.setTranslateExtent(x),h({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:v,triggerNodeChanges:w,triggerEdgeChanges:y,elementsSelectable:N}=g();if(!N)return;const k=v.reduce((M,P)=>P.selected?[...M,Ln(P.id,!1)]:M,[]),S=x.reduce((M,P)=>P.selected?[...M,Ln(P.id,!1)]:M,[]);w(k),y(S)},setNodeExtent:x=>{const{nodes:v,nodeLookup:w,parentLookup:y,nodeOrigin:N,elevateNodesOnSelect:k,nodeExtent:S,zIndexMode:M}=g();x[0][0]===S[0][0]&&x[0][1]===S[0][1]&&x[1][0]===S[1][0]&&x[1][1]===S[1][1]||(kl(v,w,y,{nodeOrigin:N,nodeExtent:x,elevateNodesOnSelect:k,checkEquality:!1,zIndexMode:M}),h({nodeExtent:x}))},panBy:x=>{const{transform:v,width:w,height:y,panZoom:N,translateExtent:k}=g();return bj({delta:x,panZoom:N,transform:v,translateExtent:k,width:w,height:y})},setCenter:async(x,v,w)=>{const{width:y,height:N,maxZoom:k,panZoom:S}=g();if(!S)return Promise.resolve(!1);const M=typeof w?.zoom<"u"?w.zoom:k;return await S.setViewport({x:y/2-x*M,y:N/2-v*M,zoom:M},{duration:w?.duration,ease:w?.ease,interpolate:w?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...z0}})},updateConnection:x=>{h({connection:x})},reset:()=>h({...Cf()})}},Object.is);function FV({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:s,initialHeight:a,initialMinZoom:i,initialMaxZoom:l,initialFitViewOptions:c,fitView:d,nodeOrigin:f,nodeExtent:p,zIndexMode:m,children:h}){const[g]=$(()=>BV({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:s,height:a,fitView:d,minZoom:i,maxZoom:l,fitViewOptions:c,nodeOrigin:f,nodeExtent:p,zIndexMode:m}));return r(rH,{value:g,children:r(IH,{children:h})})}function jV({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:s,width:a,height:i,fitView:l,fitViewOptions:c,minZoom:d,maxZoom:f,nodeOrigin:p,nodeExtent:m,zIndexMode:h}){return ye(Da)?r(ve,{children:e}):r(FV,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:i,fitView:l,initialFitViewOptions:c,initialMinZoom:d,initialMaxZoom:f,nodeOrigin:p,nodeExtent:m,zIndexMode:h,children:e})}const HV={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function VV({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:s,nodeTypes:a,edgeTypes:i,onNodeClick:l,onEdgeClick:c,onInit:d,onMove:f,onMoveStart:p,onMoveEnd:m,onConnect:h,onConnectStart:g,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:v,onNodeMouseEnter:w,onNodeMouseMove:y,onNodeMouseLeave:N,onNodeContextMenu:k,onNodeDoubleClick:S,onNodeDragStart:M,onNodeDrag:P,onNodeDragStop:I,onNodesDelete:F,onEdgesDelete:E,onDelete:B,onSelectionChange:O,onSelectionDragStart:A,onSelectionDrag:D,onSelectionDragStop:_,onSelectionContextMenu:R,onSelectionStart:L,onSelectionEnd:z,onBeforeDelete:j,connectionMode:H,connectionLineType:T=xn.Bezier,connectionLineStyle:W,connectionLineComponent:G,connectionLineContainerStyle:ee,deleteKeyCode:se="Backspace",selectionKeyCode:te="Shift",selectionOnDrag:X=!1,selectionMode:re=go.Full,panActivationKeyCode:ge="Space",multiSelectionKeyCode:Z=xo()?"Meta":"Control",zoomActivationKeyCode:U=xo()?"Meta":"Control",snapToGrid:J,snapGrid:ae,onlyRenderVisibleElements:fe=!1,selectNodesOnDrag:he,nodesDraggable:V,autoPanOnNodeFocus:ie,nodesConnectable:ue,nodesFocusable:de,nodeOrigin:le=bv,edgesFocusable:Se,edgesReconnectable:pe,elementsSelectable:Ie=!0,defaultViewport:Te=gH,minZoom:Ye=.5,maxZoom:ot=2,translateExtent:rr=ho,preventScrolling:me=!0,nodeExtent:Ee,defaultMarkerColor:_e="#b1b1b7",zoomOnScroll:Re=!0,zoomOnPinch:An=!0,panOnScroll:Pn=!1,panOnScrollSpeed:Or=.5,panOnScrollMode:Kv=Bn.Free,zoomOnDoubleClick:Gv=!0,panOnDrag:Wv=!0,onPaneClick:Yv,onPaneMouseEnter:Zv,onPaneMouseMove:Xv,onPaneMouseLeave:Jv,onPaneScroll:e1,onPaneContextMenu:t1,paneClickDistance:n1=1,nodeClickDistance:r1=0,children:o1,onReconnect:s1,onReconnectStart:a1,onReconnectEnd:i1,onEdgeContextMenu:l1,onEdgeDoubleClick:c1,onEdgeMouseEnter:d1,onEdgeMouseMove:u1,onEdgeMouseLeave:p1,reconnectRadius:f1=10,onNodesChange:m1,onEdgesChange:h1,noDragClassName:g1="nodrag",noWheelClassName:b1="nowheel",noPanClassName:wd="nopan",fitView:Nd,fitViewOptions:kd,connectOnClick:x1,attributionPosition:y1,proOptions:v1,defaultEdgeOptions:w1,elevateNodesOnSelect:N1=!0,elevateEdgesOnSelect:k1=!1,disableKeyboardA11y:Sd=!1,autoPanOnConnect:S1,autoPanOnNodeDrag:C1,autoPanSpeed:M1,connectionRadius:I1,isValidConnection:A1,onError:P1,style:E1,id:Cd,nodeDragThreshold:$1,connectionDragThreshold:_1,viewport:D1,onViewportChange:L1,width:T1,height:R1,colorMode:O1="light",debug:z1,onScroll:Md,ariaLabelConfig:B1,zIndexMode:Id="basic",...F1},j1){const Oa=Cd||"1",H1=vH(O1),V1=q(Ad=>{Ad.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Md?.(Ad)},[Md]);return r("div",{"data-testid":"rf__wrapper",...F1,onScroll:V1,style:{...E1,...HV},ref:j1,className:Ue(["react-flow",s,H1]),id:Cd,role:"application",children:u(jV,{nodes:e,edges:t,width:T1,height:R1,fitView:Nd,fitViewOptions:kd,minZoom:Ye,maxZoom:ot,nodeOrigin:le,nodeExtent:Ee,zIndexMode:Id,children:[r(yH,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:h,onConnectStart:g,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:v,nodesDraggable:V,autoPanOnNodeFocus:ie,nodesConnectable:ue,nodesFocusable:de,edgesFocusable:Se,edgesReconnectable:pe,elementsSelectable:Ie,elevateNodesOnSelect:N1,elevateEdgesOnSelect:k1,minZoom:Ye,maxZoom:ot,nodeExtent:Ee,onNodesChange:m1,onEdgesChange:h1,snapToGrid:J,snapGrid:ae,connectionMode:H,translateExtent:rr,connectOnClick:x1,defaultEdgeOptions:w1,fitView:Nd,fitViewOptions:kd,onNodesDelete:F,onEdgesDelete:E,onDelete:B,onNodeDragStart:M,onNodeDrag:P,onNodeDragStop:I,onSelectionDrag:D,onSelectionDragStart:A,onSelectionDragStop:_,onMove:f,onMoveStart:p,onMoveEnd:m,noPanClassName:wd,nodeOrigin:le,rfId:Oa,autoPanOnConnect:S1,autoPanOnNodeDrag:C1,autoPanSpeed:M1,onError:P1,connectionRadius:I1,isValidConnection:A1,selectNodesOnDrag:he,nodeDragThreshold:$1,connectionDragThreshold:_1,onBeforeDelete:j,debug:z1,ariaLabelConfig:B1,zIndexMode:Id}),r(zV,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:w,onNodeMouseMove:y,onNodeMouseLeave:N,onNodeContextMenu:k,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:i,connectionLineType:T,connectionLineStyle:W,connectionLineComponent:G,connectionLineContainerStyle:ee,selectionKeyCode:te,selectionOnDrag:X,selectionMode:re,deleteKeyCode:se,multiSelectionKeyCode:Z,panActivationKeyCode:ge,zoomActivationKeyCode:U,onlyRenderVisibleElements:fe,defaultViewport:Te,translateExtent:rr,minZoom:Ye,maxZoom:ot,preventScrolling:me,zoomOnScroll:Re,zoomOnPinch:An,zoomOnDoubleClick:Gv,panOnScroll:Pn,panOnScrollSpeed:Or,panOnScrollMode:Kv,panOnDrag:Wv,onPaneClick:Yv,onPaneMouseEnter:Zv,onPaneMouseMove:Xv,onPaneMouseLeave:Jv,onPaneScroll:e1,onPaneContextMenu:t1,paneClickDistance:n1,nodeClickDistance:r1,onSelectionContextMenu:R,onSelectionStart:L,onSelectionEnd:z,onReconnect:s1,onReconnectStart:a1,onReconnectEnd:i1,onEdgeContextMenu:l1,onEdgeDoubleClick:c1,onEdgeMouseEnter:d1,onEdgeMouseMove:u1,onEdgeMouseLeave:p1,reconnectRadius:f1,defaultMarkerColor:_e,noDragClassName:g1,noWheelClassName:b1,noPanClassName:wd,rfId:Oa,disableKeyboardA11y:Sd,nodeExtent:Ee,viewport:D1,onViewportChange:L1}),r(hH,{onSelectionChange:O}),o1,r(dH,{proOptions:v1,position:y1}),r(cH,{rfId:Oa,disableKeyboardA11y:Sd})]})})}var qV=yv(VV);function QV({dimensions:e,lineWidth:t,variant:n,className:o}){return r("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Ue(["react-flow__background-pattern",n,o])})}function UV({radius:e,className:t}){return r("circle",{cx:e,cy:e,r:e,className:Ue(["react-flow__background-pattern","dots",t])})}var vn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(vn||(vn={}));const KV={[vn.Dots]:1,[vn.Lines]:1,[vn.Cross]:6},GV=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Vv({id:e,variant:t=vn.Dots,gap:n=20,size:o,lineWidth:s=1,offset:a=0,color:i,bgColor:l,style:c,className:d,patternClassName:f}){const p=ne(null),{transform:m,patternId:h}=$e(GV,Be),g=o||KV[t],b=t===vn.Dots,x=t===vn.Cross,v=Array.isArray(n)?n:[n,n],w=[v[0]*m[2]||1,v[1]*m[2]||1],y=g*m[2],N=Array.isArray(a)?a:[a,a],k=x?[y,y]:w,S=[N[0]*m[2]||1+k[0]/2,N[1]*m[2]||1+k[1]/2],M=`${h}${e||""}`;return u("svg",{className:Ue(["react-flow__background",d]),style:{...c,...Ta,"--xy-background-color-props":l,"--xy-background-pattern-color-props":i},ref:p,"data-testid":"rf__background",children:[r("pattern",{id:M,x:m[0]%w[0],y:m[1]%w[1],width:w[0],height:w[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${S[0]},-${S[1]})`,children:b?r(UV,{radius:y/2,className:f}):r(QV,{dimensions:k,lineWidth:s,variant:t,className:f})}),r("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}Vv.displayName="Background";const WV=Fe(Vv);function YV(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:r("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ZV(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:r("path",{d:"M0 0h32v4.2H0z"})})}function XV(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:r("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function JV(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:r("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function eq(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:r("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function ds({children:e,className:t,...n}){return r("button",{type:"button",className:Ue(["react-flow__controls-button",t]),...n,children:e})}const tq=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function qv({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:s,onZoomIn:a,onZoomOut:i,onFitView:l,onInteractiveChange:c,className:d,children:f,position:p="bottom-left",orientation:m="vertical","aria-label":h}){const g=je(),{isInteractive:b,minZoomReached:x,maxZoomReached:v,ariaLabelConfig:w}=$e(tq,Be),{zoomIn:y,zoomOut:N,fitView:k}=yd(),S=()=>{y(),a?.()},M=()=>{N(),i?.()},P=()=>{k(s),l?.()},I=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),c?.(!b)};return u(La,{className:Ue(["react-flow__controls",m==="horizontal"?"horizontal":"vertical",d]),position:p,style:e,"data-testid":"rf__controls","aria-label":h??w["controls.ariaLabel"],children:[t&&u(ve,{children:[r(ds,{onClick:S,className:"react-flow__controls-zoomin",title:w["controls.zoomIn.ariaLabel"],"aria-label":w["controls.zoomIn.ariaLabel"],disabled:v,children:r(YV,{})}),r(ds,{onClick:M,className:"react-flow__controls-zoomout",title:w["controls.zoomOut.ariaLabel"],"aria-label":w["controls.zoomOut.ariaLabel"],disabled:x,children:r(ZV,{})})]}),n&&r(ds,{className:"react-flow__controls-fitview",onClick:P,title:w["controls.fitView.ariaLabel"],"aria-label":w["controls.fitView.ariaLabel"],children:r(XV,{})}),o&&r(ds,{className:"react-flow__controls-interactive",onClick:I,title:w["controls.interactive.ariaLabel"],"aria-label":w["controls.interactive.ariaLabel"],children:b?r(eq,{}):r(JV,{})}),f]})}qv.displayName="Controls";const nq=Fe(qv);function rq({id:e,x:t,y:n,width:o,height:s,style:a,color:i,strokeColor:l,strokeWidth:c,className:d,borderRadius:f,shapeRendering:p,selected:m,onClick:h}){const{background:g,backgroundColor:b}=a||{},x=i||g||b;return r("rect",{className:Ue(["react-flow__minimap-node",{selected:m},d]),x:t,y:n,rx:f,ry:f,width:o,height:s,style:{fill:x,stroke:l,strokeWidth:c},shapeRendering:p,onClick:h?v=>h(v,e):void 0})}const oq=Fe(rq),sq=e=>e.nodes.map(t=>t.id),Ei=e=>e instanceof Function?e:()=>e;function aq({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:s,nodeComponent:a=oq,onClick:i}){const l=$e(sq,Be),c=Ei(t),d=Ei(e),f=Ei(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return r(ve,{children:l.map(m=>r(lq,{id:m,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:f,nodeBorderRadius:o,nodeStrokeWidth:s,NodeComponent:a,onClick:i,shapeRendering:p},m))})}function iq({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:s,nodeStrokeWidth:a,shapeRendering:i,NodeComponent:l,onClick:c}){const{node:d,x:f,y:p,width:m,height:h}=$e(g=>{const b=g.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const x=b.internals.userNode,{x:v,y:w}=b.internals.positionAbsolute,{width:y,height:N}=fn(x);return{node:x,x:v,y:w,width:y,height:N}},Be);return!d||d.hidden||!Q0(d)?null:r(l,{x:f,y:p,width:m,height:h,style:d.style,selected:!!d.selected,className:o(d),color:t(d),borderRadius:s,strokeColor:n(d),strokeWidth:a,shapeRendering:i,onClick:c,id:d.id})}const lq=Fe(iq);var cq=Fe(aq);const dq=200,uq=150,pq=e=>!e.hidden,fq=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?q0(Do(e.nodeLookup,{filter:pq}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},mq="react-flow__minimap-desc";function Qv({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:s="",nodeBorderRadius:a=5,nodeStrokeWidth:i,nodeComponent:l,bgColor:c,maskColor:d,maskStrokeColor:f,maskStrokeWidth:p,position:m="bottom-right",onClick:h,onNodeClick:g,pannable:b=!1,zoomable:x=!1,ariaLabel:v,inversePan:w,zoomStep:y=1,offsetScale:N=5}){const k=je(),S=ne(null),{boundingRect:M,viewBB:P,rfId:I,panZoom:F,translateExtent:E,flowWidth:B,flowHeight:O,ariaLabelConfig:A}=$e(fq,Be),D=e?.width??dq,_=e?.height??uq,R=M.width/D,L=M.height/_,z=Math.max(R,L),j=z*D,H=z*_,T=N*z,W=M.x-(j-M.width)/2-T,G=M.y-(H-M.height)/2-T,ee=j+T*2,se=H+T*2,te=`${mq}-${I}`,X=ne(0),re=ne();X.current=z,Y(()=>{if(S.current&&F)return re.current=Mj({domNode:S.current,panZoom:F,getTransform:()=>k.getState().transform,getViewScale:()=>X.current}),()=>{re.current?.destroy()}},[F]),Y(()=>{re.current?.update({translateExtent:E,width:B,height:O,inversePan:w,pannable:b,zoomStep:y,zoomable:x})},[b,x,w,y,E,B,O]);const ge=h?J=>{const[ae,fe]=re.current?.pointer(J)||[0,0];h(J,{x:ae,y:fe})}:void 0,Z=g?q((J,ae)=>{const fe=k.getState().nodeLookup.get(ae).internals.userNode;g(J,fe)},[]):void 0,U=v??A["minimap.ariaLabel"];return r(La,{position:m,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*z:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof i=="number"?i:void 0},className:Ue(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:u("svg",{width:D,height:_,viewBox:`${W} ${G} ${ee} ${se}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":te,ref:S,onClick:ge,children:[U&&r("title",{id:te,children:U}),r(cq,{onClick:Z,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:s,nodeStrokeWidth:i,nodeComponent:l}),r("path",{className:"react-flow__minimap-mask",d:`M${W-T},${G-T}h${ee+T*2}v${se+T*2}h${-ee-T*2}z
|
|
1098
|
+
M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Qv.displayName="MiniMap";Fe(Qv);const hq=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,gq={[Mr.Line]:"right",[Mr.Handle]:"bottom-right"};function bq({nodeId:e,position:t,variant:n=Mr.Handle,className:o,style:s=void 0,children:a,color:i,minWidth:l=10,minHeight:c=10,maxWidth:d=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:m,autoScale:h=!0,shouldResize:g,onResizeStart:b,onResize:x,onResizeEnd:v}){const w=kv(),y=typeof e=="string"?e:w,N=je(),k=ne(null),S=n===Mr.Handle,M=$e(q(hq(S&&h),[S,h]),Be),P=ne(null),I=t??gq[n];Y(()=>{if(!(!k.current||!y))return P.current||(P.current=Fj({domNode:k.current,nodeId:y,getStoreItems:()=>{const{nodeLookup:E,transform:B,snapGrid:O,snapToGrid:A,nodeOrigin:D,domNode:_}=N.getState();return{nodeLookup:E,transform:B,snapGrid:O,snapToGrid:A,nodeOrigin:D,paneDomNode:_}},onChange:(E,B)=>{const{triggerNodeChanges:O,nodeLookup:A,parentLookup:D,nodeOrigin:_}=N.getState(),R=[],L={x:E.x,y:E.y},z=A.get(y);if(z&&z.expandParent&&z.parentId){const j=z.origin??_,H=E.width??z.measured.width??0,T=E.height??z.measured.height??0,W={id:z.id,parentId:z.parentId,rect:{width:H,height:T,...U0({x:E.x??z.position.x,y:E.y??z.position.y},{width:H,height:T},z.parentId,A,j)}},G=xd([W],A,D,_);R.push(...G),L.x=E.x?Math.max(j[0]*H,E.x):void 0,L.y=E.y?Math.max(j[1]*T,E.y):void 0}if(L.x!==void 0&&L.y!==void 0){const j={id:y,type:"position",position:{...L}};R.push(j)}if(E.width!==void 0&&E.height!==void 0){const H={id:y,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:E.width,height:E.height}};R.push(H)}for(const j of B){const H={...j,type:"position"};R.push(H)}O(R)},onEnd:({width:E,height:B})=>{const O={id:y,type:"dimensions",resizing:!1,dimensions:{width:E,height:B}};N.getState().triggerNodeChanges([O])}})),P.current.update({controlPosition:I,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:f},keepAspectRatio:p,resizeDirection:m,onResizeStart:b,onResize:x,onResizeEnd:v,shouldResize:g}),()=>{P.current?.destroy()}},[I,l,c,d,f,p,b,x,v,g]);const F=I.split("-");return r("div",{className:Ue(["react-flow__resize-control","nodrag",...F,n,o]),ref:k,style:{...s,scale:M,...i&&{[S?"backgroundColor":"borderColor"]:i}},children:a})}Fe(bq);function xq({data:e,selected:t}){const n=e.isOnline,o=e.isHub,s=e.engines??[],a=e.addons??[],i=e.processes??[],l=e.name,c=e.hostname,d=e.localIps??[],f=e.cpuPercent,p=e.memoryPercent,m=e.isExpanded,h=e.onToggleExpand,g=e.onShowNodeLogs,b=e.onRestartNode,x=e.id,v=i.length,w=q(M=>{M.stopPropagation(),h?.()},[h]),y=q(M=>{M.stopPropagation(),g?.()},[g]),N=q(M=>{M.stopPropagation(),b?.()},[b]);return u("div",{className:`rounded-xl bg-surface px-3 py-2.5 min-w-[180px] max-w-[260px] transition-all duration-200 ${n?o?"border-2 border-success":"border-2 border-dashed border-primary/60 bg-primary/5":"border-2 border-dashed border-muted-foreground/30 opacity-50"} ${t?"ring-2 ring-primary ring-offset-1":""}`,children:[r(kn,{type:"target",position:we.Top,className:"!bg-border !w-2 !h-2"}),u("div",{className:"flex items-center gap-1.5 mb-1.5",children:[r("div",{className:`w-2 h-2 rounded-full ${n?"bg-success":"bg-destructive"}`}),r("span",{className:"text-xs font-semibold truncate flex-1",children:l}),o?r("span",{className:"text-[8px] px-1 py-0.5 rounded bg-primary/10 text-primary font-medium",children:"HUB"}):r("span",{className:"text-[8px] px-1 py-0.5 rounded bg-muted text-muted-foreground font-medium",children:"AGENT"})]}),(c||d.length>0)&&(()=>{const M=d.filter(P=>!P.includes(":"));return u("div",{className:"text-[9px] text-muted-foreground mb-1 space-y-0.5",title:[c,...d].filter(Boolean).join(", "),children:[c&&r("div",{className:"truncate",children:c}),M.length>0&&r("div",{className:"truncate font-mono opacity-70",children:M.join(", ")})]})})(),s.length>0&&r("div",{className:"flex flex-wrap gap-1 mb-1.5",children:s.map(M=>r("span",{className:"text-[8px] px-1 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:M},M))}),a.length>0&&u("div",{className:"text-[9px] text-muted-foreground mb-1",children:[a.length," addon",a.length!==1?"s":""," in-process"]}),n&&u("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground",children:[u("span",{className:"flex items-center gap-0.5",children:[r(ut,{className:"h-2.5 w-2.5"}),f,"%"]}),u("span",{className:"flex items-center gap-0.5",children:[r(Gc,{className:"h-2.5 w-2.5"}),p,"%"]}),u("div",{className:"flex items-center gap-1 ml-auto",children:[v>0&&u("button",{onClick:w,className:"flex items-center gap-0.5 px-1 py-0.5 rounded hover:bg-amber-500/10 text-amber-500 transition-colors",title:m?"Collapse processes":`Expand ${v} process${v!==1?"es":""}`,children:[m?r(Rt,{className:"h-3 w-3"}):r(Mt,{className:"h-3 w-3"}),r("span",{className:"text-[9px] font-medium",children:v})]}),r("button",{onClick:y,className:"p-0.5 rounded hover:bg-primary/10 text-muted-foreground hover:text-primary transition-colors",title:`Logs: ${x}`,children:r(Xe,{className:"h-3 w-3"})}),r("button",{onClick:N,className:"p-0.5 rounded hover:bg-primary/10 text-muted-foreground hover:text-primary transition-colors",title:"Restart all processes",children:r(bt,{className:"h-3 w-3"})})]})]}),!n&&r("div",{className:"text-[10px] text-muted-foreground",children:"offline"}),r(kn,{type:"source",position:we.Bottom,className:"!bg-border !w-2 !h-2"})]})}const yq=Fe(xq);function vq(e){return e===0?"0":e<1024*1024?`${Math.round(e/1024)}K`:e<1024*1024*1024?`${Math.round(e/(1024*1024))}M`:`${(e/(1024*1024*1024)).toFixed(1)}G`}function wq({data:e}){const t=e.name,n=e.state,o=e.pid,s=e.cpuPercent,a=e.memoryRss,i=e.addonId,l=e.services??[],c=e.isExpanded,d=e.onToggleServices,f=e.parentNodeId,p=e.onShowLogs,m=e.onRestartAddon,h=n==="running",g=t.includes("(core)"),b=!g&&l.length===1,x=b?l[0]:null,v=f??"hub",w=`${v}/${t}`,y=q(M=>{M.stopPropagation(),d?.()},[d]),N=g?ln:ha,k=g?"border-primary/50":h?"border-amber-500/50":"border-destructive/50",S=g?"text-primary":"text-amber-500";return u("div",{className:`rounded-lg bg-surface min-w-[150px] border ${k} ${c?"max-w-[240px]":"max-w-[210px]"}`,children:[r(kn,{type:"target",position:we.Top,className:`!w-1.5 !h-1.5 ${g?"!bg-primary":"!bg-amber-500"}`}),u("div",{className:"px-2.5 pt-2 pb-1.5",children:[u("div",{className:"flex items-start gap-1.5 mb-1.5",children:[r(N,{className:`h-3 w-3 ${S} shrink-0 mt-0.5`}),r("span",{className:"text-[10px] font-semibold truncate flex-1",children:g?"core":i??t}),r("span",{className:"text-[8px] text-muted-foreground/60 tabular-nums shrink-0",children:o})]}),u("div",{className:"flex items-center gap-2 text-[9px] text-muted-foreground",children:[r("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${h?"bg-success":"bg-destructive"}`}),u("span",{className:"flex items-center gap-0.5",children:[r(ut,{className:"h-2 w-2"}),s,"%"]}),u("span",{className:"flex items-center gap-0.5",children:[r(Gc,{className:"h-2 w-2"}),vq(a)]}),b&&x?u("div",{className:"flex items-center gap-0.5 ml-auto",children:[r("button",{onClick:M=>{M.stopPropagation(),p?.(x.addonId,v)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Logs: ${x.addonId}`,children:r(Xe,{className:"h-2.5 w-2.5"})}),r("button",{onClick:M=>{M.stopPropagation(),m?.(x.addonId,w)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Restart: ${x.addonId}`,children:r(bt,{className:"h-2.5 w-2.5"})})]}):l.length>0?u("button",{onClick:y,className:"flex items-center gap-0.5 ml-auto px-0.5 rounded hover:bg-blue-500/10 text-blue-400 transition-colors",title:c?"Hide addons":`Show ${l.length} addon${l.length!==1?"s":""}`,children:[c?r(Rt,{className:"h-2.5 w-2.5"}):r(Mt,{className:"h-2.5 w-2.5"}),r("span",{className:"text-[8px] font-medium",children:l.length})]}):null]})]}),c&&l.length>0&&!b&&r("div",{className:"border-t border-border/40 px-2 py-1 space-y-0.5 max-h-[200px] overflow-y-auto",children:l.map(M=>{const P=g?v:`${v}/${t}`;return u("div",{className:"flex items-center gap-1 py-0.5",children:[r("div",{className:`w-1 h-1 rounded-full shrink-0 ${M.status==="running"?"bg-success":"bg-muted-foreground/30"}`}),r("span",{className:"text-[9px] truncate flex-1",children:M.addonId}),r("button",{onClick:I=>{I.stopPropagation(),p?.(M.addonId,v)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Logs: ${M.addonId}`,children:r(Xe,{className:"h-2.5 w-2.5"})}),r("button",{onClick:I=>{I.stopPropagation(),m?.(M.addonId,P)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Restart: ${M.addonId}`,children:r(bt,{className:"h-2.5 w-2.5"})})]},M.addonId)})}),r(kn,{type:"source",position:we.Bottom,className:`!w-1.5 !h-1.5 ${g?"!bg-primary":"!bg-amber-500"}`})]})}const Nq=Fe(wq),kq={clusterNode:yq,processNode:Nq},Mf=280,If=40,Af=280,Pf=200,Sq=150;function Cq({topology:e}){const{resolvedMode:t}=Ir(),n=eb(),o=aa(),[,s]=$(null),[a,i]=$(()=>e.length<=1?new Set(e.map(M=>M.id)):new Set),[l,c]=$(null),[d,f]=$(null),p=q((M,P)=>{f(I=>I?.addonId===M&&I?.agentId===P?null:{addonId:M,agentId:P})},[]),m=q(M=>{f(P=>P?.agentId===M&&!P?.addonId?null:{agentId:M})},[]),h=q(async M=>{try{await n.mutateAsync({nodeId:M})}catch(P){console.error("Failed to restart node:",P)}},[n]),g=q(async(M,P)=>{try{await o.mutateAsync({nodeId:P,addonId:M})}catch(I){console.error("Failed to restart addon:",I)}},[o]),b=q(M=>{i(P=>{const I=new Set(P);return I.has(M)?I.delete(M):I.add(M),I})},[]),x=q(M=>{c(P=>P===M?null:M)},[]),v=q(M=>{s(M)},[]),w=Q(()=>{const M=e.filter(D=>D.isHub),P=e.filter(D=>!D.isHub),I=[],F=[],E=M[0]?.id,B=E?a.has(E):!1;function O(D,_,R,L){const z=[...L];if(z.length===0)return;const j=(z.length-1)*Pf,H=_-j/2,T=R+Sq;for(let W=0;W<z.length;W++){const G=z[W],ee=`proc:${D}/${G.name}`,se=G.services??[],te=l===ee;I.push({id:ee,type:"processNode",position:{x:H+W*Pf,y:T},data:{...G,addonId:G.name.includes("(core)")?void 0:se.length>1?G.name:se[0]?.addonId??G.name,parentNodeId:D,services:se,isExpanded:te,onToggleServices:()=>x(ee),onShowLogs:p,onRestartAddon:g}}),F.push({id:`edge:${D}-${ee}`,source:D,target:ee,animated:!0,style:{stroke:"var(--amber-500, #f59e0b)",strokeWidth:1,strokeDasharray:"4 4"}})}}for(const D of M){const _=Math.max(0,(P.length-1)*Mf)/2;I.push({id:D.id,type:"clusterNode",position:{x:_,y:If},data:{...D,label:D.name,isExpanded:a.has(D.id),onToggleExpand:()=>b(D.id),onShowDetail:()=>v(D.id),onShowNodeLogs:()=>m(D.id),onRestartNode:()=>h(D.id)}}),a.has(D.id)&&O(D.id,_,If,D.processes??[])}const A=B?Af+120:Af;for(let D=0;D<P.length;D++){const _=P[D],R=D*Mf;I.push({id:_.id,type:"clusterNode",position:{x:R,y:A},data:{..._,label:_.name,isExpanded:a.has(_.id),onToggleExpand:()=>b(_.id),onShowDetail:()=>v(_.id),onShowNodeLogs:()=>m(_.id),onRestartNode:()=>h(_.id)}}),E&&_.isOnline&&F.push({id:`${E}-${_.id}`,source:E,target:_.id,animated:!0,style:{stroke:"var(--border)",strokeWidth:1.5}}),a.has(_.id)&&O(_.id,R,A,_.processes??[])}return{nodes:I,edges:F}},[e,a,l,b,x,v,p,m,h,g]),y=ne(new Map),N=Q(()=>{const M=y.current;return w.nodes.map(I=>({...I,position:M.get(I.id)??I.position}))},[w.nodes]),k=q(M=>{for(const P of M)P.type==="position"&&P.position&&y.current.set(P.id,P.position)},[]),S=q(()=>s(null),[]);return r("div",{className:"flex flex-col gap-4 flex-1",children:u("div",{className:"relative flex-1 min-h-[350px] border border-border rounded-xl overflow-hidden",children:[u(qV,{nodes:N,edges:w.edges,onNodesChange:k,onPaneClick:S,nodeTypes:kq,nodesConnectable:!1,fitView:!0,fitViewOptions:{padding:.2,maxZoom:1.2},proOptions:{hideAttribution:!0},className:"bg-background",colorMode:t,children:[r(WV,{gap:20,size:1}),r(nq,{showInteractive:!1})]}),d&&r(kx,{addonId:d.addonId,agentId:d.agentId,showScope:!0,onClose:()=>f(null)})]})})}function Mq({onlineNodeIds:e}){const t=ke(),n=rt(),{data:o,isLoading:s}=$r(),a=Sb({onSuccess:()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","listAgentSettings"]]})}}),i=Q(()=>{if(!o)return[];const c=new Set(e);return c.add("hub"),o.filter(d=>!c.has(d.nodeId))},[o,e]);if(s)return r("section",{className:"rounded-lg border border-border bg-surface p-6 text-xs text-muted-foreground animate-pulse",children:"Loading persisted agent settings…"});const l=async c=>{await n({title:"Remove offline agent?",message:`Drop the persisted orchestrator settings for "${c}". This won't affect a node that comes back online — it just clears stale addonDefaults so it stops cluttering the cluster view.`,confirmLabel:"Remove",cancelLabel:"Keep",variant:"danger"})&&a.mutate({agentNodeId:c})};return i.length===0?r("section",{className:"rounded-lg border border-border bg-surface p-6",children:u("div",{className:"flex flex-col items-center gap-2 text-center text-muted-foreground",children:[r(el,{className:"h-6 w-6 opacity-40"}),r("p",{className:"text-xs",children:"No stale agent entries."}),r("p",{className:"text-[11px] opacity-60",children:"Every persisted nodeId matches a node currently online in the cluster."})]})}):u("section",{className:"rounded-lg border border-border bg-surface",children:[u("header",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[r(el,{className:"h-4 w-4 text-muted-foreground"}),r("h2",{className:"text-sm font-semibold",children:"Offline agents"}),u("span",{className:"ml-auto text-[11px] text-muted-foreground",children:[i.length," stale ",i.length===1?"entry":"entries"]})]}),r("p",{className:"px-4 pt-3 text-[11px] text-muted-foreground",children:"Persisted orchestrator settings for nodes not currently in the live topology. Remove entries you don't expect to come back — leftover from data-dir resets, env-driven nodeId changes, or decommissioned hosts."}),r("ul",{className:"divide-y divide-border",children:i.map(c=>{const d=Object.keys(c.settings.addonDefaults??{}).length,f=Object.values(c.settings.addonDefaults??{}).filter(p=>p?.enabled).length;return u("li",{className:"flex items-center gap-3 px-4 py-2 text-xs",children:[r("span",{className:"font-mono text-foreground",children:c.nodeId}),u("span",{className:"text-muted-foreground",children:[d," addons configured",d>0&&u(ve,{children:[" · ",f," enabled"]})]}),u("button",{type:"button",onClick:()=>{l(c.nodeId)},disabled:a.isPending,className:"ml-auto flex items-center gap-1 px-2 py-1 rounded text-destructive hover:bg-destructive/10 disabled:opacity-50",children:[r(We,{className:"h-3 w-3"}),"Remove"]})]},c.nodeId)})})]})}function Iq(e){const[t,n]=$(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return Y(()=>{const o=window.matchMedia(e),s=a=>n(a.matches);return o.addEventListener("change",s),()=>o.removeEventListener("change",s)},[e]),t}function Aq(){const{data:e,isLoading:t}=In(void 0,{staleTime:1/0}),[n,o]=$(null);return dt("cluster.topology-snapshot",a=>{const i=a.data?.nodes;Array.isArray(i)&&o(i)}),{nodes:Q(()=>n??e??[],[n,e]),isLoading:t&&!n}}function Pq(){const[e,t]=$("diagram"),n=Iq("(max-width: 767px)"),o=n&&e==="diagram"?"table":e,{nodes:s,isLoading:a}=Aq(),i=s.filter(m=>m.isOnline).length,l=s.filter(m=>!m.isOnline).length,c=Q(()=>s.map(m=>m.id??"").filter(Boolean),[s]),{data:d}=$r(),f=Q(()=>{if(!d)return 0;const m=new Set(c);return m.add("hub"),d.filter(h=>!m.has(h.nodeId)).length},[d,c]),p=(m,h,g,b)=>u("button",{onClick:()=>t(m),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${e===m?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:[r(g,{className:"h-3.5 w-3.5"}),h,b!==void 0&&b>0&&r("span",{className:`ml-1 inline-flex h-4 min-w-[1rem] items-center justify-center rounded-full px-1 text-[10px] font-semibold ${e===m?"bg-primary-foreground/20 text-primary-foreground":"bg-destructive/15 text-destructive"}`,children:b})]});return u("div",{className:"flex flex-col h-full gap-4 p-4",children:[u("div",{className:"flex items-center justify-between",children:[u("div",{className:"flex items-center gap-3",children:[r("h1",{className:"text-xl font-semibold",children:"Cluster"}),i>0&&u("span",{className:"text-xs px-2 py-0.5 rounded-full bg-success/10 text-success",children:[i," online"]}),l>0&&u("span",{className:"text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:[l," offline"]})]}),u("div",{className:"flex gap-0.5 p-1 rounded-lg bg-muted",children:[!n&&p("diagram","Diagram",an),p("table","Table",iT),p("offline-agents","Offline agents",el,f)]})]}),a?r("div",{className:"flex items-center justify-center flex-1 text-muted-foreground",children:"Loading cluster topology..."}):o==="diagram"?r(Cq,{topology:s}):o==="table"?r("div",{className:"flex-1 overflow-auto",children:r(l7,{nodes:s})}):r("div",{className:"flex-1 overflow-auto",children:r(Mq,{onlineNodeIds:c})})]})}function en({title:e,children:t}){return u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r("div",{className:"border-b border-border px-4 py-2.5",children:r("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:e})}),r("div",{className:"p-4",children:t})]})}function tt({name:e,cssVar:t,hex:n}){const o=t?`var(${t})`:n;return u("div",{className:"flex flex-col items-center gap-1.5",children:[r("div",{className:"h-10 w-10 rounded-lg border border-border shadow-inner",style:{backgroundColor:o}}),r("span",{className:"text-[10px] text-foreground-subtle text-center leading-tight",children:e})]})}const Eq={sections:[{id:"demo",title:"Demo Fields",columns:2,fields:[{key:"name",type:"text",label:"Name",placeholder:"Enter name"},{key:"count",type:"number",label:"Count",min:0,max:100,unit:"items"},{key:"enabled",type:"boolean",label:"Enabled"},{key:"mode",type:"select",label:"Mode",options:[{value:"a",label:"Alpha"},{value:"b",label:"Beta"}]},{key:"tags",type:"tags",label:"Tags",span:2,suggestions:["camera","zone","alert"]},{key:"confidence",type:"slider",label:"Confidence",min:0,max:100,step:5,unit:"%",span:2},{key:"info",type:"info",label:"Note",content:"This is an informational message for the user.",variant:"info"}]}]};function $q(){const[e,t]=$({name:"Example",count:10,enabled:!0,mode:"a",tags:["camera"],confidence:60});return u("div",{className:"p-6 space-y-6 max-w-5xl mx-auto",children:[u("div",{className:"mb-6",children:[r("h1",{className:"text-xl font-bold text-foreground",children:"Component Showroom"}),r("p",{className:"text-sm text-foreground-subtle mt-1",children:"All UI components at a glance"})]}),r(en,{title:"Typography",children:u("div",{className:"space-y-3",children:[r("h1",{className:"text-2xl font-bold text-foreground",children:"Heading 1 — Display title"}),r("h2",{className:"text-xl font-semibold text-foreground",children:"Heading 2 — Section title"}),r("h3",{className:"text-base font-semibold text-foreground",children:"Heading 3 — Card title"}),r("h4",{className:"text-sm font-semibold text-foreground",children:"Heading 4 — Sub-section"}),r("p",{className:"text-sm text-foreground",children:"Body text — Regular paragraph content goes here. It uses the foreground color."}),r("p",{className:"text-sm text-foreground-subtle",children:"Subtle text — Secondary/descriptive text with reduced emphasis."}),r("p",{className:"text-xs text-foreground-subtle uppercase tracking-wider font-semibold",children:"Label / Caption"}),r("p",{className:"text-xs text-foreground-disabled",children:"Disabled / placeholder text"})]})}),r(en,{title:"Colors",children:u("div",{className:"flex flex-wrap gap-4",children:[r(tt,{name:"primary",cssVar:"--color-primary"}),r(tt,{name:"background",cssVar:"--color-background"}),r(tt,{name:"surface",cssVar:"--color-surface"}),r(tt,{name:"foreground",cssVar:"--color-foreground"}),r(tt,{name:"success",cssVar:"--color-success"}),r(tt,{name:"warning",cssVar:"--color-warning"}),r(tt,{name:"danger",cssVar:"--color-danger"}),r(tt,{name:"info",cssVar:"--color-info"}),r(tt,{name:"border",cssVar:"--color-border"}),r("div",{className:"w-px"}),r(tt,{name:"frigate",hex:"#3b82f6"}),r(tt,{name:"scrypted",hex:"#a855f7"}),r(tt,{name:"reolink",hex:"#06b6d4"}),r(tt,{name:"ha",hex:"#22d3ee"}),r(tt,{name:"rtsp",hex:"#78716c"})]})}),r(en,{title:"Buttons",children:u("div",{className:"flex flex-wrap gap-3",children:[r("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity",children:"Primary"}),r("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-4 py-2 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors",children:"Secondary"}),r("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-danger/40 bg-danger/10 px-4 py-2 text-sm font-medium text-danger hover:bg-danger/20 transition-colors",children:"Danger"}),r("button",{disabled:!0,className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white opacity-40 cursor-not-allowed",children:"Disabled"}),r("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-4 py-2 text-sm font-medium text-warning hover:bg-warning/20 transition-colors",children:"Warning"}),r("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-success/40 bg-success/10 px-4 py-2 text-sm font-medium text-success hover:bg-success/20 transition-colors",children:"Success"})]})}),r(en,{title:"Inputs",children:u("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Text input"}),r("input",{type:"text",className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30",placeholder:"Type something..."})]}),u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Number input"}),r("input",{type:"number",className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30",placeholder:"0"})]}),u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Password input"}),r("input",{type:"password",className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30",placeholder:"••••••••"})]}),u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Select"}),u("select",{className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30",children:[r("option",{children:"Option A"}),r("option",{children:"Option B"}),r("option",{children:"Option C"})]})]}),u("div",{className:"md:col-span-2",children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Textarea"}),r("textarea",{className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 resize-y min-h-[60px]",placeholder:"Enter multi-line text...",rows:3})]}),r("div",{children:u("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[r("input",{type:"checkbox",className:"h-3.5 w-3.5 rounded border-border accent-primary",defaultChecked:!0}),r("span",{className:"text-xs font-medium text-foreground",children:"Checkbox (checked)"})]})}),r("div",{children:u("div",{className:"flex items-center justify-between",children:[r("span",{className:"text-xs font-medium text-foreground",children:"Toggle switch"}),r(_q,{})]})}),u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Slider"}),r("input",{type:"range",className:"w-full h-1 accent-primary cursor-pointer",min:0,max:100,defaultValue:60})]}),u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Tags example"}),r("div",{className:"flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px]",children:["camera","zone","alert"].map(n=>r("span",{className:"inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:n},n))})]})]})}),r(en,{title:"Badges",children:u("div",{className:"space-y-3",children:[u("div",{children:[r("p",{className:"text-xs text-foreground-subtle mb-2",children:"StatusBadge"}),r("div",{className:"flex flex-wrap gap-2",children:["running","stopped","error","online","offline","idle"].map(n=>r(Na,{status:n},n))})]}),u("div",{children:[r("p",{className:"text-xs text-foreground-subtle mb-2",children:"CapabilityBadges"}),r(va,{capabilities:["streaming","detection","recording","audio"]})]})]})}),r(en,{title:"Cards",children:u("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[u("div",{className:"rounded-lg bg-surface p-4",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Surface card"}),r("p",{className:"text-xs text-foreground-subtle",children:"Uses `bg-surface`. Default card background."})]}),u("div",{className:"rounded-lg border border-border bg-surface p-4",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Bordered card"}),r("p",{className:"text-xs text-foreground-subtle",children:"Uses `border border-border bg-surface`."})]}),u("div",{className:"rounded-lg border border-primary/30 bg-primary/5 p-4",children:[r("h3",{className:"text-sm font-semibold text-primary mb-1",children:"Accent card"}),r("p",{className:"text-xs text-foreground-subtle",children:"Highlighted with primary color."})]}),u("div",{className:"rounded-lg bg-background p-4",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Background card"}),r("p",{className:"text-xs text-foreground-subtle",children:"Uses `bg-background`. Inset card."})]})]})}),r(en,{title:"Provider Icons",children:r("div",{className:"flex flex-wrap gap-4",children:["frigate","scrypted","reolink","homeassistant","rtsp","onvif"].map(n=>r(cn,{type:n,size:"lg",showLabel:!0},n))})}),u(en,{title:"Form Builder Demo",children:[r(Nn,{schema:Eq,values:e,onChange:t}),u("details",{className:"mt-3",children:[r("summary",{className:"text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground",children:"View current values"}),r("pre",{className:"mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto",children:JSON.stringify(e,null,2)})]})]}),r(en,{title:"Info Boxes",children:r("div",{className:"space-y-2",children:[{variant:"info",label:"Info",content:"This is an informational message. Use it for tips and hints."},{variant:"warning",label:"Warning",content:"This action may have side effects. Proceed with caution."},{variant:"success",label:"Success",content:"Operation completed successfully. All systems are green."},{variant:"danger",label:"Danger",content:"This operation is irreversible. Data will be permanently deleted."}].map(({variant:n,label:o,content:s})=>{const i={info:{border:"border-info",bg:"bg-info/5",text:"text-info"},warning:{border:"border-warning",bg:"bg-warning/5",text:"text-warning"},success:{border:"border-success",bg:"bg-success/5",text:"text-success"},danger:{border:"border-danger",bg:"bg-danger/5",text:"text-danger"}}[n];return u("div",{className:`rounded-md border-l-4 px-3 py-2.5 ${i.border} ${i.bg}`,children:[r("p",{className:`text-xs font-semibold mb-0.5 ${i.text}`,children:o}),r("p",{className:"text-xs text-foreground-subtle leading-relaxed",children:s})]},n)})})})]})}function _q(){const[e,t]=$(!0);return r("button",{type:"button",role:"switch","aria-checked":e,onClick:()=>t(n=>!n),className:["relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150 cursor-pointer",e?"bg-primary":"bg-foreground-subtle/30"].join(" "),children:r("span",{className:["inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150",e?"translate-x-4":"translate-x-0.5"].join(" ")})})}const Ef={info:{bg:"bg-blue-500/10",border:"border-blue-500/30",icon:Ps},warning:{bg:"bg-orange-500/10",border:"border-orange-500/30",icon:xt},critical:{bg:"bg-red-500/10",border:"border-red-500/30",icon:ba}};function Dq({toast:e,onDismiss:t}){const n=Ef[e.severity]??Ef.info,o=n.icon;return Y(()=>{const s=e.duration??5e3;if(s<=0)return;const a=setTimeout(()=>t(e.id),s);return()=>clearTimeout(a)},[e.id,e.duration,t]),u("div",{className:`flex items-start gap-3 px-4 py-3 rounded-lg border ${n.border} ${n.bg} shadow-lg backdrop-blur-sm animate-in slide-in-from-right-5 fade-in duration-200`,children:[r(o,{className:"h-4 w-4 shrink-0 mt-0.5 text-foreground-subtle"}),u("div",{className:"flex-1 min-w-0",children:[r("div",{className:"text-xs font-semibold text-foreground",children:e.title}),r("div",{className:"text-[11px] text-foreground-subtle mt-0.5",children:e.message})]}),r("button",{type:"button",onClick:()=>t(e.id),className:"shrink-0 p-0.5 rounded hover:bg-surface-hover transition-colors",children:r(qe,{className:"h-3.5 w-3.5 text-foreground-subtle"})})]})}function Lq(){const[e,t]=$([]),n=q(o=>{t(s=>s.filter(a=>a.id!==o))},[]);return Yb(void 0,{onData:o=>{const s=o,a=`toast-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;t(i=>[...i,{...s,id:a,timestamp:Date.now()}])}}),e.length===0?null:r("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2 max-w-sm w-full pointer-events-none",children:e.map(o=>r("div",{className:"pointer-events-auto",children:r(Dq,{toast:o,onDismiss:n})},o.id))})}const Il=new Of({defaultOptions:{queries:{staleTime:3e4,retry:!1,refetchOnWindowFocus:!1}}});function Tq({field:e,value:t,onChange:n,disabled:o}){return r(kT,{field:e,value:t,onChange:n,disabled:o})}function Rq({field:e,value:t,onChange:n,disabled:o}){return r(DT,{field:e,value:t,onChange:n,disabled:o})}const Oq={"zone-editor":F_,"live-stats":H_,"pipeline-editor":Tq,"model-selector":Rq,"live-stream-viewer":TT,"pipeline-stats":RT,"stream-network-stats":OT,"doorbell-recent":BT,"device-info":Ny};function zq({children:e}){const{user:t}=Tr(),[n,o]=$(0),s=ne(t?.username??null);Y(()=>{const p=t?.username??null;p!==s.current&&(s.current=p,Yr(),o(m=>m+1))},[t]);const a=Q(()=>Ji(),[n]),[i,l]=$(!1),[c,d]=$(null);Y(()=>{if(l(!1),d(null),!t){l(!0);return}let p=!1;return a.init().then(()=>{p||l(!0)},m=>{if(p)return;const h=m instanceof Error?m.message:String(m);d(h),l(!0)}),()=>{p=!0}},[a,t]);const f=q(()=>{Yr(),o(p=>p+1),Il.invalidateQueries()},[]);return T_(f),r(Xl,{system:a,children:r(C.Provider,{client:a.trpcClient,queryClient:Il,children:u(lx,{children:[i?e:r(Bq,{}),c!==null&&i&&u("div",{className:"fixed bottom-4 right-4 z-50 max-w-sm rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning shadow-lg",children:["Boot probe failed: ",c,". Retrying in background."]})]})})})}function Bq(){return r("div",{className:"flex min-h-screen items-center justify-center bg-background",children:u("div",{className:"flex items-center gap-3 text-sm text-foreground-subtle",children:[r("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary"}),"Connecting…"]})})}function Fq(){return r(ws,{defaultMode:"dark",children:r(zf,{client:Il,children:r(JT,{children:r(zq,{children:r(yh,{children:u(Bh,{renderers:Oq,children:[r(S_,{children:u(J$,{children:[r(De,{path:"/login",element:r(n6,{})}),r(De,{path:"/change-password",element:r(jt,{children:r(o6,{})})}),r(De,{path:"/access-denied",element:r(s6,{})}),r(De,{path:"/showroom",element:r($q,{})}),u(De,{element:r(jt,{children:r(t6,{})}),children:[r(De,{index:!0,element:r(gt,{to:"/dashboard",replace:!0})}),r(De,{path:"/dashboard",element:r(g6,{})}),r(De,{path:"/devices",element:r(b6,{})}),r(De,{path:"/cameras",element:r(gt,{to:"/devices",replace:!0})}),r(De,{path:"/integrations",element:r(A6,{})}),r(De,{path:"/integrations/:integrationId",element:r($6,{})}),r(De,{path:"/timeline",element:r(j6,{})}),r(De,{path:"/pipeline",element:r(NO,{})}),r(De,{path:"/devices/:deviceId",element:r(y8,{})}),r(De,{path:"/system/logs",element:r(jt,{requiredRole:"admin",children:r($8,{})})}),r(De,{path:"/system/addons",element:r(jt,{requiredRole:"admin",children:r(E8,{})})}),r(De,{path:"/system/settings",element:r(jt,{requiredRole:"admin",children:r(U9,{})})}),r(De,{path:"/system/cluster",element:r(jt,{requiredRole:"admin",children:r(Pq,{})})}),r(De,{path:"/system/identity",element:r(jt,{requiredRole:"admin",children:r(Q8,{})})}),r(De,{path:"/system/network",element:r(jt,{requiredRole:"admin",children:r(o9,{})})}),r(De,{path:"/system/data",element:r(jt,{requiredRole:"admin",children:r(Q9,{})})}),r(De,{path:"/system/users",element:r(gt,{to:"/system/identity?tab=users",replace:!0})}),r(De,{path:"/system/api-keys",element:r(gt,{to:"/system/identity?tab=api-keys",replace:!0})}),r(De,{path:"/system/authentication",element:r(gt,{to:"/system/identity?tab=authentication",replace:!0})}),r(De,{path:"/system/remote-access",element:r(gt,{to:"/system/network?tab=remote-access",replace:!0})}),r(De,{path:"/system/turn",element:r(gt,{to:"/system/network?tab=turn",replace:!0})}),r(De,{path:"/system/storage",element:r(gt,{to:"/system/data?tab=storage",replace:!0})}),r(De,{path:"/system/backup",element:r(gt,{to:"/system/data?tab=backup",replace:!0})}),r(De,{path:"/addon/:pagePath",element:r(jt,{requiredRole:"admin",children:r(XR,{})})})]})]})}),r(Lq,{})]})})})})})})}const jq={dashboard:"Dashboard",integrations:"Integrations",metrics:"Metrics"},Hq={title:"System",addons:"Addons",agents:"Agents",processes:"Processes",logs:"Logs",users:"Users",settings:"Settings",repl:"REPL",models:"Models"},Vq={save:"Save",cancel:"Cancel",delete:"Delete",enable:"Enable",disable:"Disable",edit:"Edit",add:"Add",remove:"Remove",confirm:"Confirm",close:"Close",back:"Back",next:"Next",search:"Search",filter:"Filter",reset:"Reset",apply:"Apply",submit:"Submit",loading:"Loading…",error:"Error",success:"Success",warning:"Warning",info:"Info",noData:"No data available",noResults:"No results found",retry:"Retry",refresh:"Refresh",copy:"Copy",copied:"Copied!",yes:"Yes",no:"No"},qq={disconnected:"Server unreachable — reconnecting…",connected:"Connected"},Qq={online:"Online",offline:"Offline",connecting:"Connecting",error:"Error",disabled:"Disabled",enabled:"Enabled",active:"Active",inactive:"Inactive",running:"Running",stopped:"Stopped",pending:"Pending",unknown:"Unknown"},Uq={login:"Login",logout:"Logout",username:"Username",password:"Password",signIn:"Sign In",invalidCredentials:"Invalid username or password"},Kq={dark:"Dark",light:"Light",system:"System"},Gq={select:"Language",en:"English",it:"Italian"},Wq={dashboard:{title:"Dashboard",subtitle:"Overview of all devices and their status"},integrations:{title:"Integrations",subtitle:"Manage camera sources and provider connections"},metrics:{title:"Metrics",subtitle:"System performance and usage statistics"},agents:{title:"Agents",subtitle:"Manage distributed processing agents"},addons:{title:"Addons",subtitle:"Extend functionality with addon modules"},settings:{title:"Settings",subtitle:"Configure system-wide preferences"},users:{title:"Users",subtitle:"Manage user accounts and permissions"},logs:{title:"Logs",subtitle:"View system and device logs"}},Yq={preview:"Preview",snapshotUnavailable:"Snapshot unavailable",noSnapshot:"No snapshot",lastSnapshot:"Last snapshot:",offline:"Offline",active:"Active",available:"Available",noDevices:"No devices.",addFirstDevice:"Add your first device to get started.",import:"+ Import",noProviders:"No providers available. Install a provider addon.",manage:"Manage",integrationName:"Integration name",integrationNamePlaceholder:"e.g. Garage Server",connectionSuccess:"Connection successful!",errorPrefix:"Error:",back:"Back",testing:"Testing...",testConnection:"Test connection",forward:"Next",searchingDevices:"Searching for devices...",foundDevices:"Found {{count}} devices. Select the ones to import.",noDevicesFound:"No devices found.",skip:"Skip",importSelected:"Import selected",newIntegration:"New Integration",configureIntegration:"Configure Integration",importDevices:"Import Devices",addDevice:"Add device",name:"Name",namePlaceholder:"e.g. Entrance Camera",snapshotUrlOptional:"Snapshot URL (optional)",streamUrls:"Stream URLs",addStream:"Add stream",cancel:"Cancel",saving:"Saving...",save:"Save",saveAndNew:"Save and new",test:"Test",stream:"Stream {{number}}:",devices:"devices",rediscover:"Rediscover",config:"Config",integrationNotFound:"Integration not found.",configComingSoon:"Config coming soon.",providerConfig:"Provider Config"},Zq={nav:jq,system:Hq,common:Vq,connection:qq,status:Qq,auth:Uq,theme:Kq,language:Gq,pages:Wq,integrations:Yq},Xq={dashboard:"Dashboard",integrations:"Integrazioni",metrics:"Metriche"},Jq={title:"Sistema",addons:"Addon",agents:"Agenti",processes:"Processi",logs:"Log",users:"Utenti",settings:"Impostazioni",repl:"REPL",models:"Modelli"},eQ={save:"Salva",cancel:"Annulla",delete:"Elimina",enable:"Abilita",disable:"Disabilita",edit:"Modifica",add:"Aggiungi",remove:"Rimuovi",confirm:"Conferma",close:"Chiudi",back:"Indietro",next:"Avanti",search:"Cerca",filter:"Filtra",reset:"Reimposta",apply:"Applica",submit:"Invia",loading:"Caricamento…",error:"Errore",success:"Successo",warning:"Avviso",info:"Info",noData:"Nessun dato disponibile",noResults:"Nessun risultato trovato",retry:"Riprova",refresh:"Aggiorna",copy:"Copia",copied:"Copiato!",yes:"Sì",no:"No"},tQ={disconnected:"Server non raggiungibile — riconnessione in corso…",connected:"Connesso"},nQ={online:"Online",offline:"Offline",connecting:"Connessione in corso",error:"Errore",disabled:"Disabilitato",enabled:"Abilitato",active:"Attivo",inactive:"Inattivo",running:"In esecuzione",stopped:"Fermato",pending:"In attesa",unknown:"Sconosciuto"},rQ={login:"Accesso",logout:"Esci",username:"Nome utente",password:"Password",signIn:"Accedi",invalidCredentials:"Nome utente o password non validi"},oQ={dark:"Scuro",light:"Chiaro",system:"Sistema"},sQ={select:"Lingua",en:"Inglese",it:"Italiano"},aQ={dashboard:{title:"Dashboard",subtitle:"Panoramica di tutti i dispositivi e il loro stato"},integrations:{title:"Integrazioni",subtitle:"Gestisci le sorgenti video e le connessioni ai provider"},metrics:{title:"Metriche",subtitle:"Statistiche di prestazioni e utilizzo del sistema"},agents:{title:"Agenti",subtitle:"Gestisci gli agenti di elaborazione distribuita"},addons:{title:"Addon",subtitle:"Estendi le funzionalità con moduli addon"},settings:{title:"Impostazioni",subtitle:"Configura le preferenze di sistema"},users:{title:"Utenti",subtitle:"Gestisci gli account utente e i permessi"},logs:{title:"Log",subtitle:"Visualizza i log di sistema e dei dispositivi"}},iQ={preview:"Anteprima",snapshotUnavailable:"Snapshot non disponibile",noSnapshot:"Nessuno snapshot",lastSnapshot:"Ultimo snapshot:",offline:"Offline",active:"Attivi",available:"Disponibili",noDevices:"Nessun dispositivo.",addFirstDevice:"Aggiungi il primo dispositivo per iniziare.",import:"+ Importa",noProviders:"Nessun provider disponibile. Installa un addon provider.",manage:"Gestisci",integrationName:"Nome integrazione",integrationNamePlaceholder:"es. Server Garage",connectionSuccess:"Connessione riuscita!",errorPrefix:"Errore:",back:"Indietro",testing:"Test...",testConnection:"Test connessione",forward:"Avanti",searchingDevices:"Ricerca dispositivi in corso...",foundDevices:"Trovati {{count}} dispositivi. Seleziona quelli da importare.",noDevicesFound:"Nessun dispositivo trovato.",skip:"Salta",importSelected:"Importa selezionati",newIntegration:"Nuova Integrazione",configureIntegration:"Configura Integrazione",importDevices:"Importa Dispositivi",addDevice:"Aggiungi dispositivo",name:"Nome",namePlaceholder:"es. Camera Ingresso",snapshotUrlOptional:"Snapshot URL (opzionale)",streamUrls:"Stream URLs",addStream:"Aggiungi stream",cancel:"Annulla",saving:"Salvataggio...",save:"Salva",saveAndNew:"Salva e nuova",test:"Test",stream:"Stream {{number}}:",devices:"dispositivi",rediscover:"Riscopri",config:"Config",integrationNotFound:"Integrazione non trovata.",configComingSoon:"Config coming soon.",providerConfig:"Provider Config"},lQ={nav:Xq,system:Jq,common:eQ,connection:tQ,status:nQ,auth:rQ,theme:oQ,language:sQ,pages:aQ,integrations:iQ},Uv="camstack_language",cQ=localStorage.getItem(Uv)??"en";Ze.use(DR).init({resources:{en:{translation:Zq},it:{translation:lQ}},lng:cQ,fallbackLng:"en",interpolation:{escapeValue:!1}});Ze.on("languageChanged",e=>{localStorage.setItem(Uv,e)});window.__camstackUiLibrary=XE;window.__camstackSdk=aw;window.__camstackTypes=iw;Tf(document.getElementById("root")).render(r(Y1,{children:r(Fq,{})}));
|