@camstack/addon-admin-ui 0.1.33 → 0.1.34
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/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DJQnlBBe.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CZpDKvbm.js} +1 -1
- package/dist/assets/{devices-BnLu5dxg.js → devices-DFv560M2.js} +1 -1
- package/dist/assets/{hostInit-DQ5UjxJa.js → hostInit-bYpW6FId.js} +1 -1
- package/dist/assets/index-8vQS4K6d.js +1 -0
- package/dist/assets/index-B3RV989b.js +1 -0
- package/dist/assets/{index-BmzE49kT.js → index-BuBZuTof.js} +1 -1
- package/dist/assets/index-CJmL3_yz.css +1 -0
- package/dist/assets/index-CtaWAhdy.js +88 -0
- package/dist/assets/index-D4HNoPqG.js +152 -0
- package/dist/assets/{index-dePEzy7t.js → index-DAxxrrPB.js} +1 -1
- package/dist/assets/index-DJ0oJxIB.js +1 -0
- package/dist/assets/{index-DIIqKU3D.js → index-DOOUOoL9.js} +1 -1
- package/dist/assets/index-DUltPrcr.js +1 -0
- package/dist/assets/index-N4SZRZr8.js +1156 -0
- package/dist/assets/{index-CMxz0koW.js → index-xQgtnvQh.js} +1 -1
- package/dist/assets/method-access-map-DLph6s5D.js +1 -0
- package/dist/assets/{remoteEntry-D28y34bi.js → remoteEntry-DToxOPzT.js} +1 -1
- package/dist/assets/{schemas-DZqswtjx.js → schemas-BEt-CulV.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BXwMMqlX.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-C3bnYyiP.js} +2 -2
- package/dist/index.html +7 -7
- package/dist/mf-entry-bootstrap-0.js +2 -2
- package/dist/server/addon.js +168 -5
- package/dist/server/addon.js.map +1 -1
- package/dist/sw.js +1 -1
- package/package.json +1 -1
- package/dist/assets/index-DFRMwfPq.js +0 -1
- package/dist/assets/index-DRW7rVhn.js +0 -1133
- package/dist/assets/index-DYSrVZ4G.js +0 -1
- package/dist/assets/index-DeVjiPqm.js +0 -1
- package/dist/assets/index-DuHBxCOe.js +0 -1
- package/dist/assets/index-Dv0-1gwL.js +0 -80
- package/dist/assets/index-NNW--T4H.js +0 -80
- package/dist/assets/index-n9RexO7D.css +0 -1
- package/dist/assets/method-access-map-OoQznstl.js +0 -1
|
@@ -0,0 +1,1156 @@
|
|
|
1
|
+
import"./virtualExposes-_ivNhQLP.js";import{d as _r}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-C3bnYyiP.js";import{c as o,a as Kh,d as f,e as he,g as t2}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-C_6K4VBY.js";import{b as ze,e as _,h as U,c as Y,f as q,d as ve,a as Wh,j as Ue,k as Ee,i as te,l as Xn,m as Ia,g as Aa,R as Ge,n as Sc,o as n2,p as r2,q as $r,r as He,s as o2,t as s2,u as a2,v as i2}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-Dl4u0xYE.js";import{a as Yh,b as Uo}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-CzO_Esxm.js";import{a as Zh,b as Xh}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-DNpf5SLz.js";import{_ as Jh,m as Ln,n as ke,o as em,p as tm,h as Gn,j as l2}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-CeLhKMin.js";import{_ as nm,c as rm,s as om,n as c2,B as d2,F as u2}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.mjs-DIkg6-MH.js";import{_ as sm,a as p2}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-OcRSBqRe.js";import{c as f2,D as am,E as h2,a as Kn,b as ft,M as m2,W as Sl,S as g2,d as Fs}from"./index-DJ0oJxIB.js";import{S as Cl,c as im}from"./devices-DFv560M2.js";import{a as b2}from"./schemas-BEt-CulV.js";import{E as Ne,A as x2,K as y2}from"./method-access-map-DLph6s5D.js";import{s as v2}from"./index-BuBZuTof.js";import{a as _u,C as w2,S as $u,s as N2}from"./index-8vQS4K6d.js";import{r as lm}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-CSyOECfO.js";import{_ as k2}from"./preload-helper-BlTxHScW.js";import"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-xw6c6JeS.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"]'))r(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"&&r(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 r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();const cm={frigate:"#3b82f6",scrypted:"#a855f7",reolink:"#06b6d4",homeAssistant:"#22d3ee",rtsp:"#78716c"},dm={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:cm},um={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:cm},Ml={colors:{dark:dm,light:um},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 pm(e,t){const n={...e};for(const r in t){const s=t[r],a=e[r];s!==void 0&&typeof s=="object"&&s!==null&&!Array.isArray(s)&&typeof a=="object"&&a!==null?n[r]=pm(a,s):s!==void 0&&(n[r]=s)}return n}function S2(e){return e?pm(structuredClone(Ml),e):structuredClone(Ml)}function fm(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function C2(e){return`--color-${fm(e)}`}function Du(e){const t=[];for(const[n,r]of Object.entries(e))n!=="provider"&&t.push(` ${C2(n)}: ${r};`);return t.join(`
|
|
2
|
+
`)}function M2(e){const t=[];for(const[n,r]of Object.entries(e))t.push(` --color-provider-${fm(n)}: ${r};`);return t.join(`
|
|
3
|
+
`)}function E2(e){const t=[];for(const[n,r]of Object.entries(e))t.push(` --spacing-${n}: ${r}px;`);return t.join(`
|
|
4
|
+
`)}function I2(e){const t=[];for(const[n,r]of Object.entries(e))t.push(` --radius-${n}: ${r}px;`);return t.join(`
|
|
5
|
+
`)}function A2(e){const t=Du(e.colors.dark),n=Du(e.colors.light),r=M2(e.colors.dark.provider),s=E2(e.spacing),a=I2(e.radius);return`@theme {
|
|
6
|
+
${r}
|
|
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 hm=ze(null),Ni=["dark","light","system"];function mm(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function P2(e,t){if(typeof window>"u")return t;const n=localStorage.getItem(e);return n==="dark"||n==="light"||n==="system"?n:t}function Lu(e){return e==="system"?mm():e}function Xs({children:e,defaultMode:t="system",storageKey:n="camstack-theme-mode"}){const[r,s]=_(()=>P2(n,t)),[a,i]=_(()=>Lu(r)),l=U(u=>{s(u),i(Lu(u)),typeof window<"u"&&localStorage.setItem(n,u)},[n]),c=U(()=>{const p=(Ni.indexOf(r)+1)%Ni.length;l(Ni[p]??"dark")},[r,l]);Y(()=>{if(typeof document>"u")return;const u=document.documentElement;u.classList.remove("dark","light"),u.classList.add(a)},[r,a]),Y(()=>{if(typeof window>"u"||r!=="system")return;const u=window.matchMedia("(prefers-color-scheme: dark)"),p=()=>{i(mm())};return u.addEventListener("change",p),()=>u.removeEventListener("change",p)},[r]);const d=q(()=>({mode:r,resolvedMode:a,setMode:l,toggleMode:c}),[r,a,l,c]);return o(hm.Provider,{value:d,children:e})}function Hr(){const e=ve(hm);if(!e)throw new Error("useThemeMode must be used within a ThemeProvider");return e}function gm(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=gm(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function bm(){for(var e,t,n=0,r="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=gm(e))&&(r&&(r+=" "),r+=t);return r}const _2=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},$2=(e,t)=>({classGroupId:e,validator:t}),xm=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Js="-",Tu=[],D2="arbitrary..",L2=e=>{const t=R2(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return T2(i);const l=i.split(Js),c=l[0]===""&&l.length>1?1:0;return ym(l,c,t)},getConflictingClassGroupIds:(i,l)=>{if(l){const c=r[i],d=n[i];return c?d?_2(d,c):c:d||Tu}return n[i]||Tu}}},ym=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const s=e[t],a=n.nextPart.get(s);if(a){const d=ym(e,t+1,a);if(d)return d}const i=n.validators;if(i===null)return;const l=t===0?e.join(Js):e.slice(t).join(Js),c=i.length;for(let d=0;d<c;d++){const u=i[d];if(u.validator(l))return u.classGroupId}},T2=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?D2+r:void 0})(),R2=e=>{const{theme:t,classGroups:n}=e;return O2(n,t)},O2=(e,t)=>{const n=xm();for(const r in e){const s=e[r];Cc(s,n,r,t)}return n},Cc=(e,t,n,r)=>{const s=e.length;for(let a=0;a<s;a++){const i=e[a];B2(i,t,n,r)}},B2=(e,t,n,r)=>{if(typeof e=="string"){z2(e,t,n);return}if(typeof e=="function"){F2(e,t,n,r);return}j2(e,t,n,r)},z2=(e,t,n)=>{const r=e===""?t:vm(t,e);r.classGroupId=n},F2=(e,t,n,r)=>{if(V2(e)){Cc(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push($2(n,e))},j2=(e,t,n,r)=>{const s=Object.entries(e),a=s.length;for(let i=0;i<a;i++){const[l,c]=s[i];Cc(c,vm(t,l),n,r)}},vm=(e,t)=>{let n=e;const r=t.split(Js),s=r.length;for(let a=0;a<s;a++){const i=r[a];let l=n.nextPart.get(i);l||(l=xm(),n.nextPart.set(i,l)),n=l}return n},V2=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,H2=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const s=(a,i)=>{n[a]=i,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(a){let i=n[a];if(i!==void 0)return i;if((i=r[a])!==void 0)return s(a,i),i},set(a,i){a in n?n[a]=i:s(a,i)}}},El="!",Ru=":",q2=[],Ou=(e,t,n,r,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:s}),U2=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=s=>{const a=[];let i=0,l=0,c=0,d;const u=s.length;for(let b=0;b<u;b++){const x=s[b];if(i===0&&l===0){if(x===Ru){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 h=p,m=!1;p.endsWith(El)?(h=p.slice(0,-1),m=!0):p.startsWith(El)&&(h=p.slice(1),m=!0);const g=d&&d>c?d-c:void 0;return Ou(a,m,h,g)};if(t){const s=t+Ru,a=r;r=i=>i.startsWith(s)?a(i.slice(s.length)):Ou(q2,!1,i,void 0,!0)}if(n){const s=r;r=a=>n({className:a,parseClassName:s})}return r},Q2=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];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(),r.push(...s),s=[]),r.push(i)):s.push(i)}return s.length>0&&(s.sort(),r.push(...s)),r}},G2=e=>({cache:H2(e.cacheSize),parseClassName:U2(e),sortModifiers:Q2(e),...L2(e)}),K2=/\s+/,W2=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:s,sortModifiers:a}=t,i=[],l=e.trim().split(K2);let c="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:p,modifiers:h,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:b}=n(u);if(p){c=u+(c.length>0?" "+c:c);continue}let x=!!b,y=r(x?g.substring(0,b):g);if(!y){if(!x){c=u+(c.length>0?" "+c:c);continue}if(y=r(g),!y){c=u+(c.length>0?" "+c:c);continue}x=!1}const w=h.length===0?"":h.length===1?h[0]:a(h).join(":"),v=m?w+El:w,N=v+y;if(i.indexOf(N)>-1)continue;i.push(N);const k=s(y,x);for(let C=0;C<k.length;++C){const M=k[C];i.push(v+M)}c=u+(c.length>0?" "+c:c)}return c},Y2=(...e)=>{let t=0,n,r,s="";for(;t<e.length;)(n=e[t++])&&(r=wm(n))&&(s&&(s+=" "),s+=r);return s},wm=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=wm(e[r]))&&(n&&(n+=" "),n+=t);return n},Z2=(e,...t)=>{let n,r,s,a;const i=c=>{const d=t.reduce((u,p)=>p(u),e());return n=G2(d),r=n.cache.get,s=n.cache.set,a=l,l(c)},l=c=>{const d=r(c);if(d)return d;const u=W2(c,n);return s(c,u),u};return a=i,(...c)=>a(Y2(...c))},X2=[],Ye=e=>{const t=n=>n[e]||X2;return t.isThemeGetter=!0,t},Nm=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,km=/^\((?:(\w[\w-]*):)?(.+)\)$/i,J2=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ek=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,tk=/\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$/,nk=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,rk=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ok=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,kn=e=>J2.test(e),Ie=e=>!!e&&!Number.isNaN(Number(e)),Sn=e=>!!e&&Number.isInteger(Number(e)),ki=e=>e.endsWith("%")&&Ie(e.slice(0,-1)),sn=e=>ek.test(e),Sm=()=>!0,sk=e=>tk.test(e)&&!nk.test(e),Mc=()=>!1,ak=e=>rk.test(e),ik=e=>ok.test(e),lk=e=>!xe(e)&&!ye(e),ck=e=>Tn(e,Em,Mc),xe=e=>Nm.test(e),jn=e=>Tn(e,Im,sk),Bu=e=>Tn(e,bk,Ie),dk=e=>Tn(e,Pm,Sm),uk=e=>Tn(e,Am,Mc),zu=e=>Tn(e,Cm,Mc),pk=e=>Tn(e,Mm,ik),ds=e=>Tn(e,_m,ak),ye=e=>km.test(e),oo=e=>dr(e,Im),fk=e=>dr(e,Am),Fu=e=>dr(e,Cm),hk=e=>dr(e,Em),mk=e=>dr(e,Mm),us=e=>dr(e,_m,!0),gk=e=>dr(e,Pm,!0),Tn=(e,t,n)=>{const r=Nm.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},dr=(e,t,n=!1)=>{const r=km.exec(e);return r?r[1]?t(r[1]):n:!1},Cm=e=>e==="position"||e==="percentage",Mm=e=>e==="image"||e==="url",Em=e=>e==="length"||e==="size"||e==="bg-size",Im=e=>e==="length",bk=e=>e==="number",Am=e=>e==="family-name",Pm=e=>e==="number"||e==="weight",_m=e=>e==="shadow",xk=()=>{const e=Ye("color"),t=Ye("font"),n=Ye("text"),r=Ye("font-weight"),s=Ye("tracking"),a=Ye("leading"),i=Ye("breakpoint"),l=Ye("container"),c=Ye("spacing"),d=Ye("radius"),u=Ye("shadow"),p=Ye("inset-shadow"),h=Ye("text-shadow"),m=Ye("drop-shadow"),g=Ye("blur"),b=Ye("perspective"),x=Ye("aspect"),y=Ye("ease"),w=Ye("animate"),v=()=>["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(),ye,xe],C=()=>["auto","hidden","clip","visible","scroll"],M=()=>["auto","contain","none"],P=()=>[ye,xe,c],I=()=>[kn,"full","auto",...P()],z=()=>[Sn,"none","subgrid",ye,xe],A=()=>["auto",{span:["full",Sn,ye,xe]},Sn,ye,xe],O=()=>[Sn,"auto",ye,xe],R=()=>["auto","min","max","fr",ye,xe],E=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],D=()=>["start","end","center","stretch","center-safe","end-safe"],L=()=>["auto",...P()],T=()=>[kn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...P()],B=()=>[kn,"screen","full","dvw","lvw","svw","min","max","fit",...P()],F=()=>[kn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...P()],j=()=>[e,ye,xe],V=()=>[...N(),Fu,zu,{position:[ye,xe]}],$=()=>["no-repeat",{repeat:["","x","y","space","round"]}],H=()=>["auto","cover","contain",hk,ck,{size:[ye,xe]}],G=()=>[ki,oo,jn],Z=()=>["","none","full",d,ye,xe],oe=()=>["",Ie,oo,jn],ne=()=>["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=()=>[Ie,ki,Fu,zu],be=()=>["","none",g,ye,xe],J=()=>["none",Ie,ye,xe],W=()=>["none",Ie,ye,xe],ee=()=>[Ie,ye,xe],ae=()=>[kn,"full",...P()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[sn],breakpoint:[sn],color:[Sm],container:[sn],"drop-shadow":[sn],ease:["in","out","in-out"],font:[lk],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[sn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[sn],shadow:[sn],spacing:["px",Ie],text:[sn],"text-shadow":[sn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",kn,xe,ye,x]}],container:["container"],columns:[{columns:[Ie,xe,ye,l]}],"break-after":[{"break-after":v()}],"break-before":[{"break-before":v()}],"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:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],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:[Sn,"auto",ye,xe]}],basis:[{basis:[kn,"full","auto",l,...P()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ie,kn,"auto","initial","none",xe]}],grow:[{grow:["",Ie,ye,xe]}],shrink:[{shrink:["",Ie,ye,xe]}],order:[{order:[Sn,"first","last","none",ye,xe]}],"grid-cols":[{"grid-cols":z()}],"col-start-end":[{col:A()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":z()}],"row-start-end":[{row:A()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:P()}],"gap-x":[{"gap-x":P()}],"gap-y":[{"gap-y":P()}],"justify-content":[{justify:[...E(),"normal"]}],"justify-items":[{"justify-items":[...D(),"normal"]}],"justify-self":[{"justify-self":["auto",...D()]}],"align-content":[{content:["normal",...E()]}],"align-items":[{items:[...D(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...D(),{baseline:["","last"]}]}],"place-content":[{"place-content":E()}],"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:L()}],mx:[{mx:L()}],my:[{my:L()}],ms:[{ms:L()}],me:[{me:L()}],mbs:[{mbs:L()}],mbe:[{mbe:L()}],mt:[{mt:L()}],mr:[{mr:L()}],mb:[{mb:L()}],ml:[{ml:L()}],"space-x":[{"space-x":P()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":P()}],"space-y-reverse":["space-y-reverse"],size:[{size:T()}],"inline-size":[{inline:["auto",...B()]}],"min-inline-size":[{"min-inline":["auto",...B()]}],"max-inline-size":[{"max-inline":["none",...B()]}],"block-size":[{block:["auto",...F()]}],"min-block-size":[{"min-block":["auto",...F()]}],"max-block-size":[{"max-block":["none",...F()]}],w:[{w:[l,"screen",...T()]}],"min-w":[{"min-w":[l,"screen","none",...T()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...T()]}],h:[{h:["screen","lh",...T()]}],"min-h":[{"min-h":["screen","lh","none",...T()]}],"max-h":[{"max-h":["screen","lh",...T()]}],"font-size":[{text:["base",n,oo,jn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,gk,dk]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ki,xe]}],"font-family":[{font:[fk,uk,t]}],"font-features":[{"font-features":[xe]}],"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,ye,xe]}],"line-clamp":[{"line-clamp":[Ie,"none",ye,Bu]}],leading:[{leading:[a,...P()]}],"list-image":[{"list-image":["none",ye,xe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ye,xe]}],"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:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ie,"from-font","auto",ye,jn]}],"text-decoration-color":[{decoration:j()}],"underline-offset":[{"underline-offset":[Ie,"auto",ye,xe]}],"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",ye,xe]}],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",ye,xe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:V()}],"bg-repeat":[{bg:$()}],"bg-size":[{bg:H()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Sn,ye,xe],radial:["",ye,xe],conic:[Sn,ye,xe]},mk,pk]}],"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:Z()}],"rounded-s":[{"rounded-s":Z()}],"rounded-e":[{"rounded-e":Z()}],"rounded-t":[{"rounded-t":Z()}],"rounded-r":[{"rounded-r":Z()}],"rounded-b":[{"rounded-b":Z()}],"rounded-l":[{"rounded-l":Z()}],"rounded-ss":[{"rounded-ss":Z()}],"rounded-se":[{"rounded-se":Z()}],"rounded-ee":[{"rounded-ee":Z()}],"rounded-es":[{"rounded-es":Z()}],"rounded-tl":[{"rounded-tl":Z()}],"rounded-tr":[{"rounded-tr":Z()}],"rounded-br":[{"rounded-br":Z()}],"rounded-bl":[{"rounded-bl":Z()}],"border-w":[{border:oe()}],"border-w-x":[{"border-x":oe()}],"border-w-y":[{"border-y":oe()}],"border-w-s":[{"border-s":oe()}],"border-w-e":[{"border-e":oe()}],"border-w-bs":[{"border-bs":oe()}],"border-w-be":[{"border-be":oe()}],"border-w-t":[{"border-t":oe()}],"border-w-r":[{"border-r":oe()}],"border-w-b":[{"border-b":oe()}],"border-w-l":[{"border-l":oe()}],"divide-x":[{"divide-x":oe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":oe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ne(),"hidden","none"]}],"divide-style":[{divide:[...ne(),"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:[...ne(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ie,ye,xe]}],"outline-w":[{outline:["",Ie,oo,jn]}],"outline-color":[{outline:j()}],shadow:[{shadow:["","none",u,us,ds]}],"shadow-color":[{shadow:j()}],"inset-shadow":[{"inset-shadow":["none",p,us,ds]}],"inset-shadow-color":[{"inset-shadow":j()}],"ring-w":[{ring:oe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:j()}],"ring-offset-w":[{"ring-offset":[Ie,jn]}],"ring-offset-color":[{"ring-offset":j()}],"inset-ring-w":[{"inset-ring":oe()}],"inset-ring-color":[{"inset-ring":j()}],"text-shadow":[{"text-shadow":["none",h,us,ds]}],"text-shadow-color":[{"text-shadow":j()}],opacity:[{opacity:[Ie,ye,xe]}],"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":[Ie]}],"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":[ye,xe]}],"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":[Ie]}],"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:V()}],"mask-repeat":[{mask:$()}],"mask-size":[{mask:H()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ye,xe]}],filter:[{filter:["","none",ye,xe]}],blur:[{blur:be()}],brightness:[{brightness:[Ie,ye,xe]}],contrast:[{contrast:[Ie,ye,xe]}],"drop-shadow":[{"drop-shadow":["","none",m,us,ds]}],"drop-shadow-color":[{"drop-shadow":j()}],grayscale:[{grayscale:["",Ie,ye,xe]}],"hue-rotate":[{"hue-rotate":[Ie,ye,xe]}],invert:[{invert:["",Ie,ye,xe]}],saturate:[{saturate:[Ie,ye,xe]}],sepia:[{sepia:["",Ie,ye,xe]}],"backdrop-filter":[{"backdrop-filter":["","none",ye,xe]}],"backdrop-blur":[{"backdrop-blur":be()}],"backdrop-brightness":[{"backdrop-brightness":[Ie,ye,xe]}],"backdrop-contrast":[{"backdrop-contrast":[Ie,ye,xe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ie,ye,xe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ie,ye,xe]}],"backdrop-invert":[{"backdrop-invert":["",Ie,ye,xe]}],"backdrop-opacity":[{"backdrop-opacity":[Ie,ye,xe]}],"backdrop-saturate":[{"backdrop-saturate":[Ie,ye,xe]}],"backdrop-sepia":[{"backdrop-sepia":["",Ie,ye,xe]}],"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",ye,xe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ie,"initial",ye,xe]}],ease:[{ease:["linear","initial",y,ye,xe]}],delay:[{delay:[Ie,ye,xe]}],animate:[{animate:["none",w,ye,xe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,ye,xe]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:J()}],"rotate-x":[{"rotate-x":J()}],"rotate-y":[{"rotate-y":J()}],"rotate-z":[{"rotate-z":J()}],scale:[{scale:W()}],"scale-x":[{"scale-x":W()}],"scale-y":[{"scale-y":W()}],"scale-z":[{"scale-z":W()}],"scale-3d":["scale-3d"],skew:[{skew:ee()}],"skew-x":[{"skew-x":ee()}],"skew-y":[{"skew-y":ee()}],transform:[{transform:[ye,xe,"","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",ye,xe]}],"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",ye,xe]}],fill:[{fill:["none",...j()]}],"stroke-w":[{stroke:[Ie,oo,jn,Bu]}],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"]}},yk=Z2(xk);function K(...e){return yk(bm(e))}const vk="rounded-lg border border-border bg-surface overflow-hidden",wk="border-b border-border px-3 sm:px-4 py-1.5 sm:py-2",Nk="p-2 sm:p-3 lg:p-4",$m="space-y-3 sm:space-y-4",Dm="gap-2 sm:gap-3",Lm="px-3 sm:px-4 py-1.5 sm:py-2",kk="grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4",Sk="grid grid-cols-1 lg:grid-cols-2",Ck="flex flex-col-reverse md:flex-row",Mk="w-full md:w-44 lg:w-52 md:flex-shrink-0 border-b md:border-b-0 md:border-l border-border",Ek="text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider",Ik="text-[11px] sm:text-xs text-foreground",ea="text-[10px] text-foreground-subtle",Ak="text-[11px] sm:text-xs font-medium text-foreground",Il="text-base sm:text-lg font-semibold leading-tight text-foreground",Pk="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",_k="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",$k="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",Dk="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",Lk="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",Tk="inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors",Rk="border-primary/50 bg-primary/15 text-primary",Ok="border-border bg-surface text-foreground-subtle hover:bg-surface-hover";function Bk(e,t){for(const n of e.slots)for(const r of n.addons)if(r.id===t)return r;return null}function zk(e,t){return e.models.find(n=>n.id===t)??null}function Fk(e,t){return e.models.find(n=>!!n.formats[t])??null}function jk(e,t){const n=new Set((t.configSchema??[]).map(s=>s.key)),r={};for(const[s,a]of Object.entries(e))n.has(s)&&(r[s]=a);return r}function Tm(e){const{source:t,target:n,catalog:r,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=Bk(r,i);if(!c){a.push({addonId:i,outcome:"skip",modelId:null,reason:"addon not in target catalog",patch:null});continue}const d=zk(c,l.modelId),u=d!==null&&!!d.formats[n.engine.format];let p,h;if(u)p=l.modelId,h="exact";else{const g=Fk(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,h="mapped"}const m={enabled:l.enabled,modelId:p,settings:jk(l.settings,c)};a.push({addonId:i,outcome:h,modelId:p,patch:m})}return a}const Al={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 ur(e){return Al[e]??Al.watching}function yn(e,t){if(typeof globalThis>"u")return ze(t);const n=globalThis.__camstackSharedContexts,r=n??new Map;n||(globalThis.__camstackSharedContexts=r);const s=r.get(e);if(s)return s;const a=ze(t);return r.set(e,a),a}function Er(e){const n=(typeof globalThis<"u"?globalThis:void 0)?.[e];return n&&typeof n=="object"?n:{}}const Vk={singleton:!0,requiredVersion:!1,eager:!0},Qt=e=>({version:"0.0.0",scope:"default",lib:e,shareConfig:Vk}),ju="__mf_module_cache__";function Hk(){const e=globalThis,t=e[ju];if(t&&typeof t=="object"){const r=t;return r.share??={},r.remote??={},r}const n={share:{},remote:{}};return e[ju]=n,n}function qk(){const e=Hk();e.share.react??=Wh,e.share["react-dom"]??=Yh,e.share["react-dom/client"]??=Zh,e.share["react/jsx-runtime"]??=Kh,e.share["@tanstack/react-query"]??=Jh,e.share["@trpc/client"]??=nm,e.share["@trpc/react-query"]??=sm,e.share["@camstack/ui-library"]??=Er("__camstackUiLibrary"),e.share["@camstack/sdk"]??=Er("__camstackSdk"),e.share["@camstack/types"]??=Er("__camstackTypes")}function Ec(){qk(),_r.getInstance()===null&&_r.init({name:"admin_ui_host",remotes:[],shared:{react:Qt(()=>Wh),"react-dom":Qt(()=>Yh),"react-dom/client":Qt(()=>Zh),"react/jsx-runtime":Qt(()=>Kh),"@tanstack/react-query":Qt(()=>Jh),"@trpc/client":Qt(()=>nm),"@trpc/react-query":Qt(()=>sm),"@camstack/ui-library":Qt(()=>Er("__camstackUiLibrary")),"@camstack/sdk":Qt(()=>Er("__camstackSdk")),"@camstack/types":Qt(()=>Er("__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 Rm=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.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 Uk=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 Qk=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.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 Vu=e=>{const t=Qk(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 Gk={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 Kk=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 Wk=Ue(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:i,...l},c)=>Ee("svg",{ref:c,...Gk,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Rm("lucide",s),...!a&&!Kk(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,u])=>Ee(d,u)),...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 ie=(e,t)=>{const n=Ue(({className:r,...s},a)=>Ee(Wk,{ref:a,iconNode:t,className:Rm(`lucide-${Uk(Vu(e))}`,`lucide-${e}`,r),...s}));return n.displayName=Vu(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 Yk=[["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"}]],In=ie("activity",Yk);/**
|
|
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 Zk=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Xk=ie("arrow-down",Zk);/**
|
|
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 Jk=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],e5=ie("arrow-left",Jk);/**
|
|
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 t5=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],n5=ie("arrow-right",t5);/**
|
|
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 r5=[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]],Ic=ie("arrow-up-to-line",r5);/**
|
|
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 o5=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],s5=ie("arrow-up",o5);/**
|
|
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 a5=[["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"}]],i5=ie("battery-full",a5);/**
|
|
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 l5=[["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"}]],c5=ie("battery-low",l5);/**
|
|
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 d5=[["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"}]],u5=ie("battery-warning",d5);/**
|
|
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 p5=[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],Om=ie("battery",p5);/**
|
|
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 f5=[["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"}]],h5=ie("bell-ring",f5);/**
|
|
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 m5=[["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"}]],Pa=ie("bell",m5);/**
|
|
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 g5=[["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"}]],b5=ie("bug",g5);/**
|
|
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 x5=[["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"}]],Ac=ie("camera",x5);/**
|
|
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 y5=[["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"}]],v5=ie("cast",y5);/**
|
|
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 w5=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],qr=ie("check",w5);/**
|
|
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 N5=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],pr=ie("chevron-down",N5);/**
|
|
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 k5=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],S5=ie("chevron-left",k5);/**
|
|
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 C5=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Rn=ie("chevron-right",C5);/**
|
|
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 M5=[["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"}]],Qo=ie("circle-alert",M5);/**
|
|
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 E5=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],I5=ie("circle-check-big",E5);/**
|
|
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 A5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],P5=ie("circle-check",A5);/**
|
|
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 _5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],$5=ie("circle-dot",_5);/**
|
|
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 D5=[["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"}]],L5=ie("circle-pause",D5);/**
|
|
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 T5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],R5=ie("circle-plus",T5);/**
|
|
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 O5=[["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"}]],Bm=ie("circle-question-mark",O5);/**
|
|
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 B5=[["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"}]],z5=ie("circle-x",B5);/**
|
|
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 F5=[["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"}]],j5=ie("copy-plus",F5);/**
|
|
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 V5=[["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"}]],vn=ie("copy",V5);/**
|
|
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 H5=[["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"}]],q5=ie("cpu",H5);/**
|
|
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 U5=[["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"}]],zm=ie("crosshair",U5);/**
|
|
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 Q5=[["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"}]],G5=ie("database",Q5);/**
|
|
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 K5=[["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"}]],Fm=ie("door-open",K5);/**
|
|
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 W5=[["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"}]],Pl=ie("download",W5);/**
|
|
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 Y5=[["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"}]],jm=ie("ellipsis-vertical",Y5);/**
|
|
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 Z5=[["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"}]],Pc=ie("external-link",Z5);/**
|
|
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 X5=[["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"}]],_c=ie("eye-off",X5);/**
|
|
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 J5=[["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"}]],Ur=ie("eye",J5);/**
|
|
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 eS=[["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"}]],Vm=ie("funnel",eS);/**
|
|
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 tS=[["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"}]],nS=ie("grip-horizontal",tS);/**
|
|
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 rS=[["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"}]],Hm=ie("house",rS);/**
|
|
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 oS=[["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"}]],sS=ie("image",oS);/**
|
|
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 aS=[["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"}]],iS=ie("inbox",aS);/**
|
|
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 lS=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],cS=ie("info",lS);/**
|
|
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 dS=[["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"}]],uS=ie("layout-grid",dS);/**
|
|
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 pS=[["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"}]],qm=ie("lightbulb",pS);/**
|
|
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 fS=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Mt=ie("loader-circle",fS);/**
|
|
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 hS=[["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"}]],mS=ie("locate-fixed",hS);/**
|
|
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 gS=[["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"}]],Hu=ie("maximize-2",gS);/**
|
|
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 bS=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],xS=ie("menu",bS);/**
|
|
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 yS=[["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"}]],Um=ie("mic",yS);/**
|
|
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 vS=[["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"}]],qu=ie("minimize-2",vS);/**
|
|
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 wS=[["path",{d:"M5 12h14",key:"1ays0h"}]],Qm=ie("minus",wS);/**
|
|
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 NS=[["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"}]],$c=ie("moon",NS);/**
|
|
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 kS=[["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"}]],SS=ie("music",kS);/**
|
|
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 CS=[["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"}]],_l=ie("network",CS);/**
|
|
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 MS=[["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"}]],ES=ie("pencil",MS);/**
|
|
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 IS=[["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"}]],$l=ie("play",IS);/**
|
|
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 AS=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Go=ie("plus",AS);/**
|
|
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 PS=[["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"}]],_S=ie("plug",PS);/**
|
|
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 $S=[["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"}]],DS=ie("power-off",$S);/**
|
|
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 LS=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],TS=ie("qr-code",LS);/**
|
|
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 RS=[["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"}]],Gm=ie("radar",RS);/**
|
|
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 OS=[["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"}]],BS=ie("radio",OS);/**
|
|
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 zS=[["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"}]],_a=ie("refresh-cw",zS);/**
|
|
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 FS=[["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"}]],Km=ie("rotate-ccw",FS);/**
|
|
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 jS=[["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"}]],Wm=ie("rotate-cw",jS);/**
|
|
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 VS=[["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"}]],HS=ie("save",VS);/**
|
|
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 qS=[["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"}]],US=ie("scan",qS);/**
|
|
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 QS=[["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"}]],GS=ie("scroll-text",QS);/**
|
|
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 KS=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Mo=ie("search",KS);/**
|
|
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 WS=[["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"}]],YS=ie("server",WS);/**
|
|
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 ZS=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],Uu=ie("share-2",ZS);/**
|
|
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 XS=[["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"}]],JS=ie("shield",XS);/**
|
|
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 eC=[["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"}]],tC=ie("ship",eC);/**
|
|
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 nC=[["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"}]],rC=ie("sliders-horizontal",nC);/**
|
|
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 oC=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Qu=ie("square",oC);/**
|
|
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 sC=[["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"}]],aC=ie("star",sC);/**
|
|
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 iC=[["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"}]],Ym=ie("sun",iC);/**
|
|
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 lC=[["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"}]],cC=ie("table-2",lC);/**
|
|
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 dC=[["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"}]],Gu=ie("target",dC);/**
|
|
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 uC=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],pC=ie("thermometer",uC);/**
|
|
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 fC=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],hC=ie("toggle-left",fC);/**
|
|
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 mC=[["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"}]],Jt=ie("trash-2",mC);/**
|
|
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 gC=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],bC=ie("trending-up",gC);/**
|
|
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 xC=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],yC=ie("trending-down",xC);/**
|
|
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 vC=[["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"}]],Qr=ie("triangle-alert",vC);/**
|
|
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 wC=[["path",{d:"M15 7h2a5 5 0 0 1 0 10h-2m-6 0H7A5 5 0 0 1 7 7h2",key:"1re2ne"}]],NC=ie("unlink-2",wC);/**
|
|
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 kC=[["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"}]],Zm=ie("upload",kC);/**
|
|
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 SC=[["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"}]],CC=ie("wifi-off",SC);/**
|
|
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 MC=[["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"}]],Xm=ie("wifi",MC);/**
|
|
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 EC=[["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"}]],Dc=ie("wrench",EC);/**
|
|
531
|
+
* @license lucide-react v0.576.0 - ISC
|
|
532
|
+
*
|
|
533
|
+
* This source code is licensed under the ISC license.
|
|
534
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
535
|
+
*/const IC=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Je=ie("x",IC);/**
|
|
536
|
+
* @license lucide-react v0.576.0 - ISC
|
|
537
|
+
*
|
|
538
|
+
* This source code is licensed under the ISC license.
|
|
539
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
540
|
+
*/const AC=[["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"}]],Ku=ie("zap",AC);/**
|
|
541
|
+
* @license lucide-react v0.576.0 - ISC
|
|
542
|
+
*
|
|
543
|
+
* This source code is licensed under the ISC license.
|
|
544
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
545
|
+
*/const PC=[["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"}]],_C=ie("zoom-in",PC);/**
|
|
546
|
+
* @license lucide-react v0.576.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 $C=[["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"}]],DC=ie("zoom-out",$C),LC={frigate:tC,scrypted:JS,reolink:BS,homeAssistant:Hm,rtsp:v5},TC={online:P5,offline:z5,degraded:Qo,unknown:Bm},Wu=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Yu=bm,fr=(e,t)=>n=>{var r;if(t?.variants==null)return Yu(e,n?.class,n?.className);const{variants:s,defaultVariants:a}=t,i=Object.keys(s).map(d=>{const u=n?.[d],p=a?.[d];if(u===null)return null;const h=Wu(u)||Wu(p);return s[d][h]}),l=n&&Object.entries(n).reduce((d,u)=>{let[p,h]=u;return h===void 0||(d[p]=h),d},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,u)=>{let{class:p,className:h,...m}=u;return Object.entries(m).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...a,...l}[b]):{...a,...l}[b]===x})?[...d,p,h]:d},[]);return Yu(e,i,c,n?.class,n?.className)},RC=fr("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"}}),Re=Ue(({className:e,variant:t,size:n,...r},s)=>o("button",{ref:s,className:K(RC({variant:t,size:n}),e),...r}));Re.displayName="Button";const OC=fr("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"}}),Lc=Ue(({className:e,variant:t,size:n,icon:r,...s},a)=>o("button",{ref:a,className:K(OC({variant:t,size:n}),e),...s,children:o(r,{className:"h-4 w-4"})}));Lc.displayName="IconButton";const BC=fr("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"}}),zt=Ue(({className:e,variant:t,style:n,...r},s)=>o("span",{ref:s,className:K(BC({variant:t,styleVariant:n}),e),...r}));zt.displayName="Badge";const zC=fr("rounded-lg p-3",{variants:{variant:{flat:"bg-surface",bordered:"bg-surface border border-border"}},defaultVariants:{variant:"bordered"}}),Ft=Ue(({className:e,variant:t,...n},r)=>o("div",{ref:r,className:K(zC({variant:t}),e),...n}));Ft.displayName="Card";function Jm({expanded:e,onExpandedChange:t,header:n,children:r,dimmed:s=!1,hideChevron:a=!1,className:i}){return f("div",{className:K("rounded-lg border border-border bg-surface overflow-hidden",s&&"opacity-[0.45]",i),children:[f("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&&o("span",{className:"text-foreground-subtle shrink-0",children:e?o(pr,{className:"h-4 w-4"}):o(Rn,{className:"h-4 w-4"})}),n]}),e&&r&&o("div",{className:"border-t border-border px-3 py-3",children:r})]})}const Tc=Ue(({className:e,...t},n)=>o("label",{ref:n,className:K("text-[10px] uppercase tracking-wider text-foreground-muted font-medium",e),...t}));Tc.displayName="Label";const FC=fr("",{variants:{orientation:{horizontal:"h-px w-full bg-border-subtle",vertical:"w-px h-full bg-border-subtle"}},defaultVariants:{orientation:"horizontal"}}),Rc=Ue(({className:e,orientation:t,...n},r)=>o("div",{ref:r,role:"separator",className:K(FC({orientation:t}),e),...n}));Rc.displayName="Separator";const eg=Ue(({className:e,...t},n)=>o("div",{ref:n,className:K("animate-pulse bg-surface-hover rounded-md h-4 w-full",e),...t}));eg.displayName="Skeleton";const Zu=fr("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"}}),ta=Ue(({className:e,state:t,leftSlot:n,rightSlot:r,...s},a)=>n||r?f("div",{className:"relative flex items-center w-full",children:[n&&o("div",{className:"absolute left-2.5 flex items-center pointer-events-none",children:n}),o("input",{ref:a,className:K(Zu({state:t}),n?"pl-7":"",r?"pr-7":"",e),...s}),r&&o("div",{className:"absolute right-2.5 flex items-center pointer-events-none",children:r})]}):o("input",{ref:a,className:K(Zu({state:t}),e),...s}));ta.displayName="Input";const Eo=Ue(({className:e,options:t,...n},r)=>f("div",{className:"relative w-full",children:[o("select",{ref:r,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=>o("option",{value:s.value,children:s.label},s.value))}),o("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none text-foreground-muted",children:o(pr,{className:"h-3.5 w-3.5"})})]}));Eo.displayName="Select";const tg=Ue(({className:e,...t},n)=>o("input",{ref:n,type:"checkbox",className:K("w-3.5 h-3.5 rounded-sm border border-border accent-primary",e),...t}));tg.displayName="Checkbox";const Oc=Ue(({className:e,checked:t,onCheckedChange:n,label:r,...s},a)=>f("button",{ref:a,role:"switch","aria-checked":t,type:"button",onClick:()=>n(!t),className:K("inline-flex items-center gap-2",e),...s,children:[o("span",{className:K("w-8 h-4 rounded-full transition-colors",t?"bg-primary":"bg-surface-hover"),children:o("span",{className:K("block w-3.5 h-3.5 rounded-full bg-white transition-transform",t?"translate-x-4":"translate-x-0.5")})}),r&&o("span",{className:"text-xs text-foreground",children:r})]}));Oc.displayName="Switch";const ng=ze(null);function rg(){const e=ve(ng);if(!e)throw new Error("Dialog compound components must be used within <Dialog>");return e}function og({children:e,open:t,onOpenChange:n}){const[r,s]=_(!1),a=t??r,i=Xn(),l=U(c=>{n?.(c),t===void 0&&s(c)},[t,n]);return o(ng.Provider,{value:{open:a,setOpen:l,contentId:i},children:e})}function jC({children:e,...t}){const{setOpen:n}=rg();return o("button",{type:"button",onClick:()=>n(!0),...t,children:e})}const VC=fr("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"}}),Bc=Ue(({className:e,width:t,children:n,...r},s)=>{const{open:a,setOpen:i,contentId:l}=rg(),c=te(null),d=s??c;Y(()=>{const p=d.current;p&&(a&&!p.open&&p.showModal(),!a&&p.open&&p.close())},[a,d]);const u=p=>{p.target===p.currentTarget&&i(!1)};return o("dialog",{ref:d,id:l,className:K(VC({width:t}),"w-full",e),onClick:u,onClose:()=>i(!1),...r,children:n})});Bc.displayName="DialogContent";function sg({className:e,...t}){return o("div",{className:K("flex flex-col gap-1 mb-3",e),...t})}function ag({className:e,...t}){return o("div",{className:K("flex justify-end gap-2 mt-4",e),...t})}function ig({className:e,...t}){return o("h2",{className:K("text-sm font-semibold text-foreground",e),...t})}function lg({className:e,...t}){return o("p",{className:K("text-xs text-foreground-muted",e),...t})}const cg=ze(null);function zc(){const e=ve(cg);if(!e)throw new Error("Dropdown compound components must be used within <Dropdown>");return e}function dg({children:e}){const[t,n]=_(!1),r=Xn(),s=Xn(),a=te(null);return o(cg.Provider,{value:{open:t,setOpen:n,triggerId:r,contentId:s,triggerRef:a},children:o("div",{className:"relative inline-block",children:e})})}function ug({children:e,...t}){const{open:n,setOpen:r,triggerId:s,contentId:a,triggerRef:i}=zc();return o("button",{type:"button",ref:i,id:s,"aria-haspopup":"menu","aria-expanded":n,"aria-controls":n?a:void 0,onClick:()=>r(!n),...t,children:e})}function pg({className:e,children:t,align:n="start",offset:r=4,...s}){const{open:a,setOpen:i,contentId:l,triggerId:c,triggerRef:d}=zc(),u=te(null),[p,h]=_(null);if(Ia(()=>{if(!a){h(null);return}const g=()=>{const b=d.current;if(!b)return;const x=b.getBoundingClientRect(),y=n==="end"?x.right:x.left;h({top:x.bottom+r,left:y,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,r,d]),Y(()=>{if(!a)return;const g=x=>{const y=u.current,w=d.current;y&&!y.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 m={position:"fixed",top:p.top,...n==="end"?{right:window.innerWidth-p.left}:{left:p.left},minWidth:p.minWidth};return Uo(o("div",{ref:u,id:l,role:"menu","aria-labelledby":c,style:m,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 fg({className:e,icon:t,variant:n="default",children:r,onClick:s,...a}){const{setOpen:i}=zc(),l=U(c=>{s?.(c),i(!1)},[s,i]);return f("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&&o(t,{size:14}),r]})}const hg=ze(null);function mg(){const e=ve(hg);if(!e)throw new Error("Tooltip compound components must be used within <Tooltip>");return e}function HC({children:e}){const[t,n]=_(!1),r=te(null),s=Xn(),a=()=>{r.current=setTimeout(()=>n(!0),300)},i=()=>{r.current&&clearTimeout(r.current),n(!1)};return o(hg.Provider,{value:{open:t,show:a,hide:i,tooltipId:s},children:o("div",{className:"relative inline-block",children:e})})}function qC({children:e,...t}){const{show:n,hide:r,tooltipId:s,open:a}=mg();return o("div",{onMouseEnter:n,onMouseLeave:r,onFocus:n,onBlur:r,"aria-describedby":a?s:void 0,...t,children:e})}function UC({className:e,children:t,...n}){const{open:r,tooltipId:s}=mg();return o("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",r?"opacity-100":"opacity-0",e),...n,children:t})}const Xu="(max-width: 767px)",Ju="(min-width: 768px) and (max-width: 1023px)";function gg(e){return t=>{const n=window.matchMedia(e);return n.addEventListener("change",t),()=>n.removeEventListener("change",t)}}function bg(e){return()=>window.matchMedia(e).matches}function xg(){return!1}function hr(){return Aa(gg(Xu),bg(Xu),xg)}function yg(){return Aa(gg(Ju),bg(Ju),xg)}function Fc({open:e,onClose:t,title:n,children:r,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]),f(he,{children:[o("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"}),f("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:[o("div",{className:"flex justify-center pt-2 pb-1",children:o("div",{className:"h-1 w-8 rounded-full bg-foreground-subtle/30"})}),n&&f("div",{className:"flex items-center justify-between px-4 pb-2",children:[o("span",{className:"text-sm font-medium text-foreground",children:n}),o("button",{onClick:t,className:"p-1 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors",children:o(Je,{className:"h-4 w-4"})})]}),o("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:r})]})]})}const vg=ze(null);function wg(){const e=ve(vg);if(!e)throw new Error("Popover compound components must be used within <Popover>");return e}function Ng({children:e,open:t,onOpenChange:n}){const[r,s]=_(!1),a=t??r,i=Xn(),l=Xn(),c=U(d=>{n?.(d),t===void 0&&s(d)},[t,n]);return o(vg.Provider,{value:{open:a,setOpen:c,triggerId:i,contentId:l},children:o("div",{className:"relative inline-block",children:e})})}function kg({children:e,...t}){const{open:n,setOpen:r,triggerId:s,contentId:a}=wg();return o("button",{type:"button",id:s,"aria-haspopup":"dialog","aria-expanded":n,"aria-controls":n?a:void 0,onClick:()=>r(!n),...t,children:e})}function Sg({className:e,children:t,...n}){const{open:r,setOpen:s,contentId:a,triggerId:i}=wg(),l=hr(),c=te(null);return Y(()=>{if(!r||l)return;const d=p=>{const h=c.current,m=document.getElementById(i);h&&!h.contains(p.target)&&!m?.contains(p.target)&&s(!1)},u=p=>{p.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",d),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",u)}},[r,s,i,l]),r?l?o(Fc,{open:r,onClose:()=>s(!1),children:t}):o("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 Cg=ze(null);function Mg(){const e=ve(Cg);if(!e)throw new Error("Tabs compound components must be used within <Tabs>");return e}function QC({value:e,onValueChange:t,defaultValue:n="",className:r,...s}){const[a,i]=_(n),l=e??a,c=U(d=>{t?.(d),e===void 0&&i(d)},[e,t]);return o(Cg.Provider,{value:{value:l,setValue:c},children:o("div",{className:r,...s})})}function GC({className:e,...t}){return o("div",{role:"tablist",className:K("flex flex-row border-b border-border-subtle",e),...t})}function KC({value:e,className:t,...n}){const{value:r,setValue:s}=Mg(),a=e===r,i=`tabpanel-${e}`;return o("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 WC({value:e,className:t,...n}){const{value:r}=Mg();return e!==r?null:o("div",{role:"tabpanel",id:`tabpanel-${e}`,className:K("pt-3",t),...n})}const jc=Ue(({className:e,...t},n)=>o("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}));jc.displayName="ScrollArea";function YC({title:e,onClose:t,children:n,defaultWidth:r=360,defaultHeight:s=280,minWidth:a=280,minHeight:i=160,offsetIndex:l=0,className:c}){const[d,u]=_({x:80+l*30,y:80+l*30}),[p,h]=_({w:r,h:s}),[m,g]=_(!1),b=te(!1),x=te(!1),y=te({x:0,y:0}),w=hr(),v=U(k=>{k.preventDefault(),b.current=!0,y.current={x:k.clientX-d.x,y:k.clientY-d.y}},[d]),N=U(k=>{k.preventDefault(),k.stopPropagation(),x.current=!0,y.current={x:k.clientX,y:k.clientY}},[]);return Y(()=>{const k=M=>{if(b.current&&u({x:M.clientX-y.current.x,y:M.clientY-y.current.y}),x.current){const P=M.clientX-y.current.x,I=M.clientY-y.current.y;y.current={x:M.clientX,y:M.clientY},h(z=>({w:Math.max(a,z.w+P),h:Math.max(i,z.h+I)}))}},C=()=>{b.current=!1,x.current=!1};return window.addEventListener("mousemove",k),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",C)}},[a,i]),w?f("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:[f("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border shrink-0 bg-surface",children:[o("span",{className:"text-[11px] font-medium truncate",children:e}),f("div",{className:"flex items-center gap-1 shrink-0",children:[o("button",{onClick:()=>g(!m),className:"p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors",children:m?o(Hu,{size:12}):o(qu,{size:12})}),o("button",{onClick:t,className:"p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors",children:o(Je,{size:12})})]})]}),!m&&o("div",{className:"flex-1 min-h-0 overflow-y-auto",children:n})]}):f("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:m?280:p.w,height:m?"auto":p.h},children:[f("div",{onMouseDown:v,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:[f("div",{className:"flex items-center gap-2 min-w-0",children:[o(nS,{size:12,className:"text-foreground-subtle shrink-0"}),o("span",{className:"text-[11px] font-medium truncate",children:e})]}),f("div",{className:"flex items-center gap-1 shrink-0",children:[o("button",{onClick:()=>g(!m),className:"p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors",title:m?"Restore":"Minimize",children:m?o(Hu,{size:12}):o(qu,{size:12})}),o("button",{onClick:t,className:"p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors",title:"Close",children:o(Je,{size:12})})]})]}),!m&&f("div",{className:"flex-1 min-h-0 overflow-y-auto relative",children:[n,o("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 Vc({open:e,onClose:t,children:n,className:r,width:s="w-64"}){const a=te(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]),f(he,{children:[o("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"}),o("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",r),children:n})]})}function Hc({items:e,className:t}){return o("nav",{className:`flex items-center gap-1 text-[11px] text-foreground-subtle ${t??""}`,children:e.map((n,r)=>{const s=r===e.length-1,a=!s&&(n.onClick||n.href);return f(Ge.Fragment,{children:[r>0&&o(Rn,{className:"h-3 w-3 flex-shrink-0"}),a?n.onClick?o("button",{type:"button",onClick:n.onClick,className:"hover:text-foreground transition-colors",children:n.label}):o("a",{href:n.href,className:"hover:text-foreground transition-colors",children:n.label}):o("span",{className:s?"text-foreground font-medium":"",children:n.label})]},r)})})}const ep={left:"text-left",right:"text-right",center:"text-center"};function $a({columns:e,rows:t,rowKey:n,onRowClick:r,minWidthPx:s=480,emptyMessage:a,className:i,bordered:l=!0,rowClassName:c}){if(t.length===0&&a)return o("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 o("div",{className:d,children:f("table",{className:"w-full text-xs",style:{minWidth:`${s}px`},children:[o("thead",{className:"bg-surface",children:o("tr",{children:e.map(u=>{const p=u.align??"left",h=u.nowrap??!0;return o("th",{className:["px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border",ep[p],h?"whitespace-nowrap":"",u.width??""].filter(Boolean).join(" "),children:u.headerRender?u.headerRender():u.header},u.key)})})}),o("tbody",{children:t.map((u,p)=>{const h=n?n(u,p):p,m=c?.(u,p)??"",g=r!==void 0;return o("tr",{onClick:g?()=>r(u,p):void 0,className:[g?"cursor-pointer hover:bg-primary/5":"hover:bg-primary/5",m].filter(Boolean).join(" "),children:e.map(b=>{const x=b.align??"left",y=b.nowrap??!1;return o("td",{className:["px-3 py-2 text-foreground border-b border-border",ep[x],y?"whitespace-nowrap":""].filter(Boolean).join(" "),children:b.render(u,p)},b.key)})},h)})})]})})}function qc({open:e,onClose:t,title:n,subtitle:r,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?f("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:[f("header",{className:"flex items-start justify-between gap-2 px-4 py-3 border-b border-border",children:[f("div",{className:"min-w-0",children:[o("div",{className:"text-sm font-semibold text-foreground truncate",children:n}),r!==void 0&&o("div",{className:"text-[11px] text-foreground-subtle mt-0.5 truncate",children:r})]}),o("button",{type:"button",onClick:t,className:"p-1 rounded hover:bg-muted text-foreground-subtle hover:text-foreground","aria-label":"Close panel",children:o(Je,{className:"w-4 h-4"})})]}),o("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-3",children:a}),s!==void 0&&o("footer",{className:"flex items-center gap-2 justify-end px-4 py-3 border-t border-border",children:s})]}):null}const ZC={inherit:"bg-muted",on:"bg-emerald-500",off:"bg-orange-500",na:"bg-gray-300 opacity-50"};function Eg({node:e,depth:t,selectedAddonId:n,onSelect:r,agentDots:s}){const a=e.addonId===n,i=s?.[e.addonId]??[];return f("div",{children:[f("button",{type:"button",onClick:()=>r(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:[o("span",{className:"truncate",children:e.addonName}),i.length>0&&o("span",{className:"flex items-center gap-1 shrink-0",children:i.map(l=>o("span",{title:`${l.agentNodeId}: ${l.state}`,className:K("w-2 h-2 rounded-full",ZC[l.state])},l.agentNodeId))})]}),e.children.map(l=>o(Eg,{node:l,depth:t+1,selectedAddonId:n,onSelect:r,agentDots:s},l.addonId))]})}function Ig({tree:e,selectedAddonId:t,onSelect:n,agentDots:r,className:s}){return o("div",{className:K("flex flex-col py-2",s),children:e.map(a=>o(Eg,{node:a,depth:0,selectedAddonId:t,onSelect:n,agentDots:r},a.addonId))})}function Da(e){const t=[],n=[],r=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),r.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 XC(e){return e?e.models.map(t=>({id:t.id,name:t.name})):[]}function js({step:e,schema:t,allSchemas:n,depth:r=0,onChange:s,onDelete:a,readOnly:i=!1,toggleMode:l="simple",overrideState:c=null,onOverrideChange:d,inheritedEnabled:u,hideModelAndSettings:p=!1}){const[h,m]=_(!1),g=XC(t);if(g.length>0&&!g.some(x=>x.id===e.modelId)&&!i){const y=(t?.defaultModelId?g.find(w=>w.id===t.defaultModelId):null)??g[0];y&&y.id!==e.modelId&&queueMicrotask(()=>s({...e,modelId:y.id}))}const b=f(he,{children:[f("div",{className:"flex-1 min-w-0",children:[o("span",{className:"text-[10px] uppercase tracking-wider font-medium text-foreground-subtle/60 block leading-none",children:e.slot}),o("span",{className:"text-sm font-semibold text-foreground truncate block leading-tight",children:e.addonName}),f("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(x=>o("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&&o("span",{className:"text-foreground-subtle/40 text-[10px]",children:"→"}),e.outputClasses.map(x=>o("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"&&o("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:o("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&&f("div",{className:"flex items-center gap-0.5 rounded-md border border-border p-0.5",onClick:x=>x.stopPropagation(),children:[o(Si,{label:"Inherit",active:c===null,variant:"inherit",subtext:u===void 0?void 0:u?"on":"off",onClick:()=>d(null)}),o(Si,{label:"On",active:c===!0,variant:"on",onClick:()=>d(!0)}),o(Si,{label:"Off",active:c===!1,variant:"off",onClick:()=>d(!1)})]})]});return o(Jm,{expanded:h,onExpandedChange:m,dimmed:!e.enabled,header:b,children:p?o("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."}):f("div",{className:"space-y-3",children:[o(Dl,{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&&o(Dl,{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[y,w]=x.split("/");s({...e,engine:{runtime:y,backend:w,format:w==="coreml"?"coreml":"onnx"}})}}),t?.configSchema?.map(x=>o(La,{field:x,allFields:t.configSchema??[],step:e,disabled:i,onChange:s},x.key))]})})}function Dl({label:e,value:t,options:n,disabled:r,onChange:s}){return f("div",{children:[o("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e}),f("select",{value:t,onChange:a=>s(a.target.value),disabled:r,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&&o("option",{value:t,children:t||"default"}),n.map(a=>o("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]})]})}function JC({label:e,description:t,value:n,options:r,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 f("div",{children:[o("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1",children:e}),t&&o("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:t}),o("div",{className:"flex flex-wrap gap-1.5",children:r.map(l=>{const c=n.includes(l.value);return o("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 e3(e,t,n){const r=t.settings?.[e];if(r!==void 0)return r;const s=n.find(a=>"key"in a&&a.key===e);return s&&"default"in s?s.default:void 0}function La({field:e,allFields:t,step:n,disabled:r,onChange:s}){const a=e.type!=="separator"&&e.type!=="info"?e.showWhen:void 0;if(a){const{field:l,equals:c,notEquals:d,in:u,notIn:p}=a,h=e3(l,n,t);if(c!==void 0&&h!==c||d!==void 0&&h===d||u!==void 0&&!u.includes(h)||p!==void 0&&p.includes(h))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 o(Dl,{label:e.label,value:c,disabled:r||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 o(JC,{label:e.label,description:e.description,value:c,options:e.options,disabled:r||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,u=e.min??0,p=e.max??1,h=e.step??.01,m=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 f("div",{children:[f("div",{className:"flex items-center justify-between mb-1",children:[o("span",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide",children:e.label}),m&&f("span",{className:"text-xs font-medium text-foreground tabular-nums",children:[typeof x=="number"?x.toFixed(2).replace(/\.?0+$/,""):x,g?` ${g}`:""]})]}),e.description&&o("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:e.description}),o("input",{type:"range",min:u,max:p,step:h,value:d,disabled:r||e.disabled,onChange:y=>i(Number(y.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 f("label",{className:"flex items-center gap-2",children:[o("input",{type:"checkbox",checked:c,disabled:r||e.disabled,onChange:d=>i(d.target.checked),className:"h-3.5 w-3.5 accent-primary"}),o("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 f("div",{children:[o("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e.label}),e.type==="textarea"?o("textarea",{value:c,disabled:r||e.disabled,placeholder:e.placeholder,onChange:u=>i(u.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"}):o("input",{type:d,value:c,disabled:r||e.disabled,placeholder:e.placeholder,onChange:u=>i(u.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"?o("div",{className:"border-t border-border my-2"}):e.type==="info"?o("div",{className:"rounded-md border border-border bg-surface px-2 py-1.5 text-[10px] text-foreground-subtle",children:e.content}):null}function Si({label:e,active:t,variant:n,subtext:r,onClick:s}){return f("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,r&&t&&f("span",{className:"ml-1 opacity-60",children:["(",r,")"]})]})}function Ag(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 t3(e,t,n){return n?{enabled:n.enabled??t.enabled,modelId:n.modelId??t.modelId,settings:n.settings??t.settings}:t}function n3({addon:e,agentDefault:t,modelsForFormat:n,onChangeAgentConfig:r}){const s=a=>{r?.({...t,...a})};return f("div",{className:"space-y-4 text-xs",children:[f("label",{className:"flex items-center gap-2",children:[o("input",{type:"checkbox",checked:t.enabled,onChange:a=>s({enabled:a.target.checked})}),f("span",{children:["Enabled on this agent (",e.name,")"]})]}),f("div",{children:[o("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle mb-1",children:"Model"}),o("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=>o("option",{value:a.id,children:a.name},a.id))})]}),(e.configSchema?.length??0)>0&&f("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[o("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Settings"}),e.configSchema?.map(a=>o(La,{field:a,allFields:e.configSchema??[],step:Ag(e,t),disabled:!1,onChange:i=>s({settings:{...i.settings}})},a.key))]})]})}function r3({addon:e,agentDefault:t,agentNodeId:n,currentPatch:r,modelsForFormat:s,onChangePatch:a}){const i=t3("device",t,r),l=m=>{const g=m.enabled!==void 0||m.modelId!==void 0||m.settings!==void 0;a?.(g?m:null)},c=m=>{const{enabled:g,...b}=r??{},x=m==="inherit"?b:{...b,enabled:m==="on"};l(x)},d=m=>{const{modelId:g,...b}=r??{},x=m===void 0?b:{...b,modelId:m};l(x)},u=m=>{const{settings:g,...b}=r??{},x=m===void 0?b:{...b,settings:m};l(x)},p=r?.enabled===void 0?"inherit":r.enabled?"on":"off",h=r?.modelId!==void 0;return f("div",{className:"space-y-4 text-xs",children:[f("div",{className:"flex items-center gap-1",children:[["inherit","on","off"].map(m=>o("button",{type:"button",onClick:()=>c(m),className:K("px-3 py-1 border border-border rounded text-xs capitalize",p===m?"bg-primary text-primary-foreground border-primary":"bg-surface text-foreground hover:bg-muted"),children:m},m)),f("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["agent default: ",o("span",{className:"font-semibold",children:t.enabled?"on":"off"})]})]}),f("div",{children:[f("div",{className:"flex items-center justify-between mb-1",children:[o("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Model"}),h?o("button",{type:"button",className:"text-[10px] text-foreground-subtle hover:text-foreground",onClick:()=>d(void 0),children:"Clear"}):o("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>d(t.modelId),children:"Override"})]}),o("select",{disabled:!h,className:"w-full bg-surface border border-border rounded px-2 py-1 text-xs disabled:opacity-50",value:h?r?.modelId??t.modelId:t.modelId,onChange:m=>d(m.target.value),children:s.map(m=>o("option",{value:m.id,children:m.name},m.id))}),!h&&f("div",{className:"text-[10px] text-foreground-subtle mt-1",children:["inherits from ",n]})]}),(e.configSchema?.length??0)>0&&(()=>{const m=r?.settings!==void 0;return f("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[f("div",{className:"flex items-center justify-between",children:[o("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Settings"}),m?o("button",{type:"button",className:"text-[10px] text-foreground-subtle hover:text-foreground",onClick:()=>u(void 0),children:"Clear"}):o("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>u({...t.settings}),children:"Override"})]}),e.configSchema?.map(g=>o(La,{field:g,allFields:e.configSchema??[],step:Ag(e,i),disabled:!m,onChange:b=>u({...b.settings})},g.key)),!m&&f("div",{className:"text-[10px] text-foreground-subtle",children:["inherits from ",n]})]})})(),f("div",{className:"rounded bg-muted/40 px-3 py-2 text-[11px] text-foreground-subtle",children:[o("div",{className:"font-semibold text-foreground mb-0.5",children:"Effective config preview"}),f("div",{className:"font-mono truncate",children:[e.id," · model: ",i.modelId," · ",i.enabled?"on":"off"]})]})]})}function Ta(e){const{mode:t,addon:n,agentDefault:r,agentNodeId:s,currentPatch:a,onChangeAgentConfig:i,onChangePatch:l,engineFormat:c}=e,d=q(()=>n.models.filter(u=>!!u.formats[c]),[n.models,c]);return t==="agent"?o(n3,{addon:n,agentDefault:r,modelsForFormat:d,onChangeAgentConfig:i}):o(r3,{addon:n,agentDefault:r,agentNodeId:s,currentPatch:a,modelsForFormat:d,onChangePatch:l})}function o3(e){const t=[],n=(r,s)=>{for(const a of r)t.push({node:a,depth:s}),n(a.children,s+1)};return n(e,0),t}const tp={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 s3({slot:e}){const t=tp[e]??tp.classifier;return o("span",{className:K("text-[9px] font-semibold uppercase tracking-widest leading-none",t.className),children:t.label})}const np="inline-flex items-center rounded bg-muted px-1.5 py-px text-[9px] font-medium text-foreground-subtle";function a3({inputs:e,outputs:t}){return e.length===0&&t.length===0?null:f("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[e.map(n=>o("span",{className:K(np,"bg-blue-500/10 text-blue-500"),children:n},`in-${n}`)),e.length>0&&t.length>0&&o("span",{className:"text-foreground-subtle/60 text-[9px]",children:"→"}),t.map(n=>o("span",{className:K(np,"bg-emerald-500/10 text-emerald-500"),children:n},`out-${n}`))]})}function i3({enabled:e,onChange:t,disabled:n}){return o("button",{type:"button",role:"switch","aria-checked":e,disabled:n,onClick:r=>{r.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:o("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 l3(e){return e.kind==="enabled"?f("span",{className:"inline-flex items-center gap-1",children:[o("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 shrink-0"}),o("span",{className:"font-mono text-foreground",children:e.modelId})]}):e.kind==="disabled"?f("span",{className:"inline-flex items-center gap-1 text-foreground-subtle",children:[o("span",{className:"h-1.5 w-1.5 rounded-full border border-foreground-subtle/60 shrink-0"}),"off"]}):f("span",{className:"inline-flex items-center gap-1 text-foreground-subtle/70",children:[o("span",{className:"h-1.5 w-1.5 rounded-full bg-muted shrink-0"}),"n/a"]})}function c3({node:e,depth:t,agents:n,getCellState:r,onCellClick:s,selectedCell:a,toggleProps:i}){return f(he,{children:[f("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:[f("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:[o(s3,{slot:e.slot}),f("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"font-semibold truncate",children:e.addonName}),o(a3,{inputs:e.inputClasses,outputs:e.outputClasses})]})]}),i&&o("span",{className:"pl-2 pt-0.5 shrink-0",children:o(i3,{enabled:i.enabled,onChange:i.onChange,disabled:i.disabled})})]}),n.map(l=>{const c=r(e.addonId,l.agentNodeId),d=a?.addonId===e.addonId&&a.agentNodeId===l.agentNodeId;return o("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:l3(c)},l.agentNodeId)})]})}function Uc({tree:e,agents:t,getCellState:n,onCellClick:r,selectedCell:s,onToggleEnabled:a}){const i=q(()=>o3(e),[e]),l=`minmax(320px, 1fr) repeat(${t.length}, minmax(160px, 220px))`,c=a!==void 0&&t.length===1,d=t[0]?.agentNodeId;return o("div",{className:"overflow-auto border border-border rounded",children:f("div",{className:"grid",style:{gridTemplateColumns:l},children:[o("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(u=>f("div",{className:"sticky top-0 z-10 bg-muted/60 px-3 py-2 border-b border-l border-border",children:[o("div",{className:"text-xs font-semibold text-foreground",children:u.agentNodeId}),o("div",{className:"text-[10px] text-foreground-subtle truncate",children:u.engineLabel})]},u.agentNodeId)),i.map(({node:u,depth:p})=>{const h=c&&d!==void 0?n(u.addonId,d):null,m=c&&h!==null?{enabled:h.kind==="enabled",onChange:g=>a?.(u.addonId,g),disabled:h.kind==="na"}:void 0;return o(c3,{node:u,depth:p,agents:t,getCellState:n,onCellClick:r,selectedCell:s,toggleProps:m},u.addonId)})]})})}const Pg=typeof globalThis<"u"?globalThis.__camstackTrpcReact:void 0,S=Pg??p2();typeof globalThis<"u"&&!Pg&&(globalThis.__camstackTrpcReact=S);const Qc=yn("camstack:system",null);function Gc({system:e,children:t}){return o(Qc.Provider,{value:e,children:t})}function Le(){const e=ve(Qc);if(!e)throw new Error("useSystem(): no <SystemProvider> in tree");return e}function d3(){return ve(Qc)}function bt(e,t){const n=Le(),r=te(t);r.current=t;const[s,a]=_(n.connectionVersion);Y(()=>n.subscribeConnectionEvents((i,l)=>{i==="connected"&&a(l)}),[n]),Y(()=>n.subscribeEvent(e,l=>{r.current(l)}),[n,e,s])}function Ll(e){const t=te(e);return t.current=e,t}function Gr(e,t){const[n,r]=_(null),s=Ll(t);return bt(e,a=>{const i=a.data,l=s.current;l&&!l(i)||r(i)}),n}function Kc(e,t,n){const[r,s]=_(()=>new Map),a=Ll(t),i=Ll(n);bt(e,c=>{const d=c.data,u=i.current;if(u&&!u(d))return;const p=a.current(d);s(h=>{const m=new Map(h);return m.set(p,d),m})});const l=q(()=>Array.from(r.values()),[r]);return{map:r,values:l}}function Kr(){const{data:e,isLoading:t}=S.nodes.topology.useQuery(void 0,{staleTime:6e4}),r=Gr("cluster.topology-snapshot")?.nodes??e;return{nodes:q(()=>{const a=[];for(const i of r??[])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},[r]),isLoading:t}}function _g({selectedNodeId:e,onSelect:t,label:n="Node",hideIcon:r=!1,alwaysShow:s=!1}){const{nodes:a}=Kr();return!s&&a.length<=1?null:f("div",{className:"flex items-center gap-1.5",children:[!r&&o(YS,{className:"h-3.5 w-3.5 text-foreground-subtle"}),n&&o("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:n}),o("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 o("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 u3={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 p3({status:e,showDot:t=!0,showLabel:n=!0,size:r="sm",className:s}){const a=u3[e];return f("span",{className:K("inline-flex items-center gap-1.5",r==="sm"?"text-xs":"text-sm",s),children:[t&&o("span",{className:K("h-1.5 w-1.5 shrink-0 rounded-full",a.colorClass),"aria-hidden":"true"}),n&&o("span",{className:"text-foreground",children:a.label})]})}const f3={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 h3({provider:e,showLabel:t=!0,className:n}){const r=f3[e];return f("span",{className:K("inline-flex items-center gap-1.5 text-xs",n),children:[o("span",{className:K("h-1.5 w-1.5 shrink-0 rounded-sm",r.colorClass),"aria-hidden":"true"}),t&&o("span",{className:"text-foreground",children:r.label})]})}const m3={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 $g({children:e,variant:t="neutral",mono:n,className:r}){return o("span",{className:K("inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-bold leading-tight",n&&"font-mono",m3[t],r),children:e})}function g3({version:e,preRelease:t,className:n}){const r=t??/-(alpha|beta|rc|dev|canary|next)/i.test(e);return o($g,{variant:r?"warning":"success",mono:!0,className:n,children:e})}function b3({label:e,description:t,error:n,required:r,children:s,orientation:a="vertical",className:i}){const l=a==="horizontal";return f("div",{className:K("flex gap-2",l?"flex-row items-center justify-between":"flex-col",i),children:[f("div",{className:K(l?"flex-1":""),children:[f(Tc,{children:[e,r&&o("span",{className:"text-danger ml-0.5",children:"*"})]}),t&&o("p",{className:"text-foreground-subtle text-xs mt-0.5",children:t})]}),o("div",{className:K(l?"shrink-0":""),children:s}),n&&o("p",{className:"text-danger text-xs",children:n})]})}function x3({title:e,subtitle:t,actions:n,className:r}){return f("div",{className:K("flex flex-col gap-2 mb-3 sm:flex-row sm:items-center sm:justify-between",r),children:[f("div",{children:[o("h1",{className:"text-sm font-semibold text-foreground",children:e}),t&&o("p",{className:"text-foreground-subtle text-xs",children:t})]}),n&&o("div",{className:"flex items-center gap-2 flex-wrap",children:n})]})}function Ra({icon:e,title:t,description:n,action:r,className:s}){return f("div",{className:K("flex flex-col items-center justify-center gap-3 py-12",s),children:[e&&o(e,{className:"h-12 w-12 text-foreground-subtle","aria-hidden":"true"}),f("div",{className:"flex flex-col items-center gap-1 text-center",children:[o("p",{className:"text-foreground-muted text-sm font-medium",children:t}),n&&o("p",{className:"text-foreground-subtle text-xs max-w-xs",children:n})]}),r&&o("div",{className:"mt-1",children:r})]})}const y3={danger:{box:"border-danger/40 bg-danger/10",icon:"text-danger",title:"text-danger",message:"text-danger"},warning:{box:"border-amber-500/40 bg-amber-500/10",icon:"text-amber-600 dark:text-amber-400",title:"text-amber-700 dark:text-amber-300",message:"text-amber-700 dark:text-amber-300"}};function Oa({message:e,title:t,onRetry:n,action:r,variant:s="danger",className:a}){const i=y3[s],l=s==="warning"?Qr:Qo;return f("div",{role:"alert",className:K("flex items-start gap-2.5 rounded border px-3 py-2.5",i.box,a),children:[o(l,{className:K("h-4 w-4 mt-0.5 shrink-0",i.icon),"aria-hidden":"true"}),f("div",{className:"flex-1 min-w-0",children:[t&&o("p",{className:K("text-xs font-semibold",i.title),children:t}),o("div",{className:K("text-xs break-words",i.message,t?"mt-0.5":""),children:e})]}),r??(n&&f("button",{type:"button",onClick:n,className:K("shrink-0 inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium","border border-current/30 hover:bg-current/10 transition-colors",i.message),children:[o(_a,{className:"h-3 w-3","aria-hidden":"true"}),"Retry"]}))]})}const Dg=yn("camstack:confirm-dialog",null);function rt(){const e=ve(Dg);if(!e)throw new Error("useConfirm must be used within ConfirmDialogProvider");return e.confirm}function Lg({children:e}){const[t,n]=_(null),r=U(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 f(Dg.Provider,{value:{confirm:r},children:[e,t&&f("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[o("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:a}),f("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:[f("div",{className:"px-5 pt-5 pb-4",children:[o("h3",{className:"text-sm font-semibold text-foreground",children:t.title}),o("p",{className:"mt-2 text-xs text-foreground-subtle leading-relaxed",children:t.message})]}),f("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-border bg-surface-hover/30",children:[o("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"}),o("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 v3({value:e,label:t,trend:n,className:r}){return f(Ft,{className:K("flex flex-col gap-1",r),children:[f("div",{className:"flex items-baseline gap-2",children:[o("span",{className:"text-2xl font-semibold text-foreground",children:e}),n&&f("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"?o(bC,{className:"h-3 w-3"}):o(yC,{className:"h-3 w-3"}),n.value,"%"]})]}),o("span",{className:"text-xs text-foreground-muted",children:t})]})}function w3({items:e,className:t}){return o("dl",{className:K("flex flex-col",t),children:e.map(n=>f("div",{className:"flex items-center h-7",children:[o("dt",{className:"text-foreground-subtle text-xs w-1/3 shrink-0",children:n.key}),o("dd",{className:"text-foreground text-xs",children:n.value})]},n.key))})}function N3({children:e,maxHeight:t=300,className:n}){const[r,s]=_(!1),a=U(()=>{navigator.clipboard.writeText(e).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)})},[e]);return f("div",{className:K("relative group",n),children:[o(jc,{style:{maxHeight:t},children:o("pre",{className:"font-mono text-xs bg-surface p-3 rounded-md border border-border-subtle",children:o("code",{children:e})})}),o("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:o(Lc,{icon:r?qr:vn,"aria-label":"Copy code",variant:"ghost",size:"sm",onClick:a})})]})}function k3({filters:e,values:t,onChange:n,className:r}){const s=hr(),[a,i]=_(!1),l=(d,u)=>{n({...t,[d]:u})},c=Object.values(t).filter(d=>d!==void 0&&d!=="").length;if(s){const d=e.find(p=>p.type==="search"),u=e.some(p=>p.type!=="search");return f("div",{className:K("flex items-center gap-2",r),children:[d&&o(ta,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:p=>l(d.key,p.target.value),leftSlot:o(Mo,{className:"h-3 w-3 text-foreground-subtle"}),className:"flex-1"}),u&&f(he,{children:[f("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:[o(rC,{className:"h-3.5 w-3.5"}),"Filters",c>0&&o(zt,{variant:"info",className:"ml-1 text-[10px] px-1 py-0",children:c})]}),o(Fc,{open:a,onClose:()=>i(!1),title:"Filters",children:o("div",{className:"flex flex-col gap-3",children:e.filter(p=>p.type!=="search").map(p=>{switch(p.type){case"select":return f("div",{children:[o("label",{className:"text-xs text-foreground-muted mb-1 block",children:p.label}),o(Eo,{options:p.options,value:t[p.key]??"",onChange:h=>l(p.key,h.target.value),className:"w-full"})]},p.key);case"badge-toggle":return o("div",{className:"flex items-center gap-1 flex-wrap",children:p.options.map(h=>{const g=t[p.key]===h.value;return o("button",{type:"button",onClick:()=>l(p.key,g?void 0:h.value),children:o(zt,{variant:g?"info":"default",className:"cursor-pointer",children:h.label})},h.value)})},p.key);default:return null}})})})]})]})}return o("div",{className:K("flex items-center gap-2 flex-wrap",r),children:e.map(d=>{switch(d.type){case"search":return o(ta,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:u=>l(d.key,u.target.value),leftSlot:o(Mo,{className:"h-3 w-3 text-foreground-subtle"}),className:"w-48"},d.key);case"select":return o(Eo,{options:d.options,value:t[d.key]??"",onChange:u=>l(d.key,u.target.value),className:"w-36"},d.key);case"badge-toggle":return o("div",{className:"flex items-center gap-1",children:d.options.map(u=>{const h=t[d.key]===u.value;return o("button",{type:"button",onClick:()=>l(d.key,h?void 0:u.value),children:o(zt,{variant:h?"info":"default",className:"cursor-pointer",children:u.label})},u.value)})},d.key);default:return null}})})}function Tl({label:e,icon:t,href:n,badge:r,active:s=!1,className:a}){return f("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:[o(t,{className:"h-3.5 w-3.5 shrink-0"}),o("span",{className:"truncate flex-1",children:e}),r!==void 0&&o(zt,{className:"ml-auto text-[10px] px-1.5 py-0",children:r})]})}function Rl({logo:e,sections:t,footer:n,onNavigate:r,className:s}){return f("nav",{className:K("bg-surface border-r border-border h-full flex flex-col",s),children:[e&&o("div",{className:"px-3 py-2 shrink-0",children:e}),o("div",{className:"flex-1 overflow-auto px-1 py-1",children:t.map((a,i)=>f("div",{className:K(i>0?"mt-3":""),children:[a.label&&o("span",{className:"text-[10px] text-foreground-disabled uppercase tracking-wider px-2 mb-1 block",children:a.label}),o("div",{className:"flex flex-col gap-0.5",onClick:r,children:a.items.map(l=>o(Tl,{...l},l.href))})]},i))}),n&&n.length>0&&f("div",{className:"shrink-0 px-1 pb-1",children:[o(Rc,{className:"mb-1"}),o("div",{className:"flex flex-col gap-0.5",onClick:r,children:n.map(a=>o(Tl,{...a},a.href))})]})]})}function S3({sidebar:e,header:t,mobileLogo:n,mobileActions:r,children:s,className:a}){const i=hr(),[l,c]=_(!1);return f("div",{className:K("flex h-screen",a),children:[!i&&o(Rl,{...e,className:K("w-44",e.className)}),i&&o(Vc,{open:l,onClose:()=>c(!1),width:"w-64",children:o(Rl,{...e,onNavigate:()=>c(!1),className:"w-full border-r-0"})}),f("div",{className:"flex flex-1 flex-col min-w-0",children:[i&&f("header",{className:"flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm",children:[o("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:o(xS,{className:"h-5 w-5"})}),n&&o("div",{className:"flex-1 flex justify-center",children:n}),r&&o("div",{className:"shrink-0",children:r})]}),!i&&t&&f("header",{className:"flex items-center h-10 border-b border-border px-4 shrink-0",children:[t.breadcrumbs&&t.breadcrumbs.length>0&&o("nav",{className:"flex items-center gap-1 text-xs flex-1 min-w-0",children:t.breadcrumbs.map((d,u)=>{const p=u===t.breadcrumbs.length-1;return f("span",{className:"flex items-center gap-1",children:[u>0&&o(Rn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),d.href&&!p?o("a",{href:d.href,className:"text-foreground-subtle hover:text-foreground transition-colors truncate",children:d.label}):o("span",{className:"text-foreground truncate",children:d.label})]},u)})}),t.actions&&o("div",{className:"flex items-center gap-2 ml-auto shrink-0",children:t.actions})]}),o("main",{className:"flex-1 overflow-auto p-4",children:s})]})]})}const C3={online:"bg-success",offline:"bg-danger",warning:"bg-warning",unknown:"bg-foreground-subtle"};function M3({title:e,subtitle:t,status:n,selected:r,onClick:s,badges:a,actions:i,offlineAction:l,className:c}){const d=n==="offline";return f("div",{onClick:s,className:K("w-full rounded-lg border p-3 text-left transition-colors",s&&"cursor-pointer",r?"border-primary bg-primary/10":"border-border bg-surface hover:bg-surface-hover",d&&!r&&"opacity-50",c),children:[f("div",{className:"flex items-center justify-between mb-2",children:[o("span",{className:"text-sm font-medium truncate",children:e}),n&&o("span",{className:K("h-2 w-2 rounded-full shrink-0",C3[n])})]}),t&&o("div",{className:"text-[11px] text-foreground-muted",children:t}),a&&a.length>0&&o("div",{className:"flex flex-wrap gap-1 mt-2",children:a.map((u,p)=>{const h=K("rounded px-1.5 py-0.5 text-[10px] flex items-center gap-0.5",r?"bg-primary/20":"bg-surface-hover",u.onClick&&"hover:opacity-80 transition-opacity cursor-pointer");return u.onClick?f("button",{onClick:m=>{m.stopPropagation(),u.onClick()},className:h,children:[u.icon,u.label]},p):f("span",{className:h,children:[u.icon,u.label]},p)})}),!d&&i&&i.length>0&&o("div",{className:"flex items-center gap-0.5 mt-2 -mb-1",children:i.map((u,p)=>o("button",{onClick:h=>{h.stopPropagation(),u.onClick()},className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",title:u.label,"aria-label":u.label,children:u.icon},p))}),d&&l&&o("div",{className:"mt-2",onClick:u=>u.stopPropagation(),children:l})]})}function E3({children:e,minCardWidth:t=220,gap:n=3,className:r}){return o("div",{className:K("p-4 overflow-y-auto flex-1 content-start",r),style:{display:"grid",gridTemplateColumns:`repeat(auto-fill, minmax(${t}px, 1fr))`,gap:`${n*4}px`},children:e})}const I3="capability.binding-changed";function At(e,t){const[n,r]=_(null);return Y(()=>{if(t===null){r(null);return}let s=!1;const a=async()=>{try{const l=await e.deviceManager.getBindings.query({deviceId:t});s||r(l)}catch{s||r(l=>l)}};a();const i=e.live?.onEvent.subscribe({category:I3},{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?f2(e,n):null,[e,n])}function pn(e){const t=U(r=>e?e.subscribe(()=>r()):()=>{},[e]),n=U(()=>e?.value,[e]);return Aa(t,n,n)}function Tg(e,t,n){const r=At(e,t),s=r?n(r.state):void 0;return pn(s)}function Wr(e){const t=At(e.trpc,e.deviceId),n=t!==null?e.slice(t):void 0,r=pn(n),s=t!==null?e.cap(t):void 0,c=(e.requireFeature===void 0||(e.deviceFeatures??[]).includes(e.requireFeature))&&s!==void 0&&r!==void 0;return{dev:t,cap:s,slice:r,available:c}}function A3(e){return e.parentDeviceId===null?"top-level":e.role?"accessory":"adopted"}const P3={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 _3(e){const t=P3[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 $3={siren:Pa,floodlight:qm,spotlight:Ym,"pir-sensor":Gm,chime:SS,autotrack:zm,nightvision:$c,"privacy-mask":_c,doorbell:Fm},D3={camera:Ac,hub:_l,nvr:_l,light:qm,siren:Pa,switch:hC,sensor:Gm,thermostat:pC,button:$5,generic:Dc};function Rg(e){return e.role?$3[e.role]??Dc:D3[e.type.toLowerCase()]??Ac}const Og={"native-snapshot":sS,"two-way-audio":Um,"pan-tilt-zoom":zm,"ptz-autotrack":mS,"doorbell-button":Fm,"motion-trigger":In,"battery-operated":Om,rebootable:Wm},Bg={"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"},L3={"native-snapshot":"snapshot",rebootable:"reboot","pan-tilt-zoom":"ptz","ptz-autotrack":"ptz-autotrack","two-way-audio":"intercom","motion-trigger":"motion-trigger"},zg=new Set(["camera","hub","nvr"]);function Fg(e){return!zg.has(e.type.toLowerCase())}function rp(e){return e.role?!0:!zg.has(e.type.toLowerCase())}function jg(e){return(e.features??[]).includes("motion-trigger")}function T3(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 r=n.slice(-2).join("-");if(r.length>=6)return r}return`…${e.slice(-18)}`}function R3({trpc:e,accessoryChildren:t,adoptedChildren:n,onNavigate:r}){return f("div",{className:"border-t border-border-subtle/50",children:[n.length>0&&o(op,{trpc:e,label:"Adopted devices",rows:n,onNavigate:r}),t.length>0&&o(op,{trpc:e,label:"Accessories",rows:t,onNavigate:r})]})}function op({trpc:e,label:t,rows:n,onNavigate:r}){return f("div",{children:[o("div",{className:"px-3 pt-1.5 pb-1 text-[9px] font-semibold uppercase tracking-wide text-foreground-subtle",children:t}),o("ul",{children:n.map(s=>o(O3,{trpc:e,child:s,onNavigate:r},s.id))})]})}function O3({trpc:e,child:t,onNavigate:n}){const r=!t.disabled,s=r&&Fg(t),a=r&&jg(t),i=Rg(t);return o("li",{children:f("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:[o(i,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),o("span",{className:"text-[10.5px] text-foreground flex-1 truncate",children:t.name}),a&&o(z3,{trpc:e,deviceId:t.id,features:t.features}),s&&o(B3,{trpc:e,deviceId:t.id}),o("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 B3({trpc:e,deviceId:t}){const{dev:n,cap:r,slice:s,available:a}=Wr({trpc:e,deviceId:t,cap:p=>p.switch,slice:p=>p.state.switch}),[i,l]=_(!1);if(n!==null&&!r)return null;const c=s?.on===!0,d={transform:c?"translateX(14px)":"translateX(2px)"},u=async p=>{if(p.stopPropagation(),!(i||!a||!r)){l(!0);try{await r.setState({on:!c})}finally{l(!1)}}};return o("button",{type:"button",onClick:p=>{u(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:o("span",{className:K("absolute h-3 w-3 rounded-full transition-all",c?"bg-success":"bg-foreground-subtle"),style:d})})}function z3({trpc:e,deviceId:t,features:n}){const{dev:r,cap:s,slice:a,available:i}=Wr({trpc:e,deviceId:t,cap:p=>p.motionTrigger,slice:p=>p.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:n}),[l,c]=_(!1);if(r!==null&&!s)return null;const d=a?.enabled===!0,u=async p=>{if(p.stopPropagation(),!(l||!i||!s)){c(!0);try{await s.setMotionTrigger({enabled:!d})}finally{c(!1)}}};return o("button",{type:"button",onClick:p=>{u(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:o(In,{className:"h-2.5 w-2.5"})})}function Vg({trpc:e,device:t,flags:n}){if(!!t.disabled)return null;const s=t.type.toLowerCase(),a=n.showSwitchToggle&&Fg(t),i=jg(t),l=s==="hub"||s==="nvr",c=(t.features??[]).includes("rebootable"),d=l&&c;return f(he,{children:[i&&o(j3,{trpc:e,deviceId:t.id,features:t.features}),a&&o(F3,{trpc:e,deviceId:t.id}),d&&o(H3,{trpc:e,deviceId:t.id})]})}function F3({trpc:e,deviceId:t}){const{dev:n,cap:r,slice:s,available:a}=Wr({trpc:e,deviceId:t,cap:p=>p.switch,slice:p=>p.state.switch}),[i,l]=_(!1);if(n!==null&&!r)return null;const c=s?.on===!0,d={transform:c?"translateX(14px)":"translateX(2px)"},u=async p=>{if(p.stopPropagation(),!(i||!a||!r)){l(!0);try{await r.setState({on:!c})}finally{l(!1)}}};return o("button",{type:"button",onClick:p=>{u(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:o("span",{className:K("absolute h-3 w-3 rounded-full transition-all",c?"bg-success":"bg-foreground-subtle"),style:d})})}function j3({trpc:e,deviceId:t,features:n}){const{dev:r,cap:s,slice:a,available:i}=Wr({trpc:e,deviceId:t,cap:p=>p.motionTrigger,slice:p=>p.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:n}),[l,c]=_(!1);if(r!==null&&!s)return null;const d=a?.enabled===!0,u=async p=>{if(p.stopPropagation(),!(l||!i||!s)){c(!0);try{await s.setMotionTrigger({enabled:!d})}finally{c(!1)}}};return o("button",{type:"button",onClick:p=>{u(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:o(In,{className:"h-2.5 w-2.5"})})}const Ci=168,V3=4;function H3({trpc:e,deviceId:t}){const{dev:n,cap:r}=Wr({trpc:e,deviceId:t,cap:x=>x.reboot,slice:()=>{}}),s=te(null),a=te(null),[i,l]=_(null),[c,d]=_(!1),u=n!==null&&r!==void 0&&r!==null,p=i!==null,h=()=>l(null),m=()=>{const x=s.current;if(!x)return;const y=x.getBoundingClientRect(),w=y.right-Ci,v=Math.max(8,Math.min(w,window.innerWidth-Ci-8)),N=y.bottom+V3;l({top:N,left:v})};if(Y(()=>{if(!p)return;const x=w=>{const v=s.current,N=a.current,k=w.target;k!==null&&(v&&v.contains(k)||N&&N.contains(k)||h())},y=w=>{w.key==="Escape"&&(w.stopPropagation(),h())};return document.addEventListener("mousedown",x),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",y)}},[p]),n!==null&&!r)return null;const g=x=>{x.stopPropagation(),p?h():m()},b=async()=>{if(!(c||!u||!r)){d(!0),h();try{await r.reboot({})}finally{d(!1)}}};return f(he,{children:[o("button",{ref:s,type:"button",onClick:g,disabled:c||!u,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||!u)&&"opacity-50",p&&"bg-surface-hover text-foreground"),title:"More actions","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":p,children:o(jm,{className:"h-3 w-3"})}),i&&Uo(o("div",{ref:a,role:"menu",style:{position:"fixed",top:i.top,left:i.left,width:Ci},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-1",onClick:x=>x.stopPropagation(),children:f("button",{type:"button",role:"menuitem",onClick:()=>{b()},disabled:c||!u,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:[o(Wm,{className:"h-3 w-3 shrink-0 text-foreground-subtle"}),o("span",{children:"Reboot device"})]})}),document.body)]})}const q3=Object.freeze([]);function U3(e){return e==="native"?"native":"enhanced"}function Q3(e){return e.map(t=>({kind:"marker",feature:t}))}function G3(e,t){const n=new Map,r=t.entries??[];for(const a of r)n.set(a.capName,a);const s=[];for(const a of e){const i=L3[a];if(i===void 0){s.push({kind:"marker",feature:a});continue}const l=n.get(i);l&&s.push({kind:U3(l.kind),feature:a,capName:i})}return s}function K3(e,t,n){const[r,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 u=async()=>{try{const h=await e.deviceManager.getBindings.query({deviceId:t});if(d)return;s(h),c(!1)}catch{if(d)return;i(!0),c(!1)}};u();const p=e.live?.onEvent.subscribe({category:"capability.binding-changed"},{onData:h=>{const m=h.data?.source;if(!m){u();return}m.type==="device"&&m.id===t&&u()}});return()=>{d=!0,p?.unsubscribe()}},[e,t]),n.length===0?{loading:l,resolved:q3}:l||a||!r?{loading:l,resolved:Q3(n)}:{loading:!1,resolved:G3(n,r)}}const W3=[];function Hg({trpc:e,device:t,flags:n,accessoryCount:r,adoptedCount:s,showFeatureRow:a=!1}){const i=r+s,l=n.showChildrenAccordion&&i>0,c=t.features??W3,d=a&&c.length>0,{resolved:u}=K3(e,d?t.id:null,c),p=d&&u.length>0;return!l&&!p?null:f("div",{className:"flex items-center gap-1.5 flex-nowrap whitespace-nowrap min-w-0",children:[l&&o(Y3,{accessoryCount:r,adoptedCount:s}),p&&o(Z3,{resolved:u})]})}function Y3({accessoryCount:e,adoptedCount:t}){const n=e+t;if(n===0)return null;const r=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 f("span",{className:"text-[9px] font-medium text-foreground-subtle bg-surface-elevated/60 rounded px-1.5 py-0.5 flex-shrink-0",title:r,children:["+",n]})}const qg=240,sp=200;function Z3({resolved:e}){const t=te(null),[n,r]=_(null);return f("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(),u=window.innerHeight-l.bottom>=sp?l.bottom+4:l.top-sp-4,p=Math.max(8,Math.min(l.left,window.innerWidth-qg-8));r({top:u,left:p})},onMouseLeave:()=>r(null),children:[e.map(i=>{const l=Og[i.feature];return l?o("span",{className:"inline-flex items-center justify-center h-4 w-4 rounded bg-surface-elevated/60 text-foreground-subtle",title:Bg[i.feature]??i.feature,children:o(l,{className:"h-2.5 w-2.5"})},i.feature):null}),n&&Uo(o(X3,{resolved:e,position:n}),document.body)]})}function X3({resolved:e,position:t}){return f("div",{style:{position:"fixed",top:t.top,left:t.left,width:qg,pointerEvents:"none"},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-2",children:[o("h5",{className:"text-[9px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5",children:"Features"}),o("ul",{className:"space-y-0.5",children:e.map(n=>o(J3,{entry:n},n.feature))})]})}function J3({entry:e}){const t=Og[e.feature],n=Bg[e.feature]??e.feature;return f("li",{className:"flex items-center justify-between gap-2 text-[10px]",children:[f("span",{className:"flex items-center gap-1.5 text-foreground",children:[t&&o(t,{className:"h-3 w-3 text-foreground-subtle"}),o("span",{children:n})]}),o(eM,{kind:e.kind})]})}function eM({kind:e}){return e==="marker"?o("span",{className:"text-[8.5px] px-1 rounded text-foreground-subtle",title:"Informational marker (no cap registered)",children:"marker"}):o("span",{className:K("text-[8.5px] px-1 rounded",e==="native"?"bg-success/15 text-success":"bg-primary/15 text-primary"),children:e})}function Ug({device:e,variant:t,flags:n,parent:r,integrationIcon:s,hasChildren:a,expanded:i,onToggleExpand:l,onNavigateToParent:c}){const d=Rg(e);return f("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[n.showChildrenAccordion&&a?o("button",{type:"button",onClick:u=>{u.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?o(pr,{className:"h-3 w-3"}):o(Rn,{className:"h-3 w-3"})}):n.showChildrenAccordion?o("span",{className:"h-3.5 w-3.5 flex-shrink-0"}):null,o(d,{className:K("text-foreground-subtle flex-shrink-0",t==="minimal"?"h-3 w-3":"h-3.5 w-3.5")}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.showIntegrationIcon&&s&&o("span",{className:"flex-shrink-0",children:s}),o("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)&&f("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&&f("span",{className:"flex-shrink-0 tabular-nums",children:["#",String(e.id)]}),n.showId&&n.showStableId&&o("span",{className:"flex-shrink-0 opacity-50",children:"·"}),n.showStableId&&o("span",{className:"truncate",children:T3(e.stableId)})]}),n.showParentBadge&&r&&f("button",{type:"button",onClick:u=>{u.stopPropagation(),c(r.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: ${r.name} (#${String(r.id)})`,children:[o(_l,{className:"h-2.5 w-2.5 shrink-0"}),f("span",{className:"truncate",children:["Under: ",r.name]})]})]})]})}function Wc(e,t){return Tg(e,t,r=>r.battery)??null}function Yc(e,t){const n=At(e,t),r=te(!1),{data:s,isLoading:a,isFetching:i,refetch:l}=Ln({queryKey:["device",t,"snapshot"],queryFn:()=>{if(!n)throw new Error("useDeviceSnapshotImage: device proxy not ready");const u=r.current;return r.current=!1,n.snapshot?.getSnapshot({force:u})??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(){r.current=!0,l()}return{src:c,loading:a||i,refresh:d}}function tM(e){return e<=10?u5:e<=30?c5:e>=95?i5:Om}function nM(e,t){return t!=="none"?"text-emerald-400":e<=10?"text-rose-400":e<=30?"text-amber-400":"text-foreground-subtle"}function Zc({status:e,variant:t="compact",className:n}){if(!e)return null;const r=tM(e.percentage),s=nM(e.percentage,e.charging),a=e.charging==="solar"?Ym:e.charging==="dc"?_S:null,i=e.sleeping;return f("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:[o(r,{className:"h-3.5 w-3.5"}),f("span",{children:[Math.round(e.percentage),"%"]}),a&&o(a,{className:"h-3 w-3"}),i&&o($c,{className:"h-3 w-3 text-blue-300"}),t==="full"&&e.charging!=="none"&&o("span",{className:"text-foreground-subtle",children:e.charging})]})}function Qg({trpc:e,device:t,status:n,enabled:r,showStatusPills:s=!1}){const a=r&&t.online,i=Yc(e,a?t.id:null),l=(t.features??[]).includes("battery-operated"),c=s&&l&&!t.disabled,d=Wc(e,c?t.id:null);return!r&&!c?null:f("span",{className:"inline-flex items-center gap-1.5 flex-nowrap whitespace-nowrap",children:[c&&d&&o(Zc,{status:d}),r&&o(rM,{deviceName:t.name,snapshotUrl:i.src,status:n})]})}const Mi=288,ap=196,Ei=8;function rM({deviceName:e,snapshotUrl:t,status:n}){const r=te(null),[s,a]=_(null),i=n==="offline"||n==="disabled",l=()=>{const d=r.current;if(!d)return;const u=d.getBoundingClientRect(),p=u.top,h=window.innerHeight-u.bottom,m=p<ap+Ei&&h>p,g=m?u.bottom+Ei:u.top-ap-Ei,b=u.right-Mi,x=Math.max(8,Math.min(b,window.innerWidth-Mi-8));a({top:g,left:x,placeBelow:m})},c=()=>a(null);return f(he,{children:[o("button",{ref:r,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:o(Ur,{className:"h-3.5 w-3.5"})}),s&&Uo(f("div",{style:{position:"fixed",top:s.top,left:s.left,width:Mi,pointerEvents:"none"},className:"rounded-lg border border-border bg-surface shadow-lg shadow-black/30 z-[9999] overflow-hidden",children:[o("div",{className:"h-40 bg-background flex items-center justify-center",children:t&&!i?o("img",{src:t,alt:e,className:"h-full w-full object-cover"}):o("span",{className:"text-xs text-foreground-subtle",children:n==="offline"?"Offline — no snapshot":n==="disabled"?"Disabled":"No snapshot yet"})}),o("div",{className:"px-3 py-2",children:o("p",{className:"text-xs font-semibold text-foreground truncate",children:e})})]}),document.body)]})}function Gg({status:e}){const t=e==="disabled"?"bg-warning":e==="online"?"bg-success":"bg-danger",n=e==="disabled"?"Disabled":e==="online"?"Online":"Offline";return o("span",{className:K("h-1.5 w-1.5 rounded-full flex-shrink-0",t),title:n})}function Io(e){const{trpc:t,device:n,parent:r,integrationIcon:s,onNavigate:a,className:i}=e,l=_3(e),c=e.variant??"compact",d=e.view??"card",u=!n.disabled,p=n.isCamera??n.type.toLowerCase()==="camera",h=e.children??[],m=h.filter(rp),g=h.filter(M=>!rp(M)),b=h.length>0,[x,y]=_(!1),w=e.expanded??x,v=e.onToggleExpand??(()=>y(M=>!M)),N=M=>{a?.(M)},k=e.indentLevel??(e.isAccessoryRow?2:0),C=u?n.online?"online":"offline":"disabled";return d==="table"?o(sM,{trpc:t,device:n,variant:c,flags:l,parent:r??null,integrationIcon:s??null,accessoryCount:m.length,adoptedCount:g.length,hasChildren:b,expanded:w,onToggleExpand:v,onNavigate:N,displayStatus:C,isCamera:p,showSnapshot:l.showSnapshot&&p,isAccessoryRow:e.isAccessoryRow??!1,indentLevel:k,className:i}):f("div",{className:K("rounded-lg border border-border bg-surface transition-colors",!u&&"opacity-60",i),children:[f("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:[o(Ug,{device:n,variant:c,flags:l,parent:r??null,integrationIcon:s??null,hasChildren:b,expanded:w,onToggleExpand:v,onNavigateToParent:N}),o(Hg,{trpc:t,device:n,flags:l,accessoryCount:m.length,adoptedCount:g.length,showFeatureRow:!1}),o(Qg,{trpc:t,device:n,status:C,enabled:l.showSnapshot&&p,showStatusPills:!0}),o(Vg,{trpc:t,device:n,flags:l}),o(Gg,{status:C})]}),w&&b&&o(R3,{trpc:t,accessoryChildren:m,adoptedChildren:g,onNavigate:N})]})}const oM={0:"pl-2",1:"pl-6",2:"pl-8"};function sM(e){const{trpc:t,device:n,variant:r,flags:s,parent:a,integrationIcon:i,accessoryCount:l,adoptedCount:c,hasChildren:d,expanded:u,onToggleExpand:p,onNavigate:h,displayStatus:m,isCamera:g,showSnapshot:b,isAccessoryRow:x,indentLevel:y,className:w}=e;return f("tr",{onClick:()=>h(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:[o("td",{className:K("py-2 align-middle pr-2",oM[y]),children:o(Ug,{device:n,variant:r,flags:s,parent:a,integrationIcon:i,hasChildren:d,expanded:u,onToggleExpand:p,onNavigateToParent:h})}),o("td",{className:"px-2 py-2 align-middle text-[10px] text-foreground-subtle whitespace-nowrap",children:n.type}),o("td",{className:"px-2 py-2 align-middle",children:o(Hg,{trpc:t,device:n,flags:s,accessoryCount:l,adoptedCount:c,showFeatureRow:!0})}),o("td",{className:"px-2 py-2 align-middle",children:o(Qg,{trpc:t,device:n,status:m,enabled:b&&g,showStatusPills:!0})}),o("td",{className:"px-2 py-2 align-middle text-right whitespace-nowrap",children:f("span",{className:"inline-flex items-center gap-1.5",children:[o(Vg,{trpc:t,device:n,flags:s}),o(Gg,{status:m})]})})]})}function Kg(e,t){const[n,r]=_(e);return Y(()=>{const s=setTimeout(()=>r(e),t);return()=>clearTimeout(s)},[e,t]),n}const aM=new Set(["hub","nvr"]);function iM(e){const t=new Map;for(const s of e)t.set(s.id,s);const n=[],r=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(aM.has(i.type)&&!l){n.push(s);continue}const d=r.get(a);d?d.push(s):r.set(a,[s])}return{topLevel:n,accessoriesByParent:r}}const ip=2;function lM(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=[],r=Math.max(2,e-ip),s=Math.min(t-1,e+ip);n.push({kind:"page",n:1}),r>2&&n.push({kind:"ellipsis",side:"left"});for(let a=r;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 cM({currentPage:e,totalItems:t,pageSize:n,onPageChange:r,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=lM(e,a);return f("div",{className:"flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle",children:[f("span",{children:["Showing ",i,"–",l," of ",t," ",s]}),f("span",{className:"inline-flex items-center gap-1",children:[o("button",{type:"button","aria-label":"Previous page",disabled:e===1,onClick:()=>r(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:o(S5,{className:"h-3 w-3"})}),c.map((d,u)=>{if(d.kind==="ellipsis")return o("span",{className:"px-1 text-foreground-subtle/60 select-none",children:"…"},`e-${u}`);const p=d.n===e;return o("button",{type:"button",onClick:()=>r(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}`)}),o("button",{type:"button","aria-label":"Next page",disabled:e===a,onClick:()=>r(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:o(Rn,{className:"h-3 w-3"})})]})]})}function dM({view:e,onViewChange:t,types:n,currentType:r,onTypeChange:s,addons:a,currentAddon:i,onAddonChange:l,hideAddons:c=!1}){return f("div",{className:"flex items-center gap-2 flex-wrap",children:[f("span",{className:"inline-flex border border-border rounded-md overflow-hidden",children:[o("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:o(uS,{className:"h-3.5 w-3.5"})}),o("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:o(cC,{className:"h-3.5 w-3.5"})})]}),n&&n.length>0&&f(he,{children:[o(lp,{children:"Type"}),o(Ii,{active:r===null,onClick:()=>s(null),children:"All"}),n.map(d=>o(Ii,{active:r===d,onClick:()=>s(r===d?null:d),children:uM(d)},d))]}),!c&&a&&a.length>0&&f(he,{children:[o(lp,{children:"Integration"}),a.map(d=>o(Ii,{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 lp({children:e}){return o("span",{className:"text-[10px] font-medium uppercase tracking-wider text-foreground-subtle ml-1",children:e})}function Ii({active:e,icon:t,onClick:n,showClearIcon:r,children:s}){return f("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&&o("span",{className:"inline-flex items-center",children:t}),o("span",{children:s}),e&&r&&o(Je,{className:"h-2.5 w-2.5 opacity-70"})]})}function uM(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function pM({variant:e,onClearFilters:t}){return f("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[o(iS,{className:"h-8 w-8 text-foreground-subtle/40 mb-3"}),o("p",{className:"text-sm font-medium text-foreground-subtle",children:e==="filtered"?"No devices match the current filters":"No devices yet"}),e==="filtered"&&t&&o("button",{type:"button",onClick:t,className:"mt-2 text-[11px] text-primary hover:underline",children:"Clear filters"})]})}function Wt(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 cp(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 fM(e,t){try{localStorage.setItem(`camstack:${e}:lastFilters`,JSON.stringify(t))}catch{}}function dp(e,t,n){const r=new URLSearchParams(window.location.search),s=r.get(Wt(e,"view")),a=s==="cards"||s==="table"?s:n.view??t,i=r.get(Wt(e,"page")),l=i?parseInt(i,10):1,c=Number.isFinite(l)&&l>=1?l:1,d=r.get(Wt(e,"addon"))??n.addon??null,u=r.get(Wt(e,"type"))??n.type??null,p=r.get(Wt(e,"q"))??n.q??"";return{view:a,page:c,addon:d,type:u,q:p}}function hM(e,t,n){const r=new URLSearchParams(window.location.search),s=(l,c)=>{c===null||c===""?r.delete(l):r.set(l,c)};s(Wt(e,"view"),t.view===n?null:t.view),s(Wt(e,"page"),t.page===1?null:String(t.page)),s(Wt(e,"addon"),t.addon),s(Wt(e,"type"),t.type),s(Wt(e,"q"),t.q||null);const a=r.toString(),i=a?`${window.location.pathname}?${a}`:window.location.pathname;window.history.replaceState(null,"",i)}function mM(e){const{scope:t,defaultView:n,lsKey:r}=e,[s,a]=_(()=>{const g=cp(r);return dp(t,n,g)}),i=te(s);i.current=s,Y(()=>{const g=()=>{const b=cp(r),x=dp(t,n,b);i.current=x,a(x)};return window.addEventListener("popstate",g),()=>window.removeEventListener("popstate",g)},[t,n,r]);const l=U(g=>{const b=g(i.current);i.current=b,a(b),hM(t,b,n),fM(r,{view:b.view,addon:b.addon,type:b.type,q:b.q})},[t,n,r]),c=U(g=>l(b=>({...b,view:g})),[l]),d=U(g=>l(b=>({...b,page:g})),[l]),u=U(g=>l(b=>({...b,addon:g,page:1})),[l]),p=U(g=>l(b=>({...b,type:g,page:1})),[l]),h=U(g=>l(b=>({...b,q:g,page:1})),[l]),m=U(()=>l(g=>({...g,addon:null,type:null,q:"",page:1})),[l]);return{state:s,setView:c,setPage:d,setAddon:u,setType:p,setQ:h,clearFilters:m}}const gM={cards:24,table:50};function Ao(e){const{devices:t,trpc:n,defaultView:r="table",filters:s,forceAddon:a,resolveIntegrationIcon:i,resolveParent:l,onNavigate:c,pageSize:d=gM,urlScope:u="root",lsKey:p=u==="root"?"devices":"integrations:nested"}=e,h=mM({scope:u,defaultView:r,lsKey:p}),m=h.state.view,g=m==="cards"?d.cards:d.table,[b,x]=_(h.state.q),y=Kg(b,300);Y(()=>{y!==h.state.q&&h.setQ(y)},[y]);const w=a??h.state.addon,v=q(()=>{const R=h.state.q.toLowerCase().trim();return t.filter(E=>!(w&&E.addonId!==w||h.state.type&&E.type!==h.state.type||R&&!E.name.toLowerCase().includes(R)&&!E.stableId.toLowerCase().includes(R)))},[t,w,h.state.type,h.state.q]),N=q(()=>iM(v),[v]),k=q(()=>{if(h.state.q.trim()==="")return new Set;const R=h.state.q.toLowerCase().trim(),E=new Set;for(const[D,L]of N.accessoriesByParent.entries())L.some(T=>T.name.toLowerCase().includes(R)||T.stableId.toLowerCase().includes(R))&&E.add(D);return E},[N.accessoriesByParent,h.state.q]),C=N.topLevel.length,M=Math.max(1,Math.ceil(C/g)),P=Math.min(h.state.page,M),I=(P-1)*g,z=N.topLevel.slice(I,I+g);Y(()=>{P!==h.state.page&&h.setPage(P)},[P]),NM();const A=w!=null||h.state.type!==null||h.state.q!=="",O=C===0;return f("div",{className:"flex flex-col gap-3",children:[f("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[o(dM,{view:m,onViewChange:h.setView,types:s?.types,currentType:h.state.type,onTypeChange:h.setType,addons:s?.addons,currentAddon:h.state.addon,onAddonChange:h.setAddon,hideAddons:a!==void 0}),f("div",{className:"relative",children:[o(Mo,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle pointer-events-none"}),o("input",{type:"text",value:b,onChange:R=>x(R.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"})]})]}),O?o(pM,{variant:A?"filtered":"nofilter",onClearFilters:A?h.clearFilters:void 0}):m==="cards"?o(bM,{rows:z,accessoriesByParent:N.accessoriesByParent,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:c??null}):o(vM,{rows:z,accessoriesByParent:N.accessoriesByParent,autoExpandedParents:k,devices:v,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:c??null}),o(cM,{currentPage:P,totalItems:C,pageSize:g,onPageChange:h.setPage}),a===void 0&&A&&C>0&&f("p",{className:"text-[11px] text-foreground-subtle",children:["Showing ",C," of ",t.length," devices",w&&f(he,{children:[" ","· filtered by"," ",o("strong",{className:"text-primary",children:s?.addons?.find(R=>R.id===w)?.name??w})]})]})]})}function bM({rows:e,accessoriesByParent:t,trpc:n,resolveIntegrationIcon:r,resolveParent:s,onNavigate:a}){return o("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 o(Io,{trpc:n,device:i,view:"card",integrationIcon:r?.(i.addonId)??null,parent:i.parentDeviceId!==null?s?.(i.parentDeviceId)??null:null,children:l,onNavigate:a??void 0},i.id)})})}const xM=new Set(["hub","nvr"]);function yM(e,t){return e.parentDeviceId===null||t===null?0:xM.has(t.toLowerCase())?1:0}function vM({rows:e,accessoriesByParent:t,autoExpandedParents:n,devices:r,trpc:s,resolveIntegrationIcon:a,resolveParent:i,onNavigate:l}){const c=q(()=>{const d=new Map;for(const u of r)d.set(u.id,u.type);return d},[r]);return o("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:f("table",{className:"w-full border-collapse",children:[o("thead",{children:f("tr",{className:"border-b border-border",children:[o("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle",children:"Name"}),o("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-24",children:"Type"}),o("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Features"}),o("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-20",children:"Preview"}),o("th",{className:"text-right px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Actions"})]})}),o("tbody",{children:e.map(d=>{const u=t.get(d.id)??[],p=u.length>0,h=n.has(d.id),m=d.parentDeviceId!==null?i?.(d.parentDeviceId)??null:null,g=d.parentDeviceId!==null?c.get(d.parentDeviceId)??null:null;return o(wM,{parent:d,accessories:u,hasAccessories:p,forceExpanded:h,trpc:s,integrationIcon:a?.(d.addonId)??null,parentRowParent:m,indentLevel:yM(d,g),onNavigate:l??null},d.id)})})]})})}function wM({parent:e,accessories:t,hasAccessories:n,forceExpanded:r,trpc:s,integrationIcon:a,parentRowParent:i,indentLevel:l,onNavigate:c}){const[d,u]=_(r),p=te(r);return Y(()=>{p.current!==r&&(u(r),p.current=r)},[r]),f(he,{children:[o(Io,{trpc:s,device:e,view:"table",integrationIcon:a,parent:i,children:t,onNavigate:c??void 0,showChildrenAccordion:n,expanded:d,onToggleExpand:()=>u(g=>!g),indentLevel:l}),n&&d&&t.map(g=>o(Io,{trpc:s,device:g,view:"table",integrationIcon:null,parent:null,isAccessoryRow:!0,showChildrenAccordion:!1,onNavigate:c??void 0},g.id))]})}function NM(){ke()}function kM({options:e,value:t,onChange:n}){return o("div",{className:"flex flex-wrap gap-2",children:e.map(r=>{const s=r.id===t;return f("button",{onClick:()=>r.available&&n(r.id),disabled:!r.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":r.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:[o(q5,{className:"h-3.5 w-3.5 shrink-0"}),r.label,r.isBest&&f("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:[o(aC,{className:"h-2.5 w-2.5"}),"Best"]}),r.platformScore!=null&&f("span",{className:"text-[10px] text-foreground-subtle/60",children:["(",r.platformScore,")"]}),o("span",{className:`h-1.5 w-1.5 rounded-full ${r.available?"bg-success":"bg-danger"}`})]},r.id)})})}function SM(e,t){const n=new Set(t.slots.flatMap(i=>i.addons.map(l=>l.id))),r=[];function s(i){if(!n.has(i.addonId))return r.push(`Addon "${i.addonId}" is no longer available — step removed`),null;const l=t.slots.flatMap(u=>u.addons).find(u=>u.id===i.addonId);let c=i.modelId;if(l&&!l.models.some(u=>u.id===c)){const u=l.defaultModelId;r.push(`Model "${c}" not available for ${i.addonId} — using "${u}"`),c=u}const d=i.children.map(u=>s(u)).filter(u=>u!==null);return{...i,modelId:c,children:d}}const a=e.map(i=>s(i)).filter(i=>i!==null);return{valid:r.length===0,steps:a,warnings:r}}function CM(e){const t=new Map;for(const n of e.slots)for(const r of n.addons)t.set(r.id,r);return t}function Ai(e){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:!0,modelId:e.defaultModelId,children:[]}}function Pi({addon:e,onClick:t}){return o("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:f("div",{className:"flex items-center gap-3",children:[o(R5,{className:"h-[18px] w-[18px] text-foreground-subtle/30 group-hover:text-primary/60 shrink-0"}),f("div",{className:"flex-1 min-w-0",children:[o("span",{className:"text-[13px] font-medium text-foreground-subtle/50 group-hover:text-foreground-subtle block truncate",children:e.name}),f("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(n=>o("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&&o("span",{className:"text-foreground-subtle/25 text-[10px]",children:"→"}),e.outputClasses.map(n=>o("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 Xc({schema:e,steps:t,onChange:n,templates:r,selectedTemplateId:s,onSelectTemplate:a,onSaveTemplate:i,onUpdateTemplate:l,onDeleteTemplate:c,readOnly:d=!1,excludeAddons:u=[],hideTemplates:p=!1,showOnlyEnabled:h=!1,showSlotLabels:m=!1,toggleMode:g="simple",overrides:b={},onOverrideChange:x,inheritedEnabledByAddon:y={},hideModelAndSettings:w=!1}){const v=V=>({toggleMode:g,hideModelAndSettings:w,...g==="threeState"?{overrideState:b[V]!==void 0?b[V]:null,onOverrideChange:x?$=>x(V,$):void 0,inheritedEnabled:y[V]}:{}}),N=q(()=>new Set(u),[u]),k=q(()=>CM(e),[e]),[C,M]=_([]),P=s?JSON.stringify(t)!==JSON.stringify(r.find(V=>V.id===s)?.steps):!1;function I(V){const $=V.target.value||null;if($){const H=r.find(G=>G.id===$);if(H){const G=SM(H.steps,e);M([...G.warnings])}}else M([]);a($)}function z(){s&&l(s,t)}function A(){const V=window.prompt("Template name:");V?.trim()&&i(V.trim(),t)}function O(){if(!s)return;const V=r.find($=>$.id===s);V&&window.confirm(`Delete template "${V.name}"?`)&&c(s)}function R(V){n(t.map($=>$.addonId!==V.addonId?$:E(V)))}function E(V){const $=V.children.some(H=>H.enabled||H.children.some(G=>G.enabled));return{...V,enabled:V.enabled||$,children:V.children.map(H=>{const G=H.children.some(Z=>Z.enabled);return{...H,enabled:H.enabled||G}})}}function D(V,$){const H=Ai($);n(t.map(G=>G.addonId!==V?G:{...G,children:[...G.children,H]}))}function L(V){const $=new Set;for(const H of V){$.add(H.addonId);for(const Z of H.children)$.add(Z.addonId);const G=L(H.children);for(const Z of G)$.add(Z)}return $}const T=L(t);function B(V){const $=k.get(V.addonId);if(!$)return[];const G=e.slots.find(X=>X.id===$.slot)?.parentSlot==null,Z=$.childSlots,oe=new Set(V.children.map(X=>X.addonId)),ne=[];for(const X of e.slots)if(Z.includes(X.id))for(const re of X.addons){if(oe.has(re.id)||N.has(re.id))continue;const be=re.inputClasses.length===0;if(be&&!G)continue;(be||re.inputClasses.some(W=>V.outputClasses.includes(W)))&&ne.push(re)}return ne}function F(V){const $=h?{...V,children:V.children.filter(G=>G.enabled).map(G=>({...G,children:G.children.filter(Z=>Z.enabled)}))}:V,H=h?[]:B($);return f("div",{className:"space-y-1.5",children:[o(js,{step:$,schema:k.get($.addonId)??null,allSchemas:k,onChange:R,onDelete:d?void 0:G=>n(t.filter(Z=>Z.addonId!==G)),readOnly:d,...v($.addonId)}),($.children.length>0||H.length>0)&&f("div",{className:"ml-4 pl-3 border-l border-border/60 space-y-1.5",children:[m&&o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/40",children:"Slot: Cropper / Classifier"}),$.children.map(G=>{const Z=B(G);return f("div",{className:"space-y-1.5",children:[o(js,{step:G,schema:k.get(G.addonId)??null,allSchemas:k,depth:1,onChange:oe=>{R({...$,children:$.children.map(ne=>ne.addonId===oe.addonId?oe:ne)})},onDelete:d?void 0:oe=>{R({...$,children:$.children.filter(ne=>ne.addonId!==oe)})},readOnly:d,...v(G.addonId)}),(G.children.length>0||Z.length>0)&&f("div",{className:"ml-4 pl-3 border-l border-border/40 space-y-1.5",children:[m&&o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/30",children:"Slot: Recognizer"}),G.children.map(oe=>o(js,{step:oe,schema:k.get(oe.addonId)??null,allSchemas:k,depth:2,onChange:ne=>{R({...$,children:$.children.map(X=>X.addonId===G.addonId?{...X,children:X.children.map(re=>re.addonId===ne.addonId?ne:re)}:X)})},onDelete:d?void 0:ne=>{R({...$,children:$.children.map(X=>X.addonId===G.addonId?{...X,children:X.children.filter(re=>re.addonId!==ne)}:X)})},readOnly:d,...v(oe.addonId)},oe.addonId)),!d&&Z.map(oe=>o(Pi,{addon:oe,onClick:()=>{const ne=Ai(oe);R({...$,children:$.children.map(X=>X.addonId===G.addonId?{...X,children:[...X.children,ne]}:X)})}},oe.id))]})]},G.addonId)}),!d&&H.map(G=>o(Pi,{addon:G,onClick:()=>D($.addonId,G)},G.id))]})]},$.addonId)}const j=e.slots.filter(V=>V.parentSlot===null).sort((V,$)=>V.priority-$.priority);return f("div",{className:"space-y-4",children:[!p&&o("div",{className:"rounded-lg border border-border bg-surface p-3",children:f("div",{className:"flex items-center gap-2",children:[o("div",{className:"relative flex-1 min-w-0",children:f("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:[o("option",{value:"",children:"No template"}),r.map(V=>o("option",{value:V.id,children:V.name},V.id))]})}),P&&o("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500 shrink-0"}),o("button",{onClick:z,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:o(HS,{className:"h-4 w-4"})}),o("button",{onClick:A,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:o(j5,{className:"h-4 w-4"})}),o("button",{onClick:O,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:o(Jt,{className:"h-4 w-4"})})]})}),C.length>0&&f("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 text-xs text-amber-400 space-y-1",children:[f("div",{className:"flex items-center justify-between",children:[o("span",{className:"font-medium",children:"Template loaded with warnings:"}),o("button",{onClick:()=>M([]),className:"text-amber-400/60 hover:text-amber-400",children:o(Je,{className:"h-3.5 w-3.5"})})]}),C.map((V,$)=>f("div",{children:["• ",V]},$))]}),j.map(V=>{const $=t.filter(ne=>ne.slot===V.id&&!N.has(ne.addonId)),H=h?$.filter(ne=>ne.enabled):$,G=h?[]:V.addons.filter(ne=>!T.has(ne.id)&&!N.has(ne.id)),Z=new Map,oe=[];for(const ne of H)ne.group?(Z.has(ne.group)||Z.set(ne.group,[]),Z.get(ne.group).push(ne)):oe.push(ne);return f("div",{className:"space-y-2",children:[m&&f("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50",children:["Slot: ",V.label]}),oe.map(ne=>F(ne)),[...Z.entries()].map(([ne,X])=>f("div",{className:"space-y-2 rounded-lg border border-border/40 p-2",children:[o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50 px-1",children:ne}),X.map(re=>F(re))]},ne)),!d&&G.map(ne=>o(Pi,{addon:ne,onClick:()=>{n([...t,Ai(ne)])}},ne.id))]},V.id)})]})}const po={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"},up=["#ef4444","#8b5cf6","#06b6d4","#f97316","#10b981","#6366f1","#e11d48","#0891b2","#7c3aed","#059669"],Wg="#f59e42";function gt(e,t){if(t?.[e])return t[e];if(t?.[e.toLowerCase()])return t[e.toLowerCase()];if(po[e])return po[e];if(po[e.toLowerCase()])return po[e.toLowerCase()];let n=0;for(let r=0;r<e.length;r++)n=n*31+(e.codePointAt(r)??0)>>>0;return up[n%up.length]??Wg}function MM({src:e,imageWidth:t,imageHeight:n,detections:r=[],classColors:s,aspectRatio:a,className:i,placeholder:l,showConfidence:c=!0,minConfidence:d=0,borderWidth:u=2}){function p(y){return gt(y,s)}const h=a??(t&&n?`${t}/${n}`:"16/9"),m=r.filter(y=>y.score>=d),g=m.filter(y=>y.kind==="first-level"),b=m.filter(y=>y.kind==="detail"),x=AM(b,y=>y.parentId??"");return o("div",{className:K("rounded-lg border border-border bg-surface overflow-hidden relative",i),style:{aspectRatio:h},children:e?f(he,{children:[o("img",{src:e,className:"absolute inset-0 w-full h-full object-fill",alt:""}),m.map((y,w)=>y.debug?.mask&&y.debug.maskWidth&&y.debug.maskHeight?o(EM,{mask:y.debug.mask,maskWidth:y.debug.maskWidth,maskHeight:y.debug.maskHeight,bbox:y.bbox,imageWidth:t,imageHeight:n,color:p(y.macroClass)},`mask-${w}`):null),g.map(y=>{const w=x.get(y.id)??[];return o(pp,{detection:y,imageWidth:t,imageHeight:n,color:p(y.macroClass),showConfidence:c,borderWidth:y.debug?.mask?1:u,children:w.map(v=>o(IM,{child:v,parentBbox:y.bbox,color:p(v.macroClass),showConfidence:c},`child-${v.id}`))},`det-${y.id}`)}),b.filter(y=>!y.parentId||!g.some(w=>w.id===y.parentId)).map(y=>o(pp,{detection:y,imageWidth:t,imageHeight:n,color:p(y.macroClass),showConfidence:c,borderWidth:u},`orphan-${y.id}`))]}):o("div",{className:"w-full h-full flex items-center justify-center text-foreground-subtle text-sm",children:l??"No image loaded"})})}function pp({detection:e,imageWidth:t,imageHeight:n,color:r,showConfidence:s,borderWidth:a,children:i}){const{x:l,y:c,width:d,height:u}=e.bbox,p=f("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"2px"},children:[f("span",{className:"text-[10px] px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:r},children:[e.macroClass,s&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((h,m)=>f("span",{className:"text-[9px] font-semibold px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:gt(h.label)},children:[h.label," ",(h.score*100).toFixed(0),"%"]},`${e.id}-lbl-${m}`))]});return f("div",{className:"absolute rounded-sm",style:{left:`${l/t*100}%`,top:`${c/n*100}%`,width:`${d/t*100}%`,height:`${u/n*100}%`,borderWidth:`${a}px`,borderStyle:"solid",borderColor:r},children:[p,i]})}function EM({mask:e,maskWidth:t,maskHeight:n,bbox:r,imageWidth:s,imageHeight:a,color:i}){const l=te(null);return Y(()=>{const c=l.current;if(!c)return;const d=c.getContext("2d");if(!d)return;const u=atob(e),p=new Uint8Array(u.length);for(let y=0;y<u.length;y++)p[y]=u.charCodeAt(y);const h=parseInt(i.slice(1,3),16),m=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 y=0;y<x;y++){const w=y<p.length?p[y]:0,v=y*4;w>0&&(b.data[v]=h,b.data[v+1]=m,b.data[v+2]=g,b.data[v+3]=120)}d.putImageData(b,0,0)},[e,t,n,i]),o("canvas",{ref:l,className:"absolute pointer-events-none",style:{left:`${r.x/s*100}%`,top:`${r.y/a*100}%`,width:`${r.width/s*100}%`,height:`${r.height/a*100}%`,imageRendering:"pixelated"}})}function IM({child:e,parentBbox:t,color:n,showConfidence:r}){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 o("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:f("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"1px"},children:[f("span",{className:"text-[9px] px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:n},children:[e.macroClass,r&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((c,d)=>f("span",{className:"text-[8px] font-semibold px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:gt(c.label)},children:[c.label," ",(c.score*100).toFixed(0),"%"]},`${e.id}-lbl-${d}`))]})})}function AM(e,t){const n=new Map;for(const r of e){const s=t(r),a=n.get(s)??[];a.push(r),n.set(s,a)}return n}function PM({detections:e,classColors:t,className:n,hiddenKeys:r,onToggleVisibility:s}){const a=t;if(e.length===0)return o("div",{className:"text-sm text-foreground-subtle italic text-center py-4",children:"No detections"});const i=e.filter(u=>u.kind==="first-level"),l=e.filter(u=>u.kind==="detail"),c=new Map;for(const u of l){if(!u.parentId)continue;const p=c.get(u.parentId)??[];p.push(u),c.set(u.parentId,p)}const d=l.filter(u=>!u.parentId||!i.some(p=>p.id===u.parentId));return f("div",{className:n,children:[f("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Detections (",e.length,")"]}),f("div",{className:"space-y-2",children:[i.map(u=>o(fp,{detection:u,children_:c.get(u.id)??[],colors:a,hiddenKeys:r,onToggleVisibility:s},u.id)),d.map(u=>o(fp,{detection:u,children_:[],colors:a,hiddenKeys:r,onToggleVisibility:s},u.id))]})]})}function fp({detection:e,children_:t,colors:n,hiddenKeys:r,onToggleVisibility:s}){const a=gt(e.macroClass,n),i=!r?.has(e.id),l=e.debug?.mask,c=e.debug?.maskWidth,d=e.debug?.maskHeight,u=e.debug?.alternateLabels;return f("div",{className:`rounded-md border border-border bg-surface p-3 space-y-1 ${i?"":"opacity-40"}`,children:[f("div",{className:"flex justify-between items-center",children:[f("div",{className:"flex items-center gap-2",children:[s&&o("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"}),o("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:a}}),o("span",{className:"text-sm font-medium text-foreground",children:e.macroClass}),e.kind==="detail"&&o("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:"detail"}),l&&c&&d&&f("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:["mask ",c,"x",d]})]}),o(DM,{confidence:e.score})]}),f("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&&o("div",{className:"flex flex-wrap gap-1 mt-1",children:e.labels.map((p,h)=>f("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{backgroundColor:gt(p.label,n)+"20",color:gt(p.label,n)},children:[p.label,f("span",{className:"opacity-60",children:[(p.score*100).toFixed(0),"%"]}),p.detectionId&&f("span",{className:"opacity-40 text-[8px]",children:["→ ",p.detectionId]})]},h))}),u&&Object.keys(u).length>0&&o($M,{alternateLabels:u,colors:n}),t.length>0&&o(_M,{items:t,colors:n,hiddenKeys:r,onToggleVisibility:s})]})}function _M({items:e,colors:t,hiddenKeys:n,onToggleVisibility:r}){return o("div",{className:"ml-4 mt-1.5 space-y-1.5 border-l-2 border-border pl-3",children:e.map(s=>{const a=gt(s.macroClass,t),i=!n?.has(s.id),l=s.debug?.mask,c=s.debug?.maskWidth,d=s.debug?.maskHeight;return f("div",{className:`text-xs space-y-0.5 ${i?"":"opacity-40"}`,children:[f("div",{className:"flex items-center gap-1.5",children:[r&&o("input",{type:"checkbox",checked:i,onChange:()=>r(s.id,!i),className:"h-3 w-3 rounded border-border accent-primary cursor-pointer shrink-0"}),o("span",{className:"h-1.5 w-1.5 rounded-full shrink-0",style:{backgroundColor:a}}),o("span",{className:"font-medium",style:{color:a},children:s.macroClass}),f("span",{className:"text-foreground-subtle",children:[(s.score*100).toFixed(0),"%"]}),l&&c&&d&&f("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&&o("div",{className:"flex flex-wrap gap-1 ml-5 mt-0.5",children:s.labels.map((u,p)=>f("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-medium px-1 py-0.5 rounded-full",style:{backgroundColor:gt(u.label,t)+"20",color:gt(u.label,t)},children:[u.label," ",f("span",{className:"opacity-60",children:[(u.score*100).toFixed(0),"%"]})]},p))})]},s.id)})})}function $M({alternateLabels:e,colors:t}){const[n,r]=_(!1),s=Object.keys(e);return f("div",{className:"mt-1",children:[f("button",{onClick:()=>r(a=>!a),className:"text-[9px] text-foreground-subtle hover:text-foreground transition-colors flex items-center gap-1",children:[o("span",{className:`transition-transform ${n?"rotate-90":""}`,children:"▶"}),"Alternates (",s.length," source",s.length!==1?"s":"",")"]}),n&&o("div",{className:"mt-1 ml-3 space-y-1.5",children:s.map(a=>{const i=e[a];return!i||i.length===0?null:f("div",{children:[o("div",{className:"text-[9px] font-medium text-foreground-subtle mb-0.5",children:a}),o("div",{className:"flex flex-wrap gap-1",children:i.map((l,c)=>f("span",{className:"inline-flex items-center gap-0.5 text-[9px] px-1 py-0.5 rounded-full",style:{backgroundColor:gt(a,t)+"10",color:gt(a,t),opacity:Math.max(.4,l.score)},children:[l.label,f("span",{className:"opacity-60",children:[(l.score*100).toFixed(1),"%"]})]},c))})]},a)})})]})}function DM({confidence:e}){const t=e>=.8?"bg-success/10 text-success":e>=.5?"bg-warning/10 text-warning":"bg-danger/10 text-danger";return f("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${t}`,children:[(e*100).toFixed(1),"%"]})}function LM({timings:e,totalMs:t,className:n}){const r=Object.entries(e);return r.length===0&&t===void 0?null:f("div",{className:`rounded-lg border border-border bg-surface p-3 space-y-2 ${n??""}`,children:[o("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide",children:"Timings"}),f("div",{className:"space-y-1 text-xs",children:[r.map(([s,a])=>f("div",{className:"flex justify-between",children:[o("span",{className:"text-foreground-subtle",children:s}),f("span",{className:"font-mono text-foreground",children:[a.toFixed(1),"ms"]})]},s)),t!==void 0&&f("div",{className:"flex justify-between pt-1 border-t border-border font-medium text-foreground",children:[o("span",{children:"Total"}),f("span",{className:"font-mono",children:[t.toFixed(1),"ms"]})]})]})]})}function TM({images:e,selectedFilename:t,uploadedName:n,onSelect:r,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 u=d.files?.[0];if(!u)return;const p=new FileReader;p.onload=()=>{const h=p.result,m=h.split(",")[1];m&&s(m,u.name,h)},p.readAsDataURL(u)},d.click()};return f("div",{className:`flex flex-wrap items-center gap-2 ${a??""}`,children:[e.map(d=>o("button",{onClick:()=>r(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)),o("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&&o("span",{className:"text-xs text-foreground-subtle",children:n})]})}const ps="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 RM({runtime:e,backend:t,modelId:n,agentId:r="hub",runtimes:s,backends:a,models:i,agents:l=[],onRuntimeChange:c,onBackendChange:d,onModelChange:u,onAgentChange:p,layout:h="grid",className:m,showAgent:g=!1}){return f("div",{className:`${h==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4":h==="horizontal"?"flex flex-wrap items-end gap-4":"space-y-3"} ${m??""}`,children:[g&&l.length>0&&f("label",{className:"space-y-1",children:[o("span",{className:"text-xs font-medium text-foreground-subtle",children:"Agent"}),o("select",{value:r,onChange:x=>p?.(x.target.value),className:ps,children:l.map(x=>f("option",{value:x.id,children:[x.name," (",x.status,")"]},x.id))})]}),f("label",{className:"space-y-1",children:[o("span",{className:"text-xs font-medium text-foreground-subtle",children:"Runtime"}),o("select",{value:e,onChange:x=>c(x.target.value),className:ps,children:s.map(x=>f("option",{value:x.value,disabled:!x.available,children:[x.label,x.available?"":" (unavailable)"]},x.value))})]}),f("label",{className:"space-y-1",children:[o("span",{className:"text-xs font-medium text-foreground-subtle",children:"Backend"}),o("select",{value:t,onChange:x=>d(x.target.value),className:ps,children:a.map(x=>f("option",{value:x.id,disabled:!x.available,children:[x.label,x.available?"":" (unavailable)"]},x.id))})]}),f("label",{className:"space-y-1",children:[o("span",{className:"text-xs font-medium text-foreground-subtle",children:"Model"}),o("select",{value:n,onChange:x=>u(x.target.value),className:ps,children:i.length===0?o("option",{value:"",children:"No compatible models"}):i.map(x=>f("option",{value:x.id,children:[x.name,x.downloaded?" ✓":""]},x.id))})]})]})}function OM({className:e}){return f("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:[o("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"}),o("circle",{cx:"12",cy:"12",r:"3"})]})}function BM({className:e}){return f("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:[o("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"}),o("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),o("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"}),o("path",{d:"m2 2 20 20"})]})}function zM({className:e}){return o("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:o("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}function Yg({onLogin:e,serverUrl:t,logoSrc:n,error:r,className:s}){const[a,i]=_(""),[l,c]=_(""),[d,u]=_(!1),[p,h]=_(!1),[m,g]=_(null),b=r??m,x=async y=>{if(y.preventDefault(),!p){g(null),h(!0);try{await e(a,l)}catch(w){const v=w instanceof Error?w.message:"Login failed. Please try again.";g(v)}finally{h(!1)}}};return o("div",{className:K("flex min-h-screen items-center justify-center bg-background p-4",s),children:f("div",{className:"w-full max-w-sm",children:[n&&o("div",{className:"flex justify-center mb-8",children:o("img",{src:n,alt:"Logo",className:"h-12"})}),t&&o("p",{className:"mb-4 text-center text-xs text-foreground-subtle truncate",children:t}),f("form",{onSubmit:x,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[b&&o("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:b}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"Username"}),o("input",{type:"text",value:a,onChange:y=>i(y.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"})]}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"Password"}),f("div",{className:"relative",children:[o("input",{type:d?"text":"password",value:l,onChange:y=>c(y.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"}),o("button",{type:"button",onClick:()=>u(y=>!y),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",tabIndex:-1,children:d?o(BM,{className:"h-4 w-4"}):o(OM,{className:"h-4 w-4"})})]})]}),f("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&&o(zM,{className:"h-4 w-4 animate-spin"}),p?"Logging in...":"Log in"]})]})]})})}const Ol="camstack_dev_token",Zg=ze(null);function FM(){const e=ve(Zg);if(!e)throw new Error("useDevShell must be used within a DevShell");return e}function jM(){return typeof window>"u"?null:localStorage.getItem(Ol)}function VM({className:e}){return f("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:[o("circle",{cx:"12",cy:"12",r:"4"}),o("path",{d:"M12 2v2"}),o("path",{d:"M12 20v2"}),o("path",{d:"m4.93 4.93 1.41 1.41"}),o("path",{d:"m17.66 17.66 1.41 1.41"}),o("path",{d:"M2 12h2"}),o("path",{d:"M20 12h2"}),o("path",{d:"m6.34 17.66-1.41 1.41"}),o("path",{d:"m19.07 4.93-1.41 1.41"})]})}function HM({className:e}){return o("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:o("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function qM({children:e,serverUrl:t,title:n,token:r,onLogout:s}){const a=Hr(),i=q(()=>{const h=t.replace(/^http/,"ws")+"/trpc",m=c2({url:h,connectionParams:()=>({token:r})});return[d2({condition:g=>g.type==="subscription",true:u2({client:m,transformer:Cl}),false:om({url:`${t}/trpc`,transformer:Cl,headers:()=>({authorization:`Bearer ${r}`})})})]},[t,r]),l=q(()=>rm({links:i}),[i]),c=q(()=>S.createClient({links:i}),[i]),d=q(()=>im({serverUrl:t,token:r}),[t,r]);Y(()=>(d.init().catch(()=>{}),()=>{d.close()}),[d]);const u=q(()=>new em,[]),p=q(()=>({trpc:l,token:r,logout:s}),[l,r,s]);return o(Gc,{system:d,children:o(S.Provider,{client:c,queryClient:u,children:o(tm,{client:u,children:o(Zg.Provider,{value:p,children:f("div",{className:"min-h-screen bg-background text-foreground",children:[f("div",{className:"flex items-center justify-between border-b border-border bg-surface px-4 py-2",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"rounded bg-warning/20 px-2 py-0.5 text-xs font-bold text-warning",children:"DEV MODE"}),n&&o("span",{className:"text-sm font-medium text-foreground",children:n}),o("span",{className:"text-xs text-foreground-subtle",children:t})]}),f("div",{className:"flex items-center gap-2",children:[f("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"?o(VM,{className:"h-3.5 w-3.5"}):o(HM,{className:"h-3.5 w-3.5"}),a.mode==="dark"?"Dark":a.mode==="light"?"Light":"System"]}),o("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"})]})]}),o("div",{className:"p-4",children:e({trpc:l,theme:a})})]})})})})})}function Xg({children:e,serverUrl:t="https://localhost:4443",title:n}){const[r,s]=_(jM),a=U(async(l,c)=>{const p=await rm({links:[om({url:`${t}/trpc`,transformer:Cl})]}).auth.login.mutate({username:l,password:c});if(!p.token)throw new Error("No token returned");localStorage.setItem(Ol,p.token),s(p.token)},[t]),i=U(()=>{localStorage.removeItem(Ol),s(null)},[]);return r?o(Xs,{children:o(qM,{serverUrl:t,title:n,token:r,onLogout:i,children:e})}):o(Xs,{children:o(Yg,{onLogin:a,serverUrl:t})})}function UM(e,t={}){const{serverUrl:n="https://localhost:4443",title:r,rootId:s="root"}=t,a=document.getElementById(s);if(!a){console.error(`[mountAddonPage] Element #${s} not found`);return}Xh(a).render(Ee(Xg,{serverUrl:n,title:r,children:({trpc:i,theme:l})=>Ee(e,{trpc:i,theme:{isDark:l.resolvedMode==="dark"},navigate:c=>{console.log("[dev] navigate:",c)}})}))}const Jg=yn("camstack:custom-field-renderers",{});function eb({renderers:e,children:t}){return o(Jg.Provider,{value:e,children:t})}function tb(e){return ve(Jg)[e]??null}const Jc=yn("camstack:device-context",null);function nb({deviceId:e,device:t,children:n}){const r={deviceId:e,device:t??null};return o(Jc.Provider,{value:r,children:n})}function wn(){return ve(Jc)?.deviceId??null}function ed(){return ve(Jc)?.device??null}const QM=S.accessories.getStatus.useQuery,Ba=S.addonPages.listPages.useQuery,Ko=S.addons.list.useQuery,GM=S.addons.getLogs.useQuery,KM=S.addons.listPackages.useQuery,td=S.addons.installPackage.useMutation,WM=S.addons.installFromWorkspace.useMutation,YM=S.addons.isWorkspaceAvailable.useQuery,ZM=S.addons.listWorkspacePackages.useQuery,rb=S.addons.uninstallPackage.useMutation,ob=S.addons.reloadPackages.useMutation,sb=S.addons.searchAvailable.useQuery,nd=S.addons.listUpdates.useQuery,Bl=S.addons.updatePackage.useMutation,XM=S.addons.rollbackPackage.useMutation,ab=S.addons.forceRefresh.useMutation,ib=S.addons.restartServer.useMutation,lb=S.addons.getLastRestart.useQuery,cb=S.addons.listFrameworkPackages.useQuery,JM=S.addons.listCapabilityProviders.useQuery,db=S.addons.updateFrameworkPackage.useMutation,ub=S.addons.getVersions.useQuery,Wo=S.addons.restartAddon.useMutation,pb=S.addons.retryLoad.useMutation,fb=S.addons.getAutoUpdateSettings.useQuery,e4=S.addons.setAutoUpdateSettings.useMutation,hb=S.addons.getAddonAutoUpdate.useQuery,mb=S.addons.setAddonAutoUpdate.useMutation,gb=S.addons.applyAutoUpdateToAll.useMutation,t4=S.addons.custom.useMutation,n4=S.addons.onAddonLogs.useSubscription,rd=S.addonSettings.getGlobalSettings.useQuery,bb=S.addonSettings.updateGlobalSettings.useMutation,r4=S.addonSettings.getDeviceSettings.useQuery,xb=S.addonSettings.updateDeviceSettings.useMutation,yb=S.addonWidgets.listWidgets.useQuery,o4=S.alerts.emit.useMutation,s4=S.alerts.update.useMutation,vb=S.alerts.list.useQuery,wb=S.alerts.getUnreadCount.useQuery,Nb=S.alerts.markRead.useMutation,kb=S.alerts.markAllRead.useMutation,Sb=S.alerts.dismiss.useMutation,a4=S.audioAnalysis.resolveDeviceSettings.useQuery,i4=S.audioAnalysis.getDeviceSettingsContribution.useQuery,l4=S.audioAnalysis.getDeviceLiveContribution.useQuery,c4=S.audioAnalysis.applyDeviceSettingsPatch.useMutation,d4=S.audioAnalyzer.analyseChunk.useMutation,u4=S.audioAnalyzer.classify.useQuery,p4=S.audioAnalyzer.isReady.useQuery,f4=S.audioAnalyzer.dispose.useMutation,Cb=S.audioAnalyzer.reprobeAudioEngine.useMutation,h4=S.audioCodec.listSupportedCodecs.useQuery,m4=S.audioCodec.canHandle.useQuery,g4=S.audioCodec.createDecodeSession.useMutation,b4=S.audioCodec.createEncodeSession.useMutation,x4=S.audioCodec.closeSession.useMutation,y4=S.audioCodec.pushEncodedFrame.useMutation,v4=S.audioCodec.pullPcm.useQuery,w4=S.audioCodec.pushPcm.useMutation,N4=S.audioCodec.pullEncoded.useQuery,k4=S.audioCodec.flushEncode.useMutation,S4=S.audioCodec.listActiveSessions.useQuery,C4=S.audioMetrics.getCurrentSnapshot.useQuery,M4=S.audioMetrics.getHistory.useQuery,od=S.authentication.listProviders.useQuery,E4=S.authentication.setProviderEnabled.useMutation,sd=S.backup.listDestinations.useQuery,Mb=S.backup.trigger.useMutation,I4=S.backup.list.useQuery,Eb=S.backup.listLocations.useQuery,Ib=S.backup.getEntries.useQuery,Ab=S.backup.restore.useMutation,Pb=S.backup.delete.useMutation,ad=S.backup.listArchives.useQuery,_b=S.backup.upsertDestinationPolicy.useMutation,$b=S.backup.previewSchedule.useQuery,A4=S.battery.getStatus.useQuery,P4=S.brightness.setBrightness.useMutation,_4=S.brightness.getStatus.useQuery,$4=S.cameraCredentials.getCredentials.useQuery,D4=S.cameraCredentials.getStatus.useQuery,L4=S.cameraStreams.getCameraStreams.useQuery,T4=S.cameraStreams.getBrokerStreams.useQuery,Db=S.cameraStreams.getRtspEntries.useQuery,R4=S.decoder.supportsCodec.useQuery,O4=S.decoder.getInfo.useQuery,B4=S.decoder.createSession.useQuery,z4=S.decoder.destroySession.useQuery,F4=S.decoder.pushPacket.useQuery,j4=S.decoder.openStream.useQuery,V4=S.decoder.pullFrames.useQuery,H4=S.decoder.updateConfig.useQuery,q4=S.decoder.getStats.useQuery,U4=S.decoder.listActiveSessions.useQuery,Lb=S.decoder.reprobeHwaccel.useMutation,Q4=S.detectionPipeline.getDeviceSettingsContribution.useQuery,G4=S.detectionPipeline.getDeviceLiveContribution.useQuery,K4=S.detectionPipeline.applyDeviceSettingsPatch.useMutation,Tb=S.deviceDiscovery.listDiscovered.useQuery,Rb=S.deviceDiscovery.refreshDiscovery.useMutation,W4=S.deviceDiscovery.adoptDevice.useMutation,Y4=S.deviceDiscovery.releaseDevice.useMutation,Z4=S.deviceDiscovery.getStatus.useQuery,id=S.deviceExport.getStatus.useQuery,X4=S.deviceExport.listSupportedDeviceKinds.useQuery,Ob=S.deviceExport.listExposedDevices.useQuery,J4=S.deviceExport.exposeDevice.useMutation,Bb=S.deviceExport.unexposeDevice.useMutation,eE=S.deviceExport.getDeviceSettingsContribution.useQuery,tE=S.deviceExport.getDeviceLiveContribution.useQuery,nE=S.deviceExport.applyDeviceSettingsPatch.useMutation,rE=S.deviceManager.allocateDeviceId.useMutation,oE=S.deviceManager.registerDevice.useMutation,sE=S.deviceManager.removeDevice.useMutation,aE=S.deviceManager.persistConfig.useMutation,iE=S.deviceManager.loadConfig.useQuery,lE=S.deviceManager.loadRuntimeState.useQuery,cE=S.deviceManager.loadMeta.useQuery,zb=S.deviceManager.setName.useMutation,Fb=S.deviceManager.setLocation.useMutation,dE=S.deviceManager.setMetadata.useMutation,jb=S.deviceManager.listLocations.useQuery,uE=S.deviceManager.addLocation.useMutation,pE=S.deviceManager.removeLocation.useMutation,fE=S.deviceManager.setDisabled.useMutation,hE=S.deviceManager.listPersistedByAddon.useQuery,On=S.deviceManager.listAll.useQuery,Jn=S.deviceManager.getDevice.useQuery,Vb=S.deviceManager.getChildren.useQuery,mE=S.deviceManager.getStreamSources.useQuery,gE=S.deviceManager.getConfigSchema.useQuery,bE=S.deviceManager.getSettingsSchema.useQuery,xE=S.deviceManager.updateConfig.useMutation,Hb=S.deviceManager.enable.useMutation,qb=S.deviceManager.disable.useMutation,Ub=S.deviceManager.remove.useMutation,yE=S.deviceManager.getStreamProfileMap.useQuery,vE=S.deviceManager.setStreamProfileMap.useMutation,wE=S.deviceManager.probeStreams.useMutation,Qb=S.deviceManager.getBindings.useQuery,NE=S.deviceManager.getAllBindings.useQuery,Gb=S.deviceManager.setWrapperActive.useMutation,kE=S.deviceManager.listWrappersForCap.useQuery,Kb=S.deviceManager.listBindableCapsForDeviceType.useQuery,SE=S.deviceManager.getDeviceSettingsAggregate.useQuery,CE=S.deviceManager.getDeviceLiveInfoAggregate.useQuery,ld=S.deviceManager.getDeviceAggregate.useQuery,ME=S.deviceManager.updateDeviceField.useMutation,Wb=S.deviceManager.updateDeviceFieldsBatch.useMutation,cd=S.deviceManager.discoverDevices.useMutation,Yb=S.deviceManager.adoptDevice.useMutation,Zb=S.deviceManager.getCreationSchema.useQuery,Xb=S.deviceManager.createDevice.useMutation,dd=S.deviceManager.testCreationField.useMutation,EE=S.deviceManager.testField.useMutation,IE=S.deviceManager.getDeviceStatusAggregate.useQuery,AE=S.deviceOps.getStreamSources.useQuery,PE=S.deviceOps.getConfigEntries.useQuery,_E=S.deviceOps.setConfig.useMutation,$E=S.deviceOps.removeDevice.useMutation,DE=S.deviceOps.getSettingsSchema.useQuery,LE=S.deviceProvider.start.useMutation,TE=S.deviceProvider.stop.useMutation,RE=S.deviceProvider.getStatus.useQuery,OE=S.deviceProvider.getDevices.useQuery,BE=S.deviceProvider.supportsDiscovery.useQuery,zE=S.deviceProvider.discoverDevices.useMutation,FE=S.deviceProvider.adoptDiscoveredDevice.useMutation,jE=S.deviceProvider.supportsManualCreation.useQuery,VE=S.deviceProvider.getChildCreationSchema.useQuery,HE=S.deviceProvider.createDevice.useMutation,qE=S.deviceProvider.testCreationField.useMutation,UE=S.deviceState.getSnapshot.useQuery,QE=S.deviceState.getCapSlice.useQuery,GE=S.deviceState.getAllSnapshots.useQuery,KE=S.deviceState.setCapSlice.useMutation,WE=S.deviceStatus.getStatus.useQuery,YE=S.doorbell.getStatus.useQuery,ZE=S.events.getEvents.useQuery,XE=S.events.getEventThumbnail.useQuery,JE=S.events.getEventClipUrl.useQuery,eI=S.featureProbe.getStatus.useQuery,ud=S.integrations.list.useQuery,Jb=S.integrations.get.useQuery,ex=S.integrations.getByAddonId.useQuery,tx=S.integrations.create.useMutation,nx=S.integrations.update.useMutation,rx=S.integrations.delete.useMutation,tI=S.integrations.getSettings.useQuery,nI=S.integrations.setSettings.useMutation,ox=S.integrations.getAvailableTypes.useQuery,sx=S.integrations.testConnection.useMutation,ax=S.intercom.startSession.useMutation,ix=S.intercom.handleAnswer.useMutation,lx=S.intercom.stopSession.useMutation,rI=S.intercom.startTalkSession.useMutation,oI=S.intercom.pushTalkPcm.useMutation,sI=S.intercom.endTalkSession.useMutation,aI=S.intercom.getStatus.useQuery,cx=S.localNetwork.list.useQuery,iI=S.localNetwork.getPreferred.useQuery,dx=S.localNetwork.getConnectionEndpoints.useQuery,ux=S.localNetwork.getAllowedAddresses.useQuery,px=S.localNetwork.setAllowedAddresses.useMutation,fx=S.localNetwork.resetAllowlistToBestMatch.useMutation,lI=S.meshNetwork.getStatus.useQuery,cI=S.meshNetwork.join.useMutation,dI=S.meshNetwork.startLogin.useMutation,uI=S.meshNetwork.leave.useMutation,pI=S.meshNetwork.logout.useMutation,fI=S.meshNetwork.listPeers.useQuery,hI=S.meshNetwork.testConnection.useMutation,hx=S.meshOrchestrator.listProviders.useQuery,mI=S.meshOrchestrator.joinProvider.useMutation,mx=S.meshOrchestrator.leaveProvider.useMutation,gx=S.meshOrchestrator.startLoginProvider.useMutation,bx=S.meshOrchestrator.logoutProvider.useMutation,xx=S.meshOrchestrator.listProviderPeers.useQuery,gI=S.metricsProvider.collectSnapshot.useQuery,bI=S.metricsProvider.getCached.useQuery,xI=S.metricsProvider.getCurrent.useQuery,yI=S.metricsProvider.getDiskSpace.useQuery,vI=S.metricsProvider.getGpuInfo.useQuery,wI=S.metricsProvider.getCpuTemperature.useQuery,NI=S.metricsProvider.getProcessStats.useQuery,kI=S.metricsProvider.listAddonInstances.useQuery,SI=S.metricsProvider.getAddonStats.useQuery,yx=S.metricsProvider.listNodeProcesses.useQuery,vx=S.metricsProvider.killProcess.useMutation,CI=S.motion.isDetected.useQuery,MI=S.motion.getStatus.useQuery,EI=S.motionDetection.analyze.useMutation,II=S.motionDetection.removeCamera.useMutation,AI=S.motionDetection.reset.useMutation,PI=S.motionDetection.getDeviceSettingsContribution.useQuery,_I=S.motionDetection.getDeviceLiveContribution.useQuery,$I=S.motionDetection.applyDeviceSettingsPatch.useMutation,DI=S.motionTrigger.setMotionTrigger.useMutation,LI=S.motionTrigger.getStatus.useQuery,TI=S.mqttBroker.listBrokers.useQuery,RI=S.mqttBroker.getBrokerConfig.useQuery,OI=S.mqttBroker.addBroker.useMutation,BI=S.mqttBroker.removeBroker.useMutation,zI=S.mqttBroker.testConnection.useMutation,FI=S.mqttBroker.startEmbeddedBroker.useMutation,jI=S.mqttBroker.stopEmbeddedBroker.useMutation,wx=S.mqttBroker.getStatus.useQuery,VI=S.nativeObjectDetection.getStatus.useQuery,pd=S.networkQuality.getDeviceStats.useQuery,HI=S.networkQuality.getAllStats.useQuery,qI=S.networkQuality.reportClientStats.useMutation,Bn=S.nodes.topology.useQuery,UI=S.nodes.deployAddon.useMutation,Nx=S.nodes.undeployAddon.useMutation,za=S.nodes.restartAddon.useMutation,kx=S.nodes.restartProcess.useMutation,Sx=S.nodes.restartNode.useMutation,QI=S.nodes.shutdownNode.useMutation,Cx=S.nodes.renameNode.useMutation,Mx=S.nodes.clusterAddonStatus.useQuery,Ex=S.nodes.getNodeAddons.useQuery,Ix=S.nodes.setProcessLogLevel.useMutation,GI=S.nodes.executeQuery.useMutation,KI=S.notificationOutput.send.useMutation,WI=S.notificationOutput.sendTest.useMutation,YI=S.osd.setOverlay.useMutation,ZI=S.osd.getStatus.useQuery,XI=S.pipelineAnalytics.getActiveTracks.useQuery,JI=S.pipelineAnalytics.getTrack.useQuery,eA=S.pipelineAnalytics.listTracks.useQuery,tA=S.pipelineAnalytics.clearTracks.useMutation,nA=S.pipelineAnalytics.getMotionEvents.useQuery,rA=S.pipelineAnalytics.getObjectEvents.useQuery,oA=S.pipelineAnalytics.getAudioEvents.useQuery,sA=S.pipelineAnalytics.getEventMedia.useQuery,aA=S.pipelineAnalytics.getTrackMedia.useQuery,iA=S.pipelineAnalytics.getDeviceSettingsContribution.useQuery,lA=S.pipelineAnalytics.getDeviceLiveContribution.useQuery,cA=S.pipelineAnalytics.applyDeviceSettingsPatch.useMutation,Ax=S.pipelineExecutor.getAvailableEngines.useQuery,Px=S.pipelineExecutor.getSelectedEngine.useQuery,dA=S.pipelineExecutor.getDefaultSteps.useQuery,_x=S.pipelineExecutor.reprobeEngine.useMutation,uA=S.pipelineExecutor.getVideoPipelineSteps.useQuery,pA=S.pipelineExecutor.setVideoPipelineSteps.useMutation,Yo=S.pipelineExecutor.getSchema.useQuery,fA=S.pipelineExecutor.getGlobalSteps.useQuery,hA=S.pipelineExecutor.getGlobalPipelineConfig.useQuery,mA=S.pipelineExecutor.getOrchestratorConfigSchema.useQuery,gA=S.pipelineExecutor.listTemplates.useQuery,bA=S.pipelineExecutor.saveTemplate.useMutation,xA=S.pipelineExecutor.updateTemplate.useMutation,yA=S.pipelineExecutor.deleteTemplate.useMutation,vA=S.pipelineExecutor.getCapabilities.useQuery,wA=S.pipelineExecutor.getAddonModels.useQuery,$x=S.pipelineExecutor.downloadModel.useMutation,Dx=S.pipelineExecutor.deleteModel.useMutation,NA=S.pipelineExecutor.detect.useQuery,kA=S.pipelineExecutor.runPipeline.useMutation,SA=S.pipelineExecutor.runPipelineBatch.useMutation,CA=S.pipelineExecutor.cacheFrameInPool.useMutation,MA=S.pipelineExecutor.inferCached.useMutation,EA=S.pipelineExecutor.uncacheFrame.useMutation,IA=S.pipelineExecutor.getEffectiveTuning.useQuery,Lx=S.pipelineExecutor.listLoadedEngines.useQuery,AA=S.pipelineExecutor.spinEngine.useMutation,Tx=S.pipelineExecutor.killEngine.useMutation,PA=S.pipelineExecutor.listReferenceImages.useQuery,_A=S.pipelineExecutor.getReferenceImage.useQuery,$A=S.pipelineExecutor.getReferenceAudioFiles.useQuery,DA=S.pipelineExecutor.getReferenceAudio.useQuery,LA=S.pipelineExecutor.getAudioCapabilities.useQuery,TA=S.pipelineExecutor.runAudioTest.useMutation,RA=S.pipelineExecutor.getDetectionConfigSchema.useQuery,Rx=S.pipelineOrchestrator.assignPipeline.useMutation,Ox=S.pipelineOrchestrator.unassignPipeline.useMutation,Bx=S.pipelineOrchestrator.rebalance.useMutation,Fa=S.pipelineOrchestrator.getPipelineAssignments.useQuery,ja=S.pipelineOrchestrator.getPipelineAssignment.useQuery,zx=S.pipelineOrchestrator.getAgentLoad.useQuery,OA=S.pipelineOrchestrator.getGlobalMetrics.useQuery,BA=S.pipelineOrchestrator.getCameraMetrics.useQuery,Fx=S.pipelineOrchestrator.getCapabilityBindings.useQuery,jx=S.pipelineOrchestrator.setCapabilityBinding.useMutation,Vx=S.pipelineOrchestrator.assignDecoder.useMutation,Hx=S.pipelineOrchestrator.unassignDecoder.useMutation,qx=S.pipelineOrchestrator.getDecoderAssignments.useQuery,Ux=S.pipelineOrchestrator.assignAudio.useMutation,Qx=S.pipelineOrchestrator.unassignAudio.useMutation,zA=S.pipelineOrchestrator.getAudioAssignment.useQuery,Gx=S.pipelineOrchestrator.getAudioNodeLoad.useQuery,Kx=S.pipelineOrchestrator.getAudioAssignments.useQuery,FA=S.pipelineOrchestrator.getDecoderAssignment.useQuery,fd=S.pipelineOrchestrator.getAgentSettings.useQuery,Yr=S.pipelineOrchestrator.listAgentSettings.useQuery,hd=S.pipelineOrchestrator.setAgentAddonDefaults.useMutation,Wx=S.pipelineOrchestrator.removeAgentSettings.useMutation,md=S.pipelineOrchestrator.getCameraSettings.useQuery,Yx=S.pipelineOrchestrator.setCameraStepToggle.useMutation,jA=S.pipelineOrchestrator.getCameraStepOverrides.useQuery,Zx=S.pipelineOrchestrator.setCameraStepOverride.useMutation,Xx=S.pipelineOrchestrator.setCameraPipelineForAgent.useMutation,Jx=S.pipelineOrchestrator.resolvePipeline.useQuery,e0=S.pipelineOrchestrator.listTemplates.useQuery,VA=S.pipelineOrchestrator.saveTemplate.useMutation,t0=S.pipelineOrchestrator.updateTemplate.useMutation,n0=S.pipelineOrchestrator.deleteTemplate.useMutation,HA=S.pipelineOrchestrator.getDeviceSettingsContribution.useQuery,qA=S.pipelineOrchestrator.getDeviceLiveContribution.useQuery,UA=S.pipelineOrchestrator.applyDeviceSettingsPatch.useMutation,QA=S.pipelineRunner.attachCamera.useMutation,GA=S.pipelineRunner.detachCamera.useMutation,KA=S.pipelineRunner.reportMotion.useMutation,WA=S.pipelineRunner.getLocalLoad.useQuery,YA=S.pipelineRunner.getLocalMetrics.useQuery,gd=S.pipelineRunner.getCameraMetrics.useQuery,ZA=S.pipelineRunner.getAllCameraMetrics.useQuery,r0=S.pipelineRunner.getLocalCameras.useQuery,XA=S.platformProbe.getCapabilities.useQuery,JA=S.platformProbe.getHardware.useQuery,eP=S.platformProbe.resolveInferenceConfig.useQuery,tP=S.platformProbe.resolveHwAccel.useQuery,nP=S.platformProbe.getHardwareEncoders.useQuery,rP=S.platformProbe.refreshHardwareEncoders.useMutation,oP=S.ptz.move.useMutation,sP=S.ptz.continuousMove.useMutation,aP=S.ptz.stop.useMutation,iP=S.ptz.getPresets.useQuery,lP=S.ptz.goToPreset.useMutation,cP=S.ptz.goHome.useMutation,dP=S.ptz.getPosition.useQuery,uP=S.ptz.getStatus.useQuery,o0=S.ptzAutotrack.getStatus.useQuery,s0=S.ptzAutotrack.setEnabled.useMutation,pP=S.ptzAutotrack.getSettings.useQuery,a0=S.ptzAutotrack.setSettings.useMutation,i0=S.reboot.reboot.useMutation,fP=S.recording.getSegments.useQuery,hP=S.recording.getPlaybackUrl.useQuery,mP=S.recording.getThumbnailAt.useQuery,gP=S.recordingEngine.getStatus.useQuery,l0=S.recordingEngine.enable.useMutation,c0=S.recordingEngine.disable.useMutation,d0=S.recordingEngine.getConfig.useQuery,bP=S.recordingEngine.updateConfig.useMutation,xP=S.recordingEngine.getPlaylist.useQuery,yP=S.recordingEngine.getThumbnail.useQuery,u0=S.recordingEngine.getSegments.useQuery,vP=S.recordingEngine.getAvailability.useQuery,wP=S.recordingEngine.estimateStorage.useQuery,NP=S.recordingEngine.estimateGlobalStorage.useQuery,p0=S.recordingEngine.getStorageUsage.useQuery,kP=S.recordingEngine.setPolicy.useMutation,SP=S.recordingEngine.getPolicy.useQuery,f0=S.recordingEngine.getPolicyStatus.useQuery,h0=S.recordingEngine.getRetentionConfig.useQuery,CP=S.recordingEngine.updateRetentionConfig.useMutation,MP=S.recordingEngine.getMotionStats.useQuery,m0=S.remoteAccess.listProviders.useQuery,g0=S.remoteAccess.startProvider.useMutation,b0=S.remoteAccess.stopProvider.useMutation,EP=S.settingsStore.get.useQuery,IP=S.settingsStore.set.useMutation,AP=S.settingsStore.query.useQuery,PP=S.settingsStore.insert.useMutation,_P=S.settingsStore.update.useMutation,$P=S.settingsStore.delete.useMutation,DP=S.settingsStore.count.useQuery,LP=S.settingsStore.isEmpty.useQuery,TP=S.settingsStore.declareCollection.useMutation,RP=S.snapshot.getSnapshot.useQuery,OP=S.snapshot.invalidateCache.useMutation,BP=S.snapshot.getStatus.useQuery,zP=S.snapshot.getDeviceSettingsContribution.useQuery,FP=S.snapshot.getDeviceLiveContribution.useQuery,jP=S.snapshot.applyDeviceSettingsPatch.useMutation,VP=S.snapshotProvider.supportsDevice.useQuery,HP=S.snapshotProvider.getSnapshot.useQuery,qP=S.storage.resolve.useQuery,UP=S.storage.write.useMutation,QP=S.storage.read.useQuery,GP=S.storage.exists.useQuery,KP=S.storage.list.useQuery,WP=S.storage.delete.useMutation,YP=S.storage.getAvailableSpace.useQuery,ZP=S.storage.beginUpload.useMutation,XP=S.storage.writeChunk.useMutation,JP=S.storage.finalizeUpload.useMutation,e_=S.storage.abortUpload.useMutation,t_=S.storage.beginDownload.useMutation,n_=S.storage.readChunk.useQuery,r_=S.storage.endDownload.useMutation,x0=S.storage.listLocations.useQuery,o_=S.storage.getDefaultLocation.useQuery,Va=S.storage.upsertLocation.useMutation,y0=S.storage.deleteLocation.useMutation,s_=S.storage.testLocation.useQuery,bd=S.storage.listProviders.useQuery,a_=S.storage.testConfig.useQuery,i_=S.streamBroker.publishCameraStream.useMutation,l_=S.streamBroker.retractCameraStream.useMutation,c_=S.streamBroker.assignProfile.useMutation,d_=S.streamBroker.unassignProfile.useMutation,u_=S.streamBroker.listAllCameraStreams.useQuery,p_=S.streamBroker.listAllProfileSlots.useQuery,f_=S.streamBroker.getBrokerStats.useQuery,h_=S.streamBroker.listClients.useQuery,m_=S.streamBroker.killClient.useMutation,g_=S.streamBroker.restartProfile.useMutation,b_=S.streamBroker.getStreamUrl.useQuery,x_=S.streamBroker.getStreamWithCodec.useMutation,y_=S.streamBroker.releaseStreamWithCodec.useMutation,v_=S.streamBroker.getBroker.useQuery,w_=S.streamBroker.setPreBufferDuration.useMutation,N_=S.streamBroker.getPreBufferInfo.useQuery,k_=S.streamBroker.getRtspPort.useQuery,S_=S.streamBroker.getAllRtspEntries.useQuery,C_=S.streamBroker.getRtspEntry.useQuery,v0=S.streamBroker.regenerateRtspToken.useMutation,M_=S.streamBroker.setRtspEnabled.useMutation,E_=S.streamBroker.isRtspEnabled.useQuery,I_=S.streamBroker.getDeviceSettingsContribution.useQuery,A_=S.streamBroker.getDeviceLiveContribution.useQuery,P_=S.streamBroker.applyDeviceSettingsPatch.useMutation,__=S.switch.setState.useMutation,$_=S.switch.getStatus.useQuery,D_=S.system.info.useQuery,L_=S.system.health.useQuery,T_=S.system.featureFlags.useQuery,R_=S.system.networkAddresses.useQuery,O_=S.system.getRetentionConfig.useQuery,B_=S.system.setRetentionConfig.useMutation,z_=S.system.forceRetentionCleanup.useMutation,w0=S.toast.onToast.useSubscription,N0=S.turnOrchestrator.listProviders.useQuery,k0=S.turnOrchestrator.getAllServers.useQuery,S0=S.turnOrchestrator.setProviderEnabled.useMutation,F_=S.turnProvider.getTurnServers.useQuery,xd=S.userManagement.listUsers.useQuery,C0=S.userManagement.createUser.useMutation,M0=S.userManagement.updateUser.useMutation,E0=S.userManagement.deleteUser.useMutation,yd=S.userManagement.resetPassword.useMutation,I0=S.userManagement.setUserScopes.useMutation,j_=S.userManagement.validateCredentials.useMutation,A0=S.userManagement.listApiKeys.useQuery,V_=S.userManagement.createApiKey.useMutation,P0=S.userManagement.revokeApiKey.useMutation,H_=S.userManagement.validateApiKey.useMutation,_0=S.userManagement.createScopedToken.useMutation,$0=S.userManagement.revokeScopedToken.useMutation,q_=S.userManagement.validateScopedToken.useQuery,D0=S.userManagement.listScopedTokens.useQuery,U_=S.userManagement.setupTotp.useMutation,Q_=S.userManagement.confirmTotp.useMutation,L0=S.userManagement.disableTotp.useMutation,T0=S.userManagement.getTotpStatus.useQuery,G_=S.userManagement.verifyTotp.useMutation,K_=S.webrtcSession.listStreams.useQuery,W_=S.webrtcSession.createSession.useMutation,Y_=S.webrtcSession.handleOffer.useMutation,Z_=S.webrtcSession.handleAnswer.useMutation,X_=S.webrtcSession.closeSession.useMutation,J_=S.webrtcSession.hasAdaptiveBitrate.useQuery,e$=S.zoneAnalytics.getCurrentSnapshot.useQuery,t$=S.zoneAnalytics.getZoneHistory.useQuery,n$=S.zoneAnalytics.getCameraHistory.useQuery,r$=S.zoneAnalytics.getUnzonedHistory.useQuery,o$=S.zoneRules.listRules.useQuery,s$=S.zoneRules.setRules.useMutation,a$=S.zones.listZones.useQuery,i$=S.zones.addZone.useMutation,l$=S.zones.removeZone.useMutation,c$=S.zones.updateZone.useMutation,R0=yn("camstack:widget-registry",null),na=new Map,fs=new Map,hp=new Set;function d$(e){if(!e||typeof e!="object")return!1;const t=e.default;return t!==null&&typeof t=="object"}function u$(e){if(!e||typeof e!="object")return typeof e;const t=e,n=Object.getPrototypeOf(t),r=n&&typeof n=="object"?n.constructor?.name:void 0;return{ownKeys:Object.keys(t),allKeys:Object.getOwnPropertyNames(t),proto:typeof r=="string"?r:void 0}}async function p$(e,t){const n=na.get(e);if(n)return n;const r=fs.get(e);if(r)return r;hp.has(e)||(Ec(),_r.registerRemotes([{name:e,entry:t,type:"module"}],{force:!1}),hp.add(e));const s=_r.loadRemote(`${e}/widgets`).then(a=>{if(!d$(a)){const l=u$(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 na.set(e,i),fs.delete(e),i}).catch(a=>{throw fs.delete(e),a});return fs.set(e,s),s}const f$=3e4,h$=2e3;function O0({children:e}){const t=ke(),n=te(Date.now()),{data:r}=yb(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:l=>{const c=l.state.data;return c&&c.length>0||Date.now()-n.current>=f$?!1:h$}});bt("addon.widget-ready",()=>{t.invalidateQueries({queryKey:[["addonWidgets","listWidgets"]]})});const[s,a]=_(0);Y(()=>{if(!r)return;let l=!1;const c=new Set;for(const d of r){if(c.has(d.remoteName)||(c.add(d.remoteName),na.has(d.remoteName)))continue;const u=d.bundleUrl;p$(d.remoteName,u).then(()=>{l||a(p=>p+1)}).catch(p=>{const h=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:u,reason:h})})}return()=>{l=!0}},[r]);const i=q(()=>{const l=r??[],c=new Map;for(const u of l)c.set(`${u.addonId}/${u.stableId}`,u);const d=(u,p)=>({widgetId:u,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:u=>{const p=c.get(u);if(!p)return;const h=na.get(p.remoteName);if(!h)return null;const m=h[p.stableId];if(m)return m},metadata:u=>{const p=c.get(u);if(p)return d(u,p)},listAll:()=>{const u=[];for(const[p,h]of c)u.push(d(p,h));return u}}},[r,s]);return o(R0.Provider,{value:i,children:e})}function B0(e){return Ha().resolve(e)}function z0(e){return Ha().metadata(e)}function F0(){return Ha().listAll()}function Ha(){const e=j0();if(!e)throw new Error("useWidgetRegistry(): no <WidgetRegistryProvider> in tree");return e}function j0(){return m$(R0)}function m$(e){return ve(e)}function ht(e){const{widgetId:t,host:n="device-tab",config:r,deviceId:s,integrationId:a,instanceId:i,size:l,columns:c,rows:d}=e,u=B0(t),p=z0(t),h=q(()=>i??t,[i,t]);if(u===void 0&&p===void 0)return o(hs,{widgetId:t,reason:"unknown"});if(u===void 0)return o(hs,{widgetId:t,reason:"missing-export"});if(u===null)return o(g$,{});if(p){if(p.requires.deviceContext&&s===void 0)return o(hs,{widgetId:t,reason:"missing-device-context"});if(p.requires.integrationContext&&a===void 0)return o(hs,{widgetId:t,reason:"missing-integration-context"})}return o(u,{instanceId:h,host:n,config:r,deviceId:s,integrationId:a,size:l,columns:c,rows:d})}function g$(){return f("div",{className:"rounded-lg border border-border bg-surface/40 p-4 animate-pulse",children:[o("div",{className:"h-3 w-24 bg-foreground-subtle/20 rounded mb-2"}),o("div",{className:"h-2 w-full bg-foreground-subtle/10 rounded mb-1"}),o("div",{className:"h-2 w-3/4 bg-foreground-subtle/10 rounded"})]})}function hs({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 o("div",{className:"rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",children:n})}const mr="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",qa="block text-[11px] font-medium text-foreground mb-1",b$="text-[10px] text-foreground-subtle mt-0.5";function Ke({label:e,description:t,required:n,span:r,children:s,translationFn:a}){const i=r===2?"col-span-2":r===3?"col-span-3":r===4?"col-span-4":"col-span-1",l=Vt(e,a),c=Vt(t,a);return f("div",{className:i,children:[l!==void 0&&l!==""&&f("label",{className:qa,children:[l,n&&o("span",{className:"text-danger ml-0.5",children:"*"})]}),s,c&&o("p",{className:b$,children:c})]})}function x$({field:e,value:t,onChange:n,disabled:r,translationFn:s}){return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:o("input",{type:e.inputType??"text",className:mr,value:t==null?"":String(t),placeholder:e.placeholder,maxLength:e.maxLength,pattern:e.pattern,disabled:r||e.disabled,onChange:a=>n(a.target.value)})})}function y$({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const[a,i]=_(t==null?"":String(t)),l=te(!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 u=Number(d);Number.isNaN(u)||n(u)};return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("div",{className:"flex items-center gap-1",children:[o("input",{type:"number",className:mr,value:a,placeholder:e.placeholder,min:e.min,max:e.max,step:e.step,disabled:r||e.disabled,onFocus:()=>{l.current=!0},onBlur:()=>{l.current=!1},onChange:d=>c(d.target.value)}),e.unit&&o("span",{className:"text-xs text-foreground-subtle whitespace-nowrap",children:e.unit})]})})}function v$({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const a=!!t,i=r||e.disabled;return e.style==="checkbox"?o(Ke,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[o("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)}),o("span",{className:"text-xs font-medium text-foreground",children:Vt(e.label,s)}),e.required&&o("span",{className:"text-danger",children:"*"})]})}):o(Ke,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("div",{className:"flex items-center justify-between",children:[f("span",{className:qa+" mb-0",children:[Vt(e.label,s),e.required&&o("span",{className:"text-danger ml-0.5",children:"*"})]}),o("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:o("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 w$({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const a=e.options.some(i=>i.value==="");return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("select",{className:mr,value:t==null?"":String(t),disabled:r||e.disabled,onChange:i=>n(i.target.value),children:[!e.required&&!a&&o("option",{value:"",children:"— Select —"}),e.options.map(i=>o("option",{value:i.value,children:i.label},i.value))]})})}function N$({field:e,value:t,onChange:n,disabled:r,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 o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:o("div",{className:"flex flex-wrap gap-2",children:e.options.map(l=>{const c=a.includes(l.value);return f("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",r||e.disabled?"opacity-50 cursor-not-allowed":""].join(" "),children:[o("input",{type:"checkbox",className:"sr-only",checked:c,disabled:r||e.disabled,onChange:()=>i(l.value)}),l.label]},l.value)})})})}function k$({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const[a,i]=_(!1),l=e.showToggle!==!1;return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("div",{className:"relative",children:[o("input",{type:a?"text":"password",className:mr+(l?" pr-9":""),value:t==null?"":String(t),placeholder:e.placeholder,disabled:r||e.disabled,onChange:c=>n(c.target.value)}),l&&o("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?o(_c,{className:"h-3.5 w-3.5"}):o(Ur,{className:"h-3.5 w-3.5"})})]})})}function S$({field:e,value:t,onChange:n,disabled:r,translationFn:s}){return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:o("textarea",{className:mr+" resize-y min-h-[60px]",value:t==null?"":String(t),placeholder:e.placeholder,rows:e.rows??3,maxLength:e.maxLength,disabled:r||e.disabled,onChange:a=>n(a.target.value)})})}function C$({field:e,value:t,onChange:n,disabled:r,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",u=r||e.disabled,p=e.displayScale??1,h=e.min/p,m=e.max/p,g=l/p,b=(e.step??1)/p;if(i&&a)return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("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:u,onClick:()=>n(e.default??e.min),children:[d," — click to set manually"]})});const x=e.showStepper===!0&&c,y=v=>{const N=l+v*(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 o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[f("div",{className:"flex min-w-0 flex-1 basis-[160px] items-center gap-2",children:[o("span",{className:"text-[10px] text-foreground-subtle tabular-nums shrink-0",children:h}),o("input",{type:"range",className:"min-w-0 flex-1 h-1 accent-primary cursor-pointer disabled:opacity-50",min:h,max:m,step:b,value:g,disabled:u,onChange:v=>n(Number(v.target.value)*p)}),o("span",{className:"text-[10px] text-foreground-subtle tabular-nums shrink-0",children:m})]}),(c||i||e.unit)&&f("div",{className:"flex shrink-0 items-center gap-2",children:[x&&o("button",{type:"button",className:w,disabled:u||l<=e.min,onClick:()=>y(-1),title:`Decrease by ${e.step??1}`,"aria-label":"Decrement",children:o(Qm,{className:"h-3 w-3"})}),c&&o("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:h,max:m,step:b,value:g,disabled:u,onChange:v=>{if(v.target.value===""){n(i?null:e.min);return}const N=Number(v.target.value)*p,k=e.step??1,C=N-e.min,M=e.min+Math.round(C/k)*k;n(Math.min(e.max,Math.max(e.min,M)))}}),x&&o("button",{type:"button",className:w,disabled:u||l>=e.max,onClick:()=>y(1),title:`Increase by ${e.step??1}`,"aria-label":"Increment",children:o(Go,{className:"h-3 w-3"})}),e.unit&&o("span",{className:"text-[10px] text-foreground-subtle",children:e.unit}),i&&o("button",{className:"text-[10px] text-foreground-subtle hover:text-primary transition-colors",title:`Reset to ${d}`,disabled:u,onClick:()=>n(null),children:d})]})]})})}function M$({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const a=Array.isArray(t)?t:[],[i,l]=_(""),c=te(null),d=U(m=>{const g=m.trim();!g||a.includes(g)||e.maxTags!==void 0&&a.length>=e.maxTags||(n([...a,g]),l(""))},[a,e.maxTags,n]),u=m=>n(a.filter(g=>g!==m)),p=m=>{m.key==="Enter"||m.key===","?(m.preventDefault(),d(i)):m.key==="Backspace"&&i===""&&a.length>0&&u(a[a.length-1])},h=r||e.disabled;return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("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",h?"opacity-50 cursor-not-allowed":""].join(" "),onClick:()=>!h&&c.current?.focus(),children:[a.map(m=>f("span",{className:"inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[m,!h&&o("button",{type:"button",onClick:()=>u(m),className:"hover:text-danger",children:o(Je,{className:"h-2.5 w-2.5"})})]},m)),o("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:h,list:`tags-suggestions-${e.key}`,onChange:m=>l(m.target.value),onKeyDown:p,onBlur:()=>{i.trim()&&d(i)}}),e.suggestions&&o("datalist",{id:`tags-suggestions-${e.key}`,children:e.suggestions.map(m=>o("option",{value:m},m))})]})})}function V0({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const{nodes:a}=Kr(),i=typeof t=="string"?t:"",l=e.showOffline?a:a.filter(c=>c.isOnline);return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("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:r,children:[o("option",{value:"",children:"Select node…"}),l.map(c=>f("option",{value:c.id,disabled:!c.isOnline,children:[c.shortName,c.isOnline?"":" (offline)"]},c.id))]})})}function H0({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const{nodes:a}=Kr(),i=new Set(Array.isArray(t)?t.map(String):[]),l=e.showOffline?a:a.filter(d=>d.isOnline),c=d=>{const u=new Set(i);u.has(d)?u.delete(d):u.add(d),n([...u])};return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:o("div",{className:"flex flex-wrap gap-1.5",children:l.map(d=>{const u=i.has(d.id);return o("button",{type:"button",onClick:()=>c(d.id),disabled:r||!d.isOnline,className:`px-2.5 py-1 text-xs font-medium rounded-md border transition-colors ${u?"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 E$({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const a=t==null?"#000000":String(t);return f(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:[f("div",{className:"flex items-center gap-2",children:[o("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:r||e.disabled,onChange:i=>n(i.target.value)}),o("input",{type:"text",className:mr+" flex-1 font-mono",value:a,placeholder:"#000000",disabled:r||e.disabled,onChange:i=>n(i.target.value)})]}),e.presets&&e.presets.length>0&&o("div",{className:"flex gap-1.5 mt-1.5",children:e.presets.map(i=>o("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:r||e.disabled,title:i,onClick:()=>n(i)},i))})]})}function I$({field:e,value:t,onChange:n,disabled:r,translationFn:s,onTestField:a,onAction:i,externalProbe:l}){const[c,d]=_("idle"),[u,p]=_(null),h=l?.status??c,m=l?.result??u,g=!!a||!!i,b=U(async()=>{if(g){d("probing"),p(null);try{const w=a?await a(e.key,t):await i("test-probe",e.key,t),v=w&&typeof w=="object"?w:{status:"error",error:"Probe handler returned no result"};p(v),d(v.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=h==="probing"?"border-primary/40 bg-primary/10 text-primary":h==="ok"?"border-success/40 bg-success/10 text-success hover:bg-success/15":h==="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",y=h==="probing"?o(Mt,{className:"h-3 w-3 animate-spin"}):h==="ok"?o(I5,{className:"h-3 w-3"}):h==="error"?o(Qo,{className:"h-3 w-3"}):o(Xm,{className:"h-3 w-3"});return f(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:[f("div",{className:"@container flex items-center gap-2",style:{containerType:"inline-size"},children:[f("button",{type:"button",onClick:b,title:"Test",disabled:e.disabled||h==="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:[y,o("span",{className:"hidden @[280px]:inline",children:"Test"})]}),o("input",{type:e.inputType??"url",className:mr+" flex-1 min-w-0",value:t==null?"":String(t),placeholder:e.placeholder,disabled:r||e.disabled,onChange:w=>{n(w.target.value),c!=="idle"&&(d("idle"),p(null))}})]}),h==="ok"&&m?.labels&&m.labels.length>0&&o("div",{className:"flex flex-wrap gap-1 mt-1.5",children:m.labels.map((w,v)=>o("span",{className:"text-xs bg-success/10 text-success rounded px-2 py-0.5 font-mono",children:w},v))}),h==="error"&&m?.error&&o("p",{className:"text-xs text-danger mt-1 truncate",title:m.error,children:m.error})]})}function A$({field:e,values:t,onChange:n,disabled:r,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 o("div",{className:d,children:f("div",{className:"rounded-lg border border-border bg-surface/50 overflow-hidden",children:[f("div",{className:["px-3 py-2 flex items-center justify-between",c?"cursor-pointer hover:bg-surface":""].join(" "),onClick:c?()=>l(u=>!u):void 0,children:[o("span",{className:"text-xs font-semibold text-foreground",children:Vt(e.label,s)}),c&&o("span",{className:"text-foreground-subtle text-xs",children:i?"▸":"▾"})]}),!i&&o("div",{className:"px-3 pb-3 grid grid-cols-2 gap-x-4 gap-y-3",children:e.fields.map(u=>o(gr,{field:u,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a},u.key))})]})})}function P$({field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,onAction:i}){const l=e.tabs[0]?.id??"",[c,d]=_(l),u=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:f("div",{className:u,children:[e.label&&o("div",{className:qa,children:Vt(e.label,s)}),f("div",{className:"rounded-lg border border-border-subtle bg-surface-hover/40 overflow-hidden",children:[o("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 h=p.id===c;return f("button",{type:"button",role:"tab","aria-selected":h,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 ${h?"bg-primary text-primary-foreground font-medium shadow-sm":"bg-transparent text-foreground-subtle hover:bg-surface hover:text-foreground"}`,children:[o("span",{children:Vt(p.label,s)}),p.badge&&o("span",{className:`text-[9px] px-1 py-0.5 rounded-full font-medium ${h?"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:o("div",{role:"tabpanel",className:"px-3 pb-3 pt-2 grid grid-cols-2 gap-x-4 gap-y-3",children:p.fields.map((h,m)=>{const g="key"in h&&typeof h.key=="string"?h.key:`__${p.id}__${m}`;return o(gr,{field:h,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,onAction:i},g)})},p.id))]})]})}function _$({span:e}){return o("div",{className:e===2?"col-span-2":e===3?"col-span-3":e===4?"col-span-4":"col-span-full",children:o("hr",{className:"border-border"})})}const mp={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 $$(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"),r=n.body.firstElementChild;if(!r)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(r),r.innerHTML}function D$({field:e}){const t=e.variant??"info",n=mp[t]??mp.info,r=e.format==="html";return o("div",{className:"col-span-full",children:f("div",{className:`rounded-md border-l-4 px-3 py-2.5 ${n.border} ${n.bg}`,children:[e.label&&o("p",{className:`text-xs font-semibold mb-0.5 ${n.text}`,children:e.label}),r?o("div",{className:"text-xs text-foreground-subtle leading-relaxed info-html-content",dangerouslySetInnerHTML:{__html:$$(e.content)}}):o("p",{className:"text-xs text-foreground-subtle leading-relaxed whitespace-pre-line",children:e.content})]})})}const gp={ok:"bg-success",warn:"bg-amber-500",danger:"bg-danger",idle:"bg-foreground-subtle/40",unknown:"bg-foreground-subtle/40"};function L$(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),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function T$(e){return!Number.isFinite(e)||e<=0?"—":new Date(e).toLocaleTimeString()}function R$({kind:e,value:t}){if(t==null||t==="")return o("span",{className:"text-foreground-subtle/60",children:"—"});if(e==="monospace")return o("span",{className:"font-mono text-[11px]",children:String(t)});if(e==="status"){const n=String(t).toLowerCase(),r=gp[n]??gp.unknown;return f("span",{className:"inline-flex items-center gap-1.5",children:[o("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${r}`}),o("span",{children:String(t)})]})}return e==="duration"&&typeof t=="number"?o("span",{className:"font-mono text-[11px]",children:L$(t)}):e==="timestamp"&&typeof t=="number"?o("span",{className:"font-mono text-[11px]",children:T$(t)}):o("span",{children:String(t)})}function O$({field:e}){const t=e.value??[],n=e.description;return f("div",{className:"col-span-full",children:[e.label&&o("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1",children:e.label}),n&&o("p",{className:"text-xs text-foreground-subtle mb-2",children:n}),t.length===0?o("div",{className:"rounded-md border border-border bg-surface-subtle px-3 py-2 text-xs text-foreground-subtle",children:e.emptyMessage??"No entries"}):o("div",{className:"rounded-md border border-border overflow-hidden",children:f("table",{className:"w-full text-xs",children:[o("thead",{className:"bg-surface-subtle border-b border-border",children:o("tr",{children:e.columns.map(r=>o("th",{className:"px-3 py-1.5 text-left font-medium text-foreground-subtle",style:r.width?{width:r.width}:void 0,children:r.label},r.key))})}),o("tbody",{className:"divide-y divide-border",children:t.map((r,s)=>o("tr",{className:"hover:bg-surface-hover/40",children:e.columns.map(a=>o("td",{className:"px-3 py-1.5 align-top text-foreground",children:o(R$,{kind:a.kind,value:r[a.key]})},a.key))},s))})]})})]})}function B$({field:e,value:t,onChange:n,disabled:r,translationFn:s,onTestField:a,onAction:i}){const l=Array.isArray(t)?t:[],c=e.minRows??0,d=e.maxRows??Number.POSITIVE_INFINITY,u=(x,y,w)=>{const v=l.slice(),N=v[x]??{};v[x]={...N,[y]:w},n(v)},p=x=>{l.length<=c||n(l.filter((y,w)=>w!==x))},h=()=>{if(l.length>=d)return;const x=e.defaultItem??{};n([...l,{...x}])},m=(x,y)=>e.rowTitleTemplate?e.rowTitleTemplate.replace(/\{(\w+)\}/g,(w,v)=>{const N=x[v];return N==null||N===""?"—":String(N)}):`Row ${y+1}`,g=l.length>c,b=l.length<d;return f("div",{className:"col-span-full space-y-2",children:[f("div",{className:"space-y-0.5",children:[e.label&&o("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle",children:Vt(e.label,s)}),e.description&&o("p",{className:"text-[11px] text-foreground-subtle",children:Vt(e.description,s)})]}),l.length===0?o("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"}):o("div",{className:"space-y-2",children:l.map((x,y)=>f("div",{className:"rounded-md border border-border bg-background",children:[f("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[o("span",{className:"text-xs font-medium text-foreground",children:m(x,y)}),f("button",{type:"button",onClick:()=>p(y),disabled:r||!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:[o(Qm,{className:"h-3 w-3"}),"Remove"]})]}),o("div",{className:"grid grid-cols-1 @[420px]:grid-cols-2 gap-x-3 gap-y-2 p-3",children:e.itemFields.map(w=>o(gr,{field:w,values:x,onChange:(v,N)=>u(y,v,N),disabled:r,translationFn:s,onTestField:a,allFields:e.itemFields,onAction:i},w.key))})]},y))}),f("div",{children:[f("button",{type:"button",onClick:h,disabled:r||!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:[o(Go,{className:"h-3 w-3"}),e.addLabel??"Add"]}),!b&&Number.isFinite(d)&&f("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["(limit: ",d,")"]})]})]})}function z$({field:e,disabled:t,onAction:n}){const[r,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 o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,children:o("button",{onClick:i,disabled:t||r,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:r?"Processing...":e.buttonLabel})})}function q0(e,t){const n={...e.paramsStatic??{}};if(e.paramsFromForm)for(const[r,s]of Object.entries(e.paramsFromForm)){const a=t[s];a!=null&&a!==""&&(n[r]=a)}return n}function F$({field:e,value:t,values:n,onChange:r,disabled:s,onAction:a}){const[i,l]=_(!1),[c,d]=_(null),[u,p]=_(null),h=q0(e,n),m=Object.keys(e.paramsFromForm??{}).some(w=>h[w]===void 0),g=(e.refreshOn??Object.values(e.paramsFromForm??{})).map(w=>`${w}=${JSON.stringify(n[w])}`).join("|");Y(()=>{if(!a||m){p(null),d(null);return}let w=!1;return l(!0),d(null),a(e.action,e.key,h).then(v=>{if(w)return;const N=v;let k=[];if(Array.isArray(N))k=N;else if(N&&typeof N=="object")for(const C of Object.keys(N)){const M=N[C];if(Array.isArray(M)){k=M;break}}p(k)}).catch(v=>{w||(d(v instanceof Error?v.message:String(v)),p([]))}).finally(()=>{w||l(!1)}),()=>{w=!0}},[g,a,e.action,e.key]);const b=e.mapOption.value,x=e.mapOption.label,y=e.mapOption.description;return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,children:m?o("div",{className:"text-[11px] text-foreground-subtle italic",children:e.emptyParamsMessage??"Fill the prerequisite fields above first."}):i?f("div",{className:"flex items-center gap-2 text-[11px] text-foreground-subtle",children:[o(Mt,{className:"h-3 w-3 animate-spin"})," Loading options…"]}):c?o("div",{className:"text-[11px] text-danger",children:c}):u&&u.length===0?o("div",{className:"text-[11px] text-foreground-subtle italic",children:e.emptyResultsMessage??"No options returned."}):(()=>{const w=(u??[]).some(v=>{const N=v[b];return N===""||N===void 0});return f("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:v=>r(v.target.value),children:[!w&&o("option",{value:"",children:"— Select —"}),(u??[]).map((v,N)=>{const k=v[b],C=v[x],M=y?v[y]:void 0,P=typeof k=="string"&&k!==""?k:`row-${N}`;return f("option",{value:typeof k=="string"?k:String(k??""),children:[typeof C=="string"?C:String(C??P),M!==void 0?` (${String(M)})`:""]},P)})]})})()})}function j$({field:e,values:t,disabled:n,onAction:r}){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"})||!r)return;const p=q0(e,t);a(!0),l(null);try{const h=await r(e.action,e.key,p),m=typeof h=="object"&&h!==null?h:null,g=e.successMessage?e.successMessage.replace(/\{(\w+)\}/g,(b,x)=>{const y=m?.[x];return y===void 0?"":String(y)}):"Done.";l({kind:"ok",text:g})}catch(h){l({kind:"error",text:h instanceof Error?h.message:String(h)})}finally{a(!1)}},u={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 o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,children:f("div",{className:"flex flex-col gap-1.5",children:[o("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 ${u[e.variant??"default"]??u.default}`,children:s?"Working…":e.buttonLabel}),i&&o("div",{className:`text-[11px] ${i.kind==="ok"?"text-emerald-700 dark:text-emerald-300":"text-danger"}`,children:i.text})]})})}function V$({field:e}){const t=wn();return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,children:o(ht,{widgetId:e.widgetId,host:"device-tab",config:e.widgetConfig,deviceId:t??void 0,instanceId:e.key})})}function H$(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 q$({field:e,values:t,onAction:n,translationFn:r}){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=H$(i,l),d="label"in e?e.label:void 0,u="description"in e?e.description:void 0,p="span"in e?e.span:void 0,h="actions"in e?e.actions??[]:[];return o(Ke,{label:d,description:u,span:p,translationFn:r,children:f("div",{className:"flex items-stretch gap-1",children:[o("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}),h.length>0&&o("div",{className:"flex items-center gap-1",children:h.map(m=>o(Q$,{action:m,fieldKey:s,value:i,onAction:n},m.action))})]})})}function U$({name:e}){const t="h-3.5 w-3.5";switch(e){case"copy":return o(vn,{className:t});case"refresh-cw":return o(_a,{className:t});case"external-link":return o(Pc,{className:t});case"trash-2":return o(Jt,{className:t});case"download":return o(Pl,{className:t});case"upload":return o(Zm,{className:t});default:return o(Dc,{className:t})}}function Q$({action:e,fieldKey:t,value:n,onAction:r}){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 o("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(r){i(!0);try{await r(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:o(U$,{name:e.icon})})}function G$(e){return"multiple"in e&&e.multiple!=null}function K$({field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c}){const d=e.multiple,u=d.min,p=d.max,h=t[e.key],g=[...Array.isArray(h)?h:h!=null?[h]:[]],b=d.itemDefault!==void 0?d.itemDefault:"default"in e&&e.default!==void 0?e.default:"";for(;g.length<u;)g.push(b);const x=k=>n(e.key,[...k]),y=(k,C)=>{const M=[...g];M[k]=C,x(M)},w=()=>{g.length>=p||x([...g,b])},v=k=>{g.length<=u||x(g.filter((C,M)=>M!==k))},N=()=>{const{multiple:k,...C}=e;return{...C,...{label:void 0,description:void 0,required:!1}}};return o(Ke,{label:e.label,description:e.description,required:u>0?e.required:!1,span:e.span,translationFn:s,children:f("div",{className:"space-y-2",children:[g.map((k,C)=>{const M=d.itemLabel?.replace("${n}",String(C+1));return f("div",{className:"space-y-1",children:[M&&o("div",{className:qa,children:M}),f("div",{className:"flex items-center gap-2",children:[o("div",{className:"flex-1 min-w-0",children:o(gr,{field:N(),values:{...t,[e.key]:k},onChange:(P,I)=>y(C,I),disabled:r,translationFn:s,onTestField:a,onAction:c,allFields:l})}),g.length>u&&o("button",{type:"button",onClick:()=>v(C),disabled:r,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:o(Jt,{className:"h-3.5 w-3.5"})})]})]},C)}),f("div",{className:"flex items-center justify-between pt-1",children:[g.length<p?f("button",{type:"button",onClick:w,disabled:r,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:[o(Go,{className:"h-3 w-3"}),d.addLabel??"Add"]}):o("span",{}),f("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[g.length,"/",p]})]})]})})}function vd(e,t,n){if(!("showWhen"in e)||!e.showWhen)return!0;const r=e.showWhen,s=t[r.field],a=n?.find(c=>"key"in c&&c.key===r.field),i=a&&"default"in a?a.default:void 0,l=s!==void 0?s:i;return r.equals!==void 0?l===r.equals:r.notEquals!==void 0?l!==r.notEquals:r.in!==void 0?r.in.includes(l):r.notIn!==void 0?!r.notIn.includes(l):r.includes!==void 0?Array.isArray(l)&&l.includes(r.includes):r.notIncludes!==void 0?!Array.isArray(l)||!l.includes(r.notIncludes):!0}function gr({field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c}){if(G$(e))return o(K$,{field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c});if("readonlyField"in e&&e.readonlyField===!0)return o(q$,{field:e,values:t,onAction:c,translationFn:s});if(!vd(e,t,l))return null;const d=t[e.key],u=d!==void 0?d:"default"in e?e.default:void 0,p=m=>n(e.key,m),h=tb(e.type);switch(e.type){case"text":return o(x$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"number":return o(y$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"boolean":return o(v$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"select":return o(w$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"multiselect":return o(N$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"password":return o(k$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"textarea":return o(S$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"slider":return o(C$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"tags":return o(M$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"color":return o(E$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"node-select":return o(V0,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"node-multiselect":return o(H0,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"probe":return o(I$,{field:e,value:u,onChange:p,disabled:r,translationFn:s,onTestField:a,onAction:c,externalProbe:i});case"group":return o(A$,{field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a});case"sub-tabs":return o(P$,{field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,onAction:c});case"separator":return o(_$,{});case"info":return o(D$,{field:e});case"object-array":return o(O$,{field:e});case"editable-array":return o(B$,{field:e,value:u,onChange:p,disabled:r,translationFn:s,onTestField:a,onAction:c});case"button":return o(z$,{field:e,disabled:r,onAction:c});case"addon-action-select":return o(F$,{field:e,value:u,values:t,onChange:p,disabled:r,onAction:c});case"addon-action-button":return o(j$,{field:e,values:t,disabled:r,onAction:c});case"widget":return o(V$,{field:e});default:return h?o(h,{field:e,value:u,onChange:p,disabled:r}):null}}function W$(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Vt(e,t){if(e!==void 0)return t&&W$(e)?t(e):e}function Y$({section:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,probeResults:i}){const[l,c]=_(e.defaultCollapsed??!1),d=e.style==="accordion",u=e.columns??2,p=u===1?"grid-cols-1":u===3?"grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3":u===4?"grid-cols-1 @[480px]:grid-cols-2 @[1140px]:grid-cols-4":"grid-cols-1 @[640px]:grid-cols-2";return f("div",{className:"@container rounded-lg border border-border bg-surface p-3",style:{containerType:"inline-size"},children:[f("div",{className:["flex items-center justify-between mb-2",d?"cursor-pointer":""].join(" "),onClick:d?()=>c(h=>!h):void 0,children:[f("div",{children:[o("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:Vt(e.title,s)}),e.description&&o("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:Vt(e.description,s)})]}),d&&o("span",{className:"text-foreground-subtle text-xs ml-2",children:l?"▸":"▾"})]}),!l&&o("div",{className:`grid ${p} gap-x-3 gap-y-2.5`,children:e.fields.map(h=>o(gr,{field:h,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i?.[h.key]},h.key))})]})}function U0({schema:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,probeResults:i,onClearProbe:l}){const c=(d,u)=>{n({...t,[d]:u}),l?.(d)};return o("div",{className:"space-y-4",children:e.sections.map(d=>o(Y$,{section:d,values:t,onChange:c,disabled:r,translationFn:s,onTestField:a,probeResults:i},d.id))})}const Z$=({open:e})=>o("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:o("polyline",{points:"9 18 15 12 9 6"})});function bp(e){const t={};if(!e)return t;for(const n of e.sections)for(const r of n.fields){if(r.type==="separator"||r.type==="info"||r.type==="button"||r.type==="group")continue;const s=r.key;t[s]=r.value}return t}function X$(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:r,...s}=n;return s})}))}}function J$({trpc:e,addonId:t,nodeId:n,title:r,disabled:s,onAfterChange:a,refreshToken:i,collapsible:l,defaultOpen:c,mode:d,onOverrideChange:u}){const p=d??"persist",[h,m]=_(null),[g,b]=_(!0),[x,y]=_(null),[w,v]=_(!1),[N,k]=_(c??!1),[C,M]=_({}),[P,I]=_(null);Y(()=>{I(null),M({})},[e,t,n,i,p]);const z=JSON.stringify(C);Y(()=>{let L=!1;b(!0),y(null);const T=p==="override"&&Object.keys(C).length>0?C:void 0;return e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n,...T?{overlay:T}:{}}).then(B=>{L||(m(B),T||I(bp(B)),b(!1))}).catch(B=>{L||(y(B instanceof Error?B.message:String(B)),b(!1))}),()=>{L=!0}},[e,t,n,i,p,z]);const A=q(()=>bp(h),[h]),O=q(()=>h?X$(h):null,[h]),R=async L=>{if(p==="override"){const B=P??A,F={};for(const V of Object.keys(L))L[V]!==B[V]&&(F[V]=L[V]);const j={...B,...F};M(F),u?.(F,j);return}const T={};for(const B of Object.keys(L))L[B]!==A[B]&&(T[B]=L[B]);if(Object.keys(T).length!==0){v(!0);try{await e.addonSettings.updateGlobalSettings.mutate({addonId:t,nodeId:n,patch:T});const B=await e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n});m(B),a?.()}catch(B){y(B instanceof Error?B.message:String(B))}finally{v(!1)}}};if(g)return f("div",{className:"text-xs text-foreground-subtle animate-pulse",children:["Loading ",r??t,"…"]});if(x)return f("div",{className:"text-xs text-red-400",children:[r??t,": ",x]});if(!h||!O)return f("div",{className:"text-xs text-foreground-subtle",children:[r??t," not available on ",n,"."]});const E=p==="override"?{...A,...C}:A,D=f(he,{children:[p==="override"?o("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,o(U0,{schema:O,values:E,onChange:R,disabled:s===!0||w})]});return l===!0?f("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("button",{type:"button",onClick:()=>k(L=>!L),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover text-left","aria-expanded":N,children:[o(Z$,{open:N}),o("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide flex-1",children:r??t}),o("span",{className:"text-[10px] text-foreground-subtle",children:N?"hide":"edit"})]}),N?o("div",{className:"border-t border-border px-4 py-3",children:D}):null]}):r?f("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o("div",{className:"border-b border-border px-4 py-2",children:o("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:r})}),o("div",{className:"px-4 py-3",children:D})]}):o("div",{children:D})}function Q0({detections:{motion:e,motionRaw:t,detection:n,phase:r},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,u=i&&n&&n.detections.length>0;return!c&&!d&&!u&&!l?null:f("div",{className:"absolute inset-0 pointer-events-none z-10",children:[l&&o(eD,{phase:r}),d&&o(tD,{raw:t}),c&&o(nD,{motion:e}),u&&o(rD,{detections:n.detections,frameWidth:n.frameWidth,frameHeight:n.frameHeight})]})}function eD({phase:e}){const t=ur(e);return f("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:[o("span",{className:`w-2 h-2 rounded-full ${t.dotClass}`}),o("span",{className:"text-[10px] font-semibold text-white uppercase tracking-wider",children:t.label})]})}function tD({raw:e}){return e.frameWidth===0||e.frameHeight===0?null:o(he,{children:e.boxes.map((t,n)=>{const[r,s,a,i]=t.bbox,l=r/e.frameWidth*100,c=s/e.frameHeight*100,d=(a-r)/e.frameWidth*100,u=(i-s)/e.frameHeight*100,p=Math.max(.05,Math.min(.25,t.changeScore*.3));return o("div",{className:"absolute rounded-sm",style:{left:`${l}%`,top:`${c}%`,width:`${d}%`,height:`${u}%`,backgroundColor:`rgba(239, 68, 68, ${p})`}},`mr-${n}`)})})}function nD({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 o(he,{children:t.map((n,r)=>{const s=Math.max(.15,Math.min(.5,n.intensity/255));return o("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-${r}`)})})}function rD({detections:e,frameWidth:t,frameHeight:n}){return t===0||n===0?null:o(he,{children:e.map(r=>{const{x:s,y:a,width:i,height:l}=r.bbox,c=s/t*100,d=a/n*100,u=i/t*100,p=l/n*100,h=gt(r.macroClass),m=[`${r.macroClass} ${(r.score*100).toFixed(0)}%`];for(const g of r.labels)m.push(g.label);return o("div",{className:"absolute border-2 rounded-sm",style:{left:`${c}%`,top:`${d}%`,width:`${u}%`,height:`${p}%`,borderColor:h},children:o("div",{className:"absolute -top-4 left-0 px-1 py-0.5 text-[9px] font-bold text-white rounded-sm whitespace-nowrap",style:{backgroundColor:h},children:m.join(" | ")})},`det-${r.id}`)})})}function oD(e){const t={};if(typeof window<"u"){if(e){const r=e.getBoundingClientRect();r.width>0&&r.height>0&&(t.viewportWidth=Math.round(r.width),t.viewportHeight=Math.round(r.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 sD=3e3,aD=5;function G0({serverUrl:e,streamKey:t,label:n,autoPlay:r=!0,muted:s=!0,showControls:a=!0,className:i="",onStateChange:l,onError:c,overlay:d,createSession:u,sendAnswer:p,closeSession:h,hintsOverride:m}){const g=te(null),b=te(null),x=te(null),y=te(new Set),w=te(null),v=te(null),N=te(0),k=te(!0),[C,M]=_("idle"),[P,I]=_(""),[z,A]=_(s),[O,R]=_(!1),[E,D]=_(!1),L=te(null),T=te(!1);(p||u)&&(T.current=!0);const B=T.current,F=U(W=>{M(W),l?.(W)},[l]),j=U(()=>{if(w.current?.abort(),w.current=null,v.current&&(clearTimeout(v.current),v.current=null),x.current&&(x.current.close(),x.current=null),h&&y.current.size>0){for(const W of y.current)h(W).catch(()=>{});y.current.clear()}g.current&&(g.current.srcObject=null)},[h]),V=U(async()=>{if(!k.current||!u||!p)return;j(),F("connecting");const W=new AbortController;w.current=W;try{const ae={...oD(b.current),...m},{sessionId:fe,sdpOffer:ge}=await u(ae);if(y.current.add(fe),!k.current||W.signal.aborted){h?.(fe).catch(()=>{}),y.current.delete(fe);return}const Q=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});x.current=Q;const le=new MediaStream;Q.ontrack=pe=>{console.debug("[WebRTC] ontrack",pe.track.kind,pe.track.readyState),le.addTrack(pe.track),g.current&&(g.current.srcObject=le,g.current.play().catch(()=>{}))},Q.oniceconnectionstatechange=()=>{if(!k.current)return;const pe=Q.iceConnectionState;console.debug("[WebRTC] ICE state:",pe),pe==="connected"||pe==="completed"?(N.current=0,F("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")&&(F("disconnected"),Z())},Q.onicecandidateerror=pe=>{console.debug("[WebRTC] ICE candidate error:",pe)},console.debug("[WebRTC] Setting remote description (server offer)..."),await Q.setRemoteDescription({type:"offer",sdp:ge});const ue=await Q.createAnswer();if(await Q.setLocalDescription(ue),console.debug("[WebRTC] Local description set, waiting for ICE gathering..."),await xp(Q),!k.current)return;const de=(Q.localDescription?.sdp??"").split(`
|
|
551
|
+
`).filter(pe=>pe.startsWith("a=candidate:")).length;console.debug("[WebRTC] Sending answer to server",{localCandidates:de,sessionId:fe.slice(0,8)}),await p(fe,Q.localDescription?.sdp??""),console.debug("[WebRTC] Answer sent successfully");const ce=Q,Ce=()=>{const pe=ce.connectionState;if(pe==="closed"||pe==="failed")return;const $e=g.current;$e&&$e.readyState===0&&console.log(`[WebRTC] no video data yet (ice=${ce.iceConnectionState})`)};setTimeout(Ce,3e3),setTimeout(Ce,8e3)}catch(ee){if(!k.current)return;const ae=ee instanceof Error?ee.message:String(ee);I(ae),F("error"),c?.(ae),Z()}},[e,t,u,p,j,F,c,m]),$=U(async()=>{if(k.current){j(),F("connecting");try{const W=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});x.current=W,W.addTransceiver("video",{direction:"recvonly"}),W.addTransceiver("audio",{direction:"recvonly"});const ee=new MediaStream;W.ontrack=le=>{ee.addTrack(le.track),g.current&&(g.current.srcObject=ee,g.current.play().catch(()=>{}))},W.oniceconnectionstatechange=()=>{if(!k.current)return;const le=W.iceConnectionState;le==="connected"||le==="completed"?(N.current=0,F("playing"),g.current?.paused&&g.current.play().catch(()=>{})):(le==="failed"||le==="disconnected"||le==="closed")&&(F("disconnected"),Z())};const ae=await W.createOffer();if(await W.setLocalDescription(ae),await xp(W),!k.current)return;const fe=`${e}/api/webrtc?src=${encodeURIComponent(t)}`,ge=await fetch(fe,{method:"POST",headers:{"Content-Type":"application/sdp"},body:W.localDescription?.sdp??""});if(!ge.ok)throw new Error(`WHEP ${ge.status}: ${ge.statusText}`);const Q=await ge.text();await W.setRemoteDescription({type:"answer",sdp:Q})}catch(W){if(!k.current)return;const ee=W instanceof Error?W.message:String(W);I(ee),F("error"),c?.(ee),Z()}}},[e,t,j,F,c]),H=B?V:$,G=te(()=>{});G.current=H;const Z=U(()=>{k.current&&(N.current>=aD||(N.current+=1,v.current=setTimeout(()=>{k.current&&G.current()},sD)))},[]);Y(()=>(k.current=!0,N.current=0,r&&H(),()=>{k.current=!1,j()}),[e,t]);const oe=te(!1);Y(()=>{!r||!B||!u||!p||oe.current||x.current||(oe.current=!0,H())},[r,B,u,p,H]);const ne=()=>{N.current=0,H()},X=()=>{g.current&&(g.current.muted=!g.current.muted,A(g.current.muted))},re=async()=>{if(b.current)try{document.fullscreenElement?await document.exitFullscreen():await b.current.requestFullscreen()}catch(W){console.warn(`Fullscreen toggle failed: ${W instanceof Error?W.message:W}`)}},be=()=>{if(!g.current)return;const W=document.createElement("canvas");W.width=g.current.videoWidth||1280,W.height=g.current.videoHeight||720;const ee=W.getContext("2d");if(!ee)return;ee.drawImage(g.current,0,0);const ae=document.createElement("a");ae.download=`${t.replace(/[/:]/g,"-")}-${Date.now()}.jpg`,ae.href=W.toDataURL("image/jpeg",.92),ae.click()};Y(()=>{const W=()=>R(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",W),()=>document.removeEventListener("fullscreenchange",W)},[]);const J=()=>{D(!0),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>D(!1),3e3)};return f("div",{ref:b,className:`relative bg-black overflow-hidden group ${i}`,onMouseMove:J,onMouseEnter:J,children:[o("video",{ref:g,autoPlay:r,muted:z,playsInline:!0,className:"w-full h-full object-contain"}),n&&C==="playing"&&o("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,C==="connecting"&&f("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/70 gap-2",children:[o("svg",{className:"h-6 w-6 text-white/60 animate-spin",viewBox:"0 0 24 24",fill:"none",children:o("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]"})}),o("span",{className:"text-xs text-white/60",children:"Connecting…"})]}),(C==="error"||C==="disconnected")&&f("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/70 gap-2",children:[o("svg",{className:"h-6 w-6 text-red-400",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:o("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"})}),o("span",{className:"text-xs text-red-400 text-center px-4",children:C==="error"?P||"Connection failed":"Disconnected"}),o("button",{onClick:ne,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&&C==="playing"&&f("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 ${E?"opacity-100":"opacity-0"}`,children:[o("div",{className:"flex items-center gap-1",children:o(_i,{onClick:X,title:z?"Unmute":"Mute",children:z?f("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),o("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),o("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]}):f("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),o("path",{d:"M19.07 4.93a10 10 0 010 14.14M15.54 8.46a5 5 0 010 7.07"})]})})}),f("div",{className:"flex items-center gap-1",children:[o(_i,{onClick:be,title:"Take snapshot",children:f("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o("path",{d:"M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z"}),o("circle",{cx:"12",cy:"13",r:"4"})]})}),o(_i,{onClick:re,title:O?"Exit fullscreen":"Fullscreen",children:O?o("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:o("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"})}):o("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:o("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 _i({onClick:e,title:t,children:n}){return o("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 xp(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 wd=yn("camstack:player-overlays-state",null),Nd=yn("camstack:player-overlays-actions",null);function K0({children:e}){const[t,n]=_(()=>new Map),[r,s]=_(()=>new Map),a=U(p=>{n(h=>{const m=new Map(h);return m.set(p.id,p),m})},[]),i=U(p=>{n(h=>{if(!h.has(p))return h;const m=new Map(h);return m.delete(p),m})},[]),l=U(p=>{s(h=>{const m=new Map(h);return m.set(p.id,p),m})},[]),c=U(p=>{s(h=>{if(!h.has(p))return h;const m=new Map(h);return m.delete(p),m})},[]),d=q(()=>({layers:t,buttons:r}),[t,r]),u=q(()=>({setLayer:a,removeLayer:i,setButton:l,removeButton:c}),[a,i,l,c]);return o(wd.Provider,{value:d,children:o(Nd.Provider,{value:u,children:e})})}function W0(){const e=ve(wd);return q(()=>e?[...e.layers.values()].sort((t,n)=>t.order-n.order):[],[e])}function Y0(){const e=ve(wd);return q(()=>e?[...e.buttons.values()].sort((t,n)=>t.order-n.order):[],[e])}function iD(e){const t=ve(Nd);Y(()=>{if(!(!t||!e))return t.setLayer(e),()=>t.removeLayer(e.id)},[t,e])}function lD(e){const t=ve(Nd);Y(()=>{if(!(!t||!e))return t.setButton(e),()=>t.removeButton(e.id)},[t,e])}function cD(e){return e==="streaming"?"bg-emerald-500":e==="connecting"?"bg-amber-500":e==="error"?"bg-rose-500":"bg-zinc-500"}function dD(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 zl({className:e}){return o("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o("polygon",{points:"5 3 19 12 5 21 5 3"})})}function uD({className:e}){return o("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})})}function pD({className:e}){return f("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"}),o("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),o("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),o("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})}function fD({className:e}){return f("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:[o("circle",{cx:"5",cy:"12",r:"2"}),o("circle",{cx:"12",cy:"12",r:"2"}),o("circle",{cx:"19",cy:"12",r:"2"})]})}function $i({label:e,active:t,onClick:n}){return f("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:[o("span",{children:e}),o("span",{className:`inline-block h-3 w-5 rounded-full transition-colors ${t?"bg-primary":"bg-foreground-subtle/30"} relative`,children:o("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-white transition-all ${t?"left-2.5":"left-0.5"}`})})]})}function Z0({className:e}){return f("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o("polyline",{points:"23 4 23 10 17 10"}),o("polyline",{points:"1 20 1 14 7 14"}),o("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]})}function hD({className:e}){return f("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),o("path",{d:"M10.41 10.41a2 2 0 11-2.83-2.83"}),o("line",{x1:"13.5",y1:"13.5",x2:"6",y2:"21"}),o("path",{d:"M18 12l-1.5-1.5"}),o("path",{d:"M21 15V5a2 2 0 00-2-2H5"}),o("path",{d:"M21 21H5a2 2 0 01-2-2V11"})]})}function kd({serverUrl:e,createSession:t,sendAnswer:n,closeSession:r,streams:s,activeStreamId:a,onStreamChange:i,deviceName:l,phase:c,pipelineMetrics:d,detections:u,defaultShowDetections:p=!0,defaultShowMotion:h=!1,streamStats:m,autoPlay:g=!1,showPlayStop:b=!1,snapshotSrc:x,snapshotLoading:y=!1,onRefreshSnapshot:w,showStreamStats:v=!1,children:N,extraOverlay:k,ptzAvailable:C=!1,ptzShown:M=!1,ptzOverlay:P,onPtzToggle:I,intercomAvailable:z=!1,intercomShown:A=!1,onIntercomToggle:O,chromeless:R=!1,className:E}){const D=Y0(),[L,T]=_(g),[B,F]=_(p),[j,V]=_(h),[$,H]=_(null),[G,Z]=_(!1),oe=te(null);Y(()=>{if(!G)return;function ce(Ce){oe.current&&!oe.current.contains(Ce.target)&&Z(!1)}return document.addEventListener("mousedown",ce),()=>document.removeEventListener("mousedown",ce)},[G]);const ne=a??$??s?.[0]?.id??"",X=s?.find(ce=>ce.id===ne)??s?.[0],re=X?.inputFps!=null?{status:X.status??"unknown",inputFps:X.inputFps,bitrateKbps:X.bitrateKbps??0}:null,be=ce=>{H(ce),i?.(ce),L&&b&&(T(!1),setTimeout(()=>T(!0),50))},J=q(()=>{const ce=X?.target;if(ce)return Ce=>t(ce,Ce)},[t,X]),W=s,ee=()=>T(!0),ae=()=>T(!1),fe=d?.phase??c,ge=fe==="active",Q=!!u,le=Q&&(B||j),ue=C&&M&&!!P,de=b?L:!0;return f("div",{className:`overflow-hidden ${R?"":"rounded-xl border border-border bg-surface"} ${E??""}`,children:[f("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[f("div",{className:"flex items-center gap-2",children:[(m??re)&&o("span",{className:`w-2 h-2 rounded-full ${cD((m??re).status)}`}),l&&o("span",{className:"text-xs font-medium text-foreground",children:l}),W&&W.length>1&&f("div",{className:"relative",children:[o("select",{"data-testid":"stream-profile-select",value:ne,onChange:ce=>be(ce.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:W.map(ce=>o("option",{value:ce.id,children:ce.label},ce.id))}),o("span",{className:"pointer-events-none absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle",children:o("svg",{className:"h-2.5 w-2.5",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o("polyline",{points:"3 4.5 6 7.5 9 4.5"})})})]})]}),f("div",{className:"flex items-center gap-1.5",children:[z&&f("button",{"data-testid":"stream-intercom-toggle","data-intercom-shown":A?"true":"false",onClick:O,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${A?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:A?"Close intercom":"Open intercom",children:[o(pD,{className:"h-3 w-3"}),o("span",{className:"hidden xl:inline",children:"Intercom"})]}),D.map(ce=>{const pe=ce.tone==="primary"?"bg-primary text-primary-foreground":"bg-primary/15 text-primary";return f("button",{type:"button","data-toolbar-button-id":ce.id,"data-toolbar-button-active":ce.active?"true":"false",onClick:ce.onClick,disabled:ce.disabled,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors disabled:opacity-50 ${ce.active?pe:"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:ce.title??ce.label,children:[ce.icon,o("span",{className:"hidden xl:inline",children:ce.label})]},ce.id)}),b&&f("button",{"data-testid":"stream-play-toggle","data-stream-playing":de?"true":"false",onClick:de?ae:ee,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?o(uD,{className:"h-3 w-3"}):o(zl,{className:"h-3 w-3"}),o("span",{className:"hidden xl:inline",children:de?"Stop":"Play"})]}),w&&f("button",{"data-testid":"stream-snapshot-refresh",onClick:w,disabled:y,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:[o(Z0,{className:`h-3 w-3 ${y?"animate-spin":""}`}),o("span",{className:"hidden xl:inline",children:"Snapshot"})]}),(Q||C||d||fe||m||re&&re.inputFps>0)&&f("div",{ref:oe,className:"relative",children:[o("button",{onClick:()=>Z(ce=>!ce),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:o(fD,{className:"h-3.5 w-3.5"})}),G&&f("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:[v&&m&&f("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[f("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Input"}),f("span",{className:"tabular-nums text-foreground",children:[m.inputFps.toFixed(1)," fps"]})]}),f("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Decode"}),f("span",{className:"tabular-nums text-foreground",children:[m.decodeFps.toFixed(1)," fps"]})]}),f("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Uptime"}),o("span",{className:"tabular-nums text-foreground",children:dD(m.uptimeMs)})]})]}),!v&&re&&re.inputFps>0&&f("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[f("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Input"}),f("span",{className:"tabular-nums text-foreground",children:[re.inputFps.toFixed(1)," fps"]})]}),re.bitrateKbps>0&&f("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Bitrate"}),f("span",{className:"tabular-nums text-foreground",children:[re.bitrateKbps," kbps"]})]})]}),(d||Q&&fe)&&f("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[f("div",{className:"flex justify-between gap-3 items-center",children:[o("span",{children:"Phase"}),f("span",{className:`flex items-center gap-1 font-semibold uppercase tracking-wider ${ge?"text-red-400":"text-emerald-400"}`,children:[o("span",{className:`w-1.5 h-1.5 rounded-full ${ge?"bg-red-500 animate-pulse":"bg-emerald-500"}`}),ge?"Active":"Watching"]})]}),d&&d.detectionFps>0&&f("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Detection"}),f("span",{className:"tabular-nums text-foreground",children:[d.detectionFps.toFixed(1)," det/s"]})]}),d&&d.avgInferenceMs>0&&f("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Inference"}),f("span",{className:"tabular-nums text-foreground",children:[d.avgInferenceMs.toFixed(0)," ms"]})]})]}),Q&&f(he,{children:[o($i,{label:"Show detections",active:B,onClick:()=>F(ce=>!ce)}),o($i,{label:"Show motion",active:j,onClick:()=>V(ce=>!ce)})]}),C&&o($i,{label:"PTZ controls",active:M,onClick:()=>{I?.(),Z(!1)}})]})]})]})]}),de?o("div",{className:"aspect-video relative",children:o(G0,{serverUrl:e,streamKey:ne,autoPlay:!0,className:"w-full h-full",createSession:J,sendAnswer:n,closeSession:r,overlay:le||k||ue?f(he,{children:[le&&o(Q0,{detections:u,showPhaseIndicator:!1,showMotionZones:j,showMotionRaw:j,showDetections:B}),k,ue&&P]}):void 0},ne)}):o(mD,{src:x??null,isLoading:y,onPlay:ee,onRetry:w,extraOverlay:k||ue?f(he,{children:[k,ue&&P]}):null,suppressPlayHover:!!k||ue}),N]})}function mD({src:e,isLoading:t,onPlay:n,onRetry:r,extraOverlay:s,suppressPlayHover:a=!1}){return e?f("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:[o("img",{src:e,alt:"Camera snapshot",className:"w-full h-full object-contain"}),!a&&o("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:o("div",{className:"h-14 w-14 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center",children:o(zl,{className:"h-7 w-7 text-white ml-0.5"})})}),s]}):t?o("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:o("div",{className:"h-8 w-8 border-2 border-white/20 border-t-white/60 rounded-full animate-spin"})}):o("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:f("div",{className:"flex flex-col items-center gap-2 text-white/40",children:[o(hD,{className:"h-8 w-8"}),o("span",{className:"text-xs",children:"No snapshot available"}),f("div",{className:"flex items-center gap-2 mt-1",children:[r&&f("button",{onClick:r,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:[o(Z0,{className:"h-3 w-3"}),"Retry"]}),f("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:[o(zl,{className:"h-3 w-3"}),"Play Live"]})]})]})})}const yp={value:"auto",label:"Auto (best available)"};function gD(e){return e.charAt(0).toUpperCase()+e.slice(1)}function bD({deviceId:e,value:t,onChange:n,disabled:r,label:s,className:a}){const i=Xn(),l=Db({deviceId:e},{refetchOnWindowFocus:!1}),[c,d]=_([yp]);Y(()=>{if(!l.data)return;const h=`${e}/`,m=[yp];for(const g of l.data){if(!g.enabled)continue;const b=g.brokerId.startsWith(h)?g.brokerId.slice(h.length):g.brokerId;m.push({value:b,label:gD(b)})}d(m)},[l.data,e]);const u=s??"Preferred stream",p=l.isLoading?"Loading available streams…":l.isError?"Could not load streams — only Auto available.":c.length===1?"No enabled streams found — only Auto available.":null;return f("div",{className:a,children:[o("label",{id:i,className:"text-xs font-medium text-foreground-muted block mb-1",children:u}),o(Eo,{"aria-labelledby":i,options:c,value:t,disabled:r,onChange:h=>n(h.target.value)}),p!==null&&o("p",{className:"text-foreground-subtle text-[10px] mt-1",children:p})]})}var xD=Object.defineProperty,ra=Object.getOwnPropertySymbols,X0=Object.prototype.hasOwnProperty,J0=Object.prototype.propertyIsEnumerable,vp=(e,t,n)=>t in e?xD(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fl=(e,t)=>{for(var n in t||(t={}))X0.call(t,n)&&vp(e,n,t[n]);if(ra)for(var n of ra(t))J0.call(t,n)&&vp(e,n,t[n]);return e},jl=(e,t)=>{var n={};for(var r in e)X0.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ra)for(var r of ra(e))t.indexOf(r)<0&&J0.call(e,r)&&(n[r]=e[r]);return n};/**
|
|
552
|
+
* @license QR Code generator library (TypeScript)
|
|
553
|
+
* Copyright (c) Project Nayuki.
|
|
554
|
+
* SPDX-License-Identifier: MIT
|
|
555
|
+
*/var er;(e=>{const t=class Pe{constructor(c,d,u,p){if(this.version=c,this.errorCorrectionLevel=d,this.modules=[],this.isFunction=[],c<Pe.MIN_VERSION||c>Pe.MAX_VERSION)throw new RangeError("Version value out of range");if(p<-1||p>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let h=[];for(let g=0;g<this.size;g++)h.push(!1);for(let g=0;g<this.size;g++)this.modules.push(h.slice()),this.isFunction.push(h.slice());this.drawFunctionPatterns();const m=this.addEccAndInterleave(u);if(this.drawCodewords(m),p==-1){let g=1e9;for(let b=0;b<8;b++){this.applyMask(b),this.drawFormatBits(b);const x=this.getPenaltyScore();x<g&&(p=b,g=x),this.applyMask(b)}}s(0<=p&&p<=7),this.mask=p,this.applyMask(p),this.drawFormatBits(p),this.isFunction=[]}static encodeText(c,d){const u=e.QrSegment.makeSegments(c);return Pe.encodeSegments(u,d)}static encodeBinary(c,d){const u=e.QrSegment.makeBytes(c);return Pe.encodeSegments([u],d)}static encodeSegments(c,d,u=1,p=40,h=-1,m=!0){if(!(Pe.MIN_VERSION<=u&&u<=p&&p<=Pe.MAX_VERSION)||h<-1||h>7)throw new RangeError("Invalid value");let g,b;for(g=u;;g++){const v=Pe.getNumDataCodewords(g,d)*8,N=i.getTotalBits(c,g);if(N<=v){b=N;break}if(g>=p)throw new RangeError("Data too long")}for(const v of[Pe.Ecc.MEDIUM,Pe.Ecc.QUARTILE,Pe.Ecc.HIGH])m&&b<=Pe.getNumDataCodewords(g,v)*8&&(d=v);let x=[];for(const v of c){n(v.mode.modeBits,4,x),n(v.numChars,v.mode.numCharCountBits(g),x);for(const N of v.getData())x.push(N)}s(x.length==b);const y=Pe.getNumDataCodewords(g,d)*8;s(x.length<=y),n(0,Math.min(4,y-x.length),x),n(0,(8-x.length%8)%8,x),s(x.length%8==0);for(let v=236;x.length<y;v^=253)n(v,8,x);let w=[];for(;w.length*8<x.length;)w.push(0);return x.forEach((v,N)=>w[N>>>3]|=v<<7-(N&7)),new Pe(g,d,w,h)}getModule(c,d){return 0<=c&&c<this.size&&0<=d&&d<this.size&&this.modules[d][c]}getModules(){return this.modules}drawFunctionPatterns(){for(let u=0;u<this.size;u++)this.setFunctionModule(6,u,u%2==0),this.setFunctionModule(u,6,u%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const c=this.getAlignmentPatternPositions(),d=c.length;for(let u=0;u<d;u++)for(let p=0;p<d;p++)u==0&&p==0||u==0&&p==d-1||u==d-1&&p==0||this.drawAlignmentPattern(c[u],c[p]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const d=this.errorCorrectionLevel.formatBits<<3|c;let u=d;for(let h=0;h<10;h++)u=u<<1^(u>>>9)*1335;const p=(d<<10|u)^21522;s(p>>>15==0);for(let h=0;h<=5;h++)this.setFunctionModule(8,h,r(p,h));this.setFunctionModule(8,7,r(p,6)),this.setFunctionModule(8,8,r(p,7)),this.setFunctionModule(7,8,r(p,8));for(let h=9;h<15;h++)this.setFunctionModule(14-h,8,r(p,h));for(let h=0;h<8;h++)this.setFunctionModule(this.size-1-h,8,r(p,h));for(let h=8;h<15;h++)this.setFunctionModule(8,this.size-15+h,r(p,h));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let u=0;u<12;u++)c=c<<1^(c>>>11)*7973;const d=this.version<<12|c;s(d>>>18==0);for(let u=0;u<18;u++){const p=r(d,u),h=this.size-11+u%3,m=Math.floor(u/3);this.setFunctionModule(h,m,p),this.setFunctionModule(m,h,p)}}drawFinderPattern(c,d){for(let u=-4;u<=4;u++)for(let p=-4;p<=4;p++){const h=Math.max(Math.abs(p),Math.abs(u)),m=c+p,g=d+u;0<=m&&m<this.size&&0<=g&&g<this.size&&this.setFunctionModule(m,g,h!=2&&h!=4)}}drawAlignmentPattern(c,d){for(let u=-2;u<=2;u++)for(let p=-2;p<=2;p++)this.setFunctionModule(c+p,d+u,Math.max(Math.abs(p),Math.abs(u))!=1)}setFunctionModule(c,d,u){this.modules[d][c]=u,this.isFunction[d][c]=!0}addEccAndInterleave(c){const d=this.version,u=this.errorCorrectionLevel;if(c.length!=Pe.getNumDataCodewords(d,u))throw new RangeError("Invalid argument");const p=Pe.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][d],h=Pe.ECC_CODEWORDS_PER_BLOCK[u.ordinal][d],m=Math.floor(Pe.getNumRawDataModules(d)/8),g=p-m%p,b=Math.floor(m/p);let x=[];const y=Pe.reedSolomonComputeDivisor(h);for(let v=0,N=0;v<p;v++){let k=c.slice(N,N+b-h+(v<g?0:1));N+=k.length;const C=Pe.reedSolomonComputeRemainder(k,y);v<g&&k.push(0),x.push(k.concat(C))}let w=[];for(let v=0;v<x[0].length;v++)x.forEach((N,k)=>{(v!=b-h||k>=g)&&w.push(N[v])});return s(w.length==m),w}drawCodewords(c){if(c.length!=Math.floor(Pe.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let d=0;for(let u=this.size-1;u>=1;u-=2){u==6&&(u=5);for(let p=0;p<this.size;p++)for(let h=0;h<2;h++){const m=u-h,b=(u+1&2)==0?this.size-1-p:p;!this.isFunction[b][m]&&d<c.length*8&&(this.modules[b][m]=r(c[d>>>3],7-(d&7)),d++)}}s(d==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let d=0;d<this.size;d++)for(let u=0;u<this.size;u++){let p;switch(c){case 0:p=(u+d)%2==0;break;case 1:p=d%2==0;break;case 2:p=u%3==0;break;case 3:p=(u+d)%3==0;break;case 4:p=(Math.floor(u/3)+Math.floor(d/2))%2==0;break;case 5:p=u*d%2+u*d%3==0;break;case 6:p=(u*d%2+u*d%3)%2==0;break;case 7:p=((u+d)%2+u*d%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[d][u]&&p&&(this.modules[d][u]=!this.modules[d][u])}}getPenaltyScore(){let c=0;for(let h=0;h<this.size;h++){let m=!1,g=0,b=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[h][x]==m?(g++,g==5?c+=Pe.PENALTY_N1:g>5&&c++):(this.finderPenaltyAddHistory(g,b),m||(c+=this.finderPenaltyCountPatterns(b)*Pe.PENALTY_N3),m=this.modules[h][x],g=1);c+=this.finderPenaltyTerminateAndCount(m,g,b)*Pe.PENALTY_N3}for(let h=0;h<this.size;h++){let m=!1,g=0,b=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[x][h]==m?(g++,g==5?c+=Pe.PENALTY_N1:g>5&&c++):(this.finderPenaltyAddHistory(g,b),m||(c+=this.finderPenaltyCountPatterns(b)*Pe.PENALTY_N3),m=this.modules[x][h],g=1);c+=this.finderPenaltyTerminateAndCount(m,g,b)*Pe.PENALTY_N3}for(let h=0;h<this.size-1;h++)for(let m=0;m<this.size-1;m++){const g=this.modules[h][m];g==this.modules[h][m+1]&&g==this.modules[h+1][m]&&g==this.modules[h+1][m+1]&&(c+=Pe.PENALTY_N2)}let d=0;for(const h of this.modules)d=h.reduce((m,g)=>m+(g?1:0),d);const u=this.size*this.size,p=Math.ceil(Math.abs(d*20-u*10)/u)-1;return s(0<=p&&p<=9),c+=p*Pe.PENALTY_N4,s(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,d=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let u=[6];for(let p=this.size-7;u.length<c;p-=d)u.splice(1,0,p);return u}}static getNumRawDataModules(c){if(c<Pe.MIN_VERSION||c>Pe.MAX_VERSION)throw new RangeError("Version number out of range");let d=(16*c+128)*c+64;if(c>=2){const u=Math.floor(c/7)+2;d-=(25*u-10)*u-55,c>=7&&(d-=36)}return s(208<=d&&d<=29648),d}static getNumDataCodewords(c,d){return Math.floor(Pe.getNumRawDataModules(c)/8)-Pe.ECC_CODEWORDS_PER_BLOCK[d.ordinal][c]*Pe.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let d=[];for(let p=0;p<c-1;p++)d.push(0);d.push(1);let u=1;for(let p=0;p<c;p++){for(let h=0;h<d.length;h++)d[h]=Pe.reedSolomonMultiply(d[h],u),h+1<d.length&&(d[h]^=d[h+1]);u=Pe.reedSolomonMultiply(u,2)}return d}static reedSolomonComputeRemainder(c,d){let u=d.map(p=>0);for(const p of c){const h=p^u.shift();u.push(0),d.forEach((m,g)=>u[g]^=Pe.reedSolomonMultiply(m,h))}return u}static reedSolomonMultiply(c,d){if(c>>>8||d>>>8)throw new RangeError("Byte out of range");let u=0;for(let p=7;p>=0;p--)u=u<<1^(u>>>7)*285,u^=(d>>>p&1)*c;return s(u>>>8==0),u}finderPenaltyCountPatterns(c){const d=c[1];s(d<=this.size*3);const u=d>0&&c[2]==d&&c[3]==d*3&&c[4]==d&&c[5]==d;return(u&&c[0]>=d*4&&c[6]>=d?1:0)+(u&&c[6]>=d*4&&c[0]>=d?1:0)}finderPenaltyTerminateAndCount(c,d,u){return c&&(this.finderPenaltyAddHistory(d,u),d=0),d+=this.size,this.finderPenaltyAddHistory(d,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(c,d){d[0]==0&&(c+=this.size),d.pop(),d.unshift(c)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(l,c,d){if(c<0||c>31||l>>>c)throw new RangeError("Value out of range");for(let u=c-1;u>=0;u--)d.push(l>>>u&1)}function r(l,c){return(l>>>c&1)!=0}function s(l){if(!l)throw new Error("Assertion error")}const a=class Qe{constructor(c,d,u){if(this.mode=c,this.numChars=d,this.bitData=u,d<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(c){let d=[];for(const u of c)n(u,8,d);return new Qe(Qe.Mode.BYTE,c.length,d)}static makeNumeric(c){if(!Qe.isNumeric(c))throw new RangeError("String contains non-numeric characters");let d=[];for(let u=0;u<c.length;){const p=Math.min(c.length-u,3);n(parseInt(c.substring(u,u+p),10),p*3+1,d),u+=p}return new Qe(Qe.Mode.NUMERIC,c.length,d)}static makeAlphanumeric(c){if(!Qe.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let d=[],u;for(u=0;u+2<=c.length;u+=2){let p=Qe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(u))*45;p+=Qe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(u+1)),n(p,11,d)}return u<c.length&&n(Qe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(u)),6,d),new Qe(Qe.Mode.ALPHANUMERIC,c.length,d)}static makeSegments(c){return c==""?[]:Qe.isNumeric(c)?[Qe.makeNumeric(c)]:Qe.isAlphanumeric(c)?[Qe.makeAlphanumeric(c)]:[Qe.makeBytes(Qe.toUtf8ByteArray(c))]}static makeEci(c){let d=[];if(c<0)throw new RangeError("ECI assignment value out of range");if(c<128)n(c,8,d);else if(c<16384)n(2,2,d),n(c,14,d);else if(c<1e6)n(6,3,d),n(c,21,d);else throw new RangeError("ECI assignment value out of range");return new Qe(Qe.Mode.ECI,0,d)}static isNumeric(c){return Qe.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return Qe.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,d){let u=0;for(const p of c){const h=p.mode.numCharCountBits(d);if(p.numChars>=1<<h)return 1/0;u+=4+h+p.bitData.length}return u}static toUtf8ByteArray(c){c=encodeURI(c);let d=[];for(let u=0;u<c.length;u++)c.charAt(u)!="%"?d.push(c.charCodeAt(u)):(d.push(parseInt(c.substring(u+1,u+3),16)),u+=2);return d}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let i=a;e.QrSegment=a})(er||(er={}));(e=>{(t=>{const n=class{constructor(s,a){this.ordinal=s,this.formatBits=a}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),t.Ecc=n})(e.QrCode||(e.QrCode={}))})(er||(er={}));(e=>{(t=>{const n=class{constructor(s,a){this.modeBits=s,this.numBitsCharCount=a}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),t.Mode=n})(e.QrSegment||(e.QrSegment={}))})(er||(er={}));var kr=er;/**
|
|
556
|
+
* @license qrcode.react
|
|
557
|
+
* Copyright (c) Paul O'Shannessy
|
|
558
|
+
* SPDX-License-Identifier: ISC
|
|
559
|
+
*/var yD={L:kr.QrCode.Ecc.LOW,M:kr.QrCode.Ecc.MEDIUM,Q:kr.QrCode.Ecc.QUARTILE,H:kr.QrCode.Ecc.HIGH},ey=128,ty="L",ny="#FFFFFF",ry="#000000",oy=!1,sy=1,vD=4,wD=0,ND=.1;function ay(e,t=0){const n=[];return e.forEach(function(r,s){let a=null;r.forEach(function(i,l){if(!i&&a!==null){n.push(`M${a+t} ${s+t}h${l-a}v1H${a+t}z`),a=null;return}if(l===r.length-1){if(!i)return;a===null?n.push(`M${l+t},${s+t} h1v1H${l+t}z`):n.push(`M${a+t},${s+t} h${l+1-a}v1H${a+t}z`);return}i&&a===null&&(a=l)})}),n.join("")}function iy(e,t){return e.slice().map((n,r)=>r<t.y||r>=t.y+t.h?n:n.map((s,a)=>a<t.x||a>=t.x+t.w?s:!1))}function kD(e,t,n,r){if(r==null)return null;const s=e.length+n*2,a=Math.floor(t*ND),i=s/t,l=(r.width||a)*i,c=(r.height||a)*i,d=r.x==null?e.length/2-l/2:r.x*i,u=r.y==null?e.length/2-c/2:r.y*i,p=r.opacity==null?1:r.opacity;let h=null;if(r.excavate){let g=Math.floor(d),b=Math.floor(u),x=Math.ceil(l+d-g),y=Math.ceil(c+u-b);h={x:g,y:b,w:x,h:y}}const m=r.crossOrigin;return{x:d,y:u,h:c,w:l,excavation:h,opacity:p,crossOrigin:m}}function SD(e,t){return t!=null?Math.max(Math.floor(t),0):e?vD:wD}function ly({value:e,level:t,minVersion:n,includeMargin:r,marginSize:s,imageSettings:a,size:i,boostLevel:l}){let c=Ge.useMemo(()=>{const g=(Array.isArray(e)?e:[e]).reduce((b,x)=>(b.push(...kr.QrSegment.makeSegments(x)),b),[]);return kr.QrCode.encodeSegments(g,yD[t],n,void 0,void 0,l)},[e,t,n,l]);const{cells:d,margin:u,numCells:p,calculatedImageSettings:h}=Ge.useMemo(()=>{let m=c.getModules();const g=SD(r,s),b=m.length+g*2,x=kD(m,i,g,a);return{cells:m,margin:g,numCells:b,calculatedImageSettings:x}},[c,i,a,r,s]);return{qrcode:c,margin:u,cells:d,numCells:p,calculatedImageSettings:h}}var CD=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),MD=Ge.forwardRef(function(t,n){const r=t,{value:s,size:a=ey,level:i=ty,bgColor:l=ny,fgColor:c=ry,includeMargin:d=oy,minVersion:u=sy,boostLevel:p,marginSize:h,imageSettings:m}=r,b=jl(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:x}=b,y=jl(b,["style"]),w=m?.src,v=Ge.useRef(null),N=Ge.useRef(null),k=Ge.useCallback(E=>{v.current=E,typeof n=="function"?n(E):n&&(n.current=E)},[n]),[C,M]=Ge.useState(!1),{margin:P,cells:I,numCells:z,calculatedImageSettings:A}=ly({value:s,level:i,minVersion:u,boostLevel:p,includeMargin:d,marginSize:h,imageSettings:m,size:a});Ge.useEffect(()=>{if(v.current!=null){const E=v.current,D=E.getContext("2d");if(!D)return;let L=I;const T=N.current,B=A!=null&&T!==null&&T.complete&&T.naturalHeight!==0&&T.naturalWidth!==0;B&&A.excavation!=null&&(L=iy(I,A.excavation));const F=window.devicePixelRatio||1;E.height=E.width=a*F;const j=a/z*F;D.scale(j,j),D.fillStyle=l,D.fillRect(0,0,z,z),D.fillStyle=c,CD?D.fill(new Path2D(ay(L,P))):I.forEach(function(V,$){V.forEach(function(H,G){H&&D.fillRect(G+P,$+P,1,1)})}),A&&(D.globalAlpha=A.opacity),B&&D.drawImage(T,A.x+P,A.y+P,A.w,A.h)}}),Ge.useEffect(()=>{M(!1)},[w]);const O=Fl({height:a,width:a},x);let R=null;return w!=null&&(R=Ge.createElement("img",{src:w,key:w,style:{display:"none"},onLoad:()=>{M(!0)},ref:N,crossOrigin:A?.crossOrigin})),Ge.createElement(Ge.Fragment,null,Ge.createElement("canvas",Fl({style:O,height:a,width:a,ref:k,role:"img"},y)),R)});MD.displayName="QRCodeCanvas";var cy=Ge.forwardRef(function(t,n){const r=t,{value:s,size:a=ey,level:i=ty,bgColor:l=ny,fgColor:c=ry,includeMargin:d=oy,minVersion:u=sy,boostLevel:p,title:h,marginSize:m,imageSettings:g}=r,b=jl(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:x,cells:y,numCells:w,calculatedImageSettings:v}=ly({value:s,level:i,minVersion:u,boostLevel:p,includeMargin:d,marginSize:m,imageSettings:g,size:a});let N=y,k=null;g!=null&&v!=null&&(v.excavation!=null&&(N=iy(y,v.excavation)),k=Ge.createElement("image",{href:g.src,height:v.h,width:v.w,x:v.x+x,y:v.y+x,preserveAspectRatio:"none",opacity:v.opacity,crossOrigin:v.crossOrigin}));const C=ay(N,x);return Ge.createElement("svg",Fl({height:a,width:a,viewBox:`0 0 ${w} ${w}`,ref:n,role:"img"},b),!!h&&Ge.createElement("title",null,h),Ge.createElement("path",{fill:l,d:`M0,0 h${w}v${w}H0z`,shapeRendering:"crispEdges"}),Ge.createElement("path",{fill:c,d:C,shapeRendering:"crispEdges"}),k)});cy.displayName="QRCodeSVG";const ED=192;function dy({value:e,size:t=ED,className:n,alt:r}){const s=e.trim();return s.length===0?null:o("div",{className:K("inline-flex rounded-md bg-white p-2",n),children:o(cy,{value:s,size:t,marginSize:1,title:r??"QR code"})})}const ID=2e3;function uy({value:e,label:t,className:n,disabled:r}){const[s,a]=_(!1),i=U(()=>{e&&navigator.clipboard.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),ID)})},[e]);return f(Re,{size:"sm",variant:"ghost",type:"button",disabled:r||e.length===0,onClick:i,className:K(n),"aria-label":s?"Copied":`Copy ${t??"value"}`,children:[s?o(qr,{className:"h-3.5 w-3.5 text-success"}):o(vn,{className:"h-3.5 w-3.5"}),t?o("span",{className:"ml-1",children:s?"Copied":t}):null]})}const AD=b2(h2),wp=1e4;function Np(e){return e==="linked"?"success":e==="error"?"danger":"warning"}function kp(e){return e==="linked"?"Linked":e==="unlinked"?"Unlinked":e==="error"?"Error":e}function PD({field:e}){const[t,n]=_(!1),r=e.secret===!0,a=r&&!t?"•".repeat(Math.min(e.value.length,24)):e.value;return f("div",{className:"flex items-center gap-2 py-1.5",children:[o("span",{className:"text-[11px] text-foreground-subtle w-32 shrink-0",children:e.label}),o("span",{className:"flex-1 min-w-0 truncate font-mono text-xs text-foreground",children:a||"—"}),r&&o(Re,{size:"sm",variant:"ghost",type:"button","aria-label":t?"Hide value":"Reveal value",onClick:()=>n(i=>!i),children:t?o(_c,{className:"h-3.5 w-3.5"}):o(Ur,{className:"h-3.5 w-3.5"})}),o(uy,{value:e.value,label:e.label})]})}function _D({setup:e}){const t=e.fields??[];return f("div",{className:"border-b border-border bg-surface-hover/10",children:[f("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border",children:[o(TS,{className:"h-3.5 w-3.5 text-foreground-subtle shrink-0"}),o("span",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Setup"})]}),f("div",{className:"flex flex-col gap-3 p-4 sm:flex-row sm:items-start",children:[e.qr&&o("div",{className:"shrink-0",children:o(dy,{value:e.qr,alt:"Pairing QR code"})}),f("div",{className:"flex-1 min-w-0",children:[e.note&&o("p",{className:"text-xs text-foreground-muted whitespace-pre-line mb-2",children:e.note}),t.length>0&&o("div",{className:"divide-y divide-border-subtle",children:t.map(n=>o(PD,{field:n},n.label))})]})]})]})}function py({addonId:e,onOpenDevice:t}){const n=ke(),r=id({nodeId:"hub"},{refetchInterval:wp,retry:!1}),s=Ob({nodeId:"hub"},{refetchInterval:wp,retry:!1}),a=Bb({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceExport"]]})}}),i=q(()=>{const m=am.safeParse(r.data);return m.success?m.data:null},[r.data]),l=q(()=>{const m=AD.safeParse(s.data);return m.success?m.data:[]},[s.data]),c=i?.linkState??"unlinked",d=q(()=>l.map(m=>({deviceId:m.deviceId,displayName:m.exposedAs??`Device ${m.deviceId}`,streamPreference:"auto",linkState:c})),[l,c]),u=r.isLoading||s.isLoading,p=i?.exposedDeviceCount??d.length,h=q(()=>[{key:"device",header:"Device",render:m=>f("div",{className:"flex flex-col",children:[o("span",{className:"text-foreground font-medium",children:m.displayName}),f("span",{className:"text-foreground-subtle text-xs font-mono",children:["#",m.deviceId]})]})},{key:"status",header:"Status",render:m=>o(zt,{variant:Np(m.linkState),children:kp(m.linkState)})},{key:"stream",header:"Stream",render:m=>o("span",{className:"text-xs text-foreground-subtle font-mono",children:m.streamPreference==="auto"?"Auto":m.streamPreference})},{key:"actions",header:"",align:"right",render:m=>f("div",{className:"flex items-center justify-end gap-2",children:[t&&f(Re,{size:"sm",variant:"ghost",onClick:()=>t(m.deviceId),children:[o(Pc,{className:"h-3.5 w-3.5 mr-1"}),"Open"]}),f(Re,{size:"sm",variant:"ghost",disabled:a.isPending,onClick:()=>a.mutate({deviceId:m.deviceId,nodeId:"hub"}),children:[o(NC,{className:"h-3.5 w-3.5 mr-1"}),"Unexpose"]})]})}],[t,a]);return f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 border-b border-border bg-surface-hover/20",children:[f("div",{className:"flex items-center gap-2 min-w-0",children:[o(Uu,{className:"h-3.5 w-3.5 text-foreground-subtle shrink-0"}),o("span",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Exported devices"}),o(zt,{variant:Np(c),children:kp(c)}),f("span",{className:"text-[11px] text-foreground-subtle",children:[p," exposed"]})]}),u&&o(Mt,{className:"h-3.5 w-3.5 animate-spin text-foreground-subtle"})]}),i?.error&&o("div",{className:"px-4 py-3 border-b border-border",children:o(Oa,{message:i.error})}),i?.setup&&o(_D,{setup:i.setup}),d.length===0?o(Ra,{icon:Uu,title:"No devices exposed",description:`Expose a camera to "${e}" from its device-details page to surface it in the connected ecosystem.`}):o("div",{className:"p-3",children:o($a,{columns:h,rows:d,rowKey:m=>m.deviceId})})]})}function $D({samples:e,sampleRate:t=16e3,height:n=96,className:r="",color:s="#3b82f6",bgColor:a="transparent"}){const i=te(null),l=te(null),c=U(()=>{const p=i.current,h=l.current;if(!p||!h||!e||e.length===0)return;const m=h.clientWidth;if(m===0)return;const g=window.devicePixelRatio||1;p.width=m*g,p.height=n*g,p.style.width=`${m}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,m,n)):b.clearRect(0,0,m,n);const x=e.length/m,y=n/2;b.fillStyle=s,b.globalAlpha=.7;for(let w=0;w<m;w++){const v=Math.floor(w*x),N=Math.min(Math.floor((w+1)*x),e.length);let k=0,C=0;for(let z=v;z<N;z++){const A=e[z];A<k&&(k=A),A>C&&(C=A)}const M=y-C*y,P=y-k*y,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,y),b.lineTo(m,y),b.stroke(),b.globalAlpha=1},[e,n,s,a]);Y(()=>{c()},[c]),Y(()=>{const p=new ResizeObserver(()=>c()),h=l.current;return h&&p.observe(h),()=>p.disconnect()},[c]);const u=((e&&t?Math.round(e.length/t*1e3):0)/1e3).toFixed(1);return f("div",{ref:l,className:`relative ${r}`,children:[o("canvas",{ref:i,className:"w-full rounded-md"}),e&&e.length>0&&f("div",{className:"absolute bottom-1 right-2 text-[10px] text-foreground-subtle/60 font-mono",children:[u,"s · ",t/1e3,"kHz · ",e.length.toLocaleString()," samples"]})]})}function DD({currentDbfs:e,durationSec:t=30,maxSamples:n=120,height:r=64,className:s="",color:a="#10b981",clipColor:i="#ef4444",clipThreshold:l=-6,minDbfs:c=-96}){const d=te(null),u=te(null),[p,h]=_([]);Y(()=>{e!==null&&h(b=>{const x=[...b,{dbfs:e,timestamp:Date.now()}];return x.length>n?x.slice(-n):x})},[e,n]);const m=U(()=>{const b=d.current,x=u.current;if(!b||!x)return;const y=x.clientWidth;if(y===0)return;const w=window.devicePixelRatio||1;b.width=y*w,b.height=r*w,b.style.width=`${y}px`,b.style.height=`${r}px`;const v=b.getContext("2d");if(!v||(v.scale(w,w),v.clearRect(0,0,y,r),p.length===0))return;const N=p[p.length-1].timestamp,k=t*1e3,C=N-k,M=p.filter(A=>A.timestamp>=C);if(M.length===0)return;const P=Math.max(1,Math.floor(y/(t*2))),I=Math.abs(c);for(const A of M){const O=A.timestamp-C,R=Math.floor(O/k*y),D=(Math.max(c,Math.min(0,A.dbfs))-c)/I,L=Math.max(1,D*r),T=A.dbfs>=l;v.fillStyle=T?i:a,v.globalAlpha=.8,v.fillRect(R,r-L,P,L)}v.globalAlpha=1;const z=r-(l-c)/I*r;v.strokeStyle=i,v.globalAlpha=.25,v.lineWidth=1,v.setLineDash([4,4]),v.beginPath(),v.moveTo(0,z),v.lineTo(y,z),v.stroke(),v.setLineDash([]),v.globalAlpha=1},[p,t,r,a,i,l,c]);Y(()=>{m()},[m]),Y(()=>{const b=new ResizeObserver(()=>m()),x=u.current;return x&&b.observe(x),()=>b.disconnect()},[m]);const g=p.length>0?p[p.length-1].dbfs:null;return f("div",{ref:u,className:`relative ${s}`,children:[o("canvas",{ref:d,className:"w-full rounded-md"}),f("div",{className:"absolute top-1 left-2 text-[9px] text-foreground-subtle/50 font-mono",children:[t,"s"]}),g!==null&&f("div",{className:"absolute bottom-1 right-2 text-[9px] text-foreground-subtle/50 font-mono",children:[g.toFixed(1)," dBFS · ",p.length," samples"]})]})}function LD(e){return e>=.8?"bg-emerald-500":e>=.5?"bg-amber-500":e>=.3?"bg-orange-500":"bg-zinc-500"}function TD(e){return e>=.8?"text-emerald-400":e>=.5?"text-amber-400":e>=.3?"text-orange-400":"text-zinc-400"}function RD({classifications:e,processing:t=!1,inferenceMs:n,maxItems:r=10,className:s=""}){const a=e.slice(0,r),i=a.length>0?a[0].score:1;return t?o("div",{className:`rounded-xl border border-border bg-surface p-4 text-center ${s}`,children:o("div",{className:"text-sm text-foreground-subtle animate-pulse",children:"Classifying audio..."})}):a.length===0?o("div",{className:`rounded-xl border border-border bg-surface p-4 text-center ${s}`,children:o("div",{className:"text-xs text-foreground-subtle",children:"No classifications yet"})}):f("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${s}`,children:[f("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between",children:[o("h3",{className:"text-xs font-medium text-foreground",children:"Audio Classifications"}),f("div",{className:"flex items-center gap-3 text-[10px] text-foreground-subtle",children:[a.length<e.length&&f("span",{children:["showing ",a.length," of ",e.length]}),n!==void 0&&f("span",{className:"font-mono",children:[n.toFixed(1),"ms"]})]})]}),o("div",{className:"divide-y divide-border/50",children:a.map((l,c)=>{const d=i>0?l.score/i*100:0;return f("div",{className:"px-3 py-1.5 flex items-center gap-3 hover:bg-surface-hover/30",children:[o("span",{className:"text-[10px] text-foreground-subtle w-5 text-right font-mono",children:c+1}),o("span",{className:"text-xs font-medium text-foreground min-w-[120px]",children:l.className}),o("div",{className:"flex-1 h-2 rounded-full bg-zinc-800 overflow-hidden",children:o("div",{className:`h-full rounded-full transition-all duration-300 ${LD(l.score)}`,style:{width:`${d}%`}})}),f("span",{className:`text-xs font-mono font-semibold w-14 text-right ${TD(l.score)}`,children:[(l.score*100).toFixed(1),"%"]})]},`${l.className}-${c}`)})})]})}function OD({data:e,label:t="Response",className:n=""}){const[r,s]=_(!1);if(!e)return null;const a=JSON.stringify(e,null,2);return f("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${n}`,children:[f("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:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-[10px] text-foreground-subtle",children:r?"▼":"▶"}),o("h3",{className:"text-xs font-medium text-foreground",children:t})]}),o("span",{className:"text-[10px] text-foreground-subtle font-mono",children:a.length>1e3?`${(a.length/1024).toFixed(1)} KB`:`${a.length} bytes`})]}),r&&o("div",{className:"max-h-80 overflow-y-auto overflow-x-auto",children:o("pre",{className:"p-3 text-[10px] leading-4 font-mono text-foreground-subtle whitespace-pre",children:a})})]})}const BD={Activity:In,Eye:Ur,AlertTriangle:Qr,PauseCircle:L5,PowerOff:DS};function Sd({phase:e,...t}){const n=ur(e),r=BD[n.icon];return o(r,{...t})}function Wn(e){const[t,n]=_([]),r=U(a=>{n(i=>{const l=[...i,a];return l.length>e?l.slice(-e):l})},[e]),s=U(()=>{n([])},[]);return q(()=>({entries:t,append:r,reset:s}),[t,r,s])}function Sp(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 Cp={error:{icon:Qo,color:"text-red-400"},warn:{icon:Qr,color:"text-amber-400"},info:{icon:cS,color:"text-blue-400"},debug:{icon:b5,color:"text-gray-500"}},Mp={debug:0,info:1,warn:2,error:3},zD=["all","debug","info","warn","error"],FD=500;function jD(e,t){return t?(Mp[e]??0)>=(Mp[t]??0):!0}function Ht({agentId:e,addonId:t,deviceId:n,integrationId:r,requestId:s,level:a,maxHeight:i="max-h-96",showScope:l=!1,showFilters:c=!0,limit:d=100,liveBuffer:u,onClose:p,className:h}){const[m,g]=_(""),[b,x]=_(""),[y,w]=_(a),v=e,N=t??(m||void 0),k=n??(b?Number(b):void 0),C=r,M=s,P=q(()=>{const Q={};return v&&(Q.agentId=v),N&&(Q.addonId=N),k!==void 0&&Number.isFinite(k)&&(Q.deviceId=k),C&&(Q.integrationId=C),M&&(Q.requestId=M),Object.keys(Q).length>0?Q:void 0},[v,N,k,C,M]),I=Wn(FD),z=u??I,A=z.entries,[O,R]=_(0),[E,D]=_(!1),[L,T]=_(!1),[B,F]=_(new Set),[j,V]=_(""),$=te(null),H=`${v??""}:${N??""}:${String(k??"")}:${C??""}:${M??""}`,G=te(H);Y(()=>{G.current!==H&&(G.current=H,z.reset(),R(0),F(new Set))},[H,z]);const{data:Z,isLoading:oe}=S.logs.query.useQuery({...P?{tags:P}:{},limit:d},{staleTime:3e4});S.logs.subscribe.useSubscription({...P?{tags:P}:{}},{onData:Q=>{z.append(Q)}});const ne=te(A.length);Y(()=>{const Q=$.current;if(!Q){ne.current=A.length;return}const le=ne.current;if(ne.current=A.length,!(A.length<=le)){if(E&&Q.scrollTop<=8)Q.scrollTo({top:0});else if(!E&&Q.scrollTop>0){const ue=Q.querySelector("tbody tr"),de=ue instanceof HTMLElement?ue.offsetHeight:24;Q.scrollTop+=de*(A.length-le)}}},[A.length,E]);const X=q(()=>{const Q=(Z??[]).map(pe=>({timestamp:pe.timestamp,level:pe.level,message:pe.message,scope:pe.scope,tags:pe.tags,meta:pe.meta})),le=new Set,ue=[];for(const pe of[...A].reverse()){const $e=`${pe.timestamp}|${pe.level}|${pe.scope??""}|${pe.message}`;le.has($e)||(le.add($e),ue.push(pe))}for(const pe of Q){const $e=`${pe.timestamp}|${pe.level}|${pe.scope??""}|${pe.message}`;le.has($e)||(le.add($e),ue.push(pe))}const ce=(O>0?ue.filter(pe=>new Date(pe.timestamp).getTime()>O):ue).filter(pe=>jD(pe.level,y)),Ce=j.trim().toLowerCase();return Ce?ce.filter(pe=>{if(pe.message.toLowerCase().includes(Ce)||pe.scope&&pe.scope.toLowerCase().includes(Ce))return!0;if(pe.tags){for(const $e of Object.values(pe.tags))if($e!==void 0&&String($e).toLowerCase().includes(Ce))return!0}if(pe.meta){for(const $e of Object.values(pe.meta))if($e!=null&&Sp($e).toLowerCase().includes(Ce))return!0}return!1}):ce},[Z,A,y,O,j]),re=U(()=>{const Q=X.map(le=>{const ue=new Date(le.timestamp).toLocaleTimeString(),de=le.tags?" "+Object.entries(le.tags).filter(([,ce])=>ce).map(([ce,Ce])=>`${ce}=${Ce}`).join(" "):"";return`${ue} [${le.level.toUpperCase()}]${le.scope?` [${le.scope}]`:""}${de} ${le.message}`});navigator.clipboard.writeText(Q.join(`
|
|
560
|
+
`)).then(()=>{T(!0),setTimeout(()=>T(!1),1500)})},[X]),be=S.logs.clear.useMutation(),J=U(()=>{R(Date.now()),z.reset(),be.mutate({...P?{tags:P}:{}})},[z,be,P]),W=U(Q=>{F(le=>{const ue=new Set(le);return ue.has(Q)?ue.delete(Q):ue.add(Q),ue})},[]),[ee,ae]=_(null),fe=U((Q,le)=>{const ue=new Date(Q.timestamp).toISOString(),de=Q.tags?" "+Object.entries(Q.tags).filter(([,pe])=>pe).map(([pe,$e])=>`${pe}=${$e}`).join(" "):"",ce=Q.meta&&Object.keys(Q.meta).length>0?` meta=${JSON.stringify(Q.meta)}`:"",Ce=`${ue} [${Q.level.toUpperCase()}]${Q.scope?` [${Q.scope}]`:""}${de} ${Q.message}${ce}`;navigator.clipboard.writeText(Ce).then(()=>{ae(le),setTimeout(()=>ae(pe=>pe===le?null:pe),1200)})},[]),ge=U(Q=>`${Q.timestamp}|${Q.level}|${Q.scope??""}|${Q.message}`,[]);return f("div",{className:K("h-full min-h-0 flex flex-col",h),onClick:Q=>Q.stopPropagation(),children:[f("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[f("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Logs"}),v&&o(Di,{label:"agent",value:v}),N&&o(Di,{label:"addon",value:N}),k!==void 0&&o(Di,{label:"device",value:`#${k}`}),o("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:zD.map(Q=>f("button",{type:"button",onClick:()=>w(Q==="all"?void 0:Q),className:K("px-1.5 py-0.5 capitalize transition-colors",Q==="all"&&!y||y===Q?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover",Q!=="all"&&"border-l border-border"),children:[Q,Q!=="all"?"+":""]},Q))}),o(Li,{icon:Ic,label:E?"Auto":"Paused",active:!E,onClick:()=>{D(Q=>!Q),!E&&$.current&&$.current.scrollTo({top:0,behavior:"smooth"})}}),o(Li,{icon:vn,label:L?"Copied!":"Copy",onClick:re,disabled:X.length===0}),o(Li,{icon:Jt,label:"Clear",onClick:J}),f("div",{className:"relative",children:[o("input",{type:"text",value:j,onChange:Q=>V(Q.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&&o("button",{type:"button",onClick:()=>V(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:o(Je,{className:"h-2.5 w-2.5"})})]}),A.length>0&&f("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",A.length," live"]})]}),p&&o("button",{type:"button",onClick:p,className:"text-foreground-subtle hover:text-foreground",children:o(Je,{className:"h-3.5 w-3.5"})})]}),c&&(!t||!n)&&f("div",{className:"flex items-center gap-2 px-3 py-1 border-b border-border/50 bg-surface/50 text-[10px]",children:[!t&&f("label",{className:"flex items-center gap-1",children:[o("span",{className:"text-foreground-subtle",children:"Addon:"}),o("input",{type:"text",value:m,onChange:Q=>g(Q.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&&f("label",{className:"flex items-center gap-1",children:[o("span",{className:"text-foreground-subtle",children:"Device:"}),o("input",{type:"text",inputMode:"numeric",value:b,onChange:Q=>x(Q.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"})]})]}),f("div",{ref:$,className:K("flex-1 min-h-0 overflow-auto font-mono text-[10px]",i),children:[oe&&f("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[o(Mt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading logs..."]}),!oe&&X.length===0&&o("div",{className:"py-4 text-center text-foreground-subtle",children:"No logs found"}),X.length>0&&o("table",{className:"w-full",children:o("tbody",{children:X.map(Q=>{const le=Cp[Q.level]??Cp.info,ue=le.icon,de=ge(Q),ce=B.has(de),Ce=Q.tags&&Object.keys(Q.tags).length>0,pe=Q.meta&&Object.keys(Q.meta).length>0,$e=Ce||pe;return f("tr",{className:K("hover:bg-surface-hover/30 border-b border-border/30",$e&&"cursor-pointer"),onClick:$e?()=>W(de):void 0,children:[o("td",{className:"px-2 py-1 text-foreground-subtle whitespace-nowrap align-top w-[70px]",children:new Date(Q.timestamp).toLocaleTimeString()}),o("td",{className:K("px-1 py-1 align-top w-5",le.color),children:o(ue,{className:"h-3 w-3"})}),l&&o("td",{className:"px-2 py-1 text-foreground-subtle align-top truncate max-w-[120px]",title:Q.scope,children:Q.scope?.replace(/^addon:/,"")??""}),o("td",{className:"px-2 py-1 text-foreground break-all",children:f("div",{className:"flex items-start gap-1",children:[$e&&(ce?o(pr,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"}):o(Rn,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"})),f("div",{className:"flex-1 min-w-0",children:[Q.message,ce&&$e&&f("div",{className:"mt-1 text-[9px] text-foreground-subtle bg-surface rounded px-2 py-1 space-y-0.5",children:[pe&&Object.entries(Q.meta).filter(([,Ae])=>Ae!==void 0&&Ae!=="").map(([Ae,Xe])=>f("div",{children:[o("span",{className:"text-amber-400/80 font-medium",children:Ae}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground break-all",children:Sp(Xe)})]},`m-${Ae}`)),Ce&&Object.entries(Q.tags).filter(([,Ae])=>Ae!==void 0).map(([Ae,Xe])=>f("div",{children:[o("span",{className:"text-primary/70 font-medium",children:Ae}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground",children:Xe})]},`t-${Ae}`))]})]})]})}),o("td",{className:"px-1 py-1 align-top w-5",children:o(VD,{copied:ee===de,onCopy:()=>fe(Q,de)})})]},de)})})})]})]})}function fy({position:e="bottom",className:t,...n}){return o("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:o(Ht,{maxHeight:"max-h-48",...n})})}function Di({label:e,value:t}){return f("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function VD({copied:e,onCopy:t}){return o("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?o(qr,{className:"h-3 w-3"}):o(vn,{className:"h-3 w-3"})})}function Li({icon:e,label:t,onClick:n,disabled:r,active:s}){return f("button",{type:"button",onClick:n,disabled:r,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",r&&"opacity-40 cursor-not-allowed"),children:[o(e,{className:"h-2.5 w-2.5"}),t]})}function HD(e,t,n,r){if(r!==void 0&&(e.source.deviceId??(e.source.type==="device"&&typeof e.source.id=="number"?e.source.id:void 0))!==r||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 qD={[Ne.AddonStarted]:{icon:$l,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Started"},[Ne.AddonInstalled]:{icon:Pl,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Installed"},[Ne.AddonRestarted]:{icon:_a,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Restarted"},[Ne.AddonUpdated]:{icon:Zm,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Updated"},[Ne.AddonStopped]:{icon:Qu,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Stopped"},[Ne.AddonUninstalled]:{icon:Jt,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Uninstalled"},[Ne.AddonCrashed]:{icon:Qo,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Crashed"},[Ne.AddonError]:{icon:Qr,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Error"},[Ne.DetectionPhaseTransition]:{icon:In,color:"bg-violet-500/15 text-violet-400 border-violet-500/30",label:"Phase"},[Ne.DetectionResult]:{icon:US,color:"bg-purple-500/15 text-purple-400 border-purple-500/30",label:"Detection"},[Ne.DetectionEvent]:{icon:Ur,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Event"},[Ne.DetectionCameraNative]:{icon:Gu,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Camera AI"},[Ne.ProviderMotion]:{icon:Ku,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[Ne.MotionOnMotionChanged]:{icon:Ku,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[Ne.MotionAnalysis]:{icon:In,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion analysis"},[Ne.MotionZonesRaw]:{icon:In,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion zones"},[Ne.ProviderDetection]:{icon:Gu,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Provider Det"},[Ne.PipelineAudioInferenceResult]:{icon:Um,color:"bg-pink-500/15 text-pink-400 border-pink-500/30",label:"Audio"},[Ne.AgentOnline]:{icon:$l,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Agent Online"},[Ne.AgentOffline]:{icon:Qu,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Agent Offline"},[Ne.DeviceRegistered]:{icon:Pl,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Registered"},[Ne.DeviceUnregistered]:{icon:Jt,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Unregistered"},[Ne.DeviceStateChanged]:{icon:In,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"State"}};function Vl(e,t){const n=qD[e]??{icon:$l,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 r=t.capName;return{...n,label:r}}return n}const Nr=Object.freeze([...new Set(Object.values(Ne))].sort()),UD=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]),QD=new Set(UD),GD=Object.freeze(Nr.filter(e=>!QD.has(e)));function Vs(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,u=typeof d=="string"?d:"";u&&i.set(u,(i.get(u)??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:"",u=l.score;return u?`${d} (${Math.round(u*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,r=t.error;return r||(n?`addon: ${n}`:null)}function KD(e){const t=e.category;return t===Ne.DetectionResult||t===Ne.PipelineAudioInferenceResult?Vs(t,e.data)!==null:!0}const WD=300;function br({agentId:e,addonId:t,deviceId:n,defaultCategories:r,categories:s,category:a,maxHeight:i="max-h-96",limit:l=50,showCategoryFilter:c=!0,showFilters:d=!1,liveBuffer:u,onClose:p,className:h}){const m=q(()=>r??s??GD,[r,s]),g=q(()=>[...m].sort().join(","),[m]),[b,x]=_(()=>new Set(m)),y=te(g);Y(()=>{y.current!==g&&(y.current=g,x(new Set(m)))},[g,m]);const w=Wn(WD),v=u??w,N=v.entries,[k,C]=_(!0),[M,P]=_(new Set),[I,z]=_(""),[A,O]=_(!1),[R,E]=_(""),[D,L]=_(0),T=te(null),B=te(null),F=`${e??""}:${t??""}:${String(n??"")}:${a??""}`,j=te(F);Y(()=>{j.current!==F&&(j.current=F,v.reset(),P(new Set),L(0))},[F,v]),Y(()=>{if(!A)return;const me=_e=>{const Oe=B.current;Oe&&_e.target instanceof Node&&!Oe.contains(_e.target)&&O(!1)};return document.addEventListener("mousedown",me),()=>{document.removeEventListener("mousedown",me)}},[A]);const V=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]),$=q(()=>[...b].sort(),[b]),H=q(()=>$.join(","),[$]),G=q(()=>{const me={...V,limit:l};return $.length>0&&$.length<Nr.length&&(me.category=$),me},[V,l,H,$]),{data:Z,isLoading:oe}=S.systemEvents.getRecent.useQuery(G,{staleTime:3e4}),ne=te(b);Y(()=>{ne.current=b},[b]);const X=V;S.systemEvents.subscribe.useSubscription(X,{onData:me=>{const _e=me;_e?.id&&HD(_e,e,t,n)&&ne.current.has(_e.category)&&v.append(_e)}});const re=te(N.length);Y(()=>{const me=T.current;if(!me){re.current=N.length;return}const _e=re.current;if(re.current=N.length,!(N.length<=_e)){if(k&&me.scrollTop<=8)me.scrollTo({top:0});else if(!k&&me.scrollTop>0){const Oe=me.firstElementChild?.firstElementChild,Be=Oe instanceof HTMLElement?Oe.offsetHeight:28;me.scrollTop+=Be*(N.length-_e)}}},[N.length,k]);const be=q(()=>{const me=new Map;for(const Be of Z??[])me.set(Be.id,Be);for(const Be of N)me.set(Be.id,Be);let _e=[...me.values()].filter(Be=>b.has(Be.category)).filter(KD);D>0&&(_e=_e.filter(Be=>new Date(Be.timestamp).getTime()>D));const Oe=I.trim().toLowerCase();return Oe&&(_e=_e.filter(Be=>{if(Be.category.toLowerCase().includes(Oe)||Vl(Be.category,Be.data).label.toLowerCase().includes(Oe))return!0;const Fn=Vs(Be.category,Be.data);if(Fn&&Fn.toLowerCase().includes(Oe))return!0;try{if(new Date(Be.timestamp).toLocaleTimeString().toLowerCase().includes(Oe))return!0}catch{}try{if(JSON.stringify(Be.data).toLowerCase().includes(Oe)||JSON.stringify(Be.source).toLowerCase().includes(Oe))return!0}catch{}return!1})),_e.sort((Be,zn)=>new Date(zn.timestamp).getTime()-new Date(Be.timestamp).getTime())},[Z,N,b,I,D]),J=U(me=>{P(_e=>{const Oe=new Set(_e);return Oe.has(me)?Oe.delete(me):Oe.add(me),Oe})},[]),W=U(me=>{x(_e=>{const Oe=new Set(_e);return Oe.has(me)?Oe.delete(me):Oe.add(me),Oe})},[]),ee=U(()=>{x(new Set(m)),z(""),L(0)},[m]),ae=U(()=>{L(Date.now()),v.reset()},[v]),[fe,ge]=_(!1),[Q,le]=_(null),ue=U(me=>{const _e=new Date(me.timestamp).toISOString(),Oe=Vs(me.category,me.data)??"",Be=Oe?` ${Oe}`:"";return`${_e} [${me.category}]${Be} data=${JSON.stringify(me.data)}`},[]),de=U(()=>{const me=be.map(ue);navigator.clipboard.writeText(me.join(`
|
|
561
|
+
`)).then(()=>{ge(!0),setTimeout(()=>ge(!1),1500)})},[be,ue]),ce=U(me=>{navigator.clipboard.writeText(ue(me)).then(()=>{le(me.id),setTimeout(()=>le(_e=>_e===me.id?null:_e),1200)})},[ue]),Ce=U(()=>{x(new Set(Nr))},[]),pe=U(()=>{x(new Set)},[]),$e=q(()=>{const me=R.trim().toLowerCase();return me?Nr.filter(_e=>_e.toLowerCase().includes(me)):Nr},[R]),Ae=Nr.length,Xe=b.size,ut=Xe===Ae,yr=ut?"All":`${Xe}/${Ae}`;return f("div",{className:K("h-full min-h-0 flex flex-col",h),onClick:me=>me.stopPropagation(),children:[f("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[f("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Events"}),e&&o(ms,{label:"agent",value:e}),t&&o(ms,{label:"addon",value:t}),n!==void 0&&o(ms,{label:"device",value:`#${n}`}),a&&o(ms,{label:"category",value:a}),f("button",{type:"button",onClick:()=>{C(me=>!me),!k&&T.current&&T.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:[o(Ic,{className:"h-2.5 w-2.5"}),k?"Auto":"Paused"]}),c&&f("div",{className:"relative",ref:B,children:[f("button",{type:"button",onClick:()=>O(me=>!me),className:K("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",ut?"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:[o(Vm,{className:"h-2.5 w-2.5"}),"Filter (",yr,")"]}),A&&o(YD,{search:R,onSearchChange:E,categories:$e,active:b,onToggle:W,onSelectAll:Ce,onSelectNone:pe,onResetDefaults:ee})]}),f("button",{type:"button",onClick:ee,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:[o(Km,{className:"h-2.5 w-2.5"}),"Reset"]}),f("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:[o(Jt,{className:"h-2.5 w-2.5"}),"Clear"]}),f("button",{type:"button",onClick:de,disabled:be.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",be.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible events",children:[o(vn,{className:"h-2.5 w-2.5"}),fe?"Copied!":"Copy"]}),f("div",{className:"relative",children:[o("input",{type:"text",value:I,onChange:me=>z(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&&o("button",{type:"button",onClick:()=>z(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:o(Je,{className:"h-2.5 w-2.5"})})]}),N.length>0&&f("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",N.length," live"]})]}),p&&o("button",{type:"button",onClick:p,className:"text-foreground-subtle hover:text-foreground",children:o(Je,{className:"h-3.5 w-3.5"})})]}),f("div",{ref:T,className:K("flex-1 min-h-0 overflow-auto text-[10px]",i),children:[oe&&f("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[o(Mt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading events..."]}),!oe&&be.length===0&&o("div",{className:"py-4 text-center text-foreground-subtle",children:"No events found"}),be.length>0&&o("div",{className:"divide-y divide-border/30",children:be.map(me=>{const _e=Vl(me.category,me.data),Oe=_e.icon,Be=Vs(me.category,me.data),zn=M.has(me.id);return f("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>J(me.id),children:[o("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(me.timestamp).toLocaleTimeString()}),o(XD,{copied:Q===me.id,onCopy:()=>ce(me)}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-1.5",children:[zn?o(pr,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):o(Rn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),f("span",{className:K("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[9px] font-medium",_e.color),children:[o(Oe,{className:"h-2.5 w-2.5"}),_e.label]}),me.source.nodeId&&me.source.nodeId!=="hub"&&o("span",{className:"text-[9px] px-1 py-0.5 rounded bg-foreground-subtle/10 text-foreground-subtle font-mono",children:me.source.nodeId})]}),Be&&o("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5",children:Be}),zn&&f("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:[f("div",{children:[o("span",{className:"text-primary/70",children:"source"}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground",children:JSON.stringify(me.source)})]}),f("div",{children:[o("span",{className:"text-primary/70",children:"category"}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground",children:me.category})]}),Object.entries(me.data).map(([Fn,ro])=>f("div",{children:[o("span",{className:"text-primary/70",children:Fn}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground break-all",children:typeof ro=="object"?JSON.stringify(ro):String(ro)})]},Fn))]})]})]},me.id)})})]})]})}function YD({search:e,onSearchChange:t,categories:n,active:r,onToggle:s,onSelectAll:a,onSelectNone:i,onResetDefaults:l}){return f("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:[f("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[o(Mo,{className:"h-3 w-3 text-foreground-subtle"}),o("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&&o("button",{type:"button",onClick:()=>t(""),className:"text-foreground-subtle hover:text-foreground",children:o(Je,{className:"h-2.5 w-2.5"})})]}),f("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[o("button",{type:"button",onClick:a,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"All"}),o("button",{type:"button",onClick:i,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"None"}),o("button",{type:"button",onClick:l,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"Defaults"})]}),f("div",{className:"overflow-y-auto flex-1",children:[n.length===0&&o("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-3 text-center",children:"No matches"}),n.map(c=>{const d=r.has(c),u=Vl(c),p=u.icon;return f("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:[o("input",{type:"checkbox",readOnly:!0,checked:d,className:"accent-violet-500"}),f("span",{className:K("inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[9px] font-medium shrink-0",u.color),children:[o(p,{className:"h-2.5 w-2.5"}),u.label]}),o("span",{className:"text-foreground-subtle font-mono truncate",children:c})]},c)})]})]})}function ZD({position:e="bottom",className:t,...n}){return o("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:o(br,{maxHeight:"max-h-48",...n})})}function ms({label:e,value:t}){return f("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function XD({copied:e,onCopy:t}){return o("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?o(qr,{className:"h-3 w-3"}):o(vn,{className:"h-3 w-3"})})}function hy({deviceId:e,className:t="",onOpenChild:n}){const r=S.useUtils(),s=S.deviceDiscovery.listDiscovered.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),a=S.deviceDiscovery.getStatus.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),i=S.deviceDiscovery.refreshDiscovery.useMutation({onSuccess:()=>{r.deviceDiscovery.listDiscovered.invalidate({deviceId:e}),r.deviceDiscovery.getStatus.invalidate({deviceId:e})}}),l=S.deviceDiscovery.adoptDevice.useMutation({onSuccess:()=>{r.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),c=S.deviceDiscovery.releaseDevice.useMutation({onSuccess:()=>{r.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),[d,u]=_(null),{available:p,adopted:h}=q(()=>{const v=s.data??[],N=C=>typeof C.metadata.rtspChannel=="number"?C.metadata.rtspChannel:Number.POSITIVE_INFINITY,k=(C,M)=>{const P=N(C),I=N(M);return P!==I?P-I:C.name.localeCompare(M.name)};return{available:v.filter(C=>!C.alreadyAdopted).sort(k),adopted:v.filter(C=>C.alreadyAdopted).sort(k)}},[s.data]),m=a.data,g=m?.lastError??null,b=m?.lastDiscoveryAt??null;async function x(){await i.mutateAsync({deviceId:e}).catch(()=>{})}async function y(v){u(v.childNativeId);try{await l.mutateAsync({deviceId:e,childNativeId:v.childNativeId})}finally{u(null)}}async function w(v){if(v.adoptedDeviceId!=null){u(v.childNativeId);try{await c.mutateAsync({deviceId:e,childDeviceId:v.adoptedDeviceId})}finally{u(null)}}}return f("div",{className:`rounded-xl border border-border bg-surface ${t}`,children:[f("div",{className:"flex items-start justify-between gap-2 border-b border-border px-3 py-2 sm:px-5 sm:py-3",children:[f("div",{className:"min-w-0",children:[o("h3",{className:"text-sm font-semibold text-foreground",children:"Discovered devices"}),f("p",{className:"text-[11px] text-foreground-subtle",children:["Channels behind this hub. Click ",o("span",{className:"font-medium",children:"Add"})," to promote a channel to a managed device, or ",o("span",{className:"font-medium",children:"Remove"})," to detach."]})]}),f("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?o(Mt,{className:"h-3.5 w-3.5 animate-spin"}):o(_a,{className:"h-3.5 w-3.5"}),o("span",{className:"hidden sm:inline",children:"Refresh"})]})]}),g?f("div",{className:"flex items-start gap-2 border-b border-border bg-destructive/10 px-5 py-2 text-[11px] text-destructive",children:[o(Qr,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),f("span",{children:["Last refresh failed: ",g]})]}):null,s.isLoading?o("div",{className:"flex items-center justify-center py-8 text-foreground-subtle",children:o(Mt,{className:"h-5 w-5 animate-spin"})}):p.length===0&&h.length===0?o("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."}):f(he,{children:[p.length>0?o(Ep,{title:"Available to add",count:p.length,tone:"primary",children:p.map(v=>o(Ip,{child:v,busy:d===v.childNativeId,onAdopt:y,onRelease:w,onOpenChild:n},v.childNativeId))}):null,h.length>0?o(Ep,{title:"Already adopted",count:h.length,tone:"muted",children:h.map(v=>o(Ip,{child:v,busy:d===v.childNativeId,onAdopt:y,onRelease:w,onOpenChild:n},v.childNativeId))}):null]}),b!=null?f("div",{className:"border-t border-border px-5 py-2 text-[10px] text-foreground-subtle",children:["Last refreshed ",new Date(b).toLocaleString()]}):null]})}function Ep({title:e,count:t,tone:n,children:r}){return f("div",{className:"border-t border-border",children:[f("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:[o("span",{className:"font-semibold",children:e}),o("span",{className:"font-mono",children:t})]}),o("div",{className:"divide-y divide-border",children:r})]})}function Ip({child:e,busy:t,onAdopt:n,onRelease:r,onOpenChild:s}){return f("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:[f("div",{className:"min-w-0 flex-1",children:[f("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[o(JD,{status:e.status}),o("span",{className:"truncate text-sm font-medium text-foreground",children:e.name}),e.metadata.isDoorbell?o("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?o("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?o("span",{className:"rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle",children:"Multifocal"}):null]}),f("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"?f("span",{children:["ch ",o("span",{className:"font-mono",children:e.metadata.rtspChannel})]}):null,e.metadata.model?o("span",{className:"truncate max-w-[160px]",children:e.metadata.model}):null,e.metadata.uid?f("span",{className:"font-mono truncate max-w-[140px]",children:[e.metadata.uid.slice(0,12),"…"]}):null]})]}),e.alreadyAdopted?f("div",{className:"flex items-center gap-2",children:[s&&e.adoptedDeviceId!==null?f("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:[o(Pc,{className:"h-3.5 w-3.5"}),"Open"]}):null,f("button",{type:"button",onClick:()=>{r(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?o(Mt,{className:"h-3.5 w-3.5 animate-spin"}):o(Jt,{className:"h-3.5 w-3.5"}),"Remove"]})]}):f("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?o(Mt,{className:"h-3.5 w-3.5 animate-spin"}):o(Go,{className:"h-3.5 w-3.5"}),"Add"]})]})}function JD({status:e}){switch(e){case"online":return f("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:[o(Xm,{className:"h-2.5 w-2.5"})," online"]});case"sleeping":return f("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:[o($c,{className:"h-2.5 w-2.5"})," sleeping"]});case"offline":return f("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:[o(CC,{className:"h-2.5 w-2.5"})," offline"]});case"unknown":default:return f("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:[o(Bm,{className:"h-2.5 w-2.5"})," unknown"]})}}function eL(e,t){if(!e||typeof e!="object")return!1;const n=e;if(n.category!==Ne.DeviceStateChanged)return!1;const r=n.data;return!(!r||typeof r!="object"||r.deviceId!==t||typeof r.capName!="string"||!r.slice||typeof r.slice!="object")}function Ti(e){if(!e||typeof e!="object")return null;const t=e,n=typeof t.id=="string"?t.id:null,r=typeof t.timestamp=="string"?t.timestamp:null,s=t.data;return!n||!r||!s||typeof s!="object"||typeof s.capName!="string"||!s.slice||typeof s.slice!="object"?null:{id:n,timestamp:r,capName:s.capName,slice:s.slice}}const tL=300,nL=Object.freeze([...new Set(x2.filter(e=>e.scope==="device").map(e=>e.name))].sort());function Cd({deviceId:e,defaultCaps:t,maxHeight:n="max-h-96",limit:r=50,liveBuffer:s,onClose:a,className:i}){const l=q(()=>new Set(t??[]),[t]),[c,d]=_(l),[u,p]=_(""),[h,m]=_(!0),[g,b]=_(new Set),[x,y]=_(0),[w,v]=_(!1),[N,k]=_(""),C=te(null),M=Wn(tL),P=s??M,I=P.entries,z=te(null),A=te(e);Y(()=>{A.current!==e&&(A.current=e,P.reset(),b(new Set),y(0))},[e,P]);const O=q(()=>({deviceId:e,category:Ne.DeviceStateChanged,limit:r}),[e,r]),{data:R,isLoading:E}=S.systemEvents.getRecent.useQuery(O,{staleTime:3e4}),D=te(c);Y(()=>{D.current=c},[c]),S.systemEvents.subscribe.useSubscription({deviceId:e,category:Ne.DeviceStateChanged},{onData:Q=>{if(!eL(Q,e))return;const le=Ti(Q);if(!le)return;const ue=D.current;ue.size>0&&!ue.has(le.capName)||P.append(le)}});const L=te(I.length);Y(()=>{const Q=z.current;if(!Q){L.current=I.length;return}const le=L.current;if(L.current=I.length,!(I.length<=le)){if(h&&Q.scrollTop<=8)Q.scrollTo({top:0});else if(!h&&Q.scrollTop>0){const ue=Q.firstElementChild?.firstElementChild,de=ue instanceof HTMLElement?ue.offsetHeight:28,ce=I.length-le;Q.scrollTop+=de*ce}}},[I.length,h]);const T=q(()=>{const Q=new Map;for(const de of R??[]){const ce=Ti(de);ce&&Q.set(ce.id,ce)}for(const de of I)Q.set(de.id,de);let le=[...Q.values()];x>0&&(le=le.filter(de=>new Date(de.timestamp).getTime()>x)),c.size>0&&(le=le.filter(de=>c.has(de.capName)));const ue=u.trim().toLowerCase();return ue&&(le=le.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(([Ce,pe])=>`${Ce}=${Ri(pe)}`).join(" · ").toLowerCase().includes(ue))return!0}catch{}try{if(JSON.stringify(de.slice).toLowerCase().includes(ue))return!0}catch{}return!1})),le.sort((de,ce)=>new Date(ce.timestamp).getTime()-new Date(de.timestamp).getTime())},[R,I,c,u,x]),B=q(()=>{const Q=new Set(nL);for(const le of R??[]){const ue=Ti(le);ue&&Q.add(ue.capName)}for(const le of I)Q.add(le.capName);return[...Q].sort()},[R,I]),F=U(Q=>{b(le=>{const ue=new Set(le);return ue.has(Q)?ue.delete(Q):ue.add(Q),ue})},[]),j=U(Q=>{d(le=>{const ue=new Set(le);return ue.has(Q)?ue.delete(Q):ue.add(Q),ue})},[]),V=U(()=>{d(new Set(t??[])),p("")},[t]),$=U(()=>{y(Date.now()),P.reset()},[P]),[H,G]=_(!1),[Z,oe]=_(null),ne=U(Q=>`${new Date(Q.timestamp).toISOString()} [${Q.capName}] slice=${JSON.stringify(Q.slice)}`,[]),X=U(()=>{const Q=T.map(ne);navigator.clipboard.writeText(Q.join(`
|
|
562
|
+
`)).then(()=>{G(!0),setTimeout(()=>G(!1),1500)})},[T,ne]),re=U(Q=>{navigator.clipboard.writeText(ne(Q)).then(()=>{oe(Q.id),setTimeout(()=>oe(le=>le===Q.id?null:le),1200)})},[ne]),be=U(()=>{d(new Set(B))},[B]),J=U(()=>{d(new Set)},[]),W=q(()=>{const Q=N.trim().toLowerCase();return Q?B.filter(le=>le.toLowerCase().includes(Q)):B},[N,B]),ee=B.length,ae=c.size,fe=ae===0||ae===ee,ge=fe?"All":`${ae}/${ee}`;return Y(()=>{if(!w)return;const Q=le=>{const ue=C.current;ue&&!ue.contains(le.target)&&v(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[w]),f("div",{className:K("h-full min-h-0 flex flex-col",i),onClick:Q=>Q.stopPropagation(),children:[f("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[f("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"State"}),o(rL,{label:"device",value:`#${e}`}),f("button",{type:"button",onClick:()=>{m(Q=>!Q),!h&&z.current&&z.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",h?"border-border text-foreground-subtle hover:text-foreground":"border-amber-500/30 bg-amber-500/10 text-amber-400"),children:[o(Ic,{className:"h-2.5 w-2.5"}),h?"Auto":"Paused"]}),f("div",{className:"relative",ref:C,children:[f("button",{type:"button",onClick:()=>v(Q=>!Q),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:[o(Vm,{className:"h-2.5 w-2.5"}),"Filter (",ge,")"]}),w&&o(oL,{search:N,onSearchChange:k,caps:W,active:c,onToggle:j,onSelectAll:be,onSelectNone:J,onResetDefaults:V})]}),f("button",{type:"button",onClick:V,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:[o(Km,{className:"h-2.5 w-2.5"}),"Reset"]}),f("button",{type:"button",onClick:$,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:[o(Jt,{className:"h-2.5 w-2.5"}),"Clear"]}),f("button",{type:"button",onClick:X,disabled:T.length===0,className:K("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",H?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",T.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible state changes",children:[o(vn,{className:"h-2.5 w-2.5"}),H?"Copied!":"Copy"]}),f("div",{className:"relative",children:[o("input",{type:"text",value:u,onChange:Q=>p(Q.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"}),u&&o("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:o(Je,{className:"h-2.5 w-2.5"})})]}),I.length>0&&f("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",I.length," live"]})]}),a&&o("button",{type:"button",onClick:a,className:"text-foreground-subtle hover:text-foreground",children:o(Je,{className:"h-3.5 w-3.5"})})]}),f("div",{ref:z,className:K("flex-1 min-h-0 overflow-auto text-[10px]",n),children:[E&&f("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[o(Mt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading state changes..."]}),!E&&T.length===0&&o("div",{className:"py-4 text-center text-foreground-subtle",children:"No state changes"}),T.length>0&&o("div",{className:"divide-y divide-border/30",children:T.map(Q=>{const le=g.has(Q.id),ue=Object.entries(Q.slice),de=ue.slice(0,3).map(([ce,Ce])=>`${ce}=${Ri(Ce)}`).join(" · ");return f("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>F(Q.id),children:[o("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(Q.timestamp).toLocaleTimeString()}),o(sL,{copied:Z===Q.id,onCopy:()=>re(Q)}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-1.5",children:[le?o(pr,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):o(Rn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),o("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:Q.capName}),ue.length>3&&f("span",{className:"text-[9px] text-foreground-subtle",children:["+",ue.length-3," more"]})]}),de&&o("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5 truncate",children:de}),le&&o("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?o("div",{className:"text-foreground-subtle italic",children:"empty slice"}):ue.map(([ce,Ce])=>f("div",{children:[o("span",{className:"text-primary/70",children:ce}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground break-all",children:Ri(Ce)})]},ce))})]})]},Q.id)})})]})]})}function Ri(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 rL({label:e,value:t}){return f("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function oL({search:e,onSearchChange:t,caps:n,active:r,onToggle:s,onSelectAll:a,onSelectNone:i,onResetDefaults:l}){return f("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:[f("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[o(Mo,{className:"h-3 w-3 text-foreground-subtle"}),o("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&&o("button",{type:"button",onClick:()=>t(""),className:"text-foreground-subtle hover:text-foreground",children:o(Je,{className:"h-2.5 w-2.5"})})]}),f("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[o("button",{type:"button",onClick:a,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"All"}),o("button",{type:"button",onClick:i,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"None"}),o("button",{type:"button",onClick:l,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"Defaults"})]}),f("div",{className:"overflow-y-auto flex-1",children:[n.length===0&&o("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-3 text-center",children:"No matches"}),n.map(c=>{const d=r.has(c);return f("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:[o("input",{type:"checkbox",readOnly:!0,checked:d,className:"accent-violet-500"}),o("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 sL({copied:e,onCopy:t}){return o("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?o(qr,{className:"h-3 w-3"}):o(vn,{className:"h-3 w-3"})})}const Oi=500,aL=[{id:"logs",label:"Logs",icon:GS},{id:"events",label:"Events",icon:Pa},{id:"state",label:"State",icon:G5}];function iL({deviceId:e,defaultEventCategories:t,defaultStateCaps:n,initialTab:r="events",className:s,maxHeight:a="max-h-96"}){const[i,l]=_(r),c=Wn(Oi),d=Wn(Oi),u=Wn(Oi),p=c.reset,h=d.reset,m=u.reset;return Y(()=>{p(),h(),m()},[e,p,h,m]),f("div",{className:K("flex flex-col h-full min-h-0",s),children:[o("div",{className:"flex items-center gap-1 mb-2 shrink-0",children:aL.map(({id:g,label:b,icon:x})=>f("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:[o(x,{className:"h-3.5 w-3.5"}),b]},g))}),f("div",{className:"flex-1 min-h-0 overflow-hidden",children:[i==="logs"&&o(Ht,{deviceId:e,maxHeight:a,showFilters:!1,liveBuffer:c}),i==="events"&&o(br,{deviceId:e,defaultCategories:t,maxHeight:a,showCategoryFilter:!0,liveBuffer:d}),i==="state"&&o(Cd,{deviceId:e,defaultCaps:n,maxHeight:a,liveBuffer:u})]})]})}function Md({label:e,icon:t,title:n="Confirm action",description:r,confirmLabel:s,triggerVariant:a="outline",confirmVariant:i="danger",size:l="sm",disabled:c,className:d,action:u,onSuccess:p}){const[h,m]=_(!1),[g,b]=_(!1),[x,y]=_(null),w=async()=>{y(null),b(!0);try{const v=await u();p?.(v),m(!1)}catch(v){y(v instanceof Error?v.message:String(v))}finally{b(!1)}};return f(he,{children:[f(Re,{type:"button",variant:a,size:l,disabled:c,onClick:()=>{y(null),m(!0)},className:d,children:[t&&o(t,{className:"h-3.5 w-3.5"}),e]}),o(og,{open:h,onOpenChange:v=>!g&&m(v),children:f(Bc,{children:[f(sg,{children:[f(ig,{className:"flex items-center gap-2",children:[o(Qr,{className:"h-4 w-4 text-amber-400"}),n]}),typeof r=="string"?o(lg,{children:r}):r]}),x&&o("div",{className:K("mt-2 px-3 py-2 rounded border border-danger/40 bg-danger/10","text-xs text-danger"),children:x}),f(ag,{children:[o(Re,{type:"button",variant:"ghost",size:l,disabled:g,onClick:()=>m(!1),children:"Cancel"}),f(Re,{type:"button",variant:i,size:l,disabled:g,onClick:()=>{w()},children:[g&&o(Mt,{className:"h-3.5 w-3.5 animate-spin"}),s??e]})]})]})})]})}function gs({direction:e,icon:t,disabled:n,className:r,variant:s,onMove:a,onStart:i,onStop:l}){const[c,d]=_(null),[u,p]=_(!1),h=U(w=>{if(n)return;w.currentTarget.setPointerCapture(w.pointerId),d(Date.now()),p(!1);const v=setTimeout(()=>{p(!0),i(e)},250);w.currentTarget.dataset.timer=String(v)},[e,n,i]),m=U(w=>{const v=Number(w.currentTarget.dataset.timer);v&&clearTimeout(v),w.currentTarget.dataset.timer="",u?l():c!==null&&a(e),d(null),p(!1)},[u,e,a,l,c]),g=U(w=>{const v=Number(w.currentTarget.dataset.timer);v&&clearTimeout(v),w.currentTarget.dataset.timer="",u&&l(),d(null),p(!1)},[u,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 o("button",{type:"button",disabled:n,onPointerDown:h,onPointerUp:m,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,r),title:e,children:o(t,{className:x})})}function Ed({controls:e,mode:t="overlay",showPresets:n,showZoom:r=!0,showHome:s=!0,className:a}){const{move:i,startContinuous:l,stopContinuous:c,zoom:d,goHome:u,goToPreset:p,presets:h,busy:m,error:g}=e,[b,x]=_(!1),y=(n??h.length>0)&&h.length>0,w=t==="panel",v=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",m&&"ring-1 ring-primary/40"),k=w?"h-9 w-9":"h-7 w-7",C=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 f("div",{className:K(v,a),children:[g&&f("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]}),f("div",{className:K(N,w&&"justify-center"),children:[f("div",{className:"grid grid-cols-3 gap-0.5",children:[o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),o(gs,{direction:"up",icon:s5,variant:t,onMove:i,onStart:l,onStop:c}),o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),o(gs,{direction:"left",icon:e5,variant:t,onMove:i,onStart:l,onStop:c}),o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),o(gs,{direction:"right",icon:n5,variant:t,onMove:i,onStart:l,onStop:c}),o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),o(gs,{direction:"down",icon:Xk,variant:t,onMove:i,onStart:l,onStop:c}),o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"})]}),(r||s)&&o("div",{className:P}),f("div",{className:"flex flex-col gap-0.5",children:[r&&f(he,{children:[o("button",{type:"button",onClick:()=>d("in"),disabled:m,title:"Zoom in",className:K("flex items-center justify-center rounded disabled:opacity-40",k,M),children:o(_C,{className:C})}),o("button",{type:"button",onClick:()=>d("out"),disabled:m,title:"Zoom out",className:K("flex items-center justify-center rounded disabled:opacity-40",k,M),children:o(DC,{className:C})})]}),s&&o("button",{type:"button",onClick:()=>u(),disabled:m,title:"Go home",className:K("flex items-center justify-center rounded disabled:opacity-40",k,M),children:o(Hm,{className:C})})]}),y&&f("div",{className:"relative",children:[f("button",{type:"button",onClick:()=>x(I=>!I),disabled:m,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",o(pr,{className:K("h-3 w-3 transition-transform",b&&"rotate-180")})]}),b&&o("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:h.map(I=>o("button",{type:"button",onClick:()=>{p(I.id),x(!1)},disabled:m,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 lL(e,t){const n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function cL({trpc:e,deviceId:t,deviceName:n,size:r="sm",className:s}){const[a,i]=_(!1),[l,c]=_(!1),[d,u]=_(null),p=n.replace(/[^a-zA-Z0-9_.-]+/g,"_"),h=U(async k=>{i(!0),u(null),c(!1);try{const C=await e.snapshot.getSnapshot.query({deviceId:t,force:!0});if(!C)throw new Error("No snapshot available");const M=`data:${C.contentType};base64,${C.base64}`;if(k==="copy")try{await navigator.clipboard.writeText(M)}catch{throw new Error("Clipboard unavailable")}else{const P=C.contentType.includes("png")?"png":"jpg",I=new Date().toISOString().replace(/[:.]/g,"-");lL(`${p}-${I}.${P}`,M)}c(!0),setTimeout(()=>c(!1),1500)}catch(C){u(C instanceof Error?C.message:String(C))}finally{i(!1)}},[e,t,p]),m=r==="md"?"h-9 px-3 text-sm gap-2":"h-7 px-2.5 text-[11px] gap-1.5",[g,b]=_(null),[x,y]=_(!1),w=()=>{y(!1);const k=setTimeout(()=>{y(!0),h("copy")},600);b(k)},v=()=>{g&&(clearTimeout(g),b(null)),x||h("download")},N=()=>{g&&(clearTimeout(g),b(null))};return f("button",{type:"button",title:"Click to download · long-press to copy",disabled:a,onPointerDown:w,onPointerUp:v,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",m,d&&"border-danger/40 text-danger",s),children:[a?o(Mt,{className:"h-3.5 w-3.5 animate-spin"}):l?o(qr,{className:"h-3.5 w-3.5 text-success"}):o(Ac,{className:"h-3.5 w-3.5"}),"Snapshot"]})}function dL(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 Id({history:e,limit:t=5,latestIsFresh:n,className:r}){if(e.length===0)return null;const s=n?h5:Pa,a=e.slice(0,t);return f("div",{className:K("rounded-lg border border-border bg-surface px-3 py-2",r),children:[f("div",{className:"flex items-center gap-2 mb-2",children:[o(s,{className:K("h-4 w-4 text-amber-400",n&&"animate-pulse")}),o("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle",children:"Recent presses"}),o("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})]}),o("ul",{className:"space-y-1",children:a.map(i=>f("li",{className:"flex items-center justify-between text-[11px]",title:new Date(i.timestamp).toLocaleString(),children:[o("span",{className:"text-foreground",children:dL(i.timestamp)}),o("span",{className:"text-foreground-subtle font-mono text-[10px]",children:new Date(i.timestamp).toLocaleTimeString()})]},`${i.deviceId}-${i.timestamp}`))})]})}function my({items:e,header:t,triggerClassName:n,title:r="More actions"}){const[s,a]=_(!1),i=e.filter(l=>!l.hidden);return i.length===0?null:f(Ng,{open:s,onOpenChange:a,children:[o(kg,{title:r,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:o(jm,{className:"h-4 w-4"})}),f(Sg,{className:"left-auto right-0 mt-1 min-w-[200px] p-1",children:[t&&o("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wider text-foreground-subtle",children:t}),o("ul",{className:"space-y-0.5",children:i.map((l,c)=>f("li",{children:[l.separatorBefore&&c>0&&o("div",{className:"my-1 h-px bg-border"}),f("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&&o(l.icon,{className:K("h-3.5 w-3.5 shrink-0 mt-0.5",l.danger&&"text-danger/80")}),f("span",{className:"flex-1 min-w-0",children:[o("span",{className:"block leading-tight",children:l.label}),l.description&&o("span",{className:"block mt-0.5 text-[10px] text-foreground-subtle leading-tight",children:l.description})]})]})]},l.id))})]})]})}const uL=[{value:"view",label:"View",icon:Ur,hint:"Read-only — queries + subscriptions"},{value:"create",label:"Create",icon:ES,hint:"Mutations that create or update"},{value:"delete",label:"Delete",icon:Jt,hint:"Destructive ops (delete/revoke/reset/…)"}],pL=["device","system"];function fL(){return{type:"capability",target:"",access:["view"]}}function hL(e){if(e==null)return[];const t=new Set;for(const n of e)if(n.type==="device")for(const r of n.targets)t.add(r);return[...t]}function mL(e,t,n,r){let s;switch(e){case"addon":s=n;break;case"capability":s=r;break;case"category":s=pL.map(i=>({value:i,label:i}));break}if(t==null)return s;const a=new Set(t.filter(i=>i.type!=="device"&&i.type===e).map(i=>i.target));return s.filter(i=>a.has(i.value))}function gL(e,t){if(t==null)return["view","create","delete"];const n=t.filter(s=>s.type!==e.type?!1:s.type==="device"&&e.type==="device"?s.targets.some(a=>e.targets.includes(a)):s.type!=="device"&&e.type!=="device"?s.target===e.target:!1);if(n.length===0)return[];const r=new Set;for(const s of n)for(const a of s.access)r.add(a);return[...r]}function Ad({value:e,onChange:t,clampToParent:n,emptyHint:r}){const{data:s}=Ko(),{data:a}=On({}),i=q(()=>(s??[]).map(g=>({value:g.manifest.id,label:g.manifest.id})).sort((g,b)=>g.label.localeCompare(b.label)),[s]),l=q(()=>[...y2].sort().map(g=>({value:g,label:g})),[]),c=q(()=>(a??[]).map(g=>({value:String(g.id),label:`${g.name} (#${g.id} · ${g.addonId})`})).sort((g,b)=>g.label.localeCompare(b.label)),[a]),d=q(()=>n==null?null:hL(n),[n]),u=(g,b)=>{const x=[...b];switch(g){case"category":return{type:"category",target:"device",access:x};case"capability":return{type:"capability",target:"",access:x};case"addon":return{type:"addon",target:"",access:x};case"device":return{type:"device",targets:[],access:x}}},p=(g,b)=>{t(e.map((x,y)=>{if(y!==g)return x;if(b.type!==void 0&&b.type!==x.type)return u(b.type,b.access??x.access);const w=[...b.access??x.access];return x.type==="device"?{type:"device",targets:[...b.targets??x.targets],access:w}:x.type==="category"?{type:"category",target:b.target??x.target,access:w}:x.type==="capability"?{type:"capability",target:b.target??x.target,access:w}:{type:"addon",target:b.target??x.target,access:w}}))},h=g=>{t(e.filter((b,x)=>x!==g))},m=()=>{t([...e,fL()])};return f("div",{className:"space-y-2",children:[e.length===0&&r&&o("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-2",children:r}),e.map((g,b)=>{const x=gL(g,n);return f("div",{className:"flex flex-wrap items-start gap-1.5 rounded border border-border bg-surface px-2 py-1.5",children:[f("select",{value:g.type,onChange:y=>p(b,{type:y.target.value}),className:"rounded border border-border bg-background px-2 py-1 text-[11px] focus:outline-none focus:ring-1 focus:ring-primary",children:[o("option",{value:"category",children:"category"}),o("option",{value:"capability",children:"capability"}),o("option",{value:"addon",children:"addon"}),o("option",{value:"device",children:"device"})]}),g.type==="device"?o(bL,{value:g.targets,choices:c,clampToParent:d,onChange:y=>p(b,{targets:y})}):f("select",{value:g.target,onChange:y=>p(b,{target:y.target.value}),className:"flex-1 min-w-[160px] rounded border border-border bg-background px-2 py-1 text-[11px] font-mono focus:outline-none focus:ring-1 focus:ring-primary",children:[f("option",{value:"",children:["— pick ",g.type," —"]}),mL(g.type,n,i,l).map(y=>o("option",{value:y.value,children:y.label},y.value))]}),o("div",{className:"flex items-center gap-1",children:uL.map(({value:y,label:w,icon:v,hint:N})=>{const k=g.access.includes(y),C=n!=null&&!x.includes(y)&&!k;return f("label",{title:C?`${N} — not granted by your scope`:N,className:`inline-flex items-center gap-1 rounded px-1.5 py-1 text-[10px] cursor-pointer transition-colors ${k?"bg-primary/15 text-primary font-medium":"text-foreground-subtle hover:bg-foreground-subtle/10"} ${C?"opacity-40 cursor-not-allowed":""}`,children:[o("input",{type:"checkbox",checked:k,disabled:C,onChange:M=>{const P=new Set(g.access);M.target.checked?P.add(y):P.delete(y),p(b,{access:[...P]})},className:"sr-only"}),o(v,{className:"h-3 w-3"}),w]},y)})}),o("button",{type:"button",onClick:()=>h(b),className:"rounded p-1 text-foreground-subtle hover:bg-danger/10 hover:text-danger transition-colors",title:"Remove scope",children:o(Je,{className:"h-3 w-3"})})]},b)}),f("button",{type:"button",onClick:m,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 transition-colors",children:[o(Go,{className:"h-3 w-3"}),"Add scope"]})]})}function bL({value:e,choices:t,clampToParent:n,onChange:r}){const[s,a]=_(""),i=q(()=>{const u=n==null?t:t.filter(h=>n.includes(h.value)),p=new Set(e);return u.filter(h=>!p.has(h.value))},[t,n,e]),l=u=>t.find(p=>p.value===u)?.label??`#${u}`,c=u=>{u&&(r([...e,u]),a(""))},d=u=>{r(e.filter(p=>p!==u))};return f("div",{className:"flex-1 min-w-[160px] flex flex-wrap items-center gap-1",children:[e.length===0&&o("span",{className:"text-[10px] text-foreground-subtle italic px-1",children:"no devices selected"}),e.map(u=>f("span",{className:"inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-mono text-primary",children:[l(u),o("button",{type:"button",onClick:()=>d(u),className:"hover:text-danger transition-colors",title:"Remove device",children:o(Je,{className:"h-2.5 w-2.5"})})]},u)),i.length>0&&f("select",{value:s,onChange:u=>c(u.target.value),className:"rounded border border-border bg-background px-1.5 py-0.5 text-[10px] focus:outline-none focus:ring-1 focus:ring-primary",children:[o("option",{value:"",children:"+ add device…"}),i.map(u=>o("option",{value:u.value,children:u.label},u.value))]})]})}function Pd(e){for(const t of e){if(t.type==="device"){if(t.targets.length===0)return"Scope device: pick at least one device"}else if(t.target.trim().length===0)return`Scope ${t.type}: pick a target`;if(t.access.length===0){const n=t.type==="device"?`[${t.targets.join(",")}]`:t.target;return`Scope ${t.type}:${n}: pick at least one access`}}return null}const gy=yn("camstack:zone-editing",null);function by({children:e}){const[t,n]=_(!1),[r,s]=_(null),[a,i]=_(null),[l,c]=_(null),d=U(w=>{n(w),w||(s(null),i(null),c(null))},[]),u=U(w=>{s(w)},[]),p=U(w=>{i(w)},[]),h=U(w=>{n(!0),i(null),s(w),c(null)},[]),m=U(()=>{n(!1),s(null),i(null),c(null)},[]),g=U(w=>{i(w.id),c(w)},[]),b=U(w=>{c(v=>v===null?v:{...v,...w})},[]),x=U(()=>{c(null)},[]),y=q(()=>({editing:t,drawingKind:r,selectedZoneId:a,editingDraft:l,setEditing:d,setDrawingKind:u,setSelectedZoneId:p,startDrawing:h,exitEditing:m,enterDraft:g,updateDraft:b,discardDraft:x}),[t,r,a,l,d,u,p,h,m,g,b,x]);return o(gy.Provider,{value:y,children:e})}function xL(){return ve(gy)}const Ap=500,yL=800;function bs(e,t,n){try{const r=e.live;if(!r)return null;const s=r.onEvent;return!s||typeof s.subscribe!="function"?null:s.subscribe({category:t},{onData:n})}catch{return null}}function xs(e,t){return e?.id===t}function xy(e,t){const[n,r]=_(null),[s,a]=_(null),[i,l]=_(null),[c,d]=_("watching"),u=te(void 0),p=te(void 0),h=te(void 0);return Y(()=>{if(t===null)return;const m=bs(e,"detection.motion-analysis",g=>{const b=g;if(!xs(b?.source,t))return;const x=b.data;!x?.regions||x.regions.length===0||(r({zones:x.regions.map(y=>({...y.bbox,intensity:y.intensity})),frameWidth:x.frameWidth,frameHeight:x.frameHeight}),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>r(null),Ap))});return()=>{m?.unsubscribe(),u.current&&clearTimeout(u.current)}},[e,t]),Y(()=>{if(t===null)return;const m=bs(e,"detection.motion-zones-raw",g=>{const b=g;if(!xs(b?.source,t))return;const x=b.data;x?.zones&&(a({boxes:x.zones.map(y=>({bbox:y.bbox,changeScore:y.changeScore})),frameWidth:x.frameSize?.width??0,frameHeight:x.frameSize?.height??0,motionScore:x.zones.length>0?x.zones.reduce((y,w)=>y+w.changeScore,0)/x.zones.length:0}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>a(null),Ap))});return()=>{m?.unsubscribe(),p.current&&clearTimeout(p.current)}},[e,t]),Y(()=>{if(t===null)return;const m=bs(e,"detection.result",g=>{const b=g;if(!xs(b?.source,t))return;const x=b.data?.frame;x?.detections?.length&&(l({detections:x.detections,frameWidth:x.width,frameHeight:x.height}),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>l(null),yL))});return()=>{m?.unsubscribe(),h.current&&clearTimeout(h.current)}},[e,t]),Y(()=>{if(t===null)return;const m=bs(e,"detection.phase-transition",g=>{const b=g;xs(b?.source,t)&&b.data?.to&&d(b.data.to)});return()=>{m?.unsubscribe()}},[e,t]),{motion:n,motionRaw:s,detection:i,phase:c}}function _d(e,t,n=5e3){const[r,s]=_([]);Y(()=>{if(t===null)return;let h=!1;const m=()=>{e.webrtcSession.listStreams.query({deviceId:t}).then(b=>{h||s(b)}).catch(()=>{})};m();const g=setInterval(m,n);return()=>{h=!0,clearInterval(g)}},[e,t,n]);const[a,i]=_(null);Y(()=>{if(t===null)return;let h=!1;return e.pipelineOrchestrator&&e.pipelineOrchestrator.getCameraMetrics.query({deviceId:t}).then(m=>{h||!m||i({phase:m.phase,detectionFps:m.actualFps,avgInferenceMs:m.avgInferenceTimeMs,droppedFrames:m.droppedFrames})}).catch(()=>{}),()=>{h=!0}},[e,t]),bt("pipeline.camera-metrics-snapshot",h=>{if(t===null)return;const m=h.data;m.deviceId!==t||!m.metrics||i({phase:m.metrics.phase,detectionFps:m.metrics.actualFps,avgInferenceMs:m.metrics.avgInferenceTimeMs,droppedFrames:m.metrics.droppedFrames})});const{streams:l,hasWebrtc:c}=q(()=>t===null||r.length===0?{streams:[],hasWebrtc:!1}:{streams:r.map(m=>({id:m.id,label:m.label,target:m.target,status:m.status,inputFps:m.inputFps,decodeFps:m.decodeFps,bitrateKbps:m.bitrateKbps})),hasWebrtc:!0},[t,r]),d=U(async(h,m)=>{if(t===null)throw new Error("No device selected");const g=await e.webrtcSession.createSession.mutate({deviceId:t,target:h,hints:m});return{sessionId:g.sessionId,sdpOffer:g.sdpOffer}},[e,t]),u=U(async(h,m)=>{if(t===null)throw new Error("No device selected");await e.webrtcSession.handleAnswer.mutate({deviceId:t,sessionId:h,sdpAnswer:m})},[e,t]),p=U(async h=>{t!==null&&await e.webrtcSession.closeSession.mutate({deviceId:t,sessionId:h}).catch(()=>{})},[e,t]);return{streams:l,hasWebrtc:c,pipelineMetrics:a,createSession:d,sendAnswer:u,closeSession:p}}const Pp={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 $d(e,t,n){const r=n?.defaultSpeed??.5,s=n?.pulseMs??250,a=n?.enabled??!0,l=At(e,a?t:null)?.ptz,[c,d]=_([]),[u,p]=_(!1),[h,m]=_(null),g=U(async()=>{if(!(!a||!l))try{const C=await l.getPresets({});d(C)}catch(C){const M=C instanceof Error?C.message:String(C);if(M.includes("provider not available")||M.includes("no 'ptz' binding"))return;m(M)}},[l,a]);Y(()=>{g()},[g]);const b=U(async C=>{if(!(!a||!l)){m(null),p(!0);try{return await C()}catch(M){m(M instanceof Error?M.message:String(M));return}finally{p(!1)}}},[a,l]),x=U(async(C,M)=>{if(!l)return;const P=Pp[C],I=M??r;await b(async()=>{await l.move({pan:P.pan,tilt:P.tilt,speed:I}),await new Promise(z=>setTimeout(z,s)),await l.stop({})})},[l,r,s,b]),y=U(async(C,M)=>{if(!l)return;const P=Pp[C],I=M??r;await b(()=>l.continuousMove({pan:P.pan,tilt:P.tilt,speed:I}))},[l,r,b]),w=U(async()=>{l&&await b(()=>l.stop({}))},[l,b]),v=U(async(C,M)=>{if(!l)return;const P=C==="in"?1:-1,I=M??r;await b(async()=>{await l.move({zoom:P,speed:I}),await new Promise(z=>setTimeout(z,s)),await l.stop({})})},[l,r,s,b]),N=U(async()=>{l&&await b(()=>l.goHome({}))},[l,b]),k=U(async C=>{l&&await b(()=>l.goToPreset({presetId:C}))},[l,b]);return{move:x,startContinuous:y,stopContinuous:w,zoom:v,goHome:N,goToPreset:k,presets:c,refreshPresets:g,busy:u,error:h}}function Dd(e){const t=e?.deviceId??null,n=e?.historyLimit??20,r=Gr("doorbell.onPressed",t!==null?i=>i.deviceId===t:void 0),[s,a]=_([]);return Y(()=>{r&&a(i=>{if(i.length>0&&i[0].deviceId===r.deviceId&&i[0].timestamp===r.timestamp)return i;const l=[r,...i];return l.length>n?l.slice(0,n):l})},[r,n]),{latest:r??null,history:s}}function vL(e){const t=Le(),n=q(()=>e?JSON.stringify(e):"",[e]),[r,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]),r}function wL(e){const t=Le(),[n,r]=_(()=>e===null?null:t.getDevice(e));return Y(()=>{if(e===null){r(null);return}const s=()=>{r(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 NL(e,t,n){const r=Le();return Ln({queryKey:e,queryFn:()=>t(r)(),...n})}function kL(e,t){const n=Le();return Gn({mutationFn:r=>e(n)(r),...t})}function SL(e,t){const n=Le(),r=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 u=JSON.parse(l),h=u.length===1&&Array.isArray(u[0])?u:[u];r.invalidateQueries({queryKey:h})};d();for(const u of i.split("|"))if(u)try{c.push(n.subscribeEvent(u,d))}catch{}return()=>{for(const u of c)u()}},[n,r,i,l,s])}const CL=Object.freeze(Object.defineProperty({__proto__:null,AddonGlobalSettingsForm:J$,AgentStepEditor:Ta,AppShell:S3,AudioClassificationList:RD,AudioLevelWaveform:DD,AudioWaveform:$D,BTN_COMPACT:Pk,BTN_COMPACT_DANGER:$k,BTN_COMPACT_PRIMARY:_k,BTN_COMPACT_WARNING:Dk,Badge:zt,BatteryBadge:Zc,BottomSheet:Fc,Breadcrumb:Hc,Button:Re,CHIP_ACTIVE:Rk,CHIP_BASE:Tk,CHIP_INACTIVE:Ok,CLASS_COLORS:po,CameraStreamPlayer:G0,Card:Ft,Checkbox:tg,CodeBlock:N3,CollapsibleCard:Jm,ConfigFormBuilder:U0,ConfigFormField:gr,ConfigSchemaField:La,ConfirmActionButton:Md,ConfirmDialogProvider:Lg,CopyButton:uy,CustomFieldRenderersProvider:eb,DEFAULT_COLOR:Wg,DataTable:$a,DetectionCanvas:MM,DetectionOverlay:Q0,DetectionResultTree:PM,DevShell:Xg,DeviceActivityPanel:iL,DeviceCard:M3,DeviceContextProvider:nb,DeviceExportPanel:py,DeviceGrid:E3,DeviceItem:Io,DeviceList:Ao,Dialog:og,DialogContent:Bc,DialogDescription:lg,DialogFooter:ag,DialogHeader:sg,DialogTitle:ig,DialogTrigger:jC,DiscoveryPanel:hy,DoorbellRecentPanel:Id,Dropdown:dg,DropdownContent:pg,DropdownItem:fg,DropdownTrigger:ug,EmptyState:Ra,ErrorBox:Oa,EventStream:br,FilterBar:k3,FloatingEventStream:ZD,FloatingLogStream:fy,FloatingPanel:YC,FormField:b3,GRID_GAP:Dm,GRID_PAIRED:Sk,GRID_QUICK_STATS:kk,INPUT_COMPACT:Lk,IconButton:Lc,ImageSelector:TM,InferenceConfigSelector:RM,Input:ta,KebabMenu:my,KeyValueList:w3,LIST_ROW:Lm,Label:Tc,LogStream:Ht,LoginForm:Yg,MobileDrawer:Vc,NodeMultiSelectField:H0,NodePicker:_g,NodeSelectField:V0,PHASE_CONFIG:Al,PTZOverlay:Ed,PageHeader:x3,PhaseIcon:Sd,PipelineBuilder:Xc,PipelineRuntimeSelector:kM,PipelineStep:js,PipelineTreeMatrix:Uc,PlayerOverlaysProvider:K0,Popover:Ng,PopoverContent:Sg,PopoverTrigger:kg,ProviderBadge:h3,QrCode:dy,ResponseLog:OD,SECTION_BODY:Nk,SECTION_CARD:vk,SECTION_HEADER:wk,SPLIT_PANEL_OUTER:Ck,SPLIT_PANEL_SIDE:Mk,STACK_GAP:$m,ScopePicker:Ad,ScrollArea:jc,Select:Eo,SemanticBadge:$g,Separator:Rc,Sidebar:Rl,SidebarItem:Tl,Skeleton:eg,SlideOverPanel:qc,SnapshotButton:cL,StatCard:v3,StateValuesStream:Cd,StatusBadge:p3,StepTimings:LM,StepTreeMaster:Ig,StreamBrokerSelector:bD,StreamPanel:kd,Switch:Oc,SystemProvider:Gc,TEXT_FIELD_LABEL:Ik,TEXT_HINT:ea,TEXT_METRIC:Il,TEXT_SECTION_LABEL:Ek,TEXT_VALUE:Ak,Tabs:QC,TabsContent:WC,TabsList:GC,TabsTrigger:KC,ThemeProvider:Xs,Tooltip:HC,TooltipContent:UC,TooltipTrigger:qC,VersionBadge:g3,WidgetRegistryProvider:O0,WidgetSlot:ht,ZoneEditingProvider:by,buildStepTreeFromSchema:Da,cn:K,createSharedContext:yn,createTheme:S2,darkColors:dm,defaultTheme:Ml,deriveDeviceKind:A3,ensureMfHostInit:Ec,getClassColor:gt,getPhaseVisual:ur,isFieldVisible:vd,lightColors:um,mirror:Tm,mountAddonPage:UM,providerIcons:LC,statusIcons:TC,themeToCss:A2,trpc:S,useAccessoriesGetStatus:QM,useAddonPagesListPages:Ba,useAddonSettingsGetDeviceSettings:r4,useAddonSettingsGetGlobalSettings:rd,useAddonSettingsUpdateDeviceSettings:xb,useAddonSettingsUpdateGlobalSettings:bb,useAddonWidgetsListWidgets:yb,useAddonsApplyAutoUpdateToAll:gb,useAddonsCustom:t4,useAddonsForceRefresh:ab,useAddonsGetAddonAutoUpdate:hb,useAddonsGetAutoUpdateSettings:fb,useAddonsGetLastRestart:lb,useAddonsGetLogs:GM,useAddonsGetVersions:ub,useAddonsInstallFromWorkspace:WM,useAddonsInstallPackage:td,useAddonsIsWorkspaceAvailable:YM,useAddonsList:Ko,useAddonsListCapabilityProviders:JM,useAddonsListFrameworkPackages:cb,useAddonsListPackages:KM,useAddonsListUpdates:nd,useAddonsListWorkspacePackages:ZM,useAddonsOnAddonLogs:n4,useAddonsReloadPackages:ob,useAddonsRestartAddon:Wo,useAddonsRestartServer:ib,useAddonsRetryLoad:pb,useAddonsRollbackPackage:XM,useAddonsSearchAvailable:sb,useAddonsSetAddonAutoUpdate:mb,useAddonsSetAutoUpdateSettings:e4,useAddonsUninstallPackage:rb,useAddonsUpdateFrameworkPackage:db,useAddonsUpdatePackage:Bl,useAlertsDismiss:Sb,useAlertsEmit:o4,useAlertsGetUnreadCount:wb,useAlertsList:vb,useAlertsMarkAllRead:kb,useAlertsMarkRead:Nb,useAlertsUpdate:s4,useAllWidgets:F0,useAudioAnalysisApplyDeviceSettingsPatch:c4,useAudioAnalysisGetDeviceLiveContribution:l4,useAudioAnalysisGetDeviceSettingsContribution:i4,useAudioAnalysisResolveDeviceSettings:a4,useAudioAnalyzerAnalyseChunk:d4,useAudioAnalyzerClassify:u4,useAudioAnalyzerDispose:f4,useAudioAnalyzerIsReady:p4,useAudioAnalyzerReprobeAudioEngine:Cb,useAudioCodecCanHandle:m4,useAudioCodecCloseSession:x4,useAudioCodecCreateDecodeSession:g4,useAudioCodecCreateEncodeSession:b4,useAudioCodecFlushEncode:k4,useAudioCodecListActiveSessions:S4,useAudioCodecListSupportedCodecs:h4,useAudioCodecPullEncoded:N4,useAudioCodecPullPcm:v4,useAudioCodecPushEncodedFrame:y4,useAudioCodecPushPcm:w4,useAudioMetricsGetCurrentSnapshot:C4,useAudioMetricsGetHistory:M4,useAuthenticationListProviders:od,useAuthenticationSetProviderEnabled:E4,useBackupDelete:Pb,useBackupGetEntries:Ib,useBackupList:I4,useBackupListArchives:ad,useBackupListDestinations:sd,useBackupListLocations:Eb,useBackupPreviewSchedule:$b,useBackupRestore:Ab,useBackupTrigger:Mb,useBackupUpsertDestinationPolicy:_b,useBatteryGetStatus:A4,useBrightnessGetStatus:_4,useBrightnessSetBrightness:P4,useCameraCredentialsGetCredentials:$4,useCameraCredentialsGetStatus:D4,useCameraStreamsGetBrokerStreams:T4,useCameraStreamsGetCameraStreams:L4,useCameraStreamsGetRtspEntries:Db,useClusterNodes:Kr,useConfirm:rt,useCustomFieldRenderer:tb,useDebouncedString:Kg,useDecoderCreateSession:B4,useDecoderDestroySession:z4,useDecoderGetInfo:O4,useDecoderGetStats:q4,useDecoderListActiveSessions:U4,useDecoderOpenStream:j4,useDecoderPullFrames:V4,useDecoderPushPacket:F4,useDecoderReprobeHwaccel:Lb,useDecoderSupportsCodec:R4,useDecoderUpdateConfig:H4,useDetectionPipelineApplyDeviceSettingsPatch:K4,useDetectionPipelineGetDeviceLiveContribution:G4,useDetectionPipelineGetDeviceSettingsContribution:Q4,useDevShell:FM,useDevice:wL,useDeviceBattery:Wc,useDeviceCapability:Wr,useDeviceDetections:xy,useDeviceDiscoveryAdoptDevice:W4,useDeviceDiscoveryGetStatus:Z4,useDeviceDiscoveryListDiscovered:Tb,useDeviceDiscoveryRefreshDiscovery:Rb,useDeviceDiscoveryReleaseDevice:Y4,useDeviceExportApplyDeviceSettingsPatch:nE,useDeviceExportExposeDevice:J4,useDeviceExportGetDeviceLiveContribution:tE,useDeviceExportGetDeviceSettingsContribution:eE,useDeviceExportGetStatus:id,useDeviceExportListExposedDevices:Ob,useDeviceExportListSupportedDeviceKinds:X4,useDeviceExportUnexposeDevice:Bb,useDeviceId:wn,useDeviceManagerAddLocation:uE,useDeviceManagerAdoptDevice:Yb,useDeviceManagerAllocateDeviceId:rE,useDeviceManagerCreateDevice:Xb,useDeviceManagerDisable:qb,useDeviceManagerDiscoverDevices:cd,useDeviceManagerEnable:Hb,useDeviceManagerGetAllBindings:NE,useDeviceManagerGetBindings:Qb,useDeviceManagerGetChildren:Vb,useDeviceManagerGetConfigSchema:gE,useDeviceManagerGetCreationSchema:Zb,useDeviceManagerGetDevice:Jn,useDeviceManagerGetDeviceAggregate:ld,useDeviceManagerGetDeviceLiveInfoAggregate:CE,useDeviceManagerGetDeviceSettingsAggregate:SE,useDeviceManagerGetDeviceStatusAggregate:IE,useDeviceManagerGetSettingsSchema:bE,useDeviceManagerGetStreamProfileMap:yE,useDeviceManagerGetStreamSources:mE,useDeviceManagerListAll:On,useDeviceManagerListBindableCapsForDeviceType:Kb,useDeviceManagerListLocations:jb,useDeviceManagerListPersistedByAddon:hE,useDeviceManagerListWrappersForCap:kE,useDeviceManagerLoadConfig:iE,useDeviceManagerLoadMeta:cE,useDeviceManagerLoadRuntimeState:lE,useDeviceManagerPersistConfig:aE,useDeviceManagerProbeStreams:wE,useDeviceManagerRegisterDevice:oE,useDeviceManagerRemove:Ub,useDeviceManagerRemoveDevice:sE,useDeviceManagerRemoveLocation:pE,useDeviceManagerSetDisabled:fE,useDeviceManagerSetLocation:Fb,useDeviceManagerSetMetadata:dE,useDeviceManagerSetName:zb,useDeviceManagerSetStreamProfileMap:vE,useDeviceManagerSetWrapperActive:Gb,useDeviceManagerTestCreationField:dd,useDeviceManagerTestField:EE,useDeviceManagerUpdateConfig:xE,useDeviceManagerUpdateDeviceField:ME,useDeviceManagerUpdateDeviceFieldsBatch:Wb,useDeviceOpsGetConfigEntries:PE,useDeviceOpsGetSettingsSchema:DE,useDeviceOpsGetStreamSources:AE,useDeviceOpsRemoveDevice:$E,useDeviceOpsSetConfig:_E,useDeviceProviderAdoptDiscoveredDevice:FE,useDeviceProviderCreateDevice:HE,useDeviceProviderDiscoverDevices:zE,useDeviceProviderGetChildCreationSchema:VE,useDeviceProviderGetDevices:OE,useDeviceProviderGetStatus:RE,useDeviceProviderStart:LE,useDeviceProviderStop:TE,useDeviceProviderSupportsDiscovery:BE,useDeviceProviderSupportsManualCreation:jE,useDeviceProviderTestCreationField:qE,useDeviceProxy:At,useDeviceSnapshot:ed,useDeviceSnapshotImage:Yc,useDeviceState:Tg,useDeviceStateGetAllSnapshots:GE,useDeviceStateGetCapSlice:QE,useDeviceStateGetSnapshot:UE,useDeviceStateSetCapSlice:KE,useDeviceStateSlice:pn,useDeviceStatusGetStatus:WE,useDeviceWebrtc:_d,useDevices:vL,useDoorbellEvents:Dd,useDoorbellGetStatus:YE,useEventInvalidation:SL,useEventStreamLatest:Gr,useEventStreamMap:Kc,useEventsGetEventClipUrl:JE,useEventsGetEventThumbnail:XE,useEventsGetEvents:ZE,useFeatureProbeGetStatus:eI,useIntegrationsCreate:tx,useIntegrationsDelete:rx,useIntegrationsGet:Jb,useIntegrationsGetAvailableTypes:ox,useIntegrationsGetByAddonId:ex,useIntegrationsGetSettings:tI,useIntegrationsList:ud,useIntegrationsSetSettings:nI,useIntegrationsTestConnection:sx,useIntegrationsUpdate:nx,useIntercomEndTalkSession:sI,useIntercomGetStatus:aI,useIntercomHandleAnswer:ix,useIntercomPushTalkPcm:oI,useIntercomStartSession:ax,useIntercomStartTalkSession:rI,useIntercomStopSession:lx,useIsMidWidth:yg,useIsMobile:hr,useLiveBuffer:Wn,useLiveEvent:bt,useLocalNetworkGetAllowedAddresses:ux,useLocalNetworkGetConnectionEndpoints:dx,useLocalNetworkGetPreferred:iI,useLocalNetworkList:cx,useLocalNetworkResetAllowlistToBestMatch:fx,useLocalNetworkSetAllowedAddresses:px,useMeshNetworkGetStatus:lI,useMeshNetworkJoin:cI,useMeshNetworkLeave:uI,useMeshNetworkListPeers:fI,useMeshNetworkLogout:pI,useMeshNetworkStartLogin:dI,useMeshNetworkTestConnection:hI,useMeshOrchestratorJoinProvider:mI,useMeshOrchestratorLeaveProvider:mx,useMeshOrchestratorListProviderPeers:xx,useMeshOrchestratorListProviders:hx,useMeshOrchestratorLogoutProvider:bx,useMeshOrchestratorStartLoginProvider:gx,useMetricsProviderCollectSnapshot:gI,useMetricsProviderGetAddonStats:SI,useMetricsProviderGetCached:bI,useMetricsProviderGetCpuTemperature:wI,useMetricsProviderGetCurrent:xI,useMetricsProviderGetDiskSpace:yI,useMetricsProviderGetGpuInfo:vI,useMetricsProviderGetProcessStats:NI,useMetricsProviderKillProcess:vx,useMetricsProviderListAddonInstances:kI,useMetricsProviderListNodeProcesses:yx,useMotionDetectionAnalyze:EI,useMotionDetectionApplyDeviceSettingsPatch:$I,useMotionDetectionGetDeviceLiveContribution:_I,useMotionDetectionGetDeviceSettingsContribution:PI,useMotionDetectionRemoveCamera:II,useMotionDetectionReset:AI,useMotionGetStatus:MI,useMotionIsDetected:CI,useMotionTriggerGetStatus:LI,useMotionTriggerSetMotionTrigger:DI,useMqttBrokerAddBroker:OI,useMqttBrokerGetBrokerConfig:RI,useMqttBrokerGetStatus:wx,useMqttBrokerListBrokers:TI,useMqttBrokerRemoveBroker:BI,useMqttBrokerStartEmbeddedBroker:FI,useMqttBrokerStopEmbeddedBroker:jI,useMqttBrokerTestConnection:zI,useNativeObjectDetectionGetStatus:VI,useNetworkQualityGetAllStats:HI,useNetworkQualityGetDeviceStats:pd,useNetworkQualityReportClientStats:qI,useNodesClusterAddonStatus:Mx,useNodesDeployAddon:UI,useNodesExecuteQuery:GI,useNodesGetNodeAddons:Ex,useNodesRenameNode:Cx,useNodesRestartAddon:za,useNodesRestartNode:Sx,useNodesRestartProcess:kx,useNodesSetProcessLogLevel:Ix,useNodesShutdownNode:QI,useNodesTopology:Bn,useNodesUndeployAddon:Nx,useNotificationOutputSend:KI,useNotificationOutputSendTest:WI,useOptionalSystem:d3,useOptionalWidgetRegistry:j0,useOsdGetStatus:ZI,useOsdSetOverlay:YI,usePTZ:$d,usePipelineAnalyticsApplyDeviceSettingsPatch:cA,usePipelineAnalyticsClearTracks:tA,usePipelineAnalyticsGetActiveTracks:XI,usePipelineAnalyticsGetAudioEvents:oA,usePipelineAnalyticsGetDeviceLiveContribution:lA,usePipelineAnalyticsGetDeviceSettingsContribution:iA,usePipelineAnalyticsGetEventMedia:sA,usePipelineAnalyticsGetMotionEvents:nA,usePipelineAnalyticsGetObjectEvents:rA,usePipelineAnalyticsGetTrack:JI,usePipelineAnalyticsGetTrackMedia:aA,usePipelineAnalyticsListTracks:eA,usePipelineExecutorCacheFrameInPool:CA,usePipelineExecutorDeleteModel:Dx,usePipelineExecutorDeleteTemplate:yA,usePipelineExecutorDetect:NA,usePipelineExecutorDownloadModel:$x,usePipelineExecutorGetAddonModels:wA,usePipelineExecutorGetAudioCapabilities:LA,usePipelineExecutorGetAvailableEngines:Ax,usePipelineExecutorGetCapabilities:vA,usePipelineExecutorGetDefaultSteps:dA,usePipelineExecutorGetDetectionConfigSchema:RA,usePipelineExecutorGetEffectiveTuning:IA,usePipelineExecutorGetGlobalPipelineConfig:hA,usePipelineExecutorGetGlobalSteps:fA,usePipelineExecutorGetOrchestratorConfigSchema:mA,usePipelineExecutorGetReferenceAudio:DA,usePipelineExecutorGetReferenceAudioFiles:$A,usePipelineExecutorGetReferenceImage:_A,usePipelineExecutorGetSchema:Yo,usePipelineExecutorGetSelectedEngine:Px,usePipelineExecutorGetVideoPipelineSteps:uA,usePipelineExecutorInferCached:MA,usePipelineExecutorKillEngine:Tx,usePipelineExecutorListLoadedEngines:Lx,usePipelineExecutorListReferenceImages:PA,usePipelineExecutorListTemplates:gA,usePipelineExecutorReprobeEngine:_x,usePipelineExecutorRunAudioTest:TA,usePipelineExecutorRunPipeline:kA,usePipelineExecutorRunPipelineBatch:SA,usePipelineExecutorSaveTemplate:bA,usePipelineExecutorSetVideoPipelineSteps:pA,usePipelineExecutorSpinEngine:AA,usePipelineExecutorUncacheFrame:EA,usePipelineExecutorUpdateTemplate:xA,usePipelineOrchestratorApplyDeviceSettingsPatch:UA,usePipelineOrchestratorAssignAudio:Ux,usePipelineOrchestratorAssignDecoder:Vx,usePipelineOrchestratorAssignPipeline:Rx,usePipelineOrchestratorDeleteTemplate:n0,usePipelineOrchestratorGetAgentLoad:zx,usePipelineOrchestratorGetAgentSettings:fd,usePipelineOrchestratorGetAudioAssignment:zA,usePipelineOrchestratorGetAudioAssignments:Kx,usePipelineOrchestratorGetAudioNodeLoad:Gx,usePipelineOrchestratorGetCameraMetrics:BA,usePipelineOrchestratorGetCameraSettings:md,usePipelineOrchestratorGetCameraStepOverrides:jA,usePipelineOrchestratorGetCapabilityBindings:Fx,usePipelineOrchestratorGetDecoderAssignment:FA,usePipelineOrchestratorGetDecoderAssignments:qx,usePipelineOrchestratorGetDeviceLiveContribution:qA,usePipelineOrchestratorGetDeviceSettingsContribution:HA,usePipelineOrchestratorGetGlobalMetrics:OA,usePipelineOrchestratorGetPipelineAssignment:ja,usePipelineOrchestratorGetPipelineAssignments:Fa,usePipelineOrchestratorListAgentSettings:Yr,usePipelineOrchestratorListTemplates:e0,usePipelineOrchestratorRebalance:Bx,usePipelineOrchestratorRemoveAgentSettings:Wx,usePipelineOrchestratorResolvePipeline:Jx,usePipelineOrchestratorSaveTemplate:VA,usePipelineOrchestratorSetAgentAddonDefaults:hd,usePipelineOrchestratorSetCameraPipelineForAgent:Xx,usePipelineOrchestratorSetCameraStepOverride:Zx,usePipelineOrchestratorSetCameraStepToggle:Yx,usePipelineOrchestratorSetCapabilityBinding:jx,usePipelineOrchestratorUnassignAudio:Qx,usePipelineOrchestratorUnassignDecoder:Hx,usePipelineOrchestratorUnassignPipeline:Ox,usePipelineOrchestratorUpdateTemplate:t0,usePipelineRunnerAttachCamera:QA,usePipelineRunnerDetachCamera:GA,usePipelineRunnerGetAllCameraMetrics:ZA,usePipelineRunnerGetCameraMetrics:gd,usePipelineRunnerGetLocalCameras:r0,usePipelineRunnerGetLocalLoad:WA,usePipelineRunnerGetLocalMetrics:YA,usePipelineRunnerReportMotion:KA,usePlatformProbeGetCapabilities:XA,usePlatformProbeGetHardware:JA,usePlatformProbeGetHardwareEncoders:nP,usePlatformProbeRefreshHardwareEncoders:rP,usePlatformProbeResolveHwAccel:tP,usePlatformProbeResolveInferenceConfig:eP,usePlayerOverlayLayer:iD,usePlayerOverlayLayers:W0,usePlayerToolbarButton:lD,usePlayerToolbarButtons:Y0,usePtzAutotrackGetSettings:pP,usePtzAutotrackGetStatus:o0,usePtzAutotrackSetEnabled:s0,usePtzAutotrackSetSettings:a0,usePtzContinuousMove:sP,usePtzGetPosition:dP,usePtzGetPresets:iP,usePtzGetStatus:uP,usePtzGoHome:cP,usePtzGoToPreset:lP,usePtzMove:oP,usePtzStop:aP,useRebootReboot:i0,useRecordingEngineDisable:c0,useRecordingEngineEnable:l0,useRecordingEngineEstimateGlobalStorage:NP,useRecordingEngineEstimateStorage:wP,useRecordingEngineGetAvailability:vP,useRecordingEngineGetConfig:d0,useRecordingEngineGetMotionStats:MP,useRecordingEngineGetPlaylist:xP,useRecordingEngineGetPolicy:SP,useRecordingEngineGetPolicyStatus:f0,useRecordingEngineGetRetentionConfig:h0,useRecordingEngineGetSegments:u0,useRecordingEngineGetStatus:gP,useRecordingEngineGetStorageUsage:p0,useRecordingEngineGetThumbnail:yP,useRecordingEngineSetPolicy:kP,useRecordingEngineUpdateConfig:bP,useRecordingEngineUpdateRetentionConfig:CP,useRecordingGetPlaybackUrl:hP,useRecordingGetSegments:fP,useRecordingGetThumbnailAt:mP,useRemoteAccessListProviders:m0,useRemoteAccessStartProvider:g0,useRemoteAccessStopProvider:b0,useSettingsStoreCount:DP,useSettingsStoreDeclareCollection:TP,useSettingsStoreDelete:$P,useSettingsStoreGet:EP,useSettingsStoreInsert:PP,useSettingsStoreIsEmpty:LP,useSettingsStoreQuery:AP,useSettingsStoreSet:IP,useSettingsStoreUpdate:_P,useSnapshotApplyDeviceSettingsPatch:jP,useSnapshotGetDeviceLiveContribution:FP,useSnapshotGetDeviceSettingsContribution:zP,useSnapshotGetSnapshot:RP,useSnapshotGetStatus:BP,useSnapshotInvalidateCache:OP,useSnapshotProviderGetSnapshot:HP,useSnapshotProviderSupportsDevice:VP,useStorageAbortUpload:e_,useStorageBeginDownload:t_,useStorageBeginUpload:ZP,useStorageDelete:WP,useStorageDeleteLocation:y0,useStorageEndDownload:r_,useStorageExists:GP,useStorageFinalizeUpload:JP,useStorageGetAvailableSpace:YP,useStorageGetDefaultLocation:o_,useStorageList:KP,useStorageListLocations:x0,useStorageListProviders:bd,useStorageRead:QP,useStorageReadChunk:n_,useStorageResolve:qP,useStorageTestConfig:a_,useStorageTestLocation:s_,useStorageUpsertLocation:Va,useStorageWrite:UP,useStorageWriteChunk:XP,useStreamBrokerApplyDeviceSettingsPatch:P_,useStreamBrokerAssignProfile:c_,useStreamBrokerGetAllRtspEntries:S_,useStreamBrokerGetBroker:v_,useStreamBrokerGetBrokerStats:f_,useStreamBrokerGetDeviceLiveContribution:A_,useStreamBrokerGetDeviceSettingsContribution:I_,useStreamBrokerGetPreBufferInfo:N_,useStreamBrokerGetRtspEntry:C_,useStreamBrokerGetRtspPort:k_,useStreamBrokerGetStreamUrl:b_,useStreamBrokerGetStreamWithCodec:x_,useStreamBrokerIsRtspEnabled:E_,useStreamBrokerKillClient:m_,useStreamBrokerListAllCameraStreams:u_,useStreamBrokerListAllProfileSlots:p_,useStreamBrokerListClients:h_,useStreamBrokerPublishCameraStream:i_,useStreamBrokerRegenerateRtspToken:v0,useStreamBrokerReleaseStreamWithCodec:y_,useStreamBrokerRestartProfile:g_,useStreamBrokerRetractCameraStream:l_,useStreamBrokerSetPreBufferDuration:w_,useStreamBrokerSetRtspEnabled:M_,useStreamBrokerUnassignProfile:d_,useSwitchGetStatus:$_,useSwitchSetState:__,useSystem:Le,useSystemFeatureFlags:T_,useSystemForceRetentionCleanup:z_,useSystemGetRetentionConfig:O_,useSystemHealth:L_,useSystemInfo:D_,useSystemMutation:kL,useSystemNetworkAddresses:R_,useSystemQuery:NL,useSystemSetRetentionConfig:B_,useThemeMode:Hr,useToastOnToast:w0,useTurnOrchestratorGetAllServers:k0,useTurnOrchestratorListProviders:N0,useTurnOrchestratorSetProviderEnabled:S0,useTurnProviderGetTurnServers:F_,useUserManagementConfirmTotp:Q_,useUserManagementCreateApiKey:V_,useUserManagementCreateScopedToken:_0,useUserManagementCreateUser:C0,useUserManagementDeleteUser:E0,useUserManagementDisableTotp:L0,useUserManagementGetTotpStatus:T0,useUserManagementListApiKeys:A0,useUserManagementListScopedTokens:D0,useUserManagementListUsers:xd,useUserManagementResetPassword:yd,useUserManagementRevokeApiKey:P0,useUserManagementRevokeScopedToken:$0,useUserManagementSetUserScopes:I0,useUserManagementSetupTotp:U_,useUserManagementUpdateUser:M0,useUserManagementValidateApiKey:H_,useUserManagementValidateCredentials:j_,useUserManagementValidateScopedToken:q_,useUserManagementVerifyTotp:G_,useWebrtcSessionCloseSession:X_,useWebrtcSessionCreateSession:W_,useWebrtcSessionHandleAnswer:Z_,useWebrtcSessionHandleOffer:Y_,useWebrtcSessionHasAdaptiveBitrate:J_,useWebrtcSessionListStreams:K_,useWidget:B0,useWidgetMetadata:z0,useWidgetRegistry:Ha,useZoneAnalyticsGetCameraHistory:n$,useZoneAnalyticsGetCurrentSnapshot:e$,useZoneAnalyticsGetUnzonedHistory:r$,useZoneAnalyticsGetZoneHistory:t$,useZoneEditing:xL,useZoneRulesListRules:o$,useZoneRulesSetRules:s$,useZonesAddZone:i$,useZonesListZones:a$,useZonesRemoveZone:l$,useZonesUpdateZone:c$,validateScopes:Pd},Symbol.toStringTag,{value:"Module"}));/**
|
|
563
|
+
* react-router v7.15.0
|
|
564
|
+
*
|
|
565
|
+
* Copyright (c) Remix Software Inc.
|
|
566
|
+
*
|
|
567
|
+
* This source code is licensed under the MIT license found in the
|
|
568
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
569
|
+
*
|
|
570
|
+
* @license MIT
|
|
571
|
+
*/var _p="popstate";function $p(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function ML(e={}){function t(r,s){let a=s.state?.masked,{pathname:i,search:l,hash:c}=a||r.location;return Hl("",{pathname:i,search:l,hash:c},s.state&&s.state.usr||null,s.state&&s.state.key||"default",a?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,s){return typeof s=="string"?s:Po(s)}return IL(t,n,null,e)}function je(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Et(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function EL(){return Math.random().toString(36).substring(2,10)}function Dp(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 Hl(e,t,n=null,r,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Zr(t):t,state:n,key:t&&t.key||r||EL(),mask:s}}function Po({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 Zr(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function IL(e,t,n,r={}){let{window:s=document.defaultView,v5Compat:a=!1}=r,i=s.history,l="POP",c=null,d=u();d==null&&(d=0,i.replaceState({...i.state,idx:d},""));function u(){return(i.state||{idx:null}).idx}function p(){l="POP";let x=u(),y=x==null?null:x-d;d=x,c&&c({action:l,location:b.location,delta:y})}function h(x,y){l="PUSH";let w=$p(x)?x:Hl(b.location,x,y);d=u()+1;let v=Dp(w,d),N=b.createHref(w.mask||w);try{i.pushState(v,"",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 m(x,y){l="REPLACE";let w=$p(x)?x:Hl(b.location,x,y);d=u();let v=Dp(w,d),N=b.createHref(w.mask||w);i.replaceState(v,"",N),a&&c&&c({action:l,location:b.location,delta:0})}function g(x){return AL(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(_p,p),c=x,()=>{s.removeEventListener(_p,p),c=null}},createHref(x){return t(s,x)},createURL:g,encodeLocation(x){let y=g(x);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:h,replace:m,go(x){return i.go(x)}};return b}function AL(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),je(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:Po(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function yy(e,t,n="/"){return PL(e,t,n,!1)}function PL(e,t,n,r,s){let a=typeof t=="string"?Zr(t):t,i=fn(a.pathname||"/",n);if(i==null)return null;let l=_L(e),c=null,d=HL(i);for(let u=0;c==null&&u<l.length;++u)c=jL(l[u],d,r);return c}function _L(e){let t=vy(e);return $L(t),t}function vy(e,t=[],n=[],r="",s=!1){let a=(i,l,c=s,d)=>{let u={relativePath:d===void 0?i.path||"":d,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(u.relativePath.startsWith("/")){if(!u.relativePath.startsWith(r)&&c)return;je(u.relativePath.startsWith(r),`Absolute route path "${u.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(r.length)}let p=jt([r,u.relativePath]),h=n.concat(u);i.children&&i.children.length>0&&(je(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${p}".`),vy(i.children,t,h,p,c)),!(i.path==null&&!i.index)&&t.push({path:p,score:zL(p,i.index),routesMeta:h})};return e.forEach((i,l)=>{if(i.path===""||!i.path?.includes("?"))a(i,l);else for(let c of wy(i.path))a(i,l,!0,c)}),t}function wy(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return s?[a,""]:[a];let i=wy(r.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 $L(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:FL(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var DL=/^:[\w-]+$/,LL=3,TL=2,RL=1,OL=10,BL=-2,Lp=e=>e==="*";function zL(e,t){let n=e.split("/"),r=n.length;return n.some(Lp)&&(r+=BL),t&&(r+=TL),n.filter(s=>!Lp(s)).reduce((s,a)=>s+(DL.test(a)?LL:a===""?RL:OL),r)}function FL(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function jL(e,t,n=!1){let{routesMeta:r}=e,s={},a="/",i=[];for(let l=0;l<r.length;++l){let c=r[l],d=l===r.length-1,u=a==="/"?t:t.slice(a.length)||"/",p=oa({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},u),h=c.route;if(!p&&d&&n&&!r[r.length-1].route.index&&(p=oa({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},u)),!p)return null;Object.assign(s,p.params),i.push({params:s,pathname:jt([a,p.pathname]),pathnameBase:GL(jt([a,p.pathnameBase])),route:h}),p.pathnameBase!=="/"&&(a=jt([a,p.pathnameBase]))}return i}function oa(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=VL(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:r.reduce((d,{paramName:u,isOptional:p},h)=>{if(u==="*"){let g=l[h]||"";i=a.slice(0,a.length-g.length).replace(/(.)\/+$/,"$1")}const m=l[h];return p&&!m?d[u]=void 0:d[u]=(m||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:i,pattern:e}}function VL(e,t=!1,n=!0){Et(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 r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,c,d,u)=>{if(r.push({paramName:l,isOptional:c!=null}),c){let p=u.charAt(d+i.length);return p&&p!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function HL(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Et(!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 fn(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var qL=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function UL(e,t="/"){let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?Zr(e):e,a;return n?(n=Ny(n),n.startsWith("/")?a=Tp(n.substring(1),"/"):a=Tp(n,t)):a=t,{pathname:a,search:KL(r),hash:WL(s)}}function Tp(e,t){let n=sa(t).split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function Bi(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. 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 QL(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Ld(e){let t=QL(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Ua(e,t,n,r=!1){let s;typeof e=="string"?s=Zr(e):(s={...e},je(!s.pathname||!s.pathname.includes("?"),Bi("?","pathname","search",s)),je(!s.pathname||!s.pathname.includes("#"),Bi("#","pathname","hash",s)),je(!s.search||!s.search.includes("#"),Bi("#","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(!r&&i.startsWith("..")){let h=i.split("/");for(;h[0]==="..";)h.shift(),p-=1;s.pathname=h.join("/")}l=p>=0?t[p]:"/"}let c=UL(s,l),d=i&&i!=="/"&&i.endsWith("/"),u=(a||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||u)&&(c.pathname+="/"),c}var Ny=e=>e.replace(/\/\/+/g,"/"),jt=e=>Ny(e.join("/")),sa=e=>e.replace(/\/+$/,""),GL=e=>sa(e).replace(/^\/*/,"/"),KL=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,WL=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,YL=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function ZL(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function XL(e){let t=e.map(n=>n.route.path).filter(Boolean);return jt(t)||"/"}var ky=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Sy(e,t){let n=e;if(typeof n!="string"||!qL.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,s=!1;if(ky)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=fn(i.pathname,t);i.origin===a.origin&&l!=null?n=l+i.search+i.hash:s=!0}catch{Et(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:s,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Cy=["POST","PUT","PATCH","DELETE"];new Set(Cy);var JL=["GET",...Cy];new Set(JL);var Xr=ze(null);Xr.displayName="DataRouter";var Qa=ze(null);Qa.displayName="DataRouterState";var My=ze(!1);function eT(){return ve(My)}var Ey=ze({isTransitioning:!1});Ey.displayName="ViewTransition";var tT=ze(new Map);tT.displayName="Fetchers";var nT=ze(null);nT.displayName="Await";var vt=ze(null);vt.displayName="Navigation";var Zo=ze(null);Zo.displayName="Location";var Pt=ze({outlet:null,matches:[],isDataRoute:!1});Pt.displayName="Route";var Td=ze(null);Td.displayName="RouteError";var Iy="REACT_ROUTER_ERROR",rT="REDIRECT",oT="ROUTE_ERROR_RESPONSE";function sT(e){if(e.startsWith(`${Iy}:${rT}:{`))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 aT(e){if(e.startsWith(`${Iy}:${oT}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new YL(t.status,t.statusText,t.data)}catch{}}function iT(e,{relative:t}={}){je(Jr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=ve(vt),{hash:s,pathname:a,search:i}=Xo(e,{relative:t}),l=a;return n!=="/"&&(l=a==="/"?n:jt([n,a])),r.createHref({pathname:l,search:i,hash:s})}function Jr(){return ve(Zo)!=null}function wt(){return je(Jr(),"useLocation() may be used only in the context of a <Router> component."),ve(Zo).location}var Ay="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Py(e){ve(vt).static||Ia(e)}function ot(){let{isDataRoute:e}=ve(Pt);return e?NT():lT()}function lT(){je(Jr(),"useNavigate() may be used only in the context of a <Router> component.");let e=ve(Xr),{basename:t,navigator:n}=ve(vt),{matches:r}=ve(Pt),{pathname:s}=wt(),a=JSON.stringify(Ld(r)),i=te(!1);return Py(()=>{i.current=!0}),U((c,d={})=>{if(Et(i.current,Ay),!i.current)return;if(typeof c=="number"){n.go(c);return}let u=Ua(c,JSON.parse(a),s,d.relative==="path");e==null&&t!=="/"&&(u.pathname=u.pathname==="/"?t:jt([t,u.pathname])),(d.replace?n.replace:n.push)(u,d.state,d)},[t,n,a,s,e])}var cT=ze(null);function dT(e){let t=ve(Pt).outlet;return q(()=>t&&Ee(cT.Provider,{value:e},t),[t,e])}function Rd(){let{matches:e}=ve(Pt);return e[e.length-1]?.params??{}}function Xo(e,{relative:t}={}){let{matches:n}=ve(Pt),{pathname:r}=wt(),s=JSON.stringify(Ld(n));return q(()=>Ua(e,JSON.parse(s),r,t==="path"),[e,s,r,t])}function uT(e,t){return _y(e,t)}function _y(e,t,n){je(Jr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=ve(vt),{matches:s}=ve(Pt),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||"";Dy(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.
|
|
572
|
+
|
|
573
|
+
Please change the parent <Route path="${x}"> to <Route path="${x==="/"?"*":`${x}/*`}">.`)}let u=wt(),p;if(t){let x=typeof t=="string"?Zr(t):t;je(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=u;let h=p.pathname||"/",m=h;if(c!=="/"){let x=c.replace(/^\//,"").split("/");m="/"+h.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})):yy(e,{pathname:m});Et(d||g!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Et(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=gT(g&&g.map(x=>Object.assign({},x,{params:Object.assign({},i,x.params),pathname:jt([c,r.encodeLocation?r.encodeLocation(x.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?c:jt([c,r.encodeLocation?r.encodeLocation(x.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathnameBase])})),s,n);return t&&b?Ee(Zo.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...p},navigationType:"POP"}},b):b}function pT(){let e=wT(),t=ZL(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=Ee($r,null,Ee("p",null,"💿 Hey developer 👋"),Ee("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",Ee("code",{style:a},"ErrorBoundary")," or"," ",Ee("code",{style:a},"errorElement")," prop on your route.")),Ee($r,null,Ee("h2",null,"Unexpected Application Error!"),Ee("h3",{style:{fontStyle:"italic"}},t),n?Ee("pre",{style:s},n):null,i)}var fT=Ee(pT,null),$y=class extends o2{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=aT(e.digest);n&&(e=n)}let t=e!==void 0?Ee(Pt.Provider,{value:this.props.routeContext},Ee(Td.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?Ee(hT,{error:e},t):t}};$y.contextType=My;var zi=new WeakMap;function hT({children:e,error:t}){let{basename:n}=ve(vt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=sT(t.digest);if(r){let s=zi.get(t);if(s)throw s;let a=Sy(r.location,n);if(ky&&!zi.get(t))if(a.isExternal||r.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:r.replace}));throw zi.set(t,i),i}return Ee("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function mT({routeContext:e,match:t,children:n}){let r=ve(Xr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),Ee(Pt.Provider,{value:e},n)}function gT(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let s=e,a=r?.errors;if(a!=null){let u=s.findIndex(p=>p.route.id&&a?.[p.route.id]!==void 0);je(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),s=s.slice(0,Math.min(s.length,u+1))}let i=!1,l=-1;if(n&&r){i=r.renderFallback;for(let u=0;u<s.length;u++){let p=s[u];if((p.route.HydrateFallback||p.route.hydrateFallbackElement)&&(l=u),p.route.id){let{loaderData:h,errors:m}=r,g=p.route.loader&&!h.hasOwnProperty(p.route.id)&&(!m||m[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=r&&c?(u,p)=>{c(u,{location:r.location,params:r.matches?.[0]?.params??{},pattern:XL(r.matches),errorInfo:p})}:void 0;return s.reduceRight((u,p,h)=>{let m,g=!1,b=null,x=null;r&&(m=a&&p.route.id?a[p.route.id]:void 0,b=p.route.errorElement||fT,i&&(l<0&&h===0?(Dy("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,x=null):l===h&&(g=!0,x=p.route.hydrateFallbackElement||null)));let y=t.concat(s.slice(0,h+1)),w=()=>{let v;return m?v=b:g?v=x:p.route.Component?v=Ee(p.route.Component,null):p.route.element?v=p.route.element:v=u,Ee(mT,{match:p,routeContext:{outlet:u,matches:y,isDataRoute:r!=null},children:v})};return r&&(p.route.ErrorBoundary||p.route.errorElement||h===0)?Ee($y,{location:r.location,revalidation:r.revalidation,component:b,error:m,children:w(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:d}):w()},null)}function Od(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function bT(e){let t=ve(Xr);return je(t,Od(e)),t}function xT(e){let t=ve(Qa);return je(t,Od(e)),t}function yT(e){let t=ve(Pt);return je(t,Od(e)),t}function Bd(e){let t=yT(e),n=t.matches[t.matches.length-1];return je(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function vT(){return Bd("useRouteId")}function wT(){let e=ve(Td),t=xT("useRouteError"),n=Bd("useRouteError");return e!==void 0?e:t.errors?.[n]}function NT(){let{router:e}=bT("useNavigate"),t=Bd("useNavigate"),n=te(!1);return Py(()=>{n.current=!0}),U(async(s,a={})=>{Et(n.current,Ay),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:t,...a}))},[e,t])}var Rp={};function Dy(e,t,n){!t&&!Rp[e]&&(Rp[e]=!0,Et(!1,n))}He(kT);function kT({routes:e,manifest:t,future:n,state:r,isStatic:s,onError:a}){return _y(e,void 0,{manifest:t,state:r,isStatic:s,onError:a})}function kt({to:e,replace:t,state:n,relative:r}){je(Jr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:s}=ve(vt);Et(!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}=ve(Pt),{pathname:i}=wt(),l=ot(),c=Ua(e,Ld(a),i,r==="path"),d=JSON.stringify(c);return Y(()=>{l(JSON.parse(d),{replace:t,state:n,relative:r})},[l,d,r,t,n]),null}function ST(e){return dT(e.context)}function Te(e){je(!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 CT({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:s,static:a=!1,useTransitions:i}){je(!Jr(),"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=Zr(n));let{pathname:d="/",search:u="",hash:p="",state:h=null,key:m="default",mask:g}=n,b=q(()=>{let x=fn(d,l);return x==null?null:{location:{pathname:x,search:u,hash:p,state:h,key:m,mask:g},navigationType:r}},[l,d,u,p,h,m,r,g]);return Et(b!=null,`<Router basename="${l}"> is not able to match the URL "${d}${u}${p}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:Ee(vt.Provider,{value:c},Ee(Zo.Provider,{children:t,value:b}))}function MT({children:e,location:t}){return uT(ql(e),t)}function ql(e,t=[]){let n=[];return n2.forEach(e,(r,s)=>{if(!r2(r))return;let a=[...t,s];if(r.type===$r){n.push.apply(n,ql(r.props.children,a));return}je(r.type===Te,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),je(!r.props.index||!r.props.children,"An index route cannot have child routes.");let i={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(i.children=ql(r.props.children,a)),n.push(i)}),n}var Hs="get",qs="application/x-www-form-urlencoded";function Ga(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function ET(e){return Ga(e)&&e.tagName.toLowerCase()==="button"}function IT(e){return Ga(e)&&e.tagName.toLowerCase()==="form"}function AT(e){return Ga(e)&&e.tagName.toLowerCase()==="input"}function PT(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function _T(e,t){return e.button===0&&(!t||t==="_self")&&!PT(e)}function Ul(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(s=>[n,s]):[[n,r]])},[]))}function $T(e,t){let n=Ul(e);return t&&t.forEach((r,s)=>{n.has(s)||t.getAll(s).forEach(a=>{n.append(s,a)})}),n}var ys=null;function DT(){if(ys===null)try{new FormData(document.createElement("form"),0),ys=!1}catch{ys=!0}return ys}var LT=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Fi(e){return e!=null&&!LT.has(e)?(Et(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${qs}"`),null):e}function TT(e,t){let n,r,s,a,i;if(IT(e)){let l=e.getAttribute("action");r=l?fn(l,t):null,n=e.getAttribute("method")||Hs,s=Fi(e.getAttribute("enctype"))||qs,a=new FormData(e)}else if(ET(e)||AT(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(r=c?fn(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||Hs,s=Fi(e.getAttribute("formenctype"))||Fi(l.getAttribute("enctype"))||qs,a=new FormData(l,e),!DT()){let{name:d,type:u,value:p}=e;if(u==="image"){let h=d?`${d}.`:"";a.append(`${h}x`,"0"),a.append(`${h}y`,"0")}else d&&a.append(d,p)}}else{if(Ga(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Hs,r=null,s=qs,i=e}return a&&s==="text/plain"&&(i=a,a=void 0),{action:r,method:n.toLowerCase(),encType:s,formData:a,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function zd(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ly(e,t,n,r){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}_.${r}`:s.pathname=`${s.pathname}.${r}`:s.pathname==="/"?s.pathname=`_root.${r}`:t&&fn(s.pathname,t)==="/"?s.pathname=`${sa(t)}/_root.${r}`:s.pathname=`${sa(s.pathname)}.${r}`,s}async function RT(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 OT(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 BT(e,t,n){let r=await Promise.all(e.map(async s=>{let a=t.routes[s.route.id];if(a){let i=await RT(a,n);return i.links?i.links():[]}return[]}));return VT(r.flat(1).filter(OT).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function Op(e,t,n,r,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 u=r.routes[c.route.id];if(!u||!u.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 zT(e,t,{includeHydrateFallback:n}={}){return FT(e.map(r=>{let s=t.routes[r.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 FT(e){return[...new Set(e)]}function jT(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function VT(e,t){let n=new Set;return new Set(t),e.reduce((r,s)=>{let a=JSON.stringify(jT(s));return n.has(a)||(n.add(a),r.push({key:a,link:s})),r},[])}function Fd(){let e=ve(Xr);return zd(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function HT(){let e=ve(Qa);return zd(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var jd=ze(void 0);jd.displayName="FrameworkContext";function Vd(){let e=ve(jd);return zd(e,"You must render this element inside a <HydratedRouter> element"),e}function qT(e,t){let n=ve(jd),[r,s]=_(!1),[a,i]=_(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:u,onTouchStart:p}=t,h=te(null);Y(()=>{if(e==="render"&&i(!0),e==="viewport"){let b=y=>{y.forEach(w=>{i(w.isIntersecting)})},x=new IntersectionObserver(b,{threshold:.5});return h.current&&x.observe(h.current),()=>{x.disconnect()}}},[e]),Y(()=>{if(r){let b=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(b)}}},[r]);let m=()=>{s(!0)},g=()=>{s(!1),i(!1)};return n?e!=="intent"?[a,h,{}]:[a,h,{onFocus:so(l,m),onBlur:so(c,g),onMouseEnter:so(d,m),onMouseLeave:so(u,g),onTouchStart:so(p,m)}]:[!1,h,{}]}function so(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function UT({page:e,...t}){let n=eT(),{router:r}=Fd(),s=q(()=>yy(r.routes,e,r.basename),[r.routes,e,r.basename]);return s?n?Ee(GT,{page:e,matches:s,...t}):Ee(KT,{page:e,matches:s,...t}):null}function QT(e){let{manifest:t,routeModules:n}=Vd(),[r,s]=_([]);return Y(()=>{let a=!1;return BT(e,t,n).then(i=>{a||s(i)}),()=>{a=!0}},[e,t,n]),r}function GT({page:e,matches:t,...n}){let r=wt(),{future:s}=Vd(),{basename:a}=Fd(),i=q(()=>{if(e===r.pathname+r.search+r.hash)return[];let l=Ly(e,a,s.unstable_trailingSlashAwareDataRequests,"rsc"),c=!1,d=[];for(let u of t)typeof u.route.shouldRevalidate=="function"?c=!0:d.push(u.route.id);return c&&d.length>0&&l.searchParams.set("_routes",d.join(",")),[l.pathname+l.search]},[a,s.unstable_trailingSlashAwareDataRequests,e,r,t]);return Ee($r,null,i.map(l=>Ee("link",{key:l,rel:"prefetch",as:"fetch",href:l,...n})))}function KT({page:e,matches:t,...n}){let r=wt(),{future:s,manifest:a,routeModules:i}=Vd(),{basename:l}=Fd(),{loaderData:c,matches:d}=HT(),u=q(()=>Op(e,t,d,a,r,"data"),[e,t,d,a,r]),p=q(()=>Op(e,t,d,a,r,"assets"),[e,t,d,a,r]),h=q(()=>{if(e===r.pathname+r.search+r.hash)return[];let b=new Set,x=!1;if(t.forEach(w=>{let v=a.routes[w.route.id];!v||!v.hasLoader||(!u.some(N=>N.route.id===w.route.id)&&w.route.id in c&&i[w.route.id]?.shouldRevalidate||v.hasClientLoader?x=!0:b.add(w.route.id))}),b.size===0)return[];let y=Ly(e,l,s.unstable_trailingSlashAwareDataRequests,"data");return x&&b.size>0&&y.searchParams.set("_routes",t.filter(w=>b.has(w.route.id)).map(w=>w.route.id).join(",")),[y.pathname+y.search]},[l,s.unstable_trailingSlashAwareDataRequests,c,r,a,u,t,e,i]),m=q(()=>zT(p,a),[p,a]),g=QT(p);return Ee($r,null,h.map(b=>Ee("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),m.map(b=>Ee("link",{key:b,rel:"modulepreload",href:b,...n})),g.map(({key:b,link:x})=>Ee("link",{key:b,nonce:n.nonce,...x,crossOrigin:x.crossOrigin??n.crossOrigin})))}function WT(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var YT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{YT&&(window.__reactRouterVersion="7.15.0")}catch{}function ZT({basename:e,children:t,useTransitions:n,window:r}){let s=te();s.current==null&&(s.current=ML({window:r,v5Compat:!0}));let a=s.current,[i,l]=_({action:a.action,location:a.location}),c=U(d=>{n===!1?l(d):Sc(()=>l(d))},[n]);return Ia(()=>a.listen(c),[a,c]),Ee(CT,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a,useTransitions:n})}var Ty=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,tr=Ue(function({onClick:t,discover:n="render",prefetch:r="none",relative:s,reloadDocument:a,replace:i,mask:l,state:c,target:d,to:u,preventScrollReset:p,viewTransition:h,defaultShouldRevalidate:m,...g},b){let{basename:x,navigator:y,useTransitions:w}=ve(vt),v=typeof u=="string"&&Ty.test(u),N=Sy(u,x);u=N.to;let k=iT(u,{relative:s}),C=wt(),M=null;if(l){let D=Ua(l,[],C.mask?C.mask.pathname:"/",!0);x!=="/"&&(D.pathname=D.pathname==="/"?x:jt([x,D.pathname])),M=y.createHref(D)}let[P,I,z]=qT(r,g),A=tR(u,{replace:i,mask:l,state:c,target:d,preventScrollReset:p,relative:s,viewTransition:h,defaultShouldRevalidate:m,useTransitions:w});function O(D){t&&t(D),D.defaultPrevented||A(D)}let R=!(N.isExternal||a),E=Ee("a",{...g,...z,href:(R?M:void 0)||N.absoluteURL||k,onClick:R?O:t,ref:WT(b,I),target:d,"data-discover":!v&&n==="render"?"true":void 0});return P&&!v?Ee($r,null,E,Ee(UT,{page:k})):E});tr.displayName="Link";var XT=Ue(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:s=!1,style:a,to:i,viewTransition:l,children:c,...d},u){let p=Xo(i,{relative:d.relative}),h=wt(),m=ve(Qa),{navigator:g,basename:b}=ve(vt),x=m!=null&&aR(p)&&l===!0,y=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,w=h.pathname,v=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(w=w.toLowerCase(),v=v?v.toLowerCase():null,y=y.toLowerCase()),v&&b&&(v=fn(v,b)||v);const N=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let k=w===y||!s&&w.startsWith(y)&&w.charAt(N)==="/",C=v!=null&&(v===y||!s&&v.startsWith(y)&&v.charAt(y.length)==="/"),M={isActive:k,isPending:C,isTransitioning:x},P=k?t:void 0,I;typeof r=="function"?I=r(M):I=[r,k?"active":null,C?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let z=typeof a=="function"?a(M):a;return Ee(tr,{...d,"aria-current":P,className:I,ref:u,style:z,to:i,viewTransition:l},typeof c=="function"?c(M):c)});XT.displayName="NavLink";var JT=Ue(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:s,state:a,method:i=Hs,action:l,onSubmit:c,relative:d,preventScrollReset:u,viewTransition:p,defaultShouldRevalidate:h,...m},g)=>{let{useTransitions:b}=ve(vt),x=oR(),y=sR(l,{relative:d}),w=i.toLowerCase()==="get"?"get":"post",v=typeof l=="string"&&Ty.test(l);return Ee("form",{ref:g,method:w,action:y,onSubmit:r?c:k=>{if(c&&c(k),k.defaultPrevented)return;k.preventDefault();let C=k.nativeEvent.submitter,M=C?.getAttribute("formmethod")||i,P=()=>x(C||k.currentTarget,{fetcherKey:t,method:M,navigate:n,replace:s,state:a,relative:d,preventScrollReset:u,viewTransition:p,defaultShouldRevalidate:h});b&&n!==!1?Sc(()=>P()):P()},...m,"data-discover":!v&&e==="render"?"true":void 0})});JT.displayName="Form";function eR(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ry(e){let t=ve(Xr);return je(t,eR(e)),t}function tR(e,{target:t,replace:n,mask:r,state:s,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:c,useTransitions:d}={}){let u=ot(),p=wt(),h=Xo(e,{relative:i});return U(m=>{if(_T(m,t)){m.preventDefault();let g=n!==void 0?n:Po(p)===Po(h),b=()=>u(e,{replace:g,mask:r,state:s,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:c});d?Sc(()=>b()):b()}},[p,u,h,n,r,s,t,e,a,i,l,c,d])}function Ka(e){Et(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=te(Ul(e)),n=te(!1),r=wt(),s=q(()=>$T(r.search,n.current?null:t.current),[r.search]),a=ot(),i=U((l,c)=>{const d=Ul(typeof l=="function"?l(new URLSearchParams(s)):l);n.current=!0,a("?"+d,c)},[a,s]);return[s,i]}var nR=0,rR=()=>`__${String(++nR)}__`;function oR(){let{router:e}=Ry("useSubmit"),{basename:t}=ve(vt),n=vT(),r=e.fetch,s=e.navigate;return U(async(a,i={})=>{let{action:l,method:c,encType:d,formData:u,body:p}=TT(a,t);if(i.navigate===!1){let h=i.fetcherKey||rR();await r(h,n,i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:u,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:u,body:p,formMethod:i.method||c,formEncType:i.encType||d,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[r,s,t,n])}function sR(e,{relative:t}={}){let{basename:n}=ve(vt),r=ve(Pt);je(r,"useFormAction must be used inside a RouteContext");let[s]=r.matches.slice(-1),a={...Xo(e||".",{relative:t})},i=wt();if(e==null){a.search=i.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(u=>u==="")){l.delete("index"),c.filter(p=>p).forEach(p=>l.append("index",p));let u=l.toString();a.search=u?`?${u}`:""}}return(!e||e===".")&&s.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:jt([n,a.pathname])),Po(a)}function aR(e,{relative:t}={}){let n=ve(Ey);je(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Ry("useViewTransitionState"),s=Xo(e,{relative:t});if(!n.isTransitioning)return!1;let a=fn(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=fn(n.nextLocation.pathname,r)||n.nextLocation.pathname;return oa(s.pathname,i)!=null||oa(s.pathname,a)!=null}const iR=3e4;function lR(e){const t=te(e);t.current=e,Y(()=>{let n=null;const r=()=>{if(document.visibilityState==="hidden"){n=Date.now();return}if(document.visibilityState==="visible"&&n!==null){const i=Date.now()-n;n=null,i>=iR&&t.current()}},s=()=>{t.current()},a=i=>{i.persisted&&t.current()};return document.addEventListener("visibilitychange",r),window.addEventListener("online",s),window.addEventListener("pageshow",a),()=>{document.removeEventListener("visibilitychange",r),window.removeEventListener("online",s),window.removeEventListener("pageshow",a)}},[])}let Ql="disconnected";const Gl=new Set;function cR(){for(const e of Gl)e()}function dR(e){Ql!==e&&(Ql=e,cR())}function uR(e){return Gl.add(e),()=>{Gl.delete(e)}}function Bp(){return Ql}function pR(){return Aa(uR,Bp,Bp)}let bo=null;function Us(){if(!bo){const e=window.location.origin,t=localStorage.getItem("camstack_admin_token")??void 0;bo=im({serverUrl:e,token:t,onConnectionChange:n=>dR(n)})}return bo}function Sr(){bo?.close(),bo=null}/**
|
|
574
|
+
* @license lucide-react v0.511.0 - ISC
|
|
575
|
+
*
|
|
576
|
+
* This source code is licensed under the ISC license.
|
|
577
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
578
|
+
*/const fR=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),hR=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),zp=e=>{const t=hR(e);return t.charAt(0).toUpperCase()+t.slice(1)},Oy=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),mR=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/**
|
|
579
|
+
* @license lucide-react v0.511.0 - ISC
|
|
580
|
+
*
|
|
581
|
+
* This source code is licensed under the ISC license.
|
|
582
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
583
|
+
*/var gR={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"};/**
|
|
584
|
+
* @license lucide-react v0.511.0 - ISC
|
|
585
|
+
*
|
|
586
|
+
* This source code is licensed under the ISC license.
|
|
587
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
588
|
+
*/const bR=Ue(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:i,...l},c)=>Ee("svg",{ref:c,...gR,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Oy("lucide",s),...!a&&!mR(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,u])=>Ee(d,u)),...Array.isArray(a)?a:[a]]));/**
|
|
589
|
+
* @license lucide-react v0.511.0 - ISC
|
|
590
|
+
*
|
|
591
|
+
* This source code is licensed under the ISC license.
|
|
592
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
593
|
+
*/const se=(e,t)=>{const n=Ue(({className:r,...s},a)=>Ee(bR,{ref:a,iconNode:t,className:Oy(`lucide-${fR(zp(e))}`,`lucide-${e}`,r),...s}));return n.displayName=zp(e),n};/**
|
|
594
|
+
* @license lucide-react v0.511.0 - ISC
|
|
595
|
+
*
|
|
596
|
+
* This source code is licensed under the ISC license.
|
|
597
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
598
|
+
*/const xR=[["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"}]],Jo=se("activity",xR);/**
|
|
599
|
+
* @license lucide-react v0.511.0 - ISC
|
|
600
|
+
*
|
|
601
|
+
* This source code is licensed under the ISC license.
|
|
602
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
603
|
+
*/const yR=[["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"}]],By=se("archive",yR);/**
|
|
604
|
+
* @license lucide-react v0.511.0 - ISC
|
|
605
|
+
*
|
|
606
|
+
* This source code is licensed under the ISC license.
|
|
607
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
608
|
+
*/const vR=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Hd=se("arrow-left",vR);/**
|
|
609
|
+
* @license lucide-react v0.511.0 - ISC
|
|
610
|
+
*
|
|
611
|
+
* This source code is licensed under the ISC license.
|
|
612
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
613
|
+
*/const wR=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],NR=se("arrow-right",wR);/**
|
|
614
|
+
* @license lucide-react v0.511.0 - ISC
|
|
615
|
+
*
|
|
616
|
+
* This source code is licensed under the ISC license.
|
|
617
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
618
|
+
*/const kR=[["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"}]],SR=se("battery-full",kR);/**
|
|
619
|
+
* @license lucide-react v0.511.0 - ISC
|
|
620
|
+
*
|
|
621
|
+
* This source code is licensed under the ISC license.
|
|
622
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
623
|
+
*/const CR=[["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"}]],es=se("bell",CR);/**
|
|
624
|
+
* @license lucide-react v0.511.0 - ISC
|
|
625
|
+
*
|
|
626
|
+
* This source code is licensed under the ISC license.
|
|
627
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
628
|
+
*/const MR=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],ER=se("book-open",MR);/**
|
|
629
|
+
* @license lucide-react v0.511.0 - ISC
|
|
630
|
+
*
|
|
631
|
+
* This source code is licensed under the ISC license.
|
|
632
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
633
|
+
*/const IR=[["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"}]],AR=se("bot",IR);/**
|
|
634
|
+
* @license lucide-react v0.511.0 - ISC
|
|
635
|
+
*
|
|
636
|
+
* This source code is licensed under the ISC license.
|
|
637
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
638
|
+
*/const PR=[["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"}]],Wa=se("box",PR);/**
|
|
639
|
+
* @license lucide-react v0.511.0 - ISC
|
|
640
|
+
*
|
|
641
|
+
* This source code is licensed under the ISC license.
|
|
642
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
643
|
+
*/const _R=[["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"}]],Ya=se("boxes",_R);/**
|
|
644
|
+
* @license lucide-react v0.511.0 - ISC
|
|
645
|
+
*
|
|
646
|
+
* This source code is licensed under the ISC license.
|
|
647
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
648
|
+
*/const $R=[["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"}]],DR=se("calendar-clock",$R);/**
|
|
649
|
+
* @license lucide-react v0.511.0 - ISC
|
|
650
|
+
*
|
|
651
|
+
* This source code is licensed under the ISC license.
|
|
652
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
653
|
+
*/const LR=[["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"}]],zy=se("calendar",LR);/**
|
|
654
|
+
* @license lucide-react v0.511.0 - ISC
|
|
655
|
+
*
|
|
656
|
+
* This source code is licensed under the ISC license.
|
|
657
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
658
|
+
*/const TR=[["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"}]],Dr=se("camera",TR);/**
|
|
659
|
+
* @license lucide-react v0.511.0 - ISC
|
|
660
|
+
*
|
|
661
|
+
* This source code is licensed under the ISC license.
|
|
662
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
663
|
+
*/const RR=[["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"}]],Fy=se("cctv",RR);/**
|
|
664
|
+
* @license lucide-react v0.511.0 - ISC
|
|
665
|
+
*
|
|
666
|
+
* This source code is licensed under the ISC license.
|
|
667
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
668
|
+
*/const OR=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],BR=se("check-check",OR);/**
|
|
669
|
+
* @license lucide-react v0.511.0 - ISC
|
|
670
|
+
*
|
|
671
|
+
* This source code is licensed under the ISC license.
|
|
672
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
673
|
+
*/const zR=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],_t=se("check",zR);/**
|
|
674
|
+
* @license lucide-react v0.511.0 - ISC
|
|
675
|
+
*
|
|
676
|
+
* This source code is licensed under the ISC license.
|
|
677
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
678
|
+
*/const FR=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],lt=se("chevron-down",FR);/**
|
|
679
|
+
* @license lucide-react v0.511.0 - ISC
|
|
680
|
+
*
|
|
681
|
+
* This source code is licensed under the ISC license.
|
|
682
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
683
|
+
*/const jR=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],qd=se("chevron-left",jR);/**
|
|
684
|
+
* @license lucide-react v0.511.0 - ISC
|
|
685
|
+
*
|
|
686
|
+
* This source code is licensed under the ISC license.
|
|
687
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
688
|
+
*/const VR=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Nt=se("chevron-right",VR);/**
|
|
689
|
+
* @license lucide-react v0.511.0 - ISC
|
|
690
|
+
*
|
|
691
|
+
* This source code is licensed under the ISC license.
|
|
692
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
693
|
+
*/const HR=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],qR=se("chevron-up",HR);/**
|
|
694
|
+
* @license lucide-react v0.511.0 - ISC
|
|
695
|
+
*
|
|
696
|
+
* This source code is licensed under the ISC license.
|
|
697
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
698
|
+
*/const UR=[["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"}]],nr=se("circle-alert",UR);/**
|
|
699
|
+
* @license lucide-react v0.511.0 - ISC
|
|
700
|
+
*
|
|
701
|
+
* This source code is licensed under the ISC license.
|
|
702
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
703
|
+
*/const QR=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],xo=se("circle-check-big",QR);/**
|
|
704
|
+
* @license lucide-react v0.511.0 - ISC
|
|
705
|
+
*
|
|
706
|
+
* This source code is licensed under the ISC license.
|
|
707
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
708
|
+
*/const GR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ud=se("circle-check",GR);/**
|
|
709
|
+
* @license lucide-react v0.511.0 - ISC
|
|
710
|
+
*
|
|
711
|
+
* This source code is licensed under the ISC license.
|
|
712
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
713
|
+
*/const KR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],jy=se("circle-dot",KR);/**
|
|
714
|
+
* @license lucide-react v0.511.0 - ISC
|
|
715
|
+
*
|
|
716
|
+
* This source code is licensed under the ISC license.
|
|
717
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
718
|
+
*/const WR=[["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"}]],YR=se("circle-help",WR);/**
|
|
719
|
+
* @license lucide-react v0.511.0 - ISC
|
|
720
|
+
*
|
|
721
|
+
* This source code is licensed under the ISC license.
|
|
722
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
723
|
+
*/const ZR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],XR=se("clock",ZR);/**
|
|
724
|
+
* @license lucide-react v0.511.0 - ISC
|
|
725
|
+
*
|
|
726
|
+
* This source code is licensed under the ISC license.
|
|
727
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
728
|
+
*/const JR=[["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"}]],aa=se("copy",JR);/**
|
|
729
|
+
* @license lucide-react v0.511.0 - ISC
|
|
730
|
+
*
|
|
731
|
+
* This source code is licensed under the ISC license.
|
|
732
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
733
|
+
*/const e6=[["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"}]],xt=se("cpu",e6);/**
|
|
734
|
+
* @license lucide-react v0.511.0 - ISC
|
|
735
|
+
*
|
|
736
|
+
* This source code is licensed under the ISC license.
|
|
737
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
738
|
+
*/const t6=[["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"}]],n6=se("crosshair",t6);/**
|
|
739
|
+
* @license lucide-react v0.511.0 - ISC
|
|
740
|
+
*
|
|
741
|
+
* This source code is licensed under the ISC license.
|
|
742
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
743
|
+
*/const r6=[["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"}]],Vy=se("database",r6);/**
|
|
744
|
+
* @license lucide-react v0.511.0 - ISC
|
|
745
|
+
*
|
|
746
|
+
* This source code is licensed under the ISC license.
|
|
747
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
748
|
+
*/const o6=[["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"}]],en=se("download",o6);/**
|
|
749
|
+
* @license lucide-react v0.511.0 - ISC
|
|
750
|
+
*
|
|
751
|
+
* This source code is licensed under the ISC license.
|
|
752
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
753
|
+
*/const s6=[["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"}]],a6=se("ellipsis-vertical",s6);/**
|
|
754
|
+
* @license lucide-react v0.511.0 - ISC
|
|
755
|
+
*
|
|
756
|
+
* This source code is licensed under the ISC license.
|
|
757
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
758
|
+
*/const i6=[["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"}]],Qd=se("external-link",i6);/**
|
|
759
|
+
* @license lucide-react v0.511.0 - ISC
|
|
760
|
+
*
|
|
761
|
+
* This source code is licensed under the ISC license.
|
|
762
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
763
|
+
*/const l6=[["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"}]],Hy=se("eye-off",l6);/**
|
|
764
|
+
* @license lucide-react v0.511.0 - ISC
|
|
765
|
+
*
|
|
766
|
+
* This source code is licensed under the ISC license.
|
|
767
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
768
|
+
*/const c6=[["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"}]],ts=se("eye",c6);/**
|
|
769
|
+
* @license lucide-react v0.511.0 - ISC
|
|
770
|
+
*
|
|
771
|
+
* This source code is licensed under the ISC license.
|
|
772
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
773
|
+
*/const d6=[["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"}]],yo=se("film",d6);/**
|
|
774
|
+
* @license lucide-react v0.511.0 - ISC
|
|
775
|
+
*
|
|
776
|
+
* This source code is licensed under the ISC license.
|
|
777
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
778
|
+
*/const u6=[["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"}]],p6=se("flame",u6);/**
|
|
779
|
+
* @license lucide-react v0.511.0 - ISC
|
|
780
|
+
*
|
|
781
|
+
* This source code is licensed under the ISC license.
|
|
782
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
783
|
+
*/const f6=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],qy=se("gauge",f6);/**
|
|
784
|
+
* @license lucide-react v0.511.0 - ISC
|
|
785
|
+
*
|
|
786
|
+
* This source code is licensed under the ISC license.
|
|
787
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
788
|
+
*/const h6=[["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"}]],Kl=se("ghost",h6);/**
|
|
789
|
+
* @license lucide-react v0.511.0 - ISC
|
|
790
|
+
*
|
|
791
|
+
* This source code is licensed under the ISC license.
|
|
792
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
793
|
+
*/const m6=[["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"}]],g6=se("git-branch",m6);/**
|
|
794
|
+
* @license lucide-react v0.511.0 - ISC
|
|
795
|
+
*
|
|
796
|
+
* This source code is licensed under the ISC license.
|
|
797
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
798
|
+
*/const b6=[["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"}]],hn=se("globe",b6);/**
|
|
799
|
+
* @license lucide-react v0.511.0 - ISC
|
|
800
|
+
*
|
|
801
|
+
* This source code is licensed under the ISC license.
|
|
802
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
803
|
+
*/const x6=[["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"}]],ia=se("hard-drive",x6);/**
|
|
804
|
+
* @license lucide-react v0.511.0 - ISC
|
|
805
|
+
*
|
|
806
|
+
* This source code is licensed under the ISC license.
|
|
807
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
808
|
+
*/const y6=[["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"}]],v6=se("house",y6);/**
|
|
809
|
+
* @license lucide-react v0.511.0 - ISC
|
|
810
|
+
*
|
|
811
|
+
* This source code is licensed under the ISC license.
|
|
812
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
813
|
+
*/const w6=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],rr=se("info",w6);/**
|
|
814
|
+
* @license lucide-react v0.511.0 - ISC
|
|
815
|
+
*
|
|
816
|
+
* This source code is licensed under the ISC license.
|
|
817
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
818
|
+
*/const N6=[["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"}]],Uy=se("key-round",N6);/**
|
|
819
|
+
* @license lucide-react v0.511.0 - ISC
|
|
820
|
+
*
|
|
821
|
+
* This source code is licensed under the ISC license.
|
|
822
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
823
|
+
*/const k6=[["path",{d:"M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z",key:"165ttr"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"m9.4 10.6-6.814 6.814A2 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-.814",key:"1ubxi2"}]],Qy=se("key-square",k6);/**
|
|
824
|
+
* @license lucide-react v0.511.0 - ISC
|
|
825
|
+
*
|
|
826
|
+
* This source code is licensed under the ISC license.
|
|
827
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
828
|
+
*/const S6=[["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"}]],C6=se("key",S6);/**
|
|
829
|
+
* @license lucide-react v0.511.0 - ISC
|
|
830
|
+
*
|
|
831
|
+
* This source code is licensed under the ISC license.
|
|
832
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
833
|
+
*/const M6=[["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"}]],E6=se("layers",M6);/**
|
|
834
|
+
* @license lucide-react v0.511.0 - ISC
|
|
835
|
+
*
|
|
836
|
+
* This source code is licensed under the ISC license.
|
|
837
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
838
|
+
*/const I6=[["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"}]],Gy=se("layout-dashboard",I6);/**
|
|
839
|
+
* @license lucide-react v0.511.0 - ISC
|
|
840
|
+
*
|
|
841
|
+
* This source code is licensed under the ISC license.
|
|
842
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
843
|
+
*/const A6=[["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"}]],P6=se("lightbulb",A6);/**
|
|
844
|
+
* @license lucide-react v0.511.0 - ISC
|
|
845
|
+
*
|
|
846
|
+
* This source code is licensed under the ISC license.
|
|
847
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
848
|
+
*/const _6=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Se=se("loader-circle",_6);/**
|
|
849
|
+
* @license lucide-react v0.511.0 - ISC
|
|
850
|
+
*
|
|
851
|
+
* This source code is licensed under the ISC license.
|
|
852
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
853
|
+
*/const $6=[["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"}]],Gd=se("lock",$6);/**
|
|
854
|
+
* @license lucide-react v0.511.0 - ISC
|
|
855
|
+
*
|
|
856
|
+
* This source code is licensed under the ISC license.
|
|
857
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
858
|
+
*/const D6=[["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"}]],L6=se("log-in",D6);/**
|
|
859
|
+
* @license lucide-react v0.511.0 - ISC
|
|
860
|
+
*
|
|
861
|
+
* This source code is licensed under the ISC license.
|
|
862
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
863
|
+
*/const T6=[["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"}]],Kd=se("log-out",T6);/**
|
|
864
|
+
* @license lucide-react v0.511.0 - ISC
|
|
865
|
+
*
|
|
866
|
+
* This source code is licensed under the ISC license.
|
|
867
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
868
|
+
*/const R6=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],O6=se("mail",R6);/**
|
|
869
|
+
* @license lucide-react v0.511.0 - ISC
|
|
870
|
+
*
|
|
871
|
+
* This source code is licensed under the ISC license.
|
|
872
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
873
|
+
*/const B6=[["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"}]],z6=se("map-pin",B6);/**
|
|
874
|
+
* @license lucide-react v0.511.0 - ISC
|
|
875
|
+
*
|
|
876
|
+
* This source code is licensed under the ISC license.
|
|
877
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
878
|
+
*/const F6=[["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"}]],Wd=se("memory-stick",F6);/**
|
|
879
|
+
* @license lucide-react v0.511.0 - ISC
|
|
880
|
+
*
|
|
881
|
+
* This source code is licensed under the ISC license.
|
|
882
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
883
|
+
*/const j6=[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]],V6=se("menu",j6);/**
|
|
884
|
+
* @license lucide-react v0.511.0 - ISC
|
|
885
|
+
*
|
|
886
|
+
* This source code is licensed under the ISC license.
|
|
887
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
888
|
+
*/const H6=[["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"}]],Wl=se("mic",H6);/**
|
|
889
|
+
* @license lucide-react v0.511.0 - ISC
|
|
890
|
+
*
|
|
891
|
+
* This source code is licensed under the ISC license.
|
|
892
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
893
|
+
*/const q6=[["path",{d:"M5 12h14",key:"1ays0h"}]],U6=se("minus",q6);/**
|
|
894
|
+
* @license lucide-react v0.511.0 - ISC
|
|
895
|
+
*
|
|
896
|
+
* This source code is licensed under the ISC license.
|
|
897
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
898
|
+
*/const Q6=[["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"}]],G6=se("monitor",Q6);/**
|
|
899
|
+
* @license lucide-react v0.511.0 - ISC
|
|
900
|
+
*
|
|
901
|
+
* This source code is licensed under the ISC license.
|
|
902
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
903
|
+
*/const K6=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],Ky=se("moon",K6);/**
|
|
904
|
+
* @license lucide-react v0.511.0 - ISC
|
|
905
|
+
*
|
|
906
|
+
* This source code is licensed under the ISC license.
|
|
907
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
908
|
+
*/const W6=[["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"}]],Y6=se("move",W6);/**
|
|
909
|
+
* @license lucide-react v0.511.0 - ISC
|
|
910
|
+
*
|
|
911
|
+
* This source code is licensed under the ISC license.
|
|
912
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
913
|
+
*/const Z6=[["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"}]],_n=se("network",Z6);/**
|
|
914
|
+
* @license lucide-react v0.511.0 - ISC
|
|
915
|
+
*
|
|
916
|
+
* This source code is licensed under the ISC license.
|
|
917
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
918
|
+
*/const X6=[["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"}]],J6=se("octagon-alert",X6);/**
|
|
919
|
+
* @license lucide-react v0.511.0 - ISC
|
|
920
|
+
*
|
|
921
|
+
* This source code is licensed under the ISC license.
|
|
922
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
923
|
+
*/const eO=[["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"}]],Wy=se("package",eO);/**
|
|
924
|
+
* @license lucide-react v0.511.0 - ISC
|
|
925
|
+
*
|
|
926
|
+
* This source code is licensed under the ISC license.
|
|
927
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
928
|
+
*/const tO=[["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"}]],eo=se("pencil",tO);/**
|
|
929
|
+
* @license lucide-react v0.511.0 - ISC
|
|
930
|
+
*
|
|
931
|
+
* This source code is licensed under the ISC license.
|
|
932
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
933
|
+
*/const nO=[["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"}]],Yy=se("pin",nO);/**
|
|
934
|
+
* @license lucide-react v0.511.0 - ISC
|
|
935
|
+
*
|
|
936
|
+
* This source code is licensed under the ISC license.
|
|
937
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
938
|
+
*/const rO=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],Za=se("play",rO);/**
|
|
939
|
+
* @license lucide-react v0.511.0 - ISC
|
|
940
|
+
*
|
|
941
|
+
* This source code is licensed under the ISC license.
|
|
942
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
943
|
+
*/const oO=[["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"}]],_o=se("plug",oO);/**
|
|
944
|
+
* @license lucide-react v0.511.0 - ISC
|
|
945
|
+
*
|
|
946
|
+
* This source code is licensed under the ISC license.
|
|
947
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
948
|
+
*/const sO=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ct=se("plus",sO);/**
|
|
949
|
+
* @license lucide-react v0.511.0 - ISC
|
|
950
|
+
*
|
|
951
|
+
* This source code is licensed under the ISC license.
|
|
952
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
953
|
+
*/const aO=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Zy=se("power",aO);/**
|
|
954
|
+
* @license lucide-react v0.511.0 - ISC
|
|
955
|
+
*
|
|
956
|
+
* This source code is licensed under the ISC license.
|
|
957
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
958
|
+
*/const iO=[["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"}]],$o=se("puzzle",iO);/**
|
|
959
|
+
* @license lucide-react v0.511.0 - ISC
|
|
960
|
+
*
|
|
961
|
+
* This source code is licensed under the ISC license.
|
|
962
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
963
|
+
*/const lO=[["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"}]],cO=se("radar",lO);/**
|
|
964
|
+
* @license lucide-react v0.511.0 - ISC
|
|
965
|
+
*
|
|
966
|
+
* This source code is licensed under the ISC license.
|
|
967
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
968
|
+
*/const dO=[["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"}]],Xa=se("radio",dO);/**
|
|
969
|
+
* @license lucide-react v0.511.0 - ISC
|
|
970
|
+
*
|
|
971
|
+
* This source code is licensed under the ISC license.
|
|
972
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
973
|
+
*/const uO=[["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"}]],dt=se("refresh-cw",uO);/**
|
|
974
|
+
* @license lucide-react v0.511.0 - ISC
|
|
975
|
+
*
|
|
976
|
+
* This source code is licensed under the ISC license.
|
|
977
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
978
|
+
*/const pO=[["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"}]],Xy=se("rotate-ccw",pO);/**
|
|
979
|
+
* @license lucide-react v0.511.0 - ISC
|
|
980
|
+
*
|
|
981
|
+
* This source code is licensed under the ISC license.
|
|
982
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
983
|
+
*/const fO=[["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"}]],St=se("rotate-cw",fO);/**
|
|
984
|
+
* @license lucide-react v0.511.0 - ISC
|
|
985
|
+
*
|
|
986
|
+
* This source code is licensed under the ISC license.
|
|
987
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
988
|
+
*/const hO=[["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"}]],mO=se("save",hO);/**
|
|
989
|
+
* @license lucide-react v0.511.0 - ISC
|
|
990
|
+
*
|
|
991
|
+
* This source code is licensed under the ISC license.
|
|
992
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
993
|
+
*/const gO=[["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"}]],it=se("scroll-text",gO);/**
|
|
994
|
+
* @license lucide-react v0.511.0 - ISC
|
|
995
|
+
*
|
|
996
|
+
* This source code is licensed under the ISC license.
|
|
997
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
998
|
+
*/const bO=[["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"}]],xO=se("search-x",bO);/**
|
|
999
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1000
|
+
*
|
|
1001
|
+
* This source code is licensed under the ISC license.
|
|
1002
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1003
|
+
*/const yO=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Jy=se("search",yO);/**
|
|
1004
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1005
|
+
*
|
|
1006
|
+
* This source code is licensed under the ISC license.
|
|
1007
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1008
|
+
*/const vO=[["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"}]],mn=se("server",vO);/**
|
|
1009
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1010
|
+
*
|
|
1011
|
+
* This source code is licensed under the ISC license.
|
|
1012
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1013
|
+
*/const wO=[["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"}]],tn=se("settings",wO);/**
|
|
1014
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1015
|
+
*
|
|
1016
|
+
* This source code is licensed under the ISC license.
|
|
1017
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1018
|
+
*/const NO=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],kO=se("share-2",NO);/**
|
|
1019
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1020
|
+
*
|
|
1021
|
+
* This source code is licensed under the ISC license.
|
|
1022
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1023
|
+
*/const SO=[["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"}]],gn=se("shield-check",SO);/**
|
|
1024
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1025
|
+
*
|
|
1026
|
+
* This source code is licensed under the ISC license.
|
|
1027
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1028
|
+
*/const CO=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]],Fp=se("shield-off",CO);/**
|
|
1029
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1030
|
+
*
|
|
1031
|
+
* This source code is licensed under the ISC license.
|
|
1032
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1033
|
+
*/const MO=[["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"}]],EO=se("shield-x",MO);/**
|
|
1034
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1035
|
+
*
|
|
1036
|
+
* This source code is licensed under the ISC license.
|
|
1037
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1038
|
+
*/const IO=[["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"}]],AO=se("shield",IO);/**
|
|
1039
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1040
|
+
*
|
|
1041
|
+
* This source code is licensed under the ISC license.
|
|
1042
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1043
|
+
*/const PO=[["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"}]],vs=se("skull",PO);/**
|
|
1044
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1045
|
+
*
|
|
1046
|
+
* This source code is licensed under the ISC license.
|
|
1047
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1048
|
+
*/const _O=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],An=se("smartphone",_O);/**
|
|
1049
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1050
|
+
*
|
|
1051
|
+
* This source code is licensed under the ISC license.
|
|
1052
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1053
|
+
*/const $O=[["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"}]],DO=se("sparkles",$O);/**
|
|
1054
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1055
|
+
*
|
|
1056
|
+
* This source code is licensed under the ISC license.
|
|
1057
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1058
|
+
*/const LO=[["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"}]],ev=se("square-check-big",LO);/**
|
|
1059
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1060
|
+
*
|
|
1061
|
+
* This source code is licensed under the ISC license.
|
|
1062
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1063
|
+
*/const TO=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ns=se("square",TO);/**
|
|
1064
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1065
|
+
*
|
|
1066
|
+
* This source code is licensed under the ISC license.
|
|
1067
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1068
|
+
*/const RO=[["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"}]],ji=se("star",RO);/**
|
|
1069
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1070
|
+
*
|
|
1071
|
+
* This source code is licensed under the ISC license.
|
|
1072
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1073
|
+
*/const OO=[["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"}]],BO=se("sun",OO);/**
|
|
1074
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1075
|
+
*
|
|
1076
|
+
* This source code is licensed under the ISC license.
|
|
1077
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1078
|
+
*/const zO=[["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"}]],FO=se("table-2",zO);/**
|
|
1079
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1080
|
+
*
|
|
1081
|
+
* This source code is licensed under the ISC license.
|
|
1082
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1083
|
+
*/const jO=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],tv=se("terminal",jO);/**
|
|
1084
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1085
|
+
*
|
|
1086
|
+
* This source code is licensed under the ISC license.
|
|
1087
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1088
|
+
*/const VO=[["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"}]],Ze=se("trash-2",VO);/**
|
|
1089
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1090
|
+
*
|
|
1091
|
+
* This source code is licensed under the ISC license.
|
|
1092
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1093
|
+
*/const HO=[["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"}]],tt=se("triangle-alert",HO);/**
|
|
1094
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1095
|
+
*
|
|
1096
|
+
* This source code is licensed under the ISC license.
|
|
1097
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1098
|
+
*/const qO=[["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"}]],Ja=se("upload",qO);/**
|
|
1099
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1100
|
+
*
|
|
1101
|
+
* This source code is licensed under the ISC license.
|
|
1102
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1103
|
+
*/const UO=[["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"}]],QO=se("users",UO);/**
|
|
1104
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1105
|
+
*
|
|
1106
|
+
* This source code is licensed under the ISC license.
|
|
1107
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1108
|
+
*/const GO=[["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"}]],nv=se("video",GO);/**
|
|
1109
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1110
|
+
*
|
|
1111
|
+
* This source code is licensed under the ISC license.
|
|
1112
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1113
|
+
*/const KO=[["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"}]],rv=se("wifi-off",KO);/**
|
|
1114
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1115
|
+
*
|
|
1116
|
+
* This source code is licensed under the ISC license.
|
|
1117
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1118
|
+
*/const WO=[["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"}]],or=se("wifi",WO);/**
|
|
1119
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1120
|
+
*
|
|
1121
|
+
* This source code is licensed under the ISC license.
|
|
1122
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1123
|
+
*/const YO=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Fe=se("x",YO);/**
|
|
1124
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1125
|
+
*
|
|
1126
|
+
* This source code is licensed under the ISC license.
|
|
1127
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1128
|
+
*/const ZO=[["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"}]],XO=se("wrench",ZO);/**
|
|
1129
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1130
|
+
*
|
|
1131
|
+
* This source code is licensed under the ISC license.
|
|
1132
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1133
|
+
*/const JO=[["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"}]],Yd=se("zap",JO);function e8(){const e=Le(),t=ke(),[n,r]=_(()=>e.isConnected()?"connected":"disconnected"),s=te(!1),[a,i]=_(0),[l,c]=_([]);Y(()=>e.subscribeConnectionEvents(h=>{r(m=>(m!=="connected"&&h==="connected"&&s.current&&i(g=>g+1),h!=="connected"&&(s.current=!0),h))}),[e]),Y(()=>{a!==0&&t.invalidateQueries({queryKey:[["addons","getLastRestart"]]})},[a,t]);const{data:d}=lb(void 0,{enabled:n==="connected"&&a>0,staleTime:0,refetchOnMount:!1,refetchOnWindowFocus:!1}),u=te(null);return Y(()=>{if(d==null||d.requestedAt===u.current)return;u.current=d.requestedAt;const p=r8(d);c(m=>[...m,p]);const h=window.setTimeout(()=>{c(m=>m.filter(g=>g.id!==p.id))},6e3);return()=>window.clearTimeout(h)},[d]),f(he,{children:[n!=="connected"&&o(t8,{state:n}),l.length>0&&o(n8,{toasts:l})]})}function t8({state:e}){return o("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/70 backdrop-blur-sm",children:f("div",{className:"flex flex-col items-center gap-3 text-foreground",children:[o(Se,{className:"w-10 h-10 animate-spin text-primary"}),o("div",{className:"text-sm font-medium",children:e==="connecting"?"Reconnecting…":"Server unreachable"}),o("div",{className:"text-[11px] text-foreground-subtle max-w-xs text-center",children:e==="connecting"?"Waiting for the hub to finish restarting. This usually takes 10–15 seconds.":"Lost connection to the hub. The reconnect will resume automatically once the server is back up."})]})})}function n8({toasts:e}){return o("div",{className:"fixed top-4 right-4 z-50 flex flex-col gap-2 max-w-sm w-full pointer-events-none",children:e.map(t=>f("div",{className:"pointer-events-auto flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm",children:[o(Ud,{className:"w-4 h-4 shrink-0 mt-0.5 text-green-400"}),f("div",{children:[o("div",{className:"text-[11px] font-semibold text-foreground",children:t.title}),o("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:t.message})]})]},t.id))})}function r8(e){const t=`restart-${e.requestedAt}`;if(e.kind==="framework-update"&&e.packageName!==void 0&&e.toVersion!==void 0){const n=e.fromVersion!==void 0?`v${e.fromVersion} → v${e.toVersion}`:`v${e.toVersion}`;return{id:t,title:"Framework updated",message:`${e.packageName} is now ${n}.`}}return{id:t,title:"Server restarted",message:e.requestedBy!==void 0?`Manual restart by ${e.requestedBy} completed.`:"Manual restart completed."}}function o8(e){const t=wn();return t===null?o("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."}):o(ht,{widgetId:"pipeline-orchestrator/zone-editor",host:"device-tab",deviceId:t})}function s8({deviceId:e}){return f("div",{className:$m,children:[f("div",{className:`grid ${Dm}`,style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 340px), 1fr))"},children:[o(ht,{widgetId:"pipeline-analytics/live-occupancy-panel",host:"device-tab",deviceId:e}),o(ht,{widgetId:"pipeline-analytics/audio-metrics-panel",host:"device-tab",deviceId:e})]}),o(ht,{widgetId:"pipeline-analytics/audio-history-chart",host:"device-tab",deviceId:e}),o(ht,{widgetId:"pipeline-analytics/occupancy-history-chart",host:"device-tab",deviceId:e}),o(ht,{widgetId:"pipeline-analytics/motion-history-chart",host:"device-tab",deviceId:e}),o(ht,{widgetId:"pipeline-analytics/detection-history-chart",host:"device-tab",deviceId:e})]})}function a8(e){const t=wn();return t===null?o("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."}):o(s8,{deviceId:t})}function i8(e){const t=Le();return Ln({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"),r=Reflect.get(t.trpcClient,e.capName);if(!n(r))throw new Error(`useFieldResolver: no cap namespace '${e.capName}' on the tRPC client`);const s=Reflect.get(r,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 l8(e){return typeof e=="string"&&e.length>0&&e!=="undefined"&&e!=="null"}function c8(e={}){const t=ke(),n=Yr(void 0,{staleTime:1e4,enabled:e.enabled??!0}),r=q(()=>(n.data??[]).filter(i=>l8(i.nodeId)),[n.data]),s=U(()=>{t.invalidateQueries({queryKey:["pipelineOrchestrator","listAgentSettings"]})},[t]);return{agents:r,isLoading:n.isLoading,isError:n.isError,error:n.error,refetch:()=>{n.refetch()},invalidate:s}}function d8({field:e,disabled:t}){const n=ke(),r=e.deviceId,s=i8(e.catalogResolver),a=fd({agentNodeId:e.nodeId}),i=md({deviceId:r}),c=Yx({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),d=s.data,u=a.data??null,p=i.data??null,h=q(()=>d?p8(d,u,p):[],[d,u,p]),m=q(()=>{if(!u)return{};const g={};for(const[b,x]of Object.entries(u.addonDefaults))g[b]=x.enabled;return g},[u]);return s.error?f("div",{className:"text-xs text-red-400",children:["Failed to load pipeline catalog for ",o("code",{children:e.nodeId}),": ",String(s.error.message??s.error)]}):s.isLoading||!d||a.isLoading?f("div",{className:"text-xs text-foreground-subtle animate-pulse",children:["Loading pipeline for ",e.nodeId,"…"]}):f("div",{className:"col-span-full space-y-4",children:[f("div",{className:"flex items-center gap-2 text-[11px] text-foreground-subtle",children:["Agent: ",o("span",{className:"text-foreground",children:e.nodeId}),f("span",{className:"ml-2",children:["Engine: ",o("span",{className:"text-foreground font-mono",children:`${d.selectedEngine.runtime}/${d.selectedEngine.backend}`})]}),f("span",{className:"ml-auto text-[10px]",children:["Model + settings edited on Pipeline → ",e.nodeId,"."]})]}),o(Xc,{schema:d,steps:h,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:r,addonId:g,enabled:b}),inheritedEnabledByAddon:m}),o(u8,{deviceId:r,currentAgentNodeId:e.nodeId,catalog:d,pipelineByAgent:p?.pipelineByAgent??{},disabled:t===!0})]})}function u8({deviceId:e,currentAgentNodeId:t,catalog:n,pipelineByAgent:r,disabled:s}){const a=ke(),[i,l]=_(!1),[c,d]=_(t),{agents:u}=c8({enabled:i}),p=Jx({deviceId:e,agentNodeId:c},{enabled:i}),m=Xx({onSuccess:()=>{a.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),a.invalidateQueries({queryKey:[["pipelineOrchestrator","resolvePipeline"]]})}}),g=r[c]??null,b=u,x=q(()=>g?f8(g.steps,n):[],[g,n]),y=w=>{const v=g?.audio??null;m.mutate({deviceId:e,agentNodeId:c,pipeline:{steps:h8(w),audio:v?{modelId:v.modelId,enabled:v.enabled}:null}})};return f("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("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?o(lt,{className:"h-3 w-3"}):o(Nt,{className:"h-3 w-3"}),o("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:"Advanced — custom pipeline per agent"}),o("span",{className:"ml-auto text-[10px] text-foreground-subtle",children:Object.keys(r).length>0?`${Object.keys(r).length} override(s) active`:"None configured"})]}),i&&f("div",{className:"border-t border-border px-4 py-3 space-y-3",children:[f("div",{className:"flex items-center gap-2 text-xs",children:[o("span",{className:"text-foreground-subtle",children:"Agent:"}),f("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"&&f("option",{value:t,children:[t," (current)"]}),b.filter(w=>w.nodeId!==t).map(w=>o("option",{value:w.nodeId,children:w.nodeId},w.nodeId))]}),r[c]&&f("button",{type:"button",onClick:()=>{window.confirm(`Remove custom pipeline override for ${c}? The camera will revert to the agent default + step toggles.`)&&m.mutate({deviceId:e,agentNodeId:c,pipeline:null})},disabled:s||m.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:[o(Ze,{className:"h-3 w-3"}),"Remove override"]})]}),g?o(Xc,{schema:n,steps:x,onChange:y,templates:[],selectedTemplateId:null,onSelectTemplate:()=>{},onSaveTemplate:()=>{},onUpdateTemplate:()=>{},onDeleteTemplate:()=>{},readOnly:s,hideTemplates:!0}):f("div",{className:"text-xs text-foreground-subtle space-y-2",children:[f("p",{children:["No custom pipeline for ",o("code",{children:c}),". The camera uses the agent's default + step toggles."]}),o("button",{type:"button",onClick:()=>{const w=p.data;w&&m.mutate({deviceId:e,agentNodeId:c,pipeline:{steps:w.steps,audio:w.audio?{modelId:w.audio.modelId,enabled:w.audio.enabled}:null}})},disabled:s||m.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 p8(e,t,n){const r=d=>{for(const u of e.slots)for(const p of u.addons)if(p.id===d)return p;return null},s=d=>{const u=t?.addonDefaults[d.id],p=u?.enabled??d.enabledByDefault??!0,h=n?.stepToggles?.[d.id],m=h!==void 0?h:p;return{addonId:d.id,addonName:d.name,slot:d.slot,inputClasses:[...d.inputClasses],outputClasses:[...d.outputClasses],enabled:m,modelId:u?.modelId??d.defaultModelId,children:[],...u?.settings&&Object.keys(u.settings).length>0?{settings:u.settings}:{}}},a=new Map;for(const d of e.slots)for(const u of d.addons)a.set(u.id,s(u));const i=[],l=new Set;for(const[d,u]of a){const p=r(d);p&&p.inputClasses.length===0&&(i.push(u),l.add(d))}let c=!0;for(;c;){c=!1;for(const[d,u]of a){if(l.has(d))continue;const p=r(d);if(p)for(const[h,m]of a){if(h===d)continue;const g=r(h);if(g&&l.has(h)&&g.outputClasses.some(b=>p.inputClasses.includes(b))){m.children.push(u),l.add(d),c=!0;break}}}}return i}function f8(e,t){const n=new Map;for(const s of t.slots)for(const a of s.addons)n.set(a.id,a);const r=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(r),...s.settings?{settings:{...s.settings}}:{}}};return[...e].map(r)}function h8(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 m8({tabs:e,active:t,onChange:n}){return o("div",{className:"flex rounded-lg border border-border bg-surface p-0.5 gap-0.5",children:e.map(r=>o("button",{type:"button",onClick:()=>n(r.id),className:["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",t===r.id?"bg-primary/12 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"].join(" "),children:r.label},r.id))})}function g8(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 r=Math.min(...n),s=Math.max(...n);return r===s?`${r} MB`:`${r}-${s} MB`}function b8(e){return`${e.inputSize.width}x${e.inputSize.height}`}function x8(e){return e.formats?Object.keys(e.formats).filter(t=>e.formats[t]!==void 0):[]}function y8({entry:e,selected:t,onSelect:n,disabled:r}){const s=g8(e),a=b8(e),i=x8(e);return f("button",{type:"button",onClick:n,disabled:r,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",r?"opacity-50 cursor-not-allowed":"cursor-pointer"].join(" "),children:[o("div",{className:"flex items-start justify-between gap-2",children:f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-xs font-semibold text-foreground truncate",children:e.name}),t&&o(_t,{className:"h-3.5 w-3.5 text-primary shrink-0"})]}),o("p",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-2",children:e.description})]})}),f("div",{className:"flex items-center gap-3 mt-2 flex-wrap",children:[f("span",{className:"inline-flex items-center gap-1 text-[10px] text-foreground-subtle",children:[o(xt,{className:"h-3 w-3"}),a]}),s&&o("span",{className:"text-[10px] text-foreground-subtle",children:s}),i.length>0&&o("div",{className:"flex gap-1",children:i.map(l=>o("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&&f("span",{className:"text-[10px] text-foreground-subtle",children:[e.labels.length," label",e.labels.length!==1?"s":""]})]})]})}function v8({field:e,value:t,onChange:n,disabled:r}){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"),u=t==null?"":String(t);return f("div",{className:"space-y-3",children:[l.length>1&&o(m8,{tabs:l,active:c,onChange:d}),c==="catalog"&&a&&o("div",{className:"space-y-1.5 max-h-[320px] overflow-y-auto pr-1",children:s.map(p=>o(y8,{entry:p,selected:u===p.id,onSelect:()=>n(p.id),disabled:r||e.disabled},p.id))}),c==="catalog"&&!a&&f("div",{className:"rounded-md border border-info/30 bg-info/5 px-3 py-2 flex items-start gap-2",children:[o(rr,{className:"h-3.5 w-3.5 text-info shrink-0 mt-0.5"}),o("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&&f("div",{className:"space-y-2",children:[o("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:u,disabled:r||e.disabled,onChange:p=>n(p.target.value)}),e.acceptFormats&&e.acceptFormats.length>0&&f("p",{className:"text-[10px] text-foreground-subtle",children:["Accepted formats: ",e.acceptFormats.join(", ")]})]}),(e.compatibilityNote||e.conversionGuideUrl)&&f("div",{className:"flex items-start justify-between gap-3 pt-1",children:[e.compatibilityNote&&f("p",{className:"flex items-start gap-1 text-[10px] text-foreground-subtle",children:[o(rr,{className:"h-3 w-3 mt-0.5 shrink-0"}),e.compatibilityNote]}),e.conversionGuideUrl&&f("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",o(Qd,{className:"h-3 w-3"})]})]})]})}function ov(e){const t=Le();return xy(t.trpcClient,e)}function w8({deviceId:e,deviceName:t,hasPTZ:n=!1,className:r}){const s=Le(),a=typeof window<"u"?window.location.origin:"",i=Number.isFinite(e),[l,c]=_(!1),d=i&&n&&l,u=At(s.trpcClient,i?e:null),p=te(!1),{data:h,isLoading:m,isFetching:g,refetch:b}=Ln({queryKey:["device",e,"snapshot.getSnapshot"],queryFn:()=>{const I=p.current;return p.current=!1,u?.snapshot?.getSnapshot({force:I})??null},enabled:!!u&&i,staleTime:5e3,retry:!1}),x=()=>{p.current=!0,b()},{streams:y,pipelineMetrics:w,createSession:v,sendAnswer:N,closeSession:k}=_d(s.trpcClient,i?e:null),C=ov(i?e:null),M=$d(s.trpcClient,i?e:0,{enabled:d}),P=h?`data:${h.contentType};base64,${h.base64}`:null;return o(kd,{serverUrl:a,createSession:v,sendAnswer:N,closeSession:k,streams:y,pipelineMetrics:w,deviceName:t,phase:C.phase,detections:C,defaultShowDetections:!1,defaultShowMotion:!1,autoPlay:!1,showPlayStop:!0,snapshotSrc:P,snapshotLoading:m||g,onRefreshSnapshot:x,ptzAvailable:i&&n,ptzShown:d,onPtzToggle:()=>c(I=>!I),ptzOverlay:d?o(Ed,{controls:M}):void 0,className:r})}function N8(){const e=wn(),t=ed();if(e===null)return null;const n=typeof t?.name=="string"?t.name:"",s=(t?.features??[]).includes(Kn.PanTiltZoom);return o(w8,{deviceId:e,deviceName:n,hasPTZ:s})}function Ct(e,t){const n=Le(),r=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 u=JSON.parse(l),h=u.length===1&&Array.isArray(u[0])?u:[u];r.invalidateQueries({queryKey:h})};d();for(const u of i.split("|"))if(u)try{c.push(n.subscribeEvent(u,d))}catch{}return()=>{for(const u of c)u()}},[n,r,i,l,s])}function ws({icon:e,label:t,value:n,subtext:r,color:s}){return f("div",{className:"rounded-lg border border-border bg-surface p-2 sm:p-2.5 min-w-0",children:[f("div",{className:"flex items-center gap-1.5 mb-0.5 min-w-0",children:[o(e,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),o("span",{className:`${ea} uppercase tracking-wider whitespace-nowrap overflow-hidden text-ellipsis min-w-0`,children:t})]}),o("p",{className:`${s?`${Il.replace("text-foreground","")} ${s}`:Il} whitespace-nowrap overflow-hidden text-ellipsis`,children:n}),r&&o("p",{className:`${ea} mt-0.5 truncate`,children:r})]})}function Ns({label:e,value:t,warning:n}){return f("div",{className:"min-w-0",children:[o("p",{className:`${ea} truncate`,children:e}),o("p",{className:`text-[11px] font-medium truncate ${n?"text-warning":"text-foreground"}`,children:t})]})}function dn({label:e,value:t}){return f("div",{className:`${Lm} flex items-start gap-2 sm:gap-3`,children:[o("span",{className:"w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle",children:e}),o("div",{className:"flex-1 min-w-0 text-[11px] text-foreground",children:t})]})}function k8(){const e=wn();Ct(["pipelineOrchestrator","getPipelineAssignment"],["pipeline.camera-assigned","pipeline.camera-unassigned","pipeline.camera-updated"]),Ct(["pipelineRunner","getCameraMetrics"],["pipeline.camera-metrics-snapshot"]);const{data:t}=ja({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}=gd({deviceId:e??0,...s?{nodeId:s}:{}},{enabled:e!==null,staleTime:2e3,retry:!1}),i=Le(),l=At(i.trpcClient,e),{data:c}=Ln({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,u=a?.detectionMode??null,p=Number(a?.actualFps??0),h=Number(a?.configuredFps??0),m=Number(a?.avgInferenceTimeMs??0),g=Number(a?.queueDepth??0),b=Number(a?.droppedFrames??0),x=ur(d??"watching"),y=c?.length??0;return f("div",{className:"grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4 gap-2 sm:gap-3",children:[o(ws,{icon:Jo,label:"Phase",value:x.label,color:x.textColor,subtext:u??void 0}),o(ws,{icon:qy,label:"Detection FPS",value:`${p.toFixed(1)}`,subtext:h>0?`target: ${h}`:void 0}),o(ws,{icon:xt,label:"Inference",value:`${m.toFixed(1)} ms`,subtext:g>0?`queue: ${g}`:void 0}),o(ws,{icon:ts,label:"Active Tracks",value:String(y),subtext:b>0?`dropped: ${b}`:void 0})]})}function Vi(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function S8(){const e=wn(),{data:t}=pd({deviceId:e??0},{enabled:e!==null,refetchInterval:5e3});if(e===null)return null;const n=t?.streams??{},r=Object.entries(n);return r.length===0?null:f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o("div",{className:"border-b border-border px-3 sm:px-4 py-2",children:o("h2",{className:"text-[11px] font-semibold text-foreground uppercase tracking-wider",children:"Stream Network"})}),o("div",{className:"divide-y divide-border",children:r.map(([s,a])=>f("div",{className:"px-3 sm:px-4 py-2",children:[f("div",{className:"flex items-center gap-1.5 mb-1.5",children:[o(or,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),o("span",{className:"text-[11px] font-medium text-foreground truncate",children:s})]}),f("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-2",children:[o(Ns,{label:"Nominal",value:Vi(a.nominalBitrateKbps??0)}),o(Ns,{label:"Observed",value:Vi(a.observedBitrateKbps??0)}),o(Ns,{label:"Peak",value:Vi(a.peakBitrateKbps??0)}),o(Ns,{label:"Packet Loss",value:`${(a.packetLossPercent??0).toFixed(2)}%`,warning:(a.packetLossPercent??0)>1})]})]},s))})]})}const C8=3e4;function M8({field:e}){const t=wn(),n=e.type==="doorbell-recent"&&typeof e.historyLimit=="number"?e.historyLimit:10,r=Dd({deviceId:t??void 0,historyLimit:n});if(t===null)return null;const s=r.latest?Date.now()-r.latest.timestamp<C8:!1;return o(Id,{history:r.history,latestIsFresh:s})}const E8={streaming:{icon:nv,label:"Streaming"},detection:{icon:ts,label:"Detection"},recording:{icon:jy,label:"Recording"},audio:{icon:Wl,label:"Audio"},snapshot:{icon:Dr,label:"Snapshot"},motion:{icon:Yd,label:"Motion"},ptz:{icon:tn,label:"PTZ"},webrtc:{icon:Xa,label:"WebRTC"},onvif:{icon:AO,label:"ONVIF"},analytics:{icon:xt,label:"Analytics"},"battery-operated":{icon:SR,label:"Battery"},"native-snapshot":{icon:Dr,label:"Native Snapshot"},"pan-tilt-zoom":{icon:tn,label:"PTZ"},"two-way-audio":{icon:Wl,label:"Two-way Audio"},"doorbell-button":{icon:es,label:"Doorbell"},rebootable:{icon:dt,label:"Rebootable"}},I8=Wa;function ei({capabilities:e,showLabels:t=!1}){return o("div",{className:"flex items-center gap-1 flex-wrap",children:e.map(n=>{const r=E8[n],s=r?.icon??I8,a=r?.label??n;return f("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:[o(s,{className:"h-3 w-3"}),t&&o("span",{children:a})]},n)})})}const A8={frigate:{icon:Fy,color:"#3b82f6",label:"Frigate"},scrypted:{icon:mn,color:"#a855f7",label:"Scrypted"},reolink:{icon:Xa,color:"#06b6d4",label:"Reolink"},homeassistant:{icon:v6,color:"#22d3ee",label:"Home Assistant"},rtsp:{icon:or,color:"#78716c",label:"RTSP"},onvif:{icon:or,color:"#78716c",label:"ONVIF"}},jp={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6"},P8={sm:"h-7 w-7",md:"h-8 w-8",lg:"h-10 w-10"};function sv(e){const t=e.toLowerCase();return t.startsWith("provider-")?t.slice(9):t}function _8(e){const t=sv(e);return A8[t]??{icon:Fy,color:"#78716c",label:e}}function $8(e){const t=sv(e);return`/api/addon-assets/${e.toLowerCase().startsWith("provider-")?e:`provider-${t}`}/assets/icon.svg`}function bn({type:e,size:t="md",showLabel:n}){const r=_8(e),s=r.icon,[a,i]=_(!1),l=$8(e);return f("div",{className:"flex items-center gap-2",children:[o("div",{className:`flex items-center justify-center rounded-lg ${P8[t]}`,style:{backgroundColor:`${r.color}15`},children:a?o(s,{className:jp[t],style:{color:r.color}}):o("img",{src:l,alt:r.label,className:jp[t],onError:()=>i(!0)})}),n&&o("span",{className:"text-xs font-medium text-foreground-subtle",children:r.label})]})}function D8({deviceId:e,initialName:t}){const n=ke(),[r,s]=_(!1),[a,i]=_(t),[l,c]=_(!1),d=te(null);Y(()=>{r||i(t)},[t,r]),Y(()=>{r&&d.current?.focus()},[r]);const u=zb({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDevice"]]}),n.invalidateQueries({queryKey:[["deviceManager","listAll"]]}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]})}}),p=async()=>{const m=a.trim();if(m.length===0||m===t){s(!1),i(t);return}c(!0);try{await u.mutateAsync({deviceId:e,name:m}),s(!1)}catch{}finally{c(!1)}},h=()=>{i(t),s(!1)};return r?o(dn,{label:"Name",value:f("div",{className:"flex items-center gap-1",children:[o("input",{ref:d,type:"text",value:a,onChange:m=>i(m.target.value),onKeyDown:m=>{m.key==="Enter"?p():m.key==="Escape"&&h()},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"}),o("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:o(_t,{className:"h-3 w-3"})}),o("button",{type:"button",onClick:h,disabled:l,className:"p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50","aria-label":"Cancel",children:o(Fe,{className:"h-3 w-3"})})]})}):o(dn,{label:"Name",value:f("div",{className:"flex items-center gap-2 group",children:[o("span",{className:"truncate",children:t}),o("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:o(eo,{className:"h-3 w-3 text-foreground-subtle"})})]})})}function L8({deviceId:e,initialLocation:t}){const n=ke(),[r,s]=_(!1),[a,i]=_(t??""),[l,c]=_(!1),d=te(null),{data:u}=jb(void 0,{staleTime:3e4,enabled:r}),p=u??[];Y(()=>{r||i(t??"")},[t,r]),Y(()=>{r&&d.current?.focus()},[r]);const h=Fb({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDevice"]]}),n.invalidateQueries({queryKey:[["deviceManager","listAll"]]}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]}),n.invalidateQueries({queryKey:[["deviceManager","listLocations"]]})}}),m=q(()=>{const y=a.trim().toLowerCase();return y.length===0?p:p.filter(w=>w.toLowerCase()!==y&&w.toLowerCase().includes(y))},[p,a]),g=a.trim().length>0&&!p.some(y=>y.toLowerCase()===a.trim().toLowerCase()),b=async y=>{const v=(y??a).trim(),N=v.length===0?null:v;if(N===(t??null)){s(!1);return}c(!0);try{await h.mutateAsync({deviceId:e,location:N}),s(!1)}catch{}finally{c(!1)}},x=()=>{i(t??""),s(!1)};return r?o(dn,{label:"Location",value:f("div",{className:"relative",children:[f("div",{className:"flex items-center gap-1",children:[o("input",{ref:d,type:"text",value:a,onChange:y=>i(y.target.value),onKeyDown:y=>{y.key==="Enter"?b():y.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"}),o("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:o(_t,{className:"h-3 w-3"})}),o("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:o(Fe,{className:"h-3 w-3"})})]}),(m.length>0||g)&&f("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:[m.map(y=>f("button",{type:"button",onClick:()=>{i(y),b(y)},className:"w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover",children:[o(z6,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),o("span",{className:"truncate",children:y})]},y)),g&&f("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:[o("span",{className:"text-foreground-subtle",children:"Create"}),f("span",{className:"font-medium truncate",children:['"',a.trim(),'"']})]})]})]})}):o(dn,{label:"Location",value:f("div",{className:"flex items-center gap-2 group",children:[t?o("span",{className:"truncate",children:t}):o("span",{className:"italic text-foreground-subtle",children:"unset"}),o("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:o(eo,{className:"h-3 w-3 text-foreground-subtle"})})]})})}const Vp=["manufacturer","model","hardware","firmware","serialNumber","uid","mac","itemNo"];function T8(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}function R8(e){return e==null?"—":typeof e=="string"||typeof e=="number"||typeof e=="boolean"?String(e):JSON.stringify(e)}function av(){const e=wn(),t=ed(),{data:n}=Jn({deviceId:e??0},{enabled:e!==null,staleTime:3e4}),r=n??t??null,[s,a]=_("identity");if(e===null||!r)return null;const i=String(r.stableId??""),l=String(r.name??""),c=String(r.type??""),d=String(r.addonId??""),u=r.features??[],p=r.location??null,h=r.metadata??null,m=h!==null&&Object.keys(h).length>0;return f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("div",{className:"border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3",children:[o("h2",{className:"text-[11px] font-semibold text-foreground uppercase tracking-wider",children:"Device Info"}),m&&f("div",{className:"flex items-center gap-1 rounded-md bg-surface-hover p-0.5",children:[o(Hp,{active:s==="identity",onClick:()=>a("identity"),label:"Identity"}),o(Hp,{active:s==="hardware",onClick:()=>a("hardware"),label:"Hardware"})]})]}),(!m||s==="identity")&&f("div",{className:"divide-y divide-border",children:[o(dn,{label:"ID",value:f("span",{className:"font-mono text-[11px] text-foreground",children:[`#${e}`,f("span",{className:"ml-1.5 text-foreground-subtle",children:["(",i,")"]})]})}),o(D8,{deviceId:e,initialName:l}),o(L8,{deviceId:e,initialLocation:p}),o(dn,{label:"Type",value:c}),o(dn,{label:"Provider",value:o(bn,{type:d,size:"sm",showLabel:!0})}),o(dn,{label:"Capabilities",value:u.length>0?o(ei,{capabilities:u,showLabels:!0}):o("span",{className:"text-[11px] text-foreground-subtle",children:"None"})})]}),m&&s==="hardware"&&o(O8,{metadata:h})]})}function Hp({active:e,onClick:t,label:n}){return o("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 O8({metadata:e}){const t=Vp.filter(s=>s in e),n=Object.keys(e).filter(s=>!Vp.includes(s)).sort(),r=[...t,...n];return f("div",{children:[o("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."}),o("div",{className:"divide-y divide-border",children:r.map(s=>o(dn,{label:T8(s),value:o("span",{className:"font-mono text-[11px] text-foreground break-all",children:R8(e[s])})},s))})]})}function Qs(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"),isAdmin:!!n.isAdmin,exp:Number(n.exp??0),scopes:F8(n.scopes)}}catch{return null}}const B8=new Set(["view","create","delete"]),z8=new Set(["category","capability","addon","device"]);function F8(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(typeof n!="object"||n===null)continue;const r=n,{type:s,access:a}=r;if(typeof s!="string"||!z8.has(s)||!Array.isArray(a))continue;const i=a.filter(c=>typeof c=="string"&&B8.has(c));if(i.length===0)continue;if(s==="device"){const c=r.targets;if(!Array.isArray(c))continue;const d=c.filter(u=>typeof u=="string"&&u.length>0);if(d.length===0)continue;t.push({type:"device",targets:d,access:i});continue}const l=r.target;if(typeof l=="string")if(s==="category"){if(l!=="device"&&l!=="system")continue;t.push({type:s,target:l,access:i})}else s==="capability"?t.push({type:s,target:l,access:i}):t.push({type:"addon",target:l,access:i})}return t}function j8(e){const t=Qs(e);return t?t.exp*1e3<Date.now():!0}const V8="changeme",iv=ze(null);function H8({children:e}){const[t,n]=_(null),[r,s]=_(!0),[a,i]=_(!1);Y(()=>{if(typeof window<"u"&&window.location.hash.startsWith("#token=")){const x=new URLSearchParams(window.location.hash.slice(1)).get("token");x&&(localStorage.setItem("camstack_admin_token",x),window.history.replaceState({},"","/admin"))}const p=localStorage.getItem("camstack_admin_token");if(!p){s(!1);return}if(j8(p)){localStorage.removeItem("camstack_admin_token"),s(!1);return}const h=Qs(p);if(!h){localStorage.removeItem("camstack_admin_token"),s(!1);return}Us().trpcClient.system.info.query().then(()=>n(h)).catch(b=>{const x=b?.data?.code;x==="UNAUTHORIZED"||x==="FORBIDDEN"?(localStorage.removeItem("camstack_admin_token"),Sr()):n(h)}).finally(()=>s(!1))},[]);const l=U(async(p,h)=>{const g=await Us().login(p,h);if(g.requiresTotp===!0)return{kind:"totp-required",challengeToken:g.token};const b=g.token;return localStorage.setItem("camstack_admin_token",b),Sr(),n(Qs(b)),i(h===V8),{kind:"ok"}},[]),c=U(async(p,h)=>{const b=(await Us().loginVerifyTotp(p,h)).token;localStorage.setItem("camstack_admin_token",b),Sr(),n(Qs(b)),i(!1)},[]),d=U(()=>{localStorage.removeItem("camstack_admin_token"),Sr(),n(null),i(!1)},[]),u=U(()=>{i(!1)},[]);return o(iv.Provider,{value:{user:t,loading:r,mustChangePassword:a,login:l,verifyTotp:c,logout:d,clearMustChangePassword:u},children:e})}function rn(){const e=ve(iv);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}function Dt({children:e,requireAdmin:t}){const{user:n,loading:r,mustChangePassword:s}=rn(),a=wt();return r?o("div",{className:"flex h-screen items-center justify-center bg-background text-foreground-subtle",children:"Loading..."}):n?s&&a.pathname!=="/change-password"?o(kt,{to:"/change-password",replace:!0}):t&&!n.isAdmin?o(kt,{to:"/access-denied",replace:!0}):o(he,{children:e}):o(kt,{to:"/login",replace:!0})}var Hi={};const Me=e=>typeof e=="string",ao=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},qp=e=>e==null?"":""+e,q8=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},U8=/###/g,Up=e=>e&&e.indexOf("###")>-1?e.replace(U8,"."):e,Qp=e=>!e||Me(e),vo=(e,t,n)=>{const r=Me(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(Qp(e))return{};const a=Up(r[s]);!e[a]&&n&&(e[a]=new n),Object.prototype.hasOwnProperty.call(e,a)?e=e[a]:e={},++s}return Qp(e)?{}:{obj:e,k:Up(r[s])}},Gp=(e,t,n)=>{const{obj:r,k:s}=vo(e,t,Object);if(r!==void 0||t.length===1){r[s]=n;return}let a=t[t.length-1],i=t.slice(0,t.length-1),l=vo(e,i,Object);for(;l.obj===void 0&&i.length;)a=`${i[i.length-1]}.${a}`,i=i.slice(0,i.length-1),l=vo(e,i,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},Q8=(e,t,n,r)=>{const{obj:s,k:a}=vo(e,t,Object);s[a]=s[a]||[],s[a].push(n)},la=(e,t)=>{const{obj:n,k:r}=vo(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},G8=(e,t,n)=>{const r=la(e,n);return r!==void 0?r:la(t,n)},lv=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?Me(e[r])||e[r]instanceof String||Me(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):lv(e[r],t[r],n):e[r]=t[r]);return e},Vn=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var K8={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const W8=e=>Me(e)?e.replace(/[&<>"'\/]/g,t=>K8[t]):e;class Y8{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 r=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,r),this.regExpQueue.push(t),r}}const Z8=[" ",",","?","!",";"],X8=new Y8(20),J8=(e,t,n)=>{t=t||"",n=n||"";const r=Z8.filter(i=>t.indexOf(i)<0&&n.indexOf(i)<0);if(r.length===0)return!0;const s=X8.getRegExp(`(${r.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},Yl=(e,t,n=".")=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;const r=t.split(n);let s=e;for(let a=0;a<r.length;){if(!s||typeof s!="object")return;let i,l="";for(let c=a;c<r.length;++c)if(c!==a&&(l+=n),l+=r[c],i=s[l],i!==void 0){if(["string","number","boolean"].indexOf(typeof i)>-1&&c<r.length-1)continue;a+=c-a+1;break}s=i}return s},Do=e=>e?.replace(/_/g,"-"),e9={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 ca{constructor(t,n={}){this.init(t,n)}init(t,n={}){this.prefix=n.prefix||"i18next:",this.logger=t||e9,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,r,s){return s&&!this.debug?null:(Me(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new ca(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new ca(this.logger,t)}}var Yt=new ca;class ti{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const s=this.observers[r].get(n)||0;this.observers[r].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 Kp extends ti{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,r,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],r&&(Array.isArray(r)?l.push(...r):Me(r)&&a?l.push(...r.split(a)):l.push(r)));const c=la(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!i||!Me(r)?c:Yl(this.data?.[t]?.[n],r,a)}addResource(t,n,r,s,a={silent:!1}){const i=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let l=[t,n];r&&(l=l.concat(i?r.split(i):r)),t.indexOf(".")>-1&&(l=t.split("."),s=n,n=l[1]),this.addNamespaces(n),Gp(this.data,l,s),a.silent||this.emit("added",t,n,r,s)}addResources(t,n,r,s={silent:!1}){for(const a in r)(Me(r[a])||Array.isArray(r[a]))&&this.addResource(t,n,a,r[a],{silent:!0});s.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,s,a,i={silent:!1,skipCopy:!1}){let l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),s=r,r=n,n=l[1]),this.addNamespaces(n);let c=la(this.data,l)||{};i.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?lv(c,r,a):c={...c,...r},Gp(this.data,l,c),i.silent||this.emit("added",t,n,r)}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 cv={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,s){return e.forEach(a=>{t=this.processors[a]?.process(t,n,r,s)??t}),t}};const dv=Symbol("i18next/PATH_KEY");function t9(){const e=[],t=Object.create(null);let n;return t.get=(r,s)=>(n?.revoke?.(),s===dv?e:(e.push(s),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function Ir(e,t){const{[dv]:n}=e(t9()),r=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(r)}`}return n.join(r)}const Wp={},qi=e=>!Me(e)&&typeof e!="boolean"&&typeof e!="number";class da extends ti{constructor(t,n={}){super(),q8(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Yt.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t,n={interpolation:{}}){const r={...n};if(t==null)return!1;const s=this.resolve(t,r);if(s?.res===void 0)return!1;const a=qi(s.res);return!(r.returnObjects===!1&&a)}extractFromKey(t,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const i=r&&t.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!J8(t,r,s);if(i&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:Me(a)?[a]:a};const d=t.split(r);(r!==s||r===s&&this.options.ns.indexOf(d[0])>-1)&&(a=d.shift()),t=d.join(s)}return{key:t,namespaces:Me(a)?[a]:a}}translate(t,n,r){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=Ir(t,{...this.options,...s})),Array.isArray(t)||(t=[String(t)]),t=t.map(R=>typeof R=="function"?Ir(R,{...this.options,...s}):String(R));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 u=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;u===void 0&&(u=":");const p=s.lng||this.language,h=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p?.toLowerCase()==="cimode")return h?a?{res:`${d}${u}${l}`,usedKey:l,exactUsedKey:l,usedLng:p,usedNS:d,usedParams:this.getUsedParamsDetails(s)}:`${d}${u}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:p,usedNS:d,usedParams:this.getUsedParamsDetails(s)}:l;const m=this.resolve(t,s);let g=m?.res;const b=m?.usedKey||l,x=m?.exactUsedKey||l,y=["[object Number]","[object Function]","[object RegExp]"],w=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,v=!this.i18nFormat||this.i18nFormat.handleAsObject,N=s.count!==void 0&&!Me(s.count),k=da.hasDefaultValue(s),C=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${C}`]||s[`defaultValue${M}`]||s.defaultValue;let z=g;v&&!g&&k&&(z=I);const A=qi(z),O=Object.prototype.toString.apply(z);if(v&&z&&A&&y.indexOf(O)<0&&!(Me(w)&&Array.isArray(z))){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const R=this.options.returnedObjectHandler?this.options.returnedObjectHandler(b,z,{...s,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(m.res=R,m.usedParams=this.getUsedParamsDetails(s),m):R}if(i){const R=Array.isArray(z),E=R?[]:{},D=R?x:b;for(const L in z)if(Object.prototype.hasOwnProperty.call(z,L)){const T=`${D}${i}${L}`;k&&!g?E[L]=this.translate(T,{...s,defaultValue:qi(I)?I[L]:void 0,joinArrays:!1,ns:c}):E[L]=this.translate(T,{...s,joinArrays:!1,ns:c}),E[L]===T&&(E[L]=z[L])}g=E}}else if(v&&Me(w)&&Array.isArray(g))g=g.join(w),g&&(g=this.extendTranslation(g,t,s,r));else{let R=!1,E=!1;!this.isValidLookup(g)&&k&&(R=!0,g=I),this.isValidLookup(g)||(E=!0,g=l);const L=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&E?void 0:g,T=k&&I!==g&&this.options.updateMissing;if(E||R||T){if(this.logger.log(T?"updateKey":"missingKey",p,d,l,T?I:g),i){const V=this.resolve(l,{...s,keySeparator:!1});V&&V.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 B=[];const F=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&F&&F[0])for(let V=0;V<F.length;V++)B.push(F[V]);else this.options.saveMissingTo==="all"?B=this.languageUtils.toResolveHierarchy(s.lng||this.language):B.push(s.lng||this.language);const j=(V,$,H)=>{const G=k&&H!==g?H:L;this.options.missingKeyHandler?this.options.missingKeyHandler(V,d,$,G,T,s):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(V,d,$,G,T,s),this.emit("missingKey",V,d,$,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?B.forEach(V=>{const $=this.pluralResolver.getSuffixes(V,s);P&&s[`defaultValue${this.options.pluralSeparator}zero`]&&$.indexOf(`${this.options.pluralSeparator}zero`)<0&&$.push(`${this.options.pluralSeparator}zero`),$.forEach(H=>{j([V],l+H,s[`defaultValue${H}`]||I)})}):j(B,l,I))}g=this.extendTranslation(g,t,s,m,r),E&&g===l&&this.options.appendNamespaceToMissingKey&&(g=`${d}${u}${l}`),(E||R)&&this.options.parseMissingKeyHandler&&(g=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${u}${l}`:l,R?g:void 0,s))}return a?(m.res=g,m.usedParams=this.getUsedParamsDetails(s),m):g}extendTranslation(t,n,r,s,a){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=Me(t)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let d;if(c){const p=t.match(this.interpolator.nestingRegexp);d=p&&p.length}let u=r.replace&&!Me(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(u={...this.options.interpolation.defaultVariables,...u}),t=this.interpolator.interpolate(t,u,r.lng||this.language||s.usedLng,r),c){const p=t.match(this.interpolator.nestingRegexp),h=p&&p.length;d<h&&(r.nest=!1)}!r.lng&&s&&s.res&&(r.lng=this.language||s.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,(...p)=>a?.[0]===p[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${p[0]} in key: ${n[0]}`),null):this.translate(...p,n),r)),r.interpolation&&this.interpolator.reset()}const i=r.postProcess||this.options.postProcess,l=Me(i)?[i]:i;return t!=null&&l?.length&&r.applyPostProcessor!==!1&&(t=cv.handle(l,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t,n={}){let r,s,a,i,l;return Me(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(c=>typeof c=="function"?Ir(c,{...this.options,...n}):c)),t.forEach(c=>{if(this.isValidLookup(r))return;const d=this.extractFromKey(c,n),u=d.key;s=u;let p=d.namespaces;this.options.fallbackNS&&(p=p.concat(this.options.fallbackNS));const h=n.count!==void 0&&!Me(n.count),m=h&&!n.ordinal&&n.count===0,g=n.context!==void 0&&(Me(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(r)||(l=x,!Wp[`${b[0]}-${x}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(Wp[`${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(y=>{if(this.isValidLookup(r))return;i=y;const w=[u];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(w,u,y,x,n);else{let N;h&&(N=this.pluralResolver.getSuffix(y,n.count,n));const k=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(h&&(n.ordinal&&N.indexOf(C)===0&&w.push(u+N.replace(C,this.options.pluralSeparator)),w.push(u+N),m&&w.push(u+k)),g){const M=`${u}${this.options.contextSeparator||"_"}${n.context}`;w.push(M),h&&(n.ordinal&&N.indexOf(C)===0&&w.push(M+N.replace(C,this.options.pluralSeparator)),w.push(M+N),m&&w.push(M+k))}}let v;for(;v=w.pop();)this.isValidLookup(r)||(a=v,r=this.getResource(y,x,v,n))}))})}),{res:r,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,r,s={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,n,r,s):this.resourceStore.getResource(t,n,r,s)}getUsedParamsDetails(t={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=t.replace&&!Me(t.replace);let s=r?t.replace:t;if(r&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!r){s={...s};for(const a of n)delete s[a]}return s}static hasDefaultValue(t){const n="defaultValue";for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&n===r.substring(0,n.length)&&t[r]!==void 0)return!0;return!1}}class Yp{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Yt.create("languageUtils")}getScriptPartFromCode(t){if(t=Do(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=Do(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(Me(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(r=>{if(n)return;const s=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(s))&&(n=s)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const s=this.getScriptPartFromCode(r);if(this.isSupportedCode(s))return n=s;const a=this.getLanguagePartFromCode(r);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)),Me(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}toResolveHierarchy(t,n){const r=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 Me(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))):Me(t)&&a(this.formatLanguageCode(t)),r.forEach(i=>{s.indexOf(i)<0&&a(this.formatLanguageCode(i))}),s}}const Zp={zero:0,one:1,two:2,few:3,many:4,other:5},Xp={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class n9{constructor(t,n={}){this.languageUtils=t,this.options=n,this.logger=Yt.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,n={}){const r=Do(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:r,type:s});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let i;try{i=new Intl.PluralRules(r,{type:s})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),Xp;if(!t.match(/-|_/))return Xp;const c=this.languageUtils.getLanguagePartFromCode(t);i=this.getRule(c,n)}return this.pluralRulesCache[a]=i,i}needsPlural(t,n={}){let r=this.getRule(t,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,n,r={}){return this.getSuffixes(t,r).map(s=>`${n}${s}`)}getSuffixes(t,n={}){let r=this.getRule(t,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((s,a)=>Zp[s]-Zp[a]).map(s=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(t,n,r={}){const s=this.getRule(t,r);return s?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${s.select(n)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",n,r))}}const Jp=(e,t,n,r=".",s=!0)=>{let a=G8(e,t,n);return!a&&s&&Me(n)&&(a=Yl(e,n,r),a===void 0&&(a=Yl(t,n,r))),a},Ui=e=>e.replace(/\$/g,"$$$$");class ef{constructor(t={}){this.logger=Yt.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:r,useRawValueToEscape:s,prefix:a,prefixEscaped:i,suffix:l,suffixEscaped:c,formatSeparator:d,unescapeSuffix:u,unescapePrefix:p,nestingPrefix:h,nestingPrefixEscaped:m,nestingSuffix:g,nestingSuffixEscaped:b,nestingOptionsSeparator:x,maxReplaces:y,alwaysFormat:w}=t.interpolation;this.escape=n!==void 0?n:W8,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=a?Vn(a):i||"{{",this.suffix=l?Vn(l):c||"}}",this.formatSeparator=d||",",this.unescapePrefix=u?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=h?Vn(h):m||Vn("$t("),this.nestingSuffix=g?Vn(g):b||Vn(")"),this.nestingOptionsSeparator=x||",",this.maxReplaces=y||1e3,this.alwaysFormat=w!==void 0?w:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"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,r,s){let a,i,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=m=>{if(m.indexOf(this.formatSeparator)<0){const y=Jp(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,r,{...s,...n,interpolationkey:m}):y}const g=m.split(this.formatSeparator),b=g.shift().trim(),x=g.join(this.formatSeparator).trim();return this.format(Jp(n,c,b,this.options.keySeparator,this.options.ignoreJSONStructure),x,r,{...s,...n,interpolationkey:b})};this.resetRegExp();const u=s?.missingInterpolationHandler||this.options.missingInterpolationHandler,p=s?.interpolation?.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>Ui(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?Ui(this.escape(m)):Ui(m)}].forEach(m=>{for(l=0;a=m.regex.exec(t);){const g=a[1].trim();if(i=d(g),i===void 0)if(typeof u=="function"){const x=u(t,a,s);i=Me(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!Me(i)&&!this.useRawValueToEscape&&(i=qp(i));const b=m.safeValue(i);if(t=t.replace(a[0],b),p?(m.regex.lastIndex+=i.length,m.regex.lastIndex-=a[0].length):m.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n,r={}){let s,a,i;const l=(c,d)=>{const u=this.nestingOptionsSeparator;if(c.indexOf(u)<0)return c;const p=c.split(new RegExp(`${Vn(u)}[ ]*{`));let h=`{${p[1]}`;c=p[0],h=this.interpolate(h,i);const m=h.match(/'/g),g=h.match(/"/g);((m?.length??0)%2===0&&!g||(g?.length??0)%2!==0)&&(h=h.replace(/'/g,'"'));try{i=JSON.parse(h),d&&(i={...d,...i})}catch(b){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,b),`${c}${u}${h}`}return i.defaultValue&&i.defaultValue.indexOf(this.prefix)>-1&&delete i.defaultValue,c};for(;s=this.nestingRegexp.exec(t);){let c=[];i={...r},i=i.replace&&!Me(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(u=>u.trim()).filter(Boolean),s[1]=s[1].slice(0,d)),a=n(l.call(this,s[1].trim(),i),i),a&&s[0]===t&&!Me(a))return a;Me(a)||(a=qp(a)),a||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),a=""),c.length&&(a=c.reduce((u,p)=>this.format(u,p,r.lng,{...r,interpolationkey:s[1].trim()}),a.trim())),t=t.replace(s[0],a),this.regexp.lastIndex=0}return t}}const r9=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const s=r[1].substring(0,r[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,""),u=l.trim();n[u]||(n[u]=d),d==="false"&&(n[u]=!1),d==="true"&&(n[u]=!0),isNaN(d)||(n[u]=parseInt(d,10))}})}return{formatName:t,formatOptions:n}},tf=e=>{const t={};return(n,r,s)=>{let a=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(a={...a,[s.interpolationkey]:void 0});const i=r+JSON.stringify(a);let l=t[i];return l||(l=e(Do(r),s),t[i]=l),l(n)}},o9=e=>(t,n,r)=>e(Do(n),r)(t);class s9{constructor(t={}){this.logger=Yt.create("formatter"),this.options=t,this.init(t)}init(t,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?tf:o9;this.formats={number:r((s,a)=>{const i=new Intl.NumberFormat(s,{...a});return l=>i.format(l)}),currency:r((s,a)=>{const i=new Intl.NumberFormat(s,{...a,style:"currency"});return l=>i.format(l)}),datetime:r((s,a)=>{const i=new Intl.DateTimeFormat(s,{...a});return l=>i.format(l)}),relativetime:r((s,a)=>{const i=new Intl.RelativeTimeFormat(s,{...a});return l=>i.format(l,a.range||"day")}),list:r((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()]=tf(n)}format(t,n,r,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:u}=r9(c);if(this.formats[d]){let p=l;try{const h=s?.formatParams?.[s.interpolationkey]||{},m=h.locale||h.lng||s.locale||s.lng||r;p=this.formats[d](l,m,{...u,...s,...h})}catch(h){this.logger.warn(h)}return p}else this.logger.warn(`there was no format function for ${d}`);return l},t)}}const a9=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class i9 extends ti{constructor(t,n,r,s={}){super(),this.backend=t,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=s,this.logger=Yt.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?.(r,s.backend,s)}queueLoad(t,n,r,s){const a={},i={},l={},c={};return t.forEach(d=>{let u=!0;n.forEach(p=>{const h=`${d}|${p}`;!r.reload&&this.store.hasResourceBundle(d,p)?this.state[h]=2:this.state[h]<0||(this.state[h]===1?i[h]===void 0&&(i[h]=!0):(this.state[h]=1,u=!1,i[h]===void 0&&(i[h]=!0),a[h]===void 0&&(a[h]=!0),c[p]===void 0&&(c[p]=!0)))}),u||(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,r){const s=t.split("|"),a=s[0],i=s[1];n&&this.emit("failedLoading",a,i,n),!n&&r&&this.store.addResourceBundle(a,i,r,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&r&&(this.state[t]=0);const l={};this.queue.forEach(c=>{Q8(c.loaded,[a],i),a9(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(d=>{l[d]||(l[d]={});const u=c.loaded[d];u.length&&u.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,r,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:r,tried:s,wait:a,callback:i});return}this.readingCalls++;const l=(d,u)=>{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&&u&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,a*2,i)},a);return}i(d,u)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const d=c(t,n);d&&typeof d.then=="function"?d.then(u=>l(null,u)).catch(l):l(null,d)}catch(d){l(d)}return}return c(t,n,l)}prepareLoading(t,n,r={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();Me(t)&&(t=this.languageUtils.toResolveHierarchy(t)),Me(n)&&(n=[n]);const a=this.queueLoad(t,n,r,s);if(!a.toLoad.length)return a.pending.length||s(),null;a.toLoad.forEach(i=>{this.loadOne(i)})}load(t,n,r){this.prepareLoading(t,n,{},r)}reload(t,n,r){this.prepareLoading(t,n,{reload:!0},r)}loadOne(t,n=""){const r=t.split("|"),s=r[0],a=r[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,r,s,a,i={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" 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(!(r==null||r==="")){if(this.backend?.create){const c={...i,isUpdate:a},d=this.backend.create.bind(this.backend);if(d.length<6)try{let u;d.length===5?u=d(t,n,r,s,c):u=d(t,n,r,s),u&&typeof u.then=="function"?u.then(p=>l(null,p)).catch(l):l(null,u)}catch(u){l(u)}else d(t,n,r,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const Qi=()=>({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]),Me(e[1])&&(t.defaultValue=e[1]),Me(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(r=>{t[r]=n[r]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),nf=e=>(Me(e.ns)&&(e.ns=[e.ns]),Me(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),Me(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),ks=()=>{},l9=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})},uv="__i18next_supportNoticeShown",c9=()=>!!(typeof globalThis<"u"&&globalThis[uv]||typeof process<"u"&&Hi&&Hi.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&Hi),d9=()=>{typeof globalThis<"u"&&(globalThis[uv]=!0)},u9=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 wo extends ti{constructor(t={},n){if(super(),this.options=nf(t),this.services={},this.logger=Yt,this.modules={external:[]},l9(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&&(Me(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const r=Qi();this.options={...r,...this.options,...nf(t)},this.options.interpolation={...r.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=r.overloadTranslationOptionHandler),this.options.showSupportNotice!==!1&&!u9(this)&&!c9()&&(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 💙"),d9());const s=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Yt.init(s(this.modules.logger),this.options):Yt.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=s9;const u=new Yp(this.options);this.store=new Kp(this.options.resources,this.options);const p=this.services;p.logger=Yt,p.resourceStore=this.store,p.languageUtils=u,p.pluralResolver=new n9(u,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.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===r.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 ef(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new i9(s(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",(m,...g)=>{this.emit(m,...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 da(this.services,this.options),this.translator.on("*",(m,...g)=>{this.emit(m,...g)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,n||(n=ks),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]=(...u)=>this.store[d](...u)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=(...u)=>(this.store[d](...u),this)});const l=ao(),c=()=>{const d=(u,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(u,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=ks){let r=n;const s=Me(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(s?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();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),r(l)})}else r(null)}reloadResources(t,n,r){const s=ao();return typeof t=="function"&&(r=t,t=void 0),typeof n=="function"&&(r=n,n=void 0),t||(t=this.languages),n||(n=this.options.ns),r||(r=ks),this.services.backendConnector.reload(t,n,a=>{s.resolve(),r(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"&&cv.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 r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;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 r=ao();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,r.resolve((...d)=>this.t(...d)),n&&n(l,(...d)=>this.t(...d))},i=l=>{!t&&!l&&this.services.languageDetector&&(l=[]);const c=Me(l)?l:l&&l[0],d=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(Me(l)?[l]:l);d&&(this.language||s(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector?.cacheUserLanguage?.(d)),this.loadResources(d,u=>{a(u,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),r}getFixedT(t,n,r){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||r||s.keyPrefix);const d={...this.options,...c};typeof c.keyPrefix=="function"&&(c.keyPrefix=Ir(c.keyPrefix,d));const u=this.options.keySeparator||".";let p;return c.keyPrefix&&Array.isArray(a)?p=a.map(h=>(typeof h=="function"&&(h=Ir(h,d)),`${c.keyPrefix}${u}${h}`)):(typeof a=="function"&&(a=Ir(a,d)),p=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(p,c)};return Me(t)?s.lng=t:s.lngs=t,s.ns=n,s.keyPrefix=r,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 r=n.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(r.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(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(r,t)&&(!s||i(a,t)))}loadNamespaces(t,n){const r=ao();return this.options.ns?(Me(t)&&(t=[t]),t.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{r.resolve(),n&&n(s)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=ao();Me(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=>{r.resolve(),n&&n(i)}),r):(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"],r=this.services?.languageUtils||new Yp(Qi());return t.toLowerCase().indexOf("-latn")>1?"ltr":n.indexOf(r.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},n){const r=new wo(t,n);return r.createInstance=wo.createInstance,r}cloneInstance(t={},n=ks){const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},a=new wo(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)},r){const l=Object.keys(this.store.data).reduce((c,d)=>(c[d]={...this.store.data[d]},c[d]=Object.keys(c[d]).reduce((u,p)=>(u[p]={...c[d][p]},u),c[d]),c),{});a.store=new Kp(l,s),a.services.resourceStore=a.store}if(t.interpolation){const c={...Qi().interpolation,...this.options.interpolation,...t.interpolation},d={...s,interpolation:c};a.services.interpolator=new ef(d)}return a.translator=new da(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 et=wo.createInstance();et.createInstance;et.dir;et.init;et.loadResources;et.reloadResources;et.use;et.changeLanguage;et.getFixedT;et.t;et.exists;et.setDefaultNamespace;et.hasLoadedNamespace;et.loadNamespaces;et.loadLanguages;const p9=(e,t,n,r)=>{const s=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(s,"warn","react-i18next::",!0);sr(s[0])&&(s[0]=`react-i18next:: ${s[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...s):console?.warn&&console.warn(...s)},rf={},Zl=(e,t,n,r)=>{sr(n)&&rf[n]||(sr(n)&&(rf[n]=new Date),p9(e,t,n,r))},pv=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}},Xl=(e,t,n)=>{e.loadNamespaces(t,pv(e,n))},of=(e,t,n,r)=>{if(sr(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return Xl(e,n,r);n.forEach(s=>{e.options.ns.indexOf(s)<0&&e.options.ns.push(s)}),e.loadLanguages(t,pv(e,r))},f9=(e,t,n={})=>!t.languages||!t.languages.length?(Zl(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(r,s)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&r.services.backendConnector.backend&&r.isLanguageChangingTo&&!s(r.isLanguageChangingTo,e))return!1}}),sr=e=>typeof e=="string",h9=e=>typeof e=="object"&&e!==null,m9=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,g9={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},b9=e=>g9[e],x9=e=>e.replace(m9,b9);let Jl={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:x9,transDefaultProps:void 0};const y9=(e={})=>{Jl={...Jl,...e}},v9=()=>Jl;let fv;const w9=e=>{fv=e},N9=()=>fv,k9={type:"3rdParty",init(e){y9(e.options.react),w9(e)}},S9=ze();class C9{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var hv={exports:{}},mv={};/**
|
|
1134
|
+
* @license React
|
|
1135
|
+
* use-sync-external-store-shim.production.js
|
|
1136
|
+
*
|
|
1137
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1138
|
+
*
|
|
1139
|
+
* This source code is licensed under the MIT license found in the
|
|
1140
|
+
* LICENSE file in the root directory of this source tree.
|
|
1141
|
+
*/var Lr=lm;function M9(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var E9=typeof Object.is=="function"?Object.is:M9,I9=Lr.useState,A9=Lr.useEffect,P9=Lr.useLayoutEffect,_9=Lr.useDebugValue;function $9(e,t){var n=t(),r=I9({inst:{value:n,getSnapshot:t}}),s=r[0].inst,a=r[1];return P9(function(){s.value=n,s.getSnapshot=t,Gi(s)&&a({inst:s})},[e,n,t]),A9(function(){return Gi(s)&&a({inst:s}),e(function(){Gi(s)&&a({inst:s})})},[e]),_9(n),n}function Gi(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!E9(e,n)}catch{return!0}}function D9(e,t){return t()}var L9=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?D9:$9;mv.useSyncExternalStore=Lr.useSyncExternalStore!==void 0?Lr.useSyncExternalStore:L9;hv.exports=mv;var gv=hv.exports;const T9=(e,t)=>{if(sr(t))return t;if(h9(t)&&sr(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},R9={t:T9,ready:!1},O9=()=>()=>{},qt=(e,t={})=>{const{i18n:n}=t,{i18n:r,defaultNS:s}=ve(S9)||{},a=n||r||N9();a&&!a.reportNamespaces&&(a.reportNamespaces=new C9),a||Zl(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const i=q(()=>({...v9(),...a?.options?.react,...t}),[a,t]),{useSuspense:l,keyPrefix:c}=i,d=s||a?.options?.defaultNS,u=sr(d)?[d]:d||["translation"],p=q(()=>u,u);a?.reportNamespaces?.addUsedNamespaces?.(p);const h=te(0),m=U(I=>{if(!a)return O9;const{bindI18n:z,bindI18nStore:A}=i,O=()=>{h.current+=1,I()};return z&&a.on(z,O),A&&a.store.on(A,O),()=>{z&&z.split(" ").forEach(R=>a.off(R,O)),A&&A.split(" ").forEach(R=>a.store.off(R,O))}},[a,i]),g=te(),b=U(()=>{if(!a)return R9;const I=!!(a.isInitialized||a.initializedStoreOnce)&&p.every(D=>f9(D,a,i)),z=t.lng||a.language,A=h.current,O=g.current;if(O&&O.ready===I&&O.lng===z&&O.keyPrefix===c&&O.revision===A)return O;const E={t:a.getFixedT(z,i.nsMode==="fallback"?p:p[0],c),ready:I,lng:z,keyPrefix:c,revision:A};return g.current=E,E},[a,p,c,i,t.lng]),[x,y]=_(0),{t:w,ready:v}=gv.useSyncExternalStore(m,b,b);Y(()=>{if(a&&!v&&!l){const I=()=>y(z=>z+1);t.lng?of(a,t.lng,p,I):Xl(a,p,I)}},[a,t.lng,p,v,l,x]);const N=a||{},k=te(null),C=te(),M=I=>{const z=Object.getOwnPropertyDescriptors(I);z.__original&&delete z.__original;const A=Object.create(Object.getPrototypeOf(I),z);if(!Object.prototype.hasOwnProperty.call(A,"__original"))try{Object.defineProperty(A,"__original",{value:I,writable:!1,enumerable:!1,configurable:!1})}catch{}return A},P=q(()=>{const I=N,z=I?.language;let A=I;I&&(k.current&&k.current.__original===I?C.current!==z?(A=M(I),k.current=A,C.current=z):A=k.current:(A=M(I),k.current=A,C.current=z));const O=!v&&!l?(...E)=>(Zl(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(...E)):w,R=[O,A,v];return R.t=O,R.i18n=A,R.ready=v,R},[w,N,v,N.resolvedLanguage,N.language,N.languages]);if(a&&l&&!v)throw new Promise(I=>{const z=()=>I();t.lng?of(a,t.lng,p,z):Xl(a,p,z)});return P},sf={info:rr,success:Ud,warning:tt,error:nr},B9={info:"text-blue-400",success:"text-green-400",warning:"text-amber-400",error:"text-red-400"},af={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 z9(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 r=Math.floor(n/60);if(r<24)return`${String(r)}h ago`;const s=Math.floor(r/24);return`${String(s)}d ago`}function lf({alert:e,onMarkRead:t,onDismiss:n}){const r=e.severity in sf?e.severity:"info",s=e.status in af?e.status:"active",a=sf[r],i=B9[r],l=af[s];return f("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:[o(a,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${i}`}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-1.5",children:[o("span",{className:`text-[11px] font-semibold ${e.read?"text-foreground-subtle":"text-foreground"}`,children:e.title}),!e.read&&o("span",{className:"h-1.5 w-1.5 rounded-full bg-primary shrink-0"})]}),o("div",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-2",children:e.message}),e.status==="in-progress"&&e.progress!==void 0&&f("div",{className:"mt-1.5 flex items-center gap-2",children:[o("div",{className:"flex-1 h-1 bg-surface-hover rounded-full overflow-hidden",children:o("div",{className:"h-full bg-primary rounded-full transition-all duration-300",style:{width:`${String(Math.min(100,Math.max(0,e.progress)))}%`}})}),f("span",{className:"text-[9px] text-foreground-subtle font-mono shrink-0",children:[String(Math.round(e.progress)),"%"]})]}),o("div",{className:"text-[9px] text-foreground-subtle/60 mt-1",children:z9(e.updatedAt)})]}),f("div",{className:"flex items-center gap-0.5 shrink-0",children:[!e.read&&o("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:o(_t,{className:"h-3 w-3 text-foreground-subtle"})}),e.status!=="in-progress"&&o("button",{type:"button",onClick:c=>{c.stopPropagation(),n(e.id)},className:"p-1 rounded hover:bg-surface-hover transition-colors",title:"Dismiss",children:o(Fe,{className:"h-3 w-3 text-foreground-subtle"})})]})]})}function cf({variant:e="icon",compact:t=!1}={}){const[n,r]=_(!1),[s,a]=_(!1),i=te(null),l=te(null),c=ke(),{data:d=0}=wb(void 0,{staleTime:1e4,refetchInterval:3e4}),{data:u=[],isLoading:p}=vb({limit:50},{enabled:n,staleTime:5e3}),h=s?u:u.filter(I=>!I.read),m=u.filter(I=>I.read).length,g=()=>{c.invalidateQueries({queryKey:[["alerts"]]})},b=Nb({onSuccess:g}),x=kb({onSuccess:g}),y=Sb({onSuccess:g});bt("alert.created",()=>{c.invalidateQueries({queryKey:[["alerts"]]})}),bt("alert.updated",()=>{c.invalidateQueries({queryKey:[["alerts"]]})}),Y(()=>{if(!n)return;const I=z=>{const A=z.target;i.current&&!i.current.contains(A)&&l.current&&!l.current.contains(A)&&r(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[n]);const w=U(I=>{b.mutate({alertId:I})},[b]),v=U(I=>{I&&y.mutate({alertId:I})},[y]),N=U(()=>{x.mutate(void 0),r(!1)},[x]),k=h.filter(I=>I.status==="in-progress"),C=h.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]),f("div",{children:[e==="sidebar"?f("button",{ref:l,type:"button",onClick:()=>r(!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:[f("span",{className:"relative inline-flex shrink-0",children:[o(it,{className:"h-3.5 w-3.5"}),t&&d>0&&o("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary"})]}),!t&&o("span",{className:"flex-1 text-left",children:"Alerts"}),!t&&d>0&&o("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)})]}):f("button",{ref:l,type:"button",onClick:()=>r(!n),className:"relative p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors","aria-label":"Alerts",children:[o(it,{className:"h-4.5 w-4.5"}),d>0&&o("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&&Uo(f("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:[f("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border shrink-0",children:[o("span",{className:"text-[12px] font-semibold text-foreground",children:"Alerts"}),f("div",{className:"flex items-center gap-2",children:[m>0&&f("label",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle cursor-pointer select-none",children:[o("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&&f("button",{type:"button",onClick:N,className:"flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors",children:[o(BR,{className:"h-3 w-3"}),"Mark all read"]})]})]}),f("div",{className:"flex-1 overflow-y-auto",children:[p&&o("div",{className:"flex items-center justify-center py-8",children:o(Se,{className:"h-4 w-4 animate-spin text-foreground-subtle"})}),!p&&h.length===0&&f("div",{className:"flex flex-col items-center justify-center py-8 text-foreground-subtle",children:[o(it,{className:"h-6 w-6 mb-2 opacity-40"}),o("span",{className:"text-[11px]",children:u.length>0?"No unread alerts":"No alerts"}),u.length>0&&!s&&f("button",{type:"button",onClick:()=>a(!0),className:"text-[10px] text-primary mt-1 hover:underline",children:["Show ",m," read alert",m!==1?"s":""]})]}),k.length>0&&f("div",{className:"border-b border-border",children:[o("div",{className:"px-3 py-1.5 bg-surface-hover/50",children:o("span",{className:"text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:"In Progress"})}),k.map(I=>o(lf,{alert:I,onMarkRead:w,onDismiss:v},I.id))]}),C.map(I=>o(lf,{alert:I,onMarkRead:w,onDismiss:v},I.id))]})]}),document.body)]})}function bv(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 df=new Map,Ss=new Map,uf=new Set;function F9(e){return!e||typeof e!="object"?!1:typeof e.default=="function"}async function j9(e,t){const n=df.get(e);if(n)return n;const r=Ss.get(e);if(r)return r;uf.has(e)||(Ec(),_r.registerRemotes([{name:e,entry:t,type:"module"}],{force:!1}),uf.add(e));const s=_r.loadRemote(`${e}/page`).then(a=>{if(!F9(a))throw new Error(`Addon page remote ${e} (${t}) does not expose a default React component on './page'`);return df.set(e,a.default),Ss.delete(e),a.default}).catch(a=>{throw Ss.delete(e),a});return Ss.set(e,s),s}function V9(){const{pagePath:e}=Rd(),t=Le(),{data:n}=Ba(void 0,{staleTime:6e4}),r=q(()=>n?bv(n):void 0,[n]),s=r?.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 j9(s.remoteName,s.bundleUrl).then(u=>{d||i(()=>u)}).catch(u=>{if(d)return;const p=u instanceof Error?u.message:String(u);c(`Failed to load addon page: ${p}`)}),()=>{d=!0}},[s]),r?s?l?o("div",{className:"flex items-center justify-center h-full text-red-400 text-sm",children:l}):a?o(a,{trpc:t.trpcClient,theme:{isDark:document.documentElement.classList.contains("dark")},navigate:d=>{window.location.href=d}}):o("div",{className:"flex items-center justify-center h-full",children:o("div",{className:"animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full"})}):o("div",{className:"flex items-center justify-center h-full text-foreground-subtle",children:"Addon page not found"}):o("div",{className:"flex items-center justify-center h-full",children:o("div",{className:"animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full"})})}const H9={dark:Ky,light:BO,system:G6},q9={gauge:qy,puzzle:$o,bot:AR,cpu:xt,terminal:tv,box:Wa,wrench:XO,activity:Jo,plug:_o};function U9(){const e=wt(),t=ot(),{user:n,logout:r}=rn(),s=Hr(),{t:a}=qt(),i=hr(),l=yg(),c=pR(),d=c!=="connected",u=c==="connecting",[p,h]=_(!1),[m,g]=_(()=>typeof window>"u"?!1:window.localStorage.getItem("camstack:sidebar-collapsed")==="1");Y(()=>{typeof window>"u"||window.localStorage.setItem("camstack:sidebar-collapsed",m?"1":"0")},[m]);const[b,x]=_(()=>{if(typeof window>"u")return new Set;try{const $=window.localStorage.getItem("camstack:sidebar-collapsed-groups");if(!$)return new Set;const H=JSON.parse($);return Array.isArray(H)?new Set(H.filter(G=>typeof G=="string")):new Set}catch{return new Set}});Y(()=>{typeof window>"u"||window.localStorage.setItem("camstack:sidebar-collapsed-groups",JSON.stringify([...b]))},[b]),Y(()=>{l&&window.localStorage.getItem("camstack:sidebar-collapsed")===null&&g(!0)},[l]);const{data:y=[]}=nd({nodeId:"hub"},{staleTime:3e4,refetchInterval:3e4}),w=y.length,v=ke(),N=te(Date.now()),k=3e4,C=2e3,{data:M}=Ba(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:$=>{const H=$.state.data;return H&&H.length>0||Date.now()-N.current>=k?!1:C}}),P=q(()=>M&&n?.isAdmin?bv(M):[],[M,n?.isAdmin]);bt("addon.page-ready",()=>{v.invalidateQueries({queryKey:[["addonPages","listPages"]]})});const I=()=>{r(),t("/login")},z=$=>!!(e.pathname===$||e.pathname.startsWith($+"/")),O=["/pipeline","/timeline"].some($=>e.pathname===$||e.pathname.startsWith($+"/")),R=n?.isAdmin===!0,E=[{label:a("nav.devices","Devices"),icon:Dr,path:"/devices"},{label:a("nav.integrations"),icon:_o,path:"/integrations"},{label:a("nav.timeline","Timeline"),icon:XR,path:"/timeline"},{label:a("nav.pipeline","Pipeline"),icon:g6,path:"/pipeline"}].filter(Boolean),L=[{label:a("system.identity","Identity & Access"),icon:Gd,path:"/system/identity",adminOnly:!0},{label:a("system.network","Network"),icon:hn,path:"/system/network",adminOnly:!0},{label:a("system.integrations","Integrations"),icon:_o,path:"/system/integrations",adminOnly:!0},{label:a("system.data","Data"),icon:Vy,path:"/system/data",adminOnly:!0},{label:a("system.cluster","Cluster"),icon:_n,path:"/system/cluster",adminOnly:!0},{label:a("system.addons"),icon:$o,path:"/system/addons",adminOnly:!0},{label:a("system.addonSettings","Addon Settings"),icon:tn,path:"/system/settings",adminOnly:!0},{label:a("system.logs","Logs"),icon:it,path:"/system/logs",adminOnly:!0}].filter($=>!$.adminOnly||R),T=s?.mode??"system",B={dark:a("theme.dark"),light:a("theme.light"),system:a("theme.system")},F=m&&!i,j=($,H="md")=>`flex w-full items-center gap-2.5 rounded-md ${F?"justify-center px-0 py-2":"px-2.5 py-1.5"} ${H==="lg"?"text-[13px] font-medium":"text-[12px]"} transition-all ${$?H==="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"}`,V=f(he,{children:[f("div",{className:`flex h-14 items-center border-b border-border ${F?"justify-center px-1":"pl-3 pr-4 gap-2"}`,children:[!F&&o("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"}),!i&&o("button",{onClick:()=>g($=>!$),className:`p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle transition-colors flex-shrink-0 ${F?"":"mr-2"}`,"aria-label":m?"Expand sidebar":"Collapse sidebar",title:m?"Expand sidebar":"Collapse sidebar",children:m?o(Nt,{className:"h-4 w-4"}):o(qd,{className:"h-4 w-4"})})]}),f("nav",{className:`flex-1 overflow-y-auto py-3 ${F?"px-1.5":"px-2"} space-y-0.5`,children:[(()=>{const $=z("/dashboard");return f("button",{"data-testid":"nav-dashboard",onClick:()=>{t("/dashboard"),h(!1)},className:j($,"lg"),title:F?a("nav.dashboard"):void 0,children:[o(Gy,{className:`h-4 w-4 shrink-0 ${$?"text-primary":""}`}),!F&&a("nav.dashboard")]})})(),!F&&o("div",{className:"pt-4 pb-1.5 px-2.5",children:o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("nav.camerasSection","Cameras")})}),F&&o("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),E.map($=>{const H=$.icon,G=z($.path),Z=`nav-${$.path.replace(/^\//,"").replace(/\//g,"-")}`;return f("button",{"data-testid":Z,onClick:()=>{t($.path),h(!1)},className:j(G),title:F?$.label:void 0,children:[o(H,{className:`h-3.5 w-3.5 shrink-0 ${G?"text-primary":""}`}),!F&&$.label]},$.path)}),!F&&o("div",{className:"pt-4 pb-1.5 px-2.5",children:o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("system.title")})}),F&&o("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),L.map($=>{const H=$.icon,G=z($.path),Z=$.path==="/system/addons",oe=`nav-${$.path.replace(/^\//,"").replace(/\//g,"-")}`;return f("button",{"data-testid":oe,onClick:()=>{t($.path),h(!1)},className:j(G),title:F?$.label:void 0,children:[o(H,{className:`h-3.5 w-3.5 shrink-0 ${G?"text-primary":""}`}),!F&&f(he,{children:[o("span",{className:"flex-1 text-left",children:$.label}),Z&&w>0&&o("span",{className:"ml-auto rounded-full bg-primary px-1.5 py-0.5 text-[9px] font-bold text-primary-foreground leading-none",children:w})]}),F&&Z&&w>0&&o("span",{className:"absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary"})]},$.path)}),P&&P.length>0&&!F&&o("div",{className:"pt-4 pb-1.5 px-2.5",children:o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("nav.addonPages","Addon Pages")})}),F&&P&&P.length>0&&o("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),P?.map($=>{const H=z($.path),G=q9[$.icon]??$o;return f("button",{onClick:()=>{t($.path),h(!1)},className:j(H),title:F?$.label:void 0,children:[o(G,{className:`h-3.5 w-3.5 shrink-0 ${H?"text-primary":""}`}),!F&&$.label]},$.id)})]}),f("div",{className:`border-t border-border ${F?"p-1.5":"p-2"} space-y-0.5`,children:[f("button",{onClick:()=>s?.toggleMode(),className:j(!1),title:F?B[T]:void 0,children:[(()=>{const $=H9[T];return o($,{className:"h-3.5 w-3.5 shrink-0"})})(),!F&&o("span",{children:B[T]})]}),o(cf,{variant:"sidebar",compact:F}),f("button",{type:"button",onClick:()=>t("/system/my-access"),className:j(z("/system/my-access")),title:F?a("system.myAccess","My access"):void 0,children:[o(gn,{className:"h-3.5 w-3.5 shrink-0"}),!F&&o("span",{className:"truncate",children:a("system.myAccess","My access")})]}),f("button",{onClick:I,className:j(!1).replace("hover:text-foreground","hover:text-danger"),title:F?n?.username??"Logout":void 0,children:[o(Kd,{className:"h-3.5 w-3.5 shrink-0"}),!F&&o("span",{className:"truncate",children:n?.username??"User"})]})]})]});return f("div",{className:"flex h-screen bg-background text-foreground",children:[!i&&o("aside",{className:`flex flex-col border-r border-border bg-surface/80 backdrop-blur-sm shrink-0 transition-[width] duration-150 ease-out ${F?"w-12":"w-48"}`,children:V}),i&&o(Vc,{open:p,onClose:()=>h(!1),width:"w-64",children:V}),f("div",{className:"flex flex-1 flex-col min-w-0",children:[d&&f("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:[o(rv,{className:"h-3.5 w-3.5"}),o("span",{children:u?a("connection.reconnecting","Reconnecting…"):a("connection.disconnected","Server unreachable — reconnecting…")}),o(Se,{className:"h-3.5 w-3.5 animate-spin"})]}),i&&f("header",{className:"flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm",children:[o("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:o(V6,{className:"h-5 w-5"})}),o("div",{className:"flex-1 flex justify-center",children:o("img",{src:s?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack",className:"h-7"})}),o(cf,{})]}),f("main",{className:`relative flex-1 min-h-0 bg-background ${O?"overflow-hidden":"overflow-auto"}`,children:[d&&o("div",{className:"absolute inset-0 z-40 bg-background/60 backdrop-blur-[2px]"}),o(ST,{})]})]})]})}function Q9(){const{login:e,verifyTotp:t}=rn(),n=Hr(),r=ot(),[s,a]=_(""),[i,l]=_(""),[c,d]=_(!1),[u,p]=_(""),[h,m]=_(!1),[g,b]=_("credentials"),[x,y]=_(""),[w,v]=_(""),N=async M=>{M.preventDefault(),p(""),m(!0);try{const P=await e(s,i);if(P.kind==="totp-required"){y(P.challengeToken),b("totp");return}r(i==="changeme"?"/change-password":"/dashboard",{replace:!0})}catch(P){p(P instanceof Error?P.message:"Login failed")}finally{m(!1)}},k=async M=>{M.preventDefault(),p(""),m(!0);try{await t(x,w.trim()),r("/dashboard",{replace:!0})}catch(P){p(P instanceof Error?P.message:"TOTP verification failed"),v("")}finally{m(!1)}},C=()=>{b("credentials"),y(""),v(""),p("")};return o("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:f("div",{className:"w-full max-w-sm",children:[o("div",{className:"flex justify-center mb-8",children:o("img",{src:n?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack Admin",className:"h-12"})}),g==="credentials"?f("form",{onSubmit:N,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[u&&o("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:u}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"Username"}),o("input",{"data-testid":"login-username",type:"text",placeholder:"Username",value:s,onChange:M=>a(M.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})]}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"Password"}),f("div",{className:"relative",children:[o("input",{"data-testid":"login-password",type:c?"text":"password",placeholder:"Password",value:i,onChange:M=>l(M.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"}),o("button",{type:"button",onClick:()=>d(!c),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors",tabIndex:-1,children:c?o(Hy,{className:"h-4 w-4"}):o(ts,{className:"h-4 w-4"})})]})]}),o("button",{"data-testid":"login-submit",type:"submit",disabled:h||!s||!i,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:h?f("span",{className:"flex items-center justify-center gap-2",children:[o("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground/30 border-t-primary-foreground"}),"Logging in..."]}):"Log in"})]}):f("form",{onSubmit:k,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[f("div",{className:"flex items-center gap-2 pb-1 border-b border-border",children:[o(An,{className:"h-4 w-4 text-primary"}),o("div",{className:"text-sm font-medium text-foreground",children:"Two-factor authentication"})]}),f("p",{className:"text-xs text-foreground-subtle",children:["Enter the 6-digit code from your authenticator app to finish signing in as"," ",o("span",{className:"font-mono text-foreground",children:s}),"."]}),u&&o("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:u}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"Authentication code"}),o("input",{"data-testid":"login-totp",type:"text",inputMode:"numeric",autoComplete:"one-time-code",placeholder:"123456",value:w,onChange:M=>v(M.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full rounded-lg border border-border bg-background px-3 py-3 text-center text-2xl font-mono tracking-widest text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all",autoFocus:!0})]}),o("button",{"data-testid":"login-totp-submit",type:"submit",disabled:h||w.length!==6,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:h?f("span",{className:"flex items-center justify-center gap-2",children:[o("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground/30 border-t-primary-foreground"}),"Verifying..."]}):"Verify and sign in"}),f("button",{type:"button",onClick:C,className:"w-full flex items-center justify-center gap-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors",children:[o(Hd,{className:"h-3 w-3"}),"Back to username + password"]})]}),g==="credentials"&&o(G9,{}),o("p",{className:"mt-6 text-center text-[10px] text-foreground-subtle/50",children:"CamStack v0.1.0"})]})})}function G9(){const t=(od().data??[]).filter(n=>n.enabled&&n.hasRedirectFlow);return t.length===0?null:f("div",{className:"mt-6 space-y-3",children:[f("div",{className:"flex items-center gap-3",children:[o("div",{className:"h-px flex-1 bg-border"}),o("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"Or continue with"}),o("div",{className:"h-px flex-1 bg-border"})]}),o("div",{className:"space-y-2",children:t.map(n=>{const r=n.instanceId?`/addon/${encodeURIComponent(n.addonId)}/${encodeURIComponent(n.instanceId)}/start`:`/addon/${encodeURIComponent(n.addonId)}/start`,s=n.instanceId?`${n.addonId}#${n.instanceId}`:n.addonId;return f("a",{href:r,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:[o(gn,{className:"h-4 w-4 text-primary"}),n.displayName]},s)})})]})}const pf=8;function K9(){const{user:e,mustChangePassword:t,clearMustChangePassword:n,logout:r}=rn(),s=Hr(),a=ot(),[i,l]=_(""),[c,d]=_(""),[u,p]=_(!1),[h,m]=_(""),g=yd({onSuccess:()=>{n(),a("/dashboard",{replace:!0})},onError:x=>{m(x instanceof Error?x.message:"Could not change password")}}),b=async x=>{if(x.preventDefault(),m(""),!e){m("Not signed in");return}if(i.length<pf){m(`Password must be at least ${pf} characters`);return}if(i!==c){m("The two passwords do not match");return}if(i==="changeme"){m("Choose a password different from the seed default");return}g.mutate({id:e.id,newPassword:i})};return o("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:f("div",{className:"w-full max-w-sm",children:[o("div",{className:"flex justify-center mb-8",children:o("img",{src:s?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack Admin",className:"h-12"})}),f("form",{onSubmit:b,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[f("div",{className:"space-y-1",children:[o("h1",{className:"text-sm font-semibold text-foreground",children:"Set a new password"}),o("p",{className:"text-xs text-foreground-subtle",children:t?"You must rotate the seed password before continuing.":"Choose a new password for your account."})]}),h&&o("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:h}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"New password"}),f("div",{className:"relative",children:[o("input",{"data-testid":"change-password-new",type:u?"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}),o("button",{type:"button",onClick:()=>p(!u),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors",tabIndex:-1,children:u?o(Hy,{className:"h-4 w-4"}):o(ts,{className:"h-4 w-4"})})]})]}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"Confirm new password"}),o("input",{"data-testid":"change-password-confirm",type:u?"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"})]}),o("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&&o("button",{type:"button",onClick:()=>{r(),a("/login",{replace:!0})},className:"w-full text-xs text-foreground-subtle hover:text-foreground transition-colors",children:"Sign out instead"})]})]})})}function W9(){const e=ot();return f("div",{className:"flex flex-col items-center justify-center text-foreground py-16 px-4",children:[o("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-danger/10 mb-4",children:o(EO,{className:"h-8 w-8 text-danger"})}),o("h1",{className:"text-xl font-bold",children:"Access Denied"}),o("p",{className:"mt-2 text-sm text-foreground-subtle",children:"You don't have permission to access this page."}),o("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 xv="camstack:dashboard-layout",Ki={version:1,widgets:[]};function Y9(){try{const e=localStorage.getItem(xv);if(!e)return Ki;const t=JSON.parse(e);return t&&t.version===1&&Array.isArray(t.widgets)?{version:1,widgets:t.widgets}:Ki}catch{return Ki}}function Z9(e){try{localStorage.setItem(xv,JSON.stringify(e))}catch{}}function X9(){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 J9(){const[e,t]=_(Y9),[n,r]=_(!1),s=F0(),a=q(()=>s.filter(d=>d.hosts.includes("dashboard")),[s]),i=U(d=>{t(d),Z9(d)},[]),l=U(d=>{i({version:1,widgets:[...e.widgets,d]})},[e,i]),c=U(d=>{i({version:1,widgets:e.widgets.filter(u=>u.instanceId!==d)})},[e,i]);return f("div",{className:"p-4",children:[f("div",{className:"flex items-center justify-between mb-4",children:[o("h1",{className:"text-lg font-semibold text-foreground",children:"Dashboard"}),f("button",{onClick:()=>r(!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:[o(ct,{className:"h-3.5 w-3.5"}),"Add widget"]})]}),e.widgets.length===0?o(e7,{onAdd:()=>r(!0)}):o("div",{className:"grid grid-cols-12 gap-3 auto-rows-[minmax(80px,_auto)]",children:e.widgets.map(d=>o(t7,{entry:d,onRemove:()=>c(d.instanceId)},d.instanceId))}),n&&o(r7,{widgets:a,onClose:()=>r(!1),onAdd:d=>{l(d),r(!1)}})]})}function e7({onAdd:e}){return f("div",{className:"flex flex-col items-center justify-center py-24 text-foreground-subtle",children:[o("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-surface border border-border mb-4",children:o(Gy,{className:"h-8 w-8 text-foreground-subtle/40"})}),o("p",{className:"text-sm font-medium text-foreground/70",children:"Your dashboard is empty"}),o("p",{className:"text-xs text-foreground-subtle mt-1 mb-4",children:"Add widgets to monitor your cameras and system"}),f("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:[o(ct,{className:"h-3.5 w-3.5"}),"Add your first widget"]})]})}function t7({entry:e,onRemove:t}){const n=n7(e.columns),r=Math.max(1,Math.min(12,e.rows));return f("div",{className:"relative group rounded-lg border border-border bg-surface overflow-hidden flex flex-col",style:{gridColumn:`span ${n} / span ${n}`,gridRow:`span ${r} / span ${r}`},children:[o("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:o(Fe,{className:"h-3 w-3"})}),o("div",{className:"flex-1 min-h-0 overflow-auto p-2",children:o(ht,{widgetId:e.widgetId,host:"dashboard",instanceId:e.instanceId,config:e.config,deviceId:e.deviceId,size:e.size,columns:e.columns,rows:e.rows})})]})}function n7(e){return!Number.isFinite(e)||e<1?6:Math.min(12,Math.floor(e))}function r7({widgets:e,onClose:t,onAdd:n}){const[r,s]=_(null);return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:t,children:f("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:[f("div",{className:"flex items-center justify-between mb-4",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:r?`Configure: ${r.label}`:"Add widget"}),o("button",{onClick:t,className:"p-1 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",children:o(Fe,{className:"h-4 w-4"})})]}),r===null?o(o7,{widgets:e,onSelect:s}):o(s7,{widget:r,onCancel:()=>s(null),onAdd:n})]})})}function o7({widgets:e,onSelect:t}){return e.length===0?o("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."}):o("div",{className:"grid grid-cols-2 gap-2 max-h-96 overflow-auto",children:e.map(n=>f("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:[o("span",{className:"text-xs font-medium text-foreground block",children:n.label}),o("span",{className:"text-[10px] text-foreground-subtle truncate",title:n.widgetId,children:n.widgetId}),n.description&&o("span",{className:"text-[10px] text-foreground-subtle mt-1 line-clamp-2",children:n.description})]},n.widgetId))})}function s7({widget:e,onCancel:t,onAdd:n}){const[r,s]=_(e.defaultSize),[a,i]=_(e.defaultColumns),[l,c]=_(e.defaultRows),[d,u]=_(null),{data:p}=On({},{enabled:e.requires.deviceContext,staleTime:3e4}),h=!e.requires.deviceContext||d!==null&&d>0,m=()=>{if(!h)return;const g={instanceId:X9(),widgetId:e.widgetId,size:r,columns:a,rows:l,...e.requires.deviceContext&&d!==null?{deviceId:d}:{}};n(g)};return f("div",{className:"space-y-3",children:[f("div",{children:[o("label",{className:"block text-[11px] font-medium text-foreground-subtle mb-1",children:"Size"}),o("div",{className:"flex items-center gap-1",children:e.allowedSizes.map(g=>o("button",{onClick:()=>s(g),className:`px-3 py-1 rounded-md text-[11px] font-medium border transition-colors ${r===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))})]}),f("div",{className:"grid grid-cols-2 gap-3",children:[o(ff,{label:"Columns (1-12)",value:a,min:1,max:12,onChange:i}),o(ff,{label:"Rows (1-12)",value:l,min:1,max:12,onChange:c})]}),e.requires.deviceContext&&f("div",{children:[o("label",{className:"block text-[11px] font-medium text-foreground-subtle mb-1",children:"Device"}),f("select",{value:d??"",onChange:g=>u(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:[o("option",{value:"",children:"— select a device —"}),(p??[]).map(g=>f("option",{value:g.id,children:[g.name??g.stableId," (#",g.id,")"]},g.id))]})]}),f("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-border",children:[o("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"}),o("button",{disabled:!h,onClick:m,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 ff({label:e,value:t,min:n,max:r,onChange:s}){return f("div",{children:[o("label",{className:"block text-[11px] font-medium text-foreground-subtle mb-1",children:e}),o("input",{type:"number",min:n,max:r,value:t,onChange:a=>{const i=Number(a.target.value);Number.isFinite(i)&&s(Math.max(n,Math.min(r,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 a7(){return o(J9,{})}function nt({icon:e,title:t,subtitle:n,actions:r,children:s}){const a=!!t||n!=null||r!=null;return f("div",{className:"p-4 space-y-4",children:[a&&f("div",{className:"flex items-center justify-between gap-4",children:[f("div",{className:"min-w-0",children:[t&&f("h1",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e&&o(e,{className:"h-4 w-4 text-foreground-subtle"}),t]}),n&&o("p",{className:"text-xs text-foreground-subtle mt-0.5",children:n})]}),r&&o("div",{className:"shrink-0 flex items-center gap-2",children:r})]}),s]})}const hf=["camera","hub","nvr","light","siren","switch","sensor","thermostat","button","generic"];function i7(){const{t:e}=qt(),t=ot(),n=Le();Ct(["deviceManager"],["device.registered","device.unregistered","device.online","device.offline","device.disabled","device.enabled"]),Ct(["integrations"],["integration.enabled","integration.disabled","integration.deleted","provider.started","provider.stopped","addon.installed","addon.uninstalled","addon.started","addon.stopped"]);const{data:r}=On({},{staleTime:3e4}),{data:s}=ud(void 0,{staleTime:3e4}),a=q(()=>r??[],[r]),{activeDevices:i,orphanDevices:l}=q(()=>{const m=new Set((s??[]).map(k=>k.addonId)),g=k=>typeof k.addonId=="string"&&k.addonId.length>0&&!m.has(k.addonId),b=new Set;for(const k of a)g(k)&&b.add(k.id);const x=new Set(b),y=new Map;for(const k of a)y.set(k.id,k);const w=(k,C=0)=>{if(C>32)return!1;if(b.has(k.id))return!0;if(k.parentDeviceId==null)return!1;const M=y.get(k.parentDeviceId);return M?w(M,C+1):!1};for(const k of a)w(k)&&x.add(k.id);const v=[],N=[];for(const k of a)x.has(k.id)?N.push(k):v.push(k);return{activeDevices:v,orphanDevices:N}},[a,s]),c=q(()=>{const m=new Map;for(const g of a)m.set(g.id,{id:g.id,name:g.name??g.stableId??`#${String(g.id)}`});return m},[a]),d=U(m=>c.get(m)??null,[c]),u=q(()=>(s??[]).map(m=>({id:m.addonId,name:m.name??m.addonId,icon:o(bn,{type:m.addonId,size:"sm"})})),[s]),p=U(m=>o(bn,{type:m,size:"sm"}),[]),h=U(m=>t(`/devices/${String(m)}`),[t]);return f(nt,{icon:Dr,title:e("nav.devices","Devices"),children:[o(Ao,{devices:i,trpc:n.trpcClient,filters:{types:hf,addons:u},resolveIntegrationIcon:p,resolveParent:d,onNavigate:h}),l.length>0&&f("div",{className:"mt-6 space-y-2",children:[f("div",{className:"flex items-baseline gap-2",children:[o(tt,{className:"h-3.5 w-3.5 text-warning shrink-0"}),o("h2",{className:"text-sm font-semibold text-foreground",children:"Orphan devices"}),f("span",{className:"text-[10px] text-foreground-subtle",children:[l.length," device",l.length===1?"":"s"," pointing at integrations no longer registered"]})]}),f("div",{className:"rounded-lg border border-warning/30 bg-warning/5 p-2",children:[o("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."}),o(Ao,{devices:l,trpc:n.trpcClient,filters:{types:hf,addons:u},urlScope:"nested",lsKey:"devices:orphan",resolveIntegrationIcon:p,resolveParent:d,onNavigate:h})]})]})]})}function l7({onSelect:e,onClose:t,pendingAddonId:n=null}){const{t:r}=qt(),s=ot(),{data:a,isLoading:i}=ox();if(i)return o("div",{className:"space-y-2 p-2",children:[1,2,3].map(c=>o("div",{className:"h-14 rounded-lg bg-surface animate-pulse"},c))});const l=n!==null;return f("div",{className:"space-y-2",children:[(a??[]).map(c=>{const d=c.instanceMode==="unique"&&c.existingInstances.length>0,u=n===c.addonId,p=l;return f("button",{disabled:p,onClick:()=>{if(!p)if(d){const h=c.existingInstances[0].id;t(),s(`/integrations/${h}`)}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?o("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0",style:{backgroundColor:`${c.color}15`},children:o("img",{src:c.iconUrl,alt:"",className:"h-5 w-5"})}):o("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0",style:{backgroundColor:`${c.color}15`},children:o("span",{className:"text-sm",style:{color:c.color},children:"◉"})}),f("div",{className:"flex-1 min-w-0",children:[o("p",{className:"text-xs font-semibold text-foreground",children:c.name}),c.description&&o("p",{className:"text-[10px] text-foreground-subtle mt-0.5 truncate",children:c.description})]}),u?o(Se,{className:"h-4 w-4 animate-spin text-primary flex-shrink-0"}):d?f("span",{className:"flex items-center gap-1 text-[10px] font-medium text-foreground-subtle",children:[o(tn,{className:"h-3 w-3"}),r("integrations.manage")]}):o(Nt,{className:"h-4 w-4 text-foreground-subtle flex-shrink-0"})]},c.addonId)}),(a??[]).length===0&&o("div",{className:"py-8 text-center text-xs text-foreground-subtle",children:r("integrations.noProviders")})]})}function c7(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function mf(e,t){if(e!==void 0)return t&&c7(e)?t(e):e}function d7({section:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,probeResults:i,onAction:l}){const[c,d]=_(e.defaultCollapsed??!1),u=e.style==="accordion";if(e.fields.reduce((b,x)=>b+(vd(x,t,e.fields)?1:0),0)===0)return null;const h=e.columns??2,m=h===1?"grid-cols-1":h===3?"grid-cols-1 @[420px]:grid-cols-2 @[680px]:grid-cols-3":h===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 f("div",{className:"@container rounded-lg border border-border bg-surface p-3",style:{containerType:"inline-size"},children:[!g&&f("div",{className:["flex items-center justify-between mb-2",u?"cursor-pointer":""].join(" "),onClick:u?()=>d(b=>!b):void 0,children:[f("div",{children:[e.title&&o("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:mf(e.title,s)}),e.description&&o("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:mf(e.description,s)})]}),u&&o("span",{className:"text-foreground-subtle text-xs ml-2",children:c?"▸":"▾"})]}),!c&&o("div",{className:`grid ${m} gap-x-3 gap-y-2.5`,children:e.fields.map(b=>o(gr,{field:b,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i?.[b.key],allFields:e.fields,onAction:l},b.key))})]})}function $n({schema:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,probeResults:i,onClearProbe:l,onAction:c}){const d=(u,p)=>{n({...t,[u]:p}),l?.(u)};return o("div",{className:"space-y-4",children:e.sections.map((u,p)=>o(d7,{section:u,values:t,onChange:d,disabled:r,translationFn:s,onTestField:a,probeResults:i,onAction:c},`${u.id}-${p}`))})}function u7({addonId:e,configSchema:t,onSave:n,onBack:r}){const{t:s}=qt(),[a,i]=_(""),[l,c]=_({}),[d,u]=_(null),p=sx({onSuccess:h=>u(h),onError:h=>u({success:!1,error:String(h)})});return f("div",{className:"space-y-4",children:[f("div",{children:[o("label",{className:"block text-[11px] font-medium text-foreground mb-1",children:s("integrations.integrationName")}),o("input",{type:"text",value:a,onChange:h=>i(h.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&&o($n,{schema:t,values:l,onChange:c}),d&&o("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}`}),f("div",{className:"flex items-center justify-between pt-2",children:[o("button",{onClick:r,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")}),f("div",{className:"flex items-center gap-2",children:[o("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")}),o("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 p7({providerId:e,onImport:t,onSkip:n}){const{t:r}=qt(),[s,a]=_(new Set),i=cd(),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(h=>{const m=new Set(h);return m.has(p)?m.delete(p):m.add(p),m})}if(c)return f("div",{className:"flex flex-col items-center py-12",children:[o("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"}),o("p",{className:"mt-3 text-xs text-foreground-subtle",children:r("integrations.searchingDevices")})]});const u=l??[];return f("div",{className:"space-y-4",children:[o("p",{className:"text-xs text-foreground-subtle",children:u.length>0?r("integrations.foundDevices",{count:u.length}):r("integrations.noDevicesFound")}),u.length>0&&o("div",{className:"space-y-1.5 max-h-64 overflow-y-auto",children:u.map(p=>{const h=p.stableId,m=p.suggestedName??h,g=s.has(h);return f("button",{onClick:()=>d(h),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:[o("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&&o(_t,{className:"h-3 w-3 text-primary-foreground"})}),o(Dr,{className:"h-3.5 w-3.5 text-foreground-subtle flex-shrink-0"}),o("span",{className:"text-xs font-medium text-foreground truncate",children:m})]},h)})}),f("div",{className:"flex items-center justify-between pt-2",children:[o("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:r("integrations.skip")}),u.length>0&&f("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:[r("integrations.importSelected")," (",s.size,")"]})]})]})}function f7(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 r=n,{value:s,...a}=r;return a};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(n=>({...n,fields:n.fields.map(t)}))}}function h7({open:e,onClose:t}){const{t:n}=qt(),r=ot(),s=ke(),[a,i]=_("picker"),[l,c]=_(null),[d,u]=_(null),[p,h]=_("manual"),{data:m}=rd({addonId:l??"",nodeId:"hub"},{enabled:l!=null}),g=q(()=>m?f7(m):null,[m]),b=tx({onSuccess:()=>s.invalidateQueries({queryKey:[["integrations"]]})}),x=cd(),y=x.data;Y(()=>{a!=="discovery"||!d||!l||x.isPending||x.data||x.mutate({addonId:l})},[a,d,l,x]);const w=Yb({onSuccess:()=>s.invalidateQueries({queryKey:[["deviceManager"]]})});async function v(R,E,D,L){if(!b.isPending){if(c(R),h(D),E==="unique"){try{const T=await b.mutateAsync({addonId:R,name:L,settings:{}});t(),M(),r(`/integrations/${T.id}`)}catch{}return}i("config")}}async function N(R){if(l)try{const E=await b.mutateAsync({addonId:l,name:R.name,settings:R.config});u(E.id),p==="auto"||p==="both"?i("discovery"):C(E.id)}catch{}}async function k(R){if(l){for(const E of R){const D=y?.find(L=>L.stableId===E);D&&await w.mutateAsync({addonId:l,candidate:D})}C()}}function C(R){const E=R??d??l;t(),M(),E&&r(`/integrations/${E}`)}function M(){i("picker"),c(null),u(null),h("manual")}function P(){t(),M()}if(!e)return null;const I={picker:n("integrations.newIntegration"),config:n("integrations.configureIntegration"),discovery:n("integrations.importDevices")},z=b.isPending,A=z?l:null,O=b.error;return f("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[o("div",{className:"absolute inset-0 bg-black/60",onClick:z?void 0:P}),f("div",{className:"relative z-10 w-full max-w-lg rounded-xl border border-border bg-background shadow-2xl",children:[f("div",{className:"flex items-center justify-between border-b border-border px-5 py-4",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:I[a]}),o("button",{onClick:P,disabled:z,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:o(Fe,{className:"h-4 w-4"})})]}),f("div",{className:"relative px-5 py-4",children:[O&&!z&&o("div",{className:"mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:O instanceof Error?O.message:String(O)}),a==="picker"&&o(l7,{onSelect:v,onClose:P,pendingAddonId:A}),a==="config"&&l&&o(u7,{addonId:l,configSchema:g??null,onSave:N,onBack:()=>i("picker")}),a==="discovery"&&d&&o(p7,{providerId:d,onImport:k,onSkip:C}),z&&f("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background/85 backdrop-blur-sm",children:[o(Se,{className:"h-6 w-6 animate-spin text-primary"}),o("p",{className:"text-xs font-medium text-foreground",children:n("integrations.creating",{defaultValue:"Creating integration…"})}),o("p",{className:"text-[10px] text-foreground-subtle",children:n("integrations.creatingHint",{defaultValue:"Waiting for the addon to restart and register"})})]})]})]})]})}const gf={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 ni({status:e}){const t=gf[e]??gf.stopped;return f("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:[o("span",{className:`h-1.5 w-1.5 rounded-full ${t.dot}`}),t.label]})}const Wi="px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle";function m7({integrations:e,expandedAddonId:t,onToggleExpand:n,onOpenSettings:r,renderExpanded:s}){const a=U(i=>n(i),[n]);return o("div",{className:"overflow-hidden rounded-lg border border-border bg-surface",children:f("table",{className:"w-full table-fixed text-xs",children:[o("thead",{className:"bg-surface-hover/40",children:f("tr",{children:[o("th",{className:K(Wi,"w-[60%]"),children:"Integration"}),o("th",{className:K(Wi,"w-[15%]"),children:"Devices"}),o("th",{className:K(Wi,"w-[25%]"),children:"Status"})]})}),o("tbody",{children:e.map(i=>{const l=t===i.addonId;return o(g7,{integration:i,isExpanded:l,onClick:a,onOpenSettings:r,renderExpanded:s},i.id)})})]})})}function g7({integration:e,isExpanded:t,onClick:n,onOpenSettings:r,renderExpanded:s}){const a=U(c=>{c.stopPropagation(),r(e.id)},[e.id,r]),i=U(()=>{n(e.addonId)},[e.addonId,n]),l=U(c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),i())},[i]);return f(he,{children:[f("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:[o("td",{className:"px-3 py-2.5",children:f("div",{className:"flex items-center gap-2.5",children:[t?o(lt,{className:"h-3.5 w-3.5 flex-shrink-0 text-foreground-subtle"}):o(Nt,{className:"h-3.5 w-3.5 flex-shrink-0 text-foreground-subtle"}),o(bn,{type:e.addonId,size:"sm"}),f("div",{className:"flex min-w-0 flex-col",children:[o("span",{className:"truncate text-xs font-semibold text-foreground",children:e.name}),o("span",{className:"truncate text-[10px] text-foreground-subtle",children:e.addonId})]})]})}),f("td",{className:"px-3 py-2.5 text-[11px] text-foreground-subtle",children:[e.deviceCount," device",e.deviceCount!==1?"s":""]}),o("td",{className:"px-3 py-2.5",children:f("div",{className:"flex items-center justify-between gap-2",children:[o(ni,{status:e.status}),f("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:[o(tn,{className:"h-3 w-3"}),"Settings"]})]})})]}),t&&o("tr",{className:"border-t border-border bg-surface",children:o("td",{colSpan:3,className:"px-3 py-3",children:s(e.addonId)})})]})}function b7(e){if(!e.enabled)return"disabled";switch(e.processState){case"running":return"running";case"stopped":case"crashed":case"unknown":default:return"stopped"}}const Cs="expand";function x7(){const{t:e}=qt(),t=ot(),n=Le(),[r]=Ka(),[s,a]=_(!1),i=U(()=>a(!0),[]),l=U(()=>a(!1),[]);Ct(["integrations"],["integration.enabled","integration.disabled","integration.deleted","provider.started","provider.stopped","addon.installed","addon.uninstalled","addon.started","addon.stopped","addon.updated"]),Ct(["deviceManager"],["device.registered","device.unregistered","device.online","device.offline","device.disabled","device.enabled"]);const{data:c,isLoading:d,refetch:u}=ud(void 0,{staleTime:3e4}),{data:p,isLoading:h,refetch:m}=On({},{staleTime:3e4}),g=q(()=>p??[],[p]),b=q(()=>c??[],[c]),x=q(()=>{const R=new Map;for(const E of g)R.set(E.id,{id:E.id,name:E.name??E.stableId??`#${String(E.id)}`});return R},[g]),y=q(()=>{const R=new Map;for(const E of g){if(E.parentDeviceId!==null&&E.parentDeviceId!==void 0&&!!E.role)continue;const L=E.addonId??"";L&&R.set(L,(R.get(L)??0)+1)}return R},[g]),w=q(()=>b.map(R=>({id:R.id,addonId:R.addonId,name:R.name,enabled:R.enabled,status:b7(R),deviceCount:y.get(R.addonId)??0})),[b,y]),v=r.get(Cs),N=U(R=>{const E=new URLSearchParams(window.location.search);E.get(Cs)===R?E.delete(Cs):E.set(Cs,R);const L=E.toString(),T=`${window.location.pathname}${L?`?${L}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",T),window.dispatchEvent(new PopStateEvent("popstate"))},[]),k=U(R=>t(`/integrations/${R}`),[t]),C=U(R=>x.get(R)??null,[x]),M=U(R=>o(bn,{type:R,size:"sm"}),[]),P=U(R=>t(`/devices/${String(R)}`),[t]),I=U(R=>o(Ao,{devices:g,trpc:n.trpcClient,forceAddon:R,urlScope:"nested",lsKey:`integrations:nested:${R}`,resolveIntegrationIcon:M,resolveParent:C,onNavigate:P}),[g,n.trpcClient,M,C,P]),z=U(()=>{u(),m()},[u,m]),A=d||h,O=b.length>0;return f(nt,{icon:_o,title:e("nav.integrations","Integrations"),actions:f(he,{children:[o("button",{onClick:z,disabled:A,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:o(dt,{className:K("h-3.5 w-3.5",A&&"animate-spin")})}),f("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:[o(ct,{className:"h-3.5 w-3.5"}),"New Integration"]})]}),children:[A&&o("div",{className:"space-y-2",children:[1,2,3].map(R=>o("div",{className:"h-12 rounded-lg border border-border bg-surface animate-pulse"},R))}),!A&&!O&&f("div",{className:"flex flex-col items-center py-20 text-foreground-subtle",children:[o("p",{className:"text-sm",children:"No integrations configured."}),o("p",{className:"text-xs mt-1",children:'Click "New Integration" to connect cameras and devices.'})]}),!A&&O&&o(m7,{integrations:w,expandedAddonId:v,onToggleExpand:N,onOpenSettings:k,renderExpanded:I}),o(h7,{open:s,onClose:l})]})}function yv(e){const t=[];for(const n of e)n.type==="probe"&&t.push(n.key),n.type==="group"&&"fields"in n&&t.push(...yv(n.fields));return t}function y7(e,t,n){const[r,s]=_("idle"),[a,i]=_({}),l=q(()=>{const p=[];for(const h of e.sections)p.push(...yv(h.fields));return p},[e]),c=l.length>0&&n!==void 0,d=U(p=>{i(h=>{if(!h[p])return h;const m={...h};return delete m[p],m})},[]),u=U(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 h={};for(const b of p)h[b]={status:"probing"};i(h);const m=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 m)if(b.status==="fulfilled"){const{key:x,result:y}=b.value;g[x]={status:y.status==="ok"?"ok":"error",result:y}}i(g),s("idle")},[n,l,t]);return{testAllStatus:r,hasProbeFields:c,probeResults:a,handleTestAll:u,clearProbeResult:d}}function vv(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(...vv(n.fields));return t}function Yi(e){return e==null?!0:typeof e=="string"?e.trim()==="":!1}function ec(e,t={}){for(const n of e){if(n.type==="group"&&"fields"in n){ec(n.fields,t);continue}"key"in n&&n.key&&"default"in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function bf(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function v7({open:e,integrationId:t,addonId:n,onClose:r}){const{t:s}=qt(),a=ke(),[i,l]=_({}),[c,d]=_(!1),[u,p]=_(null),[h,m]=_(bf),g=Zb({addonId:n,type:ft.Camera},{enabled:e}),b=g.data??null;Y(()=>{if(e){const E=b?ec(b.sections.flatMap(D=>D.fields)):{};l(E),m(bf()),d(!1),p(null)}},[e,t,b]);const x=q(()=>({...i,_probeRequestId:h}),[i,h]),y=Xb({onSuccess:()=>{a.invalidateQueries({queryKey:[["deviceManager"]]})}}),w=dd(),v=U(async(E,D)=>{d(!0);const L=await w.mutateAsync({addonId:n,type:ft.Camera,key:E,value:D,formValues:x});return L.status==="ok"&&L.suggestedValues&&l(T=>{let B=!1;const F={...T};for(const[j,V]of Object.entries(L.suggestedValues??{}))Yi(T[j])&&!Yi(V)&&(F[j]=V,B=!0);return B?F:T}),L},[w,n,x]),{testAllStatus:N,hasProbeFields:k,probeResults:C,handleTestAll:M,clearProbeResult:P}=y7(b??{sections:[]},i,v);async function I(E){p(null);try{if(await y.mutateAsync({addonId:n,type:ft.Camera,config:i}),E){const D=b?ec(b.sections.flatMap(L=>L.fields)):{};l(D)}else r()}catch(D){p(D instanceof Error?D.message:String(D))}}if(!e)return null;const A=vv((b?.sections??[]).flatMap(E=>E.fields)).filter(E=>Yi(i[E])),O=A.length===0,R=!g.isLoading&&(g.isError||b===null);return f("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[o("div",{className:"absolute inset-0 bg-black/60",onClick:r}),f("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:[f("div",{className:"flex items-center justify-between border-b border-border px-5 py-4 shrink-0",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:s("integrations.addDevice")}),o("button",{onClick:r,className:"rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:o(Fe,{className:"h-4 w-4"})})]}),o("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-3",children:g.isLoading?o("div",{className:"flex items-center justify-center py-8",children:o(Se,{className:"h-5 w-5 animate-spin text-primary"})}):R?f("div",{className:"flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3",children:[o(tt,{className:"h-4 w-4 text-destructive mt-0.5 shrink-0"}),f("div",{className:"space-y-1",children:[o("p",{className:"text-xs font-medium text-destructive",children:"Provider unavailable"}),f("p",{className:"text-xs text-foreground-subtle",children:["The addon ",o("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."]})]})]}):o($n,{schema:b,values:i,onChange:l,onTestField:v,probeResults:C,onClearProbe:P})}),!R&&!g.isLoading&&f("div",{className:"border-t border-border bg-surface/50 shrink-0",children:[f("button",{type:"button",onClick:()=>d(E=>!E),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:[f("span",{className:"flex items-center gap-2",children:[o(it,{className:"h-3.5 w-3.5"}),"Test logs",o("span",{className:"font-mono text-[9px] opacity-60",children:h.slice(0,14)})]}),o(lt,{className:`h-3.5 w-3.5 transition-transform ${c?"rotate-180":""}`})]}),c&&o("div",{className:"border-t border-border max-h-64 overflow-hidden",children:o(Ht,{addonId:n,requestId:h,limit:50,maxHeight:"max-h-64",showFilters:!1,showScope:!1,className:"border-0 rounded-none"})})]}),!R&&!g.isLoading&&(u||A.length>0)&&o("div",{className:"border-t border-destructive/30 bg-destructive/5 px-5 py-2 shrink-0",children:f("div",{className:"flex items-start gap-2",children:[o(tt,{className:"h-3.5 w-3.5 text-destructive mt-0.5 shrink-0"}),o("p",{className:"text-[11px] text-destructive",children:u||`Required: ${A.join(", ")}`})]})}),f("div",{className:"flex items-center justify-between border-t border-border px-5 py-3 shrink-0",children:[f("div",{className:"flex items-center gap-2",children:[o("button",{onClick:r,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")}),!R&&k&&f("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"?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(or,{className:"h-3.5 w-3.5"}),"Test All"]})]}),f("div",{className:"flex items-center gap-2",children:[o("button",{onClick:()=>I(!0),disabled:R||!O||y.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")}),o("button",{onClick:()=>I(!1),disabled:R||!O||y.isPending,className:"rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:y.isPending?s("integrations.saving"):s("integrations.save")})]})]})]})]})}function w7(){const{t:e}=qt(),{integrationId:t}=Rd(),n=ke(),r=ot(),s=Le(),[a,i]=_(!1),[l,c]=_(!1),[d,u]=_(!1),[p,h]=_(!1),{data:m,isLoading:g}=Jb({id:t??""},{enabled:!!t}),{data:b}=rd({addonId:m?.addonId??"",nodeId:"hub"},{enabled:!!m?.addonId}),x=b!=null&&Array.isArray(b.sections)&&b.sections.some(O=>O.fields.length>0),{data:y}=On({},{refetchInterval:5e3}),w=[["integrations","get"],{input:{id:t??""},type:"query"}],v=nx({onMutate:async O=>{await n.cancelQueries({queryKey:w});const R=n.getQueryData(w);return R!=null&&n.setQueryData(w,{...R,enabled:O.enabled}),{previous:R}},onError:(O,R,E)=>{const D=E;D?.previous!=null&&n.setQueryData(w,D.previous)},onSettled:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),N=rx({onSuccess:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]}),u(!1),r("/integrations")}}),k=Wo({onSuccess:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),C=q(()=>y??[],[y]),M=q(()=>{const O=new Map;for(const R of C)O.set(R.id,{id:R.id,name:R.name??R.stableId??`#${String(R.id)}`});return O},[C]),P=U(O=>M.get(O)??null,[M]),I=U(O=>o(bn,{type:O,size:"sm"}),[]),z=U(O=>r(`/devices/${String(O)}`),[r]),A=q(()=>{const O=m?.addonId;if(!O)return 0;let R=0;for(const E of C)E.addonId!==O||E.parentDeviceId!==null&&E.parentDeviceId!==void 0&&E.role||(R+=1);return R},[C,m?.addonId]);return g?f("div",{className:"p-4",children:[o("div",{className:"h-16 rounded-lg bg-surface animate-pulse mb-4"}),o("div",{className:"h-40 rounded-lg bg-surface animate-pulse"})]}):m?f("div",{className:"p-4 space-y-4",children:[o(Hc,{items:[{label:"Integrations",onClick:()=>r("/integrations")},{label:m.name}]}),f("div",{className:"flex items-center justify-between",children:[f("div",{className:"flex items-center gap-3",children:[o("img",{src:`/api/addon-assets/${m.addonId}/assets/icon.svg`,alt:"",className:"h-8 w-8 rounded-lg",onError:O=>{O.target.style.display="none"}}),f("div",{children:[o("h1",{className:"text-lg font-semibold text-foreground",children:m.name}),f("p",{className:"text-[11px] text-foreground-subtle mt-0.5",children:[m.addonId," · ",A," ",e("integrations.devices")]})]})]}),f("div",{className:"flex items-center gap-3",children:[f("div",{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${v.isPending?"opacity-60":""} ${m.enabled?"border-success/30 bg-success/5":"border-border bg-surface"}`,title:e("integrations.toggleHint",{defaultValue:"Click to toggle"}),children:[o(Oc,{checked:m.enabled,onCheckedChange:O=>v.mutate({id:t,enabled:O}),disabled:v.isPending,"aria-label":m.enabled?"Disable integration":"Enable integration"}),o("span",{className:`text-[11px] font-medium ${m.enabled?"text-success":"text-foreground-subtle"}`,children:m.enabled?"Enabled":"Disabled"}),v.isPending&&o(Se,{className:"h-3 w-3 animate-spin text-foreground-subtle"})]}),x&&f("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:[o(tn,{className:"h-3 w-3"}),e("integrations.config")]}),f("button",{onClick:()=>h(!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:[o(it,{className:"h-3 w-3"}),e("integrations.logs",{defaultValue:"Logs"})]}),o(Md,{label:"Restart",icon:dt,title:`Restart "${m.name}"?`,description:`Restarting the addon will briefly disconnect every device backed by it (${A} active). Streams will reconnect automatically.`,confirmLabel:"Restart",triggerVariant:"outline",confirmVariant:"danger",disabled:k.isPending,action:()=>k.mutateAsync({addonId:m.addonId})}),f("button",{onClick:()=>u(!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:[o(Ze,{className:"h-3 w-3"}),e("integrations.delete",{defaultValue:"Delete"})]})]})]}),o(Ao,{devices:C,trpc:s.trpcClient,defaultView:"cards",forceAddon:m.addonId,urlScope:"root",lsKey:`integration-detail:${m.addonId}`,resolveIntegrationIcon:I,resolveParent:P,onNavigate:z}),o("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:o(ct,{className:"h-5 w-5 text-primary-foreground"})}),a&&t&&o(v7,{open:a,integrationId:t,addonId:m.addonId,onClose:()=>i(!1)}),l&&o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>c(!1),children:f("div",{className:"rounded-xl border border-border bg-surface p-6 shadow-xl w-80",onClick:O=>O.stopPropagation(),children:[o("h2",{className:"text-sm font-semibold text-foreground mb-2",children:e("integrations.providerConfig")}),o("p",{className:"text-[11px] text-foreground-subtle",children:e("integrations.configComingSoon")}),o("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&&o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6",onClick:()=>h(!1),children:f("div",{className:"flex flex-col rounded-xl border border-border bg-surface shadow-xl w-full max-w-5xl h-[80vh]",onClick:O=>O.stopPropagation(),children:[f("div",{className:"flex items-center justify-between border-b border-border px-4 py-2.5",children:[f("div",{className:"flex items-center gap-2 min-w-0",children:[o(it,{className:"h-4 w-4 text-primary shrink-0"}),o("h2",{className:"text-sm font-semibold text-foreground truncate",children:m.name}),f("span",{className:"text-[10px] text-foreground-subtle font-mono truncate",children:[m.addonId,t?` · ${t}`:""]})]}),o("button",{onClick:()=>h(!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:o(Fe,{className:"h-4 w-4"})})]}),o("div",{className:"flex-1 min-h-0 overflow-hidden",children:o(Ht,{addonId:m.addonId,limit:200,maxHeight:"max-h-full",showScope:!1,className:"h-full border-0 rounded-none"})})]})}),d&&o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>!N.isPending&&u(!1),children:f("div",{className:"rounded-xl border border-border bg-background p-5 shadow-2xl w-96 space-y-3",onClick:O=>O.stopPropagation(),children:[f("div",{className:"flex items-start gap-3",children:[o("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-danger/10 shrink-0",children:o(tt,{className:"h-4 w-4 text-danger"})}),f("div",{className:"min-w-0",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:e("integrations.deleteTitle",{defaultValue:"Delete integration?"})}),o("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:m.name,count:A})})]})]}),N.error&&o("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)}),f("div",{className:"flex items-center justify-end gap-2 pt-1",children:[o("button",{onClick:()=>u(!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"})}),o("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?f(he,{children:[o(Se,{className:"h-3 w-3 animate-spin"}),e("integrations.deleting",{defaultValue:"Deleting…"})]}):f(he,{children:[o(Ze,{className:"h-3 w-3"}),e("integrations.confirmDelete",{defaultValue:"Delete integration"})]})})]})]})})]}):f("div",{className:"flex flex-col items-center justify-center py-20 px-6 text-center gap-4",children:[o("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10",children:o(xO,{className:"h-6 w-6 text-foreground-subtle"})}),f("div",{className:"space-y-1 max-w-sm",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:e("integrations.integrationNotFound",{defaultValue:"Integration not found"})}),o("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??""})})]}),f("button",{onClick:()=>r("/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:[o(Hd,{className:"h-3 w-3"}),e("integrations.backToList",{defaultValue:"Back to integrations"})]})]})}function N7({label:e,color:t,title:n,style:r}){return f("div",{className:"absolute top-1/2 -translate-y-1/2 -translate-x-1/2 z-10 group cursor-pointer",style:r,title:n,children:[o("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&&o("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:f("div",{className:"bg-surface border border-border rounded px-2 py-1 text-[10px] text-foreground whitespace-nowrap shadow-lg",children:[o("span",{className:"inline-block h-1.5 w-1.5 rounded-full mr-1 align-middle",style:{backgroundColor:t}}),e]})})]})}const Zi=36e5;function k7(e){return String(e).padStart(2,"0")}function S7(e){const t=new Date(e);return`${k7(t.getHours())}:00`}function C7({startMs:e,endMs:t,segments:n,events:r,playheadMs:s,onSeek:a}){const i=te(null),l=t-e,c=U(m=>Math.max(0,Math.min(100,(m-e)/l*100)),[e,l]);function d(m){if(!i.current)return;const g=i.current.getBoundingClientRect(),b=Math.max(0,Math.min(1,(m.clientX-g.left)/g.width));a(Math.round(e+b*l))}const u=[],p=Math.floor(e/Zi),h=Math.ceil(t/Zi);for(let m=p;m<=h;m++){const g=m*Zi;g<e||g>t||u.push({percent:c(g),label:S7(g)})}return f("div",{className:"select-none",children:[o("div",{className:"relative h-5 mb-1",children:u.map(({percent:m,label:g})=>o("span",{className:"absolute -translate-x-1/2 text-[10px] text-foreground-subtle",style:{left:`${m}%`},children:g},g))}),f("div",{ref:i,className:"relative h-8 rounded bg-surface-hover cursor-pointer overflow-hidden border border-border",onClick:d,onPointerMove:m=>{m.buttons===1&&d(m)},children:[n.map((m,g)=>{const b=c(m.startMs),x=c(m.endMs)-b;return o("div",{className:"absolute top-1 bottom-1 rounded-sm bg-success/60",style:{left:`${b}%`,width:`${Math.max(x,.1)}%`}},g)}),r.map(m=>o(N7,{label:m.label,color:m.color,title:`${m.label} — ${new Date(m.timestampMs).toLocaleTimeString()}`,style:{left:`${c(m.timestampMs)}%`}},m.id)),o("div",{className:"absolute top-0 bottom-0 w-0.5 bg-danger z-20 pointer-events-none",style:{left:`${c(s)}%`},children:o("div",{className:"absolute -top-0.5 left-1/2 -translate-x-1/2 w-2.5 h-2.5 bg-danger rotate-45"})})]})]})}const xf={person:"#f59e0b",vehicle:"#3b82f6",car:"#3b82f6",face:"#a855f7",plate:"#ec4899",animal:"#10b981",motion:"#ef4444",unknown:"#6b7280"};function tc(e){return xf[e.toLowerCase()]??xf.unknown}function M7(e){const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function E7(e){return new Date(e).toISOString().slice(0,10)}function I7(e){return new Date(e+"T00:00:00").getTime()}function A7(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 P7(e){const t=["person","vehicle","face","motion"];return Array.from({length:24},(n,r)=>({id:`placeholder-${r}`,timestampMs:e+Math.floor(Math.random()*24*36e5),label:t[r%t.length],color:tc(t[r%t.length])})).sort((n,r)=>n.timestampMs-r.timestampMs)}function _7(){const{t:e}=qt(),t=M7(new Date),[n,r]=_(t),[s,a]=_(null),[i,l]=_(t+12*36e5),c=n,d=n+24*36e5,{data:u,isLoading:p}=On({},{staleTime:3e4}),h=u??[],m=q(()=>h.filter(N=>{const k=N.type.toLowerCase();return k==="camera"||k.includes("camera")||N.features.some(C=>C.toLowerCase().includes("video")||C.toLowerCase().includes("stream"))}).map(N=>({id:N.id,name:N.name??N.stableId})),[h]),g=s??m[0]?.id??null,{data:b}=Ln({queryKey:["events",g,c],queryFn:()=>Promise.resolve(null),enabled:!!g,staleTime:6e4}),x=q(()=>{const v=Array.isArray(b)?b:(()=>{const k=_u(b)?.events;return Array.isArray(k)?k:[]})();return v.length===0?g?P7(c):[]:v.flatMap((N,k)=>{const C=_u(N);if(!C)return[];const M=String(C.class??C.type??C.label??"unknown").toLowerCase(),P=typeof C.timestamp=="number"?C.timestamp:c;return[{id:String(C.id??k),timestampMs:P,label:M,color:tc(M)}]})},[b,g,c]),y=q(()=>g?A7(c):[],[g,c]);function w(v){r(N=>N+v*24*36e5),l(N=>N+v*24*36e5)}return f("div",{className:"flex flex-col h-full p-4 gap-4 overflow-hidden",children:[f("div",{className:"flex items-center justify-between gap-4 shrink-0",children:[o("h1",{className:"text-lg font-semibold text-foreground",children:e("nav.timeline","Timeline")}),f("div",{className:"flex items-center gap-2",children:[o("button",{onClick:()=>w(-1),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",children:o(qd,{className:"h-4 w-4"})}),f("div",{className:"relative flex items-center",children:[o(zy,{className:"absolute left-2 h-3.5 w-3.5 text-foreground-subtle pointer-events-none"}),o("input",{type:"date",value:E7(n),onChange:v=>{if(v.target.value){const N=I7(v.target.value);r(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"})]}),o("button",{onClick:()=>w(1),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",disabled:n>=t,children:o(Nt,{className:"h-4 w-4"})})]})]}),f("div",{className:"flex gap-1.5 shrink-0 overflow-x-auto pb-1",children:[p&&o("div",{className:"h-8 w-48 rounded-lg bg-surface animate-pulse"}),!p&&m.length===0&&o("span",{className:"text-xs text-foreground-subtle",children:"No cameras found"}),m.map(v=>{const N=v.id===g;return o("button",{onClick:()=>a(v.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:v.name},v.id)})]}),f("div",{className:"relative w-full aspect-video rounded-xl border border-border bg-black shrink-0 overflow-hidden max-h-[45vh]",children:[f("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 text-foreground-subtle",children:[o(yo,{className:"h-12 w-12 opacity-20"}),o("p",{className:"text-sm opacity-50",children:g?`${m.find(v=>v.id===g)?.name??g} — seek to play`:"Select a camera"})]}),o("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()})]}),f("div",{className:"rounded-xl border border-border bg-surface px-4 pt-3 pb-4 shrink-0",children:[f("div",{className:"flex flex-wrap items-center gap-4 mb-3",children:[o("span",{className:"text-[10px] font-semibold text-foreground-subtle uppercase tracking-wider",children:"Timeline"}),f("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"inline-block h-2 w-4 rounded-sm bg-success/60"}),o("span",{className:"text-[10px] text-foreground-subtle",children:"Recording"})]}),Array.from(new Set(x.map(v=>v.label))).slice(0,5).map(v=>f("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{backgroundColor:tc(v)}}),o("span",{className:"text-[10px] text-foreground-subtle capitalize",children:v})]},v))]}),g?o(C7,{startMs:c,endMs:d,segments:y,events:x,playheadMs:i,onSeek:l}):o("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 $7({selectedNodeId:e,onSelect:t,refreshToken:n}){const{data:r}=Bn(void 0,{staleTime:3e4}),{data:s}=Fa(void 0,{staleTime:3e4}),a=new Map;for(const d of s??[])a.set(d.agentNodeId,(a.get(d.agentNodeId)??0)+1);const i=r??[],l=i.filter(d=>d.isOnline).length,c=i.filter(d=>!d.isOnline).length;return f("div",{className:"flex flex-col h-full",children:[f("button",{type:"button",onClick:()=>t(No),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===No?"bg-primary/10 text-primary":"text-foreground hover:bg-surface-hover"}`,children:[o(hn,{className:"h-4 w-4 flex-shrink-0"}),f("div",{className:"min-w-0 flex-1",children:[o("div",{className:"text-xs font-semibold truncate",children:"Cluster"}),o("div",{className:"text-[10px] text-foreground-subtle",children:"Balancer + failover + assignments"})]})]}),o("div",{className:"flex-1 overflow-y-auto",children:i.map(d=>{const u=e===d.id,p=a.get(d.id)??0,h=d.isHub?mn:xt;return f("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 ${u?"bg-primary/10 text-primary":"text-foreground hover:bg-surface-hover"}`,children:[o(h,{className:"h-4 w-4 flex-shrink-0"}),f("div",{className:"min-w-0 flex-1",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-xs font-semibold truncate",children:d.name}),d.isHub&&o("span",{className:"text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5",children:"hub"}),!d.isOnline&&o("span",{className:"h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0"}),d.isOnline&&o("span",{className:"h-1.5 w-1.5 rounded-full bg-success flex-shrink-0"})]}),f("div",{className:"text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5",children:[f("span",{children:[d.cpuCores," cores"]}),o("span",{children:"•"}),f("span",{children:[Math.round(d.memoryMB/1024)," GB"]}),p>0&&f(he,{children:[o("span",{children:"•"}),f("span",{className:"inline-flex items-center gap-0.5 text-foreground",children:[o(nv,{className:"h-2.5 w-2.5"}),p]})]})]})]})]},d.id)})}),f("div",{className:"px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between",children:[f("span",{children:[l," online"]}),c>0&&f("span",{className:"text-destructive",children:[c," offline"]})]})]})}function D7({nodeId:e,refreshToken:t}){const{data:n}=Bn(void 0,{staleTime:3e4}),r=n?.find(i=>i.id===e),a=Gr("pipeline.runner-load-snapshot",i=>i.nodeId===e)?.load??null;return r?f("div",{className:"px-6 py-4 border-b border-border",children:[f("div",{className:"flex items-center gap-2 mb-1",children:[o("h2",{className:"text-base font-semibold text-foreground",children:r.name}),r.isOnline?o("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success",children:"online"}):o("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:"offline"}),r.isHub&&o("span",{className:"text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5",children:"hub"})]}),f("div",{className:"text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap",children:[o("span",{children:r.cpuModel??"CPU"}),o("span",{children:"•"}),f("span",{children:[r.cpuCores," cores"]}),o("span",{children:"•"}),f("span",{children:[Math.round(r.memoryMB/1024)," GB"]}),a&&f(he,{children:[o("span",{children:"•"}),f("span",{children:[a.attachedCameras," cameras (",a.activeCameras," active)"]}),o("span",{children:"•"}),f("span",{children:[a.avgInferenceTimeMs.toFixed(0),"ms avg inference"]}),o("span",{children:"•"}),f("span",{children:["queue ",a.queueDepthTotal]}),a.hardware.hasGpu&&f(he,{children:[o("span",{children:"•"}),o("span",{className:"text-success",children:"GPU"})]})]})]})]}):o("div",{className:"px-6 py-4 border-b border-border",children:f("div",{className:"text-xs text-foreground-subtle",children:["Node not found: ",e]})})}function wv({refreshToken:e,nodeId:t}){const[n,r]=_(new Map),{nodes:s}=Kr();bt("pipeline.camera-metrics-snapshot",p=>{const h=p.data;typeof h?.deviceId=="number"&&r(m=>{const g=new Map(m);return g.set(h.deviceId,h),g})});const{data:a}=Gx(void 0,{staleTime:5e3}),i=q(()=>{const p=new Map;for(const h of a??[])p.set(h.nodeId,h.deviceCount);return p},[a]),l=q(()=>{const p=new Map,h=Date.now()-3e4;for(const m of n.values()){if(m.timestamp<h)continue;const g=m.nodeId??"hub",b=p.get(g)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};b.attachedCameras++,m.metrics.phase==="active"&&b.activeCameras++,b.totalFps+=m.metrics.actualFps,b.totalInferenceWeighted+=m.metrics.avgInferenceTimeMs,b.queueDepth+=m.metrics.queueDepth,p.set(g,b)}return p},[n]),c=q(()=>{const p=new Map;for(const h of s)p.set(h.id,h.shortName);return p},[s]),d=q(()=>{let p=0,h=0,m=0,g=0,b=0;for(const y of l.values())p+=y.attachedCameras,h+=y.activeCameras,m+=y.totalFps,g+=y.totalInferenceWeighted,b+=y.queueDepth;const x=p>0?g/p:0;return{totalAgents:s.length,onlineAgents:s.filter(y=>y.isOnline).length,attachedCameras:p,activeCameras:h,avgInferenceTimeMs:x,queueDepth:b,totalFps:m}},[l,s]);if(t){const p=l.get(t);return f("div",{className:"@container/liveload",children:[o("h3",{className:"text-sm font-semibold text-foreground mb-2",children:"Live load"}),f("div",{className:"grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3",children:[o(Gt,{label:"FPS",value:p?p.totalFps.toFixed(1):"—"}),o(Gt,{label:"Cameras",value:p?`${p.activeCameras}/${p.attachedCameras}`:"—"}),o(Gt,{label:"Avg infer ms",value:p&&p.attachedCameras>0?(p.totalInferenceWeighted/p.attachedCameras).toFixed(0):"—"}),o(Gt,{label:"Queue",value:p?String(p.queueDepth):"—"}),o(Gt,{label:"Audio",value:String(i.get(t)??"—")})]})]})}const u=[...l.entries()].sort(([p],[h])=>p==="hub"?-1:h==="hub"?1:p.localeCompare(h));return f("div",{className:"@container/liveload",children:[o("h3",{className:"text-sm font-semibold text-foreground mb-2",children:"Live load"}),f("div",{className:"grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3",children:[o(Gt,{label:"Total agents",value:`${d.onlineAgents}/${d.totalAgents}`}),o(Gt,{label:"Cameras",value:`${d.activeCameras}/${d.attachedCameras}`}),o(Gt,{label:"Total FPS",value:d.totalFps.toFixed(1)}),o(Gt,{label:"Avg inference ms",value:d.avgInferenceTimeMs.toFixed(0)}),o(Gt,{label:"Queue depth",value:String(d.queueDepth)})]}),o("div",{className:"rounded-lg border border-border overflow-x-auto",children:f("table",{className:"w-full text-xs min-w-[480px]",children:[o("thead",{className:"bg-surface",children:f("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[o("th",{className:"text-left px-3 py-2",children:"Agent"}),o("th",{className:"text-right px-3 py-2",children:"FPS"}),o("th",{className:"text-right px-3 py-2",children:"Cameras"}),o("th",{className:"text-right px-3 py-2",children:"Inference ms"}),o("th",{className:"text-right px-3 py-2",children:"Queue"}),o("th",{className:"text-right px-3 py-2",children:"Audio"})]})}),f("tbody",{children:[u.map(([p,h])=>f("tr",{className:"border-t border-border",children:[o("td",{className:"px-3 py-2 text-foreground font-medium",children:c.get(p)??p}),o("td",{className:"px-3 py-2 text-right text-foreground",children:h.totalFps.toFixed(1)}),o("td",{className:"px-3 py-2 text-right text-foreground",children:h.attachedCameras}),o("td",{className:"px-3 py-2 text-right text-foreground",children:h.attachedCameras>0?(h.totalInferenceWeighted/h.attachedCameras).toFixed(0):"—"}),o("td",{className:"px-3 py-2 text-right text-foreground",children:h.queueDepth}),o("td",{className:"px-3 py-2 text-right text-foreground",children:i.get(p)??"—"})]},p)),u.length===0&&o("tr",{children:o("td",{colSpan:6,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:"No camera metrics received yet"})})]})]})})]})}function Gt({label:e,value:t}){return f("div",{className:"rounded-lg border border-border bg-surface/60 p-3",children:[o("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle mb-1",children:e}),o("div",{className:"text-lg font-semibold text-foreground",children:t})]})}function Nv(e){return On({addonId:e})}function L7(e){return Jn({deviceId:e},{enabled:Number.isFinite(e)})}const T7=3e4,R7=2e3;function kv(e){const t=te(0);return t.current===0&&(t.current=Date.now()),Vb({parentDeviceId:e},{enabled:Number.isFinite(e),staleTime:0,refetchOnMount:"always",refetchInterval:n=>{const r=n.state.data;return r&&r.length>0||Date.now()-t.current>=T7?!1:R7}})}const Xi={active:!1,pinned:!1,nodeId:null,reason:""},Ji=["pipeline.camera-assigned","pipeline.camera-unassigned","pipeline.camera-updated","agent.online","agent.offline"],O7={pipeline:xt,decoder:yo,audio:Wl},yf={pipeline:"Pipeline",decoder:"Decoder",audio:"Audio"};function Sv({mode:e,nodeId:t,compact:n=!1}){if(e==="agent"&&!t)throw new Error('CameraAssignmentsTable: nodeId is required when mode === "agent"');const r=ke(),[s,a]=_(null),[i,l]=_(null),[c,d]=_(new Map);Ct(["pipelineOrchestrator","getPipelineAssignments"],Ji),Ct(["pipelineOrchestrator","getDecoderAssignments"],Ji),Ct(["pipelineOrchestrator","getAudioAssignments"],Ji);const{data:u}=Fa(void 0,{staleTime:3e4}),{data:p}=qx(void 0,{staleTime:3e4}),{data:h}=Kx(void 0,{staleTime:3e4}),{nodes:m}=Kr(),{data:g}=Nv();bt("pipeline.camera-metrics-snapshot",A=>{const O=A.data;typeof O.deviceId=="number"&&d(R=>{const E=new Map(R);return E.set(O.deviceId,O),E})}),Y(()=>{if(c.size===0)return;const A=setInterval(()=>{d(O=>{const R=Date.now()-1e4;let E=!1;const D=new Map(O);for(const[L,T]of O)T.timestamp<R&&(D.delete(L),E=!0);return E?D:O})},5e3);return()=>clearInterval(A)},[c.size]);const b=q(()=>{const A=new Map;for(const O of g??[])A.set(O.id,O.name);return A},[g]),x=q(()=>{const A=new Map,O=E=>{const D=A.get(E);if(D)return D;const L={deviceId:E,deviceName:b.get(E)??`Device ${E}`,pipeline:Xi,decoder:Xi,audio:Xi};return A.set(E,L),L};for(const E of u??[]){const D=O(E.deviceId);A.set(E.deviceId,{...D,pipeline:{active:e==="cluster"?!0:E.agentNodeId===t,pinned:E.pinned,nodeId:E.agentNodeId,reason:E.reason??""}})}for(const E of p??[]){const D=O(E.deviceId);A.set(E.deviceId,{...D,decoder:{active:e==="cluster"?!0:E.decoderNodeId===t,pinned:E.pinned,nodeId:E.decoderNodeId,reason:E.reason??""}})}for(const E of h??[]){const D=O(E.deviceId);A.set(E.deviceId,{...D,audio:{active:e==="cluster"?!0:E.nodeId===t,pinned:E.pinned,nodeId:E.nodeId,reason:"capacity"}})}let R=[...A.values()];return e==="agent"&&(R=R.filter(E=>E.pipeline.active||E.decoder.active||E.audio.active)),R.sort((E,D)=>E.deviceId-D.deviceId),R},[u,p,h,b,e,t]),y=q(()=>(m??[]).filter(A=>A.isOnline).map(A=>({id:A.id,name:A.name})),[m]),w=()=>{r.invalidateQueries({queryKey:[["pipelineOrchestrator","getPipelineAssignments"]]}),r.invalidateQueries({queryKey:[["pipelineOrchestrator","getDecoderAssignments"]]}),r.invalidateQueries({queryKey:[["pipelineOrchestrator","getAudioAssignments"]]})},v=Rx({onSuccess:w}),N=Ox({onSuccess:w}),k=Vx({onSuccess:w}),C=Hx({onSuccess:w}),M=Ux({onSuccess:w}),P=Qx({onSuccess:w}),I=(A,O,R)=>{O==="pipeline"?v.mutate({deviceId:A,agentNodeId:R}):O==="decoder"?k.mutate({deviceId:A,nodeId:R}):M.mutate({deviceId:A,nodeId:R}),a(null)},z=(A,O)=>{O==="pipeline"?N.mutate({deviceId:A}):O==="decoder"?C.mutate({deviceId:A}):P.mutate({deviceId:A}),a(null)};return o("div",{className:"rounded-lg border border-border overflow-x-auto",children:f("table",{className:"w-full text-xs min-w-[640px]",children:[o("thead",{className:"bg-surface",children:f("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[!n&&o("th",{className:"w-6"}),o("th",{className:"text-left px-3 py-2 align-middle",children:"Camera"}),o("th",{className:"text-left px-3 py-2 align-middle",children:"Pipeline"}),o("th",{className:"text-left px-3 py-2 align-middle",children:"Decoder"}),o("th",{className:"text-left px-3 py-2 align-middle",children:"Audio"}),o("th",{className:"text-left px-3 py-2 align-middle",children:"Status"})]})}),f("tbody",{children:[x.map(A=>{const O=c.get(A.deviceId),R=i===A.deviceId;return f(Ge.Fragment,{children:[f("tr",{className:"border-t border-border align-middle relative",children:[!n&&o("td",{className:"px-2 py-2 align-middle",children:o("button",{type:"button",onClick:()=>l(R?null:A.deviceId),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle","aria-label":R?"Collapse broker details":"Expand broker details",children:R?o(lt,{className:"h-3.5 w-3.5"}):o(Nt,{className:"h-3.5 w-3.5"})})}),f("td",{className:"px-3 py-2 align-middle",children:[o("div",{className:"text-foreground font-medium leading-tight",children:A.deviceName}),f("div",{className:"text-[10px] text-foreground-subtle leading-tight",children:["#",A.deviceId]})]}),o(el,{role:"pipeline",state:A.pipeline,mode:e,deviceId:A.deviceId,onlineNodes:y,isMenuOpen:s?.deviceId===A.deviceId&&s.role==="pipeline",onToggleMenu:()=>a(s?.deviceId===A.deviceId&&s.role==="pipeline"?null:{deviceId:A.deviceId,role:"pipeline"}),onCloseMenu:()=>a(null),onMove:E=>I(A.deviceId,"pipeline",E),onUnpin:()=>z(A.deviceId,"pipeline")}),o(el,{role:"decoder",state:A.decoder,mode:e,deviceId:A.deviceId,onlineNodes:y,isMenuOpen:s?.deviceId===A.deviceId&&s.role==="decoder",onToggleMenu:()=>a(s?.deviceId===A.deviceId&&s.role==="decoder"?null:{deviceId:A.deviceId,role:"decoder"}),onCloseMenu:()=>a(null),onMove:E=>I(A.deviceId,"decoder",E),onUnpin:()=>z(A.deviceId,"decoder")}),o(el,{role:"audio",state:A.audio,mode:e,deviceId:A.deviceId,onlineNodes:y,isMenuOpen:s?.deviceId===A.deviceId&&s.role==="audio",onToggleMenu:()=>a(s?.deviceId===A.deviceId&&s.role==="audio"?null:{deviceId:A.deviceId,role:"audio"}),onCloseMenu:()=>a(null),onMove:E=>I(A.deviceId,"audio",E),onUnpin:()=>z(A.deviceId,"audio")}),o("td",{className:"px-3 py-2 align-middle",children:o(F7,{snap:O})})]}),R&&!n&&f("tr",{className:"bg-surface/50",children:[o("td",{}),o("td",{colSpan:5,className:"px-3 py-2",children:o(ht,{widgetId:"stream-broker/stream-broker-panel",host:"device-tab",deviceId:A.deviceId,instanceId:`pipeline-row/${A.deviceId}`,config:{variant:"compact",title:"Stream brokers & clients"}})})]})]},A.deviceId)}),x.length===0&&o("tr",{children:o("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 el({role:e,state:t,mode:n,onlineNodes:r,isMenuOpen:s,onToggleMenu:a,onCloseMenu:i,onMove:l,onUnpin:c}){const d=O7[e],u=r.filter(m=>m.id!==(t.nodeId??"")),h=(t.active||n==="cluster")&&(u.length>0||t.pinned);return f("td",{className:"px-3 py-2 align-middle relative",children:[f("div",{className:"flex items-center gap-2",children:[n==="agent"?o(B7,{state:t,Icon:d}):o(z7,{state:t,Icon:d}),o("div",{className:"ml-auto",children:h&&o("button",{type:"button",onClick:a,className:"p-1 rounded hover:bg-surface-hover","aria-label":`${yf[e]} actions`,children:o(a6,{className:"h-3 w-3 text-foreground-subtle"})})})]}),s&&h&&o(j7,{title:yf[e],targets:u,pinned:t.pinned,onMove:l,onUnpin:c,onClose:i})]})}function B7({state:e,Icon:t}){const n=e.active?ev:ns;return f("div",{className:"flex items-center gap-1.5",children:[o(n,{className:`h-3.5 w-3.5 ${e.active?"text-success":"text-foreground-subtle/50"}`}),o(t,{className:`h-3 w-3 ${e.active?"text-foreground-subtle":"text-foreground-subtle/40"}`}),e.pinned&&o(Yy,{className:"h-2.5 w-2.5 text-amber-400"})]})}function z7({state:e,Icon:t}){return!e.active||!e.nodeId?f("div",{className:"flex items-center gap-1.5 text-foreground-subtle/60",children:[o(t,{className:"h-3 w-3"}),o("span",{className:"text-[10px] italic",children:"—"})]}):f("div",{className:"flex items-center gap-1.5 min-w-0",children:[o(t,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),f("div",{className:"flex flex-col leading-tight min-w-0",children:[o("span",{className:"font-mono text-[11px] text-foreground truncate",children:e.nodeId}),o("span",{className:"flex items-center gap-1 text-[10px]",children:e.pinned?f("span",{className:"inline-flex items-center gap-0.5 text-amber-400",children:[o(Yy,{className:"h-2.5 w-2.5"})," manual"]}):f("span",{className:"text-foreground-subtle truncate",children:["auto · ",e.reason||"capacity"]})})]})]})}function F7({snap:e}){if(!e)return o("span",{className:"text-[10px] text-foreground-subtle italic",children:"—"});const{phase:t,actualFps:n,avgInferenceTimeMs:r,queueDepth:s,configuredFps:a}=e.metrics,i=ur(t);return f("div",{className:"flex flex-col gap-0.5 font-mono text-[10px] tabular-nums leading-tight",children:[f("span",{className:`inline-flex items-center gap-1 ${i.textColor}`,children:[o(Sd,{phase:t,className:"h-2.5 w-2.5"}),o("span",{className:"font-semibold uppercase tracking-wider",children:i.label})]}),f("span",{className:"text-foreground-subtle",children:[o("span",{className:"text-foreground",children:n.toFixed(1)}),f("span",{children:["/",a.toFixed(0)," fps"]})]}),f("span",{className:"text-foreground-subtle",children:[o("span",{className:"text-foreground",children:r.toFixed(0)}),o("span",{children:" ms"}),s>0&&f("span",{className:"text-warning ml-1",children:["q",s]})]})]})}function j7({title:e,targets:t,pinned:n,onMove:r,onUnpin:s,onClose:a}){const i=te(null);return Y(()=>{const l=c=>{i.current?.contains(c.target)||a()};return window.addEventListener("mousedown",l),()=>window.removeEventListener("mousedown",l)},[a]),f("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:[o("div",{className:"px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border",children:e}),t.length>0&&o("div",{className:"py-1",children:t.map(l=>f("button",{type:"button",onClick:()=>r(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&&f("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&&o("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle italic",children:"Already auto · no other nodes online"})]})}function V7({nodeId:e,refreshToken:t}){return f("div",{className:"space-y-6",children:[o(wv,{refreshToken:t,nodeId:e}),f("div",{children:[o("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Cameras on this node"}),f("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."]})]}),o(Sv,{mode:"agent",nodeId:e,compact:!0})]})}function H7(e,t){const n=Math.max(0,t-e),r=Math.floor(e/1e3),s=Math.floor(n/1e3);return`${r}s idle · ${s}s left`}function q7({nodeId:e,refreshToken:t}){const n=ke(),r=Tx({onSettled:()=>{n.invalidateQueries({queryKey:["pipelineExecutor","listLoadedEngines"]})}}),{data:s}=Lx({nodeId:e},{staleTime:5e3}),i=Gr("pipeline.engine-metrics-snapshot",h=>h.nodeId===e)?.engines??s??null,l=i===null;Ct(["pipelineRunner","getLocalCameras"],["pipeline.camera-assigned","pipeline.camera-unassigned"]);const{data:c}=r0({nodeId:e},{staleTime:3e4}),{values:d}=Kc("pipeline.camera-metrics-snapshot",h=>h.deviceId,h=>h.nodeId===e),u=q(()=>d.filter(h=>h.metrics.phase==="active").length,[d]),p=h=>{const m=c??[];m.length>0&&!window.confirm(`${m.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||r.mutate({nodeId:e,engine:h,force:m.length>0})};return f("div",{className:"space-y-6",children:[f("div",{children:[o("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Inference engines on this node"}),f("p",{className:"text-[11px] text-foreground-subtle",children:[(i??[]).length," engine(s) resident in RAM. ",(c??[]).length," camera(s) attached, ",u," actively dispatching frames. Refreshes every 5s."]})]}),o("div",{className:"rounded-lg border border-border overflow-x-auto",children:f("table",{className:"w-full text-xs min-w-[640px]",children:[o("thead",{className:"bg-surface",children:f("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[o("th",{className:"text-left px-3 py-2 whitespace-nowrap",children:"Kind"}),o("th",{className:"text-left px-3 py-2 whitespace-nowrap",children:"Runtime / Backend / Device"}),o("th",{className:"text-left px-3 py-2",children:"Models"}),o("th",{className:"text-right px-3 py-2 whitespace-nowrap",children:"Pool PID"}),o("th",{className:"text-right px-3 py-2 whitespace-nowrap",children:"Auto-kill"}),o("th",{className:"text-right px-3 py-2 whitespace-nowrap",children:"In use"}),o("th",{className:"w-20"})]})}),f("tbody",{children:[l&&o("tr",{children:o("td",{colSpan:7,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:"Loading…"})}),!l&&(i??[]).map(h=>{const m=h.kind==="warm-override";return f("tr",{className:`border-t border-border ${m?"bg-amber-500/5":""}`,children:[o("td",{className:"px-3 py-2",children:f("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${m?"bg-amber-500/15 text-amber-400":"bg-success/15 text-success"}`,children:[m?o(p6,{className:"h-3 w-3"}):o(xt,{className:"h-3 w-3"}),m?"warm":"runtime"]})}),o("td",{className:"px-3 py-2",children:f("span",{className:"inline-flex items-center gap-1 text-[11px] text-sky-400",children:[o(Yd,{className:"h-3 w-3"}),h.engine.runtime,"/",h.engine.backend,h.engine.device?`/${h.engine.device}`:"",h.engine.format?` · ${h.engine.format}`:""]})}),o("td",{className:"px-3 py-2",children:h.modelsLoaded.length===0?o("span",{className:"text-foreground-subtle text-[11px]",children:"—"}):o("div",{className:"flex flex-wrap gap-1",children:h.modelsLoaded.map(g=>o("span",{className:"inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle",children:g},g))})}),o("td",{className:"px-3 py-2 text-right font-mono text-foreground",children:h.poolPid??"—"}),o("td",{className:"px-3 py-2 text-right text-[11px]",children:h.idleMs!==null&&h.idleTtlMs!==null?o("span",{className:"text-foreground-subtle",children:H7(h.idleMs,h.idleTtlMs)}):o("span",{className:"text-foreground-subtle/50",children:"never"})}),o("td",{className:"px-3 py-2 text-right text-foreground",children:m?"—":(c??[]).length}),o("td",{className:"px-3 py-2 text-right",children:f("button",{type:"button",disabled:r.isPending,onClick:()=>p(h.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:[o(Ze,{className:"h-3 w-3"}),"Kill"]})})]},h.engineKey)}),!l&&(i??[]).length===0&&o("tr",{children:o("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."})})]})]})}),f("div",{className:"text-[10px] text-foreground-subtle leading-relaxed",children:[o("strong",{className:"text-foreground",children:"runtime"}),": main camera-serving engine; never auto-killed while cameras attached. ",o("strong",{className:"text-foreground",children:"warm"}),": benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL."]}),r.isError&&f("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive",children:["Kill failed: ",r.error instanceof Error?r.error.message:"unknown"]})]})}function It(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,r="KB";for(const a of t){if(r=a,n<1024)break;n/=1024}return`${n>=100?Math.round(n).toString():n.toFixed(1)} ${r}`}function Cv(e){return It(e*1024*1024)}const U7=new Set(m2);function vf(e){return U7.has(e)}function tl(e,t,n){return`${e}/${t}/${n}`}function nc(e){return{coreml:"CoreML",openvino:"OpenVINO",onnx:"ONNX"}[e.format]??e.format.toUpperCase()}function wf(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 Hn(e){return e.format}function Q7(e,t){let n=0,r=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&&(r++,s+=c.sizeMB))}return{total:n,downloaded:r,downloadedSizeMB:s}}function G7({addonId:e,model:t,format:n,isActive:r,progress:s,errorMsg:a,onDownload:i,onDelete:l}){const c=t.formats[n];return c?f("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:[o("div",{className:`h-2 w-2 rounded-full shrink-0 ${c.downloaded?"bg-success":"bg-foreground-subtle/30"}`}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-sm font-medium text-foreground",children:t.name}),f("span",{className:"text-[10px] text-foreground-subtle font-mono",children:["(",t.id,")"]})]}),s&&s.progress>=0&&s.progress<100&&f("div",{className:"mt-1.5 flex items-center gap-2 max-w-xs",children:[o("div",{className:"flex-1 h-1 bg-surface-hover rounded-full overflow-hidden",children:o("div",{className:"bg-primary h-full rounded-full transition-all duration-300",style:{width:`${s.progress}%`}})}),f("span",{className:"text-[9px] text-primary font-mono tabular-nums shrink-0",children:[Math.round(s.progress),"%"]})]})]}),o("span",{className:"text-xs text-foreground-subtle tabular-nums shrink-0",children:Cv(c.sizeMB)}),a&&f("span",{className:"flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0",title:a,children:[o(nr,{className:"h-3 w-3 shrink-0"}),a]}),c.downloaded?f("button",{onClick:l,disabled:r,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:[r?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ze,{className:"h-3 w-3"}),r?"Deleting...":"Delete"]}):f("button",{onClick:i,disabled:r,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:[r?o(Se,{className:"h-3 w-3 animate-spin"}):o(en,{className:"h-3 w-3"}),r?"Downloading...":"Download"]})]}):null}function K7({engines:e,activeEngine:t,viewEngine:n,onSelect:r}){const[s,a]=_(!1);return f("div",{className:"relative",children:[f("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:[o(xt,{className:"h-4 w-4 text-primary shrink-0"}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-sm font-medium text-foreground",children:nc(n)}),Hn(n)===Hn(t)&&o("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium",children:"Active"})]}),o("div",{className:"text-[10px] text-foreground-subtle",children:wf(n)})]}),o(lt,{className:`h-4 w-4 text-foreground-subtle transition-transform ${s?"rotate-180":""}`})]}),s&&o("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=Hn(i)===Hn(n),c=Hn(i)===Hn(t);return f("button",{type:"button",onClick:()=>{r(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:[o(xt,{className:`h-4 w-4 shrink-0 ${l?"text-primary":"text-foreground-subtle"}`}),f("div",{className:"flex-1",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:`text-sm font-medium ${l?"text-primary":"text-foreground"}`,children:nc(i)}),c&&o("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium",children:"Active"})]}),o("div",{className:"text-[10px] text-foreground-subtle",children:wf(i)})]}),l&&o(Ud,{className:"h-4 w-4 text-primary shrink-0"})]},Hn(i))})})]})}function W7({embedded:e=!1,nodeId:t}={}){const n=ke(),r=t??"hub",[s,a]=_(null),[i,l]=_(new Set),[c,d]=_(new Map),[u,p]=_(new Map),[h,m]=_(""),{data:g=[]}=Ax({nodeId:r},{staleTime:6e4}),x=g.filter((B,F,j)=>j.findIndex(V=>V.format===B.format)===F),{data:y}=Px({nodeId:r},{staleTime:3e4}),w=y,{data:v,isLoading:N}=Yo({nodeId:r},{staleTime:1e4}),k=$x(),C=Dx();bt("model.download.progress",B=>{const F=B.data,j=typeof F.modelId=="string"?F.modelId:void 0,V=typeof F.progress=="number"?F.progress:void 0,$=typeof F.totalMB=="number"?F.totalMB:0;j===void 0||V===void 0||(d(H=>{const G=new Map(H);return V===100||V===-1?G.delete(j):G.set(j,{modelId:j,progress:V,totalMB:$}),G}),V===100&&n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]}))});const M=w??{runtime:"node",backend:"cpu",format:"onnx"},P=x.find(B=>B.format===s)??M,I=P.format,z=v?.slots??[],A=z.map(B=>({...B,addons:B.addons.map(F=>({...F,models:F.models.filter(j=>j.formats[I]!==void 0)})).filter(F=>F.models.length>0)})).filter(B=>B.addons.length>0),O=Q7(A,I),R=U(async(B,F,j)=>{if(!vf(j))return;const V=tl(B,F,j);l($=>new Set([...$,V])),p($=>{const H=new Map($);return H.delete(V),H});try{await k.mutateAsync({addonId:B,modelId:F,format:j,nodeId:r}),n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]})}catch($){p(H=>new Map([...H,[V,$ instanceof Error?$.message:"Download failed"]]))}finally{l($=>{const H=new Set($);return H.delete(V),H})}},[k,n,r]),E=U(async(B,F,j)=>{if(!vf(j))return;const V=tl(B,F,j);l($=>new Set([...$,V])),p($=>{const H=new Map($);return H.delete(V),H});try{await C.mutateAsync({addonId:B,modelId:F,format:j,nodeId:r}),n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]})}catch($){p(H=>new Map([...H,[V,$ instanceof Error?$.message:"Delete failed"]]))}finally{l($=>{const H=new Set($);return H.delete(V),H})}},[C,n,r]),D=U(B=>{a(B.format)},[]),L=h.trim()?A.map(B=>({...B,addons:B.addons.map(F=>({...F,models:F.models.filter(j=>j.name.toLowerCase().includes(h.toLowerCase())||j.id.toLowerCase().includes(h.toLowerCase())||F.name.toLowerCase().includes(h.toLowerCase()))})).filter(F=>F.models.length>0)})).filter(B=>B.addons.length>0):A,T=f(he,{children:[N&&o("div",{className:"flex items-center justify-center py-16",children:o(Se,{className:"h-5 w-5 animate-spin text-foreground-subtle"})}),!N&&z.length===0&&f("div",{className:"flex flex-col items-center justify-center py-16 text-foreground-subtle",children:[o(ia,{className:"h-8 w-8 mb-3 opacity-30"}),o("span",{className:"text-sm",children:"No pipeline steps available"}),o("span",{className:"text-xs mt-1",children:"Configure the detection pipeline to see available models."})]}),!N&&z.length>0&&f(he,{children:[o(K7,{engines:x,activeEngine:M,viewEngine:P,onSelect:D}),f("div",{className:"flex items-center gap-4 text-xs text-foreground-subtle",children:[f("span",{children:[o("span",{className:"font-semibold text-foreground tabular-nums",children:O.total}),o("span",{className:"ml-1",children:"compatible models"})]}),o("span",{className:"text-border",children:"|"}),f("span",{children:[o("span",{className:"font-semibold text-success tabular-nums",children:O.downloaded}),o("span",{className:"ml-1",children:"downloaded"})]}),o("span",{className:"text-border",children:"|"}),f("span",{className:"tabular-nums",children:[Cv(O.downloadedSizeMB),o("span",{className:"ml-1",children:"on disk"})]})]}),O.total>5&&f("div",{className:"relative",children:[o(Jy,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle"}),o("input",{type:"text",value:h,onChange:B=>m(B.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"})]}),L.map(B=>{const F=B.addons.reduce((V,$)=>V+$.models.length,0),j=B.addons.reduce((V,$)=>V+$.models.filter(H=>H.formats[I]?.downloaded).length,0);return f("div",{children:[f("div",{className:"flex items-center gap-2 mb-2",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:B.label}),o("div",{className:"flex-1 h-px bg-border"}),f("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[j,"/",F]})]}),o("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:B.addons.map(V=>V.models.map($=>{const H=tl(V.id,$.id,I);return o(G7,{addonId:V.id,model:$,format:I,isActive:i.has(H),progress:c.get($.id),errorMsg:u.get(H),onDownload:()=>R(V.id,$.id,I),onDelete:()=>E(V.id,$.id,I)},`${V.id}/${$.id}`)}))})]},B.id)}),L.length===0&&o("div",{className:"text-center py-8 text-sm text-foreground-subtle",children:h.trim()?f(he,{children:["No models matching “",h,"”"]}):f(he,{children:["No models available for ",nc(P)," format"]})})]})]});return e?o("div",{className:"space-y-4",children:T}):o(nt,{children:T})}function Y7({nodeId:e,refreshToken:t}){return o(W7,{embedded:!0,nodeId:e})}function Mv({nodeId:e,title:t}){const{data:n}=Nv(),{data:r}=Fa(void 0,{staleTime:3e4}),s=q(()=>{const d=new Map;for(const u of n??[])d.set(u.id,u.name);return d},[n]),a=q(()=>{if(!e)return null;const d=new Set;for(const u of r??[])u.agentNodeId===e&&d.add(u.deviceId);return d},[e,r]),[i,l]=_(new Map);bt("pipeline.camera-metrics-snapshot",d=>{const u=d.data;typeof u.deviceId=="number"&&(e&&u.nodeId!==e||l(p=>{const h=new Map(p);return h.set(u.deviceId,u),h}))}),Y(()=>{if(i.size===0)return;const d=setInterval(()=>{l(u=>{const p=Date.now()-1e4;let h=!1;const m=new Map(u);for(const[g,b]of u)b.timestamp<p&&(m.delete(g),h=!0);return h?m:u})},5e3);return()=>clearInterval(d)},[i.size]);const c=q(()=>{const d=[];for(const u of i.values())a&&!a.has(u.deviceId)||d.push(u);return d.sort((u,p)=>u.deviceId-p.deviceId),d},[i,a]);return c.length===0?f("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"]}):f("div",{className:"rounded-md border border-border bg-surface px-3 py-2",children:[f("div",{className:"flex items-center gap-2 mb-1.5",children:[o("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:t??"Cameras"}),o("span",{className:"text-[10px] text-foreground-subtle",children:c.length})]}),o("div",{className:"flex flex-wrap gap-1.5",children:c.map(d=>{const u=s.get(d.deviceId)??`#${d.deviceId}`,p=ur(d.metrics.phase);return f("div",{title:`${u} · ${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:[o(Sd,{phase:d.metrics.phase,className:"h-2.5 w-2.5"}),o("span",{className:"font-medium text-foreground/90 max-w-[120px] truncate",children:u}),o("span",{className:"font-mono tabular-nums",children:d.metrics.actualFps.toFixed(1)}),o("span",{className:"opacity-60",children:"fps"})]},d.deviceId)})})]})}function nl(e,t){if(!e)return null;for(const n of e.slots)for(const r of n.addons)if(r.id===t)return r;return null}function Z7({nodeId:e,refreshToken:t}){const n=ke(),[r,s]=_(null),[a,i]=_(null),l=Yo({nodeId:e},{refetchOnMount:"always"}),c=fd({agentNodeId:e},{refetchOnMount:"always"}),d=hd({onSuccess:()=>{n.invalidateQueries({queryKey:[["addonSettings"]]}),n.invalidateQueries({queryKey:[["pipelineOrchestrator"]]}),n.invalidateQueries({queryKey:[["pipelineExecutor"]]})}}),u=l.data??null,p=c.data,h=u?.selectedEngine.format??"coreml",m=q(()=>u?Da(u):[],[u]),g=q(()=>[{agentNodeId:e,engineLabel:h}],[e,h]),b=(C,M)=>{const P=p?.addonDefaults[C];return nl(u,C)?.models.some(A=>!!A.formats[h])?P?P.enabled?{kind:"enabled",modelId:P.modelId}:{kind:"disabled"}:{kind:"na"}:{kind:"na"}},x=r&&u?nl(u,r.addonId):null,y=C=>{const M=p?.addonDefaults[C]??null;s({addonId:C,agentNodeId:e}),i(M)},w=(C,M)=>{if(!p)return;const P=p.addonDefaults[C],I=nl(u,C);if(!P&&!I)return;const z={enabled:M,modelId:P?.modelId??I?.defaultModelId??"",settings:P?.settings??{}};d.mutate({agentNodeId:e,defaults:{...p.addonDefaults,[C]:z}})},v=()=>{s(null),i(null)},N=()=>{!a||!r||!p||d.mutate({agentNodeId:e,defaults:{...p.addonDefaults,[r.addonId]:a}},{onSuccess:v})};if(l.isLoading||c.isLoading)return o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading pipeline…"});if(l.error)return f("div",{className:"text-xs text-red-400",children:["Failed to load catalog: ",String(l.error)]});if(!u)return o("div",{className:"text-xs text-foreground-subtle",children:"Catalog unavailable for this node (runner offline?)."});const k=r!==null&&x!==null&&a!==null;return f("div",{className:"relative h-full w-full space-y-3",children:[o(Mv,{nodeId:e}),o("div",{className:k?"pr-[360px]":"",children:m.length>0?o(Uc,{tree:m,agents:g,getCellState:b,onCellClick:y,selectedCell:r,onToggleEnabled:w}):o("div",{className:"text-xs text-foreground-subtle",children:"Catalog empty."})}),o(qc,{open:k,onClose:v,title:x?.name??"",subtitle:r?`${r.agentNodeId} · ${h}`:"",footer:f(he,{children:[o("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:v,children:"Cancel"}),o("button",{type:"button",disabled:!a||!r||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&&r&&o(Ta,{mode:"agent",addon:x,agentDefault:a,agentNodeId:r.agentNodeId,engineFormat:h,onChangeAgentConfig:C=>i(C)})})]})}function Ev({pendingCount:e,onSave:t,onDiscard:n,saving:r=!1,saveLabel:s="Save",discardLabel:a="Discard"}){return e<=0?null:f("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:[f("span",{className:"text-xs text-foreground",children:[e," unsaved change",e===1?"":"s"]}),f("div",{className:"flex items-center gap-2",children:[o("button",{type:"button",onClick:n,disabled:r,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}),o("button",{type:"button",onClick:t,disabled:r,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:r?"Saving…":s})]})]})}function Iv({tabs:e,activeId:t,onChange:n,countByTab:r,pendingByTab:s}){return e.length===0?null:o("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=r?.get(a.id)??0,c=s?.get(a.id)??0;return f("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&&f("span",{className:"ml-1.5 text-[10px] opacity-60",children:["(",l,")"]}),c>0&&o("span",{className:"ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-primary"})]},a.id)})})}function X7(e,t){for(const n of e)for(const r of n.fields){if(!("key"in r)||r.key!==t)continue;if(r.type==="button"||r.type==="separator"||r.type==="info")return!0;const s=r.immediate;return s===!0?!0:s===!1?!1:n.immediate===!0}return!1}function Av({schema:e,serverValues:t,onImmediateSave:n,onDeferredSave:r}){const[s,a]=_({}),[i,l]=_(!1),c=te(null),d=e?.sections??[],u=Object.keys(s).length>0,p=q(()=>({...t,...s}),[t,s]);Y(()=>{if(u){l(!0);return}c.current&&clearTimeout(c.current),c.current=setTimeout(()=>l(!1),500)},[u]);const h=U(()=>{l(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>l(!1),2e3)},[]),m=U(y=>{h();const w={},v={},N={...t,...s};for(const[k,C]of Object.entries(y))N[k]!==C&&(X7(d,k)?w[k]=C:v[k]=C);Object.keys(w).length>0&&n(w),a(k=>{const C={...k};for(const M of Object.keys(w))delete C[M];for(const[M,P]of Object.entries(v))C[M]=P;return C})},[h,t,s,d,n]),g=U(y=>{const w={},v={};for(const[N,k]of Object.entries(s))y.includes(N)?w[N]=k:v[N]=k;a(v),Object.keys(w).length>0&&r(w)},[s,r]),b=U(y=>{a(w=>{const v={...w};for(const N of y)delete v[N];return v})},[]),x=U(()=>{a({})},[]);return{values:p,pendingKeys:Object.keys(s),hasPendingEdits:u,editingPaused:i,handleChange:m,handleSave:g,handleDiscard:b,resetAll:x}}const J7=Ue(function({addonId:t,schema:n,serverValues:r,onImmediateSave:s,onStateChange:a,onAction:i,disabled:l},c){const d=Av({schema:n,serverValues:r,onImmediateSave:U(b=>s(t,b),[t,s]),onDeferredSave:U(()=>{},[])});s2(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 u=d.pendingKeys,p=u.join("|"),h=q(()=>u.map(b=>`${b}=${JSON.stringify(d.values[b])}`).join(","),[u,d.values]),m=te(a);Y(()=>{m.current=a},[a]),Y(()=>{const b={};for(const x of u)b[x]=d.values[x];m.current({addonId:t,pendingKeys:u,pendingValues:b})},[t,p,h]);const g=q(()=>{if(i)return(b,x,y)=>i(t,b,x,y)},[t,i]);return o($n,{schema:n,values:d.values,onChange:d.handleChange,disabled:l,onAction:g})});function Pv(e,t){if(e.type==="separator"||e.type==="info"||e.type==="button")return e;if(e.type==="group"){const a=e.fields.map(i=>Pv(i,t));return{...e,fields:a}}const n=e;t[e.key]=n.value;const{value:r,...s}=n;return s}function eB(e,t){return{...e,fields:e.fields.map(n=>Pv(n,t))}}function tB(e){const t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(r=>eB(r,t))},values:t}}function to({nodeId:e,addonIds:t,level:n,deviceId:r,sectionIds:s,sectionTab:a,extraTabs:i,title:l,description:c}){const d=ke(),u=Le().trpcClient,p=bb(),h=xb(),m=_x(),g=Lb(),b=Cb(),x=!!(i&&i.length>0),[y,w]=_(null);if(n==="device"&&!r)throw new Error('NodeAddonsSettingsPanel: deviceId is required when level === "device"');const v=e??"hub",N=l2({queries:t.map(J=>({queryKey:[["addonSettings",n==="global"?"getGlobalSettings":"getDeviceSettings"],{addonId:J,nodeId:v,deviceId:r??null}],queryFn:async()=>{if(n==="global"){const ee=await u.addonSettings.getGlobalSettings.query({addonId:J,nodeId:v});return{addonId:J,result:ee}}const W=await u.addonSettings.getDeviceSettings.query({addonId:J,deviceId:r,nodeId:v});return{addonId:J,result:W}},staleTime:3e4}))}),k=N.some(J=>J.isLoading),C=N.map(J=>{if(!J.data)return"-";if(J.data.result===null)return`${J.data.addonId}:n`;const W=[];for(const ee of J.data.result.sections){W.push(`s:${ee.id}:${ee.tab??"general"}`);for(const ae of ee.fields){if(!("key"in ae))continue;const fe="options"in ae&&Array.isArray(ae.options)?ae.options.map(le=>le.value).join(","):"",ge=ae.value,Q=ge===void 0?"":typeof ge=="string"?ge:JSON.stringify(ge);W.push(`f:${ae.key}:${fe}:${Q}`)}}return`${J.data.addonId}:${W.join("|")}`}).join("||"),M=q(()=>{const J=new Set;for(const W of N){const ee=W.data?.result?.sections;if(ee)for(const ae of ee)J.add(ae.tab??"general")}return[...J]},[C+"::"+N.map(J=>(J.data?.result?.sections??[]).map(W=>W.tab??"general").join(",")).join("::")]),P=q(()=>new Map((i??[]).map(J=>[J.id,J])),[i]),I=q(()=>{if(!x)return[];const J=[...new Set([...M,...(i??[]).map(ee=>ee.id)])],W=ee=>{const ae=P.get(ee);if(ae?.order!==void 0)return ae.order;const fe=Sl[ee];return fe?fe.order:50};return J.sort((ee,ae)=>{const fe=W(ee),ge=W(ae);return fe!==ge?fe-ge:ee.localeCompare(ae)})},[x,M,i,P]),z=q(()=>{const J=new Map;for(const W of M){const ee=Sl[W];J.set(W,ee?.label??W.charAt(0).toUpperCase()+W.slice(1))}for(const W of i??[])J.set(W.id,W.label);return J},[M,i]),A=x?y&&I.includes(y)?y:I[0]??null:null,O=A!==null&&P.has(A),R=x?A&&!O?A:void 0:a,{data:E}=Ko(void 0,{staleTime:6e4}),D=q(()=>{const J=new Map;for(const W of E??[]){const ee=W.manifest?.id;if(!ee)continue;const ae=W.manifest?.name??W.manifest?.packageDisplayName??ee;J.set(ee,ae)}return J},[E]),L=q(()=>{const J=s?new Set(s):null,W=[];for(const ee of N){if(!ee.data||ee.data.result===null)continue;const{schema:ae,values:fe}=tB(ee.data.result),ge=ae.sections.filter(ue=>J?J.has(ue.id):!0);if(ge.length===0)continue;const Q={...ee.data.result,sections:ee.data.result.sections.filter(ue=>J?J.has(ue.id):!0)},le={...ae,sections:ge};W.push({addonId:ee.data.addonId,schemaWithValues:Q,schema:le,serverValues:fe})}return W},[C,s]),[T,B]=_(new Map),F=U(J=>{B(W=>{const ee=new Map(W);return ee.set(J.addonId,J),ee})},[]),j=te(new Map),V=U(J=>W=>{W?j.current.set(J,W):j.current.delete(J)},[]),$=U(async(J,W)=>{n==="global"?await p.mutateAsync({addonId:J,nodeId:v,patch:W}):await h.mutateAsync({addonId:J,deviceId:r,nodeId:v,patch:W}),d.invalidateQueries({queryKey:[["addonSettings"]]})},[p,h,v,n,r,d]),H=U(async(J,W,ee,ae)=>{const fe=v;try{switch(W){case"reprobe-engine":await m.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 ge=await u.addons.custom.mutate({addonId:J,action:W,input:ae});return d.invalidateQueries({queryKey:[["addonSettings"]]}),ge}}}catch(ge){throw console.error("[NodeAddonsSettingsPanel] action failed",{addonId:J,action:W,err:ge}),ge}},[m,g,b,v,d,u]),G=U((J,W)=>{$(J,W)},[$]),Z=Gn({mutationFn:async()=>{const J=[];for(const ee of L){const ae=T.get(ee.addonId);!ae||ae.pendingKeys.length===0||J.push({addonId:ee.addonId,patch:ae.pendingValues})}return J.length===0?{saved:[]}:{saved:await Promise.all(J.map(async({addonId:ee,patch:ae})=>(n==="global"?await p.mutateAsync({addonId:ee,nodeId:v,patch:ae}):await h.mutateAsync({addonId:ee,deviceId:r,nodeId:v,patch:ae}),ee)))}},onSuccess:({saved:J})=>{for(const W of J)j.current.get(W)?.discard();d.invalidateQueries({queryKey:[["addonSettings"]]})}}),oe=U(()=>{for(const J of j.current.values())J.discard()},[]),ne=q(()=>{let J=0;for(const W of L){const ee=T.get(W.addonId);ee&&(J+=ee.pendingKeys.length)}return J},[L,T]),X=q(()=>{const J=new Map;for(const W of L){const ee=T.get(W.addonId);if(!ee||ee.pendingKeys.length===0)continue;const ae=new Set(ee.pendingKeys);for(const fe of W.schema.sections){const ge=fe.tab??"general";for(const Q of fe.fields)"key"in Q&&ae.has(Q.key)&&J.set(ge,(J.get(ge)??0)+1)}}return J},[L,T]);if(k)return o("div",{className:"h-24 rounded-lg border border-border bg-surface animate-pulse"});const re=A&&O?P.get(A):void 0;if(!x&&L.length===0)return f("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 be=Z.isPending;return f("div",{className:"space-y-4",children:[(l||c)&&f("div",{className:"border-b border-border pb-2",children:[l&&o("h2",{className:"text-sm font-semibold text-foreground",children:l}),c&&o("p",{className:"text-[11px] text-foreground-subtle mt-0.5",children:c})]}),x&&o(Iv,{tabs:I.map(J=>({id:J,label:z.get(J)??J})),activeId:A,onChange:w,pendingByTab:X}),Z.isError&&f("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(Z.error?.message??Z.error)]}),re?re.content:(()=>{const J=R?L.reduce((ae,fe)=>ae+fe.schemaWithValues.sections.filter(ge=>(ge.tab??"general")===R).length,0):0,W=R!==null&&J<=1,ee=L.map(ae=>({...ae,renderedWithValues:{...ae.schemaWithValues,sections:ae.schemaWithValues.sections.filter(fe=>R?(fe.tab??"general")===R:!0).map(fe=>W?{...fe,title:"",description:void 0}:fe)}})).filter(ae=>ae.renderedWithValues.sections.length>0).sort((ae,fe)=>{const ge=ue=>{let de=Number.POSITIVE_INFINITY;for(const ce of ue)typeof ce.order=="number"&&ce.order<de&&(de=ce.order);return de},Q=ge(ae.renderedWithValues.sections),le=ge(fe.renderedWithValues.sections);return Q!==le?Q-le:0});return ee.length===0?o("div",{className:"text-[11px] text-foreground-subtle italic",children:"Nothing to configure here for this node."}):o(nB,{entries:ee,paneStates:T,displayNames:D,disabled:be,setPaneRef:V,onPaneStateChange:F,onImmediateSave:G,onAction:H,inline:x||!!a})})(),!k&&o(Ev,{pendingCount:ne,onSave:()=>Z.mutate(),onDiscard:oe,saving:be})]})}function nB({entries:e,paneStates:t,displayNames:n,disabled:r,setPaneRef:s,onPaneStateChange:a,onImmediateSave:i,onAction:l,inline:c}){const d=q(()=>[...e].sort((x,y)=>{if(x.addonId==="system-config")return-1;if(y.addonId==="system-config")return 1;const w=n.get(x.addonId)??x.addonId,v=n.get(y.addonId)??y.addonId;return w.localeCompare(v)}),[e,n]),u=d[0]?.addonId??"",[p,h]=_(u);Y(()=>{d.length!==0&&(d.find(x=>x.addonId===p)||h(d[0].addonId))},[d,p]);const m=d.find(x=>x.addonId===p)??d[0];if(!m)return null;const g=q(()=>l?(x,y,w,v)=>l(x,y,w,v):void 0,[l]),b=x=>o(J7,{ref:s(x.addonId),addonId:x.addonId,schema:x.renderedWithValues,serverValues:x.serverValues,onImmediateSave:i,onStateChange:a,onAction:g,disabled:r},x.addonId);return d.length===1||c?o("div",{className:"flex flex-col gap-4",children:d.map(b)}):f("div",{className:"flex flex-col gap-3",children:[o("div",{className:"flex flex-wrap items-center gap-1 border-b border-border shrink-0",children:d.map(x=>{const y=n.get(x.addonId)??x.addonId,w=x.addonId===m.addonId,v=(t.get(x.addonId)?.pendingKeys.length??0)>0;return f("button",{type:"button",onClick:()=>h(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:[y,v&&o("span",{className:"ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400"})]},x.addonId)})}),o("div",{className:"space-y-2",children:d.map(x=>o("div",{style:x.addonId===m.addonId?void 0:{display:"none"},children:b(x)},x.addonId))})]})}const rB=["detection-pipeline","decoder-nodeav","audio-analyzer","pipeline-runner"];function oB({nodeId:e,refreshToken:t}){return f("div",{className:"flex flex-col h-full",children:[o(D7,{nodeId:e,refreshToken:t}),o("div",{className:"flex-1 min-h-0 overflow-y-auto p-6",children:o(to,{nodeId:e,addonIds:rB,level:"global",extraTabs:[{id:"assignments",label:"Assignments",order:-10,content:o(V7,{nodeId:e,refreshToken:t})},{id:"tree",label:"Pipeline",order:39,content:o(Z7,{nodeId:e,refreshToken:t})},{id:"engines",label:"Warm instances",order:180,content:o(q7,{nodeId:e,refreshToken:t})},{id:"models",label:"Models",order:200,content:o(Y7,{nodeId:e,refreshToken:t})}]})})]})}function sB({refreshToken:e}){const t=ke(),n=Bx({onSuccess:()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","getPipelineAssignments"]]}),t.invalidateQueries({queryKey:[["pipelineOrchestrator","getDecoderAssignments"]]}),t.invalidateQueries({queryKey:[["pipelineOrchestrator","getAudioAssignments"]]})}});return f("div",{className:"space-y-6",children:[o(wv,{refreshToken:e}),f("div",{className:"flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between",children:[f("div",{className:"min-w-0",children:[o("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Placement matrix"}),o("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."})]}),f("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:[o(Yd,{className:"h-3.5 w-3.5"}),n.isPending?"Rebalancing…":"Rebalance pipelines"]})]}),o(Sv,{mode:"cluster"})]})}const aB=["pipeline-orchestrator"];function iB({refreshToken:e}){return o("div",{className:"space-y-4 max-w-3xl",children:o(to,{nodeId:"hub",addonIds:aB,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 lB({refreshToken:e}){const t=ke(),{data:n,isLoading:r}=e0(),[s,a]=_(null),[i,l]=_(""),[c,d]=_(""),u=()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","listTemplates"]]})},p=t0({onSuccess:()=>{a(null),u()}}),h=n0({onSuccess:u}),m=y=>{a(y.id),l(y.name),d(y.description??"")},g=()=>{a(null),l(""),d("")},b=()=>{if(!s)return;const y=c.trim();p.mutate({id:s,name:i.trim()||"Untitled",...y?{description:y}:{}})};if(r)return o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading templates…"});const x=[...n??[]].sort((y,w)=>y.name.localeCompare(w.name));return o("div",{className:"space-y-6 max-w-4xl",children:f("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("div",{className:"border-b border-border px-4 py-3 flex items-center justify-between",children:[f("div",{children:[o("h3",{className:"text-sm font-semibold text-foreground",children:"Templates"}),o("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."})]}),f("div",{className:"text-[11px] text-foreground-subtle",children:[x.length," template",x.length===1?"":"s"]})]}),x.length===0?f("div",{className:"px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2",children:[o(ct,{className:"h-6 w-6 opacity-40"}),o("div",{children:'No templates yet. Create one from a device Pipeline tab ("Save as template").'})]}):o("ul",{className:"divide-y divide-border",children:x.map(y=>{const w=s===y.id;return o("li",{className:"px-4 py-3 text-xs",children:f("div",{className:"flex items-start gap-3",children:[o("div",{className:"flex-1 min-w-0",children:w?f("div",{className:"space-y-2",children:[o("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:v=>l(v.target.value),placeholder:"Template name",autoFocus:!0}),o("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:v=>d(v.target.value),placeholder:"Description (optional)"})]}):f(he,{children:[o("div",{className:"font-medium text-foreground",children:y.name}),y.description&&o("div",{className:"text-foreground-subtle mt-0.5",children:y.description}),f("div",{className:"mt-1 font-mono text-[10px] text-foreground-subtle",children:["engine ",y.config.engine.runtime,"/",y.config.engine.backend," · ",y.config.steps.length," step(s)",y.config.audio?.enabled?" · audio":"",f("span",{className:"ml-2",children:["updated ",new Date(y.updatedAt).toLocaleString()]})]})]})}),o("div",{className:"flex items-center gap-1 shrink-0",children:w?f(he,{children:[f("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:[o(_t,{className:"h-3 w-3"}),"Save"]}),f("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:[o(Fe,{className:"h-3 w-3"}),"Cancel"]})]}):f(he,{children:[o("button",{type:"button",onClick:()=>m(y),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:o(eo,{className:"h-3 w-3"})}),o("button",{type:"button",onClick:()=>{confirm(`Delete template "${y.name}"?`)&&h.mutate({id:y.id})},disabled:h.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:o(Ze,{className:"h-3 w-3"})})]})})]})},y.id)})})]})})}function Nf(e,t){if(!e)return null;for(const n of e.slots)for(const r of n.addons)if(r.id===t)return r;return null}function cB({nodeId:e,refreshToken:t}){const n=ke(),r=Le().trpcClient,[s,a]=_(null),[i,l]=_(null),c=Yr(void 0,{refetchOnMount:"always"});Ct(["nodes","topology"],["agent.online","agent.offline","agent.unregistered","addon.installed","addon.uninstalled","addon.updated"]);const d=Bn(void 0,{staleTime:3e4,refetchOnMount:"always"}),u=q(()=>{const I=new Set;for(const z of d.data??[])z.isOnline&&I.add(z.id);return I},[d.data]),p=Yo({nodeId:e},{refetchOnMount:"always"}),h=q(()=>(c.data??[]).filter(I=>u.has(I.nodeId)).map(I=>I.nodeId),[c.data,u]),m=Ln({enabled:h.length>0,queryKey:[["pipelineExecutor","getSchema"],"schema-by-agent",h.join(","),t],queryFn:async()=>{const I={};for(const z of h)try{const A=await r.pipelineExecutor.getSchema.query({nodeId:z});I[z]=A.selectedEngine.format}catch{I[z]="coreml"}return I}}),g=hd({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator"]]}),n.invalidateQueries({queryKey:[["pipelineExecutor"]]}),n.invalidateQueries({queryKey:[["addonSettings"]]})}}),b=q(()=>p.data?Da(p.data):[],[p.data]),x=q(()=>{const I=c.data??[],z=u;return(z.size===0?[]:I.filter(O=>z.has(O.nodeId))).map(O=>{const R=m.data?.[O.nodeId];return{agentNodeId:O.nodeId,engineLabel:R??"(engine unknown)"}})},[c.data,m.data,u]),y=(I,z)=>{const O=c.data?.find(L=>L.nodeId===z)?.settings.addonDefaults[I],R=m.data?.[z];return Nf(p.data??null,I)?.models.some(L=>R!==void 0&&!!L.formats[R])?O?O.enabled?{kind:"enabled",modelId:O.modelId}:{kind:"disabled"}:{kind:"na"}:{kind:"na"}},w=s?c.data?.find(I=>I.nodeId===s.agentNodeId)??null:null,v=s&&p.data?Nf(p.data,s.addonId):null,N=s?m.data?.[s.agentNodeId]??"coreml":"coreml",k=()=>{a(null),l(null)},C=(I,z)=>{const O=c.data?.find(R=>R.nodeId===z)?.settings.addonDefaults[I]??null;a({addonId:I,agentNodeId:z}),l(O)},M=()=>{!i||!s||!w||g.mutate({agentNodeId:s.agentNodeId,defaults:{...w.settings.addonDefaults,[s.addonId]:i}},{onSuccess:k})};if(c.isLoading||p.isLoading)return o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading agents…"});if(!p.data)return f("div",{className:"text-xs text-foreground-subtle",children:["Catalog unavailable for ",e,"."]});const P=s!==null&&v!==null&&i!==null;return f("div",{className:"relative h-full w-full space-y-3",children:[o(Mv,{title:"Cluster cameras"}),o("div",{className:P?"pr-[360px]":"",children:b.length>0&&x.length>0?o(Uc,{tree:b,agents:x,getCellState:y,onCellClick:C,selectedCell:s}):o("div",{className:"text-xs text-foreground-subtle",children:"No agents or catalog empty."})}),o(qc,{open:P,onClose:k,title:v?.name??"",subtitle:s?`${s.agentNodeId} · ${N}`:"",footer:f(he,{children:[o("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:k,children:"Cancel"}),o("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:v&&i&&s&&o(Ta,{mode:"agent",addon:v,agentDefault:i,agentNodeId:s.agentNodeId,engineFormat:N,onChangeAgentConfig:I=>l(I)})})]})}const dB=[{id:"assignments",label:"Assignments"},{id:"pipeline",label:"Pipeline"},{id:"settings",label:"Settings"},{id:"templates",label:"Templates"}];function uB({refreshToken:e}){const[t,n]=_("assignments"),{data:r}=Bn(void 0,{staleTime:3e4}),s=r?.find(a=>a.isHub&&a.isOnline)?.id??r?.find(a=>a.isOnline)?.id??null;return f("div",{className:"flex flex-col h-full",children:[f("div",{className:"px-6 py-4 border-b border-border",children:[o("h2",{className:"text-base font-semibold text-foreground",children:"Cluster Orchestration"}),o("div",{className:"text-[11px] text-foreground-subtle mt-1",children:"Assignments with live load, cluster-wide settings, pipeline template library, per-camera pipeline overrides."})]}),o("div",{className:"flex items-center gap-1 px-6 border-b border-border",children:dB.map(a=>o("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))}),f("div",{className:"flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab",children:[t==="assignments"&&o(sB,{refreshToken:e}),t==="pipeline"&&(s?o(cB,{nodeId:s,refreshToken:e}):o("div",{className:"text-xs text-foreground-subtle",children:"No online node available — schema unreachable."})),t==="settings"&&o(iB,{refreshToken:e}),t==="templates"&&o(lB,{refreshToken:e})]})]})}const No="__cluster__";function pB(){const[e,t]=Ka(),n=e.get("node")??No,[r,s]=_(0);return Y(()=>{e.get("node")||t({node:No},{replace:!0})},[e,t]),f("div",{className:"flex flex-col h-full overflow-hidden",children:[o("div",{className:"flex items-center justify-end gap-4 px-4 py-3 border-b border-border shrink-0",children:f("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:[o(dt,{className:"h-3.5 w-3.5"}),"Refresh"]})}),f("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden min-h-0",children:[o("aside",{className:"w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border overflow-y-auto",children:o($7,{selectedNodeId:n,onSelect:i=>{t({node:i},{replace:!0})},refreshToken:r})}),o("section",{className:"flex-1 min-h-0 overflow-hidden",children:n===No?o(uB,{refreshToken:r}):o(oB,{nodeId:n,refreshToken:r})})]})]})}const fB="device-export",rl="export",hB="Export";function rc(e){return e.type==="separator"||e.type==="info"||e.type==="object-array"||e.type==="widget"||e.type==="addon-action-button"?!1:e.type==="group"?e.fields.some(rc):e.type==="sub-tabs"?e.tabs.some(t=>t.fields.some(rc)):e.writerCapName===fB}function Lo(e){return e.fields.some(rc)}function mB(e){const[t,n]=_("idle"),[r,s]=_(null),a=te(null),i=te(null),l=te(null),c=te(!0),d=ax(),u=ix(),p=lx(),h=U(()=>{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},[]),m=U(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((y,w)=>setTimeout(()=>w(new Error("server stopSession timeout")),2e3))])}catch(y){console.warn("[intercom] server stopSession failed (continuing teardown)",y)}h(),c.current&&(n("idle"),s(null))},[t,e,p,h]),g=U(async()=>{if(e===null||t!=="idle"&&t!=="error")return;s(null);let b=null,x=null,y=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});y=w.sessionId,l.current=y,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),m())};for(const k of b.getAudioTracks())x.addTrack(k,b);await x.setRemoteDescription({type:"offer",sdp:w.sdpOffer});const v=await x.createAnswer();await x.setLocalDescription(v);const N=x.localDescription?.sdp??v.sdp??"";await u.mutateAsync({deviceId:e,sessionId:y,sdpAnswer:N})}catch(w){const v=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,y!==null)try{await p.mutateAsync({deviceId:e,sessionId:y})}catch{}l.current=null,c.current&&(s(v),n("error"))}},[e,t,d,u,p,m]);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:r,start:g,stop:m,isTalking:t==="talking"}}let gB=0;function pt(){return++gB}function ol(e){switch(e.type){case"system":return"system";case"device":return`#${e.deviceId}`;case"provider":return e.providerId;case"addon":return e.addonId}}function bB(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 xB(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 yB(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 vB({scope:e,greeting:t,className:n}){const r=Le(),[s,a]=_(()=>{const v=[];return t&&v.push({id:pt(),kind:"info",text:t}),v.push({id:pt(),kind:"info",text:`scope: ${ol(e)} — type help or context for available commands`}),v}),[i,l]=_(""),[c,d]=_([]),[u,p]=_(-1),h=te(null),m=te(null);Y(()=>{const v=m.current;v&&(v.scrollTop=v.scrollHeight)},[s]);const g=U(()=>{h.current?.focus()},[]),b=Gn({mutationFn:v=>r.trpcClient.repl.execute.mutate({code:v,scope:e}),onSuccess:v=>{const N=v??{},k=typeof N.output=="string"?N.output:v==null?"undefined":typeof v=="string"?v:JSON.stringify(v,null,2),C=N.type==="error";a(M=>[...M,{id:pt(),kind:C?"error":"result",text:k}])},onError:v=>{const N=v instanceof Error?v.message:String(v);a(k=>[...k,{id:pt(),kind:"error",text:N}])}});function x(v){const N=v.trim();if(N){if(N==="clear"){a([{id:pt(),kind:"info",text:`scope: ${ol(e)}`}]),l("");return}if(N==="help"){a(k=>[...k,{id:pt(),kind:"input",text:`> ${N}`},...bB(e).map(C=>({id:pt(),kind:"info",text:C}))]),l("");return}if(N==="context"){a(k=>[...k,{id:pt(),kind:"input",text:`> ${N}`},...yB(e).map(C=>({id:pt(),kind:"info",text:C}))]),l("");return}if(N==="examples"){a(k=>[...k,{id:pt(),kind:"input",text:`> ${N}`},...xB(e).map(C=>({id:pt(),kind:"info",text:C}))]),l("");return}d(k=>[...k,N]),p(-1),a(k=>[...k,{id:pt(),kind:"input",text:`> ${N}`}]),l(""),b.mutate(N)}}function y(v){if(v.key==="Enter"){v.preventDefault(),x(i);return}if(v.key==="ArrowUp"){if(v.preventDefault(),c.length===0)return;const N=u===-1?c.length-1:Math.max(0,u-1);p(N),l(c[N]??"");return}if(v.key==="ArrowDown"){if(v.preventDefault(),u===-1)return;const N=u+1;N>=c.length?(p(-1),l("")):(p(N),l(c[N]??""));return}v.ctrlKey&&v.key==="l"&&(v.preventDefault(),a([{id:pt(),kind:"info",text:`scope: ${ol(e)}`}]))}const w={input:"text-zinc-300",result:"text-emerald-300",error:"text-red-300",info:"text-zinc-400"};return f("div",{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${n??""}`,onClick:g,children:[f("div",{ref:m,className:"flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]",children:[s.map(v=>o("pre",{className:`whitespace-pre-wrap break-words leading-relaxed ${w[v.kind]}`,children:v.text},v.id)),b.isPending&&o("span",{className:"text-zinc-500 animate-pulse",children:"…thinking"})]}),f("div",{className:"flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]",children:[o("span",{className:"text-emerald-400 flex-shrink-0 select-none font-bold",children:">"}),o("input",{ref:h,value:i,onChange:v=>l(v.target.value),onKeyDown:y,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 wB(e){const t=ke(),n=e!==null&&Number.isFinite(e),r=o0({deviceId:e??0},{enabled:n,refetchInterval:5e3,retry:1}),s=s0({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),a=a0({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),i=U(async d=>{e!==null&&await s.mutateAsync({deviceId:e,enabled:d})},[e,s]),l=U(async d=>{e!==null&&await a.mutateAsync({deviceId:e,settings:d})},[e,a]),c=r.error?r.error.message:s.error?s.error.message:a.error?a.error.message:null;return{status:r.data??null,isLoading:r.isLoading,isPending:s.isPending||a.isPending,error:c,setEnabled:i,setSettings:l}}function NB({deviceId:e}){const{status:t,isLoading:n,isPending:r,error:s,setEnabled:a,setSettings:i}=wB(Number.isFinite(e)?e:null),[l,c]=_({targetType:"",stopDelaySeconds:30,disappearDelaySeconds:15}),[d,u]=_(!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?f("div",{className:"flex items-center gap-2 px-3 py-2 text-[10.5px] text-foreground-subtle",children:[o(Se,{className:"h-3 w-3 animate-spin"}),"Loading autotrack…"]}):f("div",{className:"border-t border-border/40 mt-2 pt-2 px-1 space-y-2",children:[f("div",{className:"flex items-center justify-between px-2",children:[f("div",{className:"flex items-center gap-1.5 text-[10.5px] font-semibold text-foreground",children:[o(n6,{className:"h-3 w-3 text-primary"}),"Autotracking"]}),f("button",{type:"button",onClick:()=>{a(!(t?.enabled??!1))},disabled:r,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:[o("span",{className:`h-1.5 w-1.5 rounded-full ${t?.enabled?"bg-success":"bg-foreground-subtle/40"}`}),t?.enabled?"Enabled":"Disabled"]})]}),s&&f("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:[o(nr,{className:"h-3 w-3 flex-shrink-0 mt-0.5"}),o("span",{className:"leading-snug break-words",children:s})]}),f("div",{className:"grid grid-cols-2 gap-2 px-2",children:[(t?.supportedTargetTypes?.length??0)>0&&f("label",{className:"col-span-2 flex flex-col gap-1",children:[o("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Target type"}),o("select",{value:l.targetType,onFocus:()=>u(!0),onChange:p=>c(h=>({...h,targetType:p.target.value})),onBlur:()=>{u(!1);const p=t?.currentSettings?.targetType??"";l.targetType!==p&&i({targetType:l.targetType})},disabled:r,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=>o("option",{value:p.value,children:p.label},p.value))})]}),f("label",{className:"flex flex-col gap-1",children:[o("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Stop delay (s)"}),o("input",{type:"number",min:0,max:300,value:l.stopDelaySeconds,onFocus:()=>u(!0),onChange:p=>c(h=>({...h,stopDelaySeconds:Number(p.target.value)||0})),onBlur:()=>{u(!1);const p=t?.currentSettings?.stopDelaySeconds??30;l.stopDelaySeconds!==p&&i({stopDelaySeconds:l.stopDelaySeconds})},disabled:r,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"})]}),f("label",{className:"flex flex-col gap-1",children:[o("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Disappear delay (s)"}),o("input",{type:"number",min:0,max:300,value:l.disappearDelaySeconds,onFocus:()=>u(!0),onChange:p=>c(h=>({...h,disappearDelaySeconds:Number(p.target.value)||0})),onBlur:()=>{u(!1);const p=t?.currentSettings?.disappearDelaySeconds??15;l.disappearDelaySeconds!==p&&i({disappearDelaySeconds:l.disappearDelaySeconds})},disabled:r,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"})]})]}),o("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 kB({deviceId:e,intercomAvailable:t=!1}){const n=Le(),r=typeof window<"u"?window.location.origin:"",s=Number.isFinite(e),a=ov(s?e:null),{streams:i,pipelineMetrics:l,createSession:c,sendAnswer:d,closeSession:u}=_d(n.trpcClient,s?e:null),p=Yc(n.trpcClient,s?e:null),h=mB(s&&t?e:null),m=h.state==="requesting-mic"||h.state==="starting"||h.state==="connecting"||h.state==="stopping",g=h.isTalking||m,b=()=>{h.state==="idle"||h.state==="error"?h.start():h.state!=="stopping"&&h.stop()},x=W0(),y=x.length>0?o(he,{children:x.map(w=>o("div",{className:"absolute inset-0",children:w.node},w.id))}):null;return o(kd,{serverUrl:r,createSession:c,sendAnswer:d,closeSession:u,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:y,chromeless:!0,className:"h-full"})}function SB({deviceId:e}){return Number.isFinite(e)?o("div",{className:"flex flex-col h-full",children:o(Ht,{deviceId:e,limit:50,maxHeight:"max-h-full",showScope:!1,showFilters:!1})}):f("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function CB({deviceId:e}){if(!Number.isFinite(e))return f("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(`
|
|
1142
|
+
`);return o(vB,{scope:{type:"device",deviceId:e},greeting:t,className:"h-full border-0 rounded-none"})}function MB({deviceId:e}){const t=Le(),n=Number.isFinite(e),r=$d(t.trpcClient,n?e:0,{enabled:n}),{data:s}=L7(n?e:0);if(!n)return f("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(Kn.PtzAutotrack);return f("div",{className:"flex flex-col h-full overflow-y-auto",children:[o(Ed,{controls:r,mode:"panel"}),a&&o(NB,{deviceId:e})]})}function EB({deviceId:e}){return Number.isFinite(e)?o("div",{className:"flex flex-col h-full overflow-y-auto",children:o(br,{deviceId:e,limit:50,maxHeight:"max-h-full"})}):f("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function IB({deviceId:e}){return Number.isFinite(e)?o("div",{className:"flex flex-col h-full overflow-y-auto",children:o(Cd,{deviceId:e,limit:50,maxHeight:"max-h-full"})}):f("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function AB({parentDeviceId:e}){const{t}=qt(),n=ot(),r=Le(),{data:s,isLoading:a,isError:i}=kv(e);if(a)return o("div",{className:"rounded-lg border border-border bg-surface p-3",children:o("p",{className:"text-[10px] text-foreground-subtle",children:t("common.loading",{defaultValue:"Loading…"})})});if(i)return o("div",{className:"rounded-lg border border-border bg-surface p-3",children:o("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),u=c&&!d?t("device.accessories",{defaultValue:"Accessories"}):!c&&d?t("device.adoptedDevices",{defaultValue:"Adopted devices"}):t("device.children",{defaultValue:"Children"});return f("div",{className:"rounded-lg border border-border bg-surface p-3",children:[o("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5",children:u}),o("div",{className:"space-y-1",children:l.map(p=>o(Io,{trpc:r.trpcClient,device:p,variant:"minimal",onNavigate:h=>n(`/devices/${String(h)}`)},p.id))})]})}function sl(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function PB({device:e}){const t=ot(),n=typeof e.id=="number"?e.id:null,r=String(e.type??""),s=r===ft.Camera,a=r===ft.Hub,i=e.features??[],{data:l}=pd({deviceId:n??0},{enabled:n!==null&&s,refetchInterval:5e3}),c=l?.streams??{},d=Object.entries(c),u=i.includes(Kn.DoorbellButton),p=Dd(u?{deviceId:n??void 0,historyLimit:10}:void 0),h=p.latest?Date.now()-p.latest.timestamp<3e4:!1;return f("div",{className:"space-y-5",children:[a&&n!==null&&o(hy,{deviceId:n,onOpenChild:m=>t(`/devices/${m}`)}),s&&n!==null&&o(ht,{widgetId:"pipeline-orchestrator/pipeline-quick-stats",host:"device-tab",deviceId:n}),u&&o(Id,{history:p.history,latestIsFresh:h}),s&&n!==null&&o(ht,{widgetId:"stream-broker/stream-broker-panel",host:"device-tab",deviceId:n}),s&&d.length>0&&f("div",{className:"@container rounded-lg border border-border bg-surface overflow-hidden",style:{containerType:"inline-size"},children:[o("div",{className:"border-b border-border px-4 py-2",children:o("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:"Stream Network"})}),o("div",{className:"divide-y divide-border",children:d.map(([m,g])=>f("div",{className:"px-4 py-2.5",children:[f("div",{className:"flex items-center gap-2 mb-2",children:[o(or,{className:"h-3 w-3 text-foreground-subtle"}),o("span",{className:"text-[11px] font-medium text-foreground",children:m})]}),f("div",{className:"grid grid-cols-2 @[640px]:grid-cols-4 gap-2",children:[o(Ms,{label:"Nominal",value:sl(g.nominalBitrateKbps??0)}),o(Ms,{label:"Observed",value:sl(g.observedBitrateKbps??0)}),o(Ms,{label:"Peak",value:sl(g.peakBitrateKbps??0)}),o(Ms,{label:"Packet Loss",value:`${(g.packetLossPercent??0).toFixed(2)}%`,warning:(g.packetLossPercent??0)>1})]})]},m))})]}),o(av,{})]})}function Ms({label:e,value:t,warning:n}){return f("div",{children:[o("p",{className:"text-[10px] text-foreground-subtle",children:e}),o("p",{className:`text-xs font-medium ${n?"text-warning":"text-foreground"}`,children:t})]})}function _B({schema:e,values:t,pendingKeys:n,onChange:r,onAction:s,onSave:a,onDiscard:i,disabled:l}){const c=e.tabs??[],d=q(()=>{const k=new Map;for(const C of e.sections){const M=C.tab??"general",P=k.get(M)??[];P.push(C),k.set(M,P)}return k},[e.sections]),u=new Set(c.map(k=>k.id)),p=[...c,...[...d.keys()].filter(k=>!u.has(k)).map(k=>({id:k,label:k,icon:"wrench",order:100}))],h=p[0]?.id??"general",[m,g]=_(h),b=d.get(m)??[],y={sections:b.length<=1?b.length===1?[{...b[0],title:""}]:b:b.every(C=>!C.title)?[{...b[0],title:"",fields:b.flatMap(C=>C.fields)}]:b},w=o(Ev,{pendingCount:n.length,onSave:()=>a(n),onDiscard:()=>i(n),saving:l});if(p.length<=1)return f("div",{className:"flex flex-col gap-3",children:[o($n,{schema:e,values:t,onChange:r,onAction:s,disabled:l}),w]});const v=new Map,N=new Map;for(const[k,C]of d){v.set(k,C.length);const M=new Set,P=z=>{for(const A of z)if("key"in A&&typeof A.key=="string"&&M.add(A.key),A.type==="group")P(A.fields);else if(A.type==="sub-tabs")for(const O of A.tabs)P(O.fields)};for(const z of C)P(z.fields);const I=n.filter(z=>M.has(z)).length;I>0&&N.set(k,I)}return f("div",{className:"flex flex-col gap-3",children:[o(Iv,{tabs:p.map(k=>({id:k.id,label:k.label})),activeId:m,onChange:g,countByTab:v,pendingByTab:N}),o($n,{schema:y,values:t,onChange:r,onAction:s,disabled:l}),w]})}function $B(e,t){return t&&t==="admin"?e:!0}function DB(e){if(!e)return null;const n={sections:[...e.sections].sort((r,s)=>{const a=r.tab??"general",i=s.tab??"general";return a!==i?a.localeCompare(i):Lo(r)&&Lo(s)?r.id.localeCompare(s.id):(r.order??0)-(s.order??0)})};return e.tabs?{...n,tabs:e.tabs}:n}function _v(e){return e.type==="separator"||e.type==="info"||e.type==="button"||e.type==="widget"||e.type==="addon-action-button"}function $v(e){return e.key}function LB(e){if(!_v(e))return e.value}function Dv(e){return _v(e)?null:e}function ua(e,t){for(const n of e)if(t(n),n.type==="group")ua(n.fields,t);else if(n.type==="sub-tabs")for(const r of n.tabs)ua(r.fields,t)}function TB(e){if(!e)return{};const t={};for(const n of e.sections)ua(n.fields,r=>{const s=$v(r);s!==null&&(t[s]=LB(r))});return t}function kf(e,t){if(!e)return null;let n=null;for(const r of e.sections)if(ua(r.fields,s=>{if(n!==null||$v(s)!==t)return;const a=Dv(s);a&&a.writerCapName&&a.writerAddonId&&(n={capName:a.writerCapName,addonId:a.writerAddonId})}),n!==null)break;return n}function RB(e){return{...e,fields:e.fields.map(Lv)}}function Lv(e){return e.type==="separator"||e.type==="info"||e.type==="button"||e.type==="object-array"?e:{...e,readonlyField:!0}}function OB(e,t){return e&&{...e,sections:e.sections.map(n=>({...n,fields:n.fields.map(r=>{const s=Dv(r);return s?$B(t,s.minRole)?r:Lv(r):r})}))}}function oc({deviceId:e,sectionFilter:t}){const n=ke(),{user:r}=rn(),s=r?.isAdmin===!0,a=te(!1),{data:i,isLoading:l}=ld({deviceId:e},{refetchInterval:()=>a.current?!1:2500,staleTime:6e4,enabled:Number.isFinite(e)}),{data:c}=Jn({deviceId:e},{staleTime:6e4,enabled:Number.isFinite(e)}),d=i?.settings??null,u=i?.live??null,p=q(()=>{if(!d&&!u)return null;const O=d?.sections??[],R=(u?.sections??[]).map(RB),E=[...O,...R],D=t?E.filter(t):E.filter(F=>F.location!=="top-tab"&&!Lo(F));if(D.length===0)return null;const L=new Set;for(const F of D)L.add(F.tab??"general");const B=[...d?.tabs??[],...(u?.tabs??[]).filter(F=>!(d?.tabs??[]).some(j=>j.id===F.id))].filter(F=>L.has(F.id));return B.length>0?{tabs:B,sections:D}:{sections:D}},[d,u,t]),h=q(()=>DB(p),[p]),m=q(()=>OB(h,s),[h,s]),g=q(()=>TB(m),[m]),b=v0(),x=dd(),y=Wb({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]})}}),w={isPending:y.isPending,mutate:O=>{y.mutate({deviceId:e,changes:[...O]})}},v=U(O=>{const R=Object.entries(O).map(([E,D])=>{const L=kf(m,E);return L?{writerCapName:L.capName,writerAddonId:L.addonId,key:E,value:D}:null}).filter(E=>E!==null);R.length>0&&w.mutate(R)},[m,w]),N=U(O=>{const R=Object.entries(O).map(([E,D])=>{const L=kf(m,E);return L?{writerCapName:L.capName,writerAddonId:L.addonId,key:E,value:D}:null}).filter(E=>E!==null);R.length>0&&w.mutate(R)},[m,w]),k=Av({schema:m,serverValues:g,onImmediateSave:v,onDeferredSave:N}),{values:C,pendingKeys:M,handleChange:P,handleSave:I,handleDiscard:z}=k;if(a.current=k.editingPaused,l)return f("div",{className:"flex items-center justify-center py-12 text-foreground-subtle",children:[o(Se,{className:"h-4 w-4 animate-spin mr-2"}),o("span",{className:"text-xs",children:"Loading device aggregate…"})]});if(!m||m.sections.length===0)return o("div",{className:"text-xs text-foreground-subtle italic py-4 text-center",children:"No aggregate contributions for this device."});async function A(O,R,E){if(O==="regenerate-rtsp-token"){const D=["rtspUrl:","regenerateToken:"].find(B=>R.startsWith(B));if(!D)throw new Error(`regenerate-rtsp-token: unrecognised key "${R}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);const L=R.slice(D.length);if(!L)throw new Error(`regenerate-rtsp-token: key "${R}" has no streamId after prefix`);const T=`${e}/${L}`;await b.mutateAsync({brokerId:T}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]});return}if(O==="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:R,value:E})}catch(D){return{status:"error",error:D instanceof Error?D.message:String(D)}}}if(O==="refresh-driver-data"){await y.mutateAsync({deviceId:e,changes:[{writerCapName:"device-manager",writerAddonId:"device-manager",key:R,value:Date.now()}]});return}throw new Error(`[device-aggregate] unknown action "${O}"`)}return o(_B,{schema:m,values:C,pendingKeys:M,onChange:P,onAction:A,onSave:I,onDiscard:z,disabled:w.isPending})}function BB({deviceId:e}){return o(oc,{deviceId:e})}const Tv=6e4,sc=60*Tv,Sf=24*sc;function ri(e){if(e==null||e<=0)return"—";const t=Date.now()-e;return t<0||t<3e4?"just now":t<sc?`${String(Math.floor(t/Tv))}m ago`:t<Sf?`${String(Math.floor(t/sc))}h ago`:`${String(Math.floor(t/Sf))}d ago`}function zB(e,t=new Date){const n=new Date(e);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()}function Rv({dev:e,busy:t,setBusy:n}){const r=e?.motionTrigger,s=pn(e?.state.motionTrigger),[a,i]=_(!1);if(!r)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 r.setMotionTrigger({enabled:p})}finally{n(!1),i(!1)}};return f("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:[o(Jo,{className:"h-3 w-3"}),o("span",{children:a?l?"Disabling…":"Enabling…":c?l?"On motion: on":"On motion: off":"On motion: …"})]})}function Ov({deviceId:e,deviceName:t,useSiren:n=!1}){const r=Le(),s=At(r.trpcClient,e),a=pn(s?.state.switch),[i,l]=_(!1),c=a?.on??!1,d=a?.lastChangedAt??null,u=a!==void 0,p=n?es:Zy,h=async()=>{if(!(i||!u||!s?.switch)){l(!0);try{await s.switch.setState({on:!c})}finally{l(!1)}}};return f("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[o("button",{type:"button",onClick:()=>{h()},disabled:i||!u||!s?.switch,title:u?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:o(p,{className:"h-10 w-10"})}),o(Rv,{dev:s,busy:i,setBusy:l}),f("div",{className:"text-center",children:[o("div",{className:`text-sm font-semibold ${c?"text-success":"text-foreground-subtle"}`,children:u?c?"On":"Off":"Unknown"}),o("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:u?`Changed ${ri(d)}`:"Awaiting state…"})]})]})}function FB({deviceId:e,deviceName:t}){const n=Le(),r=At(n.trpcClient,e),s=pn(r?.state.switch),a=pn(r?.state.brightness),i=s?.on??!1,l=s?.lastChangedAt??null,c=s!==void 0,d=a!==void 0,u=r?.brightness!==void 0,[p,h]=_(!1),[m,g]=_(a?.percentage??0);Y(()=>{a?.percentage!==void 0&&g(a.percentage)},[a?.percentage]);const b=async()=>{if(!(p||!c||!r?.switch)){h(!0);try{await r.switch.setState({on:!i})}finally{h(!1)}}},x=async()=>{if(!(p||!d||!r?.brightness)){h(!0);try{await r.brightness.setBrightness({percentage:m})}finally{h(!1)}}};return f("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[o("button",{type:"button",onClick:()=>{b()},disabled:p||!c||!r?.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:o(P6,{className:"h-9 w-9"})}),u?f("div",{className:"flex w-full max-w-xs flex-col items-center gap-1",children:[o("input",{type:"range",min:0,max:100,step:1,value:m,disabled:p||!i||!d,onChange:y=>g(Number(y.currentTarget.value)),onPointerUp:()=>{x()},onKeyUp:y=>{y.key==="Enter"&&x()},"aria-label":"Brightness",className:"w-full accent-warning disabled:cursor-not-allowed disabled:opacity-50"}),o("div",{className:"text-[10px] text-foreground-subtle tabular-nums",children:d?`${String(m)}%`:"Brightness unavailable"})]}):null,o(Rv,{dev:r,busy:p,setBusy:h}),f("div",{className:"text-center",children:[o("div",{className:`text-sm font-semibold ${i?"text-warning":"text-foreground-subtle"}`,children:c?i?"On":"Off":"Unknown"}),o("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:c?`Changed ${ri(l)}`:"Awaiting state…"})]})]})}function jB({deviceId:e}){const t=Le(),n=At(t.trpcClient,e),r=pn(n?.state.motion),s=r?.detected??!1,a=r?.lastDetectedAt??null,i=r!==void 0;return f("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[o("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?o(cO,{className:"h-10 w-10"}):o(Jo,{className:"h-10 w-10"})}),f("div",{className:"text-center",children:[o("div",{className:`text-sm font-semibold ${s?"text-danger":"text-foreground-subtle"}`,children:i?s?"Triggered":"Idle":"Unknown"}),o("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:i?`Last trip ${ri(a)}`:"Awaiting state…"})]})]})}function VB({deviceId:e}){const t=Le(),n=At(t.trpcClient,e),r=pn(n?.state.doorbell),s=r?.lastPressedAt??null,a=r!==void 0,i=s!==null&&Date.now()-s<6e4,[l,c]=_(0),[d,u]=_(null);return Y(()=>{s===null||s===d||(u(s),zB(s)&&c(p=>p+1))},[s,d]),f("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[o("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:o(es,{className:"h-10 w-10"})}),f("div",{className:"text-center",children:[o("div",{className:`text-sm font-semibold ${i?"text-primary":"text-foreground-subtle"}`,children:a?`Last press ${ri(s)}`:"Unknown"}),o("div",{className:"text-[10px] text-foreground-subtle mt-0.5 tabular-nums",children:a?`${String(l)} ring${l===1?"":"s"} today`:"Awaiting state…"})]})]})}function HB({deviceName:e,deviceType:t,provider:n,isOnline:r,features:s}){return f("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:[o(bn,{type:n,size:"lg"}),f("div",{children:[o("div",{className:"text-sm font-semibold text-foreground",children:e}),o("div",{className:"text-[10px] text-foreground-subtle uppercase tracking-wider mt-0.5",children:t})]}),f("div",{className:"flex items-center gap-2 flex-wrap justify-center",children:[o(ni,{status:r?"online":"offline"}),s.length>0&&o(ei,{capabilities:s})]}),o("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 qB({deviceId:e}){const t=ke(),n=Tb({deviceId:e},{refetchInterval:1e4,retry:!1}),r=Rb({onSuccess:()=>{t.invalidateQueries({queryKey:[["deviceDiscovery","listDiscovered"]]}),t.invalidateQueries({queryKey:[["deviceDiscovery","getStatus"]]})}}),s=q(()=>UB(n.data??[]),[n.data]);return f("div",{className:"flex h-full w-full flex-col gap-3 p-3 sm:p-4",children:[f("div",{className:"flex flex-wrap items-stretch gap-2 sm:gap-3",children:[o(al,{label:"Discovered",value:s.total,icon:o(_n,{className:"h-3.5 w-3.5"})}),o(al,{label:"Adopted",value:s.adopted,accent:"success"}),o(al,{label:"Available",value:s.available,accent:s.available>0?"primary":void 0}),f("button",{type:"button",onClick:()=>{r.mutateAsync({deviceId:e}).catch(()=>{})},disabled:r.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:[r.isPending?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(dt,{className:"h-3.5 w-3.5"}),o("span",{className:"hidden sm:inline",children:"Discover"})]})]}),f("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:[o(Es,{icon:o(or,{className:"h-3 w-3 text-emerald-500"}),label:`${s.online} online`}),o(Es,{icon:o(Ky,{className:"h-3 w-3 text-amber-500"}),label:`${s.sleeping} sleeping`}),o(Es,{icon:o(rv,{className:"h-3 w-3 text-destructive"}),label:`${s.offline} offline`}),s.unknown>0?o(Es,{icon:o(YR,{className:"h-3 w-3 text-foreground-subtle"}),label:`${s.unknown} unknown`}):null]})]})}function UB(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 al({label:e,value:t,icon:n,accent:r}){return f("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 ${r==="success"?"bg-emerald-500/10 border-emerald-500/30 text-emerald-500":r==="primary"?"bg-primary/10 border-primary/30 text-primary":"bg-surface-hover border-border text-foreground"}`,children:[f("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider opacity-70 truncate",children:[n,o("span",{className:"truncate",children:e})]}),o("div",{className:"text-xl sm:text-2xl font-semibold tabular-nums leading-none",children:t})]})}function Es({icon:e,label:t}){return f("span",{className:"inline-flex items-center gap-1",children:[e,o("span",{children:t})]})}const QB=e=>o(Ov,{...e,useSiren:!0}),GB={[ft.Switch]:Ov,[ft.Siren]:QB,[ft.Light]:FB,[ft.Sensor]:jB,[ft.Button]:VB,[ft.Hub]:qB};function KB(e){const t=GB[e.deviceType]??HB;return o(t,{...e})}function Zd(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 r=Math.floor(t/60),s=t%60;return s>0?`${r}h ${s}m`:`${r}h`}function pa(e){return new Date(e).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function fa(e){return e.toISOString().slice(0,10)}function WB(e,t){return fa(e)===fa(t)}function fo(e){const t=new Date(e);return t.setHours(0,0,0,0),t}function YB(e){const t=new Date(e);return t.setHours(23,59,59,999),t}function Lt({className:e=""}){return o("div",{className:`animate-pulse rounded bg-foreground-subtle/10 ${e}`})}function qn(){return f("div",{className:"flex items-center gap-3 px-4 py-3",children:[o(Lt,{className:"h-4 w-4"}),o(Lt,{className:"h-3 w-24"}),o(Lt,{className:"h-3 w-16 ml-auto"})]})}function io({children:e,actions:t}){return f("div",{className:"border-b border-border px-4 py-2.5 flex items-center justify-between",children:[o("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:e}),t]})}function Cf({icon:e,label:t,value:n}){return f("div",{className:"flex items-center gap-2",children:[o(e,{className:"h-3.5 w-3.5 text-foreground-subtle flex-shrink-0"}),f("div",{className:"min-w-0",children:[o("p",{className:"text-[10px] text-foreground-subtle leading-tight",children:t}),o("p",{className:"text-xs font-medium text-foreground leading-tight",children:n})]})]})}function ZB({segments:e,selectedDate:t}){const n=fo(t).getTime(),r=1440*60*1e3,s=Array.from({length:25},(a,i)=>i);return f("div",{className:"space-y-1",children:[o("div",{className:"flex justify-between px-0.5",children:s.filter(a=>a%3===0).map(a=>o("span",{className:"text-[9px] text-foreground-subtle font-mono",children:String(a).padStart(2,"0")},a))}),f("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/r*100),d=Math.min(100-c,(l-i)/r*100);return d<=0?null:o("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:`${pa(a.startTime)} - ${pa(a.endTime)} (${Zd(a.duration)})`},a.id)}),s.slice(1,-1).map(a=>o("div",{className:"absolute top-0 bottom-0 w-px bg-border/50",style:{left:`${a/24*100}%`}},a))]})]})}function XB({segment:e,selected:t,onToggle:n,onPlay:r,onDownload:s,onDelete:a}){return f("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:[o("button",{onClick:n,className:"flex-shrink-0 text-foreground-subtle hover:text-foreground",children:t?o(ev,{className:"h-4 w-4 text-primary"}):o(ns,{className:"h-4 w-4"})}),f("div",{className:"flex-1 min-w-0",children:[f("p",{className:"text-xs font-mono text-foreground",children:[pa(e.startTime)," - ",pa(e.endTime)]}),f("p",{className:"text-[10px] text-foreground-subtle",children:[Zd(e.duration),e.sizeBytes!=null&&` · ${It(e.sizeBytes)}`]})]}),f("div",{className:"flex items-center gap-1 flex-shrink-0",children:[o("button",{onClick:r,title:"Play",className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:o(Za,{className:"h-3.5 w-3.5"})}),o("button",{onClick:s,title:"Download",className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:o(en,{className:"h-3.5 w-3.5"})}),o("button",{onClick:a,title:"Delete",className:"p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger transition-colors",children:o(Ze,{className:"h-3.5 w-3.5"})})]})]})}function JB({deviceId:e}){const t=ke(),[n,r]=_(()=>fo(new Date)),[s,a]=_(new Set),i=f0({deviceId:e},{refetchInterval:5e3}),l=d0({deviceId:e}),c=l.data?.streams[0]?.streamId??"stream0",d=u0({deviceId:e,streamId:c,startTime:fo(n).getTime(),endTime:YB(n).getTime()}),u=p0({deviceId:e,streamId:c},{refetchInterval:3e4}),p=h0({deviceId:e,dataCategory:"recording:main"}),h=U(()=>{t.invalidateQueries({queryKey:["recordingEngine","getPolicyStatus"]}),t.invalidateQueries({queryKey:["recordingEngine","getSegments"]}),t.invalidateQueries({queryKey:["recordingEngine","getStorageUsage"]})},[t]),m=l0({onSuccess:h}),g={isPending:m.isPending,error:m.error,mutate:()=>{const L=l.data,T=L?{mode:L.mode,streams:L.streams,enabled:!0,preBufferSec:L.preBufferSec,postBufferSec:L.postBufferSec,scheduleRules:L.scheduleRules}:{mode:"continuous",streams:[{streamId:c,mode:"always"}],enabled:!0,preBufferSec:10,postBufferSec:5};m.mutate({deviceId:e,policy:T})}},b=c0({onSuccess:h}),x=i.data??void 0,y=l.data??void 0,w=d.data??[],v=u.data,N=p.data??void 0,k=(x?.enabled??!1)&&(x?.activeStreams??0)>0,C=g.isPending||b.isPending,M=WB(n,new Date),P=q(()=>[...w].sort((L,T)=>new Date(T.startTime).getTime()-new Date(L.startTime).getTime()),[w]),I=q(()=>w.reduce((L,T)=>L+(T.duration??0),0),[w]),z=q(()=>w.reduce((L,T)=>L+(T.sizeBytes??0),0),[w]);function A(){k?b.mutate({deviceId:e}):g.mutate()}function O(){r(L=>{const T=new Date(L);return T.setDate(T.getDate()-1),fo(T)}),a(new Set)}function R(){M||(r(L=>{const T=new Date(L);return T.setDate(T.getDate()+1),fo(T)}),a(new Set))}function E(L){a(T=>{const B=new Set(T);return B.has(L)?B.delete(L):B.add(L),B})}function D(){s.size===P.length?a(new Set):a(new Set(P.map(L=>L.id)))}return i.isLoading&&l.isLoading?f("div",{className:"space-y-4",children:[f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(io,{children:"Recording Status"}),f("div",{className:"px-4 py-4 space-y-3",children:[o(Lt,{className:"h-10 w-full"}),o(Lt,{className:"h-4 w-48"})]})]}),f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(io,{children:"Segments"}),f("div",{className:"divide-y divide-border",children:[o(qn,{}),o(qn,{}),o(qn,{})]})]})]}):f("div",{className:"space-y-4",children:[f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(io,{children:"Recording Status"}),f("div",{className:"px-4 py-4 flex items-center justify-between gap-4",children:[f("div",{className:"flex items-center gap-3 min-w-0",children:[o("div",{className:`flex items-center justify-center rounded-full p-2 flex-shrink-0 ${k?"bg-danger/10":"bg-foreground-subtle/10"}`,children:o(jy,{className:`h-5 w-5 ${k?"text-danger animate-pulse":"text-foreground-subtle"}`})}),f("div",{className:"min-w-0",children:[o("p",{className:`text-sm font-medium ${k?"text-danger":"text-foreground-subtle"}`,children:k?"Recording":"Not Recording"}),o("p",{className:"text-[11px] text-foreground-subtle mt-0.5 truncate",children:k&&x?`${x.mode} – ${x.activeStreams} stream(s)`:"No active recording session"})]})]}),o("button",{onClick:A,disabled:C,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?f(he,{children:[o(ns,{className:"h-3.5 w-3.5"}),C?"Stopping...":"Stop Recording"]}):f(he,{children:[o(Za,{className:"h-3.5 w-3.5"}),C?"Starting...":"Start Recording"]})})]}),k&&x&&f("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-[11px] text-foreground-subtle",children:[o(yo,{className:"h-3.5 w-3.5 text-primary flex-shrink-0"}),f("span",{children:[x.activeStreams," active stream",x.activeStreams!==1?"s":""," · mode: ",x.mode]})]})]}),f("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(io,{children:f("span",{className:"flex items-center gap-1.5",children:[o(tn,{className:"h-3.5 w-3.5"}),"Settings"]})}),l.isLoading?f("div",{className:"px-4 py-3 space-y-2",children:[o(Lt,{className:"h-3 w-32"}),o(Lt,{className:"h-3 w-40"}),o(Lt,{className:"h-3 w-28"})]}):f("div",{className:"divide-y divide-border",children:[o(lo,{label:"Stream",value:c}),o(lo,{label:"Pre-buffer",value:y?`${y.preBufferSec}s`:"N/A"}),o(lo,{label:"Mode",value:y?.mode??"continuous"}),o(lo,{label:"Retention",value:N?.retentionDays!=null?`${N.retentionDays} days`:"N/A"}),N?.retentionGb!=null&&o(lo,{label:"Max Storage",value:`${N.retentionGb} GB`})]})]}),f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(io,{children:f("span",{className:"flex items-center gap-1.5",children:[o(ia,{className:"h-3.5 w-3.5"}),"Storage"]})}),u.isLoading?f("div",{className:"px-4 py-3 space-y-2",children:[o(Lt,{className:"h-3 w-28"}),o(Lt,{className:"h-3 w-36"}),o(Lt,{className:"h-3 w-24"})]}):u.error?f("div",{className:"px-4 py-4 flex items-center gap-2 text-xs text-danger",children:[o(tt,{className:"h-4 w-4"}),"Failed to load storage info"]}):f("div",{className:"px-4 py-3 grid grid-cols-2 gap-3",children:[o(Cf,{icon:ia,label:"Total",value:v?.totalBytes!=null?It(v.totalBytes):"N/A"}),o(Cf,{icon:yo,label:"Segments",value:v?.segmentCount!=null?String(v.segmentCount):"N/A"})]})]})]}),f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("div",{className:"border-b border-border px-4 py-2.5 flex items-center justify-between",children:[o("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:"Segment Browser"}),f("div",{className:"flex items-center gap-2",children:[o("button",{onClick:O,className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:o(qd,{className:"h-4 w-4"})}),f("div",{className:"flex items-center gap-1.5 text-xs text-foreground font-medium",children:[o(zy,{className:"h-3.5 w-3.5 text-foreground-subtle"}),M?"Today":fa(n)]}),o("button",{onClick:R,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:o(Nt,{className:"h-4 w-4"})})]})]}),f("div",{className:"px-4 py-3 border-b border-border",children:[o(ZB,{segments:w,selectedDate:n}),f("div",{className:"flex items-center gap-4 mt-2 text-[10px] text-foreground-subtle",children:[f("span",{children:[w.length," segment",w.length!==1?"s":""]}),I>0&&f("span",{children:[Zd(I)," recorded"]}),z>0&&o("span",{children:It(z)})]})]}),P.length>0&&f("div",{className:"border-b border-border px-4 py-2 flex items-center justify-between",children:[o("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&&f("div",{className:"flex items-center gap-2",children:[f("span",{className:"text-[10px] text-foreground-subtle",children:[s.size," selected"]}),f("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:[o(en,{className:"h-3 w-3"}),"Download"]}),f("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:[o(Ze,{className:"h-3 w-3"}),"Delete"]})]})]}),d.isLoading?f("div",{className:"divide-y divide-border",children:[o(qn,{}),o(qn,{}),o(qn,{}),o(qn,{})]}):P.length===0?f("div",{className:"flex flex-col items-center justify-center py-12 text-foreground-subtle",children:[o(yo,{className:"h-8 w-8 mb-3 opacity-30"}),o("p",{className:"text-sm",children:"No recorded segments"}),o("p",{className:"text-xs mt-1 opacity-70",children:M?"Recorded clips will appear here as they are created":`No recordings found for ${fa(n)}`})]}):o("div",{className:"max-h-[400px] overflow-y-auto",children:P.map(L=>o(XB,{segment:L,selected:s.has(L.id),onToggle:()=>E(L.id),onPlay:()=>{},onDownload:()=>{},onDelete:()=>{}},L.id))})]}),i.error&&f("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:[o(tt,{className:"h-4 w-4 flex-shrink-0"}),"Failed to load recording status. Will retry automatically."]}),(g.error||b.error)&&f("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:[o(tt,{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 lo({label:e,value:t}){return f("div",{className:"flex items-center justify-between px-4 py-2.5",children:[o("span",{className:"text-xs text-foreground-subtle",children:e}),o("span",{className:"text-xs font-medium text-foreground",children:t})]})}function ez({deviceId:e}){const t=ke(),n=Number.isFinite(e),{data:r}=Jn({deviceId:e},{enabled:n}),s=typeof r?.type=="string"?r.type:"camera";Ct(["deviceManager","getBindings"],["capability.binding-changed"]);const{data:a,isLoading:i,isError:l,error:c}=Qb({deviceId:e},{staleTime:3e4,enabled:n}),{data:d}=Kb({deviceType:s},{staleTime:3e4,enabled:!!s}),u=Gb({onSuccess:()=>{t.invalidateQueries({queryKey:[["deviceManager","getBindings"]]})}});if(i)return o("div",{className:"p-4",children:o("div",{className:"h-20 rounded-lg border border-border bg-surface animate-pulse"})});if(l)return f("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,h={};for(const b of d??[])h[b.capName]=b.wrappers;for(const b of a?.entries??[])p.set(b.capName,{...b,wrappers:h[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 m=[...p.values()].sort((b,x)=>b.capName.localeCompare(x.capName));if(m.length===0)return f("div",{className:"flex flex-col items-center justify-center gap-2 p-8 text-foreground-subtle",children:[o(Ya,{className:"h-8 w-8 opacity-40"}),o("p",{className:"text-xs",children:"No capability providers applicable to this device yet."}),o("p",{className:"text-[10px] opacity-60",children:"Native providers show up here as soon as the owning addon registers them."})]});const g=m.filter(b=>b.kind!=="unbound").length;return f("div",{className:"flex flex-col gap-3 p-1",children:[f("div",{className:"text-[11px] text-foreground-subtle",children:[o("span",{className:"font-medium text-foreground",children:g})," ","of ",m.length," capabilit",m.length===1?"y":"ies"," bound — rows marked ",o("em",{children:"unbound"})," have a wrapper available you can activate."]}),o("div",{className:"overflow-hidden rounded-lg border border-border bg-surface",children:f("table",{className:"w-full border-collapse text-[11px]",children:[o("thead",{children:f("tr",{className:"bg-surface-hover/50 text-left text-[10px] uppercase tracking-wide text-foreground-subtle",children:[o("th",{className:"px-3 py-2 font-medium",children:"Capability"}),o("th",{className:"px-3 py-2 font-medium",children:"Kind"}),o("th",{className:"px-3 py-2 font-medium",children:"Active Provider"}),o("th",{className:"px-3 py-2 font-medium",children:"Node"}),o("th",{className:"px-3 py-2 font-medium",children:"Native"}),o("th",{className:"px-3 py-2 font-medium",children:"Wrapper"})]})}),o("tbody",{children:m.map(b=>{const x=b.kind==="wrapped"?b.providerAddonId:null;return f("tr",{className:"border-t border-border align-middle",children:[o("td",{className:"px-3 py-2 font-mono text-foreground",children:b.capName}),o("td",{className:"px-3 py-2",children:o(tz,{kind:b.kind})}),o("td",{className:"px-3 py-2 font-mono text-foreground-subtle",children:b.providerAddonId||o("span",{className:"opacity-40",children:"—"})}),o("td",{className:"px-3 py-2",children:b.providerNodeId?o(nz,{nodeId:b.providerNodeId}):o("span",{className:"text-[10px] opacity-40",children:"—"})}),o("td",{className:"px-3 py-2 font-mono text-foreground-subtle",children:b.nativeAddonId||o("span",{className:"opacity-40",children:"—"})}),o("td",{className:"px-3 py-2",children:o(rz,{wrappers:b.wrappers,activeWrapperId:x,disabled:u.isPending,onPick:y=>{const w=x===y;u.mutate({deviceId:e,capName:b.capName,wrapperAddonId:y,active:!w})}})})]},b.capName)})})]})})]})}function tz({kind:e}){return e==="native"?f("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:[o(mn,{className:"h-3 w-3"}),"native"]}):e==="wrapped"?f("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:[o(E6,{className:"h-3 w-3"}),"wrapped"]}):f("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:[o(U6,{className:"h-3 w-3"}),"unbound"]})}function nz({nodeId:e}){return o("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 rz({wrappers:e,activeWrapperId:t,disabled:n,onPick:r}){return e.length===0?o("span",{className:"text-[10px] opacity-40",children:"none available"}):o("div",{className:"flex flex-wrap gap-1",children:e.map(s=>{const a=s===t;return f("button",{disabled:n,onClick:()=>r(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?o(_t,{className:"h-3 w-3"}):o(Xy,{className:"h-3 w-3"}),s]},s)})})}function oz(e,t){if(!e)return null;for(const n of e.slots)for(const r of n.addons)if(r.id===t)return r;return null}function sz(e,t,n){const r=e?.stepOverridesByAgent?.[t]?.[n];if(r)return r.enabled===!1?"off":(r.enabled===!0,"on");const s=e?.stepToggles?.[n];return s===!1?"off":s===!0?"on":"inherit"}function az({agents:e,currentAgent:t,onPick:n}){const[r,s]=_(!1);return f("div",{className:"relative",children:[o("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 ▾"}),r&&o("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=>o("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 iz({deviceId:e,refreshToken:t}){const n=ke(),[r,s]=_(null),[a,i]=_(null),[l,c]=_(null),[d,u]=_(null),p=md({deviceId:e}),h=Yr(),m=ja({deviceId:e}),g=zx(),b=q(()=>{const D=m.data?.agentNodeId;if(D)return D;const L=g.data?.find(T=>T.online)?.nodeId;return L||"hub"},[m.data?.agentNodeId,g.data]),x=a??b,y=Yo({nodeId:x??""},{enabled:!!x}),w=Zx({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),c(null)}}),v=q(()=>y.data?Da(y.data):[],[y.data]),N=q(()=>{const D=p.data??null,L={};for(const T of h.data??[])for(const B of Object.keys(T.settings.addonDefaults)){const F=L[B]??[];F.push({agentNodeId:T.nodeId,state:sz(D,T.nodeId,B)}),L[B]=F}return L},[p.data,h.data]),k=r?oz(y.data??null,r):null,C=x?h.data?.find(D=>D.nodeId===x)??null:null,M=r&&C?C.settings.addonDefaults[r]??null:null,P=r&&x?p.data?.stepOverridesByAgent?.[x]?.[r]??null:null,I=y.data?.selectedEngine.format??"coreml",z=D=>{i(D),c(null),u(null)},A=D=>{s(D),c(null),u(null)},O=D=>{if(!x||!r||!y.data||!h.data)return;const L=h.data.find(F=>F.nodeId===D),T=h.data.find(F=>F.nodeId===x);if(!L||!T)return;const[B]=Tm({source:{nodeId:L.nodeId,engine:{format:I},defaults:L.settings.addonDefaults},target:{nodeId:T.nodeId,engine:{format:I},defaults:T.settings.addonDefaults},catalog:y.data,addonIds:[r]});if(!B){u("no mirror result");return}if(B.outcome==="skip"){u(`skipped: ${B.reason??"no candidate"}`);return}c(B.patch),u(`${B.outcome} from ${D}`)},R=()=>{!x||!r||w.mutate({deviceId:e,agentNodeId:x,addonId:r,patch:l})},E=()=>{!x||!r||w.mutate({deviceId:e,agentNodeId:x,addonId:r,patch:null})};return h.isLoading||y.isLoading?o("div",{className:"text-xs text-foreground-subtle animate-pulse p-4",children:"Loading pipeline…"}):y.data?o("div",{className:"@container h-full",style:{containerType:"inline-size"},children:f("div",{className:"flex flex-col @[720px]:flex-row h-full",children:[o("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:o(Ig,{tree:v,selectedAddonId:r,onSelect:A,agentDots:N})}),o("section",{className:"flex-1 min-w-0 p-4 overflow-y-auto",children:!r||!k?o("div",{className:"text-sm text-foreground-subtle",children:"Select a step on the left to configure it for this camera."}):f("div",{className:"space-y-4",children:[f("div",{children:[o("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Selected step"}),o("div",{className:"text-base font-semibold",children:k.name})]}),f("div",{className:"flex items-end gap-3 flex-wrap",children:[f("div",{children:[o("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle mb-1",children:"Agent"}),o("div",{className:"flex rounded border border-border overflow-hidden",children:(h.data??[]).map(D=>o("button",{type:"button",onClick:()=>z(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))})]}),o(az,{agents:(h.data??[]).map(D=>D.nodeId),currentAgent:x,onPick:O}),d&&o("div",{className:"text-[10px] text-foreground-subtle",children:d})]}),M&&o(Ta,{mode:"device",addon:k,agentDefault:M,agentNodeId:x??"",currentPatch:l??P,engineFormat:I,onChangePatch:c}),f("div",{className:"flex items-center justify-between gap-2 pt-4 border-t border-border",children:[o("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:E,children:"Clear override"}),f("div",{className:"flex items-center gap-2",children:[o("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"}),o("button",{type:"button",className:"px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50",disabled:!x||!r||w.isPending,onClick:R,children:w.isPending?"Saving…":"Save"})]})]})]})})]})}):o("div",{className:"text-xs text-foreground-subtle p-4",children:"Catalog unavailable."})}const lz=[{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 cz(e){const t=e===ft.Camera;return lz.filter(n=>t||!n.cameraOnly).map(({id:n,label:r})=>({id:n,label:r}))}const dz=[{id:"logs",icon:it,label:"Logs"},{id:"repl",icon:tv,label:"REPL"},{id:"events",icon:es,label:"Events"},{id:"state",icon:Vy,label:"State"},{id:"ptz",icon:Y6,label:"PTZ",featureGate:Kn.PanTiltZoom}];function uz(){const e=Rd(),t=Number(e.deviceId),n=Number.isFinite(t),r=ot(),s=ke(),a=rt(),i=Le(),[l,c]=_("overview"),[d,u]=_("logs"),p="device-detail.left-col-width-px",[h,m]=_(()=>{if(typeof window>"u")return null;const de=window.localStorage.getItem(p),ce=de?Number(de):NaN;return Number.isFinite(ce)&&ce>0?ce:null}),g=te(h);g.current=h;function b(de){de.preventDefault();const ce=de.clientX,Ce=de.currentTarget.previousElementSibling?.getBoundingClientRect().width??h??0,pe=280,$e=Math.max(pe+50,Math.floor(window.innerWidth*.7)),Ae=ut=>{const yr=Math.max(pe,Math.min($e,Ce+(ut.clientX-ce)));m(yr)},Xe=()=>{document.removeEventListener("mousemove",Ae),document.removeEventListener("mouseup",Xe);const ut=g.current;if(ut!==null)try{window.localStorage.setItem(p,String(Math.round(ut)))}catch{}document.body.style.userSelect="",document.body.style.cursor=""};document.body.style.userSelect="none",document.body.style.cursor="col-resize",document.addEventListener("mousemove",Ae),document.addEventListener("mouseup",Xe)}const{data:x,isLoading:y,isError:w}=Jn({deviceId:t},{enabled:n,refetchInterval:5e3,retry:1}),{data:v}=ld({deviceId:t},{enabled:n,staleTime:3e4}),N=q(()=>{const de=v?.settings?.sections??[],ce=v?.live?.sections??[],Ce=[...de,...ce],pe=new Set;for(const Ae of Ce)Ae.location==="top-tab"&&Ae.tab&&pe.add(Ae.tab);return Ce.some(Lo)&&pe.add(rl),[...pe].map(Ae=>{if(Ae===rl)return{id:Ae,label:hB,isAddonContrib:!0};const Xe=Sl[Ae];return{id:Ae,label:Xe?.label??Ae,isAddonContrib:!0}})},[v]),k=x,C=String(k?.name??e.deviceId??"Device"),M=k?.online===!0,P=M?"online":"offline",I=String(k?.addonId??"rtsp"),z=k?.features??[],A=k?.type,O=A===ft.Camera,R=typeof k?.parentDeviceId=="number"?k.parentDeviceId:null,{data:E}=Jn({deviceId:R??0},{enabled:R!==null,staleTime:3e4}),D=hr(),L=q(()=>[...cz(A),...N],[A,N]),{data:T}=kv(n?t:0),B=(T??[]).length>0,F=q(()=>dz.filter(({featureGate:de})=>!de||z.includes(de)),[z]),{data:j}=ex({addonId:I},{enabled:!!I&&I!=="rtsp"}),V=Ub({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]}),r(j?.id?`/integrations/${j.id}`:"/integrations")}}),$=Hb({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),H=qb({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),G=i0(),Z=Wo({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),oe=z.includes(Kn.Rebootable),ne=z.includes(Kn.BatteryOperated),X=Wc(i.trpcClient,ne&&n?t:null),[re,be]=_(!1),J=At(i.trpcClient,n?t:null),W=async()=>{if(!(re||!J)){be(!0);try{await J.snapshot?.invalidateCache({});const de=await J.snapshot?.getSnapshot({});if(!de)return;const ce=`data:${de.contentType};base64,${de.base64}`,Ce=de.contentType.includes("png")?"png":"jpg",pe=C.replace(/[^a-zA-Z0-9_.-]+/g,"_"),$e=new Date().toISOString().replace(/[:.]/g,"-"),Ae=document.createElement("a");Ae.href=ce,Ae.download=`${pe}-${$e}.${Ce}`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae)}finally{be(!1)}}},ee=$.isPending||H.isPending,{data:ae}=ja({deviceId:t},{enabled:n,refetchInterval:1e4}),fe=ae?.agentNodeId??null,Q=typeof fe=="string"&&fe.length>0&&!fe.startsWith("addon:")?fe:void 0,{data:le}=gd({deviceId:t,...Q?{nodeId:Q}:{}},{enabled:n,refetchInterval:3e3,retry:!1});function ue(){if(!n)return null;switch(l){case"overview":return o(PB,{device:k??{}});case"config":return o(BB,{deviceId:t});case"pipeline":return o(iz,{deviceId:t,refreshToken:0});case"bindings":return o(ez,{deviceId:t});case"recording":return o(JB,{deviceId:t});default:{const de=l;return N.some(Ce=>Ce.id===de)?de===rl?o(oc,{deviceId:t,sectionFilter:Lo}):o(oc,{deviceId:t,sectionFilter:Ce=>Ce.location==="top-tab"&&Ce.tab===de}):null}}}return n?y?f("div",{className:"flex flex-col h-full",children:[f("div",{className:"border-b border-border bg-surface px-6 py-4",children:[o("div",{className:"h-4 w-48 rounded bg-surface-hover animate-pulse mb-3"}),o("div",{className:"h-8 w-64 rounded bg-surface-hover animate-pulse"})]}),o("div",{className:"flex-1 p-6",children:o("div",{className:"h-40 rounded-lg border border-border bg-surface animate-pulse"})})]}):w||!x?f("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle",children:[o("p",{className:"text-lg font-semibold text-foreground",children:"Device not found"}),f("p",{className:"text-xs",children:["No device with ID ",f("code",{className:"font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]",children:["#",t]})]}),o("button",{onClick:()=>r("/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"})]}):f("div",{className:"absolute inset-0 flex flex-col overflow-hidden",children:[f("div",{className:"border-b border-border bg-surface px-6 py-3 flex-shrink-0",children:[o("div",{className:"mb-2",children:o(Hc,{items:[{label:"Integrations",onClick:()=>r("/integrations")},{label:j?.name??I,onClick:()=>j?.id&&r(`/integrations/${j.id}`)},{label:C}]})}),f("div",{className:"flex items-center gap-2 sm:gap-3",children:[o(bn,{type:I,size:"lg"}),f("div",{className:"min-w-0 flex-1",children:[f("div",{className:"flex items-center gap-2 flex-wrap",children:[o("h1",{className:"text-sm sm:text-base font-semibold text-foreground truncate",children:C}),o(ni,{status:P}),ne&&o(Zc,{status:X,variant:"full"})]}),R!==null&&E&&f("button",{type:"button",onClick:()=>r(`/devices/${R}`),className:"text-[10px] text-foreground-subtle hover:text-primary transition-colors mt-0.5 inline-flex items-center gap-1",title:`Open parent device ${E.name}`,children:[o("span",{children:"↑"}),o("span",{className:"truncate",children:String(E.name??`Device #${R}`)})]}),o("div",{className:"hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle",children:z.length>0&&o(ei,{capabilities:z})})]}),le&&o("div",{className:"hidden lg:flex",children:o(pz,{metrics:le})}),f("div",{className:"flex items-center gap-1 shrink-0",children:[f("button",{onClick:async()=>{await a({title:`Disable "${C}"?`,message:"The device will stop processing streams and events. You can re-enable it later.",confirmLabel:"Disable",variant:"danger"})&&H.mutate({deviceId:t})},disabled:ee,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:[o(Zy,{className:"h-3.5 w-3.5"}),o("span",{className:"hidden sm:inline",children:ee?"Updating…":"Enabled"})]}),o("div",{className:"hidden sm:block h-5 w-px bg-border mx-1"}),o(my,{triggerClassName:"ml-1",items:[{id:"snapshot",label:"Take snapshot",description:"Fetch a fresh frame and download it.",icon:Dr,disabled:re,onClick:()=>{W()}},{id:"reboot",label:"Reboot device",description:"Camera goes offline for ~30 seconds.",icon:St,hidden:!oe,disabled:G.isPending,danger:!0,onClick:async()=>{await a({title:`Reboot "${C}"?`,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:dt,disabled:Z.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 "${C}"). Streams will reconnect automatically.`,confirmLabel:"Restart",variant:"danger"})&&Z.mutate({addonId:I})}},{id:"delete",label:"Delete device",description:"Remove the device and all its settings.",icon:Ze,separatorBefore:!0,disabled:V.isPending,danger:!0,onClick:async()=>{await a({title:`Delete "${C}"?`,message:"This will remove the device and all its settings. This action cannot be undone.",confirmLabel:"Delete",variant:"danger"})&&V.mutate({deviceId:t})}}]})]})]})]}),o(nb,{deviceId:t,device:k??void 0,children:o(K0,{children:o(by,{children:f("main",{className:D?"flex-1 overflow-y-auto flex flex-col":"flex-1 min-h-0 overflow-hidden flex flex-row",children:[f("div",{className:D?"flex flex-col bg-surface":`${h===null?"w-1/2 lg:w-1/3":""} flex-shrink-0 flex flex-col bg-surface min-h-0 overflow-hidden`,style:!D&&h!==null?{width:`${String(h)}px`}:void 0,children:[o("div",{className:`flex-shrink-0 border-b border-border-subtle ${O?"aspect-video bg-black":"bg-surface"}`,children:O?o(kB,{deviceId:t,intercomAvailable:z.includes(Kn.TwoWayAudio)}):o(KB,{deviceId:t,deviceName:C,deviceType:A??"unknown",provider:I,isOnline:M,features:z})}),f("div",{className:D?"flex flex-col border-b border-border":"flex-1 min-h-0 flex flex-col overflow-hidden",children:[o("div",{className:"flex-shrink-0 border-b border-border-subtle px-2 py-1.5",children:o("div",{className:"flex gap-1 overflow-x-auto -mx-1 px-1 pb-0.5",children:F.map(({id:de,label:ce,icon:Ce})=>f("button",{onClick:()=>u(de),title:ce,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:[o(Ce,{className:"h-3 w-3"}),ce]},de))})}),f("div",{className:D?"h-72 overflow-hidden":"flex-1 min-h-0 overflow-hidden",children:[d==="logs"&&o(SB,{deviceId:t}),d==="repl"&&o(CB,{deviceId:t}),d==="events"&&o(EB,{deviceId:t}),d==="state"&&o(IB,{deviceId:t}),d==="ptz"&&o(MB,{deviceId:t})]})]})]}),!D&&o("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:o("span",{className:"absolute inset-y-0 -left-1 -right-1"})}),f("div",{className:D?"flex flex-col":"flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden",children:[o("div",{className:"flex-shrink-0 border-b border-border bg-surface px-4",children:o("div",{className:"flex flex-wrap items-center gap-0",children:L.map(de=>{const ce=l===de.id;return f("button",{onClick:()=>c(de.id),className:`relative flex-shrink-0 px-3 py-2 text-xs font-medium transition-colors ${ce?"text-primary":"text-foreground-subtle hover:text-foreground"}`,children:[de.label,ce&&o("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 rounded-full bg-primary"})]},de.id)})})}),f("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"&&B&&o(AB,{parentDeviceId:t}),ue()]})]})]})})})})]}):f("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle",children:[o("p",{className:"text-lg font-semibold text-foreground",children:"Invalid device id"}),f("p",{className:"text-xs",children:["The URL segment ",o("code",{className:"font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]",children:e.deviceId})," is not a number."]}),o("button",{onClick:()=>r("/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 pz({metrics:e}){const t=e.phase??"idle",n=ur(t);return f("div",{className:"flex items-center gap-3 flex-shrink-0",children:[f("div",{className:"flex items-center gap-1.5",children:[o("span",{className:`h-1.5 w-1.5 rounded-full ${n.dotClass}`}),o("span",{className:`text-[10px] font-medium ${n.textColor}`,children:n.label})]}),o("div",{className:"h-3 w-px bg-border"}),f("div",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle",children:[o(Jo,{className:"h-3 w-3"}),o("span",{className:"text-foreground tabular-nums",children:(e.actualFps??0).toFixed(1)}),o("span",{children:"fps"})]}),f("div",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle",children:[o(xt,{className:"h-3 w-3"}),o("span",{className:"text-foreground tabular-nums",children:(e.avgInferenceTimeMs??0).toFixed(0)}),o("span",{children:"ms"})]}),(e.queueDepth??0)>0&&f("span",{className:"text-[10px] text-warning tabular-nums",children:["q:",e.queueDepth]})]})}function Bv({packageName:e,currentVersion:t,installSource:n,onInstall:r,onClose:s}){const a=n==="upload"||n==="local",{data:i,isLoading:l}=ub({name:e},{staleTime:5*6e4});return f("div",{className:"fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden",style:{top:"auto",bottom:"auto"},ref:c=>{if(!c)return;const d=c.parentElement?.getBoundingClientRect();if(!d)return;const u=window.innerHeight-d.bottom,p=d.top;u<280&&p>u?(c.style.bottom=`${window.innerHeight-d.top+4}px`,c.style.top="auto"):(c.style.top=`${d.bottom+4}px`,c.style.bottom="auto"),c.style.right=`${window.innerWidth-d.right}px`},onClick:c=>c.stopPropagation(),children:[f("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[o("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Versions"}),o("button",{type:"button",onClick:s,className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-3 w-3"})})]}),a&&f("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]",children:[o(Ja,{className:"h-3 w-3 mt-0.5 text-cyan-500 shrink-0"}),f("div",{className:"text-cyan-700 dark:text-cyan-200",children:[f("span",{className:"font-semibold",children:[n==="upload"?"Uploaded copy":"Local copy"," in place."]})," ","Re-install ",o("span",{className:"font-mono",children:t})," from npm to track upstream releases again."]})]}),l&&f("div",{className:"flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle",children:[o(Se,{className:"h-3.5 w-3.5 animate-spin"}),"Loading versions..."]}),i&&o("div",{className:"max-h-64 overflow-auto divide-y divide-border",children:i.map(c=>{const d=c.version===t,u=/-(alpha|beta|rc|dev|canary|next)/i.test(c.version);return f("div",{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${d?"bg-primary/5":"hover:bg-surface-hover"} transition-colors`,children:[o("span",{className:`font-mono flex-1 ${d?"text-primary font-semibold":u?"text-amber-400":"text-foreground"}`,children:c.version}),c.distTags.map(p=>o("span",{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${p==="latest"?"bg-emerald-500/15 text-emerald-400":p==="beta"?"bg-amber-500/15 text-amber-400":"bg-gray-500/15 text-gray-400"}`,children:p},p)),c.deprecated&&o("span",{className:"text-[9px] text-red-400 line-through",children:"deprecated"}),o("span",{className:"text-[9px] text-foreground-subtle shrink-0",children:new Date(c.publishedAt).toLocaleDateString()}),d&&!a?o(_t,{className:"h-3 w-3 text-primary shrink-0"}):o("button",{type:"button",onClick:()=>r(c.version),className:"shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors",title:d?`Re-install ${c.version} from npm`:`Install ${c.version}`,children:o(en,{className:"h-3 w-3"})})]},c.version)})}),i&&i.length===0&&o("div",{className:"py-4 text-center text-[10px] text-foreground-subtle",children:"No versions found"})]})}const fz="device-export";function hz(e){return e.capabilities.some(t=>(typeof t=="string"?t:t.name)===fz)}function mz({isBundle:e,installSource:t,addonId:n,iconPath:r,color:s}){const[a,i]=_(!1),l=s?{backgroundColor:`${s.startsWith("#")?s:`#${s}`}26`}:void 0,c=e?"bg-indigo-500/20 text-indigo-700 dark:text-indigo-300":"bg-purple-500/20 text-purple-700 dark:text-purple-300",d=n&&r?`/api/addon-assets/${n}/${r}`:null,u=!!d&&!a;return f("div",{className:"relative flex-shrink-0",children:[o("div",{className:`h-9 w-9 rounded-lg flex items-center justify-center ${l?"":c}`,style:l,children:u?o("img",{src:d,alt:n,className:"h-5 w-5",onError:()=>i(!0)}):e?o(Wy,{className:"h-4 w-4"}):o($o,{className:"h-4 w-4"})}),t==="local"&&o("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"&&o("span",{className:"absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm",children:o("svg",{viewBox:"0 0 780 250",className:"w-[11px] h-[11px]",children:o("path",{fill:"#fff",d:"M240 250h100V50h100v200h340V0H0v250z"})})}),t==="upload"&&o("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:o(Ja,{className:"h-2.5 w-2.5 text-white"})})]})}function gz({addonId:e}){const t=ke(),{data:n="inherit"}=hb({addonId:e},{staleTime:3e4}),r=mb({onSuccess:()=>{t.invalidateQueries({queryKey:[["addons","getAddonAutoUpdate"]]})}});return o("div",{className:"flex rounded-lg border border-border overflow-hidden text-[10px] font-medium",children:["inherit","off","latest","beta"].map(s=>o("button",{type:"button",onClick:a=>{a.stopPropagation(),r.mutate({addonId:e,channel:s})},disabled:r.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 ac({addon:e,agents:t=[],clusterStatus:n,hideVersion:r,availableUpdate:s,onUpdate:a,isUpdating:i,bundle:l}){const[c,d]=_(!1),[u,p]=_(!1),[h,m]=_(!1),[g,b]=_(!1),[x,y]=_(!1),[w,v]=_("logs"),N=ke(),k=rt(),{manifest:C}=e,M=e.installedOn??[],P=!l&&!C.protected&&C.removable!==!1,I=!!l,z=l?.displayName??C.name,A=l?.packageName??C.packageName,O=l?.version??C.packageVersion??C.version,R=l?.installSource??e.installSource,E=l?l.bundle?.description??l.addons[0]?.manifest.description:C.description;!l&&(C.components&&C.components.length>0||t.length>=2);const D=rb({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["addonPages"]]}),N.invalidateQueries({queryKey:[["capabilities"]]})}}),L=Wo({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]})}}),T=td({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["addonPages"]]}),N.invalidateQueries({queryKey:[["capabilities"]]}),N.invalidateQueries({queryKey:[["integrations"]]})}}),B=pb({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["alerts"]]})}}),F=e.health,j=F?.phase==="failed"&&!F.inGracePeriod,V=j&&F?.nextRetryAt&&!F.retrying;return f("div",{className:`rounded-lg border bg-surface overflow-hidden ${j?"border-red-500/50":"border-border"}`,children:[j&&F&&f("div",{className:"bg-danger/10 border-b border-danger/30 px-4 py-2.5 flex items-start gap-2.5",children:[o(J6,{className:"h-4 w-4 text-danger shrink-0 mt-0.5"}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"text-xs font-semibold text-danger",children:["Failed to load (attempt #",F.retryCount,")"]}),o("div",{className:"text-[11px] text-foreground mt-0.5 break-words font-mono",children:F.lastError?.message??"Unknown error"}),V&&F.nextRetryAt&&f("div",{className:"text-[10px] text-foreground-subtle mt-1",children:["Auto-retry at ",new Date(F.nextRetryAt).toLocaleTimeString()]})]}),f("button",{type:"button",disabled:B.isPending||F.retrying,onClick:$=>{$.stopPropagation(),B.mutate({packageName:A})},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:[o(dt,{className:`h-3 w-3 ${B.isPending||F.retrying?"animate-spin":""}`}),"Retry now"]})]}),f("div",{className:"flex items-start gap-3 px-4 py-3",children:[o(mz,{isBundle:I||!!C.components&&C.components.length>1,installSource:R,addonId:I?l.addons[0]?.manifest.id:C.id,iconPath:I?l.bundle?.icon??l.addons[0]?.manifest.icon:C.icon,color:I?l.addons[0]?.manifest.color:C.color}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-sm font-semibold text-foreground truncate",children:z}),f("span",{className:"text-[10px] text-foreground-subtle font-mono shrink-0",children:["(",A,")"]}),I&&f("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:[o(Wy,{className:"h-3 w-3"}),l.addons.length]})]}),E&&o("p",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-1",children:E}),!I&&e.process&&f("div",{className:"flex items-center gap-1.5 mt-1",children:[o("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&&f("span",{className:"text-[9px] font-mono text-foreground-subtle",children:["PID ",e.process.pid]}),o("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})]})]}),!r&&f("div",{className:"relative inline-flex items-center gap-1.5 shrink-0 pt-0.5",children:[i?f("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:[o(Se,{className:"h-3 w-3 animate-spin"}),"Updating to ",s,"…"]}):s&&a?f("button",{type:"button",onClick:$=>{$.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:[o(en,{className:"h-3 w-3"}),s]}):null,f("button",{type:"button",onClick:$=>{$.stopPropagation(),m(H=>!H)},className:["inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-bold font-mono border transition-colors",R==="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 ${O} — newer ${s} available`:"View all versions",children:[O,o(lt,{className:"h-3 w-3 opacity-50"})]}),h&&o(Bv,{packageName:A,currentVersion:O,...R?{installSource:R}:{},onInstall:$=>{m(!1),T.mutate({packageName:A,version:$})},onClose:()=>m(!1)})]})]}),!I&&f("div",{className:"flex items-center gap-1 px-4 py-1.5 border-t border-border/50 bg-surface-hover/20",children:[f("button",{type:"button",onClick:$=>{$.stopPropagation(),L.mutate({addonId:C.id})},disabled:L.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:[o(dt,{className:`h-3 w-3 ${L.isPending?"animate-spin":""}`}),"Restart"]}),f("button",{type:"button",onClick:$=>{$.stopPropagation(),b(H=>!H)},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:[o(it,{className:"h-3 w-3"}),"Logs"]}),!I&&f("button",{type:"button",onClick:$=>{$.stopPropagation(),y(!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:[o(tn,{className:"h-3 w-3"}),"Settings"]}),o("div",{className:"flex-1"}),P&&f("button",{type:"button",onClick:async $=>{$.stopPropagation(),await k({title:`Uninstall ${C.name}?`,message:"This will remove the addon package and all its data. This action cannot be undone.",confirmLabel:"Uninstall",variant:"danger"})&&D.mutate({packageName:C.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:[o(Ze,{className:"h-3 w-3"}),D.isPending?"Removing...":"Uninstall"]})]}),n&&n.nodes.length>1&&!I&&f("div",{className:"border-t border-border px-4 py-2 bg-muted/10",children:[o("div",{className:"text-[10px] font-medium text-foreground-subtle mb-1.5",children:"Cluster Deployment"}),o("div",{className:"space-y-1",children:n.nodes.map($=>f("div",{className:"flex items-center gap-2 text-[10px]",children:[o("div",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${$.status==="offline"?"bg-muted-foreground/30":$.synced?"bg-success":"bg-amber-500"}`}),o("span",{className:"font-medium text-foreground min-w-[60px]",children:$.name}),o("span",{className:"font-mono text-foreground-subtle",children:$.version}),!$.synced&&$.status!=="offline"&&o("span",{className:"text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"outdated"}),$.status==="offline"&&o("span",{className:"text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground",children:"offline"}),$.synced&&$.status!=="offline"&&o("span",{className:"text-[9px] text-success",children:"synced"})]},$.nodeId))})]}),g&&!I&&f("div",{className:"border-t border-border",children:[f("div",{className:"flex items-center px-4 py-1 bg-surface-hover/20 border-b border-border/50",children:[f("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:[o("button",{type:"button",onClick:()=>v("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"}),o("button",{type:"button",onClick:()=>v("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"})]}),o("div",{className:"flex-1"}),o("button",{type:"button",onClick:$=>{$.stopPropagation(),b(!1)},className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-3.5 w-3.5"})})]}),w==="logs"&&o(Ht,{addonId:C.id,maxHeight:"max-h-64",showFilters:!1}),w==="events"&&o(br,{addonId:C.id,category:"addon.*",maxHeight:"max-h-64"})]}),I&&f(he,{children:[o("button",{type:"button",onClick:()=>d($=>!$),className:"w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors",children:c?o(qR,{className:"h-3.5 w-3.5 text-foreground-subtle"}):o(lt,{className:"h-3.5 w-3.5 text-foreground-subtle"})}),c&&o("div",{className:"border-t border-border px-3 py-2 space-y-2",children:l.addons.map($=>o(ac,{addon:$,agents:t,hideVersion:!0},$.manifest.id))})]}),x&&!I&&o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",onClick:()=>y(!1),children:f("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:$=>$.stopPropagation(),children:[f("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border flex-shrink-0",children:[f("div",{className:"flex items-center gap-2",children:[o(tn,{className:"h-4 w-4 text-primary"}),f("h2",{className:"text-sm font-semibold text-foreground",children:[z," Settings"]})]}),o("button",{onClick:()=>y(!1),className:"text-foreground-subtle hover:text-foreground transition-colors p-1 rounded",children:o(Fe,{className:"h-4 w-4"})})]}),f("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[o(to,{nodeId:"hub",addonIds:[C.id],level:"global"}),hz(C)&&f("div",{children:[o("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:"Device export"}),o(py,{addonId:C.id})]}),R==="npm"&&f("div",{children:[o("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:"Auto-Update"}),o(gz,{addonId:C.id})]}),C.components&&C.components.length>0&&f("div",{children:[f("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Components (",C.components.length,")"]}),o("div",{className:"flex flex-wrap gap-1",children:C.components.map($=>o("span",{className:"text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono",children:$},$))})]}),t.length>=2&&f("div",{children:[o("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:"Installed on"}),f("div",{className:"flex items-center gap-1.5 flex-wrap",children:[M.length===0&&o("span",{className:"text-[10px] text-foreground-subtle",children:"Hub (local)"}),M.map($=>o("span",{className:"rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle",children:$},$)),f("div",{className:"relative",children:[f("button",{type:"button",onClick:$=>{$.stopPropagation(),p(H=>!H)},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:[o(ct,{className:"h-3 w-3"}),"Add agent"]}),u&&f("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($=>!$.isHub&&!M.includes($.name)).map($=>o("button",{type:"button",onClick:H=>{H.stopPropagation(),p(!1)},className:"w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors",children:$.name},$.id)),t.filter($=>!$.isHub&&!M.includes($.name)).length===0&&o("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle",children:"No available agents"})]})]})]})]})]}),o("div",{className:"flex items-center justify-end px-5 py-3 border-t border-border flex-shrink-0",children:o("button",{type:"button",onClick:()=>y(!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 bz=".tgz,.tar.gz,.zip";function xz({onUploadSuccess:e}){const[t,n]=_(!1),r=te(null),s=U(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=U(i=>{const l=i.target.files?.[0];l&&s(l),i.target.value=""},[s]);return f(he,{children:[o("input",{ref:r,type:"file",accept:bz,onChange:a,className:"hidden"}),f("button",{type:"button",onClick:()=>r.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?o(Se,{className:"w-3.5 h-3.5 animate-spin"}):o(Ja,{className:"w-3.5 h-3.5"}),t?"Uploading...":"Upload"]})]})}function yz(){const{data:e,isLoading:t,isError:n}=cb(void 0,{staleTime:6e4}),[r,s]=_(null),[a,i]=_(null),l=db({onError:d=>{i(d instanceof Error?d.message:String(d))},onSuccess:()=>{s(null)}});if(t)return o(il,{children:o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading system packages…"})});if(n)return o(il,{children:o("div",{className:"text-xs text-danger",children:"Failed to load system packages"})});const c=e??[];return c.length===0?o(he,{}):f(he,{children:[o(il,{collapsible:!0,defaultCollapsed:!0,children:o("div",{className:"space-y-1.5",children:c.map(d=>o(vz,{row:d,onUpdate:u=>s({packageName:d.packageName,fromVersion:d.currentVersion,toVersion:u})},d.packageName))})}),r!==null&&o(wz,{pending:r,onCancel:()=>{s(null),i(null)},onConfirm:()=>{i(null),l.mutate({packageName:r.packageName,version:r.toVersion})},isPending:l.isPending,error:a})]})}function il({children:e,collapsible:t=!1,defaultCollapsed:n=!1}){const[r,s]=_(n),a=!t||!r,i=f("div",{className:"flex items-center gap-2",children:[t&&(r?o(Nt,{className:"w-3.5 h-3.5 text-amber-700 shrink-0"}):o(lt,{className:"w-3.5 h-3.5 text-amber-700 shrink-0"})),o(tt,{className:"w-3.5 h-3.5 text-amber-700 shrink-0"}),o("span",{className:"text-[11px] font-medium text-amber-800",children:"System packages"}),o("span",{className:"text-[10px] text-foreground-subtle",children:"Updating these will restart the hub (~10s)."})]});return f("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/5 p-3 space-y-2",children:[t?o("button",{type:"button",onClick:()=>s(l=>!l),"aria-expanded":!r,className:"flex w-full items-center text-left",children:i}):i,a&&e]})}function vz({row:e,onUpdate:t}){const[n,r]=_(!1),s=e.hasUpdate&&e.latestVersion!==null;return f("div",{className:"flex items-center justify-between gap-3 px-2 py-1.5 rounded bg-surface/50 border border-border",children:[f("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o("span",{className:"font-mono text-[11px] text-foreground truncate",children:e.packageName}),e.description!==void 0&&o("span",{className:"text-[10px] text-foreground-subtle truncate",title:e.description,children:e.description})]}),f("div",{className:"flex items-center gap-2 shrink-0",children:[s&&f("button",{type:"button",onClick:()=>t(e.latestVersion),className:"inline-flex items-center gap-1 px-2 py-1 text-[10px] rounded bg-amber-500/15 text-amber-800 hover:bg-amber-500/25 border border-amber-500/30 font-medium transition-colors",title:`Update to ${e.latestVersion}`,children:[o(en,{className:"w-3 h-3"}),"v",e.latestVersion]}),f("button",{type:"button",onClick:()=>r(a=>!a),className:["inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-mono font-medium border transition-colors",s?"border-amber-500/30 bg-amber-500/10 text-amber-800 hover:bg-amber-500/20":"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 hover:bg-emerald-500/20"].join(" "),title:"View all versions",children:["v",e.currentVersion,o(lt,{className:"w-3 h-3 opacity-50"})]}),n&&o(Bv,{packageName:e.packageName,currentVersion:e.currentVersion,onInstall:a=>{r(!1),t(a)},onClose:()=>r(!1)})]})]})}function wz({pending:e,onCancel:t,onConfirm:n,isPending:r,error:s}){return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:f("div",{className:"bg-surface border border-border rounded-md shadow-xl p-5 max-w-md w-full mx-4 space-y-3",children:[f("div",{className:"flex items-center gap-2",children:[o(tt,{className:"w-4 h-4 text-amber-700"}),o("h3",{className:"text-sm font-medium text-foreground",children:"Update system package?"})]}),f("div",{className:"space-y-2 text-[11px] text-foreground-subtle",children:[f("div",{children:[o("span",{className:"font-mono text-foreground",children:e.packageName}),o("span",{className:"mx-1",children:"·"}),f("span",{className:"font-mono",children:["v",e.fromVersion]}),o("span",{className:"mx-1",children:"→"}),f("span",{className:"font-mono text-amber-700",children:["v",e.toVersion]})]}),o("div",{className:"rounded border border-amber-500/30 bg-amber-500/10 p-2 text-amber-800",children:"The hub will restart immediately after the install. Any in-flight requests will be dropped. The reconnect typically takes ~10 seconds."}),s!==null&&o("div",{className:"rounded border border-danger/40 bg-danger/10 p-2 text-danger",children:s})]}),f("div",{className:"flex justify-end gap-2 pt-1",children:[o("button",{type:"button",onClick:t,disabled:r,className:"px-3 py-1.5 text-[11px] rounded bg-surface hover:bg-surface-hover border border-border disabled:opacity-50",children:"Cancel"}),f("button",{type:"button",onClick:n,disabled:r,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] rounded bg-amber-500/20 text-amber-800 hover:bg-amber-500/30 border border-amber-500/40 font-medium disabled:opacity-50",children:[r?o(Se,{className:"w-3 h-3 animate-spin"}):o(en,{className:"w-3 h-3"}),"Update & restart"]})]})]})})}function Nz(e,t){const n=e??"hub-only";return n==="any-node"?!0:n==="hub-only"?t:!t}function kz(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??[]},r=t.process,s=r?{pid:r.pid,mode:r.mode==="forked"?"forked":"in-process",state:r.state??"unknown"}:void 0,a=t.health,i=t.declaration?.execution,l=t.manifest.execution,c=i?.placement??l?.placement;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...s?{process:s}:{},hasBackup:t.hasBackup,...a?{health:a}:{},...c?{placement:c}:{}}}function Sz(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 r=[];for(const s of t.values())s.bundle!==void 0||s.addons.length>=2?r.push({bundle:s,representative:s.addons[0]}):r.push(s.addons[0]);return r.push(...n),r}function an(e){return"bundle"in e}function Cz({addons:e,clusterStatus:t,selectedNode:n,onRefresh:r,isRefreshing:s}){const a=ke(),[i,l]=_(""),c=a2(i),[d,u]=_(!1),p=te(null);Y(()=>{if(!d)return;const $=H=>{p.current&&!p.current.contains(H.target)&&u(!1)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[d]);const{data:h}=nd({nodeId:n.id},{staleTime:5*6e4}),m=q(()=>{const $=new Map;for(const H of h??[])$.set(H.name,H.latestVersion);return $},[h]),[g,b]=_(null),[x,y]=_(null),w=Bl({onMutate:$=>{b($.name),y(null)},onSuccess:($,H)=>{b(null);const G=$;if(G&&G.success===!1){y({name:H.name,message:G.error??"Update failed (no error message returned by server)"});return}a.invalidateQueries({queryKey:[["addons"]]}),a.invalidateQueries({queryKey:[["addons","listUpdates"]]})},onError:($,H)=>{b(null),y({name:H.name,message:$ instanceof Error?$.message:String($)})}}),{data:v}=fb(void 0,{staleTime:3e4}),N=gb({onSuccess:()=>{a.invalidateQueries({queryKey:[["addons","getAutoUpdateSettings"]]})}}),{data:k,isFetching:C}=sb({query:c||void 0},{enabled:d,staleTime:6e4}),M=Bl(),P=async()=>{const $=h??[];for(const H of $)await M.mutateAsync({name:H.name,version:H.latestVersion,nodeId:n.id});a.invalidateQueries({queryKey:[["addons"]]})},I=td({onSuccess:()=>{a.invalidateQueries({queryKey:[["addons"]]}),a.invalidateQueries({queryKey:[["addonPages"]]}),a.invalidateQueries({queryKey:[["capabilities"]]}),a.invalidateQueries({queryKey:[["integrations"]]})}}),[z,A]=_("type"),[O,R]=_(()=>typeof window>"u"?"grouped":window.localStorage.getItem("camstack.addons.viewMode")==="flat"?"flat":"grouped"),E=$=>{R($),typeof window<"u"&&window.localStorage.setItem("camstack.addons.viewMode",$)},[D,L]=Ka(),T=D.get("capability"),B=q(()=>{let $=n.isHub?e:e.filter(H=>Nz(H.placement,n.isHub));return T&&($=$.filter(H=>(H.manifest.capabilities??[]).some(Z=>(typeof Z=="string"?Z:Z.name)===T))),$},[e,n.isHub,T]),F=()=>{const $=new URLSearchParams(D);$.delete("capability"),L($,{replace:!0})},j=O==="flat"?B:Sz(B),V=q(()=>{const $=[...j];switch(z){case"type":$.sort((H,G)=>{const Z=an(H)?0:1,oe=an(G)?0:1;if(Z!==oe)return Z-oe;const ne=an(H)?H.bundle.displayName:H.manifest.name,X=an(G)?G.bundle.displayName:G.manifest.name;return ne.localeCompare(X)});break;case"name":$.sort((H,G)=>{const Z=an(H)?H.bundle.displayName:H.manifest.name,oe=an(G)?G.bundle.displayName:G.manifest.name;return Z.localeCompare(oe)});break;case"source":$.sort((H,G)=>{const Z=an(H)?H.bundle.installSource??"":H.installSource??"",oe=an(G)?G.bundle.installSource??"":G.installSource??"";return Z.localeCompare(oe)});break}return $},[j,z]);return f("div",{className:"space-y-4",children:[x&&o("div",{className:"rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px]",children:f("div",{className:"flex items-start justify-between gap-3",children:[f("div",{className:"space-y-0.5",children:[f("div",{className:"font-medium text-danger",children:["Failed to update ",x.name]}),o("div",{className:"text-foreground-subtle font-mono",children:x.message})]}),o("button",{type:"button",onClick:()=>y(null),className:"text-foreground-subtle hover:text-foreground text-[10px]",children:"dismiss"})]})}),f("div",{className:"flex items-center gap-2 flex-wrap",children:[f("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"text-[10px] text-foreground-subtle",children:"Sort:"}),f("select",{value:z,onChange:$=>A($.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:[o("option",{value:"type",children:"Bundles first"}),o("option",{value:"name",children:"Name"}),o("option",{value:"source",children:"Install source"})]})]}),f("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"text-[10px] text-foreground-subtle",children:"View:"}),o("div",{className:"flex rounded-md border border-border overflow-hidden text-[10px] font-medium",children:["grouped","flat"].map($=>o("button",{type:"button",onClick:()=>E($),className:`px-2.5 py-1.5 transition-colors capitalize ${O===$?"bg-primary/10 text-primary":"bg-transparent text-foreground-subtle hover:bg-surface-hover"}`,title:$==="grouped"?"Group multi-addon packages into a bundle card":"Show every addon as its own card",children:$},$))})]}),n.isHub&&f("div",{className:"flex items-center gap-1.5",children:[o(dt,{className:"h-3 w-3 text-foreground-subtle"}),o("span",{className:"text-[10px] text-foreground-subtle",children:"Auto-Update:"}),o("div",{className:"flex rounded-md border border-border overflow-hidden text-[10px] font-medium",children:["off","latest","beta"].map($=>o("button",{type:"button",onClick:()=>N.mutate({channel:$}),disabled:N.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${v?.channel===$?$==="off"?"bg-gray-700 text-gray-200":$==="latest"?"bg-blue-500/20 text-blue-400":"bg-amber-500/20 text-amber-400":"bg-transparent text-foreground-subtle hover:bg-surface-hover"} ${$!=="off"?"border-l border-border":""}`,children:$},$))})]}),(h?.length??0)>0&&f("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:[o(en,{className:`w-3 h-3 ${M.isPending?"animate-bounce":""}`}),"Update All (",h.length,")"]}),f("button",{type:"button",onClick:r,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:[o(dt,{className:`w-3 h-3 ${s?"animate-spin":""}`}),"Refresh"]})]}),f("div",{className:"flex items-center gap-3",children:[f("div",{className:"relative flex-1 min-w-[200px]",ref:p,children:[o(Jy,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle"}),o("input",{type:"text",value:i,onChange:$=>{l($.target.value),u(!0)},onFocus:()=>u(!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"}),C&&o(Se,{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&&f("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&&f("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&&o("div",{className:"max-h-72 overflow-auto divide-y divide-border",children:k.map($=>f("div",{className:"flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors",children:[o("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:$.name.replace("@camstack/addon-","").charAt(0).toUpperCase()}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-[11px] font-semibold truncate",children:$.name}),f("span",{className:"text-[10px] text-foreground-subtle",children:["v",$.version]})]}),$.description&&o("div",{className:"text-[10px] text-foreground-subtle truncate",children:$.description})]}),$.installed?f("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:[o(_t,{className:"h-3 w-3"}),$.installedVersion??"Installed"]}):f("button",{type:"button",onClick:()=>I.mutate({packageName:$.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?o(Se,{className:"h-3 w-3 animate-spin"}):o(en,{className:"h-3 w-3"}),"Install"]})]},$.name))})]})]}),o(xz,{onUploadSuccess:()=>{a.invalidateQueries({queryKey:[["addons"]]}),r()}})]}),T&&f("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/10 border border-primary/30 text-sm",children:[o("span",{className:"text-foreground-subtle",children:"Filtering by capability:"}),o("span",{className:"font-mono text-primary font-semibold",children:T}),o("button",{type:"button",onClick:F,className:"ml-auto text-xs text-foreground-subtle hover:text-foreground underline",children:"Clear"})]}),B.length===0&&o("div",{className:"text-xs text-foreground-subtle",children:e.length===0?"No addons installed":T?`No installed addons declare the "${T}" capability. Browse the npm catalog above to find a compatible addon.`:`No addons compatible with ${n.name} (placement filter active)`}),o("div",{className:"space-y-2",children:V.map($=>{if(an($)){const Z=$.bundle.packageName,oe=m.get(Z);return o(ac,{addon:$.representative,clusterStatus:t?.[$.representative.manifest.id],bundle:$.bundle,availableUpdate:oe,isUpdating:g===Z,onUpdate:oe?()=>w.mutate({name:Z,version:oe,nodeId:n.id}):void 0},Z)}const H=$.manifest.packageName,G=m.get(H);return o(ac,{addon:$,clusterStatus:t?.[$.manifest.id],availableUpdate:G,isUpdating:g===H,onUpdate:G?()=>w.mutate({name:$.manifest.packageName,version:G,nodeId:n.id}):void 0},$.manifest.id)})})]})}function Mz(){const e=ke(),{data:t,isLoading:n,isError:r}=Ko(),{data:s}=Mx(void 0,{staleTime:15e3}),{data:a}=Bn(void 0,{staleTime:3e4,refetchInterval:1e4}),i=q(()=>{const x=new Map;x.set("hub",{id:"hub",name:"Hub",isHub:!0});for(const y of a??[]){const w=String(y.id??"");w&&x.set(w,{id:w,name:String(y.name??w),isHub:!!y.isHub})}return[...x.values()]},[a]),[l,c]=_("hub"),d=i.find(x=>x.id===l)??i[0],u=ab(),p=ob(),h=u.isPending||p.isPending,m=async()=>{await u.mutateAsync({nodeId:l}),await p.mutateAsync(),e.invalidateQueries({queryKey:[["addons"]]})},g=te(u);g.current=u,Y(()=>{g.current.mutate({nodeId:"hub"})},[]);const b=(t??[]).map(kz).filter(x=>x!==null);return f(nt,{children:[f("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[o(_g,{selectedNodeId:l,onSelect:c}),f("div",{className:"flex items-center gap-3 flex-wrap",children:[!n&&!r&&f("span",{className:"text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium",children:[b.length," installed"]}),f("button",{type:"button",onClick:()=>void m(),disabled:h,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:[o(dt,{className:`w-3 h-3 ${h?"animate-spin":""}`}),"Check for updates"]})]})]}),!d.isHub&&f("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"," ",o("span",{className:"font-medium text-foreground",children:d.name})," ","— agents only run ",o("code",{className:"font-mono",children:"agent-only"})," and"," ",o("code",{className:"font-mono",children:"any-node"})," addons. Install / uninstall is hub-driven; agents auto-sync from the hub."]}),n&&o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading…"}),r&&o("div",{className:"text-xs text-danger",children:"Failed to load addons"}),d.isHub&&o(yz,{}),!n&&!r&&o(Cz,{addons:b,clusterStatus:s,selectedNode:d,onRefresh:()=>void m(),isRefreshing:h})]})}function Ez({value:e,size:t=192}){const[n,r]=_(null),[s,a]=_(null);if(Y(()=>{let d=!1;return k2(()=>import("./browser-BXdiCFWD.js").then(u=>u.b),[]).then(async u=>{if(d)return;const p=u.create;if(typeof p!="function"){a("qrcode.create() unavailable in installed version");return}try{const h=p(e,{errorCorrectionLevel:"M"});d||r(h)}catch(h){d||a(h instanceof Error?h.message:"QR generation failed")}}).catch(()=>{d||a("qrcode library not installed")}),()=>{d=!0}},[e]),s)return o("div",{className:"flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4",style:{width:t,height:t},children:"QR rendering unavailable — use the secret below."});if(!n)return o("div",{className:"flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse",style:{width:t,height:t},children:"Generating…"});const i=n.modules.size,l=t/i,c=[];for(let d=0;d<i;d++)for(let u=0;u<i;u++)n.modules.data[d*i+u]&&c.push(o("rect",{x:u*l,y:d*l,width:l,height:l,fill:"currentColor"},`${u}-${d}`));return f("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:"text-black",children:[o("rect",{x:0,y:0,width:t,height:t,fill:"white"}),c]})}const Iz={view:{icon:ts,cls:"bg-foreground-subtle/15 text-foreground-subtle"},create:{icon:eo,cls:"bg-primary/15 text-primary"},delete:{icon:Ze,cls:"bg-danger/15 text-danger"}};function Az(){const{user:e,logout:t}=rn();if(!e)return o(nt,{children:o("div",{className:"text-xs text-foreground-subtle",children:"Not signed in."})});const n=e.isAdmin,r=e.scopes??[];return f(nt,{children:[f("div",{className:"rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3",children:[o("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base",children:e.username.slice(0,1).toUpperCase()}),f("div",{className:"flex-1 min-w-0",children:[o("div",{className:"text-sm font-semibold text-foreground truncate",children:e.username}),f("div",{className:"text-[11px] text-foreground-subtle",children:[n?"Administrator":"User"," · session id ",f("span",{className:"font-mono",children:[e.id.slice(0,8),"…"]})]})]})]}),n&&f("div",{className:"rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5",children:[o(rr,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),f("div",{children:[o("div",{className:"font-semibold text-foreground",children:"Unrestricted access"}),o("p",{className:"text-foreground-subtle mt-0.5",children:"Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below."})]})]}),o(Pz,{}),o(_z,{username:e.username}),r.length>0&&f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("div",{className:"px-4 py-2 border-b border-border",children:[o("div",{className:"text-xs font-semibold text-foreground",children:"Granted scopes"}),o("div",{className:"text-[10px] text-foreground-subtle",children:"Baked into your session token at login; sign out + back in to refresh after changes."})]}),f("div",{className:"grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border",children:[o("div",{children:"Type"}),o("div",{children:"Target"}),o("div",{children:"Access"})]}),o("ul",{className:"divide-y divide-border",children:r.map((s,a)=>f("li",{className:"grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs",children:[o("span",{className:"font-mono text-foreground-subtle",children:s.type}),o("span",{className:"font-mono text-foreground",children:s.type==="device"?s.targets.join(", "):s.target}),o("div",{className:"flex items-center gap-1",children:["view","create","delete"].map(i=>{const l=s.access.includes(i),{icon:c,cls:d}=Iz[i];return f("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${l?d:"bg-transparent text-foreground-subtle/40 line-through"}`,title:l?`Can ${i}`:`Cannot ${i}`,children:[o(c,{className:"h-3 w-3"}),i]},i)})})]},a))})]}),o("div",{className:"flex justify-end",children:f("button",{onClick:t,className:"inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground transition-colors",children:[o(Kd,{className:"h-3 w-3"}),"Sign out"]})})]})}function Pz(){const e=Le(),[t,n]=_(""),[r,s]=_(""),[a,i]=_(""),[l,c]=_(null),d=Gn({mutationFn:m=>e.changeOwnPassword(m),onSuccess:()=>{c({kind:"success",msg:"Password updated."}),n(""),s(""),i("")},onError:m=>{c({kind:"error",msg:m instanceof Error?m.message:"Update failed"})}}),u=r.length>0&&a.length>0&&r!==a,p=r.length>0&&r.length<8,h=t.length>=1&&r.length>=8&&r===a;return f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("div",{className:"px-4 py-2.5 border-b border-border flex items-center gap-2",children:[o(Uy,{className:"h-3.5 w-3.5 text-foreground-subtle"}),o("div",{className:"text-xs font-semibold text-foreground",children:"Change password"})]}),f("div",{className:"p-4 space-y-3",children:[o(ll,{label:"Current password",value:t,onChange:n,autoComplete:"current-password"}),o(ll,{label:"New password",value:r,onChange:s,autoComplete:"new-password",hint:"At least 8 characters."}),o(ll,{label:"Confirm new password",value:a,onChange:i,autoComplete:"new-password"}),(u||p)&&o("div",{className:"text-[11px] text-danger",children:u?"Passwords do not match.":"New password must be at least 8 characters."}),l&&f("div",{className:`text-[11px] flex items-center gap-1 ${l.kind==="success"?"text-emerald-500":"text-danger"}`,children:[l.kind==="success"?o(xo,{className:"h-3 w-3"}):o(nr,{className:"h-3 w-3"}),l.msg]}),o("div",{className:"flex justify-end",children:f("button",{onClick:()=>{c(null),d.mutate({currentPassword:t,newPassword:r})},disabled:!h||d.isPending,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:[d.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(Gd,{className:"h-3 w-3"}),"Update password"]})})]})]})}function ll({label:e,value:t,onChange:n,autoComplete:r,hint:s}){return f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:e}),o("input",{type:"password",value:t,onChange:a=>n(a.target.value),autoComplete:r,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"}),s&&o("div",{className:"text-[10px] text-foreground-subtle",children:s})]})}function _z({username:e}){const t=Le(),n=Ln({queryKey:["auth","getOwnTotpStatus"],queryFn:()=>t.getOwnTotpStatus()}),r=n.data,[s,a]=_(null),[i,l]=_(""),[c,d]=_(null),[u,p]=_(!1),h=Gn({mutationFn:()=>t.setupOwnTotp(),onSuccess:y=>{a({secret:y.secret,otpauthUrl:y.otpauthUrl}),l(""),d(null)},onError:y=>d(y instanceof Error?y.message:"Setup failed")}),m=Gn({mutationFn:y=>t.confirmOwnTotp(y),onSuccess:()=>{a(null),l(""),d(null),n.refetch()},onError:y=>d(y instanceof Error?y.message:"Confirmation failed — code did not match")}),g=Gn({mutationFn:()=>t.disableOwnTotp(),onSuccess:()=>{d(null),n.refetch()},onError:y=>d(y instanceof Error?y.message:"Disable failed")});Y(()=>{if(!u)return;const y=setTimeout(()=>p(!1),1500);return()=>clearTimeout(y)},[u]);const b=q(()=>n.isLoading?"loading":s?"setup_in_progress":r?.enabled?"enrolled":"not_enrolled",[n.isLoading,r?.enabled,s]),x=()=>{s&&navigator.clipboard.writeText(s.secret).then(()=>p(!0))};return f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("div",{className:"px-4 py-2.5 border-b border-border flex items-center gap-2",children:[o(An,{className:"h-3.5 w-3.5 text-foreground-subtle"}),o("div",{className:"text-xs font-semibold text-foreground",children:"Two-factor authentication"})]}),f("div",{className:"p-4 space-y-3",children:[b==="loading"&&f("div",{className:"flex items-center gap-2 text-xs text-foreground-subtle",children:[o(Se,{className:"h-3.5 w-3.5 animate-spin"}),"Checking status…"]}),b==="not_enrolled"&&f(he,{children:[o("div",{className:"text-xs text-foreground-subtle",children:"2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login."}),o("div",{className:"flex justify-end",children:f("button",{onClick:()=>{d(null),h.mutate()},disabled:h.isPending,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:[h.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(An,{className:"h-3 w-3"}),"Enable 2FA"]})})]}),b==="setup_in_progress"&&s&&f(he,{children:[f("div",{className:"text-[11px] text-foreground-subtle",children:["Scan the QR code (or enter the secret manually) into your authenticator app for ",o("span",{className:"font-mono",children:e}),", then enter the 6-digit code below to confirm."]}),f("div",{className:"flex flex-col items-center gap-3",children:[o("div",{className:"rounded-lg border border-border bg-white p-3",children:o(Ez,{value:s.otpauthUrl,size:180})}),f("div",{className:"w-full",children:[o("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle mb-1",children:"Secret (manual entry)"}),f("div",{className:"flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5",children:[o("code",{className:"text-[11px] font-mono text-foreground break-all flex-1",children:s.secret}),f("button",{onClick:x,className:"inline-flex items-center gap-1 text-[10px] text-foreground-subtle hover:text-foreground",children:[u?o(xo,{className:"h-3 w-3 text-emerald-500"}):o(aa,{className:"h-3 w-3"}),u?"Copied":"Copy"]})]})]})]}),f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"6-digit code"}),o("input",{type:"text",inputMode:"numeric",autoComplete:"one-time-code",placeholder:"123456",value:i,onChange:y=>l(y.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary"})]}),c&&f("div",{className:"text-[11px] text-danger flex items-center gap-1",children:[o(nr,{className:"h-3 w-3"}),c]}),f("div",{className:"flex justify-end gap-2",children:[o("button",{onClick:()=>{a(null),d(null),l("")},className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),f("button",{onClick:()=>{d(null),m.mutate({code:i})},disabled:m.isPending||i.length!==6,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:[m.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(xo,{className:"h-3 w-3"}),"Confirm"]})]})]}),b==="enrolled"&&r&&f(he,{children:[f("div",{className:"rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2.5 flex items-start gap-2.5",children:[o(xo,{className:"h-4 w-4 mt-0.5 text-emerald-500 shrink-0"}),f("div",{className:"text-xs text-foreground space-y-0.5",children:[o("div",{className:"font-medium",children:"2FA is active"}),f("div",{className:"text-foreground-subtle",children:["Enrolled on ",r.confirmedAt?new Date(r.confirmedAt).toLocaleString():"—"]})]})]}),c&&f("div",{className:"text-[11px] text-danger flex items-center gap-1",children:[o(nr,{className:"h-3 w-3"}),c]}),o("div",{className:"flex justify-end",children:f("button",{onClick:()=>{d(null),g.mutate()},disabled:g.isPending,className:"rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1",children:[g.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(An,{className:"h-3 w-3"}),"Disable 2FA"]})})]})]})]})}function $z(){return o(nt,{children:o("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:o(Ht,{limit:500,maxHeight:"max-h-[calc(100vh-250px)]",showScope:!0,showFilters:!0})})})}function Xd({tabs:e,defaultTab:t}){const[n,r]=Ka(),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 u=new URLSearchParams(n);u.set("tab",d),r(u,{replace:!0})};return f("div",{className:"space-y-3",children:[o("div",{className:"flex border-b border-border",children:e.map(d=>{const u=d.icon,p=d.id===i;return f("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:[u&&o(u,{className:"h-3.5 w-3.5"}),d.label]},d.id)})}),o("div",{children:l?.content})]})}function Dz({userId:e,username:t,onClose:n}){const r=ke(),s=rt(),a=T0({userId:e}),i=a.data,l=()=>r.invalidateQueries({queryKey:[["userManagement","getTotpStatus"]]}),c=L0({onSuccess:()=>{l(),n()}}),d=a.isLoading?"loading":i?.enabled?"enrolled":"not_enrolled",u=async()=>{await s({title:"Remove 2FA",message:`Remove two-factor authentication for "${t}"? They'll be able to log in with just their password until they re-enroll from their own profile page.`,confirmLabel:"Remove",variant:"danger"})&&c.mutate({userId:e})};return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm p-4",children:f("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl overflow-hidden",children:[f("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[f("div",{className:"flex items-center gap-2",children:[o(An,{className:"h-4 w-4 text-primary"}),f("div",{children:[o("div",{className:"text-sm font-medium text-foreground",children:"Two-factor authentication"}),f("div",{className:"text-[11px] text-foreground-subtle",children:["User: ",o("span",{className:"font-mono",children:t})]})]})]}),o("button",{onClick:n,className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle",children:o(Fe,{className:"h-4 w-4"})})]}),f("div",{className:"p-4 space-y-4",children:[d==="loading"&&f("div",{className:"flex items-center gap-2 text-xs text-foreground-subtle",children:[o(Se,{className:"h-3.5 w-3.5 animate-spin"}),"Checking status…"]}),d==="not_enrolled"&&f("div",{className:"rounded-md border border-border bg-surface-hover/30 px-3 py-2.5 flex items-start gap-2.5 text-xs text-foreground-subtle",children:[o(rr,{className:"h-4 w-4 mt-0.5 shrink-0"}),f("div",{children:[o("div",{className:"font-medium text-foreground",children:"2FA not enrolled"}),o("p",{className:"mt-0.5",children:"Only the user themselves can enable 2FA, from their own profile page."})]})]}),d==="enrolled"&&i&&f(he,{children:[f("div",{className:"rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2.5 flex items-start gap-2.5",children:[o(xo,{className:"h-4 w-4 mt-0.5 text-emerald-500 shrink-0"}),f("div",{className:"text-xs text-foreground space-y-0.5",children:[o("div",{className:"font-medium",children:"2FA is active"}),f("div",{className:"text-foreground-subtle",children:["Enrolled on ",i.confirmedAt?new Date(i.confirmedAt).toLocaleString():"—"]})]})]}),o("div",{className:"text-[11px] text-foreground-subtle",children:"Removing here clears the server-side secret. Use this only when the user has lost access — they'll have to re-enroll from their profile page afterwards."}),f("div",{className:"flex justify-end gap-2",children:[o(Re,{onClick:n,variant:"secondary",children:"Close"}),f("button",{onClick:u,disabled:c.isPending,className:"rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1",children:[c.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(Fe,{className:"h-3 w-3"}),"Remove 2FA"]})]})]})]})]})})}function Lz(){const e=ke(),{user:t}=rn(),[n,r]=_(!1),[s,a]=_(""),[i,l]=_(""),[c,d]=_(!1),[u,p]=_(null),{data:h,isLoading:m,isError:g}=xd(),b=rt(),x=()=>e.invalidateQueries({queryKey:[["userManagement","listUsers"]]}),y=C0({onSuccess:()=>{x(),r(!1),a(""),l(""),d(!1),p(null)},onError:D=>{p(D instanceof Error?D.message:"Failed to create user")}}),w=E0({onSuccess:x}),v=M0({onSuccess:x}),N=yd({onSuccess:x}),k=I0({onSuccess:()=>{x(),M(null)}}),[C,M]=_(null),[P,I]=_(null),z=h??[];async function A(D){await b({title:"Delete user",message:`Permanently delete user "${D.username}"? This cannot be undone — any active sessions will be revoked on next request.`,confirmLabel:"Delete",variant:"danger"})&&w.mutate({id:D.id})}async function O(D){const L=window.prompt(`New password for "${D.username}":`);if(!L)return;if(L.length<8){window.alert("Password must be at least 8 characters.");return}await b({title:"Reset password",message:`Reset the password for "${D.username}"? They will need to use the new password on their next login.`,confirmLabel:"Reset"})&&N.mutate({id:D.id,newPassword:L})}function R(D,L){L!==D.isAdmin&&v.mutate({id:D.id,isAdmin:L})}function E(D){return D?new Date(typeof D=="number"?D:String(D)).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}):"—"}return f(nt,{children:[o("div",{className:"flex items-center justify-end",children:f("button",{onClick:()=>r(!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:[o(ct,{className:"h-3.5 w-3.5"}),"Create User"]})}),n&&f("div",{className:"rounded-lg border border-border bg-surface p-4 space-y-3",children:[f("div",{className:"flex items-center justify-between",children:[o("span",{className:"text-xs font-medium text-foreground",children:"New User"}),o("button",{onClick:()=>r(!1),className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-4 w-4"})})]}),f("div",{className:"grid grid-cols-3 gap-3",children:[f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Username"}),o("input",{type:"text",value:s,onChange:D=>a(D.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"})]}),f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Password"}),o("input",{type:"password",value:i,onChange:D=>l(D.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"})]}),f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Admin"}),f("label",{className:"flex items-center gap-2 rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground cursor-pointer",children:[o("input",{type:"checkbox",checked:c,onChange:D=>d(D.target.checked),className:"rounded border-border focus:ring-primary"}),o("span",{className:"text-foreground-subtle",children:"Unrestricted access"})]})]})]}),u&&o("p",{className:"text-[10px] text-danger",children:u}),f("div",{className:"flex justify-end gap-2",children:[o("button",{onClick:()=>r(!1),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),o("button",{onClick:()=>y.mutate({username:s,password:i,isAdmin:c}),disabled:y.isPending||!s||!i,className:"rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:y.isPending?"Creating...":"Create"})]})]}),m&&o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading..."}),g&&o("div",{className:"text-xs text-danger",children:"Failed to load"}),!m&&!g&&z.length===0&&o("div",{className:"text-xs text-foreground-subtle",children:"No data"}),(()=>{const D=T=>w.isPending&&w.variables?.id===T.id||v.isPending&&v.variables?.id===T.id||N.isPending&&N.variables?.id===T.id;return o($a,{columns:[{key:"username",header:"Username",render:T=>T.username},{key:"isAdmin",header:"Admin",render:T=>f("label",{className:"inline-flex items-center gap-1.5 text-xs cursor-pointer",children:[o("input",{type:"checkbox",checked:T.isAdmin,onChange:B=>R(T,B.target.checked),disabled:D(T),className:"rounded border-border focus:ring-primary disabled:opacity-50"}),o("span",{className:T.isAdmin?"text-primary font-medium":"text-foreground-subtle",children:T.isAdmin?"Admin":"Regular"})]})},{key:"scopes",header:"Scopes",render:T=>{if(T.isAdmin)return o("span",{className:"text-[10px] text-foreground-subtle italic",children:"unscoped"});const B=T.scopes??[];return f("button",{onClick:()=>M(T),className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground",title:"Edit scope grants",children:[o(gn,{className:"h-3 w-3"}),B.length===0?"no access":`${B.length} grant${B.length===1?"":"s"}`]})}},{key:"createdAt",header:"Created",render:T=>o("span",{className:"text-foreground-subtle",children:E(T.createdAt)})},{key:"actions",header:"Actions",align:"right",render:T=>{const B=D(T),F=T.id!==t?.id&&T.totpEnabled;return f("div",{className:"flex items-center justify-end gap-1",children:[F&&f("button",{onClick:()=>I(T),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:"Remove two-factor authentication",children:[o(An,{className:"h-3 w-3"}),"Remove 2FA"]}),f("button",{onClick:()=>O(T),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:[o(C6,{className:"h-3 w-3"}),"Reset password"]}),f("button",{onClick:()=>A(T),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?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ze,{className:"h-3 w-3"}),"Delete"]})]})}}],rows:z,rowKey:T=>T.id,minWidthPx:560})})(),P&&o(Dz,{userId:P.id,username:P.username,onClose:()=>I(null)}),C&&o(Tz,{user:C,onClose:()=>M(null),onSubmit:D=>k.mutate({userId:C.id,scopes:D}),submitting:k.isPending})]})}function Tz(e){const{user:t}=rn(),n=t?.isAdmin===!0;return o(Rz,{...e,callerScopes:n?null:t?.scopes??[]})}function Rz({user:e,onClose:t,onSubmit:n,submitting:r,callerScopes:s}){const a=q(()=>(e.scopes??[]).map(d=>({...d,access:[...d.access]})),[e.scopes]),[i,l]=_(a),c=Pd(i);return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:f("div",{className:"w-full max-w-2xl rounded-lg border border-border bg-surface shadow-xl",children:[f("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[f("div",{children:[f("div",{className:"text-sm font-semibold text-foreground",children:["Edit scopes — ",e.username]}),o("div",{className:"text-[10px] text-foreground-subtle",children:e.isAdmin?"Admin users bypass the scope check; this list is ignored.":"Pick which capabilities this user can call, and which access flavours within each."})]}),o("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-4 w-4"})})]}),f("div",{className:"px-4 py-4",children:[o(Ad,{value:i,onChange:l,clampToParent:s,emptyHint:f(he,{children:["No scopes granted. ",o("span",{className:"font-medium text-foreground",children:e.username})," cannot call any protected endpoint until a scope is added."]})}),c&&o("p",{className:"mt-2 text-[10px] text-danger",children:c})]}),f("div",{className:"flex items-center justify-end gap-2 border-t border-border px-4 py-3",children:[o("button",{onClick:t,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),o("button",{onClick:()=>n(i),disabled:r||c!==null,className:"rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:r?o(Se,{className:"h-3 w-3 animate-spin"}):"Save scopes"})]})]})})}const Oz="bg-primary/10 text-primary",Bz="bg-foreground-subtle/10 text-foreground-subtle";function ko(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString()}function zz(e){return e?e==="*"?"*":e.join(", "):""}function Fz(){const e=ke(),t=rt(),{data:n,isLoading:r}=A0(),{data:s}=xd(),a=q(()=>n??[],[n]),i=q(()=>s??[],[s]),l=()=>e.invalidateQueries({queryKey:[["userManagement","listApiKeys"]]}),c=()=>e.invalidateQueries({queryKey:[["userManagement","listScopedTokens"]]}),[d,u]=_(!1),[p,h]=_(null),m=P0({onSuccess:l}),g=_0({onSuccess:({token:w,record:v})=>{c(),u(!1),h({token:w,label:v.name})}}),b=$0({onSuccess:c}),x=async(w,v)=>{await t({title:`Revoke "${v}"?`,message:"Any client using this token will lose access immediately. This cannot be undone.",confirmLabel:"Revoke",variant:"danger"})&&m.mutate({id:w})},y=async(w,v)=>{await t({title:`Revoke "${v}"?`,message:"The scoped token will be invalid on its next use.",confirmLabel:"Revoke",variant:"danger"})&&b.mutate({id:w})};return f(nt,{children:[f("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[o("p",{className:"text-xs text-foreground-subtle max-w-2xl",children:"Issue scoped tokens to grant a user a narrow surface — a specific addon, integration, or capability. Every token MUST be scoped: revoking it has predictable blast radius."}),f("button",{onClick:()=>u(!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:[o(gn,{className:"h-3.5 w-3.5"}),"New token"]})]}),f(Mf,{title:"Scoped tokens",subtitle:"Grouped per user",children:[i.length===0&&o(Vz,{text:"No users yet — scoped tokens are issued on behalf of an existing user."}),i.map(w=>o(Hz,{userId:w.id,username:w.username,onRevoke:(v,N)=>{y(v,N)},revokePending:b.isPending,revokeId:b.variables?.id},w.id))]}),a.length>0&&o(Mf,{title:"Legacy API keys",subtitle:`${a.length} pre-existing — revoke only`,children:o(zv,{headers:["Label","Admin","Prefix","Allowed providers","Created","Last used",""],rows:a.map(w=>{const v=!!w.isAdmin,N=m.isPending&&m.variables?.id===w.id;return f("tr",{className:"hover:bg-primary/5",children:[o("td",{className:"px-3 py-2 text-foreground border-b border-border font-medium",children:w.label}),o("td",{className:"px-3 py-2 text-foreground border-b border-border",children:o("span",{className:`inline-block rounded px-2 py-0.5 text-[10px] uppercase tracking-wide ${v?Oz:Bz}`,children:v?"admin":"regular"})}),f("td",{className:"px-3 py-2 text-foreground border-b border-border font-mono text-[11px]",children:[w.tokenPrefix,"…"]}),o("td",{className:"px-3 py-2 text-foreground border-b border-border text-foreground-subtle",children:zz(w.allowedProviders)||"all"}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:ko(w.createdAt)}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:ko(w.lastUsedAt)}),o("td",{className:"px-3 py-2 border-b border-border text-right",children:f("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?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ze,{className:"h-3 w-3"}),"Revoke"]})})]},w.id)})})}),r&&o(jz,{}),d&&o(qz,{users:i.map(w=>({id:w.id,username:w.username})),onClose:()=>u(!1),onSubmit:w=>g.mutate({userId:w.userId,name:w.name,scopes:w.scopes,...w.expiresAt!==void 0?{expiresAt:w.expiresAt}:{}}),submitting:g.isPending}),p&&o(Uz,{token:p.token,label:p.label,onClose:()=>h(null)})]})}function Mf({title:e,subtitle:t,children:n}){return f("div",{className:"space-y-2",children:[f("div",{className:"flex items-baseline justify-between",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:e}),t&&o("span",{className:"text-[10px] text-foreground-subtle",children:t})]}),n]})}function jz(){return o("div",{className:"space-y-2",children:[1,2].map(e=>o("div",{className:"h-10 rounded border border-border bg-surface animate-pulse"},e))})}function Vz({text:e}){return o("div",{className:"rounded border border-dashed border-border bg-surface px-3 py-4 text-xs text-foreground-subtle text-center",children:e})}function zv({headers:e,rows:t}){return o("div",{className:"rounded-lg border border-border bg-surface overflow-x-auto",children:f("table",{className:"w-full text-xs min-w-[640px]",children:[o("thead",{children:o("tr",{children:e.map((n,r)=>o("th",{className:`px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border whitespace-nowrap ${r===e.length-1?"text-right":"text-left"}`,children:n},r))})}),o("tbody",{children:t})]})})}function Hz({userId:e,username:t,onRevoke:n,revokePending:r,revokeId:s}){const{data:a,isLoading:i}=D0({userId:e}),l=a??[];return i||l.length===0?null:f("div",{className:"space-y-1.5",children:[o("div",{className:"text-[11px] font-medium text-foreground",children:t}),o(zv,{headers:["Name","Prefix","Scopes","Expires","Last used","Created",""],rows:l.map(c=>{const d=r&&s===c.id;return f("tr",{className:"hover:bg-primary/5",children:[o("td",{className:"px-3 py-2 text-foreground border-b border-border font-medium",children:c.name}),f("td",{className:"px-3 py-2 text-foreground border-b border-border font-mono text-[11px]",children:[c.tokenPrefix,"…"]}),o("td",{className:"px-3 py-2 text-foreground border-b border-border",children:o("div",{className:"flex flex-wrap gap-1",children:c.scopes.map((u,p)=>f("span",{className:"inline-block rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-mono",children:[u.type,":",u.type==="device"?`[${u.targets.join(",")}]`:u.target]},p))})}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:ko(c.expiresAt)}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:ko(c.lastUsedAt)}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:ko(c.createdAt)}),o("td",{className:"px-3 py-2 border-b border-border text-right",children:f("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?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ze,{className:"h-3 w-3"}),"Revoke"]})})]},c.id)})})]})}function qz({users:e,onClose:t,onSubmit:n,submitting:r}){const{user:s}=rn(),i=s?.isAdmin===!0?null:s?.scopes??[],[l,c]=_(e[0]?.id??""),[d,u]=_(""),[p,h]=_([{type:"capability",target:"",access:["view","create"]}]),[m,g]=_(""),b=Pd(p),x=l!==""&&d.trim().length>0&&p.length>0&&b===null&&!r,y=()=>{const w=parseInt(m,10),v=Number.isFinite(w)&&w>0?Date.now()+w*864e5:void 0;n({userId:l,name:d.trim(),scopes:p,expiresAt:v})};return f(Fv,{title:"Create scoped token",onClose:t,children:[f("div",{className:"space-y-3",children:[o(Is,{label:"On behalf of user",children:o("select",{value:l,onChange:w=>c(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=>o("option",{value:w.id,children:w.username},w.id))})}),o(Is,{label:"Name",children:o("input",{value:d,onChange:w=>u(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"})}),f(Is,{label:"Scopes",hint:"Each scope picks a (cap or addon) target + one or more access flavours. The token can access ONLY what's listed.",children:[o(Ad,{value:p,onChange:h,clampToParent:i}),b&&o("p",{className:"mt-1 text-[10px] text-danger",children:b})]}),o(Is,{label:"Expires in (days)",hint:"Leave blank for non-expiring.",children:o("input",{type:"number",min:1,value:m,onChange:w=>g(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"})})]}),f(jv,{children:[o("button",{onClick:t,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),f("button",{onClick:y,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:[r?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(gn,{className:"h-3.5 w-3.5"}),"Issue token"]})]})]})}function Uz({token:e,label:t,onClose:n}){const[r,s]=_(!1),a=async()=>{try{await navigator.clipboard.writeText(e),s(!0)}catch{}};return f(Fv,{title:`Token: ${t}`,onClose:n,children:[f("div",{className:"space-y-3",children:[o("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."}),o("div",{className:"rounded border border-border bg-background p-2 font-mono text-[11px] break-all select-all",children:e})]}),f(jv,{children:[f("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:[r?o(_t,{className:"h-3.5 w-3.5 text-primary"}):o(aa,{className:"h-3.5 w-3.5"}),r?"Copied":"Copy"]}),o("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 Fv({title:e,onClose:t,children:n}){return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:t,children:f("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:r=>r.stopPropagation(),children:[f("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:e}),o("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-4 w-4"})})]}),o("div",{className:"p-4",children:n})]})})}function jv({children:e}){return o("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:e})}function Is({label:e,hint:t,children:n}){return f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:e}),n,t&&o("p",{className:"text-[10px] text-foreground-subtle",children:t})]})}function Qz({addonId:e,fallback:t,tileClassName:n,iconPath:r="assets/icon.svg"}){const[s,a]=_(!1),i=`/api/addon-assets/${e}/${r}`;return o("div",{className:`h-10 w-10 rounded-lg flex items-center justify-center shrink-0 ${n}`,children:s?o(t,{className:"h-5 w-5"}):o("img",{src:i,alt:e,className:"h-6 w-6",onError:()=>a(!0)})})}function oi(e){const{title:t,subtitle:n,pageIcon:r,itemIcon:s,capability:a,installButtonLabel:i="Add addon",items:l,isLoading:c,emptyTitle:d="No addons installed for this capability",emptyDescription:u,itemIconColor:p,renderStatusBadges:h,renderActionButtons:m,renderExpandedBody:g,itemError:b,trailing:x,showChrome:y=!1}=e,w=l.length>1,[v,N]=_(()=>l[0]?.addonId??null);Y(()=>{v&&(l.some(M=>M.addonId===v)||N(l[0]?.addonId??null))},[l,v]);const k=M=>N(P=>P===M?null:M),C=a?`/system/addons?capability=${encodeURIComponent(a)}`:null;return o(nt,{icon:y?r:void 0,title:y?t:void 0,subtitle:y?n:void 0,actions:y&&C?o(tr,{to:C,children:f(Re,{variant:"primary",size:"sm",children:[o(ct,{className:"h-3.5 w-3.5 mr-1"}),i]})}):void 0,children:c?o(Ft,{children:o("div",{className:"p-6 text-sm text-foreground-subtle",children:"Loading…"})}):l.length===0?o(Ft,{children:o(Ra,{title:d,description:u??(C?`Install an addon that declares the "${a}" capability to get started.`:void 0),action:y&&C?o(tr,{to:C,children:f(Re,{variant:"primary",size:"sm",children:[o(ct,{className:"h-3.5 w-3.5 mr-1"}),i]})}):void 0})}):f("div",{className:"flex flex-col gap-4",children:[l.map(M=>{const P=!w||v===M.addonId,I=p?.(M)??"bg-primary/15 text-primary",z=b?.(M)??null,A=g?.(M),O=z!==null||A!=null;return f(Ft,{children:[f("div",{className:`flex items-center gap-3 p-4 ${P&&O?"border-b border-border":""}`,children:[w&&o("button",{type:"button",onClick:()=>k(M.addonId),"aria-label":P?"Collapse":"Expand",className:"shrink-0 p-1 rounded hover:bg-foreground-subtle/10 transition-colors",children:o(lt,{className:`h-4 w-4 text-foreground-subtle transition-transform ${P?"rotate-180":""}`})}),f("button",{type:"button",onClick:()=>w&&k(M.addonId),className:`flex items-center gap-4 flex-1 min-w-0 text-left ${w?"hover:opacity-80 transition-opacity":""}`,disabled:!w,children:[o(Qz,{addonId:M.addonId,fallback:s,tileClassName:I}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"font-semibold text-foreground",children:M.displayName}),h?.(M)]}),f("div",{className:"text-xs text-foreground-subtle mt-1 font-mono",children:["@camstack/addon-",M.addonId]})]})]}),m&&o("div",{className:"flex items-center gap-1 shrink-0",children:m(M)})]}),P&&f(he,{children:[z!==null&&o("div",{className:"p-4 pb-0",children:o(Oa,{message:z})}),A]})]},M.addonId)}),x]})})}function si({addonId:e,defaultActivity:t,showActivity:n=!0,maxHeight:r="max-h-64",defaultTab:s}){const a=t??(s==="events"?"events":"logs"),[i,l]=_(a);return f("div",{className:"flex flex-col gap-4",children:[o(to,{nodeId:"hub",addonIds:[e],level:"global"}),n&&f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border bg-surface-hover/20",children:[o("span",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Activity"}),f("div",{className:"flex items-center gap-1",children:[o(Ef,{kind:"logs",active:i==="logs",onClick:()=>l("logs")}),o(Ef,{kind:"events",active:i==="events",onClick:()=>l("events")})]})]}),i==="logs"?o(Ht,{addonId:e,maxHeight:r,showFilters:!1}):o(br,{addonId:e,category:"addon.*",maxHeight:r})]})]})}function Ef({kind:e,active:t,onClick:n}){return f("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:[o(e==="logs"?it:es,{className:"h-3 w-3"}),e==="logs"?"Logs":"Events"]})}function Gz(e){const t=e.kind??"";return t==="local"||e.addonId==="local-auth"?{headline:"Username + password (local).",icon:Qy,bullets:["Users live in the hub’s SQLite database — no IdP roundtrip.","TOTP / 2FA can be enrolled per-user from the Users page (added in v0.4).","API keys + scoped tokens are managed from the API Keys page."],setupSteps:["Add users from Users → New user (or seed via CAMSTACK_ADMIN_USER / CAMSTACK_ADMIN_PASS).","Hand out either passwords or scoped tokens — both validate through this provider."]}:t==="oidc"||e.addonId.startsWith("auth-oidc")?{headline:"OpenID Connect (Google, Microsoft, Okta, Keycloak, …).",icon:hn,bullets:["Three-leg redirect flow with PKCE S256 + nonce.","id_token is signature-verified against the IdP’s JWKS — no implicit trust.","First-time sign-ins are auto-provisioned with the configured Default Role."],setupSteps:["Register a web app at your IdP and copy the client_id + client_secret.","Set the redirect URI to `https://<this-hub>/addon/<addon-id>/callback`.","Paste issuer + credentials in the Settings panel below — saves on every change."]}:t==="saml"?{headline:"SAML 2.0 — enterprise SSO (Azure AD, Okta, OneLogin).",icon:hn,bullets:["Heavier handshake than OIDC — exchange metadata XML with your IdP.","Group → role mapping via SAML assertions."]}:t==="webauthn"||t==="passkey"?{headline:"Passkeys / WebAuthn — passwordless second factor.",icon:An,bullets:["Enroll a YubiKey, Touch ID, or platform passkey per user.","Resistant to phishing — the browser binds the credential to your hub origin."]}:t==="totp"?{headline:"TOTP — six-digit codes from any authenticator app.",icon:An,bullets:["Second factor on top of password (RFC 6238, ±30 s clock skew).","Compatible with Google Authenticator, Aegis, 1Password, Bitwarden, etc."]}:{headline:e.displayName,icon:gn,bullets:["Generic authentication provider. No additional hints registered."]}}function Kz(){const e=od(),t=e.data??[];return o(oi,{title:"Authentication",subtitle:"Identity providers exposed to the admin UI. Multiple providers can run in parallel — operators pick which to enable. Each provider’s settings + live logs are inline below; no redirect to /system/addons.",pageIcon:gn,itemIcon:gn,capability:"auth-provider",installButtonLabel:"Add provider",items:t,isLoading:e.isLoading,emptyTitle:"No authentication providers registered",emptyDescription:"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.",itemIconColor:n=>n.enabled?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle",renderStatusBadges:n=>f(he,{children:[!n.enabled&&o("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"}),n.hasCredentialFlow&&f("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:[o(Qy,{className:"inline h-2.5 w-2.5 mr-0.5"}),"Credential"]}),n.hasRedirectFlow&&f("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:[o(hn,{className:"inline h-2.5 w-2.5 mr-0.5"}),"Redirect SSO"]}),n.status&&f("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300",children:[o(tt,{className:"inline h-2.5 w-2.5 mr-0.5"}),n.status]})]}),renderExpandedBody:n=>{const r=Gz(n),s=r.icon;return f(he,{children:[f("div",{className:"p-4 space-y-3 border-b border-border",children:[f("div",{className:"flex items-start gap-2.5",children:[o(s,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),o("div",{className:"text-xs text-foreground font-medium",children:r.headline})]}),o("ul",{className:"text-xs text-foreground-subtle space-y-1.5 pl-6 list-disc",children:r.bullets.map((a,i)=>o("li",{children:a},i))}),r.setupSteps&&r.setupSteps.length>0&&f("div",{className:"rounded-md border border-border bg-surface-hover/40 px-3 py-2.5 space-y-1.5",children:[f("div",{className:"flex items-center gap-1.5 text-[10px] font-semibold text-foreground-subtle uppercase tracking-wide",children:[o(ER,{className:"h-3 w-3"}),"Setup steps"]}),o("ol",{className:"text-xs text-foreground space-y-0.5 pl-4 list-decimal",children:r.setupSteps.map((a,i)=>o("li",{children:a},i))})]}),n.addonId==="local-auth"&&f("div",{className:"rounded-md border border-blue-500/30 bg-blue-500/5 px-3 py-2 flex items-start gap-2 text-[11px] text-foreground",children:[o(rr,{className:"h-3.5 w-3.5 mt-0.5 text-blue-500 shrink-0"}),f("span",{children:["TOTP / 2FA settings are exposed per-user from the"," ",o("a",{href:"/system/users",className:"underline text-primary",children:"Users"})," page (added in v0.4). Enable for each user via the Actions column → “Enable TOTP”."]})]})]}),o("div",{className:"p-4",children:o(si,{addonId:n.addonId,maxHeight:"max-h-64"})})]})}})}function Wz(){return o("div",{className:"flex flex-col p-4",children:o(Xd,{tabs:[{id:"users",label:"Users",icon:QO,content:o(Lz,{})},{id:"api-keys",label:"Tokens",icon:Uy,content:o(Fz,{})},{id:"authentication",label:"Authentication",icon:gn,content:o(Kz,{})}]})})}function Yz(){const e=ke(),t=m0(void 0,{refetchInterval:5e3}),n=t.data??[],[r,s]=_(null),[a,i]=_({}),l=(p,h)=>{e.invalidateQueries({queryKey:[["remoteAccess"]]}),s(null),i(m=>{if(!(h.addonId in m))return m;const g={...m};return delete g[h.addonId],g})},c=(p,h)=>{s(null);const m=p instanceof Error?p.message:String(p);i(g=>({...g,[h.addonId]:m}))},d=g0({onSuccess:l,onError:c}),u=b0({onSuccess:l,onError:c});return o(oi,{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.",pageIcon:hn,itemIcon:hn,capability:"network-access",installButtonLabel:"Add tunnel",items:n,isLoading:t.isLoading,emptyTitle:"No remote-access providers installed",emptyDescription:"Install a tunnel addon (e.g. @camstack/addon-cloudflare-tunnel) to expose this hub publicly.",itemIconColor:p=>p.connected?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle",renderStatusBadges:p=>f(he,{children:[o("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${p.connected?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:p.connected?"Connected":"Disconnected"}),p.endpoint&&f("a",{href:p.endpoint.url,target:"_blank",rel:"noopener noreferrer",onClick:h=>h.stopPropagation(),className:"text-[10px] text-emerald-700 dark:text-emerald-300 hover:underline flex items-center gap-1",children:[o(Qd,{className:"h-3 w-3"}),p.endpoint.url]})]}),itemError:p=>p.error??null,renderActionButtons:p=>{const h=r===p.addonId;return p.connected?f(Re,{size:"sm",variant:"secondary",disabled:h,onClick:()=>{s(p.addonId),u.mutate({addonId:p.addonId})},children:[h?o(Se,{className:"h-3 w-3 animate-spin"}):o(ns,{className:"h-3 w-3"}),"Stop"]}):f(Re,{size:"sm",variant:"primary",disabled:h,onClick:()=>{s(p.addonId),d.mutate({addonId:p.addonId})},children:[h?o(Se,{className:"h-3 w-3 animate-spin"}):o(Za,{className:"h-3 w-3"}),"Start"]})},renderExpandedBody:p=>f("div",{className:"p-4 space-y-3",children:[a[p.addonId]&&o(Oa,{title:"Operation failed",message:a[p.addonId]}),o(si,{addonId:p.addonId,maxHeight:"max-h-72"})]})})}function Zz(){const e=ke(),t=N0(void 0,{refetchInterval:3e4}),n=k0(),r=t.data??[],s=n.data??[],[a,i]=_(null),l=S0({onSuccess:()=>{e.invalidateQueries({queryKey:[["turnOrchestrator"]]}),i(null)},onError:()=>i(null)});return o(oi,{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.",pageIcon:_n,itemIcon:_n,capability:"turn-provider",installButtonLabel:"Add provider",items:r,isLoading:t.isLoading,emptyTitle:"No TURN providers installed",emptyDescription:"Install a TURN addon (e.g. @camstack/addon-cloudflare-turn) to enable WebRTC behind restrictive NATs.",itemIconColor:c=>c.error?"bg-danger/15 text-danger":c.enabled?"bg-violet-500/15 text-violet-700 dark:text-violet-300":"bg-foreground-subtle/15 text-foreground-subtle",renderStatusBadges:c=>f(he,{children:[o("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${c.enabled?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:c.enabled?"Enabled":"Disabled"}),f("span",{className:"text-[10px] text-foreground-subtle",children:["· ",c.serverCount," server",c.serverCount===1?"":"s"]})]}),itemError:c=>c.error??null,renderActionButtons:c=>{const d=a===c.addonId;return c.enabled?f(Re,{size:"sm",variant:"secondary",disabled:d,onClick:()=>{i(c.addonId),l.mutate({addonId:c.addonId,enabled:!1})},children:[d?o(Se,{className:"h-3 w-3 animate-spin"}):o(ns,{className:"h-3 w-3"}),"Disable"]}):f(Re,{size:"sm",variant:"primary",disabled:d,onClick:()=>{i(c.addonId),l.mutate({addonId:c.addonId,enabled:!0})},children:[d?o(Se,{className:"h-3 w-3 animate-spin"}):o(Za,{className:"h-3 w-3"}),"Enable"]})},renderExpandedBody:c=>f(he,{children:[c.urls.length>0&&f("div",{className:"px-4 py-3 border-b border-border",children:[f("div",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide mb-2",children:["Discovered ICE servers (",c.urls.length,")"]}),o("div",{className:"flex flex-wrap gap-1",children:c.urls.map(d=>o("span",{className:"inline-block rounded px-1.5 py-0.5 text-[10px] font-mono bg-foreground-subtle/10 text-foreground",children:d},d))})]}),o("div",{className:"p-4",children:o(si,{addonId:c.addonId,maxHeight:"max-h-72"})})]}),trailing:f(Ft,{children:[f("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[f("div",{children:[o("div",{className:"text-sm font-semibold",children:"Combined ICE server list"}),o("div",{className:"text-xs text-foreground-subtle",children:"What the WebRTC layer fetches per-session."})]}),o(Re,{size:"sm",variant:"secondary",onClick:()=>n.refetch(),disabled:n.isFetching,children:"Refresh"})]}),o("div",{className:"p-4",children:s.length===0?o("div",{className:"text-xs text-foreground-subtle",children:"No servers from enabled providers."}):o("div",{className:"flex flex-col gap-3",children:s.map((c,d)=>{const u=Array.isArray(c.urls)?c.urls:[c.urls];return f("div",{className:"rounded border border-border bg-surface",children:[(c.username||c.credential)&&f("div",{className:"px-3 py-1.5 border-b border-border text-[10px] font-mono text-foreground-subtle flex items-center gap-3",children:[c.username&&f("span",{children:[o("span",{className:"text-foreground-subtle",children:"user:"})," ",o("span",{className:"text-foreground",children:c.username})]}),c.credential&&f("span",{title:c.credential,children:[o("span",{className:"text-foreground-subtle",children:"credential:"})," ",o("span",{className:"text-foreground",children:`${c.credential.slice(0,8)}…${c.credential.slice(-4)}`})]})]}),o("ul",{className:"divide-y divide-border",children:u.map(p=>o("li",{className:"px-3 py-1.5 font-mono text-xs text-foreground break-all",children:p},p))})]},d)})})})]})})}const Xz={lan:_n,wifi:or,docker:Ya,vpn:Gd,loopback:mn,other:mn},Jz={lan:"LAN",wifi:"Wi-Fi",docker:"Docker",vpn:"VPN",loopback:"Loopback",other:"Other"},eF=["lan","wifi","vpn","docker","other","loopback"];function tF(e){const{interfaces:t,disabled:n,hideLoopback:r,ipv4Only:s,emptyMessage:a}=e,i=q(()=>t.filter(u=>!(r&&u.kind==="loopback"||s&&u.family!=="IPv4")),[t,r,s]),l=q(()=>{const u=new Map;for(const p of i){const h=u.get(p.kind)??[];h.push(p),u.set(p.kind,h)}return eF.filter(p=>u.has(p)).map(p=>({kind:p,items:u.get(p)}))},[i]),c=u=>e.mode==="single"?e.value===u:e.value.includes(u),d=u=>{if(n||u.kind==="loopback")return;if(e.mode==="single"){e.onChange(e.value===u.address?null:u.address);return}const p=new Set(e.value);p.has(u.address)?p.delete(u.address):p.add(u.address),e.onChange([...p])};return i.length===0?o("div",{className:"text-xs text-foreground-subtle italic",children:a??"No addresses available."}):o("div",{className:"flex flex-col gap-3",children:l.map(({kind:u,items:p})=>{const h=Xz[u]??mn;return f("div",{className:"rounded-md border border-border overflow-hidden",children:[f("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border",children:[o(h,{className:"h-3.5 w-3.5 text-foreground-subtle"}),o("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle",children:Jz[u]??u}),f("span",{className:"text-[10px] text-foreground-subtle",children:["· ",p.length]})]}),o("ul",{className:"divide-y divide-border",children:p.map(m=>{const g=c(m.address),b=m.kind==="loopback",x=!m.plausible&&!b;return f("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(m),children:[o("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&&o(_t,{className:"h-3 w-3"})}),f("div",{className:`flex-1 min-w-0 ${x?"text-foreground-subtle":""}`,children:[f("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:`font-mono text-xs font-semibold ${x?"text-foreground-subtle":"text-foreground"}`,children:m.name}),o("span",{className:"text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono",children:m.family}),m.preferred&&o("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary",children:"Auto-preferred"}),b&&o("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle",children:"Always included"}),x&&f("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:m.plausibleReason||void 0,children:[o(tt,{className:"h-2.5 w-2.5"}),"Unlikely usable"]})]}),f("div",{className:"text-xs text-foreground-subtle mt-0.5 font-mono break-all",children:[m.address,m.cidr&&m.cidr!==m.address?` (${m.cidr})`:""]})]})]},`${m.name}-${m.family}-${m.address}`)})})]},u)})})}const If={"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 nF(){const e=ke(),t=Le(),n=cx(void 0,{refetchInterval:3e4}),r=ux(void 0),s=px({onSuccess:()=>{e.invalidateQueries({queryKey:[["localNetwork"]]})}}),a=fx({onSuccess:C=>{p(C.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=dx({port:l,scheme:c},{refetchInterval:3e4}),[u,p]=_([]),[h,m]=_(!1);Y(()=>{!h&&r.data&&(p(r.data.addresses),m(!0))},[r.data,h]);const g=r.data?.addresses??[],b=q(()=>{if(u.length!==g.length)return!0;const C=[...u].sort(),M=[...g].sort();return C.some((P,I)=>P!==M[I])},[u,g]),x=()=>{s.mutate({addresses:[...u]})},y=()=>{p(g)},w=()=>{p([])},v=()=>{n.refetch(),d.refetch(),r.refetch()},N=async()=>{try{const C=await t.raceConnectionEndpoints({perCandidateTimeoutMs:1500});console.info("[network-addresses] race result",C)}catch(C){console.warn("[network-addresses] race failed",C)}},k=d.data?.endpoints??[];return f(nt,{children:[f("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[o("p",{className:"text-xs text-foreground-subtle max-w-2xl",children:"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."}),f("div",{className:"flex items-center gap-2 shrink-0",children:[f(Re,{size:"sm",variant:"secondary",onClick:v,disabled:n.isLoading,children:[o(dt,{className:`h-3 w-3 ${n.isLoading?"animate-spin":""}`}),"Refresh"]}),o(Re,{size:"sm",variant:"secondary",onClick:N,children:"Probe race"})]})]}),f("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[f(Ft,{children:[f("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[f("div",{children:[o("div",{className:"text-sm font-semibold",children:"Allowed addresses"}),o("div",{className:"text-xs text-foreground-subtle",children:u.length===0?"Auto — every non-loopback / non-link-local interface participates.":`${u.length} pinned`})]}),f("div",{className:"flex items-center gap-1",children:[f(Re,{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:[o(DO,{className:"h-3 w-3"}),a.isPending?"Detecting…":"Best match"]}),f(Re,{size:"sm",variant:"secondary",onClick:w,disabled:u.length===0||s.isPending,children:[o(Xy,{className:"h-3 w-3"}),"Clear"]}),b&&o(Re,{size:"sm",variant:"secondary",onClick:y,disabled:s.isPending,children:"Discard"}),f(Re,{size:"sm",variant:"primary",onClick:x,disabled:!b||s.isPending,children:[o(mO,{className:"h-3 w-3"}),s.isPending?"Saving…":"Save"]})]})]}),o("div",{className:"p-4",children:o(tF,{mode:"multiple",interfaces:i,value:u,onChange:p,disabled:s.isPending,emptyMessage:n.isLoading?"Loading interfaces…":"No interfaces detected."})})]}),f(Ft,{children:[f("div",{className:"px-4 py-3 border-b border-border",children:[o("div",{className:"text-sm font-semibold",children:"Connection endpoints — priority order"}),o("div",{className:"text-xs text-foreground-subtle",children:"Live preview of the ranked candidate list the SDK would race against. Updates with each Save."})]}),o("div",{className:"p-4",children:k.length===0?o("div",{className:"text-xs text-foreground-subtle italic",children:d.isLoading?"Loading…":"No endpoints available."}):o("ul",{className:"space-y-1 text-xs",children:k.map(C=>f("li",{className:`flex items-center gap-2 flex-wrap ${C.plausible?"":"opacity-80"}`,children:[o("span",{className:"font-mono text-[10px] w-10 text-foreground-subtle",children:String(C.priority).padStart(4,"0")}),o("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${If[C.kind]??If.loopback}`,children:C.kind}),C.interfaceKind!=="lan"&&C.interfaceKind!=="public"&&o("span",{className:"text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-medium uppercase",children:C.interfaceKind}),!C.plausible&&C.interfaceKind!=="loopback"&&f("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:C.plausibleReason||void 0,children:[o(tt,{className:"h-2.5 w-2.5"}),"Unlikely usable"]}),o("span",{className:`font-mono break-all ${C.plausible?"text-foreground":"text-foreground-subtle"}`,children:C.baseUrl}),f("span",{className:"text-foreground-subtle",children:["— ",C.label]})]},`${C.priority}-${C.baseUrl}`))})})]})]})]})}const rF={mesh:"bg-violet-500/15 text-violet-700 dark:text-violet-300",public:"bg-blue-500/15 text-blue-700 dark:text-blue-300"},oF=5e3,sF=3e4;function aF(){const e=hx(void 0,{refetchInterval:oF}),t=e.data??[];return o(oi,{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).",pageIcon:Ya,itemIcon:_n,capability:"mesh-network",installButtonLabel:"Add mesh",items:t,isLoading:e.isLoading,emptyTitle:"No mesh-network providers installed",emptyDescription:"Install a mesh addon (e.g. @camstack/addon-tailscale-client) to join this hub into a private VPN mesh.",itemIconColor:n=>n.joined?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle",renderStatusBadges:n=>f(he,{children:[o("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${n.joined?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:n.joined?"Joined":"Not joined"}),n.joined&&f("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle",children:[n.peerCount," peer",n.peerCount===1?"":"s"]})]}),renderActionButtons:n=>o(iF,{addonId:n.addonId,joined:n.joined}),itemError:n=>n.error??null,renderExpandedBody:n=>o(lF,{provider:n})})}function iF({addonId:e,joined:t}){const n=ke(),[r,s]=_(!1),[a,i]=_(null),l=Le(),c=U(()=>{n.invalidateQueries({queryKey:[["meshOrchestrator"]]})},[n]),d=gx(),u=mx({onSuccess:c}),p=bx({onSuccess:c}),h=Wo({onSuccess:c}),m=U(async()=>{s(!0);const b={cancelled:!1};i(b);try{const x=await d.mutateAsync({addonId:e});if(b.cancelled)return;x.loginUrl&&window.open(x.loginUrl,"_blank","noopener,noreferrer");const y=Date.now(),w=10*6e4;for(;!b.cancelled&&(await hF(2e3),!b.cancelled);){if((await l.trpcClient.meshOrchestrator.listProviders.query().catch(()=>null))?.find(k=>k.addonId===e)?.joined){c();break}if(Date.now()-y>w)break}}finally{s(!1),i(null)}},[e,c,d,l]),g=U(()=>{a&&(a.cancelled=!0),s(!1),i(null)},[a]);return f("div",{className:"flex items-center gap-2",children:[t?f(he,{children:[f(Re,{size:"sm",variant:"secondary",disabled:u.isPending,onClick:()=>u.mutate({addonId:e}),children:[u.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(Kd,{className:"h-3 w-3"}),"Disconnect"]}),f(Re,{size:"sm",variant:"ghost",disabled:p.isPending,onClick:()=>p.mutate({addonId:e}),children:[p.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(Fp,{className:"h-3 w-3"}),"Log out"]})]}):r?f(Re,{size:"sm",variant:"ghost",onClick:g,children:[o(Fe,{className:"h-3 w-3 mr-1"})," Cancel"]}):f(he,{children:[f(Re,{size:"sm",variant:"primary",onClick:()=>void m(),children:[o(L6,{className:"h-3 w-3"}),"Connect"]}),f(Re,{size:"sm",variant:"ghost",disabled:p.isPending,onClick:()=>p.mutate({addonId:e}),children:[p.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(Fp,{className:"h-3 w-3"}),"Log out"]})]}),o(Md,{label:"Restart",icon:dt,size:"sm",title:`Restart "${e}"?`,description:"Restarting the addon bounces its subprocess — the mesh connection will briefly drop and reconnect automatically.",confirmLabel:"Restart",triggerVariant:"ghost",confirmVariant:"danger",disabled:h.isPending,action:()=>h.mutateAsync({addonId:e})})]})}function lF({provider:e}){const[t,n]=_("status"),r=xx({addonId:e.addonId},{refetchInterval:t==="peers"?sF:!1,enabled:t==="peers"});return f("div",{children:[f("div",{className:"px-4 pt-3 flex items-center gap-1 border-b border-border",children:[o(As,{active:t==="status",onClick:()=>n("status"),children:"Status"}),o(As,{active:t==="peers",onClick:()=>n("peers"),children:"Peers"}),o(As,{active:t==="settings",onClick:()=>n("settings"),children:"Settings"}),o(As,{active:t==="logs",onClick:()=>n("logs"),children:"Logs"})]}),t==="status"&&o(cF,{provider:e}),t==="peers"&&o(pF,{peers:r.data?.peers??[],loading:r.isLoading}),t==="settings"&&o("div",{className:"p-4",children:o(si,{addonId:e.addonId,maxHeight:"max-h-72"})}),t==="logs"&&o("div",{className:"p-4",children:o(Ht,{addonId:e.addonId,limit:200,maxHeight:"max-h-72"})})]})}function As({active:e,onClick:t,children:n}){return o("button",{type:"button",onClick:t,className:e?"text-xs font-medium px-3 py-1.5 border-b-2 border-primary text-foreground -mb-px":"text-xs font-medium px-3 py-1.5 border-b-2 border-transparent text-foreground-subtle hover:text-foreground",children:n})}function cF({provider:e}){return f("div",{className:"p-4 space-y-4",children:[o(dF,{provider:e}),e.endpoints.length>0&&f("div",{className:"space-y-1.5",children:[o("div",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Endpoints"}),e.endpoints.map(t=>f("div",{className:"flex items-center gap-2 text-xs flex-wrap",children:[f("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${rF[t.scope]??"bg-foreground-subtle/15 text-foreground-subtle"}`,children:[t.scope==="public"?o(hn,{className:"inline h-2.5 w-2.5 mr-0.5"}):null,t.label]}),f("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",onClick:n=>n.stopPropagation(),className:"text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1",children:[o(Qd,{className:"h-3 w-3 shrink-0"}),t.url]})]},t.id))]})]})}function dF({provider:e}){const t=[{label:"Tenant",value:e.tenantName||"—"},{label:"User",value:e.userLogin??"—"},{label:"Control plane",value:e.controlPlaneUrl||"—"},{label:"Mesh IP",value:e.meshIp||"—",mono:!0},{label:"MagicDNS",value:e.magicDnsHostname||"—",mono:!0},{label:"DNS suffix",value:e.magicDnsSuffix||"—",mono:!0},{label:"Peers",value:String(e.peerCount)},{label:"Key expiry",value:e.keyExpiry?uF(e.keyExpiry):"—"}];return o("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5",children:t.map(n=>f("div",{className:"flex items-baseline justify-between gap-3 text-xs",children:[o("span",{className:"text-foreground-subtle shrink-0",children:n.label}),o("span",{className:`text-foreground truncate ${n.mono?"font-mono":""}`,children:n.value})]},n.label))})}function uF(e){const t=e-Date.now();if(t<0)return`Expired ${Vv(e)}`;const n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return`in ${n} days`;const r=Math.floor(t/36e5);return r>1?`in ${r}h`:`in ${Math.max(1,Math.floor(t/6e4))} min`}function pF({peers:e,loading:t}){const n=q(()=>e.map(a=>({...a,_id:a.id})),[e]),r=U(a=>{a&&navigator.clipboard?.writeText(a)},[]),s=q(()=>[{key:"hostname",header:"Hostname",render:a=>f("div",{className:"flex flex-col",children:[f("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"font-medium text-foreground",children:a.hostname||"(unknown)"}),a.isSelf&&o(zt,{variant:"info",children:"self"}),a.exitNodeOption&&o(zt,{variant:"warning",children:"exit-node"})]}),a.userLogin&&o("div",{className:"text-[10px] text-foreground-subtle truncate",children:a.userLogin})]})},{key:"magicDns",header:"MagicDNS",render:a=>a.magicDns?f("div",{className:"flex items-center gap-1",children:[o("span",{className:"font-mono text-xs truncate",children:a.magicDns}),o("button",{onClick:()=>r(a.magicDns),className:"p-0.5 hover:bg-foreground-subtle/10 rounded","aria-label":"Copy MagicDNS",children:o(aa,{className:"h-3 w-3 text-foreground-subtle"})})]}):o("span",{className:"text-foreground-subtle",children:"—"})},{key:"addresses",header:"IP",render:a=>{const i=a.addresses[0]??"";return i?f("div",{className:"flex items-center gap-1",children:[o("span",{className:"font-mono text-xs",children:i}),o("button",{onClick:()=>r(i),className:"p-0.5 hover:bg-foreground-subtle/10 rounded","aria-label":"Copy IP",children:o(aa,{className:"h-3 w-3 text-foreground-subtle"})})]}):o("span",{className:"text-foreground-subtle",children:"—"})}},{key:"connection",header:"Connection",render:a=>f("div",{className:"flex items-center gap-1.5",children:[o(zt,{variant:fF(a.connection),children:a.connection}),a.relay&&o("span",{className:"text-[10px] text-foreground-subtle font-mono",children:a.relay})]})},{key:"routes",header:"Routes",render:a=>a.advertisedRoutes.length>0?o("span",{className:"text-[10px] font-mono text-foreground-subtle truncate",children:a.advertisedRoutes.join(", ")}):o("span",{className:"text-foreground-subtle",children:"—"})},{key:"tx",header:"TX / RX",render:a=>f("span",{className:"text-[10px] text-foreground-subtle font-mono",children:["↑ ",Af(a.txBytes)," · ↓ ",Af(a.rxBytes)]})},{key:"lastSeen",header:"Last seen",render:a=>o("span",{className:"text-[10px] text-foreground-subtle",children:a.lastSeenMs>0?Vv(a.lastSeenMs):"—"})}],[r]);return t&&e.length===0?f("div",{className:"p-4 text-xs text-foreground-subtle",children:[o(Se,{className:"h-3 w-3 animate-spin inline mr-1"})," Loading peers…"]}):e.length===0?o("div",{className:"p-4 text-xs text-foreground-subtle",children:"No peers visible — your tailnet may be empty or the host is not joined."}):o("div",{className:"p-4",children:o($a,{columns:s,rows:n,rowKey:a=>a._id,minWidthPx:820})})}function fF(e){return e==="direct"?"success":e==="relay"?"warning":"info"}function Af(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)}MB`:`${(e/1024/1024/1024).toFixed(2)}GB`}function Vv(e){const t=Date.now()-e;return t<6e4?"just now":t<36e5?`${Math.round(t/6e4)}m ago`:t<864e5?`${Math.round(t/36e5)}h ago`:`${Math.round(t/864e5)}d ago`}function hF(e){return new Promise(t=>setTimeout(t,e))}function mF(){return o("div",{className:"flex flex-col p-4",children:o(Xd,{tabs:[{id:"addresses",label:"Network Addresses",icon:mn,content:o(nF,{})},{id:"remote-access",label:"Remote Access",icon:hn,content:o(Yz,{})},{id:"mesh",label:"Mesh Networks",icon:Ya,content:o(aF,{})},{id:"turn",label:"TURN Servers",icon:_n,content:o(Zz,{})}]})})}const gF=[{kind:"broker",title:"Brokers",subtitle:"Message brokers consumed by exporters and downstream automations (MQTT today, future Kafka, …).",icon:Xa,emptyHint:"Install a broker addon (e.g. @camstack/addon-mqtt-broker) to publish device events for downstream automations.",addLabel:"Add broker"},{kind:"email",title:"Email providers",subtitle:"Outbound email relays used for magic-link login, notifications, and alerts (SMTP today, future SendGrid, …).",icon:O6,emptyHint:"Install an email-provider addon (e.g. @camstack/addon-smtp) so the hub can deliver magic-link logins and notifications.",addLabel:"Add email provider"},{kind:"device-export",title:"Device export",subtitle:"Outbound exporters that publish CamStack devices to other ecosystems (HomeAssistant, HomeKit, Alexa, …).",icon:kO,emptyHint:"Install an export addon (e.g. @camstack/addon-export-ha-mqtt) to surface your CamStack devices in HomeAssistant, HomeKit, …",addLabel:"Add export"}];function bF(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e.name;if(typeof t=="string")return t}return null}function xF(e){const t=e,n=t?.manifest;if(!n?.id)return null;const r=[];for(const a of n.capabilities??[]){const i=bF(a);i!==null&&r.push(i)}const s=n.packageDisplayName??n.name??n.id;return{addonId:n.id,displayName:s,packageName:n.packageName??`@camstack/addon-${n.id}`,capNames:r,processState:t?.process?.state??null}}function yF(e,t){const n=new Set(t);return e.filter(r=>r.capNames.some(s=>n.has(s)))}function vF(e){const t=e[0];return t?`/system/addons?capability=${encodeURIComponent(t)}`:null}function wF({kind:e,title:t,subtitle:n,icon:r,installHref:s,addLabel:a}){return f("div",{className:"flex items-center justify-between gap-3",children:[f("div",{className:"flex items-start gap-3 min-w-0",children:[o("div",{className:"h-9 w-9 rounded-lg bg-primary/10 text-primary flex items-center justify-center shrink-0",children:o(r,{className:"h-4 w-4"})}),f("div",{className:"min-w-0",children:[f("div",{className:"flex items-center gap-2 flex-wrap",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:t}),o(CF,{kind:e})]}),o("p",{className:"text-xs text-foreground-subtle mt-0.5",children:n})]})]}),s&&o(tr,{to:s,className:"shrink-0",children:f(Re,{size:"sm",variant:"primary",children:[o(ct,{className:"h-3.5 w-3.5 mr-1"}),a]})})]})}function NF(e){return e==="running"?{label:"Running",className:"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300"}:e==="crashed"||e==="failed"?{label:e==="failed"?"Failed":"Crashed",className:"bg-danger/15 text-danger"}:e==="stopped"||e==="disabled"?{label:"Stopped",className:"bg-foreground-subtle/15 text-foreground-subtle"}:{label:e??"Unknown",className:"bg-foreground-subtle/15 text-foreground-subtle"}}function Jd({label:e,className:t}){return o("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t}`,children:e})}function kF(){const{data:e,isLoading:t}=wx(void 0,{refetchInterval:1e4,retry:!1});if(t||!e)return null;const n=g2.safeParse(e);if(!n.success)return null;const r=n.data,s=`${r.brokerCount} broker${r.brokerCount===1?"":"s"}${r.embeddedRunning?" • embedded up":""}`;return o(Jd,{label:s,className:"bg-primary/10 text-primary"})}function SF(){const{data:e,isLoading:t}=id(void 0,{refetchInterval:1e4,retry:!1});if(t||!e)return null;const n=am.safeParse(e);if(!n.success)return null;const r=n.data,s=r.linkState==="linked"?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":r.linkState==="error"?"bg-danger/15 text-danger":"bg-foreground-subtle/15 text-foreground-subtle",a=`${r.linkState} • ${r.exposedDeviceCount} exposed`;return o(Jd,{label:a,className:s})}function CF({kind:e}){return e==="broker"?o(kF,{}):e==="device-export"?o(SF,{}):null}function MF(e,t){const n=t.get(e);return n||`/system/addons?addonId=${encodeURIComponent(e)}`}function EF({rows:e,emptyHint:t,emptyTitle:n,installHref:r,addLabel:s,addonPagePaths:a}){return e.length===0?o(Ft,{children:o(Ra,{title:n,description:t,action:r?o(tr,{to:r,children:f(Re,{size:"sm",variant:"primary",children:[o(ct,{className:"h-3.5 w-3.5 mr-1"}),s]})}):void 0})}):o("div",{className:"flex flex-col gap-3",children:e.map(i=>{const l=NF(i.processState);return o(Ft,{children:f("div",{className:"flex items-center gap-4 p-4",children:[o("div",{className:"h-10 w-10 rounded-lg bg-primary/15 text-primary flex items-center justify-center shrink-0",children:o($o,{className:"h-5 w-5"})}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"font-semibold text-foreground",children:i.displayName}),o(Jd,{label:l.label,className:l.className})]}),o("div",{className:"text-xs text-foreground-subtle mt-1 font-mono truncate",children:i.packageName})]}),o(tr,{to:MF(i.addonId,a),className:"shrink-0",children:o(Re,{size:"sm",variant:"secondary",children:"Configure"})})]})},i.addonId)})})}function IF(e){const t=new Map;for(const n of e??[])t.has(n.addonId)||t.set(n.addonId,n.page.path);return t}function AF(){const t=(Ko(void 0,{refetchInterval:1e4}).data??[]).map(xF).filter(s=>s!==null),n=Ba(void 0,{refetchInterval:3e4}),r=IF(n.data);return o(nt,{icon:_o,title:"Integrations",subtitle:"External systems this hub talks to — message brokers, email relays, and device exporters. Per-provider settings live on each addon's own page; this page is the directory.",children:o("div",{className:"flex flex-col gap-6",children:gF.map(s=>{const a=Object.entries(w2).filter(([,l])=>l===s.kind).map(([l])=>l),i=vF(a);return f("section",{className:"space-y-3",children:[o(wF,{kind:s.kind,title:s.title,subtitle:s.subtitle,icon:s.icon,installHref:i,addLabel:s.addLabel}),o(EF,{rows:yF(t,a),emptyHint:s.emptyHint,emptyTitle:`No ${s.title.toLowerCase()} installed`,installHref:i,addLabel:s.addLabel,addonPagePaths:r})]},s.kind)})})})}function PF(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 _F({location:e,onEdit:t,onDelete:n,onSetDefault:r}){const s=PF(e.config);return f("div",{className:"flex items-center gap-3 px-3 py-2 border-t border-border first:border-t-0 hover:bg-primary/5",children:[f("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o("div",{className:"w-[88px] shrink-0",children:e.isDefault?f("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:[o(ji,{className:"h-2.5 w-2.5 fill-primary"}),"Default"]}):f("button",{onClick:()=>r(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:[o(ji,{className:"h-2.5 w-2.5"}),"Set default"]})}),o("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&&o("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"}),f("div",{className:"min-w-0",children:[o("div",{className:"text-xs font-medium text-foreground truncate",children:e.displayName}),s&&o("div",{className:"text-[10px] text-foreground-subtle truncate font-mono",children:s})]})]}),f("div",{className:"flex items-center gap-1 shrink-0",children:[!e.isDefault&&f("button",{onClick:()=>r(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:[o(ji,{className:"h-3 w-3"}),"Set default"]}),f("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:[o(eo,{className:"h-3 w-3"}),"Edit"]}),!e.isSystem&&Fs[e.type]!=="singleton"&&o("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:o(Ze,{className:"h-3 w-3"})})]})]})}function $F({type:e,displayName:t,description:n,locations:r,onAdd:s,onEdit:a,onDelete:i,onSetDefault:l}){const c=q(()=>{const d=[...r];return d.sort((u,p)=>u.isDefault!==p.isDefault?u.isDefault?-1:1:u.displayName.localeCompare(p.displayName)),d},[r]);return f("div",{className:"rounded-lg border border-border bg-surface",children:[f("div",{className:"flex items-start justify-between border-b border-border px-3 py-2",children:[f("div",{className:"space-y-0.5",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-sm font-semibold text-foreground capitalize",children:t}),o("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&&o("p",{className:"text-[11px] text-foreground-subtle",children:n}),Fs[e]==="singleton"&&o("p",{className:"text-[10px] text-foreground-subtle italic",children:"Singleton — one location per type. Edit the existing entry; it can't be split."})]}),Fs[e]==="multi"&&f("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:[o(ct,{className:"h-3 w-3"}),"Add"]})]}),c.length===0?o("div",{className:"px-3 py-4 text-center text-[11px] text-foreground-subtle italic",children:Fs[e]==="multi"?'No location registered. Click "Add" to register one.':"No location registered yet — should be auto-seeded at next boot."}):o("div",{children:c.map(d=>o(_F,{location:d,onEdit:a,onDelete:i,onSetDefault:l},d.id))})]})}function DF(e){const t=e.trim().toLowerCase();return t.length===0?"":t.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Pf(e,t){const n=DF(t),r=n.length>0?n:"default";return`${e}:${r}`}function Hv({initialType:e,onClose:t,onCreated:n}){const r=ke(),s=Le().trpcClient,[a,i]=_("picker"),[l,c]=_(e),[d,u]=_(null),[p,h]=_({}),[m,g]=_(""),[b,x]=_(null),[y,w]=_(!1),[v,N]=_(null),[k,C]=_(!1),M=bd(),P=q(()=>{const D=M.data;return Array.isArray(D)?D.filter(T=>T.supportedLocationTypes.includes(l)):[]},[M.data,l]),I=M.isLoading,z=Va({onSuccess:()=>{r.invalidateQueries({queryKey:[["storage","listLocations"]]}),n()}}),A=q(()=>b!==null&&b.length>0?b:Pf(l,m),[l,m,b]),O=async()=>{if(d){C(!0),N(null);try{const T=await(B=>s.storage.testConfig.query(B))({providerId:d.providerId,config:p});N(T)}catch(D){N({ok:!1,error:D instanceof Error?D.message:String(D)})}finally{C(!1)}}},R=()=>{d&&z.mutate({id:A,type:l,displayName:m.trim(),providerId:d.providerId,config:p,isDefault:y})},E={picker:"Add Location — Pick provider",config:`Add Location — ${d?.displayName??""}`,naming:"Add Location — Name & defaults"};return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:t,children:f("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:D=>D.stopPropagation(),children:[f("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[f("div",{className:"space-y-0.5",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:E[a]}),f("p",{className:"text-xs text-foreground-subtle",children:["Type: ",o("span",{className:"font-mono",children:l})]})]}),o("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-4 w-4"})})]}),a==="picker"&&f("div",{className:"p-4 space-y-2",children:[I&&o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading providers…"}),!I&&P.length===0&&f("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. ',o("code",{className:"font-mono",children:"remote-storage"}),") to enable it."]}),P.map(D=>f("button",{onClick:()=>{u(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:[f("div",{className:"flex-1 min-w-0",children:[o("p",{className:"text-xs font-semibold text-foreground",children:D.displayName}),o("p",{className:"text-[10px] text-foreground-subtle font-mono mt-0.5 truncate",children:D.providerId})]}),o(Nt,{className:"h-4 w-4 text-foreground-subtle flex-shrink-0"})]},D.providerId))]}),a==="config"&&d&&f("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[o($n,{schema:d.configSchema,values:p,onChange:h}),v&&o("div",{className:`rounded border px-3 py-2 text-[11px] ${v.ok?"border-success/30 bg-success/5 text-success":"border-danger/30 bg-danger/5 text-danger"}`,children:v.ok?"Connection OK.":`Test failed: ${v.error??"unknown error"}`}),f("div",{className:"flex items-center justify-between pt-1",children:[o("button",{onClick:()=>i("picker"),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Back"}),f("div",{className:"flex items-center gap-2",children:[o("button",{onClick:()=>{O()},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"}),o("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&&f("div",{className:"p-4 space-y-3",children:[f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Display name"}),o("input",{type:"text",value:m,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"})]}),f("div",{className:"space-y-1",children:[f("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:["Id ",o("span",{className:"lowercase tracking-normal text-foreground-subtle",children:"— auto-derived; override if needed"})]}),o("input",{type:"text",value:A,onChange:D=>x(D.target.value),placeholder:Pf(l,m),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"}),f("p",{className:"text-[10px] text-foreground-subtle",children:["Format: ",o("code",{className:"font-mono",children:"<type>:<slug>"}),". Lowercase letters, digits, and hyphens only."]})]}),f("label",{className:"flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5",children:[o("input",{type:"checkbox",checked:y,onChange:D=>w(D.target.checked),className:"accent-primary mt-0.5"}),f("div",{className:"space-y-0.5",children:[f("div",{className:"text-xs font-medium text-foreground",children:['Mark as default for type "',l,'"']}),f("div",{className:"text-[10px] text-foreground-subtle",children:["Setting this as default will demote the current default for this type. References like"," ",f("code",{className:"font-mono",children:['"',l,'"']})," resolve to whichever location is the default."]})]})]}),z.isError&&o("div",{className:"rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]",children:z.error instanceof Error?z.error.message:String(z.error)}),f("div",{className:"flex items-center justify-between pt-1",children:[o("button",{onClick:()=>i("config"),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Back"}),f("div",{className:"flex items-center gap-2",children:[o("button",{onClick:()=>{c(e),u(null),h({}),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"}),f("button",{onClick:R,disabled:z.isPending||m.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:[z.isPending?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):null,z.isPending?"Saving…":"Save"]})]})]})]})]})})}function LF({location:e,onClose:t,onSaved:n}){const r=ke(),s=Le().trpcClient,[a,i]=_({...e.config}),[l,c]=_(e.displayName),[d,u]=_(null),[p,h]=_(!1),m=bd(),g=q(()=>{const w=m.data;return Array.isArray(w)?w.find(N=>N.providerId===e.providerId)??null:null},[m.data,e.providerId]),b=Va({onSuccess:()=>{r.invalidateQueries({queryKey:[["storage","listLocations"]]}),n()}}),x=async()=>{h(!0),u(null);try{const v=await(N=>s.storage.testConfig.query(N))({providerId:e.providerId,config:a});u(v)}catch(w){u({ok:!1,error:w instanceof Error?w.message:String(w)})}finally{h(!1)}},y=()=>{b.mutate({id:e.id,type:e.type,providerId:e.providerId,isDefault:e.isDefault,displayName:l.trim(),config:a})};return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:t,children:f("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:w=>w.stopPropagation(),children:[f("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[f("div",{className:"space-y-0.5",children:[f("h2",{className:"text-sm font-semibold text-foreground",children:["Edit ",e.displayName]}),f("p",{className:"text-xs text-foreground-subtle",children:[o("span",{className:"font-mono",children:e.id})," · ",g?.displayName??e.providerId]})]}),o("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-4 w-4"})})]}),f("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Display name"}),o("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&&o($n,{schema:g.configSchema,values:a,onChange:i}),!g&&!m.isLoading&&f("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 ",o("code",{className:"font-mono",children:e.providerId})," is no longer registered. Field schema unavailable; raw config is preserved on save."]}),d&&o("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&&o("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)})]}),f("div",{className:"flex items-center justify-between gap-2 border-t border-border px-4 py-3",children:[o("button",{onClick:t,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),f("div",{className:"flex items-center gap-2",children:[o("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"}),f("button",{onClick:y,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?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):null,b.isPending?"Saving…":"Save"]})]})]})]})})}const TF={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"},RF={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 OF(){const e=ke(),t=rt(),{data:n,isLoading:r,isError:s}=x0({}),[a,i]=_(null),[l,c]=_(null),d=y0({onSuccess:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]})}}),u=Va({onSuccess:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]})}}),p=g=>{g.isDefault||u.mutate({id:g.id,type:g.type,providerId:g.providerId,displayName:g.displayName,config:g.config,isDefault:!0})},h=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})},m=q(()=>{const g=new Map;for(const b of $u)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 f(nt,{children:[r&&o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading locations…"}),s&&o("div",{className:"text-xs text-danger",children:"Failed to load storage locations."}),!r&&!s&&o("div",{className:"space-y-3",children:$u.map(g=>o($F,{type:g,displayName:TF[g],description:RF[g],locations:m.get(g)??[],onAdd:b=>i(b),onEdit:b=>c(b),onDelete:b=>{h(b)},onSetDefault:b=>p(b)},g))}),a!==null&&o(Hv,{initialType:a,onClose:()=>i(null),onCreated:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]}),i(null)}}),l!==null&&o(LF,{location:l,onClose:()=>c(null),onSaved:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]}),c(null)}})]})}const BF=[["backup","listDestinations"]],zF=["backup","listArchives"];function FF({destinationId:e,restoreSupported:t,onOpenRestoreWizard:n}){const r=ke(),s=rt(),{data:a,isLoading:i,isError:l}=ad({destinationId:e}),c=a??[],d=Pb({onSuccess:()=>{r.invalidateQueries({queryKey:[[...zF]]}),r.invalidateQueries({queryKey:BF})}}),u=U(async b=>{await s({title:"Delete this archive?",message:`Permanently deletes "${b.label??b.id}" and frees ${It(b.sizeBytes)}.`,confirmLabel:"Delete",variant:"danger"})&&d.mutate({destinationId:e,backupId:b.id})},[s,e,d]),[p,h]=_(null),m=U(async b=>{h(b.id);try{const x=localStorage.getItem("camstack_admin_token"),y={};x&&(y.Authorization=`Bearer ${x}`);const w=await fetch(jF(e,b.id),{headers:y});if(!w.ok)throw new Error(`download failed: ${w.status} ${w.statusText}`);const v=await w.blob(),N=URL.createObjectURL(v),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{h(null)}},[e]),g=q(()=>[...c].sort((b,x)=>x.createdAt-b.createdAt),[c]);return i?o("div",{className:"text-xs text-foreground-subtle animate-pulse py-2",children:"Loading archives…"}):l?o("div",{className:"text-xs text-danger py-2",children:"Failed to read manifest for this destination"}):g.length===0?o("div",{className:"text-xs text-foreground-subtle italic py-2",children:"No archives at this destination yet."}):o("div",{className:"rounded border border-border bg-surface overflow-x-auto",children:f("table",{className:"w-full text-xs min-w-[640px]",children:[o("thead",{children:f("tr",{className:"text-foreground-subtle bg-background/30",children:[o("th",{className:"text-left px-3 py-1.5 font-medium",children:"When"}),o("th",{className:"text-left px-3 py-1.5 font-medium",children:"Label"}),o("th",{className:"text-left px-3 py-1.5 font-medium",children:"Includes"}),o("th",{className:"text-right px-3 py-1.5 font-medium",children:"Size"}),o("th",{className:"text-right px-3 py-1.5 font-medium w-52",children:"Actions"})]})}),o("tbody",{children:g.map(b=>f("tr",{className:"border-t border-border hover:bg-primary/5",children:[o("td",{className:"px-3 py-1.5 text-foreground tabular-nums",children:VF(b.createdAt)}),o("td",{className:"px-3 py-1.5 text-foreground",children:b.label??o("span",{className:"text-foreground-subtle italic",children:"—"})}),o("td",{className:"px-3 py-1.5 text-foreground-subtle",children:b.locations.join(", ")}),o("td",{className:"px-3 py-1.5 text-foreground text-right tabular-nums",children:It(b.sizeBytes)}),o("td",{className:"px-3 py-1.5",children:f("div",{className:"flex items-center justify-end gap-1",children:[f("button",{onClick:()=>{m(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?o(Se,{className:"h-3 w-3 animate-spin"}):o(en,{className:"h-3 w-3"}),"Download"]}),t&&n&&f("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:[o(St,{className:"h-3 w-3"}),"Restore"]}),o("button",{onClick:()=>{u(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?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ze,{className:"h-3 w-3"})})]})})]},b.id))})]})})}function jF(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function VF(e){return new Date(e).toLocaleString(void 0,{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}const qv=[{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 HF(e){const t=e.trim();for(const n of qv)if(n.cron===t)return n.id;return"custom"}function qF({value:e,onChange:t,previewCount:n=5,disabled:r=!1}){const s=HF(e),[a,i]=_(s==="custom");Y(()=>{s!=="custom"&&i(!1)},[s]);const l=GF(e,250),c=$b({cron:l,count:n},{enabled:l.trim().length>0}),d=c.data??null,u=h=>{i(!1),t(h.cron)},p=a||s==="custom";return f("div",{className:"space-y-3",children:[f("div",{className:"space-y-1",children:[o("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Schedule preset"}),f("div",{className:"flex flex-wrap gap-1.5",children:[qv.map(h=>{const m=!a&&s===h.id;return o("button",{type:"button",onClick:()=>u(h),disabled:r,className:"rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 "+(m?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground"),title:h.description??h.label,children:h.label},h.id)}),o("button",{type:"button",onClick:()=>{i(!0),e.trim().length===0&&t("0 3 * * *")},disabled:r,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&&f("div",{className:"space-y-1",children:[o("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Cron expression (5-field POSIX)"}),o("input",{type:"text",value:e,onChange:h=>t(h.target.value),disabled:r,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"}),f("p",{className:"text-[10px] text-foreground-subtle",children:["Format: ",o("span",{className:"font-mono",children:"minute hour day-of-month month day-of-week"})," · all times server-local"]})]}),o(UF,{cron:l,preview:d,loading:c.isFetching})]})}function UF({cron:e,preview:t,loading:n}){return n&&t===null?f("div",{className:"flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle",children:[o(Se,{className:"h-3 w-3 animate-spin"}),"Validating…"]}):t===null?null:t.ok?t.nextRuns.length===0?o("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."}):f("div",{className:"space-y-1",children:[o("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Next runs"}),o("ul",{className:"rounded border border-border bg-background/40 divide-y divide-border",children:t.nextRuns.map((r,s)=>f("li",{className:"flex items-center justify-between px-3 py-1.5 text-[11px]",children:[o("span",{className:"text-foreground tabular-nums",children:new Date(r).toLocaleString()}),o("span",{className:"text-foreground-subtle text-[10px] tabular-nums",children:QF(r)})]},`${r}-${s}`))})]}):o("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 QF(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 r=Math.floor(n/60);if(r<60)return`in ${r}m`;const s=Math.floor(r/60);return s<24?`in ${s}h`:`in ${Math.floor(s/24)}d`}function GF(e,t){const[n,r]=_(e),s=q(()=>e,[e]);return Y(()=>{const a=setTimeout(()=>r(s),t);return()=>clearTimeout(a)},[s,t]),n}const KF=[["backup","listDestinations"]];function WF({onCreateAt:e,onOpenRestoreWizard:t}){const{data:n,isLoading:r,isError:s}=sd(),a=n??[],[i,l]=_(null),c=u=>{l(p=>p===u?null:u)},d=ej();return r?o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading destinations…"}):s?o("div",{className:"text-xs text-danger",children:"Failed to load destinations"}):a.length===0?o("div",{className:"rounded-lg border border-border bg-surface px-4 py-8 text-center",children:o("p",{className:"text-xs text-foreground-subtle",children:"No `backups`-typed storage locations registered. Add one in Settings → Storage to begin."})}):o("div",{className:"rounded-lg border border-border bg-surface overflow-x-auto",children:f("table",{className:"w-full text-xs min-w-[720px]",children:[o("thead",{children:f("tr",{className:"text-foreground-subtle border-b border-border bg-background/40",children:[o("th",{className:"text-left px-3 py-2 font-medium w-6"}),o("th",{className:"text-left px-3 py-2 font-medium",children:"Destination"}),o("th",{className:"text-left px-3 py-2 font-medium w-20",children:"Enabled"}),o("th",{className:"text-left px-3 py-2 font-medium w-28",children:"Retention"}),o("th",{className:"text-left px-3 py-2 font-medium w-56",children:"Schedule"}),o("th",{className:"text-left px-3 py-2 font-medium w-44",children:"Last success"}),o("th",{className:"text-right px-3 py-2 font-medium w-44",children:"Actions"})]})}),o("tbody",{children:a.map(u=>{const p=d.get(u.id);return o(YF,{row:u,isOpen:i===u.id,onToggle:()=>c(u.id),onCreateAt:e,liveLastSuccessAt:p?.at,liveLastSuccessSizeBytes:p?.sizeBytes,...t?{onOpenRestoreWizard:t}:{}},u.id)})})]})})}function YF({row:e,isOpen:t,onToggle:n,onCreateAt:r,onOpenRestoreWizard:s,liveLastSuccessAt:a,liveLastSuccessSizeBytes:i}){const l=ke(),c=_b({onSuccess:()=>{l.invalidateQueries({queryKey:KF})}}),[d,u]=_(String(e.retentionCount));Y(()=>{u(String(e.retentionCount))},[e.retentionCount]);const[p,h]=_(!1),m=U(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=U(()=>{const x=Number.parseInt(d,10);if(Number.isNaN(x)||x<1){u(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=U(x=>{c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:e.retentionCount,...e.label!==void 0?{label:e.label}:{},cron:x},{onSuccess:()=>{h(!1)}})},[c,e.id,e.enabled,e.retentionCount,e.label]);return f(he,{children:[f("tr",{className:"border-t border-border first:border-t-0 hover:bg-primary/5",children:[o("td",{className:"px-2 py-2",children:o("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?o(lt,{className:"h-3.5 w-3.5"}):o(Nt,{className:"h-3.5 w-3.5"})})}),o("td",{className:"px-3 py-2",children:f("button",{onClick:n,className:"text-left hover:underline focus:outline-none",title:"View archives",children:[o("div",{className:"text-foreground font-medium",children:e.displayName}),f("div",{className:"flex items-center gap-1.5 mt-0.5",children:[o("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}),o("span",{className:"text-[10px] text-foreground-subtle font-mono",children:e.id})]})]})}),o("td",{className:"px-3 py-2",children:o("label",{className:"inline-flex items-center cursor-pointer",children:o("input",{type:"checkbox",className:"accent-primary",checked:e.enabled,disabled:c.isPending,onChange:x=>m(x.target.checked)})})}),o("td",{className:"px-3 py-2",children:o("input",{type:"number",min:1,max:1e3,value:d,disabled:c.isPending,onChange:x=>u(x.target.value),onBlur:g,onKeyDown:x=>{x.key==="Enter"&&x.target.blur(),x.key==="Escape"&&u(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"})}),o("td",{className:"px-3 py-2",children:o(ZF,{cron:e.cron,nextRunAt:e.nextRunAt,onEdit:()=>h(!0),disabled:c.isPending})}),o("td",{className:"px-3 py-2 text-foreground-subtle",children:(()=>{const x=tj(a,e.lastSuccessAt),y=x===a?i:e.lastSuccessSizeBytes;return x!==void 0?o(nj,{at:x,sizeBytes:y}):o("span",{className:"italic",children:"Never"})})()}),o("td",{className:"px-3 py-2",children:o("div",{className:"flex items-center justify-end gap-1.5",children:e.triggerSupported&&f("button",{onClick:()=>r(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:[o(ct,{className:"h-3 w-3"}),"Create here"]})})})]}),t&&o("tr",{className:"border-t border-border bg-background/30",children:o("td",{colSpan:7,className:"px-4 py-3",children:o(FF,{destinationId:e.id,restoreSupported:e.restoreSupported,...s?{onOpenRestoreWizard:s}:{}})})}),p&&o(JF,{destinationName:e.displayName,currentCron:e.cron??"",onSave:b,onClose:()=>h(!1),saving:c.isPending,saveError:c.error instanceof Error?c.error.message:null})]})}function ZF({cron:e,nextRunAt:t,onEdit:n,disabled:r}){const s=typeof e=="string"&&e.trim().length>0;return f("button",{type:"button",onClick:n,disabled:r,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:[f("div",{className:"flex items-center gap-1.5",children:[o(DR,{className:"h-3 w-3 text-foreground-subtle group-hover:text-foreground"}),o("span",{className:s?"font-mono text-foreground":"italic text-foreground-subtle",children:s?e:"Manual"})]}),s&&t!==void 0&&f("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:["next ",XF(t)]})]})}function XF(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 r=Math.floor(n/60);if(r<60)return`in ${r}m`;const s=Math.floor(r/60);return s<24?`in ${s}h`:`in ${Math.floor(s/24)}d`}function JF({destinationName:e,currentCron:t,onSave:n,onClose:r,saving:s,saveError:a}){const[i,l]=_(t);return o("tr",{children:o("td",{colSpan:7,className:"p-0",children:o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:r,children:f("div",{className:"w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl",onClick:c=>c.stopPropagation(),children:[f("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[f("div",{className:"space-y-0.5",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:"Schedule"}),f("p",{className:"text-xs text-foreground-subtle",children:["→ ",e]})]}),o("button",{onClick:r,className:"text-foreground-subtle hover:text-foreground",title:"Close",children:o(Fe,{className:"h-4 w-4"})})]}),f("div",{className:"p-4",children:[o(qF,{value:i,onChange:l,disabled:s}),a!==null&&o("div",{className:"mt-3 rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger",children:a})]}),f("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:[o("button",{onClick:r,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"}),o("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 ej(){const{map:e}=Kc(Ne.BackupCompleted,t=>t.destinationId);return q(()=>{const t=new Map;for(const[n,r]of e)t.set(n,{at:Date.now(),sizeBytes:r.sizeMB*1024*1024});return t},[e])}function tj(e,t){return e===void 0?t:t===void 0||e>t?e:t}function nj({at:e,sizeBytes:t}){const n=rj(e),r=q(()=>new Date(e).toLocaleString(),[e]);return f("span",{title:r,className:"text-foreground tabular-nums",children:[n,t!==void 0&&f("span",{className:"ml-1 text-foreground-subtle",children:["· ",It(t)]})]})}function rj(e){const[,t]=_(0);return Y(()=>{const n=setInterval(()=>t(r=>r+1),3e4);return()=>clearInterval(n)},[]),oj(e)}function oj(e){const t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const s=Math.floor(r/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 sj=[["backup","list"]];function aj({initialDestinationId:e,initialArchiveId:t,onClose:n,onScheduled:r}){const s=ke(),[a,i]=_(e&&t?2:1),[l,c]=_(e),[d,u]=_(t),[p,h]=_(new Set),{data:m}=sd(),g=m??[],{data:b,isLoading:x}=ad({destinationId:l??""},{enabled:!!l}),y=b??[];Y(()=>{if(l!==void 0)return;const z=g.filter(A=>A.restoreSupported);z.length===1&&c(z[0].id)},[l,g]);const{data:w}=Ib({destinationId:l??"",backupId:d??""},{enabled:!!l&&!!d}),v=q(()=>w?.locations??[],[w]);Y(()=>{v.length!==0&&h(z=>z.size===0?new Set(v):z)},[v]);const N=Ab({onSuccess:()=>{s.invalidateQueries({queryKey:sj}),r(),n()}}),k=z=>{h(A=>{const O=new Set(A);return O.has(z)?O.delete(z):O.add(z),O})},C=!!l&&!!d,M=p.size>0,P=C&&M&&!N.isPending,I=()=>{!l||!d||N.mutate({destinationId:l,backupId:d,locations:[...p]})};return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:n,children:f("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:z=>z.stopPropagation(),children:[f("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[f("div",{className:"space-y-0.5",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:"Restore Backup"}),f("p",{className:"text-xs text-foreground-subtle",children:["Step ",a," of 3 — ",a===1?"pick source":a===2?"pick locations":"confirm"]})]}),o("button",{onClick:n,className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-4 w-4"})})]}),a===1&&o(ij,{destinations:g,destinationId:l,onPickDestination:z=>{c(z),u(void 0),h(new Set)},archives:y,archivesLoading:x,archiveId:d,onPickArchive:u}),a===2&&o(lj,{locations:v,picked:p,onToggle:k}),a===3&&o(cj,{destinationName:g.find(z=>z.id===l)?.displayName??l??"",archive:y.find(z=>z.id===d),picked:[...p]}),f("div",{className:"flex justify-between gap-2 border-t border-border px-4 py-3",children:[o("div",{children:a>1&&f("button",{onClick:()=>i(z=>z===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:[o(Hd,{className:"h-3 w-3"}),"Back"]})}),f("div",{className:"flex items-center gap-2",children:[o("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?f("button",{disabled:a===1&&!C||a===2&&!M,onClick:()=>i(z=>z===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",o(NR,{className:"h-3 w-3"})]}):f("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?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(St,{className:"h-3.5 w-3.5"}),"Schedule Restore"]})]})]})]})})}function ij({destinations:e,destinationId:t,onPickDestination:n,archives:r,archivesLoading:s,archiveId:a,onPickArchive:i}){const l=e.filter(c=>c.restoreSupported);return f("div",{className:"p-4 space-y-3",children:[f("div",{className:"space-y-1.5",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Destination"}),f("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:[o("option",{value:"",disabled:!0,children:"Select destination…"}),l.map(c=>f("option",{value:c.id,children:[c.displayName," (",c.kind,")"]},c.id))]})]}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Archive"}),!t&&o("div",{className:"text-xs text-foreground-subtle italic",children:"Pick a destination first."}),t&&s&&o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Reading archives…"}),t&&!s&&r.length===0&&o("div",{className:"text-xs text-foreground-subtle italic",children:"No archives available at this destination."}),t&&r.length>0&&o("div",{className:"rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto",children:r.map(c=>{const d=a===c.id;return f("label",{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${d?"bg-primary/10":"hover:bg-primary/5"}`,children:[f("div",{className:"flex items-center gap-2",children:[o("input",{type:"radio",name:"archive",checked:d,onChange:()=>i(c.id),className:"accent-primary"}),f("div",{children:[o("div",{className:"font-medium text-foreground",children:c.label??c.id}),o("div",{className:"text-[10px] text-foreground-subtle",children:new Date(c.createdAt).toLocaleString()})]})]}),o("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:It(c.sizeBytes)})]},c.id)})})]})]})}function lj({locations:e,picked:t,onToggle:n}){return e.length===0?o("div",{className:"p-4",children:o("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."})}):f("div",{className:"p-4 space-y-3",children:[o("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."}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Apply"}),o("div",{className:"rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto",children:e.map(r=>f("label",{className:"flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer",children:[o("input",{type:"checkbox",checked:t.has(r),onChange:()=>n(r),className:"accent-primary"}),o("span",{className:"font-mono text-foreground",children:r}),o("span",{className:"ml-auto text-[10px] text-foreground-subtle",children:uj(r)})]},r))})]})]})}function cj({destinationName:e,archive:t,picked:n}){return f("div",{className:"p-4 space-y-3 text-xs",children:[o("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."}),f("dl",{className:"space-y-1.5",children:[o(Ps,{term:"Destination",value:e}),o(Ps,{term:"Archive",value:t?.label??t?.id??"—"}),t&&o(Ps,{term:"Created",value:`${new Date(t.createdAt).toLocaleString()} · ${It(t.sizeBytes)}`}),o(Ps,{term:"Locations",value:n.length>0?n.join(", "):"— (full archive)"})]})]})}function Ps({term:e,value:t}){return f("div",{className:"flex justify-between gap-3",children:[o("dt",{className:"text-foreground-subtle",children:e}),o("dd",{className:"text-foreground font-mono text-right truncate",children:t})]})}const dj={db:"Database",addons:"Addon configs","addons-data":"Addon data",tls:"TLS certificates",cache:"Cache",data:"Top-level data"};function uj(e){return dj[e]??""}const pj=[["backup","list"]],fj=[["backup","listLocations"]];function hj(){const e=ke(),t=rt(),{data:n}=Eb(),r=Mb({onSuccess:()=>{e.invalidateQueries({queryKey:pj}),e.invalidateQueries({queryKey:[["backup","listDestinations"]]}),e.invalidateQueries({queryKey:[["backup","listArchives"]]})}}),s=ib(),[a,i]=_(null),[l,c]=_(null),[d,u]=_(!1),[p,h]=_(!1),[m,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 f(nt,{children:[f("div",{className:"flex items-center justify-end gap-2 flex-wrap",children:[f("button",{onClick:()=>u(!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:[o(St,{className:"h-3.5 w-3.5"}),"Restore…"]}),f("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:[o(ct,{className:"h-3.5 w-3.5"}),"Add destination"]})]}),p&&o("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:f("div",{className:"flex items-center justify-between gap-3",children:[f("div",{className:"flex items-center gap-2",children:[o(St,{className:"h-3.5 w-3.5"}),o("span",{children:"Restore scheduled. Restart the server to apply."})]}),f("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?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(St,{className:"h-3.5 w-3.5"}),"Restart Now"]})]})}),o(WF,{onCreateAt:x=>i(x),onOpenRestoreWizard:x=>c(x)}),a&&o(mj,{destination:a,locations:n??[],onClose:()=>i(null),onSubmit:(x,y)=>{r.mutate({destinations:[a.id],locations:x,label:y||void 0},{onSuccess:()=>{i(null),e.invalidateQueries({queryKey:fj})}})},submitting:r.isPending}),(l||d)&&o(aj,{...l?{initialDestinationId:l.destinationId,initialArchiveId:l.archiveId}:{},onClose:()=>{c(null),u(!1)},onScheduled:()=>h(!0)}),m&&o(Hv,{initialType:"backups",onClose:()=>g(!1),onCreated:()=>{g(!1),e.invalidateQueries({queryKey:[["backup","listDestinations"]]})}})]})}function mj({destination:e,locations:t,onClose:n,onSubmit:r,submitting:s}){const a=t.filter(p=>p.present),[i,l]=_(""),[c,d]=_(()=>new Set(a.map(p=>p.name))),u=p=>{d(h=>{const m=new Set(h);return m.has(p)?m.delete(p):m.add(p),m})};return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:n,children:f("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:p=>p.stopPropagation(),children:[f("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[f("div",{className:"space-y-0.5",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:"Create Backup"}),f("p",{className:"text-xs text-foreground-subtle",children:["→ ",e.displayName]})]}),o("button",{onClick:n,className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-4 w-4"})})]}),f("div",{className:"p-4 space-y-3",children:[f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Label (optional)"}),o("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"})]}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Include"}),f("div",{className:"rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto",children:[a.length===0&&o("div",{className:"px-3 py-2 text-xs text-foreground-subtle italic",children:"Nothing to back up."}),a.map(p=>f("label",{className:"flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer",children:[f("div",{className:"flex items-center gap-2",children:[o("input",{type:"checkbox",checked:c.has(p.name),onChange:()=>u(p.name),className:"accent-primary"}),o("span",{className:"font-mono text-foreground",children:p.name})]}),f("div",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[It(p.sizeBytes)," · ",p.fileCount," files"]})]},p.name))]})]})]}),f("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:[o("button",{onClick:n,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),f("button",{onClick:()=>r(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?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(By,{className:"h-3.5 w-3.5"}),s?"Creating…":"Create"]})]})]})})}function gj(){return o("div",{className:"flex flex-col p-4",children:o(Xd,{tabs:[{id:"storage",label:"Storage",icon:ia,content:o(OF,{})},{id:"backup",label:"Backup",icon:By,content:o(hj,{})}]})})}function bj(){const{data:e,isLoading:t}=Bn(void 0,{staleTime:3e4}),n=(e??[]).find(s=>s.isHub&&s.isOnline),r=n?.addons.map(s=>s.id)??[];return o(nt,{children:t?o("div",{className:"text-muted-foreground text-sm py-12 text-center",children:"Loading hub topology…"}):n?r.length===0?o("div",{className:"text-muted-foreground text-sm py-12 text-center",children:"No addons installed on the hub yet."}):o(to,{nodeId:n.id,addonIds:r,level:"global"}):f("div",{className:"flex flex-col items-center justify-center text-muted-foreground text-sm gap-2 py-12",children:[o(tn,{className:"h-8 w-8 opacity-30"}),o("p",{children:"No online hub node found."}),o("p",{className:"text-xs",children:"Settings will appear once the hub is reachable."})]})})}function xj(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,r)=>{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{r(new Error(`HTTP ${s.status}`));return}s.status>=200&&s.status<300?n(a):r(new Error(a.error??`HTTP ${s.status}`))}),s.addEventListener("error",()=>r(new Error("Network error during upload"))),s.addEventListener("abort",()=>r(new Error("Upload aborted"))),s.send(t)})}function yj({nodeId:e,addons:t,isHub:n}){const r=ke(),s=rt(),[a,i]=_(null),[l,c]=_(null),[d,u]=_(!1),[p,h]=_(null),[m,g]=_(0),b=te(null),x=za(),y=Nx(),w=Ex({nodeId:e}),v=w.data??[],N=new Map(t.map(A=>[A.id,A.capabilities])),k=v.length>0?v.map(A=>({id:A.id,status:A.status,capabilities:N.get(A.id)??[],version:A.version,packageName:A.packageName})):t.map(A=>({id:A.id,status:A.status,capabilities:A.capabilities,version:void 0,packageName:void 0})),C=()=>{r.invalidateQueries({queryKey:[["nodes","topology"]]}),w.refetch()},M=async A=>{i(A);try{await x.mutateAsync({nodeId:e,addonId:A}),C()}catch(O){console.error("Failed to restart addon:",O)}finally{i(null)}},P=async A=>{if(await s({title:"Uninstall addon",message:`Remove "${A}" from ${e}? The addon directory will be deleted on disk.`,confirmLabel:"Uninstall",variant:"danger"})){c(A);try{await y.mutateAsync({nodeId:e,addonId:A}),C()}catch(R){console.error("Failed to uninstall addon:",R)}finally{c(null)}}},z=f("div",{className:"flex items-center gap-2 mb-2",children:[o("input",{ref:b,type:"file",accept:".tgz,.tar.gz",className:"hidden",onChange:async A=>{const O=A.target.files?.[0];if(O){A.target.value="",h(null),u(!0),g(0);try{const R=localStorage.getItem("camstack_admin_token");await xj({file:O,nodeId:e,token:R,onProgress:g}),C()}catch(R){h(R instanceof Error?R.message:String(R))}finally{u(!1),g(0)}}}}),f("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?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ja,{className:"h-3 w-3"}),d?`Uploading… ${m}%`:"Upload addon (.tgz)"]}),d&&o("div",{className:"flex-1 h-1 rounded-full bg-muted overflow-hidden max-w-[140px]",children:o("div",{className:"h-full bg-primary transition-all",style:{width:`${m}%`}})}),p&&o("span",{className:"text-[10px] text-destructive",children:p})]});return k.length===0?f("div",{children:[z,o("div",{className:"py-4 text-xs text-muted-foreground text-center",children:w.isLoading?"Loading addons…":"No addons on this node"})]}):f("div",{children:[z,f("table",{className:"w-full text-xs",children:[o("thead",{children:f("tr",{className:"text-muted-foreground text-left",children:[o("th",{className:"py-2 font-medium",children:"Addon"}),o("th",{className:"py-2 font-medium",children:"Version"}),o("th",{className:"py-2 font-medium",children:"Capabilities"}),o("th",{className:"py-2 font-medium",children:"Status"}),o("th",{className:"py-2 font-medium w-16"})]})}),o("tbody",{children:k.map(A=>f("tr",{className:"border-t border-border/50",children:[f("td",{className:"py-2 font-medium",children:[o("div",{children:A.id}),A.packageName&&o("div",{className:"text-[9px] text-muted-foreground",children:A.packageName})]}),o("td",{className:"py-2 text-muted-foreground",children:A.version??"—"}),o("td",{className:"py-2",children:o("div",{className:"flex flex-wrap gap-1",children:A.capabilities.length>0?A.capabilities.map(O=>o("span",{className:"text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400",children:O},O)):o("span",{className:"text-muted-foreground",children:"—"})})}),o("td",{className:"py-2",children:o("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full ${A.status==="running"?"bg-success/10 text-success":A.status==="error"?"bg-destructive/10 text-destructive":"bg-muted text-muted-foreground"}`,children:A.status})}),o("td",{className:"py-2",children:f("div",{className:"flex items-center gap-1 justify-end",children:[o("button",{onClick:()=>M(A.id),disabled:a===A.id||l===A.id,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:`Restart ${A.id}`,children:o(St,{className:`h-3 w-3 ${a===A.id?"animate-spin":""}`})}),o("button",{onClick:()=>P(A.id),disabled:a===A.id||l===A.id,className:"p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50",title:`Uninstall ${A.id}`,children:l===A.id?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ze,{className:"h-3 w-3"})})]})})]},A.id))})]})]})}function vj(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 wj({state:e}){return o("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 Nj=["trace","debug","info","warn","error"];function kj({proc:e,nodeId:t,defaultExpanded:n,activePanel:r,onTogglePanel:s}){const a=e.services??[],i=a.length===1,[l,c]=_(i||n),[d,u]=_(null),[p,h]=_("info"),m=e.name.includes("(core)"),g=za(),b=kx(),x=Ix(),y=async N=>{u(N);try{await g.mutateAsync({nodeId:t,addonId:N})}catch(k){console.error("Failed to restart addon:",k)}finally{u(null)}},w=async()=>{u(e.name);try{await b.mutateAsync({nodeId:t,processName:e.name})}catch(N){console.error("Failed to restart process:",N)}finally{u(null)}},v=async N=>{const k=`${t}/${e.name}`;try{await x.mutateAsync({nodeId:k,level:N}),h(N)}catch(C){console.error("Failed to set log level:",C)}};return f("div",{className:"border border-border/50 rounded-lg overflow-hidden",children:[f("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?o("span",{className:"h-3 w-3 shrink-0"}):l?o(lt,{className:"h-3 w-3 text-muted-foreground shrink-0"}):o(Nt,{className:"h-3 w-3 text-muted-foreground shrink-0"}),m?o(mn,{className:"h-3.5 w-3.5 text-primary shrink-0"}):o(Wa,{className:"h-3.5 w-3.5 text-amber-500 shrink-0"}),o("span",{className:"text-xs font-semibold flex-1",children:e.name}),f("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:["PID ",e.pid]}),o(wj,{state:e.state}),f("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[e.cpuPercent,"% CPU"]}),o("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:It(e.memoryRss)}),o("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:vj(e.uptimeSeconds)}),!m&&f("div",{className:"flex items-center gap-1",onClick:N=>N.stopPropagation(),children:[f(dg,{children:[o(ug,{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}),o(pg,{align:"end",className:"min-w-[70px] py-0.5",children:Nj.map(N=>o(fg,{onClick:()=>v(N),className:`h-auto px-2 py-1 text-[10px] font-mono ${N===p?"text-primary font-semibold":""}`,children:N},N))})]}),o("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:o(St,{className:`h-3 w-3 ${d===e.name?"animate-spin":""}`})})]})]}),l&&a.length>0&&o("div",{className:"divide-y divide-border/30",children:a.map(N=>f("div",{children:[f("div",{className:"flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors",children:[o("div",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${N.status==="running"?"bg-success":"bg-muted-foreground/30"}`}),o("span",{className:"text-xs font-medium flex-1 min-w-0 truncate",children:N.addonId}),N.capabilities.length>0&&f("div",{className:"flex gap-1 flex-shrink-0",children:[N.capabilities.slice(0,3).map(k=>o("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&&f("span",{className:"text-[9px] text-muted-foreground",children:["+",N.capabilities.length-3]})]}),f("div",{className:"flex items-center gap-1 shrink-0",children:[o("button",{onClick:()=>s(N.addonId,"logs"),className:`p-0.5 rounded transition-colors ${r?.addonId===N.addonId&&r.type==="logs"?"bg-primary/10 text-primary":"hover:bg-muted text-muted-foreground hover:text-foreground"}`,title:`Show logs for ${N.addonId}`,children:o(it,{className:"h-3 w-3"})}),o("button",{onClick:()=>s(N.addonId,"events"),className:`p-0.5 rounded transition-colors ${r?.addonId===N.addonId&&r.type==="events"?"bg-primary/10 text-primary":"hover:bg-muted text-muted-foreground hover:text-foreground"}`,title:`Show events for ${N.addonId}`,children:o(Xa,{className:"h-3 w-3"})}),o("button",{onClick:()=>y(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:o(St,{className:`h-3 w-3 ${d===N.addonId?"animate-spin":""}`})})]})]}),r?.addonId===N.addonId&&r.type==="logs"&&o("div",{className:"border-t border-border/40 bg-muted/5",children:o(Ht,{addonId:N.addonId,agentId:t,maxHeight:"max-h-48",showFilters:!1,onClose:()=>s(N.addonId,"logs")})}),r?.addonId===N.addonId&&r.type==="events"&&o("div",{className:"border-t border-border/40 bg-muted/5",children:o(br,{addonId:N.addonId,category:"addon.*",maxHeight:"max-h-48",onClose:()=>s(N.addonId,"events")})})]},N.addonId))}),l&&a.length===0&&o("div",{className:"px-3 py-2 pl-9 text-[10px] text-muted-foreground",children:"No services"})]})}function Sj({nodeId:e,processes:t}){const[n,r]=_(null),s=(a,i)=>{r(l=>l?.addonId===a&&l.type===i?null:{addonId:a,type:i})};return t.length===0?o("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No processes on this node"}):o("div",{className:"space-y-2 py-1",children:t.map((a,i)=>o(kj,{proc:a,nodeId:e,defaultExpanded:i===0,activePanel:n,onTogglePanel:s},a.name))})}function Cj(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 Mj(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function Ej({nodeId:e}){const t=ke(),n=rt(),[r,s]=_("all"),a=Gr("metrics.node-processes-snapshot",k=>k.nodeId===e),{data:i}=yx({nodeId:e},{staleTime:6e4}),l=a?.processes??i,c=q(()=>l?[...l]:[],[l]),d=q(()=>r==="ghost"?c.filter(k=>k.classification==="ghost"):c,[c,r]),u=q(()=>{const k=c.filter(M=>M.classification==="ghost"),C=new Map;for(const M of k)C.has(M.ppid)||C.set(M.ppid,[]),C.get(M.ppid).push(M);return[...C.entries()].filter(([,M])=>M.length>1).map(([M,P])=>({ppid:M,children:P})).sort((M,P)=>P.children.length-M.children.length)},[c]),p=vx({onSettled:()=>{t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]})}}),h=q(()=>{const k=new Map;for(const C of c)k.set(C.pid,C.classification);return k},[c]),m=async(k,C)=>{if(k.classification==="root"||k.classification==="system")return;const M=k.classification==="ghost"?"ghost":k.addonId??"process",P=C?"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:C})},g=async(k,C)=>{try{await p.mutateAsync({nodeId:e,pid:k,force:C})}catch{}},b=async k=>{const C=h.get(k.ppid);if(C==="root"||C==="system"){await n({title:"Cannot kill protected ancestor",message:C==="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"]]}))},y=c.filter(k=>k.classification==="ghost").length,w=c.filter(k=>k.classification==="managed").length,v=c.filter(k=>k.classification==="root").length,N=c.filter(k=>k.classification==="system").length;return f("div",{className:"space-y-4",children:[f("div",{className:"flex items-start justify-between gap-4",children:[f("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."]}),f("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:[o(dt,{className:"h-3 w-3"})," Refresh"]})]}),f("div",{className:"grid grid-cols-4 gap-3",children:[f("div",{className:"rounded-lg border border-border p-3",children:[o("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"Root"}),o("div",{className:"text-xl font-semibold text-foreground",children:v})]}),f("div",{className:"rounded-lg border border-border p-3",children:[o("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"Managed"}),o("div",{className:"text-xl font-semibold text-foreground",children:w})]}),f("div",{className:"rounded-lg border border-border p-3",children:[o("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"System"}),o("div",{className:"text-xl font-semibold text-foreground",children:N})]}),f("div",{className:`rounded-lg border p-3 ${y>0?"border-destructive/40 bg-destructive/5":"border-border"}`,children:[f("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle flex items-center gap-1",children:[y>0&&o(vs,{className:"h-3 w-3 text-destructive"})," Ghosts"]}),o("div",{className:`text-xl font-semibold ${y>0?"text-destructive":"text-foreground"}`,children:y})]})]}),u.length>0&&f("div",{className:"rounded-lg border border-amber-500/40 bg-amber-500/5 p-3",children:[f("div",{className:"flex items-center gap-1 text-[11px] font-semibold text-amber-400 mb-2",children:[o(tt,{className:"h-3 w-3"})," Recurring ghost parents (",u.length,")"]}),o("div",{className:"space-y-1.5",children:u.map(k=>f("div",{className:"text-[11px] text-foreground flex items-center justify-between gap-2",children:[f("div",{className:"flex items-center gap-2",children:[f("span",{className:"font-mono text-foreground-subtle",children:["ppid ",k.ppid]}),f("span",{children:["→ ",k.children.length," ghost(s)"]})]}),f("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:[o(vs,{className:"h-3 w-3"})," Kill parent + ",k.children.length]})]},k.ppid))})]}),f("div",{className:"flex items-center justify-between gap-2 text-[11px]",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-foreground-subtle",children:"Filter:"}),f("button",{type:"button",className:`px-2 py-0.5 rounded ${r==="all"?"bg-primary text-primary-foreground":"border border-border text-foreground hover:bg-surface-hover"}`,onClick:()=>s("all"),children:["All (",c.length,")"]}),f("button",{type:"button",className:`px-2 py-0.5 rounded ${r==="ghost"?"bg-destructive text-destructive-foreground":"border border-border text-foreground hover:bg-surface-hover"}`,onClick:()=>s("ghost"),children:["Ghost only (",y,")"]})]}),y>0&&f("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:[o(vs,{className:"h-3 w-3"})," Kill all ",y," ghost(s)"]})]}),o("div",{className:"rounded-lg border border-border overflow-hidden",children:f("table",{className:"w-full text-xs",children:[o("thead",{className:"bg-surface",children:f("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[o("th",{className:"text-left px-3 py-2",children:"Class"}),o("th",{className:"text-right px-3 py-2",children:"PID"}),o("th",{className:"text-right px-3 py-2",children:"PPID"}),o("th",{className:"text-left px-3 py-2",children:"Addon"}),o("th",{className:"text-left px-3 py-2",children:"Command"}),o("th",{className:"text-right px-3 py-2",children:"CPU%"}),o("th",{className:"text-right px-3 py-2",children:"RSS"}),o("th",{className:"text-right px-3 py-2",children:"Uptime"}),o("th",{className:"w-44"})]})}),f("tbody",{children:[d.length===0&&o("tr",{children:o("td",{colSpan:9,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:r==="ghost"?"No ghost processes detected.":"Scanning…"})}),d.map(k=>f("tr",{className:`border-t border-border ${k.classification==="ghost"?"bg-destructive/5":""}`,children:[o("td",{className:"px-3 py-2",children:o("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})}),o("td",{className:"px-3 py-2 text-right font-mono text-foreground",children:k.pid}),f("td",{className:"px-3 py-2 text-right font-mono text-foreground-subtle",children:[k.ppid,k.orphaned?" ⚠":""]}),o("td",{className:"px-3 py-2 text-foreground-subtle text-[11px]",children:k.addonId??"—"}),o("td",{className:"px-3 py-2 font-mono text-[10px] text-foreground-subtle break-all",children:Mj(k.command)}),o("td",{className:"px-3 py-2 text-right text-foreground",children:k.cpuPercent.toFixed(1)}),o("td",{className:"px-3 py-2 text-right text-foreground",children:It(k.memoryRssBytes)}),o("td",{className:"px-3 py-2 text-right text-foreground-subtle",children:Cj(k.uptimeSec)}),o("td",{className:"px-3 py-2 text-right",children:f("div",{className:"inline-flex gap-1",children:[f("button",{type:"button",disabled:p.isPending||k.classification==="root"||k.classification==="system",onClick:()=>{m(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:[o(Ze,{className:"h-3 w-3"})," Term"]}),f("button",{type:"button",disabled:p.isPending||k.classification==="root"||k.classification==="system",onClick:()=>{m(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:[o(vs,{className:"h-3 w-3"})," Kill"]})]})})]},k.pid))]})]})}),p.isError&&f("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 Ij({nodeId:e,addonIds:t}){return t.length===0?o("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No addons on this node"}):o("div",{className:"w-full py-2",children:o(to,{nodeId:e,addonIds:t,level:"global"})})}function Aj({nodeId:e,addons:t}){const n=ke(),{data:r,isLoading:s}=Fx({nodeId:e}),a=q(()=>{const l=new Map;for(const c of t)for(const d of c.capabilities){const u=l.get(d)??[];u.push(c.id),l.set(d,u)}return[...l.entries()].sort(([c],[d])=>c.localeCompare(d)).map(([c,d])=>({capName:c,providers:d}))},[t]),i=jx({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCapabilityBindings"]]})}});return a.length===0?o("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No capabilities on this node"}):f("table",{className:"w-full text-xs",children:[o("thead",{children:f("tr",{className:"text-muted-foreground text-left",children:[o("th",{className:"py-2 font-medium w-1/2",children:"Capability"}),o("th",{className:"py-2 font-medium",children:"Bound provider"})]})}),o("tbody",{children:a.map(({capName:l,providers:c})=>{const u=r?.[l]??c[0]??"",p=c.length===1;return f("tr",{className:"border-t border-border/50",children:[o("td",{className:"py-2 font-medium",children:l}),o("td",{className:"py-2",children:o("select",{value:u,onChange:h=>i.mutate({nodeId:e,capName:l,addonId:h.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(h=>o("option",{value:h,children:h},h))})})]},l)})})]})}function Pj(e){if(e==null)return"—";const t=Math.floor(e/1e3),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),s=Math.floor(t%3600/60);return n>0?`${n}d ${r}h ${s}m`:r>0?`${r}h ${s}m`:`${s}m`}function _j(e){const[t,n]=_(!1),[r,s]=_(e.name),a=ke(),i=Cx({onSuccess:()=>{a.invalidateQueries({queryKey:[["nodes","topology"]]})}}),l=(e.localIps??[]).filter(p=>!p.includes(":")),c=(e.localIps??[]).filter(p=>p.includes(":")),d=async()=>{if(!r.trim()||r===e.name){n(!1);return}try{await i.mutateAsync({nodeId:e.nodeId,name:r.trim()}),n(!1)}catch(p){console.error("Rename failed:",p)}},u=[["Node ID",o("span",{className:"font-mono text-xs",children:e.nodeId})],["Display Name",t?f("div",{className:"flex items-center gap-1.5",children:[o("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:r,onChange:p=>s(p.target.value),onKeyDown:p=>{p.key==="Enter"&&d(),p.key==="Escape"&&n(!1)},disabled:i.isPending,autoFocus:!0}),o("button",{onClick:()=>void d(),disabled:i.isPending,className:"p-0.5 text-success hover:bg-success/10 rounded",title:"Save",children:o(_t,{className:"h-3.5 w-3.5"})}),o("button",{onClick:()=>n(!1),className:"p-0.5 text-muted-foreground hover:bg-muted rounded",title:"Cancel",children:o(Fe,{className:"h-3.5 w-3.5"})})]}):f("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"text-xs",children:e.name}),!e.isHub&&o("button",{onClick:()=>{s(e.name),n(!0)},className:"p-0.5 text-muted-foreground hover:text-primary rounded",title:"Rename",children:o(eo,{className:"h-3 w-3"})})]})],["Hostname",o("span",{className:"text-xs",children:e.hostname})],["Role",e.isHub?o("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium",children:"Hub"}):o("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium",children:"Agent"})],["Platform",f("span",{className:"text-xs",children:[e.platform," / ",e.arch]})],["CPU",f("span",{className:"text-xs",children:[e.cpuModel??"—"," (",e.cpuCores," cores)"]})],["Memory",o("span",{className:"text-xs",children:e.memoryMB>0?`${(e.memoryMB/1024).toFixed(1)} GB`:"—"})],["Uptime",o("span",{className:"text-xs",children:Pj(e.uptime)})],["Engines",e.engines.length>0?o("div",{className:"flex flex-wrap gap-1",children:e.engines.map(p=>o("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:p},p))}):o("span",{className:"text-xs text-muted-foreground",children:"—"})]];return l.length>0&&u.push(["IPv4",o("div",{className:"flex flex-wrap gap-1.5",children:l.map((p,h)=>o("span",{className:"font-mono text-xs px-1.5 py-0.5 rounded bg-muted",children:p},`${p}-${h}`))})]),c.length>0&&u.push(["IPv6",o("div",{className:"flex flex-wrap gap-1.5",children:c.map((p,h)=>o("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]",title:p,children:p},`${p}-${h}`))})]),o("div",{className:"py-2",children:o("table",{className:"w-full text-sm",children:o("tbody",{children:u.map(([p,h],m)=>f("tr",{className:m%2===0?"bg-muted/20":"",children:[o("td",{className:"py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap",children:p}),o("td",{className:"py-1.5 px-2",children:h})]},p))})})})}function $j({node:e}){const[t,n]=_("info"),r=e.processes??[],s=e.addons.map(a=>a.id);return e.isOnline?f("div",{className:"border border-border rounded-xl overflow-hidden",children:[f("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/30 border-b border-border",children:[o("div",{className:"w-2.5 h-2.5 rounded-full bg-success"}),o("span",{className:"text-sm font-semibold",children:e.name}),f("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=>o("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:a},a)),f("div",{className:"ml-auto flex gap-3 text-xs text-muted-foreground",children:[f("span",{className:"flex items-center gap-1",children:[o(xt,{className:"h-3 w-3"})," ",e.cpuPercent,"%"]}),f("span",{className:"flex items-center gap-1",children:[o(Wd,{className:"h-3 w-3"})," ",e.memoryPercent,"%"]})]})]}),o("div",{className:"flex border-b border-border px-4",children:["info","addons","forks","processes","settings","capabilities"].map(a=>o("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 (${r.length})`:a==="processes"?"Processes":a==="settings"?"Settings":"Capabilities"},a))}),f("div",{className:"px-4 py-2",children:[t==="info"&&o(_j,{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"&&o(yj,{nodeId:e.id,addons:e.addons,isHub:e.isHub}),t==="forks"&&o(Sj,{nodeId:e.id,processes:r}),t==="processes"&&o(Ej,{nodeId:e.id}),t==="settings"&&o(Ij,{nodeId:e.id,addonIds:s}),t==="capabilities"&&o(Aj,{nodeId:e.id,addons:e.addons})]})]}):f("div",{className:"border border-border rounded-xl overflow-hidden opacity-60",children:[f("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/30",children:[o("div",{className:"w-2.5 h-2.5 rounded-full bg-destructive"}),o("span",{className:"text-sm font-semibold",children:e.name}),f("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=>o("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:a},a)),o("span",{className:"ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:"offline"})]}),f("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 Dj({nodes:e}){const t=[...e].sort((n,r)=>n.isHub?-1:r.isHub?1:n.isOnline&&!r.isOnline?-1:!n.isOnline&&r.isOnline?1:n.name.localeCompare(r.name));return o("div",{className:"flex flex-col gap-4",children:t.map(n=>o($j,{node:n},n.id))})}function We(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=We(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Lj={value:()=>{}};function ai(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Gs(n)}function Gs(e){this._=e}function Tj(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");if(s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Gs.prototype=ai.prototype={constructor:Gs,on:function(e,t){var n=this._,r=Tj(e+"",n),s,a=-1,i=r.length;if(arguments.length<2){for(;++a<i;)if((s=(e=r[a]).type)&&(s=Rj(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=r[a]).type)n[s]=_f(n[s],e.name,t);else if(t==null)for(s in n)n[s]=_f(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),r=0,s,a;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],r=0,s=a.length;r<s;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],s=0,a=r.length;s<a;++s)r[s].value.apply(t,n)}};function Rj(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function _f(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=Lj,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var ic="http://www.w3.org/1999/xhtml";const $f={svg:"http://www.w3.org/2000/svg",xhtml:ic,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ii(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),$f.hasOwnProperty(t)?{space:$f[t],local:e}:e}function Oj(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===ic&&t.documentElement.namespaceURI===ic?t.createElement(e):t.createElementNS(n,e)}}function Bj(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Uv(e){var t=ii(e);return(t.local?Bj:Oj)(t)}function zj(){}function eu(e){return e==null?zj:function(){return this.querySelector(e)}}function Fj(e){typeof e!="function"&&(e=eu(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=r[s]=new Array(i),c,d,u=0;u<i;++u)(c=a[u])&&(d=e.call(c,c.__data__,u,a))&&("__data__"in c&&(d.__data__=c.__data__),l[u]=d);return new yt(r,this._parents)}function jj(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Vj(){return[]}function Qv(e){return e==null?Vj:function(){return this.querySelectorAll(e)}}function Hj(e){return function(){return jj(e.apply(this,arguments))}}function qj(e){typeof e=="function"?e=Hj(e):e=Qv(e);for(var t=this._groups,n=t.length,r=[],s=[],a=0;a<n;++a)for(var i=t[a],l=i.length,c,d=0;d<l;++d)(c=i[d])&&(r.push(e.call(c,c.__data__,d,i)),s.push(c));return new yt(r,s)}function Gv(e){return function(){return this.matches(e)}}function Kv(e){return function(t){return t.matches(e)}}var Uj=Array.prototype.find;function Qj(e){return function(){return Uj.call(this.children,e)}}function Gj(){return this.firstElementChild}function Kj(e){return this.select(e==null?Gj:Qj(typeof e=="function"?e:Kv(e)))}var Wj=Array.prototype.filter;function Yj(){return Array.from(this.children)}function Zj(e){return function(){return Wj.call(this.children,e)}}function Xj(e){return this.selectAll(e==null?Yj:Zj(typeof e=="function"?e:Kv(e)))}function Jj(e){typeof e!="function"&&(e=Gv(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=r[s]=[],c,d=0;d<i;++d)(c=a[d])&&e.call(c,c.__data__,d,a)&&l.push(c);return new yt(r,this._parents)}function Wv(e){return new Array(e.length)}function eV(){return new yt(this._enter||this._groups.map(Wv),this._parents)}function ha(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ha.prototype={constructor:ha,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 tV(e){return function(){return e}}function nV(e,t,n,r,s,a){for(var i=0,l,c=t.length,d=a.length;i<d;++i)(l=t[i])?(l.__data__=a[i],r[i]=l):n[i]=new ha(e,a[i]);for(;i<c;++i)(l=t[i])&&(s[i]=l)}function rV(e,t,n,r,s,a,i){var l,c,d=new Map,u=t.length,p=a.length,h=new Array(u),m;for(l=0;l<u;++l)(c=t[l])&&(h[l]=m=i.call(c,c.__data__,l,t)+"",d.has(m)?s[l]=c:d.set(m,c));for(l=0;l<p;++l)m=i.call(e,a[l],l,a)+"",(c=d.get(m))?(r[l]=c,c.__data__=a[l],d.delete(m)):n[l]=new ha(e,a[l]);for(l=0;l<u;++l)(c=t[l])&&d.get(h[l])===c&&(s[l]=c)}function oV(e){return e.__data__}function sV(e,t){if(!arguments.length)return Array.from(this,oV);var n=t?rV:nV,r=this._parents,s=this._groups;typeof e!="function"&&(e=tV(e));for(var a=s.length,i=new Array(a),l=new Array(a),c=new Array(a),d=0;d<a;++d){var u=r[d],p=s[d],h=p.length,m=aV(e.call(u,u&&u.__data__,d,r)),g=m.length,b=l[d]=new Array(g),x=i[d]=new Array(g),y=c[d]=new Array(h);n(u,p,b,x,y,m,t);for(var w=0,v=0,N,k;w<g;++w)if(N=b[w]){for(w>=v&&(v=w+1);!(k=x[v])&&++v<g;);N._next=k||null}}return i=new yt(i,r),i._enter=l,i._exit=c,i}function aV(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function iV(){return new yt(this._exit||this._groups.map(Wv),this._parents)}function lV(e,t,n){var r=this.enter(),s=this,a=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?a.remove():n(a),r&&s?r.merge(s).order():s}function cV(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,a=r.length,i=Math.min(s,a),l=new Array(s),c=0;c<i;++c)for(var d=n[c],u=r[c],p=d.length,h=l[c]=new Array(p),m,g=0;g<p;++g)(m=d[g]||u[g])&&(h[g]=m);for(;c<s;++c)l[c]=n[c];return new yt(l,this._parents)}function dV(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,a=r[s],i;--s>=0;)(i=r[s])&&(a&&i.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(i,a),a=i);return this}function uV(e){e||(e=pV);function t(p,h){return p&&h?e(p.__data__,h.__data__):!p-!h}for(var n=this._groups,r=n.length,s=new Array(r),a=0;a<r;++a){for(var i=n[a],l=i.length,c=s[a]=new Array(l),d,u=0;u<l;++u)(d=i[u])&&(c[u]=d);c.sort(t)}return new yt(s,this._parents).order()}function pV(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function fV(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function hV(){return Array.from(this)}function mV(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,a=r.length;s<a;++s){var i=r[s];if(i)return i}return null}function gV(){let e=0;for(const t of this)++e;return e}function bV(){return!this.node()}function xV(e){for(var t=this._groups,n=0,r=t.length;n<r;++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 yV(e){return function(){this.removeAttribute(e)}}function vV(e){return function(){this.removeAttributeNS(e.space,e.local)}}function wV(e,t){return function(){this.setAttribute(e,t)}}function NV(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function kV(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function SV(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 CV(e,t){var n=ii(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?vV:yV:typeof t=="function"?n.local?SV:kV:n.local?NV:wV)(n,t))}function Yv(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function MV(e){return function(){this.style.removeProperty(e)}}function EV(e,t,n){return function(){this.style.setProperty(e,t,n)}}function IV(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function AV(e,t,n){return arguments.length>1?this.each((t==null?MV:typeof t=="function"?IV:EV)(e,t,n??"")):Tr(this.node(),e)}function Tr(e,t){return e.style.getPropertyValue(t)||Yv(e).getComputedStyle(e,null).getPropertyValue(t)}function PV(e){return function(){delete this[e]}}function _V(e,t){return function(){this[e]=t}}function $V(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function DV(e,t){return arguments.length>1?this.each((t==null?PV:typeof t=="function"?$V:_V)(e,t)):this.node()[e]}function Zv(e){return e.trim().split(/^|\s+/)}function tu(e){return e.classList||new Xv(e)}function Xv(e){this._node=e,this._names=Zv(e.getAttribute("class")||"")}Xv.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 Jv(e,t){for(var n=tu(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function e1(e,t){for(var n=tu(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function LV(e){return function(){Jv(this,e)}}function TV(e){return function(){e1(this,e)}}function RV(e,t){return function(){(t.apply(this,arguments)?Jv:e1)(this,e)}}function OV(e,t){var n=Zv(e+"");if(arguments.length<2){for(var r=tu(this.node()),s=-1,a=n.length;++s<a;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?RV:t?LV:TV)(n,t))}function BV(){this.textContent=""}function zV(e){return function(){this.textContent=e}}function FV(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function jV(e){return arguments.length?this.each(e==null?BV:(typeof e=="function"?FV:zV)(e)):this.node().textContent}function VV(){this.innerHTML=""}function HV(e){return function(){this.innerHTML=e}}function qV(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function UV(e){return arguments.length?this.each(e==null?VV:(typeof e=="function"?qV:HV)(e)):this.node().innerHTML}function QV(){this.nextSibling&&this.parentNode.appendChild(this)}function GV(){return this.each(QV)}function KV(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function WV(){return this.each(KV)}function YV(e){var t=typeof e=="function"?e:Uv(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function ZV(){return null}function XV(e,t){var n=typeof e=="function"?e:Uv(e),r=t==null?ZV:typeof t=="function"?t:eu(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function JV(){var e=this.parentNode;e&&e.removeChild(this)}function eH(){return this.each(JV)}function tH(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function nH(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function rH(e){return this.select(e?nH:tH)}function oH(e){return arguments.length?this.property("__data__",e):this.node().__data__}function sH(e){return function(t){e.call(this,t,this.__data__)}}function aH(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function iH(e){return function(){var t=this.__on;if(t){for(var n=0,r=-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[++r]=a;++r?t.length=r:delete this.__on}}}function lH(e,t,n){return function(){var r=this.__on,s,a=sH(t);if(r){for(var i=0,l=r.length;i<l;++i)if((s=r[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},r?r.push(s):this.__on=[s]}}function cH(e,t,n){var r=aH(e+""),s,a=r.length,i;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,d=l.length,u;c<d;++c)for(s=0,u=l[c];s<a;++s)if((i=r[s]).type===u.type&&i.name===u.name)return u.value}return}for(l=t?lH:iH,s=0;s<a;++s)this.each(l(r[s],t,n));return this}function t1(e,t,n){var r=Yv(e),s=r.CustomEvent;typeof s=="function"?s=new s(t,n):(s=r.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function dH(e,t){return function(){return t1(this,e,t)}}function uH(e,t){return function(){return t1(this,e,t.apply(this,arguments))}}function pH(e,t){return this.each((typeof t=="function"?uH:dH)(e,t))}function*fH(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,a=r.length,i;s<a;++s)(i=r[s])&&(yield i)}var n1=[null];function yt(e,t){this._groups=e,this._parents=t}function rs(){return new yt([[document.documentElement]],n1)}function hH(){return this}yt.prototype=rs.prototype={constructor:yt,select:Fj,selectAll:qj,selectChild:Kj,selectChildren:Xj,filter:Jj,data:sV,enter:eV,exit:iV,join:lV,merge:cV,selection:hH,order:dV,sort:uV,call:fV,nodes:hV,node:mV,size:gV,empty:bV,each:xV,attr:CV,style:AV,property:DV,classed:OV,text:jV,html:UV,raise:GV,lower:WV,append:YV,insert:XV,remove:eH,clone:rH,datum:oH,on:cH,dispatch:pH,[Symbol.iterator]:fH};function mt(e){return typeof e=="string"?new yt([[document.querySelector(e)]],[document.documentElement]):new yt([[e]],n1)}function mH(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Tt(e,t){if(e=mH(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.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 gH={passive:!1},To={capture:!0,passive:!1};function cl(e){e.stopImmediatePropagation()}function Ar(e){e.preventDefault(),e.stopImmediatePropagation()}function r1(e){var t=e.document.documentElement,n=mt(e).on("dragstart.drag",Ar,To);"onselectstart"in t?n.on("selectstart.drag",Ar,To):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function o1(e,t){var n=e.document.documentElement,r=mt(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ar,To),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const _s=e=>()=>e;function lc(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:a,x:i,y:l,dx:c,dy:d,dispatch:u}){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:r,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:u}})}lc.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function bH(e){return!e.ctrlKey&&!e.button}function xH(){return this.parentNode}function yH(e,t){return t??{x:e.x,y:e.y}}function vH(){return navigator.maxTouchPoints||"ontouchstart"in this}function s1(){var e=bH,t=xH,n=yH,r=vH,s={},a=ai("start","drag","end"),i=0,l,c,d,u,p=0;function h(N){N.on("mousedown.drag",m).filter(r).on("touchstart.drag",x).on("touchmove.drag",y,gH).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(N,k){if(!(u||!e.call(this,N,k))){var C=v(this,t.call(this,N,k),N,k,"mouse");C&&(mt(N.view).on("mousemove.drag",g,To).on("mouseup.drag",b,To),r1(N.view),cl(N),d=!1,l=N.clientX,c=N.clientY,C("start",N))}}function g(N){if(Ar(N),!d){var k=N.clientX-l,C=N.clientY-c;d=k*k+C*C>p}s.mouse("drag",N)}function b(N){mt(N.view).on("mousemove.drag mouseup.drag",null),o1(N.view,d),Ar(N),s.mouse("end",N)}function x(N,k){if(e.call(this,N,k)){var C=N.changedTouches,M=t.call(this,N,k),P=C.length,I,z;for(I=0;I<P;++I)(z=v(this,M,N,k,C[I].identifier,C[I]))&&(cl(N),z("start",N,C[I]))}}function y(N){var k=N.changedTouches,C=k.length,M,P;for(M=0;M<C;++M)(P=s[k[M].identifier])&&(Ar(N),P("drag",N,k[M]))}function w(N){var k=N.changedTouches,C=k.length,M,P;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),M=0;M<C;++M)(P=s[k[M].identifier])&&(cl(N),P("end",N,k[M]))}function v(N,k,C,M,P,I){var z=a.copy(),A=Tt(I||C,k),O,R,E;if((E=n.call(N,new lc("beforestart",{sourceEvent:C,target:h,identifier:P,active:i,x:A[0],y:A[1],dx:0,dy:0,dispatch:z}),M))!=null)return O=E.x-A[0]||0,R=E.y-A[1]||0,function D(L,T,B){var F=A,j;switch(L){case"start":s[P]=D,j=i++;break;case"end":delete s[P],--i;case"drag":A=Tt(B||T,k),j=i;break}z.call(L,N,new lc(L,{sourceEvent:T,subject:E,target:h,identifier:P,active:j,x:A[0]+O,y:A[1]+R,dx:A[0]-F[0],dy:A[1]-F[1],dispatch:z}),M)}}return h.filter=function(N){return arguments.length?(e=typeof N=="function"?N:_s(!!N),h):e},h.container=function(N){return arguments.length?(t=typeof N=="function"?N:_s(N),h):t},h.subject=function(N){return arguments.length?(n=typeof N=="function"?N:_s(N),h):n},h.touchable=function(N){return arguments.length?(r=typeof N=="function"?N:_s(!!N),h):r},h.on=function(){var N=a.on.apply(a,arguments);return N===a?h:N},h.clickDistance=function(N){return arguments.length?(p=(N=+N)*N,h):Math.sqrt(p)},h}function nu(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function a1(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function os(){}var Ro=.7,ma=1/Ro,Pr="\\s*([+-]?\\d+)\\s*",Oo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",wH=/^#([0-9a-f]{3,8})$/,NH=new RegExp(`^rgb\\(${Pr},${Pr},${Pr}\\)$`),kH=new RegExp(`^rgb\\(${Xt},${Xt},${Xt}\\)$`),SH=new RegExp(`^rgba\\(${Pr},${Pr},${Pr},${Oo}\\)$`),CH=new RegExp(`^rgba\\(${Xt},${Xt},${Xt},${Oo}\\)$`),MH=new RegExp(`^hsl\\(${Oo},${Xt},${Xt}\\)$`),EH=new RegExp(`^hsla\\(${Oo},${Xt},${Xt},${Oo}\\)$`),Df={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};nu(os,ar,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Lf,formatHex:Lf,formatHex8:IH,formatHsl:AH,formatRgb:Tf,toString:Tf});function Lf(){return this.rgb().formatHex()}function IH(){return this.rgb().formatHex8()}function AH(){return i1(this).formatHsl()}function Tf(){return this.rgb().formatRgb()}function ar(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=wH.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Rf(t):n===3?new at(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?$s(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?$s(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=NH.exec(e))?new at(t[1],t[2],t[3],1):(t=kH.exec(e))?new at(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=SH.exec(e))?$s(t[1],t[2],t[3],t[4]):(t=CH.exec(e))?$s(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=MH.exec(e))?zf(t[1],t[2]/100,t[3]/100,1):(t=EH.exec(e))?zf(t[1],t[2]/100,t[3]/100,t[4]):Df.hasOwnProperty(e)?Rf(Df[e]):e==="transparent"?new at(NaN,NaN,NaN,0):null}function Rf(e){return new at(e>>16&255,e>>8&255,e&255,1)}function $s(e,t,n,r){return r<=0&&(e=t=n=NaN),new at(e,t,n,r)}function PH(e){return e instanceof os||(e=ar(e)),e?(e=e.rgb(),new at(e.r,e.g,e.b,e.opacity)):new at}function cc(e,t,n,r){return arguments.length===1?PH(e):new at(e,t,n,r??1)}function at(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}nu(at,cc,a1(os,{brighter(e){return e=e==null?ma:Math.pow(ma,e),new at(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ro:Math.pow(Ro,e),new at(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new at(Yn(this.r),Yn(this.g),Yn(this.b),ga(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:Of,formatHex:Of,formatHex8:_H,formatRgb:Bf,toString:Bf}));function Of(){return`#${Qn(this.r)}${Qn(this.g)}${Qn(this.b)}`}function _H(){return`#${Qn(this.r)}${Qn(this.g)}${Qn(this.b)}${Qn((isNaN(this.opacity)?1:this.opacity)*255)}`}function Bf(){const e=ga(this.opacity);return`${e===1?"rgb(":"rgba("}${Yn(this.r)}, ${Yn(this.g)}, ${Yn(this.b)}${e===1?")":`, ${e})`}`}function ga(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Yn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Qn(e){return e=Yn(e),(e<16?"0":"")+e.toString(16)}function zf(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Rt(e,t,n,r)}function i1(e){if(e instanceof Rt)return new Rt(e.h,e.s,e.l,e.opacity);if(e instanceof os||(e=ar(e)),!e)return new Rt;if(e instanceof Rt)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),a=Math.max(t,n,r),i=NaN,l=a-s,c=(a+s)/2;return l?(t===a?i=(n-r)/l+(n<r)*6:n===a?i=(r-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 Rt(i,l,c,e.opacity)}function $H(e,t,n,r){return arguments.length===1?i1(e):new Rt(e,t,n,r??1)}function Rt(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}nu(Rt,$H,a1(os,{brighter(e){return e=e==null?ma:Math.pow(ma,e),new Rt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ro:Math.pow(Ro,e),new Rt(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,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new at(dl(e>=240?e-240:e+120,s,r),dl(e,s,r),dl(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Rt(Ff(this.h),Ds(this.s),Ds(this.l),ga(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=ga(this.opacity);return`${e===1?"hsl(":"hsla("}${Ff(this.h)}, ${Ds(this.s)*100}%, ${Ds(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ff(e){return e=(e||0)%360,e<0?e+360:e}function Ds(e){return Math.max(0,Math.min(1,e||0))}function dl(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 ru=e=>()=>e;function DH(e,t){return function(n){return e+n*t}}function LH(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function TH(e){return(e=+e)==1?l1:function(t,n){return n-t?LH(t,n,e):ru(isNaN(t)?n:t)}}function l1(e,t){var n=t-e;return n?DH(e,n):ru(isNaN(e)?t:e)}const ba=(function e(t){var n=TH(t);function r(s,a){var i=n((s=cc(s)).r,(a=cc(a)).r),l=n(s.g,a.g),c=n(s.b,a.b),d=l1(s.opacity,a.opacity);return function(u){return s.r=i(u),s.g=l(u),s.b=c(u),s.opacity=d(u),s+""}}return r.gamma=e,r})(1);function RH(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),s;return function(a){for(s=0;s<n;++s)r[s]=e[s]*(1-a)+t[s]*a;return r}}function OH(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function BH(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,s=new Array(r),a=new Array(n),i;for(i=0;i<r;++i)s[i]=So(e[i],t[i]);for(;i<n;++i)a[i]=t[i];return function(l){for(i=0;i<r;++i)a[i]=s[i](l);return a}}function zH(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Kt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function FH(e,t){var n={},r={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=So(e[s],t[s]):r[s]=t[s];return function(a){for(s in n)r[s]=n[s](a);return r}}var dc=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ul=new RegExp(dc.source,"g");function jH(e){return function(){return e}}function VH(e){return function(t){return e(t)+""}}function c1(e,t){var n=dc.lastIndex=ul.lastIndex=0,r,s,a,i=-1,l=[],c=[];for(e=e+"",t=t+"";(r=dc.exec(e))&&(s=ul.exec(t));)(a=s.index)>n&&(a=t.slice(n,a),l[i]?l[i]+=a:l[++i]=a),(r=r[0])===(s=s[0])?l[i]?l[i]+=s:l[++i]=s:(l[++i]=null,c.push({i,x:Kt(r,s)})),n=ul.lastIndex;return n<t.length&&(a=t.slice(n),l[i]?l[i]+=a:l[++i]=a),l.length<2?c[0]?VH(c[0].x):jH(t):(t=c.length,function(d){for(var u=0,p;u<t;++u)l[(p=c[u]).i]=p.x(d);return l.join("")})}function So(e,t){var n=typeof t,r;return t==null||n==="boolean"?ru(t):(n==="number"?Kt:n==="string"?(r=ar(t))?(t=r,ba):c1:t instanceof ar?ba:t instanceof Date?zH:OH(t)?RH:Array.isArray(t)?BH:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?FH:Kt)(e,t)}var jf=180/Math.PI,uc={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function d1(e,t,n,r,s,a){var i,l,c;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,c/=l),e*r<t*n&&(e=-e,t=-t,c=-c,i=-i),{translateX:s,translateY:a,rotate:Math.atan2(t,e)*jf,skewX:Math.atan(c)*jf,scaleX:i,scaleY:l}}var Ls;function HH(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?uc:d1(t.a,t.b,t.c,t.d,t.e,t.f)}function qH(e){return e==null||(Ls||(Ls=document.createElementNS("http://www.w3.org/2000/svg","g")),Ls.setAttribute("transform",e),!(e=Ls.transform.baseVal.consolidate()))?uc:(e=e.matrix,d1(e.a,e.b,e.c,e.d,e.e,e.f))}function u1(e,t,n,r){function s(d){return d.length?d.pop()+" ":""}function a(d,u,p,h,m,g){if(d!==p||u!==h){var b=m.push("translate(",null,t,null,n);g.push({i:b-4,x:Kt(d,p)},{i:b-2,x:Kt(u,h)})}else(p||h)&&m.push("translate("+p+t+h+n)}function i(d,u,p,h){d!==u?(d-u>180?u+=360:u-d>180&&(d+=360),h.push({i:p.push(s(p)+"rotate(",null,r)-2,x:Kt(d,u)})):u&&p.push(s(p)+"rotate("+u+r)}function l(d,u,p,h){d!==u?h.push({i:p.push(s(p)+"skewX(",null,r)-2,x:Kt(d,u)}):u&&p.push(s(p)+"skewX("+u+r)}function c(d,u,p,h,m,g){if(d!==p||u!==h){var b=m.push(s(m)+"scale(",null,",",null,")");g.push({i:b-4,x:Kt(d,p)},{i:b-2,x:Kt(u,h)})}else(p!==1||h!==1)&&m.push(s(m)+"scale("+p+","+h+")")}return function(d,u){var p=[],h=[];return d=e(d),u=e(u),a(d.translateX,d.translateY,u.translateX,u.translateY,p,h),i(d.rotate,u.rotate,p,h),l(d.skewX,u.skewX,p,h),c(d.scaleX,d.scaleY,u.scaleX,u.scaleY,p,h),d=u=null,function(m){for(var g=-1,b=h.length,x;++g<b;)p[(x=h[g]).i]=x.x(m);return p.join("")}}}var UH=u1(HH,"px, ","px)","deg)"),QH=u1(qH,", ",")",")"),GH=1e-12;function Vf(e){return((e=Math.exp(e))+1/e)/2}function KH(e){return((e=Math.exp(e))-1/e)/2}function WH(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ks=(function e(t,n,r){function s(a,i){var l=a[0],c=a[1],d=a[2],u=i[0],p=i[1],h=i[2],m=u-l,g=p-c,b=m*m+g*g,x,y;if(b<GH)y=Math.log(h/d)/t,x=function(M){return[l+M*m,c+M*g,d*Math.exp(t*M*y)]};else{var w=Math.sqrt(b),v=(h*h-d*d+r*b)/(2*d*n*w),N=(h*h-d*d-r*b)/(2*h*n*w),k=Math.log(Math.sqrt(v*v+1)-v),C=Math.log(Math.sqrt(N*N+1)-N);y=(C-k)/t,x=function(M){var P=M*y,I=Vf(k),z=d/(n*w)*(I*WH(t*P+k)-KH(k));return[l+z*m,c+z*g,d*I/Vf(t*P+k)]}}return x.duration=y*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 Rr=0,ho=0,co=0,p1=1e3,xa,mo,ya=0,ir=0,li=0,Bo=typeof performance=="object"&&performance.now?performance:Date,f1=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ou(){return ir||(f1(YH),ir=Bo.now()+li)}function YH(){ir=0}function va(){this._call=this._time=this._next=null}va.prototype=h1.prototype={constructor:va,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ou():+n)+(t==null?0:+t),!this._next&&mo!==this&&(mo?mo._next=this:xa=this,mo=this),this._call=e,this._time=n,pc()},stop:function(){this._call&&(this._call=null,this._time=1/0,pc())}};function h1(e,t,n){var r=new va;return r.restart(e,t,n),r}function ZH(){ou(),++Rr;for(var e=xa,t;e;)(t=ir-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Rr}function Hf(){ir=(ya=Bo.now())+li,Rr=ho=0;try{ZH()}finally{Rr=0,JH(),ir=0}}function XH(){var e=Bo.now(),t=e-ya;t>p1&&(li-=t,ya=e)}function JH(){for(var e,t=xa,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:xa=n);mo=e,pc(r)}function pc(e){if(!Rr){ho&&(ho=clearTimeout(ho));var t=e-ir;t>24?(e<1/0&&(ho=setTimeout(Hf,e-Bo.now()-li)),co&&(co=clearInterval(co))):(co||(ya=Bo.now(),co=setInterval(XH,p1)),Rr=1,f1(Hf))}}function qf(e,t,n){var r=new va;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var eq=ai("start","end","cancel","interrupt"),tq=[],m1=0,Uf=1,fc=2,Ws=3,Qf=4,hc=5,Ys=6;function ci(e,t,n,r,s,a){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;nq(e,n,{name:t,index:r,group:s,on:eq,tween:tq,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:m1})}function su(e,t){var n=Ut(e,t);if(n.state>m1)throw new Error("too late; already scheduled");return n}function on(e,t){var n=Ut(e,t);if(n.state>Ws)throw new Error("too late; already running");return n}function Ut(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function nq(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=h1(a,0,n.time);function a(d){n.state=Uf,n.timer.restart(i,n.delay,n.time),n.delay<=d&&i(d-n.delay)}function i(d){var u,p,h,m;if(n.state!==Uf)return c();for(u in r)if(m=r[u],m.name===n.name){if(m.state===Ws)return qf(i);m.state===Qf?(m.state=Ys,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[u]):+u<t&&(m.state=Ys,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[u])}if(qf(function(){n.state===Ws&&(n.state=Qf,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=fc,n.on.call("start",e,e.__data__,n.index,n.group),n.state===fc){for(n.state=Ws,s=new Array(h=n.tween.length),u=0,p=-1;u<h;++u)(m=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(s[++p]=m);s.length=p+1}}function l(d){for(var u=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(c),n.state=hc,1),p=-1,h=s.length;++p<h;)s[p].call(e,u);n.state===hc&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Ys,n.timer.stop(),delete r[t];for(var d in r)return;delete e.__transition}}function Zs(e,t){var n=e.__transition,r,s,a=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((r=n[i]).name!==t){a=!1;continue}s=r.state>fc&&r.state<hc,r.state=Ys,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}a&&delete e.__transition}}function rq(e){return this.each(function(){Zs(this,e)})}function oq(e,t){var n,r;return function(){var s=on(this,e),a=s.tween;if(a!==n){r=n=a;for(var i=0,l=r.length;i<l;++i)if(r[i].name===t){r=r.slice(),r.splice(i,1);break}}s.tween=r}}function sq(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var a=on(this,e),i=a.tween;if(i!==r){s=(r=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 aq(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Ut(this.node(),n).tween,s=0,a=r.length,i;s<a;++s)if((i=r[s]).name===e)return i.value;return null}return this.each((t==null?oq:sq)(n,e,t))}function au(e,t,n){var r=e._id;return e.each(function(){var s=on(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Ut(s,r).value[t]}}function g1(e,t){var n;return(typeof t=="number"?Kt:t instanceof ar?ba:(n=ar(t))?(t=n,ba):c1)(e,t)}function iq(e){return function(){this.removeAttribute(e)}}function lq(e){return function(){this.removeAttributeNS(e.space,e.local)}}function cq(e,t,n){var r,s=n+"",a;return function(){var i=this.getAttribute(e);return i===s?null:i===r?a:a=t(r=i,n)}}function dq(e,t,n){var r,s=n+"",a;return function(){var i=this.getAttributeNS(e.space,e.local);return i===s?null:i===r?a:a=t(r=i,n)}}function uq(e,t,n){var r,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===r&&c===s?a:(s=c,a=t(r=i,l)))}}function pq(e,t,n){var r,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===r&&c===s?a:(s=c,a=t(r=i,l)))}}function fq(e,t){var n=ii(e),r=n==="transform"?QH:g1;return this.attrTween(e,typeof t=="function"?(n.local?pq:uq)(n,r,au(this,"attr."+e,t)):t==null?(n.local?lq:iq)(n):(n.local?dq:cq)(n,r,t))}function hq(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function mq(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function gq(e,t){var n,r;function s(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&mq(e,a)),n}return s._value=t,s}function bq(e,t){var n,r;function s(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&hq(e,a)),n}return s._value=t,s}function xq(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 r=ii(e);return this.tween(n,(r.local?gq:bq)(r,t))}function yq(e,t){return function(){su(this,e).delay=+t.apply(this,arguments)}}function vq(e,t){return t=+t,function(){su(this,e).delay=t}}function wq(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?yq:vq)(t,e)):Ut(this.node(),t).delay}function Nq(e,t){return function(){on(this,e).duration=+t.apply(this,arguments)}}function kq(e,t){return t=+t,function(){on(this,e).duration=t}}function Sq(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Nq:kq)(t,e)):Ut(this.node(),t).duration}function Cq(e,t){if(typeof t!="function")throw new Error;return function(){on(this,e).ease=t}}function Mq(e){var t=this._id;return arguments.length?this.each(Cq(t,e)):Ut(this.node(),t).ease}function Eq(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;on(this,e).ease=n}}function Iq(e){if(typeof e!="function")throw new Error;return this.each(Eq(this._id,e))}function Aq(e){typeof e!="function"&&(e=Gv(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=r[s]=[],c,d=0;d<i;++d)(c=a[d])&&e.call(c,c.__data__,d,a)&&l.push(c);return new xn(r,this._parents,this._name,this._id)}function Pq(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,a=Math.min(r,s),i=new Array(r),l=0;l<a;++l)for(var c=t[l],d=n[l],u=c.length,p=i[l]=new Array(u),h,m=0;m<u;++m)(h=c[m]||d[m])&&(p[m]=h);for(;l<r;++l)i[l]=t[l];return new xn(i,this._parents,this._name,this._id)}function _q(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 $q(e,t,n){var r,s,a=_q(t)?su:on;return function(){var i=a(this,e),l=i.on;l!==r&&(s=(r=l).copy()).on(t,n),i.on=s}}function Dq(e,t){var n=this._id;return arguments.length<2?Ut(this.node(),n).on.on(e):this.each($q(n,e,t))}function Lq(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Tq(){return this.on("end.remove",Lq(this._id))}function Rq(e){var t=this._name,n=this._id;typeof e!="function"&&(e=eu(e));for(var r=this._groups,s=r.length,a=new Array(s),i=0;i<s;++i)for(var l=r[i],c=l.length,d=a[i]=new Array(c),u,p,h=0;h<c;++h)(u=l[h])&&(p=e.call(u,u.__data__,h,l))&&("__data__"in u&&(p.__data__=u.__data__),d[h]=p,ci(d[h],t,n,h,d,Ut(u,n)));return new xn(a,this._parents,t,n)}function Oq(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Qv(e));for(var r=this._groups,s=r.length,a=[],i=[],l=0;l<s;++l)for(var c=r[l],d=c.length,u,p=0;p<d;++p)if(u=c[p]){for(var h=e.call(u,u.__data__,p,c),m,g=Ut(u,n),b=0,x=h.length;b<x;++b)(m=h[b])&&ci(m,t,n,b,h,g);a.push(h),i.push(u)}return new xn(a,i,t,n)}var Bq=rs.prototype.constructor;function zq(){return new Bq(this._groups,this._parents)}function Fq(e,t){var n,r,s;return function(){var a=Tr(this,e),i=(this.style.removeProperty(e),Tr(this,e));return a===i?null:a===n&&i===r?s:s=t(n=a,r=i)}}function b1(e){return function(){this.style.removeProperty(e)}}function jq(e,t,n){var r,s=n+"",a;return function(){var i=Tr(this,e);return i===s?null:i===r?a:a=t(r=i,n)}}function Vq(e,t,n){var r,s,a;return function(){var i=Tr(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),Tr(this,e))),i===c?null:i===r&&c===s?a:(s=c,a=t(r=i,l))}}function Hq(e,t){var n,r,s,a="style."+t,i="end."+a,l;return function(){var c=on(this,e),d=c.on,u=c.value[a]==null?l||(l=b1(t)):void 0;(d!==n||s!==u)&&(r=(n=d).copy()).on(i,s=u),c.on=r}}function qq(e,t,n){var r=(e+="")=="transform"?UH:g1;return t==null?this.styleTween(e,Fq(e,r)).on("end.style."+e,b1(e)):typeof t=="function"?this.styleTween(e,Vq(e,r,au(this,"style."+e,t))).each(Hq(this._id,e)):this.styleTween(e,jq(e,r,t),n).on("end.style."+e,null)}function Uq(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Qq(e,t,n){var r,s;function a(){var i=t.apply(this,arguments);return i!==s&&(r=(s=i)&&Uq(e,i,n)),r}return a._value=t,a}function Gq(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,Qq(e,t,n??""))}function Kq(e){return function(){this.textContent=e}}function Wq(e){return function(){var t=e(this);this.textContent=t??""}}function Yq(e){return this.tween("text",typeof e=="function"?Wq(au(this,"text",e)):Kq(e==null?"":e+""))}function Zq(e){return function(t){this.textContent=e.call(this,t)}}function Xq(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&Zq(s)),t}return r._value=e,r}function Jq(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,Xq(e))}function eU(){for(var e=this._name,t=this._id,n=x1(),r=this._groups,s=r.length,a=0;a<s;++a)for(var i=r[a],l=i.length,c,d=0;d<l;++d)if(c=i[d]){var u=Ut(c,t);ci(c,e,n,d,i,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new xn(r,this._parents,e,n)}function tU(){var e,t,n=this,r=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=on(this,r),u=d.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),d.on=t}),s===0&&a()})}var nU=0;function xn(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function x1(){return++nU}var ln=rs.prototype;xn.prototype={constructor:xn,select:Rq,selectAll:Oq,selectChild:ln.selectChild,selectChildren:ln.selectChildren,filter:Aq,merge:Pq,selection:zq,transition:eU,call:ln.call,nodes:ln.nodes,node:ln.node,size:ln.size,empty:ln.empty,each:ln.each,on:Dq,attr:fq,attrTween:xq,style:qq,styleTween:Gq,text:Yq,textTween:Jq,remove:Tq,tween:aq,delay:wq,duration:Sq,ease:Mq,easeVarying:Iq,end:tU,[Symbol.iterator]:ln[Symbol.iterator]};function rU(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var oU={time:null,delay:0,duration:250,ease:rU};function sU(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 aU(e){var t,n;e instanceof xn?(t=e._id,e=e._name):(t=x1(),(n=oU).time=ou(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,a=0;a<s;++a)for(var i=r[a],l=i.length,c,d=0;d<l;++d)(c=i[d])&&ci(c,e,t,d,i,n||sU(c,t));return new xn(r,this._parents,e,t)}rs.prototype.interrupt=rq;rs.prototype.transition=aU;const Ts=e=>()=>e;function iU(e,{sourceEvent:t,target:n,transform:r,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:r,enumerable:!0,configurable:!0},_:{value:s}})}function un(e,t,n){this.k=e,this.x=t,this.y=n}un.prototype={constructor:un,scale:function(e){return e===1?this:new un(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new un(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 di=new un(1,0,0);y1.prototype=un.prototype;function y1(e){for(;!e.__zoom;)if(!(e=e.parentNode))return di;return e.__zoom}function pl(e){e.stopImmediatePropagation()}function uo(e){e.preventDefault(),e.stopImmediatePropagation()}function lU(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function cU(){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 Gf(){return this.__zoom||di}function dU(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function uU(){return navigator.maxTouchPoints||"ontouchstart"in this}function pU(e,t,n){var r=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>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),i>a?(a+i)/2:Math.min(0,a)||Math.max(0,i))}function v1(){var e=lU,t=cU,n=pU,r=dU,s=uU,a=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,c=Ks,d=ai("start","zoom","end"),u,p,h,m=500,g=150,b=0,x=10;function y(E){E.property("__zoom",Gf).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",z).filter(s).on("touchstart.zoom",A).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",R).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(E,D,L,T){var B=E.selection?E.selection():E;B.property("__zoom",Gf),E!==B?k(E,D,L,T):B.interrupt().each(function(){C(this,arguments).event(T).start().zoom(null,typeof D=="function"?D.apply(this,arguments):D).end()})},y.scaleBy=function(E,D,L,T){y.scaleTo(E,function(){var B=this.__zoom.k,F=typeof D=="function"?D.apply(this,arguments):D;return B*F},L,T)},y.scaleTo=function(E,D,L,T){y.transform(E,function(){var B=t.apply(this,arguments),F=this.__zoom,j=L==null?N(B):typeof L=="function"?L.apply(this,arguments):L,V=F.invert(j),$=typeof D=="function"?D.apply(this,arguments):D;return n(v(w(F,$),j,V),B,i)},L,T)},y.translateBy=function(E,D,L,T){y.transform(E,function(){return n(this.__zoom.translate(typeof D=="function"?D.apply(this,arguments):D,typeof L=="function"?L.apply(this,arguments):L),t.apply(this,arguments),i)},null,T)},y.translateTo=function(E,D,L,T,B){y.transform(E,function(){var F=t.apply(this,arguments),j=this.__zoom,V=T==null?N(F):typeof T=="function"?T.apply(this,arguments):T;return n(di.translate(V[0],V[1]).scale(j.k).translate(typeof D=="function"?-D.apply(this,arguments):-D,typeof L=="function"?-L.apply(this,arguments):-L),F,i)},T,B)};function w(E,D){return D=Math.max(a[0],Math.min(a[1],D)),D===E.k?E:new un(D,E.x,E.y)}function v(E,D,L){var T=D[0]-L[0]*E.k,B=D[1]-L[1]*E.k;return T===E.x&&B===E.y?E:new un(E.k,T,B)}function N(E){return[(+E[0][0]+ +E[1][0])/2,(+E[0][1]+ +E[1][1])/2]}function k(E,D,L,T){E.on("start.zoom",function(){C(this,arguments).event(T).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(T).end()}).tween("zoom",function(){var B=this,F=arguments,j=C(B,F).event(T),V=t.apply(B,F),$=L==null?N(V):typeof L=="function"?L.apply(B,F):L,H=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),G=B.__zoom,Z=typeof D=="function"?D.apply(B,F):D,oe=c(G.invert($).concat(H/G.k),Z.invert($).concat(H/Z.k));return function(ne){if(ne===1)ne=Z;else{var X=oe(ne),re=H/X[2];ne=new un(re,$[0]-X[0]*re,$[1]-X[1]*re)}j.zoom(null,ne)}})}function C(E,D,L){return!L&&E.__zooming||new M(E,D)}function M(E,D){this.that=E,this.args=D,this.active=0,this.sourceEvent=null,this.extent=t.apply(E,D),this.taps=0}M.prototype={event:function(E){return E&&(this.sourceEvent=E),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(E,D){return this.mouse&&E!=="mouse"&&(this.mouse[1]=D.invert(this.mouse[0])),this.touch0&&E!=="touch"&&(this.touch0[1]=D.invert(this.touch0[0])),this.touch1&&E!=="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(E){var D=mt(this.that).datum();d.call(E,this.that,new iU(E,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:d}),D)}};function P(E,...D){if(!e.apply(this,arguments))return;var L=C(this,D).event(E),T=this.__zoom,B=Math.max(a[0],Math.min(a[1],T.k*Math.pow(2,r.apply(this,arguments)))),F=Tt(E);if(L.wheel)(L.mouse[0][0]!==F[0]||L.mouse[0][1]!==F[1])&&(L.mouse[1]=T.invert(L.mouse[0]=F)),clearTimeout(L.wheel);else{if(T.k===B)return;L.mouse=[F,T.invert(F)],Zs(this),L.start()}uo(E),L.wheel=setTimeout(j,g),L.zoom("mouse",n(v(w(T,B),L.mouse[0],L.mouse[1]),L.extent,i));function j(){L.wheel=null,L.end()}}function I(E,...D){if(h||!e.apply(this,arguments))return;var L=E.currentTarget,T=C(this,D,!0).event(E),B=mt(E.view).on("mousemove.zoom",$,!0).on("mouseup.zoom",H,!0),F=Tt(E,L),j=E.clientX,V=E.clientY;r1(E.view),pl(E),T.mouse=[F,this.__zoom.invert(F)],Zs(this),T.start();function $(G){if(uo(G),!T.moved){var Z=G.clientX-j,oe=G.clientY-V;T.moved=Z*Z+oe*oe>b}T.event(G).zoom("mouse",n(v(T.that.__zoom,T.mouse[0]=Tt(G,L),T.mouse[1]),T.extent,i))}function H(G){B.on("mousemove.zoom mouseup.zoom",null),o1(G.view,T.moved),uo(G),T.event(G).end()}}function z(E,...D){if(e.apply(this,arguments)){var L=this.__zoom,T=Tt(E.changedTouches?E.changedTouches[0]:E,this),B=L.invert(T),F=L.k*(E.shiftKey?.5:2),j=n(v(w(L,F),T,B),t.apply(this,D),i);uo(E),l>0?mt(this).transition().duration(l).call(k,j,T,E):mt(this).call(y.transform,j,T,E)}}function A(E,...D){if(e.apply(this,arguments)){var L=E.touches,T=L.length,B=C(this,D,E.changedTouches.length===T).event(E),F,j,V,$;for(pl(E),j=0;j<T;++j)V=L[j],$=Tt(V,this),$=[$,this.__zoom.invert($),V.identifier],B.touch0?!B.touch1&&B.touch0[2]!==$[2]&&(B.touch1=$,B.taps=0):(B.touch0=$,F=!0,B.taps=1+!!u);u&&(u=clearTimeout(u)),F&&(B.taps<2&&(p=$[0],u=setTimeout(function(){u=null},m)),Zs(this),B.start())}}function O(E,...D){if(this.__zooming){var L=C(this,D).event(E),T=E.changedTouches,B=T.length,F,j,V,$;for(uo(E),F=0;F<B;++F)j=T[F],V=Tt(j,this),L.touch0&&L.touch0[2]===j.identifier?L.touch0[0]=V:L.touch1&&L.touch1[2]===j.identifier&&(L.touch1[0]=V);if(j=L.that.__zoom,L.touch1){var H=L.touch0[0],G=L.touch0[1],Z=L.touch1[0],oe=L.touch1[1],ne=(ne=Z[0]-H[0])*ne+(ne=Z[1]-H[1])*ne,X=(X=oe[0]-G[0])*X+(X=oe[1]-G[1])*X;j=w(j,Math.sqrt(ne/X)),V=[(H[0]+Z[0])/2,(H[1]+Z[1])/2],$=[(G[0]+oe[0])/2,(G[1]+oe[1])/2]}else if(L.touch0)V=L.touch0[0],$=L.touch0[1];else return;L.zoom("touch",n(v(j,V,$),L.extent,i))}}function R(E,...D){if(this.__zooming){var L=C(this,D).event(E),T=E.changedTouches,B=T.length,F,j;for(pl(E),h&&clearTimeout(h),h=setTimeout(function(){h=null},m),F=0;F<B;++F)j=T[F],L.touch0&&L.touch0[2]===j.identifier?delete L.touch0:L.touch1&&L.touch1[2]===j.identifier&&delete L.touch1;if(L.touch1&&!L.touch0&&(L.touch0=L.touch1,delete L.touch1),L.touch0)L.touch0[1]=this.__zoom.invert(L.touch0[0]);else if(L.end(),L.taps===2&&(j=Tt(j,this),Math.hypot(p[0]-j[0],p[1]-j[1])<x)){var V=mt(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return y.wheelDelta=function(E){return arguments.length?(r=typeof E=="function"?E:Ts(+E),y):r},y.filter=function(E){return arguments.length?(e=typeof E=="function"?E:Ts(!!E),y):e},y.touchable=function(E){return arguments.length?(s=typeof E=="function"?E:Ts(!!E),y):s},y.extent=function(E){return arguments.length?(t=typeof E=="function"?E:Ts([[+E[0][0],+E[0][1]],[+E[1][0],+E[1][1]]]),y):t},y.scaleExtent=function(E){return arguments.length?(a[0]=+E[0],a[1]=+E[1],y):[a[0],a[1]]},y.translateExtent=function(E){return arguments.length?(i[0][0]=+E[0][0],i[1][0]=+E[1][0],i[0][1]=+E[0][1],i[1][1]=+E[1][1],y):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},y.constrain=function(E){return arguments.length?(n=E,y):n},y.duration=function(E){return arguments.length?(l=+E,y):l},y.interpolate=function(E){return arguments.length?(c=E,y):c},y.on=function(){var E=d.on.apply(d,arguments);return E===d?y:E},y.clickDistance=function(E){return arguments.length?(b=(E=+E)*E,y):Math.sqrt(b)},y.tapDistance=function(E){return arguments.length?(x=+E,y):x},y}const nn={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:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", 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."},zo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],w1=["Enter"," ","Escape"],N1={"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 Or;(function(e){e.Strict="strict",e.Loose="loose"})(Or||(Or={}));var Zn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Zn||(Zn={}));var Fo;(function(e){e.Partial="partial",e.Full="full"})(Fo||(Fo={}));const k1={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var En;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(En||(En={}));var wa;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(wa||(wa={}));var we;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(we||(we={}));const Kf={[we.Left]:we.Right,[we.Right]:we.Left,[we.Top]:we.Bottom,[we.Bottom]:we.Top};function S1(e){return e===null?null:e?"valid":"invalid"}const C1=e=>"id"in e&&"source"in e&&"target"in e,fU=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),iu=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),ss=(e,t=[0,0])=>{const{width:n,height:r}=Nn(e),s=e.origin??t,a=n*s[0],i=r*s[1];return{x:e.position.x-a,y:e.position.y-i}},hU=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const a=typeof s=="string";let i=!t.nodeLookup&&!a?s:void 0;t.nodeLookup&&(i=a?t.nodeLookup.get(s):iu(s)?s:t.nodeLookup.get(s.id));const l=i?Na(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return ui(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return pi(n)},as=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=ui(n,Na(s)),r=!0)}),r?pi(n):{x:0,y:0,width:0,height:0}},lu=(e,t,[n,r,s]=[0,0,1],a=!1,i=!1)=>{const l={...ls(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const d of e.values()){const{measured:u,selectable:p=!0,hidden:h=!1}=d;if(i&&!p||h)continue;const m=u.width??d.width??d.initialWidth??null,g=u.height??d.height??d.initialHeight??null,b=jo(l,zr(d)),x=(m??0)*(g??0),y=a&&b>0;(!d.internals.handleBounds||y||b>=x||d.dragging)&&c.push(d)}return c},mU=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function gU(e,t){const n=new Map,r=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)&&(!r||r.has(s.id))&&n.set(s.id,s)}),n}async function bU({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:a},i){if(e.size===0)return Promise.resolve(!0);const l=gU(e,i),c=as(l),d=cu(c,t,n,i?.minZoom??s,i?.maxZoom??a,i?.padding??.1);return await r.setViewport(d,{duration:i?.duration,ease:i?.ease,interpolate:i?.interpolate}),Promise.resolve(!0)}function M1({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[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},u=i.origin??r;let p=i.extent||s;if(i.extent==="parent"&&!i.expandParent)if(!l)a?.("005",nn.error005());else{const m=l.measured.width,g=l.measured.height;m&&g&&(p=[[c,d],[c+m,d+g]])}else l&&Fr(i.extent)&&(p=[[i.extent[0][0]+c,i.extent[0][1]+d],[i.extent[1][0]+c,i.extent[1][1]+d]]);const h=Fr(p)?lr(t,p,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&a?.("015",nn.error015()),{position:{x:h.x-c+(i.measured.width??0)*u[0],y:h.y-d+(i.measured.height??0)*u[1]},positionAbsolute:h}}async function xU({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const a=new Set(e.map(h=>h.id)),i=[];for(const h of n){if(h.deletable===!1)continue;const m=a.has(h.id),g=!m&&h.parentId&&i.find(b=>b.id===h.parentId);(m||g)&&i.push(h)}const l=new Set(t.map(h=>h.id)),c=r.filter(h=>h.deletable!==!1),u=mU(i,c);for(const h of c)l.has(h.id)&&!u.find(g=>g.id===h.id)&&u.push(h);if(!s)return{edges:u,nodes:i};const p=await s({nodes:i,edges:u});return typeof p=="boolean"?p?{edges:u,nodes:i}:{edges:[],nodes:[]}:p}const Br=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),lr=(e={x:0,y:0},t,n)=>({x:Br(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Br(e.y,t[0][1],t[1][1]-(n?.height??0))});function E1(e,t,n){const{width:r,height:s}=Nn(n),{x:a,y:i}=n.internals.positionAbsolute;return lr(e,[[a,i],[a+r,i+s]],t)}const Wf=(e,t,n)=>e<t?Br(Math.abs(e-t),1,t)/t:e>n?-Br(Math.abs(e-n),1,t)/t:0,I1=(e,t,n=15,r=40)=>{const s=Wf(e.x,r,t.width-r)*n,a=Wf(e.y,r,t.height-r)*n;return[s,a]},ui=(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)}),mc=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),pi=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),zr=(e,t=[0,0])=>{const{x:n,y:r}=iu(e)?e.internals.positionAbsolute:ss(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Na=(e,t=[0,0])=>{const{x:n,y:r}=iu(e)?e.internals.positionAbsolute:ss(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},A1=(e,t)=>pi(ui(mc(e),mc(t))),jo=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},Yf=e=>Ot(e.width)&&Ot(e.height)&&Ot(e.x)&&Ot(e.y),Ot=e=>!isNaN(e)&&isFinite(e),yU=(e,t)=>{},is=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),ls=({x:e,y:t},[n,r,s],a=!1,i=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return a?is(l,i):l},ka=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function vr(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 vU(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=vr(e,n),s=vr(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=vr(e.top??e.y??0,n),s=vr(e.bottom??e.y??0,n),a=vr(e.left??e.x??0,t),i=vr(e.right??e.x??0,t);return{top:r,right:i,bottom:s,left:a,x:a+i,y:r+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function wU(e,t,n,r,s,a){const{x:i,y:l}=ka(e,[t,n,r]),{x:c,y:d}=ka({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=s-c,p=a-d;return{left:Math.floor(i),top:Math.floor(l),right:Math.floor(u),bottom:Math.floor(p)}}const cu=(e,t,n,r,s,a)=>{const i=vU(a,t,n),l=(t-i.x)/e.width,c=(n-i.y)/e.height,d=Math.min(l,c),u=Br(d,r,s),p=e.x+e.width/2,h=e.y+e.height/2,m=t/2-p*u,g=n/2-h*u,b=wU(e,m,g,u,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:m-x.left+x.right,y:g-x.top+x.bottom,zoom:u}},Vo=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Fr(e){return e!=null&&e!=="parent"}function Nn(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function P1(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function _1(e,t={width:0,height:0},n,r,s){const a={...e},i=r.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 Zf(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function NU(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function kU(e){return{...N1,...e||{}}}function Co(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:a,y:i}=Bt(e),l=ls({x:a-(s?.left??0),y:i-(s?.top??0)},r),{x:c,y:d}=n?is(l,t):l;return{xSnapped:c,ySnapped:d,...l}}const du=e=>({width:e.offsetWidth,height:e.offsetHeight}),$1=e=>e?.getRootNode?.()||window?.document,SU=["INPUT","SELECT","TEXTAREA"];function D1(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:SU.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const L1=e=>"clientX"in e,Bt=(e,t)=>{const n=L1(e),r=n?e.clientX:e.touches?.[0].clientX,s=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:s-(t?.top??0)}},Xf=(e,t,n,r,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)/r,y:(l.top-n.top)/r,...du(i)}})};function T1({sourceX:e,sourceY:t,targetX:n,targetY:r,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+r*.125,u=Math.abs(c-e),p=Math.abs(d-t);return[c,d,u,p]}function Rs(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Jf({pos:e,x1:t,y1:n,x2:r,y2:s,c:a}){switch(e){case we.Left:return[t-Rs(t-r,a),n];case we.Right:return[t+Rs(r-t,a),n];case we.Top:return[t,n-Rs(n-s,a)];case we.Bottom:return[t,n+Rs(s-n,a)]}}function R1({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:r,targetY:s,targetPosition:a=we.Top,curvature:i=.25}){const[l,c]=Jf({pos:n,x1:e,y1:t,x2:r,y2:s,c:i}),[d,u]=Jf({pos:a,x1:r,y1:s,x2:e,y2:t,c:i}),[p,h,m,g]=T1({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:u});return[`M${e},${t} C${l},${c} ${d},${u} ${r},${s}`,p,h,m,g]}function O1({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,a=n<e?n+s:n-s,i=Math.abs(r-t)/2,l=r<t?r+i:r-i;return[a,l,s,i]}function CU({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:s=!1,zIndexMode:a="basic"}){if(a==="manual")return r;const i=s&&n?r+1e3:r,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 MU({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const a=ui(Na(e),Na(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:r/s[2]};return jo(i,pi(a))>0}const EU=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,IU=(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)),AU=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||EU;let s;return C1(e)?s={...e}:s={...e,id:r(e)},IU(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function B1({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,a,i,l]=O1({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,a,i,l]}const eh={[we.Left]:{x:-1,y:0},[we.Right]:{x:1,y:0},[we.Top]:{x:0,y:-1},[we.Bottom]:{x:0,y:1}},PU=({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},th=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function _U({source:e,sourcePosition:t=we.Bottom,target:n,targetPosition:r=we.Top,center:s,offset:a,stepPosition:i}){const l=eh[t],c=eh[r],d={x:e.x+l.x*a,y:e.y+l.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},p=PU({source:d,sourcePosition:t,target:u}),h=p.x!==0?"x":"y",m=p[h];let g=[],b,x;const y={x:0,y:0},w={x:0,y:0},[,,v,N]=O1({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[h]*c[h]===-1){h==="x"?(b=s.x??d.x+(u.x-d.x)*i,x=s.y??(d.y+u.y)/2):(b=s.x??(d.x+u.x)/2,x=s.y??d.y+(u.y-d.y)*i);const P=[{x:b,y:d.y},{x:b,y:u.y}],I=[{x:d.x,y:x},{x:u.x,y:x}];l[h]===m?g=h==="x"?P:I:g=h==="x"?I:P}else{const P=[{x:d.x,y:u.y}],I=[{x:u.x,y:d.y}];if(h==="x"?g=l.x===m?I:P:g=l.y===m?P:I,t===r){const E=Math.abs(e[h]-n[h]);if(E<=a){const D=Math.min(a-1,a-E);l[h]===m?y[h]=(d[h]>e[h]?-1:1)*D:w[h]=(u[h]>n[h]?-1:1)*D}}if(t!==r){const E=h==="x"?"y":"x",D=l[h]===c[E],L=d[E]>u[E],T=d[E]<u[E];(l[h]===1&&(!D&&L||D&&T)||l[h]!==1&&(!D&&T||D&&L))&&(g=h==="x"?P:I)}const z={x:d.x+y.x,y:d.y+y.y},A={x:u.x+w.x,y:u.y+w.y},O=Math.max(Math.abs(z.x-g[0].x),Math.abs(A.x-g[0].x)),R=Math.max(Math.abs(z.y-g[0].y),Math.abs(A.y-g[0].y));O>=R?(b=(z.x+A.x)/2,x=g[0].y):(b=g[0].x,x=(z.y+A.y)/2)}const k={x:d.x+y.x,y:d.y+y.y},C={x:u.x+w.x,y:u.y+w.y};return[[e,...k.x!==g[0].x||k.y!==g[0].y?[k]:[],...g,...C.x!==g[g.length-1].x||C.y!==g[g.length-1].y?[C]:[],n],b,x,v,N]}function $U(e,t,n,r){const s=Math.min(th(e,t)/2,th(t,n)/2,r),{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,u=e.y<n.y?1:-1;return`L ${a+s*d},${i}Q ${a},${i} ${a},${i+s*u}`}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 gc({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:r,targetY:s,targetPosition:a=we.Top,borderRadius:i=5,centerX:l,centerY:c,offset:d=20,stepPosition:u=.5}){const[p,h,m,g,b]=_U({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:a,center:{x:l,y:c},offset:d,stepPosition:u});let x=`M${p[0].x} ${p[0].y}`;for(let y=1;y<p.length-1;y++)x+=$U(p[y-1],p[y],p[y+1],i);return x+=`L${p[p.length-1].x} ${p[p.length-1].y}`,[x,h,m,g,b]}function nh(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function DU(e){const{sourceNode:t,targetNode:n}=e;if(!nh(t)||!nh(n))return null;const r=t.internals.handleBounds||rh(t.handles),s=n.internals.handleBounds||rh(n.handles),a=oh(r?.source??[],e.sourceHandle),i=oh(e.connectionMode===Or.Strict?s?.target??[]:(s?.target??[]).concat(s?.source??[]),e.targetHandle);if(!a||!i)return e.onError?.("008",nn.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=cr(t,a,l),u=cr(n,i,c);return{sourceX:d.x,sourceY:d.y,targetX:u.x,targetY:u.y,sourcePosition:l,targetPosition:c}}function rh(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function cr(e,t,n=we.Left,r=!1){const s=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:i,height:l}=t??Nn(e);if(r)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 oh(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function bc(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function LU(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const a=new Set;return e.reduce((i,l)=>([l.markerStart||r,l.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const d=bc(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 z1=1e3,TU=10,uu={nodeOrigin:[0,0],nodeExtent:zo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},RU={...uu,checkEquality:!0};function pu(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function OU(e,t,n){const r=pu(uu,n);for(const s of e.values())if(s.parentId)hu(s,e,t,r);else{const a=ss(s,r.nodeOrigin),i=Fr(s.extent)?s.extent:r.nodeExtent,l=lr(a,i,Nn(s));s.internals.positionAbsolute=l}}function BU(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],r=[];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"&&r.push(a)}return{source:n,target:r}}function fu(e){return e==="manual"}function xc(e,t,n,r={}){const s=pu(RU,r),a={i:0},i=new Map(t),l=s?.elevateNodesOnSelect&&!fu(s.zIndexMode)?z1:0;let c=e.length>0,d=!1;t.clear(),n.clear();for(const u of e){let p=i.get(u.id);if(s.checkEquality&&u===p?.internals.userNode)t.set(u.id,p);else{const h=ss(u,s.nodeOrigin),m=Fr(u.extent)?u.extent:s.nodeExtent,g=lr(h,m,Nn(u));p={...s.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:g,handleBounds:BU(u,p),z:F1(u,l,s.zIndexMode),userNode:u}},t.set(u.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(c=!1),u.parentId&&hu(p,t,n,r,a),d||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:d}}function zU(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 hu(e,t,n,r,s){const{elevateNodesOnSelect:a,nodeOrigin:i,nodeExtent:l,zIndexMode:c}=pu(uu,r),d=e.parentId,u=t.get(d);if(!u){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}zU(e,n),s&&!u.parentId&&u.internals.rootParentIndex===void 0&&c==="auto"&&(u.internals.rootParentIndex=++s.i,u.internals.z=u.internals.z+s.i*TU),s&&u.internals.rootParentIndex!==void 0&&(s.i=u.internals.rootParentIndex);const p=a&&!fu(c)?z1:0,{x:h,y:m,z:g}=FU(e,u,i,l,p,c),{positionAbsolute:b}=e.internals,x=h!==b.x||m!==b.y;(x||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:h,y:m}:b,z:g}})}function F1(e,t,n){const r=Ot(e.zIndex)?e.zIndex:0;return fu(n)?r:r+(e.selected?t:0)}function FU(e,t,n,r,s,a){const{x:i,y:l}=t.internals.positionAbsolute,c=Nn(e),d=ss(e,n),u=Fr(e.extent)?lr(d,e.extent,c):d;let p=lr({x:i+u.x,y:l+u.y},r,c);e.extent==="parent"&&(p=E1(p,c,t));const h=F1(e,s,a),m=t.internals.z??0;return{x:p.x,y:p.y,z:m>=h?m+1:h}}function mu(e,t,n,r=[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??zr(l),d=A1(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,u=Nn(l),p=l.origin??r,h=i.x<d.x?Math.round(Math.abs(d.x-i.x)):0,m=i.y<d.y?Math.round(Math.abs(d.y-i.y)):0,g=Math.max(u.width,Math.round(i.width)),b=Math.max(u.height,Math.round(i.height)),x=(g-u.width)*p[0],y=(b-u.height)*p[1];(h>0||m>0||x||y)&&(s.push({id:c,type:"position",position:{x:l.position.x-h+x,y:l.position.y-m+y}}),n.get(c)?.forEach(w=>{e.some(v=>v.id===w.id)||s.push({id:w.id,type:"position",position:{x:w.position.x+h,y:w.position.y+m}})})),(u.width<i.width||u.height<i.height||h||m)&&s.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:g+(h?p[0]*h-x:0),height:b+(m?p[1]*m-y:0)}})}),s}function jU(e,t,n,r,s,a,i){const l=r?.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const d=[],u=window.getComputedStyle(l),{m22:p}=new window.DOMMatrixReadOnly(u.transform),h=[];for(const m of e.values()){const g=t.get(m.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const b=du(m.nodeElement),x=g.measured.width!==b.width||g.measured.height!==b.height;if(!!(b.width&&b.height&&(x||!g.internals.handleBounds||m.force))){const w=m.nodeElement.getBoundingClientRect(),v=Fr(g.extent)?g.extent:a;let{positionAbsolute:N}=g.internals;g.parentId&&g.extent==="parent"?N=E1(N,b,t.get(g.parentId)):v&&(N=lr(N,v,b));const k={...g,measured:b,internals:{...g.internals,positionAbsolute:N,handleBounds:{source:Xf("source",m.nodeElement,w,p,g.id),target:Xf("target",m.nodeElement,w,p,g.id)}}};t.set(g.id,k),g.parentId&&hu(k,t,n,{nodeOrigin:s,zIndexMode:i}),c=!0,x&&(d.push({id:g.id,type:"dimensions",dimensions:b}),g.expandParent&&g.parentId&&h.push({id:g.id,parentId:g.parentId,rect:zr(k,s)}))}}if(h.length>0){const m=mu(h,t,n,s);d.push(...m)}return{changes:d,updatedInternals:c}}async function VU({delta:e,panZoom:t,transform:n,translateExtent:r,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]],r),l=!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2]);return Promise.resolve(l)}function sh(e,t,n,r,s,a){let i=s;const l=r.get(i)||new Map;r.set(i,l.set(n,t)),i=`${s}-${e}`;const c=r.get(i)||new Map;if(r.set(i,c.set(n,t)),a){i=`${s}-${e}-${a}`;const d=r.get(i)||new Map;r.set(i,d.set(n,t))}}function j1(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:a,sourceHandle:i=null,targetHandle:l=null}=r,c={edgeId:r.id,source:s,target:a,sourceHandle:i,targetHandle:l},d=`${s}-${i}--${a}-${l}`,u=`${a}-${l}--${s}-${i}`;sh("source",c,u,e,s,i),sh("target",c,d,e,a,l),t.set(r.id,r)}}function V1(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:V1(n,t):!1}function ah(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function HU(e,t,n,r){const s=new Map;for(const[a,i]of e)if((i.selected||i.id===r)&&(!i.parentId||!V1(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 fl({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){const s=[];for(const[i,l]of t){const c=n.get(i)?.internals.userNode;c&&s.push({...c,position:l.position,dragging:r})}if(!e)return[s[0],s];const a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:s[0],s]}function qU({dragItems:e,snapGrid:t,x:n,y:r}){const s=e.values().next().value;if(!s)return null;const a={x:n-s.distance.x,y:r-s.distance.y},i=is(a,t);return{x:i.x-a.x,y:i.y-a.y}}function UU({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let a={x:null,y:null},i=0,l=new Map,c=!1,d={x:0,y:0},u=null,p=!1,h=null,m=!1,g=!1,b=null;function x({noDragClassName:w,handleSelector:v,domNode:N,isSelectable:k,nodeId:C,nodeClickDistance:M=0}){h=mt(N);function P({x:O,y:R}){const{nodeLookup:E,nodeExtent:D,snapGrid:L,snapToGrid:T,nodeOrigin:B,onNodeDrag:F,onSelectionDrag:j,onError:V,updateNodePositions:$}=t();a={x:O,y:R};let H=!1;const G=l.size>1,Z=G&&D?mc(as(l)):null,oe=G&&T?qU({dragItems:l,snapGrid:L,x:O,y:R}):null;for(const[ne,X]of l){if(!E.has(ne))continue;let re={x:O-X.distance.x,y:R-X.distance.y};T&&(re=oe?{x:Math.round(re.x+oe.x),y:Math.round(re.y+oe.y)}:is(re,L));let be=null;if(G&&D&&!X.extent&&Z){const{positionAbsolute:ee}=X.internals,ae=ee.x-Z.x+D[0][0],fe=ee.x+X.measured.width-Z.x2+D[1][0],ge=ee.y-Z.y+D[0][1],Q=ee.y+X.measured.height-Z.y2+D[1][1];be=[[ae,ge],[fe,Q]]}const{position:J,positionAbsolute:W}=M1({nodeId:ne,nextPosition:re,nodeLookup:E,nodeExtent:be||D,nodeOrigin:B,onError:V});H=H||X.position.x!==J.x||X.position.y!==J.y,X.position=J,X.internals.positionAbsolute=W}if(g=g||H,!!H&&($(l,!0),b&&(r||F||!C&&j))){const[ne,X]=fl({nodeId:C,dragItems:l,nodeLookup:E});r?.(b,l,ne,X),F?.(b,ne,X),C||j?.(b,X)}}async function I(){if(!u)return;const{transform:O,panBy:R,autoPanSpeed:E,autoPanOnNodeDrag:D}=t();if(!D){c=!1,cancelAnimationFrame(i);return}const[L,T]=I1(d,u,E);(L!==0||T!==0)&&(a.x=(a.x??0)-L/O[2],a.y=(a.y??0)-T/O[2],await R({x:L,y:T})&&P(a)),i=requestAnimationFrame(I)}function z(O){const{nodeLookup:R,multiSelectionActive:E,nodesDraggable:D,transform:L,snapGrid:T,snapToGrid:B,selectNodesOnDrag:F,onNodeDragStart:j,onSelectionDragStart:V,unselectNodesAndEdges:$}=t();p=!0,(!F||!k)&&!E&&C&&(R.get(C)?.selected||$()),k&&F&&C&&e?.(C);const H=Co(O.sourceEvent,{transform:L,snapGrid:T,snapToGrid:B,containerBounds:u});if(a=H,l=HU(R,D,H,C),l.size>0&&(n||j||!C&&V)){const[G,Z]=fl({nodeId:C,dragItems:l,nodeLookup:R});n?.(O.sourceEvent,l,G,Z),j?.(O.sourceEvent,G,Z),C||V?.(O.sourceEvent,Z)}}const A=s1().clickDistance(M).on("start",O=>{const{domNode:R,nodeDragThreshold:E,transform:D,snapGrid:L,snapToGrid:T}=t();u=R?.getBoundingClientRect()||null,m=!1,g=!1,b=O.sourceEvent,E===0&&z(O),a=Co(O.sourceEvent,{transform:D,snapGrid:L,snapToGrid:T,containerBounds:u}),d=Bt(O.sourceEvent,u)}).on("drag",O=>{const{autoPanOnNodeDrag:R,transform:E,snapGrid:D,snapToGrid:L,nodeDragThreshold:T,nodeLookup:B}=t(),F=Co(O.sourceEvent,{transform:E,snapGrid:D,snapToGrid:L,containerBounds:u});if(b=O.sourceEvent,(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1||C&&!B.has(C))&&(m=!0),!m){if(!c&&R&&p&&(c=!0,I()),!p){const j=Bt(O.sourceEvent,u),V=j.x-d.x,$=j.y-d.y;Math.sqrt(V*V+$*$)>T&&z(O)}(a.x!==F.xSnapped||a.y!==F.ySnapped)&&l&&p&&(d=Bt(O.sourceEvent,u),P(F))}}).on("end",O=>{if(!(!p||m)&&(c=!1,p=!1,cancelAnimationFrame(i),l.size>0)){const{nodeLookup:R,updateNodePositions:E,onNodeDragStop:D,onSelectionDragStop:L}=t();if(g&&(E(l,!1),g=!1),s||D||!C&&L){const[T,B]=fl({nodeId:C,dragItems:l,nodeLookup:R,dragging:!1});s?.(O.sourceEvent,l,T,B),D?.(O.sourceEvent,T,B),C||L?.(O.sourceEvent,B)}}}).filter(O=>{const R=O.target;return!O.button&&(!w||!ah(R,`.${w}`,N))&&(!v||ah(R,v,N))});h.call(A)}function y(){h?.on(".drag",null)}return{update:x,destroy:y}}function QU(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const a of t.values())jo(s,zr(a))>0&&r.push(a);return r}const GU=250;function KU(e,t,n,r){let s=[],a=1/0;const i=QU(e,n,t+GU);for(const l of i){const c=[...l.internals.handleBounds?.source??[],...l.internals.handleBounds?.target??[]];for(const d of c){if(r.nodeId===d.nodeId&&r.type===d.type&&r.id===d.id)continue;const{x:u,y:p}=cr(l,d,d.position,!0),h=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(p-e.y,2));h>t||(h<a?(s=[{...d,x:u,y:p}],a=h):h===a&&s.push({...d,x:u,y:p}))}}if(!s.length)return null;if(s.length>1){const l=r.type==="source"?"target":"source";return s.find(c=>c.type===l)??s[0]}return s[0]}function H1(e,t,n,r,s,a=!1){const i=r.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,...cr(i,c,c.position,!0)}:c}function q1(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function WU(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const U1=()=>!0;function YU(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:a,isTarget:i,domNode:l,nodeLookup:c,lib:d,autoPanOnConnect:u,flowId:p,panBy:h,cancelConnection:m,onConnectStart:g,onConnect:b,onConnectEnd:x,isValidConnection:y=U1,onReconnectEnd:w,updateConnection:v,getTransform:N,getFromHandle:k,autoPanSpeed:C,dragThreshold:M=1,handleDomNode:P}){const I=$1(e.target);let z=0,A;const{x:O,y:R}=Bt(e),E=q1(a,P),D=l?.getBoundingClientRect();let L=!1;if(!D||!E)return;const T=H1(s,E,r,c,t);if(!T)return;let B=Bt(e,D),F=!1,j=null,V=!1,$=null;function H(){if(!u||!D)return;const[J,W]=I1(B,D,C);h({x:J,y:W}),z=requestAnimationFrame(H)}const G={...T,nodeId:s,type:E,position:T.position},Z=c.get(s);let ne={inProgress:!0,isValid:null,from:cr(Z,G,we.Left,!0),fromHandle:G,fromPosition:G.position,fromNode:Z,to:B,toHandle:null,toPosition:Kf[G.position],toNode:null,pointer:B};function X(){L=!0,v(ne),g?.(e,{nodeId:s,handleId:r,handleType:E})}M===0&&X();function re(J){if(!L){const{x:Q,y:le}=Bt(J),ue=Q-O,de=le-R;if(!(ue*ue+de*de>M*M))return;X()}if(!k()||!G){be(J);return}const W=N();B=Bt(J,D),A=KU(ls(B,W,!1,[1,1]),n,c,G),F||(H(),F=!0);const ee=Q1(J,{handle:A,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:i?"target":"source",isValidConnection:y,doc:I,lib:d,flowId:p,nodeLookup:c});$=ee.handleDomNode,j=ee.connection,V=WU(!!A,ee.isValid);const ae=c.get(s),fe=ae?cr(ae,G,we.Left,!0):ne.from,ge={...ne,from:fe,isValid:V,to:ee.toHandle&&V?ka({x:ee.toHandle.x,y:ee.toHandle.y},W):B,toHandle:ee.toHandle,toPosition:V&&ee.toHandle?ee.toHandle.position:Kf[G.position],toNode:ee.toHandle?c.get(ee.toHandle.nodeId):null,pointer:B};v(ge),ne=ge}function be(J){if(!("touches"in J&&J.touches.length>0)){if(L){(A||$)&&j&&V&&b?.(j);const{inProgress:W,...ee}=ne,ae={...ee,toPosition:ne.toHandle?ne.toPosition:null};x?.(J,ae),a&&w?.(J,ae)}m(),cancelAnimationFrame(z),F=!1,V=!1,j=null,$=null,I.removeEventListener("mousemove",re),I.removeEventListener("mouseup",be),I.removeEventListener("touchmove",re),I.removeEventListener("touchend",be)}}I.addEventListener("mousemove",re),I.addEventListener("mouseup",be),I.addEventListener("touchmove",re),I.addEventListener("touchend",be)}function Q1(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:a,doc:i,lib:l,flowId:c,isValidConnection:d=U1,nodeLookup:u}){const p=a==="target",h=t?i.querySelector(`.${l}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:m,y:g}=Bt(e),b=i.elementFromPoint(m,g),x=b?.classList.contains(`${l}-flow__handle`)?b:h,y={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const w=q1(void 0,x),v=x.getAttribute("data-nodeid"),N=x.getAttribute("data-handleid"),k=x.classList.contains("connectable"),C=x.classList.contains("connectableend");if(!v||!w)return y;const M={source:p?v:r,sourceHandle:p?N:s,target:p?r:v,targetHandle:p?s:N};y.connection=M;const I=k&&C&&(n===Or.Strict?p&&w==="source"||!p&&w==="target":v!==r||N!==s);y.isValid=I&&d(M),y.toHandle=H1(v,w,N,u,n,!0)}return y}const yc={onPointerDown:YU,isValid:Q1};function ZU({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=mt(e);function a({translateExtent:l,width:c,height:d,zoomStep:u=1,pannable:p=!0,zoomable:h=!0,inversePan:m=!1}){const g=v=>{if(v.sourceEvent.type!=="wheel"||!t)return;const N=n(),k=v.sourceEvent.ctrlKey&&Vo()?10:1,C=-v.sourceEvent.deltaY*(v.sourceEvent.deltaMode===1?.05:v.sourceEvent.deltaMode?1:.002)*u,M=N[2]*Math.pow(2,C*k);t.scaleTo(M)};let b=[0,0];const x=v=>{(v.sourceEvent.type==="mousedown"||v.sourceEvent.type==="touchstart")&&(b=[v.sourceEvent.clientX??v.sourceEvent.touches[0].clientX,v.sourceEvent.clientY??v.sourceEvent.touches[0].clientY])},y=v=>{const N=n();if(v.sourceEvent.type!=="mousemove"&&v.sourceEvent.type!=="touchmove"||!t)return;const k=[v.sourceEvent.clientX??v.sourceEvent.touches[0].clientX,v.sourceEvent.clientY??v.sourceEvent.touches[0].clientY],C=[k[0]-b[0],k[1]-b[1]];b=k;const M=r()*Math.max(N[2],Math.log(N[2]))*(m?-1:1),P={x:N[0]-C[0]*M,y:N[1]-C[1]*M},I=[[0,0],[c,d]];t.setViewportConstrained({x:P.x,y:P.y,zoom:N[2]},I,l)},w=v1().on("start",x).on("zoom",p?y:null).on("zoom.wheel",h?g:null);s.call(w,{})}function i(){s.on("zoom",null)}return{update:a,destroy:i,pointer:Tt}}const fi=e=>({x:e.x,y:e.y,zoom:e.k}),hl=({x:e,y:t,zoom:n})=>di.translate(e,t).scale(n),Cr=(e,t)=>e.target.closest(`.${t}`),G1=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),XU=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ml=(e,t=0,n=XU,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},K1=e=>{const t=e.ctrlKey&&Vo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function JU({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:a,zoomOnPinch:i,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:d}){return u=>{if(Cr(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(u.ctrlKey&&i){const x=Tt(u),y=K1(u),w=p*Math.pow(2,y);r.scaleTo(n,w,x,u);return}const h=u.deltaMode===1?20:1;let m=s===Zn.Vertical?0:u.deltaX*h,g=s===Zn.Horizontal?0:u.deltaY*h;!Vo()&&u.shiftKey&&s!==Zn.Vertical&&(m=u.deltaY*h,g=0),r.translateBy(n,-(m/p)*a,-(g/p)*a,{internal:!0});const b=fi(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,b),e.panScrollTimeout=setTimeout(()=>{d?.(u,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(u,b))}}function eQ({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const a=r.type==="wheel",i=!t&&a&&!r.ctrlKey,l=Cr(r,e);if(r.ctrlKey&&a&&l&&r.preventDefault(),i||l)return null;r.preventDefault(),n.call(this,r,s)}}function tQ({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;const s=fi(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=s,r.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(r.sourceEvent,s)}}function nQ({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return a=>{e.usedRightMouseButton=!!(n&&G1(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),s&&!a.sourceEvent?.internal&&s?.(a.sourceEvent,fi(a.transform))}}function rQ({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:a}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&G1(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&a(i.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const l=fi(i.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s?.(i.sourceEvent,l)},n?150:0)}}}function oQ({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:a,userSelectionActive:i,noWheelClassName:l,noPanClassName:c,lib:d,connectionInProgress:u}){return p=>{const h=e||t,m=n&&p.ctrlKey,g=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(Cr(p,`${d}-flow__node`)||Cr(p,`${d}-flow__edge`)))return!0;if(!r&&!h&&!s&&!a&&!n||i||u&&!g||Cr(p,l)&&g||Cr(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(!h&&!s&&!m&&g||!r&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(r)&&!r.includes(p.button)&&p.type==="mousedown")return!1;const b=Array.isArray(r)&&r.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||g)&&b}}function sQ({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,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},u=e.getBoundingClientRect(),p=v1().scaleExtent([t,n]).translateExtent(r),h=mt(e).call(p);w({x:s.x,y:s.y,zoom:Br(s.zoom,t,n)},[[0,0],[u.width,u.height]],r);const m=h.on("wheel.zoom"),g=h.on("dblclick.zoom");p.wheelDelta(K1);function b(A,O){return h?new Promise(R=>{p?.interpolate(O?.interpolate==="linear"?So:Ks).transform(ml(h,O?.duration,O?.ease,()=>R(!0)),A)}):Promise.resolve(!1)}function x({noWheelClassName:A,noPanClassName:O,onPaneContextMenu:R,userSelectionActive:E,panOnScroll:D,panOnDrag:L,panOnScrollMode:T,panOnScrollSpeed:B,preventScrolling:F,zoomOnPinch:j,zoomOnScroll:V,zoomOnDoubleClick:$,zoomActivationKeyPressed:H,lib:G,onTransformChange:Z,connectionInProgress:oe,paneClickDistance:ne,selectionOnDrag:X}){E&&!d.isZoomingOrPanning&&y();const re=D&&!H&&!E;p.clickDistance(X?1/0:!Ot(ne)||ne<0?0:ne);const be=re?JU({zoomPanValues:d,noWheelClassName:A,d3Selection:h,d3Zoom:p,panOnScrollMode:T,panOnScrollSpeed:B,zoomOnPinch:j,onPanZoomStart:i,onPanZoom:a,onPanZoomEnd:l}):eQ({noWheelClassName:A,preventScrolling:F,d3ZoomHandler:m});if(h.on("wheel.zoom",be,{passive:!1}),!E){const W=tQ({zoomPanValues:d,onDraggingChange:c,onPanZoomStart:i});p.on("start",W);const ee=nQ({zoomPanValues:d,panOnDrag:L,onPaneContextMenu:!!R,onPanZoom:a,onTransformChange:Z});p.on("zoom",ee);const ae=rQ({zoomPanValues:d,panOnDrag:L,panOnScroll:D,onPaneContextMenu:R,onPanZoomEnd:l,onDraggingChange:c});p.on("end",ae)}const J=oQ({zoomActivationKeyPressed:H,panOnDrag:L,zoomOnScroll:V,panOnScroll:D,zoomOnDoubleClick:$,zoomOnPinch:j,userSelectionActive:E,noPanClassName:O,noWheelClassName:A,lib:G,connectionInProgress:oe});p.filter(J),$?h.on("dblclick.zoom",g):h.on("dblclick.zoom",null)}function y(){p.on("zoom",null)}async function w(A,O,R){const E=hl(A),D=p?.constrain()(E,O,R);return D&&await b(D),new Promise(L=>L(D))}async function v(A,O){const R=hl(A);return await b(R,O),new Promise(E=>E(R))}function N(A){if(h){const O=hl(A),R=h.property("__zoom");(R.k!==A.zoom||R.x!==A.x||R.y!==A.y)&&p?.transform(h,O,null,{sync:!0})}}function k(){const A=h?y1(h.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}function C(A,O){return h?new Promise(R=>{p?.interpolate(O?.interpolate==="linear"?So:Ks).scaleTo(ml(h,O?.duration,O?.ease,()=>R(!0)),A)}):Promise.resolve(!1)}function M(A,O){return h?new Promise(R=>{p?.interpolate(O?.interpolate==="linear"?So:Ks).scaleBy(ml(h,O?.duration,O?.ease,()=>R(!0)),A)}):Promise.resolve(!1)}function P(A){p?.scaleExtent(A)}function I(A){p?.translateExtent(A)}function z(A){const O=!Ot(A)||A<0?0:A;p?.clickDistance(O)}return{update:x,destroy:y,setViewport:v,setViewportConstrained:w,getViewport:k,scaleTo:C,scaleBy:M,setScaleExtent:P,setTranslateExtent:I,syncViewport:N,setClickDistance:z}}var jr;(function(e){e.Line="line",e.Handle="handle"})(jr||(jr={}));function aQ({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:a}){const i=e-t,l=n-r,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 ih(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:s}}function Cn(e,t){return Math.max(0,t-e)}function Mn(e,t){return Math.max(0,e-t)}function Os(e,t,n){return Math.max(0,t-e,e-n)}function lh(e,t){return e?!t:t}function iQ(e,t,n,r,s,a,i,l){let{affectsX:c,affectsY:d}=t;const{isHorizontal:u,isVertical:p}=t,h=u&&p,{xSnapped:m,ySnapped:g}=n,{minWidth:b,maxWidth:x,minHeight:y,maxHeight:w}=r,{x:v,y:N,width:k,height:C,aspectRatio:M}=e;let P=Math.floor(u?m-e.pointerX:0),I=Math.floor(p?g-e.pointerY:0);const z=k+(c?-P:P),A=C+(d?-I:I),O=-a[0]*k,R=-a[1]*C;let E=Os(z,b,x),D=Os(A,y,w);if(i){let B=0,F=0;c&&P<0?B=Cn(v+P+O,i[0][0]):!c&&P>0&&(B=Mn(v+z+O,i[1][0])),d&&I<0?F=Cn(N+I+R,i[0][1]):!d&&I>0&&(F=Mn(N+A+R,i[1][1])),E=Math.max(E,B),D=Math.max(D,F)}if(l){let B=0,F=0;c&&P>0?B=Mn(v+P,l[0][0]):!c&&P<0&&(B=Cn(v+z,l[1][0])),d&&I>0?F=Mn(N+I,l[0][1]):!d&&I<0&&(F=Cn(N+A,l[1][1])),E=Math.max(E,B),D=Math.max(D,F)}if(s){if(u){const B=Os(z/M,y,w)*M;if(E=Math.max(E,B),i){let F=0;!c&&!d||c&&!d&&h?F=Mn(N+R+z/M,i[1][1])*M:F=Cn(N+R+(c?P:-P)/M,i[0][1])*M,E=Math.max(E,F)}if(l){let F=0;!c&&!d||c&&!d&&h?F=Cn(N+z/M,l[1][1])*M:F=Mn(N+(c?P:-P)/M,l[0][1])*M,E=Math.max(E,F)}}if(p){const B=Os(A*M,b,x)/M;if(D=Math.max(D,B),i){let F=0;!c&&!d||d&&!c&&h?F=Mn(v+A*M+O,i[1][0])/M:F=Cn(v+(d?I:-I)*M+O,i[0][0])/M,D=Math.max(D,F)}if(l){let F=0;!c&&!d||d&&!c&&h?F=Cn(v+A*M,l[1][0])/M:F=Mn(v+(d?I:-I)*M,l[0][0])/M,D=Math.max(D,F)}}}I=I+(I<0?D:-D),P=P+(P<0?E:-E),s&&(h?z>A*M?I=(lh(c,d)?-P:P)/M:P=(lh(c,d)?-I:I)*M:u?(I=P/M,d=c):(P=I*M,c=d));const L=c?v+P:v,T=d?N+I:N;return{width:k+(c?-P:P),height:C+(d?-I:I),x:a[0]*P*(c?-1:1)+L,y:a[1]*I*(d?-1:1)+T}}const W1={width:0,height:0,x:0,y:0},lQ={...W1,pointerX:0,pointerY:0,aspectRatio:1};function cQ(e){return[[0,0],[e.measured.width,e.measured.height]]}function dQ(e,t,n){const r=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[[r-l,s-c],[r+a-l,s+i-c]]}function uQ({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const a=mt(e);let i={controlDirection:ih("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:u,keepAspectRatio:p,resizeDirection:h,onResizeStart:m,onResize:g,onResizeEnd:b,shouldResize:x}){let y={...W1},w={...lQ};i={boundaries:u,resizeDirection:h,keepAspectRatio:p,controlDirection:ih(d)};let v,N=null,k=[],C,M,P,I=!1;const z=s1().on("start",A=>{const{nodeLookup:O,transform:R,snapGrid:E,snapToGrid:D,nodeOrigin:L,paneDomNode:T}=n();if(v=O.get(t),!v)return;N=T?.getBoundingClientRect()??null;const{xSnapped:B,ySnapped:F}=Co(A.sourceEvent,{transform:R,snapGrid:E,snapToGrid:D,containerBounds:N});y={width:v.measured.width??0,height:v.measured.height??0,x:v.position.x??0,y:v.position.y??0},w={...y,pointerX:B,pointerY:F,aspectRatio:y.width/y.height},C=void 0,v.parentId&&(v.extent==="parent"||v.expandParent)&&(C=O.get(v.parentId),M=C&&v.extent==="parent"?cQ(C):void 0),k=[],P=void 0;for(const[j,V]of O)if(V.parentId===t&&(k.push({id:j,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const $=dQ(V,v,V.origin??L);P?P=[[Math.min($[0][0],P[0][0]),Math.min($[0][1],P[0][1])],[Math.max($[1][0],P[1][0]),Math.max($[1][1],P[1][1])]]:P=$}m?.(A,{...y})}).on("drag",A=>{const{transform:O,snapGrid:R,snapToGrid:E,nodeOrigin:D}=n(),L=Co(A.sourceEvent,{transform:O,snapGrid:R,snapToGrid:E,containerBounds:N}),T=[];if(!v)return;const{x:B,y:F,width:j,height:V}=y,$={},H=v.origin??D,{width:G,height:Z,x:oe,y:ne}=iQ(w,i.controlDirection,L,i.boundaries,i.keepAspectRatio,H,M,P),X=G!==j,re=Z!==V,be=oe!==B&&X,J=ne!==F&&re;if(!be&&!J&&!X&&!re)return;if((be||J||H[0]===1||H[1]===1)&&($.x=be?oe:y.x,$.y=J?ne:y.y,y.x=$.x,y.y=$.y,k.length>0)){const fe=oe-B,ge=ne-F;for(const Q of k)Q.position={x:Q.position.x-fe+H[0]*(G-j),y:Q.position.y-ge+H[1]*(Z-V)},T.push(Q)}if((X||re)&&($.width=X&&(!i.resizeDirection||i.resizeDirection==="horizontal")?G:y.width,$.height=re&&(!i.resizeDirection||i.resizeDirection==="vertical")?Z:y.height,y.width=$.width,y.height=$.height),C&&v.expandParent){const fe=H[0]*($.width??0);$.x&&$.x<fe&&(y.x=fe,w.x=w.x-($.x-fe));const ge=H[1]*($.height??0);$.y&&$.y<ge&&(y.y=ge,w.y=w.y-($.y-ge))}const W=aQ({width:y.width,prevWidth:j,height:y.height,prevHeight:V,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),ee={...y,direction:W};x?.(A,ee)!==!1&&(I=!0,g?.(A,ee),r($,T))}).on("end",A=>{I&&(b?.(A,{...y}),s?.({...y}),I=!1)});a.call(z)}function c(){a.on(".drag",null)}return{update:l,destroy:c}}var Y1={exports:{}},Z1={};/**
|
|
1143
|
+
* @license React
|
|
1144
|
+
* use-sync-external-store-shim/with-selector.production.js
|
|
1145
|
+
*
|
|
1146
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1147
|
+
*
|
|
1148
|
+
* This source code is licensed under the MIT license found in the
|
|
1149
|
+
* LICENSE file in the root directory of this source tree.
|
|
1150
|
+
*/var hi=lm,pQ=gv;function fQ(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var hQ=typeof Object.is=="function"?Object.is:fQ,mQ=pQ.useSyncExternalStore,gQ=hi.useRef,bQ=hi.useEffect,xQ=hi.useMemo,yQ=hi.useDebugValue;Z1.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var a=gQ(null);if(a.current===null){var i={hasValue:!1,value:null};a.current=i}else i=a.current;a=xQ(function(){function c(m){if(!d){if(d=!0,u=m,m=r(m),s!==void 0&&i.hasValue){var g=i.value;if(s(g,m))return p=g}return p=m}if(g=p,hQ(u,m))return g;var b=r(m);return s!==void 0&&s(g,b)?(u=m,g):(u=m,p=b)}var d=!1,u,p,h=n===void 0?null:n;return[function(){return c(t())},h===null?void 0:function(){return c(h())}]},[t,n,r,s]);var l=mQ(e,a[0],a[1]);return bQ(function(){i.hasValue=!0,i.value=l},[l]),yQ(l),l};Y1.exports=Z1;var vQ=Y1.exports;const wQ=t2(vQ),NQ={},ch=e=>{let t;const n=new Set,r=(u,p)=>{const h=typeof u=="function"?u(t):u;if(!Object.is(h,t)){const m=t;t=p??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(g=>g(t,m))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>d,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(NQ?"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(r,s,c);return c},kQ=e=>e?ch(e):ch,{useDebugValue:SQ}=Ge,{useSyncExternalStoreWithSelector:CQ}=wQ,MQ=e=>e;function X1(e,t=MQ,n){const r=CQ(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return SQ(r),r}const dh=(e,t)=>{const n=kQ(e),r=(s,a=t)=>X1(n,s,a);return Object.assign(r,n),r},EQ=(e,t)=>e?dh(e,t):dh;function Ve(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[r,s]of e)if(!Object.is(s,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const mi=ze(null),IQ=mi.Provider,J1=nn.error001();function De(e,t){const n=ve(mi);if(n===null)throw new Error(J1);return X1(n,e,t)}function qe(){const e=ve(mi);if(e===null)throw new Error(J1);return q(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const uh={display:"none"},AQ={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},ew="react-flow__node-desc",tw="react-flow__edge-desc",PQ="react-flow__aria-live",_Q=e=>e.ariaLiveMessage,$Q=e=>e.ariaLabelConfig;function DQ({rfId:e}){const t=De(_Q);return o("div",{id:`${PQ}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:AQ,children:t})}function LQ({rfId:e,disableKeyboardA11y:t}){const n=De($Q);return f(he,{children:[o("div",{id:`${ew}-${e}`,style:uh,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o("div",{id:`${tw}-${e}`,style:uh,children:n["edge.a11yDescription.default"]}),!t&&o(DQ,{rfId:e})]})}const gi=Ue(({position:e="top-left",children:t,className:n,style:r,...s},a)=>{const i=`${e}`.split("-");return o("div",{className:We(["react-flow__panel",n,...i]),style:r,ref:a,...s,children:t})});gi.displayName="Panel";function TQ({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:o(gi,{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:o("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const RQ=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},Bs=e=>e.id;function OQ(e,t){return Ve(e.selectedNodes.map(Bs),t.selectedNodes.map(Bs))&&Ve(e.selectedEdges.map(Bs),t.selectedEdges.map(Bs))}function BQ({onSelectionChange:e}){const t=qe(),{selectedNodes:n,selectedEdges:r}=De(RQ,OQ);return Y(()=>{const s={nodes:n,edges:r};e?.(s),t.getState().onSelectionChangeHandlers.forEach(a=>a(s))},[n,r,e]),null}const zQ=e=>!!e.onSelectionChangeHandlers;function FQ({onSelectionChange:e}){const t=De(zQ);return e||t?o(BQ,{onSelectionChange:e}):null}const vc=typeof window<"u"?Ia:Y,nw=[0,0],jQ={x:0,y:0,zoom:1},VQ=["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"],ph=[...VQ,"rfId"],HQ=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}),fh={translateExtent:zo,nodeOrigin:nw,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function qQ(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:a,setNodeExtent:i,reset:l,setDefaultNodesAndEdges:c}=De(HQ,Ve),d=qe();vc(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=fh,l()}),[]);const u=te(fh);return vc(()=>{for(const p of ph){const h=e[p],m=u.current[p];h!==m&&(typeof e[p]>"u"||(p==="nodes"?t(h):p==="edges"?n(h):p==="minZoom"?r(h):p==="maxZoom"?s(h):p==="translateExtent"?a(h):p==="nodeExtent"?i(h):p==="ariaLabelConfig"?d.setState({ariaLabelConfig:kU(h)}):p==="fitView"?d.setState({fitViewQueued:h}):p==="fitViewOptions"?d.setState({fitViewOptions:h}):d.setState({[p]:h})))}u.current=e},ph.map(p=>e[p])),null}function hh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function UQ(e){const[t,n]=_(e==="system"?null:e);return Y(()=>{if(e!=="system"){n(e);return}const r=hh(),s=()=>n(r?.matches?"dark":"light");return s(),r?.addEventListener("change",s),()=>{r?.removeEventListener("change",s)}},[e]),t!==null?t:hh()?.matches?"dark":"light"}const mh=typeof document<"u"?document:null;function Ho(e=null,t={target:mh,actInsideInputWithModifier:!0}){const[n,r]=_(!1),s=te(!1),a=te(new Set([])),[i,l]=q(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",`
|
|
1151
|
+
`).replace(`
|
|
1152
|
+
|
|
1153
|
+
`,`
|
|
1154
|
+
+`).split(`
|
|
1155
|
+
`)),u=d.reduce((p,h)=>p.concat(...h),[]);return[d,u]}return[[],[]]},[e]);return Y(()=>{const c=t?.target??mh,d=t?.actInsideInputWithModifier??!0;if(e!==null){const u=m=>{if(s.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!s.current||s.current&&!d)&&D1(m))return!1;const b=bh(m.code,l);if(a.current.add(m[b]),gh(i,a.current,!1)){const x=m.composedPath?.()?.[0]||m.target,y=x?.nodeName==="BUTTON"||x?.nodeName==="A";t.preventDefault!==!1&&(s.current||!y)&&m.preventDefault(),r(!0)}},p=m=>{const g=bh(m.code,l);gh(i,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(m[g]),m.key==="Meta"&&a.current.clear(),s.current=!1},h=()=>{a.current.clear(),r(!1)};return c?.addEventListener("keydown",u),c?.addEventListener("keyup",p),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{c?.removeEventListener("keydown",u),c?.removeEventListener("keyup",p),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[e,r]),n}function gh(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function bh(e,t){return t.includes(e)?"code":"key"}const QQ=()=>{const e=qe();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:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,a],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:s,minZoom:a,maxZoom:i,panZoom:l}=e.getState(),c=cu(t,r,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:r,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},u=n.snapGrid??s,p=n.snapToGrid??a;return ls(d,r,p,u)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:a}=r.getBoundingClientRect(),i=ka(t,n);return{x:i.x+s,y:i.y+a}}}),[])};function rw(e,t){const n=[],r=new Map,s=[];for(const a of e)if(a.type==="add"){s.push(a);continue}else if(a.type==="remove"||a.type==="replace")r.set(a.id,[a]);else{const i=r.get(a.id);i?i.push(a):r.set(a.id,[a])}for(const a of t){const i=r.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)GQ(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 GQ(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 KQ(e,t){return rw(e,t)}function WQ(e,t){return rw(e,t)}function Un(e,t){return{id:e,type:"select",selected:t}}function Mr(e,t=new Set,n=!1){const r=[];for(const[s,a]of e){const i=t.has(s);!(a.selected===void 0&&!i)&&a.selected!==i&&(n&&(a.selected=i),r.push(Un(a.id,i)))}return r}function xh({items:e=[],lookup:t}){const n=[],r=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)r.get(s)===void 0&&n.push({id:s,type:"remove"});return n}function yh(e){return{id:e.id,type:"remove"}}const vh=e=>fU(e),YQ=e=>C1(e);function ow(e){return Ue(e)}function wh(e){const[t,n]=_(BigInt(0)),[r]=_(()=>ZQ(()=>n(s=>s+BigInt(1))));return vc(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function ZQ(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const sw=ze(null);function XQ({children:e}){const t=qe(),n=U(l=>{const{nodes:c=[],setNodes:d,hasDefaultNodes:u,onNodesChange:p,nodeLookup:h,fitViewQueued:m,onNodesChangeMiddlewareMap:g}=t.getState();let b=c;for(const y of l)b=typeof y=="function"?y(b):y;let x=xh({items:b,lookup:h});for(const y of g.values())x=y(x);u&&d(b),x.length>0?p?.(x):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:w,setNodes:v}=t.getState();y&&v(w)})},[]),r=wh(n),s=U(l=>{const{edges:c=[],setEdges:d,hasDefaultEdges:u,onEdgesChange:p,edgeLookup:h}=t.getState();let m=c;for(const g of l)m=typeof g=="function"?g(m):g;u?d(m):p&&p(xh({items:m,lookup:h}))},[]),a=wh(s),i=q(()=>({nodeQueue:r,edgeQueue:a}),[]);return o(sw.Provider,{value:i,children:e})}function JQ(){const e=ve(sw);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const eG=e=>!!e.panZoom;function gu(){const e=QQ(),t=qe(),n=JQ(),r=De(eG),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:h,nodeOrigin:m}=t.getState(),g=vh(p)?p:h.get(p.id),b=g.parentId?_1(g.position,g.measured,g.parentId,h,m):g.position,x={...g,position:b,width:g.measured?.width??g.width,height:g.measured?.height??g.height};return zr(x)},d=(p,h,m={replace:!1})=>{i(g=>g.map(b=>{if(b.id===p){const x=typeof h=="function"?h(b):h;return m.replace&&vh(x)?x:{...b,...x}}return b}))},u=(p,h,m={replace:!1})=>{l(g=>g.map(b=>{if(b.id===p){const x=typeof h=="function"?h(b):h;return m.replace&&YQ(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(h=>({...h}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:i,setEdges:l,addNodes:p=>{const h=Array.isArray(p)?p:[p];n.nodeQueue.push(m=>[...m,...h])},addEdges:p=>{const h=Array.isArray(p)?p:[p];n.edgeQueue.push(m=>[...m,...h])},toObject:()=>{const{nodes:p=[],edges:h=[],transform:m}=t.getState(),[g,b,x]=m;return{nodes:p.map(y=>({...y})),edges:h.map(y=>({...y})),viewport:{x:g,y:b,zoom:x}}},deleteElements:async({nodes:p=[],edges:h=[]})=>{const{nodes:m,edges:g,onNodesDelete:b,onEdgesDelete:x,triggerNodeChanges:y,triggerEdgeChanges:w,onDelete:v,onBeforeDelete:N}=t.getState(),{nodes:k,edges:C}=await xU({nodesToRemove:p,edgesToRemove:h,nodes:m,edges:g,onBeforeDelete:N}),M=C.length>0,P=k.length>0;if(M){const I=C.map(yh);x?.(C),w(I)}if(P){const I=k.map(yh);b?.(k),y(I)}return(P||M)&&v?.({nodes:k,edges:C}),{deletedNodes:k,deletedEdges:C}},getIntersectingNodes:(p,h=!0,m)=>{const g=Yf(p),b=g?p:c(p),x=m!==void 0;return b?(m||t.getState().nodes).filter(y=>{const w=t.getState().nodeLookup.get(y.id);if(w&&!g&&(y.id===p.id||!w.internals.positionAbsolute))return!1;const v=zr(x?y:w),N=jo(v,b);return h&&N>0||N>=v.width*v.height||N>=b.width*b.height}):[]},isNodeIntersecting:(p,h,m=!0)=>{const b=Yf(p)?p:c(p);if(!b)return!1;const x=jo(b,h);return m&&x>0||x>=h.width*h.height||x>=b.width*b.height},updateNode:d,updateNodeData:(p,h,m={replace:!1})=>{d(p,g=>{const b=typeof h=="function"?h(g):h;return m.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},m)},updateEdge:u,updateEdgeData:(p,h,m={replace:!1})=>{u(p,g=>{const b=typeof h=="function"?h(g):h;return m.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},m)},getNodesBounds:p=>{const{nodeLookup:h,nodeOrigin:m}=t.getState();return hU(p,{nodeLookup:h,nodeOrigin:m})},getHandleConnections:({type:p,id:h,nodeId:m})=>Array.from(t.getState().connectionLookup.get(`${m}-${p}${h?`-${h}`:""}`)?.values()??[]),getNodeConnections:({type:p,handleId:h,nodeId:m})=>Array.from(t.getState().connectionLookup.get(`${m}${p?h?`-${p}-${h}`:`-${p}`:""}`)?.values()??[]),fitView:async p=>{const h=t.getState().fitViewResolver??NU();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:h}),n.nodeQueue.push(m=>[...m]),h.promise}}},[]);return q(()=>({...s,...e,viewportInitialized:r}),[r])}const Nh=e=>e.selected,tG=typeof window<"u"?window:void 0;function nG({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=qe(),{deleteElements:r}=gu(),s=Ho(e,{actInsideInputWithModifier:!1}),a=Ho(t,{target:tG});Y(()=>{if(s){const{edges:i,nodes:l}=n.getState();r({nodes:l.filter(Nh),edges:i.filter(Nh)}),n.setState({nodesSelectionActive:!1})}},[s]),Y(()=>{n.setState({multiSelectionActive:a})},[a])}function rG(e){const t=qe();Y(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const r=du(e.current);(r.height===0||r.width===0)&&t.getState().onError?.("004",nn.error004()),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const bi={position:"absolute",width:"100%",height:"100%",top:0,left:0},oG=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function sG({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:a=Zn.Free,zoomOnDoubleClick:i=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:d,minZoom:u,maxZoom:p,zoomActivationKeyCode:h,preventScrolling:m=!0,children:g,noWheelClassName:b,noPanClassName:x,onViewportChange:y,isControlledViewport:w,paneClickDistance:v,selectionOnDrag:N}){const k=qe(),C=te(null),{userSelectionActive:M,lib:P,connectionInProgress:I}=De(oG,Ve),z=Ho(h),A=te();rG(C);const O=U(R=>{y?.({x:R[0],y:R[1],zoom:R[2]}),w||k.setState({transform:R})},[y,w]);return Y(()=>{if(C.current){A.current=sQ({domNode:C.current,minZoom:u,maxZoom:p,translateExtent:d,viewport:c,onDraggingChange:L=>k.setState(T=>T.paneDragging===L?T:{paneDragging:L}),onPanZoomStart:(L,T)=>{const{onViewportChangeStart:B,onMoveStart:F}=k.getState();F?.(L,T),B?.(T)},onPanZoom:(L,T)=>{const{onViewportChange:B,onMove:F}=k.getState();F?.(L,T),B?.(T)},onPanZoomEnd:(L,T)=>{const{onViewportChangeEnd:B,onMoveEnd:F}=k.getState();F?.(L,T),B?.(T)}});const{x:R,y:E,zoom:D}=A.current.getViewport();return k.setState({panZoom:A.current,transform:[R,E,D],domNode:C.current.closest(".react-flow")}),()=>{A.current?.destroy()}}},[]),Y(()=>{A.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:a,zoomOnDoubleClick:i,panOnDrag:l,zoomActivationKeyPressed:z,preventScrolling:m,noPanClassName:x,userSelectionActive:M,noWheelClassName:b,lib:P,onTransformChange:O,connectionInProgress:I,selectionOnDrag:N,paneClickDistance:v})},[e,t,n,r,s,a,i,l,z,m,x,M,b,P,O,I,N,v]),o("div",{className:"react-flow__renderer",ref:C,style:bi,children:g})}const aG=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function iG(){const{userSelectionActive:e,userSelectionRect:t}=De(aG,Ve);return e&&t?o("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 gl=(e,t)=>n=>{n.target===t.current&&e?.(n)},lG=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function cG({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Fo.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:a,onSelectionStart:i,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:d,onPaneScroll:u,onPaneMouseEnter:p,onPaneMouseMove:h,onPaneMouseLeave:m,children:g}){const b=qe(),{userSelectionActive:x,elementsSelectable:y,dragging:w,connectionInProgress:v}=De(lG,Ve),N=y&&(e||x),k=te(null),C=te(),M=te(new Set),P=te(new Set),I=te(!1),z=B=>{if(I.current||v){I.current=!1;return}c?.(B),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},A=B=>{if(Array.isArray(r)&&r?.includes(2)){B.preventDefault();return}d?.(B)},O=u?B=>u(B):void 0,R=B=>{I.current&&(B.stopPropagation(),I.current=!1)},E=B=>{const{domNode:F}=b.getState();if(C.current=F?.getBoundingClientRect(),!C.current)return;const j=B.target===k.current;if(!j&&!!B.target.closest(".nokey")||!e||!(a&&j||t)||B.button!==0||!B.isPrimary)return;B.target?.setPointerCapture?.(B.pointerId),I.current=!1;const{x:H,y:G}=Bt(B.nativeEvent,C.current);b.setState({userSelectionRect:{width:0,height:0,startX:H,startY:G,x:H,y:G}}),j||(B.stopPropagation(),B.preventDefault())},D=B=>{const{userSelectionRect:F,transform:j,nodeLookup:V,edgeLookup:$,connectionLookup:H,triggerNodeChanges:G,triggerEdgeChanges:Z,defaultEdgeOptions:oe,resetSelectedElements:ne}=b.getState();if(!C.current||!F)return;const{x:X,y:re}=Bt(B.nativeEvent,C.current),{startX:be,startY:J}=F;if(!I.current){const ge=t?0:s;if(Math.hypot(X-be,re-J)<=ge)return;ne(),i?.(B)}I.current=!0;const W={startX:be,startY:J,x:X<be?X:be,y:re<J?re:J,width:Math.abs(X-be),height:Math.abs(re-J)},ee=M.current,ae=P.current;M.current=new Set(lu(V,W,j,n===Fo.Partial,!0).map(ge=>ge.id)),P.current=new Set;const fe=oe?.selectable??!0;for(const ge of M.current){const Q=H.get(ge);if(Q)for(const{edgeId:le}of Q.values()){const ue=$.get(le);ue&&(ue.selectable??fe)&&P.current.add(le)}}if(!Zf(ee,M.current)){const ge=Mr(V,M.current,!0);G(ge)}if(!Zf(ae,P.current)){const ge=Mr($,P.current);Z(ge)}b.setState({userSelectionRect:W,userSelectionActive:!0,nodesSelectionActive:!1})},L=B=>{B.button===0&&(B.target?.releasePointerCapture?.(B.pointerId),!x&&B.target===k.current&&b.getState().userSelectionRect&&z?.(B),b.setState({userSelectionActive:!1,userSelectionRect:null}),I.current&&(l?.(B),b.setState({nodesSelectionActive:M.current.size>0})))},T=r===!0||Array.isArray(r)&&r.includes(0);return f("div",{className:We(["react-flow__pane",{draggable:T,dragging:w,selection:e}]),onClick:N?void 0:gl(z,k),onContextMenu:gl(A,k),onWheel:gl(O,k),onPointerEnter:N?void 0:p,onPointerMove:N?D:h,onPointerUp:N?L:void 0,onPointerDownCapture:N?E:void 0,onClickCapture:N?R:void 0,onPointerLeave:m,ref:k,style:bi,children:[g,o(iG,{})]})}function wc({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:a,multiSelectionActive:i,nodeLookup:l,onError:c}=t.getState(),d=l.get(e);if(!d){c?.("012",nn.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&i)&&(a({nodes:[d],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):s([e])}function aw({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:a,nodeClickDistance:i}){const l=qe(),[c,d]=_(!1),u=te();return Y(()=>{u.current=UU({getStoreItems:()=>l.getState(),onNodeMouseDown:p=>{wc({id:p,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),Y(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:s,nodeClickDistance:i}),()=>{u.current?.destroy()}},[n,r,t,a,e,s,i]),c}const dG=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function iw(){const e=qe();return U(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:a,nodesDraggable:i,onError:l,updateNodePositions:c,nodeLookup:d,nodeOrigin:u}=e.getState(),p=new Map,h=dG(i),m=s?a[0]:5,g=s?a[1]:5,b=n.direction.x*m*n.factor,x=n.direction.y*g*n.factor;for(const[,y]of d){if(!h(y))continue;let w={x:y.internals.positionAbsolute.x+b,y:y.internals.positionAbsolute.y+x};s&&(w=is(w,a));const{position:v,positionAbsolute:N}=M1({nodeId:y.id,nextPosition:w,nodeLookup:d,nodeExtent:r,nodeOrigin:u,onError:l});y.position=v,y.internals.positionAbsolute=N,p.set(y.id,y)}c(p)},[])}const bu=ze(null),uG=bu.Provider;bu.Consumer;const lw=()=>ve(bu),pG=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),fG=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:a,connection:i}=r,{fromHandle:l,toHandle:c,isValid:d}=i,u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:l?.nodeId===e&&l?.id===t&&l?.type===n,connectingTo:u,clickConnecting:s?.nodeId===e&&s?.id===t&&s?.type===n,isPossibleEndHandle:a===Or.Strict?l?.type!==n:e!==l?.nodeId||t!==l?.id,connectionInProcess:!!l,clickConnectionInProcess:!!s,valid:u&&d}};function hG({type:e="source",position:t=we.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:a=!0,id:i,onConnect:l,children:c,className:d,onMouseDown:u,onTouchStart:p,...h},m){const g=i||null,b=e==="target",x=qe(),y=lw(),{connectOnClick:w,noPanClassName:v,rfId:N}=De(pG,Ve),{connectingFrom:k,connectingTo:C,clickConnecting:M,isPossibleEndHandle:P,connectionInProcess:I,clickConnectionInProcess:z,valid:A}=De(fG(y,g,e),Ve);y||x.getState().onError?.("010",nn.error010());const O=D=>{const{defaultEdgeOptions:L,onConnect:T,hasDefaultEdges:B}=x.getState(),F={...L,...D};if(B){const{edges:j,setEdges:V}=x.getState();V(AU(F,j))}T?.(F),l?.(F)},R=D=>{if(!y)return;const L=L1(D.nativeEvent);if(s&&(L&&D.button===0||!L)){const T=x.getState();yc.onPointerDown(D.nativeEvent,{handleDomNode:D.currentTarget,autoPanOnConnect:T.autoPanOnConnect,connectionMode:T.connectionMode,connectionRadius:T.connectionRadius,domNode:T.domNode,nodeLookup:T.nodeLookup,lib:T.lib,isTarget:b,handleId:g,nodeId:y,flowId:T.rfId,panBy:T.panBy,cancelConnection:T.cancelConnection,onConnectStart:T.onConnectStart,onConnectEnd:(...B)=>x.getState().onConnectEnd?.(...B),updateConnection:T.updateConnection,onConnect:O,isValidConnection:n||((...B)=>x.getState().isValidConnection?.(...B)??!0),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:T.autoPanSpeed,dragThreshold:T.connectionDragThreshold})}L?u?.(D):p?.(D)},E=D=>{const{onClickConnectStart:L,onClickConnectEnd:T,connectionClickStartHandle:B,connectionMode:F,isValidConnection:j,lib:V,rfId:$,nodeLookup:H,connection:G}=x.getState();if(!y||!B&&!s)return;if(!B){L?.(D.nativeEvent,{nodeId:y,handleId:g,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const Z=$1(D.target),oe=n||j,{connection:ne,isValid:X}=yc.isValid(D.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:F,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:oe,flowId:$,doc:Z,lib:V,nodeLookup:H});X&&ne&&O(ne);const re=structuredClone(G);delete re.inProgress,re.toPosition=re.toHandle?re.toHandle.position:null,T?.(D,re),x.setState({connectionClickStartHandle:null})};return o("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${N}-${y}-${g}-${e}`,className:We(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",v,d,{source:!b,target:b,connectable:r,connectablestart:s,connectableend:a,clickconnecting:M,connectingfrom:k,connectingto:C,valid:A,connectionindicator:r&&(!I||P)&&(I||z?a:s)}]),onMouseDown:R,onTouchStart:R,onClick:w?E:void 0,ref:m,...h,children:c})}const Dn=He(ow(hG));function mG({data:e,isConnectable:t,sourcePosition:n=we.Bottom}){return f(he,{children:[e?.label,o(Dn,{type:"source",position:n,isConnectable:t})]})}function gG({data:e,isConnectable:t,targetPosition:n=we.Top,sourcePosition:r=we.Bottom}){return f(he,{children:[o(Dn,{type:"target",position:n,isConnectable:t}),e?.label,o(Dn,{type:"source",position:r,isConnectable:t})]})}function bG(){return null}function xG({data:e,isConnectable:t,targetPosition:n=we.Top}){return f(he,{children:[o(Dn,{type:"target",position:n,isConnectable:t}),e?.label]})}const Sa={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},kh={input:mG,default:gG,output:xG,group:bG};function yG(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 vG=e=>{const{width:t,height:n,x:r,y:s}=as(e.nodeLookup,{filter:a=>!!a.selected});return{width:Ot(t)?t:null,height:Ot(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${s}px)`}};function wG({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=qe(),{width:s,height:a,transformString:i,userSelectionActive:l}=De(vG,Ve),c=iw(),d=te(null);Y(()=>{n||d.current?.focus({preventScroll:!0})},[n]);const u=!l&&s!==null&&a!==null;if(aw({nodeRef:d,disabled:!u}),!u)return null;const p=e?m=>{const g=r.getState().nodes.filter(b=>b.selected);e(m,g)}:void 0,h=m=>{Object.prototype.hasOwnProperty.call(Sa,m.key)&&(m.preventDefault(),c({direction:Sa[m.key],factor:m.shiftKey?4:1}))};return o("div",{className:We(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:o("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:s,height:a}})})}const Sh=typeof window<"u"?window:void 0,NG=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function cw({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:i,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:d,selectionOnDrag:u,selectionMode:p,onSelectionStart:h,onSelectionEnd:m,multiSelectionKeyCode:g,panActivationKeyCode:b,zoomActivationKeyCode:x,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:v,panOnScroll:N,panOnScrollSpeed:k,panOnScrollMode:C,zoomOnDoubleClick:M,panOnDrag:P,defaultViewport:I,translateExtent:z,minZoom:A,maxZoom:O,preventScrolling:R,onSelectionContextMenu:E,noWheelClassName:D,noPanClassName:L,disableKeyboardA11y:T,onViewportChange:B,isControlledViewport:F}){const{nodesSelectionActive:j,userSelectionActive:V}=De(NG,Ve),$=Ho(d,{target:Sh}),H=Ho(b,{target:Sh}),G=H||P,Z=H||N,oe=u&&G!==!0,ne=$||V||oe;return nG({deleteKeyCode:c,multiSelectionKeyCode:g}),o(sG,{onPaneContextMenu:a,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:v,panOnScroll:Z,panOnScrollSpeed:k,panOnScrollMode:C,zoomOnDoubleClick:M,panOnDrag:!$&&G,defaultViewport:I,translateExtent:z,minZoom:A,maxZoom:O,zoomActivationKeyCode:x,preventScrolling:R,noWheelClassName:D,noPanClassName:L,onViewportChange:B,isControlledViewport:F,paneClickDistance:l,selectionOnDrag:oe,children:f(cG,{onSelectionStart:h,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:i,panOnDrag:G,isSelecting:!!ne,selectionMode:p,selectionKeyPressed:$,paneClickDistance:l,selectionOnDrag:oe,children:[e,j&&o(wG,{onSelectionContextMenu:E,noPanClassName:L,disableKeyboardA11y:T})]})})}cw.displayName="FlowRenderer";const kG=He(cw),SG=e=>t=>e?lu(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 CG(e){return De(U(SG(e),[e]),Ve)}const MG=e=>e.updateNodeInternals;function EG(){const e=De(MG),[t]=_(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const a=s.target.getAttribute("data-id");r.set(a,{id:a,nodeElement:s.target,force:!0})}),e(r)}));return Y(()=>()=>{t?.disconnect()},[t]),t}function IG({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=qe(),a=te(null),i=te(null),l=te(e.sourcePosition),c=te(e.targetPosition),d=te(t),u=n&&!!e.internals.handleBounds;return Y(()=>{a.current&&!e.hidden&&(!u||i.current!==a.current)&&(i.current&&r?.unobserve(i.current),r?.observe(a.current),i.current=a.current)},[u,e.hidden]),Y(()=>()=>{i.current&&(r?.unobserve(i.current),i.current=null)},[]),Y(()=>{if(a.current){const p=d.current!==t,h=l.current!==e.sourcePosition,m=c.current!==e.targetPosition;(p||h||m)&&(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 AG({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:a,onDoubleClick:i,nodesDraggable:l,elementsSelectable:c,nodesConnectable:d,nodesFocusable:u,resizeObserver:p,noDragClassName:h,noPanClassName:m,disableKeyboardA11y:g,rfId:b,nodeTypes:x,nodeClickDistance:y,onError:w}){const{node:v,internals:N,isParent:k}=De(X=>{const re=X.nodeLookup.get(e),be=X.parentLookup.has(e);return{node:re,internals:re.internals,isParent:be}},Ve);let C=v.type||"default",M=x?.[C]||kh[C];M===void 0&&(w?.("003",nn.error003(C)),C="default",M=x?.default||kh.default);const P=!!(v.draggable||l&&typeof v.draggable>"u"),I=!!(v.selectable||c&&typeof v.selectable>"u"),z=!!(v.connectable||d&&typeof v.connectable>"u"),A=!!(v.focusable||u&&typeof v.focusable>"u"),O=qe(),R=P1(v),E=IG({node:v,nodeType:C,hasDimensions:R,resizeObserver:p}),D=aw({nodeRef:E,disabled:v.hidden||!P,noDragClassName:h,handleSelector:v.dragHandle,nodeId:e,isSelectable:I,nodeClickDistance:y}),L=iw();if(v.hidden)return null;const T=Nn(v),B=yG(v),F=I||P||t||n||r||s,j=n?X=>n(X,{...N.userNode}):void 0,V=r?X=>r(X,{...N.userNode}):void 0,$=s?X=>s(X,{...N.userNode}):void 0,H=a?X=>a(X,{...N.userNode}):void 0,G=i?X=>i(X,{...N.userNode}):void 0,Z=X=>{const{selectNodesOnDrag:re,nodeDragThreshold:be}=O.getState();I&&(!re||!P||be>0)&&wc({id:e,store:O,nodeRef:E}),t&&t(X,{...N.userNode})},oe=X=>{if(!(D1(X.nativeEvent)||g)){if(w1.includes(X.key)&&I){const re=X.key==="Escape";wc({id:e,store:O,unselect:re,nodeRef:E})}else if(P&&v.selected&&Object.prototype.hasOwnProperty.call(Sa,X.key)){X.preventDefault();const{ariaLabelConfig:re}=O.getState();O.setState({ariaLiveMessage:re["node.a11yDescription.ariaLiveMessage"]({direction:X.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),L({direction:Sa[X.key],factor:X.shiftKey?4:1})}}},ne=()=>{if(g||!E.current?.matches(":focus-visible"))return;const{transform:X,width:re,height:be,autoPanOnNodeFocus:J,setCenter:W}=O.getState();if(!J)return;lu(new Map([[e,v]]),{x:0,y:0,width:re,height:be},X,!0).length>0||W(v.position.x+T.width/2,v.position.y+T.height/2,{zoom:X[2]})};return o("div",{className:We(["react-flow__node",`react-flow__node-${C}`,{[m]:P},v.className,{selected:v.selected,selectable:I,parent:k,draggable:P,dragging:D}]),ref:E,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:F?"all":"none",visibility:R?"visible":"hidden",...v.style,...B},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:j,onMouseMove:V,onMouseLeave:$,onContextMenu:H,onClick:Z,onDoubleClick:G,onKeyDown:A?oe:void 0,tabIndex:A?0:void 0,onFocus:A?ne:void 0,role:v.ariaRole??(A?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${ew}-${b}`,"aria-label":v.ariaLabel,...v.domAttributes,children:o(uG,{value:e,children:o(M,{id:e,data:v.data,type:C,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:v.selected??!1,selectable:I,draggable:P,deletable:v.deletable??!0,isConnectable:z,sourcePosition:v.sourcePosition,targetPosition:v.targetPosition,dragging:D,dragHandle:v.dragHandle,zIndex:N.z,parentId:v.parentId,...T})})})}var PG=He(AG);const _G=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function dw(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:a}=De(_G,Ve),i=CG(e.onlyRenderVisibleElements),l=EG();return o("div",{className:"react-flow__nodes",style:bi,children:i.map(c=>o(PG,{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:r,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:a},c))})}dw.displayName="NodeRenderer";const $G=He(dw);function DG(e){return De(U(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];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&&MU({sourceNode:a,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),Ve)}const LG=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return o("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},TG=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return o("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Ch={[wa.Arrow]:LG,[wa.ArrowClosed]:TG};function RG(e){const t=qe();return q(()=>Object.prototype.hasOwnProperty.call(Ch,e)?Ch[e]:(t.getState().onError?.("009",nn.error009(e)),null),[e])}const OG=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:a="strokeWidth",strokeWidth:i,orient:l="auto-start-reverse"})=>{const c=RG(t);return c?o("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:l,refX:"0",refY:"0",children:o(c,{color:n,strokeWidth:i})}):null},uw=({defaultColor:e,rfId:t})=>{const n=De(a=>a.edges),r=De(a=>a.defaultEdgeOptions),s=q(()=>LU(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return s.length?o("svg",{className:"react-flow__marker","aria-hidden":"true",children:o("defs",{children:s.map(a=>o(OG,{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};uw.displayName="MarkerDefinitions";var BG=He(uw);function pw({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:a,labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...u}){const[p,h]=_({x:1,y:0,width:0,height:0}),m=We(["react-flow__edge-textwrapper",d]),g=te(null);return Y(()=>{if(g.current){const b=g.current.getBBox();h({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?f("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:m,visibility:p.width?"visible":"hidden",...u,children:[s&&o("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}),o("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]}):null}pw.displayName="EdgeText";const zG=He(pw);function xi({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:d=20,...u}){return f(he,{children:[o("path",{...u,d:e,fill:"none",className:We(["react-flow__edge-path",u.className])}),d?o("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,r&&Ot(t)&&Ot(n)?o(zG,{x:t,y:n,label:r,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function Mh({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===we.Left||e===we.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function fw({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:r,targetY:s,targetPosition:a=we.Top}){const[i,l]=Mh({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,d]=Mh({pos:a,x1:r,y1:s,x2:e,y2:t}),[u,p,h,m]=T1({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:i,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${i},${l} ${c},${d} ${r},${s}`,u,p,h,m]}function hw(e){return He(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:a,sourcePosition:i,targetPosition:l,label:c,labelStyle:d,labelShowBg:u,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:x,interactionWidth:y})=>{const[w,v,N]=fw({sourceX:n,sourceY:r,sourcePosition:i,targetX:s,targetY:a,targetPosition:l}),k=e.isInternal?void 0:t;return o(xi,{id:k,path:w,labelX:v,labelY:N,label:c,labelStyle:d,labelShowBg:u,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:x,interactionWidth:y})})}const FG=hw({isInternal:!1}),mw=hw({isInternal:!0});FG.displayName="SimpleBezierEdge";mw.displayName="SimpleBezierEdgeInternal";function gw(e){return He(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:a,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:h,sourcePosition:m=we.Bottom,targetPosition:g=we.Top,markerEnd:b,markerStart:x,pathOptions:y,interactionWidth:w})=>{const[v,N,k]=gc({sourceX:n,sourceY:r,sourcePosition:m,targetX:s,targetY:a,targetPosition:g,borderRadius:y?.borderRadius,offset:y?.offset,stepPosition:y?.stepPosition}),C=e.isInternal?void 0:t;return o(xi,{id:C,path:v,labelX:N,labelY:k,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:h,markerEnd:b,markerStart:x,interactionWidth:w})})}const bw=gw({isInternal:!1}),xw=gw({isInternal:!0});bw.displayName="SmoothStepEdge";xw.displayName="SmoothStepEdgeInternal";function yw(e){return He(({id:t,...n})=>{const r=e.isInternal?void 0:t;return o(bw,{...n,id:r,pathOptions:q(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const jG=yw({isInternal:!1}),vw=yw({isInternal:!0});jG.displayName="StepEdge";vw.displayName="StepEdgeInternal";function ww(e){return He(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:a,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:h,markerEnd:m,markerStart:g,interactionWidth:b})=>{const[x,y,w]=B1({sourceX:n,sourceY:r,targetX:s,targetY:a}),v=e.isInternal?void 0:t;return o(xi,{id:v,path:x,labelX:y,labelY:w,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:h,markerEnd:m,markerStart:g,interactionWidth:b})})}const VG=ww({isInternal:!1}),Nw=ww({isInternal:!0});VG.displayName="StraightEdge";Nw.displayName="StraightEdgeInternal";function kw(e){return He(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:a,sourcePosition:i=we.Bottom,targetPosition:l=we.Top,label:c,labelStyle:d,labelShowBg:u,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:x,pathOptions:y,interactionWidth:w})=>{const[v,N,k]=R1({sourceX:n,sourceY:r,sourcePosition:i,targetX:s,targetY:a,targetPosition:l,curvature:y?.curvature}),C=e.isInternal?void 0:t;return o(xi,{id:C,path:v,labelX:N,labelY:k,label:c,labelStyle:d,labelShowBg:u,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:x,interactionWidth:w})})}const HG=kw({isInternal:!1}),Sw=kw({isInternal:!0});HG.displayName="BezierEdge";Sw.displayName="BezierEdgeInternal";const Eh={default:Sw,straight:Nw,step:vw,smoothstep:xw,simplebezier:mw},Ih={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},qG=(e,t,n)=>n===we.Left?e-t:n===we.Right?e+t:e,UG=(e,t,n)=>n===we.Top?e-t:n===we.Bottom?e+t:e,Ah="react-flow__edgeupdater";function Ph({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:a,onMouseOut:i,type:l}){return o("circle",{onMouseDown:s,onMouseEnter:a,onMouseOut:i,className:We([Ah,`${Ah}-${l}`]),cx:qG(t,r,e),cy:UG(n,r,e),r,stroke:"transparent",fill:"transparent"})}function QG({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:a,targetY:i,sourcePosition:l,targetPosition:c,onReconnect:d,onReconnectStart:u,onReconnectEnd:p,setReconnecting:h,setUpdateHover:m}){const g=qe(),b=(N,k)=>{if(N.button!==0)return;const{autoPanOnConnect:C,domNode:M,connectionMode:P,connectionRadius:I,lib:z,onConnectStart:A,cancelConnection:O,nodeLookup:R,rfId:E,panBy:D,updateConnection:L}=g.getState(),T=k.type==="target",B=(V,$)=>{h(!1),p?.(V,n,k.type,$)},F=V=>d?.(n,V),j=(V,$)=>{h(!0),u?.(N,n,k.type),A?.(V,$)};yc.onPointerDown(N.nativeEvent,{autoPanOnConnect:C,connectionMode:P,connectionRadius:I,domNode:M,handleId:k.id,nodeId:k.nodeId,nodeLookup:R,isTarget:T,edgeUpdaterType:k.type,lib:z,flowId:E,cancelConnection:O,panBy:D,isValidConnection:(...V)=>g.getState().isValidConnection?.(...V)??!0,onConnect:F,onConnectStart:j,onConnectEnd:(...V)=>g.getState().onConnectEnd?.(...V),onReconnectEnd:B,updateConnection:L,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"}),y=N=>b(N,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),w=()=>m(!0),v=()=>m(!1);return f(he,{children:[(e===!0||e==="source")&&o(Ph,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:x,onMouseEnter:w,onMouseOut:v,type:"source"}),(e===!0||e==="target")&&o(Ph,{position:c,centerX:a,centerY:i,radius:t,onMouseDown:y,onMouseEnter:w,onMouseOut:v,type:"target"})]})}function GG({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:a,onContextMenu:i,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,reconnectRadius:u,onReconnect:p,onReconnectStart:h,onReconnectEnd:m,rfId:g,edgeTypes:b,noPanClassName:x,onError:y,disableKeyboardA11y:w}){let v=De(W=>W.edgeLookup.get(e));const N=De(W=>W.defaultEdgeOptions);v=N?{...N,...v}:v;let k=v.type||"default",C=b?.[k]||Eh[k];C===void 0&&(y?.("011",nn.error011(k)),k="default",C=b?.default||Eh.default);const M=!!(v.focusable||t&&typeof v.focusable>"u"),P=typeof p<"u"&&(v.reconnectable||n&&typeof v.reconnectable>"u"),I=!!(v.selectable||r&&typeof v.selectable>"u"),z=te(null),[A,O]=_(!1),[R,E]=_(!1),D=qe(),{zIndex:L,sourceX:T,sourceY:B,targetX:F,targetY:j,sourcePosition:V,targetPosition:$}=De(U(W=>{const ee=W.nodeLookup.get(v.source),ae=W.nodeLookup.get(v.target);if(!ee||!ae)return{zIndex:v.zIndex,...Ih};const fe=DU({id:e,sourceNode:ee,targetNode:ae,sourceHandle:v.sourceHandle||null,targetHandle:v.targetHandle||null,connectionMode:W.connectionMode,onError:y});return{zIndex:CU({selected:v.selected,zIndex:v.zIndex,sourceNode:ee,targetNode:ae,elevateOnSelect:W.elevateEdgesOnSelect,zIndexMode:W.zIndexMode}),...fe||Ih}},[v.source,v.target,v.sourceHandle,v.targetHandle,v.selected,v.zIndex]),Ve),H=q(()=>v.markerStart?`url('#${bc(v.markerStart,g)}')`:void 0,[v.markerStart,g]),G=q(()=>v.markerEnd?`url('#${bc(v.markerEnd,g)}')`:void 0,[v.markerEnd,g]);if(v.hidden||T===null||B===null||F===null||j===null)return null;const Z=W=>{const{addSelectedEdges:ee,unselectNodesAndEdges:ae,multiSelectionActive:fe}=D.getState();I&&(D.setState({nodesSelectionActive:!1}),v.selected&&fe?(ae({nodes:[],edges:[v]}),z.current?.blur()):ee([e])),s&&s(W,v)},oe=a?W=>{a(W,{...v})}:void 0,ne=i?W=>{i(W,{...v})}:void 0,X=l?W=>{l(W,{...v})}:void 0,re=c?W=>{c(W,{...v})}:void 0,be=d?W=>{d(W,{...v})}:void 0,J=W=>{if(!w&&w1.includes(W.key)&&I){const{unselectNodesAndEdges:ee,addSelectedEdges:ae}=D.getState();W.key==="Escape"?(z.current?.blur(),ee({edges:[v]})):ae([e])}};return o("svg",{style:{zIndex:L},children:f("g",{className:We(["react-flow__edge",`react-flow__edge-${k}`,v.className,x,{selected:v.selected,animated:v.animated,inactive:!I&&!s,updating:A,selectable:I}]),onClick:Z,onDoubleClick:oe,onContextMenu:ne,onMouseEnter:X,onMouseMove:re,onMouseLeave:be,onKeyDown:M?J:void 0,tabIndex:M?0:void 0,role:v.ariaRole??(M?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":v.ariaLabel===null?void 0:v.ariaLabel||`Edge from ${v.source} to ${v.target}`,"aria-describedby":M?`${tw}-${g}`:void 0,ref:z,...v.domAttributes,children:[!R&&o(C,{id:e,source:v.source,target:v.target,type:v.type,selected:v.selected,animated:v.animated,selectable:I,deletable:v.deletable??!0,label:v.label,labelStyle:v.labelStyle,labelShowBg:v.labelShowBg,labelBgStyle:v.labelBgStyle,labelBgPadding:v.labelBgPadding,labelBgBorderRadius:v.labelBgBorderRadius,sourceX:T,sourceY:B,targetX:F,targetY:j,sourcePosition:V,targetPosition:$,data:v.data,style:v.style,sourceHandleId:v.sourceHandle,targetHandleId:v.targetHandle,markerStart:H,markerEnd:G,pathOptions:"pathOptions"in v?v.pathOptions:void 0,interactionWidth:v.interactionWidth}),P&&o(QG,{edge:v,isReconnectable:P,reconnectRadius:u,onReconnect:p,onReconnectStart:h,onReconnectEnd:m,sourceX:T,sourceY:B,targetX:F,targetY:j,sourcePosition:V,targetPosition:$,setUpdateHover:O,setReconnecting:E})]})})}var KG=He(GG);const WG=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Cw({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:a,onEdgeContextMenu:i,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeClick:u,reconnectRadius:p,onEdgeDoubleClick:h,onReconnectStart:m,onReconnectEnd:g,disableKeyboardA11y:b}){const{edgesFocusable:x,edgesReconnectable:y,elementsSelectable:w,onError:v}=De(WG,Ve),N=DG(t);return f("div",{className:"react-flow__edges",children:[o(BG,{defaultColor:e,rfId:n}),N.map(k=>o(KG,{id:k,edgesFocusable:x,edgesReconnectable:y,elementsSelectable:w,noPanClassName:s,onReconnect:a,onContextMenu:i,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onClick:u,reconnectRadius:p,onDoubleClick:h,onReconnectStart:m,onReconnectEnd:g,rfId:n,onError:v,edgeTypes:r,disableKeyboardA11y:b},k))]})}Cw.displayName="EdgeRenderer";const YG=He(Cw),ZG=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function XG({children:e}){const t=De(ZG);return o("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function JG(e){const t=gu(),n=te(!1);Y(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const eK=e=>e.panZoom?.syncViewport;function tK(e){const t=De(eK),n=qe();return Y(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function nK(e){return e.connection.inProgress?{...e.connection,to:ls(e.connection.to,e.transform)}:{...e.connection}}function rK(e){return nK}function oK(e){const t=rK();return De(t,Ve)}const sK=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function aK({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:a,height:i,isValid:l,inProgress:c}=De(sK,Ve);return!(a&&s&&c)?null:o("svg",{style:e,width:a,height:i,className:"react-flow__connectionline react-flow__container",children:o("g",{className:We(["react-flow__connection",S1(l)]),children:o(Mw,{style:t,type:n,CustomComponent:r,isValid:l})})})}const Mw=({style:e,type:t=En.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:a,fromNode:i,fromHandle:l,fromPosition:c,to:d,toNode:u,toHandle:p,toPosition:h,pointer:m}=oK();if(!s)return;if(n)return o(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:l,fromX:a.x,fromY:a.y,toX:d.x,toY:d.y,fromPosition:c,toPosition:h,connectionStatus:S1(r),toNode:u,toHandle:p,pointer:m});let g="";const b={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:d.x,targetY:d.y,targetPosition:h};switch(t){case En.Bezier:[g]=R1(b);break;case En.SimpleBezier:[g]=fw(b);break;case En.Step:[g]=gc({...b,borderRadius:0});break;case En.SmoothStep:[g]=gc(b);break;default:[g]=B1(b)}return o("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};Mw.displayName="ConnectionLine";const iK={};function _h(e=iK){te(e),qe(),Y(()=>{},[e])}function lK(){qe(),te(!1),Y(()=>{},[])}function Ew({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:a,onEdgeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:u,onSelectionContextMenu:p,onSelectionStart:h,onSelectionEnd:m,connectionLineType:g,connectionLineStyle:b,connectionLineComponent:x,connectionLineContainerStyle:y,selectionKeyCode:w,selectionOnDrag:v,selectionMode:N,multiSelectionKeyCode:k,panActivationKeyCode:C,zoomActivationKeyCode:M,deleteKeyCode:P,onlyRenderVisibleElements:I,elementsSelectable:z,defaultViewport:A,translateExtent:O,minZoom:R,maxZoom:E,preventScrolling:D,defaultMarkerColor:L,zoomOnScroll:T,zoomOnPinch:B,panOnScroll:F,panOnScrollSpeed:j,panOnScrollMode:V,zoomOnDoubleClick:$,panOnDrag:H,onPaneClick:G,onPaneMouseEnter:Z,onPaneMouseMove:oe,onPaneMouseLeave:ne,onPaneScroll:X,onPaneContextMenu:re,paneClickDistance:be,nodeClickDistance:J,onEdgeContextMenu:W,onEdgeMouseEnter:ee,onEdgeMouseMove:ae,onEdgeMouseLeave:fe,reconnectRadius:ge,onReconnect:Q,onReconnectStart:le,onReconnectEnd:ue,noDragClassName:de,noWheelClassName:ce,noPanClassName:Ce,disableKeyboardA11y:pe,nodeExtent:$e,rfId:Ae,viewport:Xe,onViewportChange:ut}){return _h(e),_h(t),lK(),JG(n),tK(Xe),o(kG,{onPaneClick:G,onPaneMouseEnter:Z,onPaneMouseMove:oe,onPaneMouseLeave:ne,onPaneContextMenu:re,onPaneScroll:X,paneClickDistance:be,deleteKeyCode:P,selectionKeyCode:w,selectionOnDrag:v,selectionMode:N,onSelectionStart:h,onSelectionEnd:m,multiSelectionKeyCode:k,panActivationKeyCode:C,zoomActivationKeyCode:M,elementsSelectable:z,zoomOnScroll:T,zoomOnPinch:B,zoomOnDoubleClick:$,panOnScroll:F,panOnScrollSpeed:j,panOnScrollMode:V,panOnDrag:H,defaultViewport:A,translateExtent:O,minZoom:R,maxZoom:E,onSelectionContextMenu:p,preventScrolling:D,noDragClassName:de,noWheelClassName:ce,noPanClassName:Ce,disableKeyboardA11y:pe,onViewportChange:ut,isControlledViewport:!!Xe,children:f(XG,{children:[o(YG,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:i,onReconnect:Q,onReconnectStart:le,onReconnectEnd:ue,onlyRenderVisibleElements:I,onEdgeContextMenu:W,onEdgeMouseEnter:ee,onEdgeMouseMove:ae,onEdgeMouseLeave:fe,reconnectRadius:ge,defaultMarkerColor:L,noPanClassName:Ce,disableKeyboardA11y:pe,rfId:Ae}),o(aK,{style:b,type:g,component:x,containerStyle:y}),o("div",{className:"react-flow__edgelabel-renderer"}),o($G,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:u,nodeClickDistance:J,onlyRenderVisibleElements:I,noPanClassName:Ce,noDragClassName:de,disableKeyboardA11y:pe,nodeExtent:$e,rfId:Ae}),o("div",{className:"react-flow__viewport-portal"})]})})}Ew.displayName="GraphView";const cK=He(Ew),$h=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c=.5,maxZoom:d=2,nodeOrigin:u,nodeExtent:p,zIndexMode:h="basic"}={})=>{const m=new Map,g=new Map,b=new Map,x=new Map,y=r??t??[],w=n??e??[],v=u??[0,0],N=p??zo;j1(b,x,y);const{nodesInitialized:k}=xc(w,m,g,{nodeOrigin:v,nodeExtent:N,zIndexMode:h});let C=[0,0,1];if(i&&s&&a){const M=as(m,{filter:A=>!!((A.width||A.initialWidth)&&(A.height||A.initialHeight))}),{x:P,y:I,zoom:z}=cu(M,s,a,c,d,l?.padding??.1);C=[P,I,z]}return{rfId:"1",width:s??0,height:a??0,transform:C,nodes:w,nodesInitialized:k,nodeLookup:m,parentLookup:g,edges:y,edgeLookup:x,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:d,translateExtent:zo,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Or.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:v,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:{...k1},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:yU,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:N1,zIndexMode:h,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},dK=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:u,nodeExtent:p,zIndexMode:h})=>EQ((m,g)=>{async function b(){const{nodeLookup:x,panZoom:y,fitViewOptions:w,fitViewResolver:v,width:N,height:k,minZoom:C,maxZoom:M}=g();y&&(await bU({nodes:x,width:N,height:k,panZoom:y,minZoom:C,maxZoom:M},w),v?.resolve(!0),m({fitViewResolver:null}))}return{...$h({nodes:e,edges:t,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:u,nodeExtent:p,defaultNodes:n,defaultEdges:r,zIndexMode:h}),setNodes:x=>{const{nodeLookup:y,parentLookup:w,nodeOrigin:v,elevateNodesOnSelect:N,fitViewQueued:k,zIndexMode:C,nodesSelectionActive:M}=g(),{nodesInitialized:P,hasSelectedNodes:I}=xc(x,y,w,{nodeOrigin:v,nodeExtent:p,elevateNodesOnSelect:N,checkEquality:!0,zIndexMode:C}),z=M&&I;k&&P?(b(),m({nodes:x,nodesInitialized:P,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:z})):m({nodes:x,nodesInitialized:P,nodesSelectionActive:z})},setEdges:x=>{const{connectionLookup:y,edgeLookup:w}=g();j1(y,w,x),m({edges:x})},setDefaultNodesAndEdges:(x,y)=>{if(x){const{setNodes:w}=g();w(x),m({hasDefaultNodes:!0})}if(y){const{setEdges:w}=g();w(y),m({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:y,nodeLookup:w,parentLookup:v,domNode:N,nodeOrigin:k,nodeExtent:C,debug:M,fitViewQueued:P,zIndexMode:I}=g(),{changes:z,updatedInternals:A}=jU(x,w,v,N,k,C,I);A&&(OU(w,v,{nodeOrigin:k,nodeExtent:C,zIndexMode:I}),P?(b(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),z?.length>0&&(M&&console.log("React Flow: trigger node changes",z),y?.(z)))},updateNodePositions:(x,y=!1)=>{const w=[];let v=[];const{nodeLookup:N,triggerNodeChanges:k,connection:C,updateConnection:M,onNodesChangeMiddlewareMap:P}=g();for(const[I,z]of x){const A=N.get(I),O=!!(A?.expandParent&&A?.parentId&&z?.position),R={id:I,type:"position",position:O?{x:Math.max(0,z.position.x),y:Math.max(0,z.position.y)}:z.position,dragging:y};if(A&&C.inProgress&&C.fromNode.id===A.id){const E=cr(A,C.fromHandle,we.Left,!0);M({...C,from:E})}O&&A.parentId&&w.push({id:I,parentId:A.parentId,rect:{...z.internals.positionAbsolute,width:z.measured.width??0,height:z.measured.height??0}}),v.push(R)}if(w.length>0){const{parentLookup:I,nodeOrigin:z}=g(),A=mu(w,N,I,z);v.push(...A)}for(const I of P.values())v=I(v);k(v)},triggerNodeChanges:x=>{const{onNodesChange:y,setNodes:w,nodes:v,hasDefaultNodes:N,debug:k}=g();if(x?.length){if(N){const C=KQ(x,v);w(C)}k&&console.log("React Flow: trigger node changes",x),y?.(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:y,setEdges:w,edges:v,hasDefaultEdges:N,debug:k}=g();if(x?.length){if(N){const C=WQ(x,v);w(C)}k&&console.log("React Flow: trigger edge changes",x),y?.(x)}},addSelectedNodes:x=>{const{multiSelectionActive:y,edgeLookup:w,nodeLookup:v,triggerNodeChanges:N,triggerEdgeChanges:k}=g();if(y){const C=x.map(M=>Un(M,!0));N(C);return}N(Mr(v,new Set([...x]),!0)),k(Mr(w))},addSelectedEdges:x=>{const{multiSelectionActive:y,edgeLookup:w,nodeLookup:v,triggerNodeChanges:N,triggerEdgeChanges:k}=g();if(y){const C=x.map(M=>Un(M,!0));k(C);return}k(Mr(w,new Set([...x]))),N(Mr(v,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:y}={})=>{const{edges:w,nodes:v,nodeLookup:N,triggerNodeChanges:k,triggerEdgeChanges:C}=g(),M=x||v,P=y||w,I=[];for(const A of M){if(!A.selected)continue;const O=N.get(A.id);O&&(O.selected=!1),I.push(Un(A.id,!1))}const z=[];for(const A of P)A.selected&&z.push(Un(A.id,!1));k(I),C(z)},setMinZoom:x=>{const{panZoom:y,maxZoom:w}=g();y?.setScaleExtent([x,w]),m({minZoom:x})},setMaxZoom:x=>{const{panZoom:y,minZoom:w}=g();y?.setScaleExtent([w,x]),m({maxZoom:x})},setTranslateExtent:x=>{g().panZoom?.setTranslateExtent(x),m({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:y,triggerNodeChanges:w,triggerEdgeChanges:v,elementsSelectable:N}=g();if(!N)return;const k=y.reduce((M,P)=>P.selected?[...M,Un(P.id,!1)]:M,[]),C=x.reduce((M,P)=>P.selected?[...M,Un(P.id,!1)]:M,[]);w(k),v(C)},setNodeExtent:x=>{const{nodes:y,nodeLookup:w,parentLookup:v,nodeOrigin:N,elevateNodesOnSelect:k,nodeExtent:C,zIndexMode:M}=g();x[0][0]===C[0][0]&&x[0][1]===C[0][1]&&x[1][0]===C[1][0]&&x[1][1]===C[1][1]||(xc(y,w,v,{nodeOrigin:N,nodeExtent:x,elevateNodesOnSelect:k,checkEquality:!1,zIndexMode:M}),m({nodeExtent:x}))},panBy:x=>{const{transform:y,width:w,height:v,panZoom:N,translateExtent:k}=g();return VU({delta:x,panZoom:N,transform:y,translateExtent:k,width:w,height:v})},setCenter:async(x,y,w)=>{const{width:v,height:N,maxZoom:k,panZoom:C}=g();if(!C)return Promise.resolve(!1);const M=typeof w?.zoom<"u"?w.zoom:k;return await C.setViewport({x:v/2-x*M,y:N/2-y*M,zoom:M},{duration:w?.duration,ease:w?.ease,interpolate:w?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{m({connection:{...k1}})},updateConnection:x=>{m({connection:x})},reset:()=>m({...$h()})}},Object.is);function uK({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:a,initialMinZoom:i,initialMaxZoom:l,initialFitViewOptions:c,fitView:d,nodeOrigin:u,nodeExtent:p,zIndexMode:h,children:m}){const[g]=_(()=>dK({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:a,fitView:d,minZoom:i,maxZoom:l,fitViewOptions:c,nodeOrigin:u,nodeExtent:p,zIndexMode:h}));return o(IQ,{value:g,children:o(XQ,{children:m})})}function pK({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:a,height:i,fitView:l,fitViewOptions:c,minZoom:d,maxZoom:u,nodeOrigin:p,nodeExtent:h,zIndexMode:m}){return ve(mi)?o(he,{children:e}):o(uK,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:a,initialHeight:i,fitView:l,initialFitViewOptions:c,initialMinZoom:d,initialMaxZoom:u,nodeOrigin:p,nodeExtent:h,zIndexMode:m,children:e})}const fK={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function hK({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:a,edgeTypes:i,onNodeClick:l,onEdgeClick:c,onInit:d,onMove:u,onMoveStart:p,onMoveEnd:h,onConnect:m,onConnectStart:g,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:y,onNodeMouseEnter:w,onNodeMouseMove:v,onNodeMouseLeave:N,onNodeContextMenu:k,onNodeDoubleClick:C,onNodeDragStart:M,onNodeDrag:P,onNodeDragStop:I,onNodesDelete:z,onEdgesDelete:A,onDelete:O,onSelectionChange:R,onSelectionDragStart:E,onSelectionDrag:D,onSelectionDragStop:L,onSelectionContextMenu:T,onSelectionStart:B,onSelectionEnd:F,onBeforeDelete:j,connectionMode:V,connectionLineType:$=En.Bezier,connectionLineStyle:H,connectionLineComponent:G,connectionLineContainerStyle:Z,deleteKeyCode:oe="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:X=!1,selectionMode:re=Fo.Full,panActivationKeyCode:be="Space",multiSelectionKeyCode:J=Vo()?"Meta":"Control",zoomActivationKeyCode:W=Vo()?"Meta":"Control",snapToGrid:ee,snapGrid:ae,onlyRenderVisibleElements:fe=!1,selectNodesOnDrag:ge,nodesDraggable:Q,autoPanOnNodeFocus:le,nodesConnectable:ue,nodesFocusable:de,nodeOrigin:ce=nw,edgesFocusable:Ce,edgesReconnectable:pe,elementsSelectable:$e=!0,defaultViewport:Ae=jQ,minZoom:Xe=.5,maxZoom:ut=2,translateExtent:yr=zo,preventScrolling:me=!0,nodeExtent:_e,defaultMarkerColor:Oe="#b1b1b7",zoomOnScroll:Be=!0,zoomOnPinch:zn=!0,panOnScroll:Fn=!1,panOnScrollSpeed:ro=.5,panOnScrollMode:oN=Zn.Free,zoomOnDoubleClick:sN=!0,panOnDrag:aN=!0,onPaneClick:iN,onPaneMouseEnter:lN,onPaneMouseMove:cN,onPaneMouseLeave:dN,onPaneScroll:uN,onPaneContextMenu:pN,paneClickDistance:fN=1,nodeClickDistance:hN=0,children:mN,onReconnect:gN,onReconnectStart:bN,onReconnectEnd:xN,onEdgeContextMenu:yN,onEdgeDoubleClick:vN,onEdgeMouseEnter:wN,onEdgeMouseMove:NN,onEdgeMouseLeave:kN,reconnectRadius:SN=10,onNodesChange:CN,onEdgesChange:MN,noDragClassName:EN="nodrag",noWheelClassName:IN="nowheel",noPanClassName:ku="nopan",fitView:Su,fitViewOptions:Cu,connectOnClick:AN,attributionPosition:PN,proOptions:_N,defaultEdgeOptions:$N,elevateNodesOnSelect:DN=!0,elevateEdgesOnSelect:LN=!1,disableKeyboardA11y:Mu=!1,autoPanOnConnect:TN,autoPanOnNodeDrag:RN,autoPanSpeed:ON,connectionRadius:BN,isValidConnection:zN,onError:FN,style:jN,id:Eu,nodeDragThreshold:VN,connectionDragThreshold:HN,viewport:qN,onViewportChange:UN,width:QN,height:GN,colorMode:KN="light",debug:WN,onScroll:Iu,ariaLabelConfig:YN,zIndexMode:Au="basic",...ZN},XN){const wi=Eu||"1",JN=UQ(KN),e2=U(Pu=>{Pu.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Iu?.(Pu)},[Iu]);return o("div",{"data-testid":"rf__wrapper",...ZN,onScroll:e2,style:{...jN,...fK},ref:XN,className:We(["react-flow",s,JN]),id:Eu,role:"application",children:f(pK,{nodes:e,edges:t,width:QN,height:GN,fitView:Su,fitViewOptions:Cu,minZoom:Xe,maxZoom:ut,nodeOrigin:ce,nodeExtent:_e,zIndexMode:Au,children:[o(qQ,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:g,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:y,nodesDraggable:Q,autoPanOnNodeFocus:le,nodesConnectable:ue,nodesFocusable:de,edgesFocusable:Ce,edgesReconnectable:pe,elementsSelectable:$e,elevateNodesOnSelect:DN,elevateEdgesOnSelect:LN,minZoom:Xe,maxZoom:ut,nodeExtent:_e,onNodesChange:CN,onEdgesChange:MN,snapToGrid:ee,snapGrid:ae,connectionMode:V,translateExtent:yr,connectOnClick:AN,defaultEdgeOptions:$N,fitView:Su,fitViewOptions:Cu,onNodesDelete:z,onEdgesDelete:A,onDelete:O,onNodeDragStart:M,onNodeDrag:P,onNodeDragStop:I,onSelectionDrag:D,onSelectionDragStart:E,onSelectionDragStop:L,onMove:u,onMoveStart:p,onMoveEnd:h,noPanClassName:ku,nodeOrigin:ce,rfId:wi,autoPanOnConnect:TN,autoPanOnNodeDrag:RN,autoPanSpeed:ON,onError:FN,connectionRadius:BN,isValidConnection:zN,selectNodesOnDrag:ge,nodeDragThreshold:VN,connectionDragThreshold:HN,onBeforeDelete:j,debug:WN,ariaLabelConfig:YN,zIndexMode:Au}),o(cK,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:w,onNodeMouseMove:v,onNodeMouseLeave:N,onNodeContextMenu:k,onNodeDoubleClick:C,nodeTypes:a,edgeTypes:i,connectionLineType:$,connectionLineStyle:H,connectionLineComponent:G,connectionLineContainerStyle:Z,selectionKeyCode:ne,selectionOnDrag:X,selectionMode:re,deleteKeyCode:oe,multiSelectionKeyCode:J,panActivationKeyCode:be,zoomActivationKeyCode:W,onlyRenderVisibleElements:fe,defaultViewport:Ae,translateExtent:yr,minZoom:Xe,maxZoom:ut,preventScrolling:me,zoomOnScroll:Be,zoomOnPinch:zn,zoomOnDoubleClick:sN,panOnScroll:Fn,panOnScrollSpeed:ro,panOnScrollMode:oN,panOnDrag:aN,onPaneClick:iN,onPaneMouseEnter:lN,onPaneMouseMove:cN,onPaneMouseLeave:dN,onPaneScroll:uN,onPaneContextMenu:pN,paneClickDistance:fN,nodeClickDistance:hN,onSelectionContextMenu:T,onSelectionStart:B,onSelectionEnd:F,onReconnect:gN,onReconnectStart:bN,onReconnectEnd:xN,onEdgeContextMenu:yN,onEdgeDoubleClick:vN,onEdgeMouseEnter:wN,onEdgeMouseMove:NN,onEdgeMouseLeave:kN,reconnectRadius:SN,defaultMarkerColor:Oe,noDragClassName:EN,noWheelClassName:IN,noPanClassName:ku,rfId:wi,disableKeyboardA11y:Mu,nodeExtent:_e,viewport:qN,onViewportChange:UN}),o(FQ,{onSelectionChange:R}),mN,o(TQ,{proOptions:_N,position:PN}),o(LQ,{rfId:wi,disableKeyboardA11y:Mu})]})})}var mK=ow(hK);function gK({dimensions:e,lineWidth:t,variant:n,className:r}){return o("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:We(["react-flow__background-pattern",n,r])})}function bK({radius:e,className:t}){return o("circle",{cx:e,cy:e,r:e,className:We(["react-flow__background-pattern","dots",t])})}var Pn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Pn||(Pn={}));const xK={[Pn.Dots]:1,[Pn.Lines]:1,[Pn.Cross]:6},yK=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Iw({id:e,variant:t=Pn.Dots,gap:n=20,size:r,lineWidth:s=1,offset:a=0,color:i,bgColor:l,style:c,className:d,patternClassName:u}){const p=te(null),{transform:h,patternId:m}=De(yK,Ve),g=r||xK[t],b=t===Pn.Dots,x=t===Pn.Cross,y=Array.isArray(n)?n:[n,n],w=[y[0]*h[2]||1,y[1]*h[2]||1],v=g*h[2],N=Array.isArray(a)?a:[a,a],k=x?[v,v]:w,C=[N[0]*h[2]||1+k[0]/2,N[1]*h[2]||1+k[1]/2],M=`${m}${e||""}`;return f("svg",{className:We(["react-flow__background",d]),style:{...c,...bi,"--xy-background-color-props":l,"--xy-background-pattern-color-props":i},ref:p,"data-testid":"rf__background",children:[o("pattern",{id:M,x:h[0]%w[0],y:h[1]%w[1],width:w[0],height:w[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`,children:b?o(bK,{radius:v/2,className:u}):o(gK,{dimensions:k,lineWidth:s,variant:t,className:u})}),o("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}Iw.displayName="Background";const vK=He(Iw);function wK(){return o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:o("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function NK(){return o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:o("path",{d:"M0 0h32v4.2H0z"})})}function kK(){return o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:o("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 SK(){return o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o("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 CK(){return o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o("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 zs({children:e,className:t,...n}){return o("button",{type:"button",className:We(["react-flow__controls-button",t]),...n,children:e})}const MK=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Aw({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:a,onZoomOut:i,onFitView:l,onInteractiveChange:c,className:d,children:u,position:p="bottom-left",orientation:h="vertical","aria-label":m}){const g=qe(),{isInteractive:b,minZoomReached:x,maxZoomReached:y,ariaLabelConfig:w}=De(MK,Ve),{zoomIn:v,zoomOut:N,fitView:k}=gu(),C=()=>{v(),a?.()},M=()=>{N(),i?.()},P=()=>{k(s),l?.()},I=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),c?.(!b)};return f(gi,{className:We(["react-flow__controls",h==="horizontal"?"horizontal":"vertical",d]),position:p,style:e,"data-testid":"rf__controls","aria-label":m??w["controls.ariaLabel"],children:[t&&f(he,{children:[o(zs,{onClick:C,className:"react-flow__controls-zoomin",title:w["controls.zoomIn.ariaLabel"],"aria-label":w["controls.zoomIn.ariaLabel"],disabled:y,children:o(wK,{})}),o(zs,{onClick:M,className:"react-flow__controls-zoomout",title:w["controls.zoomOut.ariaLabel"],"aria-label":w["controls.zoomOut.ariaLabel"],disabled:x,children:o(NK,{})})]}),n&&o(zs,{className:"react-flow__controls-fitview",onClick:P,title:w["controls.fitView.ariaLabel"],"aria-label":w["controls.fitView.ariaLabel"],children:o(kK,{})}),r&&o(zs,{className:"react-flow__controls-interactive",onClick:I,title:w["controls.interactive.ariaLabel"],"aria-label":w["controls.interactive.ariaLabel"],children:b?o(CK,{}):o(SK,{})}),u]})}Aw.displayName="Controls";const EK=He(Aw);function IK({id:e,x:t,y:n,width:r,height:s,style:a,color:i,strokeColor:l,strokeWidth:c,className:d,borderRadius:u,shapeRendering:p,selected:h,onClick:m}){const{background:g,backgroundColor:b}=a||{},x=i||g||b;return o("rect",{className:We(["react-flow__minimap-node",{selected:h},d]),x:t,y:n,rx:u,ry:u,width:r,height:s,style:{fill:x,stroke:l,strokeWidth:c},shapeRendering:p,onClick:m?y=>m(y,e):void 0})}const AK=He(IK),PK=e=>e.nodes.map(t=>t.id),bl=e=>e instanceof Function?e:()=>e;function _K({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:a=AK,onClick:i}){const l=De(PK,Ve),c=bl(t),d=bl(e),u=bl(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return o(he,{children:l.map(h=>o(DK,{id:h,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:a,onClick:i,shapeRendering:p},h))})}function $K({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:a,shapeRendering:i,NodeComponent:l,onClick:c}){const{node:d,x:u,y:p,width:h,height:m}=De(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:y,y:w}=b.internals.positionAbsolute,{width:v,height:N}=Nn(x);return{node:x,x:y,y:w,width:v,height:N}},Ve);return!d||d.hidden||!P1(d)?null:o(l,{x:u,y:p,width:h,height:m,style:d.style,selected:!!d.selected,className:r(d),color:t(d),borderRadius:s,strokeColor:n(d),strokeWidth:a,shapeRendering:i,onClick:c,id:d.id})}const DK=He($K);var LK=He(_K);const TK=200,RK=150,OK=e=>!e.hidden,BK=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?A1(as(e.nodeLookup,{filter:OK}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},zK="react-flow__minimap-desc";function Pw({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:a=5,nodeStrokeWidth:i,nodeComponent:l,bgColor:c,maskColor:d,maskStrokeColor:u,maskStrokeWidth:p,position:h="bottom-right",onClick:m,onNodeClick:g,pannable:b=!1,zoomable:x=!1,ariaLabel:y,inversePan:w,zoomStep:v=1,offsetScale:N=5}){const k=qe(),C=te(null),{boundingRect:M,viewBB:P,rfId:I,panZoom:z,translateExtent:A,flowWidth:O,flowHeight:R,ariaLabelConfig:E}=De(BK,Ve),D=e?.width??TK,L=e?.height??RK,T=M.width/D,B=M.height/L,F=Math.max(T,B),j=F*D,V=F*L,$=N*F,H=M.x-(j-M.width)/2-$,G=M.y-(V-M.height)/2-$,Z=j+$*2,oe=V+$*2,ne=`${zK}-${I}`,X=te(0),re=te();X.current=F,Y(()=>{if(C.current&&z)return re.current=ZU({domNode:C.current,panZoom:z,getTransform:()=>k.getState().transform,getViewScale:()=>X.current}),()=>{re.current?.destroy()}},[z]),Y(()=>{re.current?.update({translateExtent:A,width:O,height:R,inversePan:w,pannable:b,zoomStep:v,zoomable:x})},[b,x,w,v,A,O,R]);const be=m?ee=>{const[ae,fe]=re.current?.pointer(ee)||[0,0];m(ee,{x:ae,y:fe})}:void 0,J=g?U((ee,ae)=>{const fe=k.getState().nodeLookup.get(ae).internals.userNode;g(ee,fe)},[]):void 0,W=y??E["minimap.ariaLabel"];return o(gi,{position:h,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 u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*F:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r: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:We(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:f("svg",{width:D,height:L,viewBox:`${H} ${G} ${Z} ${oe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:C,onClick:be,children:[W&&o("title",{id:ne,children:W}),o(LK,{onClick:J,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:s,nodeStrokeWidth:i,nodeComponent:l}),o("path",{className:"react-flow__minimap-mask",d:`M${H-$},${G-$}h${Z+$*2}v${oe+$*2}h${-Z-$*2}z
|
|
1156
|
+
M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Pw.displayName="MiniMap";He(Pw);const FK=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,jK={[jr.Line]:"right",[jr.Handle]:"bottom-right"};function VK({nodeId:e,position:t,variant:n=jr.Handle,className:r,style:s=void 0,children:a,color:i,minWidth:l=10,minHeight:c=10,maxWidth:d=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:h,autoScale:m=!0,shouldResize:g,onResizeStart:b,onResize:x,onResizeEnd:y}){const w=lw(),v=typeof e=="string"?e:w,N=qe(),k=te(null),C=n===jr.Handle,M=De(U(FK(C&&m),[C,m]),Ve),P=te(null),I=t??jK[n];Y(()=>{if(!(!k.current||!v))return P.current||(P.current=uQ({domNode:k.current,nodeId:v,getStoreItems:()=>{const{nodeLookup:A,transform:O,snapGrid:R,snapToGrid:E,nodeOrigin:D,domNode:L}=N.getState();return{nodeLookup:A,transform:O,snapGrid:R,snapToGrid:E,nodeOrigin:D,paneDomNode:L}},onChange:(A,O)=>{const{triggerNodeChanges:R,nodeLookup:E,parentLookup:D,nodeOrigin:L}=N.getState(),T=[],B={x:A.x,y:A.y},F=E.get(v);if(F&&F.expandParent&&F.parentId){const j=F.origin??L,V=A.width??F.measured.width??0,$=A.height??F.measured.height??0,H={id:F.id,parentId:F.parentId,rect:{width:V,height:$,..._1({x:A.x??F.position.x,y:A.y??F.position.y},{width:V,height:$},F.parentId,E,j)}},G=mu([H],E,D,L);T.push(...G),B.x=A.x?Math.max(j[0]*V,A.x):void 0,B.y=A.y?Math.max(j[1]*$,A.y):void 0}if(B.x!==void 0&&B.y!==void 0){const j={id:v,type:"position",position:{...B}};T.push(j)}if(A.width!==void 0&&A.height!==void 0){const V={id:v,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:A.width,height:A.height}};T.push(V)}for(const j of O){const V={...j,type:"position"};T.push(V)}R(T)},onEnd:({width:A,height:O})=>{const R={id:v,type:"dimensions",resizing:!1,dimensions:{width:A,height:O}};N.getState().triggerNodeChanges([R])}})),P.current.update({controlPosition:I,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:u},keepAspectRatio:p,resizeDirection:h,onResizeStart:b,onResize:x,onResizeEnd:y,shouldResize:g}),()=>{P.current?.destroy()}},[I,l,c,d,u,p,b,x,y,g]);const z=I.split("-");return o("div",{className:We(["react-flow__resize-control","nodrag",...z,n,r]),ref:k,style:{...s,scale:M,...i&&{[C?"backgroundColor":"borderColor"]:i}},children:a})}He(VK);var _w=Object.defineProperty,HK=(e,t,n)=>t in e?_w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qK=(e,t)=>{for(var n in t)_w(e,n,{get:t[n],enumerable:!0})},UK=(e,t,n)=>HK(e,t+"",n),$w={};qK($w,{Graph:()=>$t,alg:()=>xu,json:()=>Lw,version:()=>KK});var QK=Object.defineProperty,Dw=(e,t)=>{for(var n in t)QK(e,n,{get:t[n],enumerable:!0})},$t=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(n=>{t!==void 0?this.setNode(n,t):this.setNode(n)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=n=>this.removeEdge(this._edgeObjs[n]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(n=>{this.setParent(n)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t);for(let r of this.successors(e))n.add(r);return Array.from(n.values())}}isLeaf(e){let t;return this.isDirected()?t=this.successors(e):t=this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([s,a])=>{e(s)&&t.setNode(s,a)}),Object.values(this._edgeObjs).forEach(s=>{t.hasNode(s.v)&&t.hasNode(s.w)&&t.setEdge(s,this.edge(s))});let n={},r=s=>{let a=this.parent(s);return!a||t.hasNode(a)?(n[s]=a??void 0,a??void 0):a in n?n[a]:r(a)};return this._isCompound&&t.nodes().forEach(s=>t.setParent(s,r(s))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((n,r)=>(t!==void 0?this.setEdge(n,r,t):this.setEdge(n,r),r)),this}setEdge(e,t,n,r){let s,a,i,l,c=!1;typeof e=="object"&&e!==null&&"v"in e?(s=e.v,a=e.w,i=e.name,arguments.length===2&&(l=t,c=!0)):(s=e,a=t,i=r,arguments.length>2&&(l=n,c=!0)),s=""+s,a=""+a,i!==void 0&&(i=""+i);let d=go(this._isDirected,s,a,i);if(d in this._edgeLabels)return c&&(this._edgeLabels[d]=l),this;if(i!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(s),this.setNode(a),this._edgeLabels[d]=c?l:this._defaultEdgeLabelFn(s,a,i);let u=GK(this._isDirected,s,a,i);return s=u.v,a=u.w,Object.freeze(u),this._edgeObjs[d]=u,Dh(this._preds[a],s),Dh(this._sucs[s],a),this._in[a][d]=u,this._out[s][d]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?xl(this._isDirected,e):go(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!="object"?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?xl(this._isDirected,e):go(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?xl(this._isDirected,e):go(this._isDirected,e,t,n),s=this._edgeObjs[r];if(s){let a=s.v,i=s.w;delete this._edgeLabels[r],delete this._edgeObjs[r],Lh(this._preds[i],a),Lh(this._sucs[a],i),delete this._in[i][r],delete this._out[a][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(s=>s.v===t&&s.w===n||s.v===n&&s.w===t):r}};function Dh(e,t){e[t]?e[t]++:e[t]=1}function Lh(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function go(e,t,n,r){let s=""+t,a=""+n;if(!e&&s>a){let i=s;s=a,a=i}return s+""+a+""+(r===void 0?"\0":r)}function GK(e,t,n,r){let s=""+t,a=""+n;if(!e&&s>a){let l=s;s=a,a=l}let i={v:s,w:a};return r&&(i.name=r),i}function xl(e,t){return go(e,t.v,t.w,t.name)}var KK="4.0.1",Lw={};Dw(Lw,{read:()=>XK,write:()=>WK});function WK(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:YK(e),edges:ZK(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function YK(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),s={v:t};return n!==void 0&&(s.value=n),r!==void 0&&(s.parent=r),s})}function ZK(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function XK(e){let t=new $t(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var xu={};Dw(xu,{CycleException:()=>Ma,bellmanFord:()=>Tw,components:()=>tW,dijkstra:()=>Ca,dijkstraAll:()=>oW,findCycles:()=>sW,floydWarshall:()=>iW,isAcyclic:()=>cW,postorder:()=>uW,preorder:()=>pW,prim:()=>fW,shortestPaths:()=>hW,tarjan:()=>Ow,topsort:()=>Bw});var JK=()=>1;function Tw(e,t,n,r){return eW(e,String(t),n||JK,r||function(s){return e.outEdges(s)})}function eW(e,t,n,r){let s={},a,i=0,l=e.nodes(),c=function(p){let h=n(p);s[p.v].distance+h<s[p.w].distance&&(s[p.w]={distance:s[p.v].distance+h,predecessor:p.v},a=!0)},d=function(){l.forEach(function(p){r(p).forEach(function(h){let m=h.v===p?h.v:h.w,g=m===h.v?h.w:h.v;c({v:m,w:g})})})};l.forEach(function(p){let h=p===t?0:Number.POSITIVE_INFINITY;s[p]={distance:h,predecessor:""}});let u=l.length;for(let p=1;p<u&&(a=!1,i++,d(),!!a);p++);if(i===u-1&&(a=!1,d(),a))throw new Error("The graph contains a negative weight cycle");return s}function tW(e){let t={},n=[],r;function s(a){a in t||(t[a]=!0,r.push(a),e.successors(a).forEach(s),e.predecessors(a).forEach(s))}return e.nodes().forEach(function(a){r=[],s(a),r.length&&n.push(r)}),n}var Rw=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let s=this._arr,a=s.length;return n[r]=a,s.push({key:r,priority:t}),this._decrease(a),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,s=e;n<t.length&&(s=t[n].priority<t[s].priority?n:s,r<t.length&&(s=t[r].priority<t[s].priority?r:s),s!==e&&(this._swap(e,s),this._heapify(s)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,s=n[e],a=n[t];n[e]=a,n[t]=s,r[a.key]=e,r[s.key]=t}},nW=()=>1;function Ca(e,t,n,r){let s=function(a){return e.outEdges(a)};return rW(e,String(t),n||nW,r||s)}function rW(e,t,n,r){let s={},a=new Rw,i,l,c=function(d){let u=d.v!==i?d.v:d.w,p=s[u],h=n(d),m=l.distance+h;if(h<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+d+" Weight: "+h);m<p.distance&&(p.distance=m,p.predecessor=i,a.decrease(u,m))};for(e.nodes().forEach(function(d){let u=d===t?0:Number.POSITIVE_INFINITY;s[d]={distance:u,predecessor:""},a.add(d,u)});a.size()>0&&(i=a.removeMin(),l=s[i],l.distance!==Number.POSITIVE_INFINITY);)r(i).forEach(c);return s}function oW(e,t,n){return e.nodes().reduce(function(r,s){return r[s]=Ca(e,s,t,n),r},{})}function Ow(e){let t=0,n=[],r={},s=[];function a(i){let l=r[i]={onStack:!0,lowlink:t,index:t++};if(n.push(i),e.successors(i).forEach(function(c){c in r?r[c].onStack&&(l.lowlink=Math.min(l.lowlink,r[c].index)):(a(c),l.lowlink=Math.min(l.lowlink,r[c].lowlink))}),l.lowlink===l.index){let c=[],d;do d=n.pop(),r[d].onStack=!1,c.push(d);while(i!==d);s.push(c)}}return e.nodes().forEach(function(i){i in r||a(i)}),s}function sW(e){return Ow(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var aW=()=>1;function iW(e,t,n){return lW(e,t||aW,n||function(r){return e.outEdges(r)})}function lW(e,t,n){let r={},s=e.nodes();return s.forEach(function(a){r[a]={},r[a][a]={distance:0,predecessor:""},s.forEach(function(i){a!==i&&(r[a][i]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(a).forEach(function(i){let l=i.v===a?i.w:i.v,c=t(i);r[a][l]={distance:c,predecessor:a}})}),s.forEach(function(a){let i=r[a];s.forEach(function(l){let c=r[l];s.forEach(function(d){let u=c[a],p=i[d],h=c[d],m=u.distance+p.distance;m<h.distance&&(h.distance=m,h.predecessor=p.predecessor)})})}),r}var Ma=class extends Error{constructor(...e){super(...e)}};function Bw(e){let t={},n={},r=[];function s(a){if(a in n)throw new Ma;a in t||(n[a]=!0,t[a]=!0,e.predecessors(a).forEach(s),delete n[a],r.push(a))}if(e.sinks().forEach(s),Object.keys(t).length!==e.nodeCount())throw new Ma;return r}function cW(e){try{Bw(e)}catch(t){if(t instanceof Ma)return!1;throw t}return!0}function dW(e,t,n,r,s){Array.isArray(t)||(t=[t]);let a=(l=>{var c;return(c=e.isDirected()?e.successors(l):e.neighbors(l))!=null?c:[]}),i={};return t.forEach(function(l){if(!e.hasNode(l))throw new Error("Graph does not have node: "+l);s=zw(e,l,n==="post",i,a,r,s)}),s}function zw(e,t,n,r,s,a,i){return t in r||(r[t]=!0,n||(i=a(i,t)),s(t).forEach(function(l){i=zw(e,l,n,r,s,a,i)}),n&&(i=a(i,t))),i}function Fw(e,t,n){return dW(e,t,n,function(r,s){return r.push(s),r},[])}function uW(e,t){return Fw(e,t,"post")}function pW(e,t){return Fw(e,t,"pre")}function fW(e,t){let n=new $t,r={},s=new Rw,a;function i(c){let d=c.v===a?c.w:c.v,u=s.priority(d);if(u!==void 0){let p=t(c);p<u&&(r[d]=a,s.decrease(d,p))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(c){s.add(c,Number.POSITIVE_INFINITY),n.setNode(c)}),s.decrease(e.nodes()[0],0);let l=!1;for(;s.size()>0;){if(a=s.removeMin(),a in r)n.setEdge(a,r[a]);else{if(l)throw new Error("Input graph is not connected: "+e);l=!0}e.nodeEdges(a).forEach(i)}return n}function hW(e,t,n,r){return mW(e,t,n,r??(s=>{let a=e.outEdges(s);return a??[]}))}function mW(e,t,n,r){if(n===void 0)return Ca(e,t,n,r);let s=!1,a=e.nodes();for(let i=0;i<a.length;i++){let l=r(a[i]);for(let c=0;c<l.length;c++){let d=l[c],u=d.v===a[i]?d.v:d.w,p=u===d.v?d.w:d.v;n({v:u,w:p})<0&&(s=!0)}if(s)return Tw(e,t,n,r)}return Ca(e,t,n,r)}function no(e,t,n,r){let s=r;for(;e.hasNode(s);)s=yu(r);return n.dummy=t,e.setNode(s,n),s}function gW(e){let t=new $t().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},s=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+s.weight,minlen:Math.max(r.minlen,s.minlen)})}),t}function jw(e){let t=new $t({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function Th(e,t){let n=e.x,r=e.y,s=t.x-n,a=t.y-r,i=e.width/2,l=e.height/2;if(!s&&!a)throw new Error("Not possible to find intersection inside of the rectangle");let c,d;return Math.abs(a)*i>Math.abs(s)*l?(a<0&&(l=-l),c=l*s/a,d=l):(s<0&&(i=-i),c=i,d=i*a/s),{x:n+c,y:r+d}}function cs(e){let t=qo(Hw(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),s=r.rank;s!==void 0&&(t[s]||(t[s]=[]),t[s][r.order]=n)}),t}function bW(e){let t=e.nodes().map(r=>{let s=e.node(r).rank;return s===void 0?Number.MAX_VALUE:s}),n=Zt(Math.min,t);e.nodes().forEach(r=>{let s=e.node(r);Object.hasOwn(s,"rank")&&(s.rank-=n)})}function xW(e){let t=e.nodes().map(i=>e.node(i).rank).filter(i=>i!==void 0),n=Zt(Math.min,t),r=[];e.nodes().forEach(i=>{let l=e.node(i).rank-n;r[l]||(r[l]=[]),r[l].push(i)});let s=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((i,l)=>{i===void 0&&l%a!==0?--s:i!==void 0&&s&&i.forEach(c=>e.node(c).rank+=s)})}function Rh(e,t,n,r){let s={width:0,height:0};return arguments.length>=4&&(s.rank=n,s.order=r),no(e,"border",s,t)}function yW(e,t=Vw){let n=[];for(let r=0;r<e.length;r+=t){let s=e.slice(r,r+t);n.push(s)}return n}var Vw=65535;function Zt(e,t){if(t.length>Vw){let n=yW(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function Hw(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return Zt(Math.max,t)}function vW(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function qw(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function Uw(e,t){return t()}var wW=0;function yu(e){let t=++wW;return e+(""+t)}function qo(e,t,n=1){t==null&&(t=e,e=0);let r=a=>a<t;n<0&&(r=a=>t<a);let s=[];for(let a=e;r(a);a+=n)s.push(a);return s}function Ea(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function yi(e,t){let n;return typeof t=="string"?n=r=>r[t]:n=t,Object.entries(e).reduce((r,[s,a])=>(r[s]=n(a,s),r),{})}function NW(e,t){return e.reduce((n,r,s)=>(n[r]=t[s],n),{})}var vi="\0",kW="3.0.0",SW=class{constructor(){UK(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Oh(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Oh(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,CW)),n=n._prev;return"["+e.join(", ")+"]"}};function Oh(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function CW(e,t){if(e!=="_next"&&e!=="_prev")return t}var MW=SW,EW=()=>1;function IW(e,t){if(e.nodeCount()<=1)return[];let n=PW(e,t||EW);return AW(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function AW(e,t,n){var r;let s=[],a=t[t.length-1],i=t[0],l;for(;e.nodeCount();){for(;l=i.dequeue();)yl(e,t,n,l);for(;l=a.dequeue();)yl(e,t,n,l);if(e.nodeCount()){for(let c=t.length-2;c>0;--c)if(l=(r=t[c])==null?void 0:r.dequeue(),l){s=s.concat(yl(e,t,n,l,!0)||[]);break}}}return s}function yl(e,t,n,r,s){let a=[],i=s?a:void 0;return(e.inEdges(r.v)||[]).forEach(l=>{let c=e.edge(l),d=e.node(l.v);s&&a.push({v:l.v,w:l.w}),d.out-=c,Nc(t,n,d)}),(e.outEdges(r.v)||[]).forEach(l=>{let c=e.edge(l),d=l.w,u=e.node(d);u.in-=c,Nc(t,n,u)}),e.removeNode(r.v),i}function PW(e,t){let n=new $t,r=0,s=0;e.nodes().forEach(l=>{n.setNode(l,{v:l,in:0,out:0})}),e.edges().forEach(l=>{let c=n.edge(l.v,l.w)||0,d=t(l),u=c+d;n.setEdge(l.v,l.w,u);let p=n.node(l.v),h=n.node(l.w);s=Math.max(s,p.out+=d),r=Math.max(r,h.in+=d)});let a=_W(s+r+3).map(()=>new MW),i=r+1;return n.nodes().forEach(l=>{Nc(a,i,n.node(l))}),{graph:n,buckets:a,zeroIdx:i}}function Nc(e,t,n){var r,s,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(s=e[e.length-1])==null||s.enqueue(n):(r=e[0])==null||r.enqueue(n)}function _W(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function $W(e){(e.graph().acyclicer==="greedy"?IW(e,t(e)):DW(e)).forEach(n=>{let r=e.edge(n);e.removeEdge(n),r.forwardName=n.name,r.reversed=!0,e.setEdge(n.w,n.v,r,yu("rev"))});function t(n){return r=>n.edge(r).weight}}function DW(e){let t=[],n={},r={};function s(a){Object.hasOwn(r,a)||(r[a]=!0,n[a]=!0,e.outEdges(a).forEach(i=>{Object.hasOwn(n,i.w)?t.push(i):s(i.w)}),delete n[a])}return e.nodes().forEach(s),t}function LW(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function TW(e){e.graph().dummyChains=[],e.edges().forEach(t=>RW(e,t))}function RW(e,t){let n=t.v,r=e.node(n).rank,s=t.w,a=e.node(s).rank,i=t.name,l=e.edge(t),c=l.labelRank;if(a===r+1)return;e.removeEdge(t);let d,u,p;for(p=0,++r;r<a;++p,++r)l.points=[],u={width:0,height:0,edgeLabel:l,edgeObj:t,rank:r},d=no(e,"edge",u,"_d"),r===c&&(u.width=l.width,u.height=l.height,u.dummy="edge-label",u.labelpos=l.labelpos),e.setEdge(n,d,{weight:l.weight},i),p===0&&e.graph().dummyChains.push(d),n=d;e.setEdge(n,s,{weight:l.weight},i)}function OW(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,s;for(e.setEdge(n.edgeObj,r);n.dummy;)s=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=s,n=e.node(t)})}function vu(e){let t={};function n(r){let s=e.node(r);if(Object.hasOwn(t,r))return s.rank;t[r]=!0;let a=e.outEdges(r),i=a?a.map(c=>c==null?Number.POSITIVE_INFINITY:n(c.w)-e.edge(c).minlen):[],l=Zt(Math.min,i);return l===Number.POSITIVE_INFINITY&&(l=0),s.rank=l}e.sources().forEach(n)}function Vr(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Qw=BW;function BW(e){let t=new $t({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let r=n[0],s=e.nodeCount();t.setNode(r,{});let a,i;for(;zW(t,e)<s&&(a=FW(t,e),!!a);)i=t.hasNode(a.v)?Vr(e,a):-Vr(e,a),jW(t,e,i);return t}function zW(e,t){function n(r){let s=t.nodeEdges(r);s&&s.forEach(a=>{let i=a.v,l=r===i?a.w:i;!e.hasNode(l)&&!Vr(t,a)&&(e.setNode(l,{}),e.setEdge(r,l,{}),n(l))})}return e.nodes().forEach(n),e.nodeCount()}function FW(e,t){return t.edges().reduce((n,r)=>{let s=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(s=Vr(t,r)),s<n[0]?[s,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function jW(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:VW,postorder:HW}=xu,qW=xr;xr.initLowLimValues=Nu;xr.initCutValues=wu;xr.calcCutValue=Gw;xr.leaveEdge=Ww;xr.enterEdge=Yw;xr.exchangeEdges=Zw;function xr(e){e=gW(e),vu(e);let t=Qw(e);Nu(t),wu(t,e);let n,r;for(;n=Ww(t);)r=Yw(t,e,n),Zw(t,e,n,r)}function wu(e,t){let n=HW(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>UW(e,t,r))}function UW(e,t,n){let r=e.node(n).parent,s=e.edge(n,r);s.cutvalue=Gw(e,t,n)}function Gw(e,t,n){let r=e.node(n).parent,s=!0,a=t.edge(n,r),i=0;a||(s=!1,a=t.edge(r,n)),i=a.weight;let l=t.nodeEdges(n);return l&&l.forEach(c=>{let d=c.v===n,u=d?c.w:c.v;if(u!==r){let p=d===s,h=t.edge(c).weight;if(i+=p?h:-h,GW(e,n,u)){let m=e.edge(n,u).cutvalue;i+=p?-m:m}}}),i}function Nu(e,t){arguments.length<2&&(t=e.nodes()[0]),Kw(e,{},1,t)}function Kw(e,t,n,r,s){let a=n,i=e.node(r);t[r]=!0;let l=e.neighbors(r);return l&&l.forEach(c=>{Object.hasOwn(t,c)||(n=Kw(e,t,n,c,r))}),i.low=a,i.lim=n++,s?i.parent=s:delete i.parent,n}function Ww(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Yw(e,t,n){let r=n.v,s=n.w;t.hasEdge(r,s)||(r=n.w,s=n.v);let a=e.node(r),i=e.node(s),l=a,c=!1;return a.lim>i.lim&&(l=i,c=!0),t.edges().filter(d=>c===Bh(e,e.node(d.v),l)&&c!==Bh(e,e.node(d.w),l)).reduce((d,u)=>Vr(t,u)<Vr(t,d)?u:d)}function Zw(e,t,n,r){let s=n.v,a=n.w;e.removeEdge(s,a),e.setEdge(r.v,r.w,{}),Nu(e),wu(e,t),QW(e,t)}function QW(e,t){let n=e.nodes().find(s=>!e.node(s).parent);if(!n)return;let r=VW(e,[n]);r=r.slice(1),r.forEach(s=>{let a=e.node(s).parent,i=t.edge(s,a),l=!1;i||(i=t.edge(a,s),l=!0),t.node(s).rank=t.node(a).rank+(l?i.minlen:-i.minlen)})}function GW(e,t,n){return e.hasEdge(t,n)}function Bh(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var KW=WW;function WW(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":zh(e);break;case"tight-tree":ZW(e);break;case"longest-path":YW(e);break;case"none":break;default:zh(e)}}var YW=vu;function ZW(e){vu(e),Qw(e)}function zh(e){qW(e)}var XW=JW;function JW(e){let t=tY(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),s=r.edgeObj,a=eY(e,t,s.v,s.w),i=a.path,l=a.lca,c=0,d=i[c],u=!0;for(;n!==s.w;){if(r=e.node(n),u){for(;(d=i[c])!==l&&e.node(d).maxRank<r.rank;)c++;d===l&&(u=!1)}if(!u){for(;c<i.length-1&&e.node(i[c+1]).minRank<=r.rank;)c++;d=i[c]}d!==void 0&&e.setParent(n,d),n=e.successors(n)[0]}})}function eY(e,t,n,r){let s=[],a=[],i=Math.min(t[n].low,t[r].low),l=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),s.push(c);while(c&&(t[c].low>i||l>t[c].lim));let d=c,u=r;for(;(u=e.parent(u))!==d;)a.push(u);return{path:s.concat(a.reverse()),lca:d}}function tY(e){let t={},n=0;function r(s){let a=n;e.children(s).forEach(r),t[s]={low:a,lim:n++}}return e.children(vi).forEach(r),t}function nY(e){let t=no(e,"root",{},"_root"),n=rY(e),r=Object.values(n),s=Zt(Math.max,r)-1,a=2*s+1;e.graph().nestingRoot=t,e.edges().forEach(l=>e.edge(l).minlen*=a);let i=oY(e)+1;e.children(vi).forEach(l=>Xw(e,t,a,i,s,n,l)),e.graph().nodeRankFactor=a}function Xw(e,t,n,r,s,a,i){var l;let c=e.children(i);if(!c.length){i!==t&&e.setEdge(t,i,{weight:0,minlen:n});return}let d=Rh(e,"_bt"),u=Rh(e,"_bb"),p=e.node(i);e.setParent(d,i),p.borderTop=d,e.setParent(u,i),p.borderBottom=u,c.forEach(h=>{var m;Xw(e,t,n,r,s,a,h);let g=e.node(h),b=g.borderTop?g.borderTop:h,x=g.borderBottom?g.borderBottom:h,y=g.borderTop?r:2*r,w=b!==x?1:s-((m=a[i])!=null?m:0)+1;e.setEdge(d,b,{weight:y,minlen:w,nestingEdge:!0}),e.setEdge(x,u,{weight:y,minlen:w,nestingEdge:!0})}),e.parent(i)||e.setEdge(t,d,{weight:0,minlen:s+((l=a[i])!=null?l:0)})}function rY(e){let t={};function n(r,s){let a=e.children(r);a&&a.length&&a.forEach(i=>n(i,s+1)),t[r]=s}return e.children(vi).forEach(r=>n(r,1)),t}function oY(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function sY(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var aY=iY;function iY(e){function t(n){let r=e.children(n),s=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(s,"minRank")){s.borderLeft=[],s.borderRight=[];for(let a=s.minRank,i=s.maxRank+1;a<i;++a)Fh(e,"borderLeft","_bl",n,s,a),Fh(e,"borderRight","_br",n,s,a)}}e.children(vi).forEach(t)}function Fh(e,t,n,r,s,a){let i={width:0,height:0,rank:a,borderType:t},l=s[t][a-1],c=no(e,"border",i,n);s[t][a]=c,e.setParent(c,r),l&&e.setEdge(l,c,{weight:1})}function lY(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&Jw(e)}function cY(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&dY(e),(n==="lr"||n==="rl")&&(uY(e),Jw(e))}function Jw(e){e.nodes().forEach(t=>jh(e.node(t))),e.edges().forEach(t=>jh(e.edge(t)))}function jh(e){let t=e.width;e.width=e.height,e.height=t}function dY(e){e.nodes().forEach(t=>vl(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(vl),Object.hasOwn(r,"y")&&vl(r)})}function vl(e){e.y=-e.y}function uY(e){e.nodes().forEach(t=>wl(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(wl),Object.hasOwn(r,"x")&&wl(r)})}function wl(e){let t=e.x;e.x=e.y,e.y=t}function pY(e){let t={},n=e.nodes().filter(l=>!e.children(l).length),r=n.map(l=>e.node(l).rank),s=Zt(Math.max,r),a=qo(s+1).map(()=>[]);function i(l){if(t[l])return;t[l]=!0;let c=e.node(l);a[c.rank].push(l);let d=e.successors(l);d&&d.forEach(i)}return n.sort((l,c)=>e.node(l).rank-e.node(c).rank).forEach(i),a}function fY(e,t){let n=0;for(let r=1;r<t.length;++r)n+=hY(e,t[r-1],t[r]);return n}function hY(e,t,n){let r=NW(n,n.map((d,u)=>u)),s=t.flatMap(d=>{let u=e.outEdges(d);return u?u.map(p=>({pos:r[p.w],weight:e.edge(p).weight})).sort((p,h)=>p.pos-h.pos):[]}),a=1;for(;a<n.length;)a<<=1;let i=2*a-1;a-=1;let l=new Array(i).fill(0),c=0;return s.forEach(d=>{let u=d.pos+a;l[u]+=d.weight;let p=0;for(;u>0;)u%2&&(p+=l[u+1]),u=u-1>>1,l[u]+=d.weight;c+=d.weight*p}),c}function mY(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(!r||!r.length)return{v:n};{let s=r.reduce((a,i)=>{let l=e.edge(i),c=e.node(i.v);return{sum:a.sum+l.weight*c.order,weight:a.weight+l.weight}},{sum:0,weight:0});return{v:n,barycenter:s.sum/s.weight,weight:s.weight}}})}function gY(e,t){let n={};e.forEach((s,a)=>{let i={indegree:0,in:[],out:[],vs:[s.v],i:a};s.barycenter!==void 0&&(i.barycenter=s.barycenter,i.weight=s.weight),n[s.v]=i}),t.edges().forEach(s=>{let a=n[s.v],i=n[s.w];a!==void 0&&i!==void 0&&(i.indegree++,a.out.push(i))});let r=Object.values(n).filter(s=>!s.indegree);return bY(r)}function bY(e){let t=[];function n(s){return a=>{a.merged||(a.barycenter===void 0||s.barycenter===void 0||a.barycenter>=s.barycenter)&&xY(s,a)}}function r(s){return a=>{a.in.push(s),--a.indegree===0&&e.push(a)}}for(;e.length;){let s=e.pop();t.push(s),s.in.reverse().forEach(n(s)),s.out.forEach(r(s))}return t.filter(s=>!s.merged).map(s=>Ea(s,["vs","i","barycenter","weight"]))}function xY(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function yY(e,t){let n=vW(e,u=>Object.hasOwn(u,"barycenter")),r=n.lhs,s=n.rhs.sort((u,p)=>p.i-u.i),a=[],i=0,l=0,c=0;r.sort(vY(!!t)),c=Vh(a,s,c),r.forEach(u=>{c+=u.vs.length,a.push(u.vs),i+=u.barycenter*u.weight,l+=u.weight,c=Vh(a,s,c)});let d={vs:a.flat(1)};return l&&(d.barycenter=i/l,d.weight=l),d}function Vh(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function vY(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}function eN(e,t,n,r){let s=e.children(t),a=e.node(t),i=a?a.borderLeft:void 0,l=a?a.borderRight:void 0,c={};i&&(s=s.filter(h=>h!==i&&h!==l));let d=mY(e,s);d.forEach(h=>{if(e.children(h.v).length){let m=eN(e,h.v,n,r);c[h.v]=m,Object.hasOwn(m,"barycenter")&&NY(h,m)}});let u=gY(d,n);wY(u,c);let p=yY(u,r);if(i&&l){p.vs=[i,p.vs,l].flat(1);let h=e.predecessors(i);if(h&&h.length){let m=e.node(h[0]),g=e.predecessors(l),b=e.node(g[0]);Object.hasOwn(p,"barycenter")||(p.barycenter=0,p.weight=0),p.barycenter=(p.barycenter*p.weight+m.order+b.order)/(p.weight+2),p.weight+=2}}return p}function wY(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function NY(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function kY(e,t,n,r){r||(r=e.nodes());let s=SY(e),a=new $t({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(i=>e.node(i));return r.forEach(i=>{let l=e.node(i),c=e.parent(i);if(l.rank===t||l.minRank<=t&&t<=l.maxRank){a.setNode(i),a.setParent(i,c||s);let d=e[n](i);d&&d.forEach(u=>{let p=u.v===i?u.w:u.v,h=a.edge(p,i),m=h!==void 0?h.weight:0;a.setEdge(p,i,{weight:e.edge(u).weight+m})}),Object.hasOwn(l,"minRank")&&a.setNode(i,{borderLeft:l.borderLeft[t],borderRight:l.borderRight[t]})}}),a}function SY(e){let t;for(;e.hasNode(t=yu("_root")););return t}function CY(e,t,n){let r={},s;n.forEach(a=>{let i=e.parent(a),l,c;for(;i;){if(l=e.parent(i),l?(c=r[l],r[l]=i):(c=s,s=i),c&&c!==i){t.setEdge(c,i);return}i=l}})}function tN(e,t={}){if(typeof t.customOrder=="function"){t.customOrder(e,tN);return}let n=Hw(e),r=Hh(e,qo(1,n+1),"inEdges"),s=Hh(e,qo(n-1,-1,-1),"outEdges"),a=pY(e);if(qh(e,a),t.disableOptimalOrderHeuristic)return;let i=Number.POSITIVE_INFINITY,l,c=t.constraints||[];for(let d=0,u=0;u<4;++d,++u){MY(d%2?r:s,d%4>=2,c),a=cs(e);let p=fY(e,a);p<i?(u=0,l=Object.assign({},a),i=p):p===i&&(l=structuredClone(a))}qh(e,l)}function Hh(e,t,n){let r=new Map,s=(a,i)=>{r.has(a)||r.set(a,[]),r.get(a).push(i)};for(let a of e.nodes()){let i=e.node(a);if(typeof i.rank=="number"&&s(i.rank,a),typeof i.minRank=="number"&&typeof i.maxRank=="number")for(let l=i.minRank;l<=i.maxRank;l++)l!==i.rank&&s(l,a)}return t.map(function(a){return kY(e,a,n,r.get(a)||[])})}function MY(e,t,n){let r=new $t;e.forEach(function(s){n.forEach(l=>r.setEdge(l.left,l.right));let a=s.graph().root,i=eN(s,a,r,t);i.vs.forEach((l,c)=>s.node(l).order=c),CY(s,r,i.vs)})}function qh(e,t){Object.values(t).forEach(n=>n.forEach((r,s)=>e.node(r).order=s))}function EY(e,t){let n={};function r(s,a){let i=0,l=0,c=s.length,d=a[a.length-1];return a.forEach((u,p)=>{let h=AY(e,u),m=h?e.node(h).order:c;(h||u===d)&&(a.slice(l,p+1).forEach(g=>{let b=e.predecessors(g);b&&b.forEach(x=>{let y=e.node(x),w=y.order;(w<i||m<w)&&!(y.dummy&&e.node(g).dummy)&&nN(n,x,g)})}),l=p+1,i=m)}),a}return t.length&&t.reduce(r),n}function IY(e,t){let n={};function r(a,i,l,c,d){qo(i,l).forEach(u=>{let p=a[u];if(p!==void 0&&e.node(p).dummy){let h=e.predecessors(p);h&&h.forEach(m=>{if(m===void 0)return;let g=e.node(m);g.dummy&&(g.order<c||g.order>d)&&nN(n,m,p)})}})}function s(a,i){let l=-1,c=-1,d=0;return i.forEach((u,p)=>{if(e.node(u).dummy==="border"){let h=e.predecessors(u);if(h&&h.length){let m=h[0];if(m===void 0)return;c=e.node(m).order,r(i,d,p,l,c),d=p,l=c}}r(i,d,i.length,c,a.length)}),i}return t.length&&t.reduce(s),n}function AY(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function nN(e,t,n){if(t>n){let s=t;t=n,n=s}let r=e[t];r||(e[t]=r={}),r[n]=!0}function PY(e,t,n){if(t>n){let s=t;t=n,n=s}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function _Y(e,t,n,r){let s={},a={},i={};return t.forEach(l=>{l.forEach((c,d)=>{s[c]=c,a[c]=c,i[c]=d})}),t.forEach(l=>{let c=-1;l.forEach(d=>{let u=r(d);if(u&&u.length){let p=u.sort((m,g)=>{let b=i[m],x=i[g];return(b!==void 0?b:0)-(x!==void 0?x:0)}),h=(p.length-1)/2;for(let m=Math.floor(h),g=Math.ceil(h);m<=g;++m){let b=p[m];if(b===void 0)continue;let x=i[b];if(x!==void 0&&a[d]===d&&c<x&&!PY(n,d,b)){let y=s[b];y!==void 0&&(a[b]=d,a[d]=s[d]=y,c=x)}}}})}),{root:s,align:a}}function $Y(e,t,n,r,s=!1){let a={},i=DY(e,t,n,s),l=s?"borderLeft":"borderRight";function c(m,g){let b=i.nodes().slice(),x={},y=b.pop();for(;y;){if(x[y])m(y);else{x[y]=!0,b.push(y);for(let w of g(y))b.push(w)}y=b.pop()}}function d(m){let g=i.inEdges(m);g?a[m]=g.reduce((b,x)=>{var y;let w=(y=a[x.v])!=null?y:0,v=i.edge(x);return Math.max(b,w+(v!==void 0?v:0))},0):a[m]=0}function u(m){let g=i.outEdges(m),b=Number.POSITIVE_INFINITY;g&&(b=g.reduce((y,w)=>{let v=a[w.w],N=i.edge(w);return Math.min(y,(v!==void 0?v:0)-(N!==void 0?N:0))},Number.POSITIVE_INFINITY));let x=e.node(m);b!==Number.POSITIVE_INFINITY&&x.borderType!==l&&(a[m]=Math.max(a[m]!==void 0?a[m]:0,b))}function p(m){return i.predecessors(m)||[]}function h(m){return i.successors(m)||[]}return c(d,p),c(u,h),Object.keys(r).forEach(m=>{var g;let b=n[m];b!==void 0&&(a[m]=(g=a[b])!=null?g:0)}),a}function DY(e,t,n,r){let s=new $t,a=e.graph(),i=BY(a.nodesep,a.edgesep,r);return t.forEach(l=>{let c;l.forEach(d=>{let u=n[d];if(u!==void 0){if(s.setNode(u),c!==void 0){let p=n[c];if(p!==void 0){let h=s.edge(p,u);s.setEdge(p,u,Math.max(i(e,d,c),h||0))}}c=d}})}),s}function LY(e,t){return Object.values(t).reduce((n,r)=>{let s=Number.NEGATIVE_INFINITY,a=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([l,c])=>{let d=zY(e,l)/2;s=Math.max(c+d,s),a=Math.min(c-d,a)});let i=s-a;return i<n[0]&&(n=[i,r]),n},[Number.POSITIVE_INFINITY,null])[1]}function TY(e,t){let n=Object.values(t),r=Zt(Math.min,n),s=Zt(Math.max,n);["u","d"].forEach(a=>{["l","r"].forEach(i=>{let l=a+i,c=e[l];if(!c||c===t)return;let d=Object.values(c),u=r-Zt(Math.min,d);i!=="l"&&(u=s-Zt(Math.max,d)),u&&(e[l]=yi(c,p=>p+u))})})}function RY(e,t=void 0){let n=e.ul;return n?yi(n,(r,s)=>{var a,i;if(t){let c=t.toLowerCase(),d=e[c];if(d&&d[s]!==void 0)return d[s]}let l=Object.values(e).map(c=>{let d=c[s];return d!==void 0?d:0}).sort((c,d)=>c-d);return(((a=l[1])!=null?a:0)+((i=l[2])!=null?i:0))/2}):{}}function OY(e){let t=cs(e),n=Object.assign(EY(e,t),IY(e,t)),r={},s;["u","d"].forEach(i=>{s=i==="u"?t:Object.values(t).reverse(),["l","r"].forEach(l=>{l==="r"&&(s=s.map(u=>Object.values(u).reverse()));let c=_Y(e,s,n,u=>(i==="u"?e.predecessors(u):e.successors(u))||[]),d=$Y(e,s,c.root,c.align,l==="r");l==="r"&&(d=yi(d,u=>-u)),r[i+l]=d})});let a=LY(e,r);return TY(r,a),RY(r,e.graph().align)}function BY(e,t,n){return(r,s,a)=>{let i=r.node(s),l=r.node(a),c=0,d;if(c+=i.width/2,Object.hasOwn(i,"labelpos"))switch(i.labelpos.toLowerCase()){case"l":d=-i.width/2;break;case"r":d=i.width/2;break}if(d&&(c+=n?d:-d),d=void 0,c+=(i.dummy?t:e)/2,c+=(l.dummy?t:e)/2,c+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":d=l.width/2;break;case"r":d=-l.width/2;break}return d&&(c+=n?d:-d),c}}function zY(e,t){return e.node(t).width}function FY(e){e=jw(e),jY(e),Object.entries(OY(e)).forEach(([t,n])=>e.node(t).x=n)}function jY(e){let t=cs(e),n=e.graph(),r=n.ranksep,s=n.rankalign,a=0;t.forEach(i=>{let l=i.reduce((c,d)=>{var u;let p=(u=e.node(d).height)!=null?u:0;return c>p?c:p},0);i.forEach(c=>{let d=e.node(c);s==="top"?d.y=a+d.height/2:s==="bottom"?d.y=a+l-d.height/2:d.y=a+l/2}),a+=l+r})}function VY(e,t={}){let n=t.debugTiming?qw:Uw;return n("layout",()=>{let r=n(" buildLayoutGraph",()=>XY(e));return n(" runLayout",()=>HY(r,n,t)),n(" updateInputGraph",()=>qY(e,r)),r})}function HY(e,t,n){t(" makeSpaceForEdgeLabels",()=>JY(e)),t(" removeSelfEdges",()=>lZ(e)),t(" acyclic",()=>$W(e)),t(" nestingGraph.run",()=>nY(e)),t(" rank",()=>KW(jw(e))),t(" injectEdgeLabelProxies",()=>eZ(e)),t(" removeEmptyRanks",()=>xW(e)),t(" nestingGraph.cleanup",()=>sY(e)),t(" normalizeRanks",()=>bW(e)),t(" assignRankMinMax",()=>tZ(e)),t(" removeEdgeLabelProxies",()=>nZ(e)),t(" normalize.run",()=>TW(e)),t(" parentDummyChains",()=>XW(e)),t(" addBorderSegments",()=>aY(e)),t(" order",()=>tN(e,n)),t(" insertSelfEdges",()=>cZ(e)),t(" adjustCoordinateSystem",()=>lY(e)),t(" position",()=>FY(e)),t(" positionSelfEdges",()=>dZ(e)),t(" removeBorderNodes",()=>iZ(e)),t(" normalize.undo",()=>OW(e)),t(" fixupEdgeLabelCoords",()=>sZ(e)),t(" undoCoordinateSystem",()=>cY(e)),t(" translateGraph",()=>rZ(e)),t(" assignNodeIntersects",()=>oZ(e)),t(" reversePoints",()=>aZ(e)),t(" acyclic.undo",()=>LW(e))}function qY(e,t){e.nodes().forEach(n=>{let r=e.node(n),s=t.node(n);r&&(r.x=s.x,r.y=s.y,r.order=s.order,r.rank=s.rank,t.children(n).length&&(r.width=s.width,r.height=s.height))}),e.edges().forEach(n=>{let r=e.edge(n),s=t.edge(n);r.points=s.points,Object.hasOwn(s,"x")&&(r.x=s.x,r.y=s.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var UY=["nodesep","edgesep","ranksep","marginx","marginy"],QY={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},GY=["acyclicer","ranker","rankdir","align","rankalign"],KY=["width","height","rank"],Uh={width:0,height:0},WY=["minlen","weight","width","height","labeloffset"],YY={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},ZY=["labelpos"];function XY(e){let t=new $t({multigraph:!0,compound:!0}),n=kl(e.graph());return t.setGraph(Object.assign({},QY,Nl(n,UY),Ea(n,GY))),e.nodes().forEach(r=>{let s=kl(e.node(r)),a=Nl(s,KY);Object.keys(Uh).forEach(l=>{a[l]===void 0&&(a[l]=Uh[l])}),t.setNode(r,a);let i=e.parent(r);i!==void 0&&t.setParent(r,i)}),e.edges().forEach(r=>{let s=kl(e.edge(r));t.setEdge(r,Object.assign({},YY,Nl(s,WY),Ea(s,ZY)))}),t}function JY(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function eZ(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),s={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};no(e,"edge-proxy",s,"_ep")}})}function tZ(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function nZ(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function rZ(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,s=0,a=e.graph(),i=a.marginx||0,l=a.marginy||0;function c(d){let u=d.x,p=d.y,h=d.width,m=d.height;t=Math.min(t,u-h/2),n=Math.max(n,u+h/2),r=Math.min(r,p-m/2),s=Math.max(s,p+m/2)}e.nodes().forEach(d=>c(e.node(d))),e.edges().forEach(d=>{let u=e.edge(d);Object.hasOwn(u,"x")&&c(u)}),t-=i,r-=l,e.nodes().forEach(d=>{let u=e.node(d);u.x-=t,u.y-=r}),e.edges().forEach(d=>{let u=e.edge(d);u.points.forEach(p=>{p.x-=t,p.y-=r}),Object.hasOwn(u,"x")&&(u.x-=t),Object.hasOwn(u,"y")&&(u.y-=r)}),a.width=n-t+i,a.height=s-r+l}function oZ(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),s=e.node(t.w),a,i;n.points?(a=n.points[0],i=n.points[n.points.length-1]):(n.points=[],a=s,i=r),n.points.unshift(Th(r,a)),n.points.push(Th(s,i))})}function sZ(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function aZ(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function iZ(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),s=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),i=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(i.x-a.x),n.height=Math.abs(s.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function lZ(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function cZ(e){cs(e).forEach(t=>{let n=0;t.forEach((r,s)=>{let a=e.node(r);a.order=s+n,(a.selfEdges||[]).forEach(i=>{no(e,"selfedge",{width:i.label.width,height:i.label.height,rank:a.rank,order:s+ ++n,e:i.e,label:i.label},"_se")}),delete a.selfEdges})})}function dZ(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="selfedge"){let r=n,s=e.node(r.e.v),a=s.x+s.width/2,i=s.y,l=n.x-a,c=s.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:a+2*l/3,y:i-c},{x:a+5*l/6,y:i-c},{x:a+l,y:i},{x:a+5*l/6,y:i+c},{x:a+2*l/3,y:i+c}],r.label.x=n.x,r.label.y=n.y}})}function Nl(e,t){return yi(Ea(e,t),Number)}function kl(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}function uZ(e){let t=cs(e),n=new $t({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(r=>{n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),e.edges().forEach(r=>n.setEdge(r.v,r.w,{},r.name)),t.forEach((r,s)=>{let a="layer"+s;n.setNode(a,{rank:"same"}),r.reduce((i,l)=>(n.setEdge(i,l,{style:"invis"}),l))}),n}var pZ={graphlib:$w,version:kW,layout:VY,debug:uZ,util:{time:qw,notime:Uw}},Qh=pZ;/*! For license information please see dagre.esm.js.LEGAL.txt */function fZ({data:e,selected:t}){const n=e.isOnline,r=e.isHub,s=e.engines??[],a=e.addons??[],i=e.processes??[],l=e.name,c=e.hostname,d=e.localIps??[],u=e.cpuPercent,p=e.memoryPercent,h=e.isExpanded,m=e.onToggleExpand,g=e.onShowNodeLogs,b=e.onRestartNode,x=e.id,y=i.length,w=U(M=>{M.stopPropagation(),m?.()},[m]),v=U(M=>{M.stopPropagation(),g?.()},[g]),N=U(M=>{M.stopPropagation(),b?.()},[b]);return f("div",{className:`rounded-xl bg-surface px-3 py-2.5 min-w-[180px] max-w-[260px] transition-all duration-200 ${n?r?"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:[o(Dn,{type:"target",position:we.Top,className:"!bg-border !w-2 !h-2"}),f("div",{className:"flex items-center gap-1.5 mb-1.5",children:[o("div",{className:`w-2 h-2 rounded-full ${n?"bg-success":"bg-destructive"}`}),o("span",{className:"text-xs font-semibold truncate flex-1",children:l}),r?o("span",{className:"text-[8px] px-1 py-0.5 rounded bg-primary/10 text-primary font-medium",children:"HUB"}):o("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 f("div",{className:"text-[9px] text-muted-foreground mb-1 space-y-0.5",title:[c,...d].filter(Boolean).join(", "),children:[c&&o("div",{className:"truncate",children:c}),M.length>0&&o("div",{className:"truncate font-mono opacity-70",children:M.join(", ")})]})})(),s.length>0&&o("div",{className:"flex flex-wrap gap-1 mb-1.5",children:s.map(M=>o("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&&f("div",{className:"text-[9px] text-muted-foreground mb-1",children:[a.length," addon",a.length!==1?"s":""," in-process"]}),n&&f("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground",children:[f("span",{className:"flex items-center gap-0.5",children:[o(xt,{className:"h-2.5 w-2.5"}),u,"%"]}),f("span",{className:"flex items-center gap-0.5",children:[o(Wd,{className:"h-2.5 w-2.5"}),p,"%"]}),f("div",{className:"flex items-center gap-1 ml-auto",children:[y>0&&f("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:h?"Collapse processes":`Expand ${y} process${y!==1?"es":""}`,children:[h?o(lt,{className:"h-3 w-3"}):o(Nt,{className:"h-3 w-3"}),o("span",{className:"text-[9px] font-medium",children:y})]}),o("button",{onClick:v,className:"p-0.5 rounded hover:bg-primary/10 text-muted-foreground hover:text-primary transition-colors",title:`Logs: ${x}`,children:o(it,{className:"h-3 w-3"})}),o("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:o(St,{className:"h-3 w-3"})})]})]}),!n&&o("div",{className:"text-[10px] text-muted-foreground",children:"offline"}),o(Dn,{type:"source",position:we.Bottom,className:"!bg-border !w-2 !h-2"})]})}const hZ=He(fZ);function mZ(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 gZ({data:e}){const t=e.name,n=e.state,r=e.pid,s=e.cpuPercent,a=e.memoryRss,i=e.addonId,l=e.services??[],c=e.isExpanded,d=e.onToggleServices,u=e.parentNodeId,p=e.onShowLogs,h=e.onRestartAddon,m=n==="running",g=t.includes("(core)"),b=!g&&l.length===1,x=b?l[0]:null,y=u??"hub",w=`${y}/${t}`,v=U(M=>{M.stopPropagation(),d?.()},[d]),N=g?mn:Wa,k=g?"border-primary/50":m?"border-amber-500/50":"border-destructive/50",C=g?"text-primary":"text-amber-500";return f("div",{className:`rounded-lg bg-surface min-w-[150px] border ${k} ${c?"max-w-[240px]":"max-w-[210px]"}`,children:[o(Dn,{type:"target",position:we.Top,className:`!w-1.5 !h-1.5 ${g?"!bg-primary":"!bg-amber-500"}`}),f("div",{className:"px-2.5 pt-2 pb-1.5",children:[f("div",{className:"flex items-start gap-1.5 mb-1.5",children:[o(N,{className:`h-3 w-3 ${C} shrink-0 mt-0.5`}),o("span",{className:"text-[10px] font-semibold truncate flex-1",children:g?"core":i??t}),o("span",{className:"text-[8px] text-muted-foreground/60 tabular-nums shrink-0",children:r})]}),f("div",{className:"flex items-center gap-2 text-[9px] text-muted-foreground",children:[o("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${m?"bg-success":"bg-destructive"}`}),f("span",{className:"flex items-center gap-0.5",children:[o(xt,{className:"h-2 w-2"}),s,"%"]}),f("span",{className:"flex items-center gap-0.5",children:[o(Wd,{className:"h-2 w-2"}),mZ(a)]}),b&&x?f("div",{className:"flex items-center gap-0.5 ml-auto",children:[o("button",{onClick:M=>{M.stopPropagation(),p?.(x.addonId,y)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Logs: ${x.addonId}`,children:o(it,{className:"h-2.5 w-2.5"})}),o("button",{onClick:M=>{M.stopPropagation(),h?.(x.addonId,w)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Restart: ${x.addonId}`,children:o(St,{className:"h-2.5 w-2.5"})})]}):l.length>0?f("button",{onClick:v,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?o(lt,{className:"h-2.5 w-2.5"}):o(Nt,{className:"h-2.5 w-2.5"}),o("span",{className:"text-[8px] font-medium",children:l.length})]}):null]})]}),c&&l.length>0&&!b&&o("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?y:`${y}/${t}`;return f("div",{className:"flex items-center gap-1 py-0.5",children:[o("div",{className:`w-1 h-1 rounded-full shrink-0 ${M.status==="running"?"bg-success":"bg-muted-foreground/30"}`}),o("span",{className:"text-[9px] truncate flex-1",children:M.addonId}),o("button",{onClick:I=>{I.stopPropagation(),p?.(M.addonId,y)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Logs: ${M.addonId}`,children:o(it,{className:"h-2.5 w-2.5"})}),o("button",{onClick:I=>{I.stopPropagation(),h?.(M.addonId,P)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Restart: ${M.addonId}`,children:o(St,{className:"h-2.5 w-2.5"})})]},M.addonId)})}),o(Dn,{type:"source",position:we.Bottom,className:`!w-1.5 !h-1.5 ${g?"!bg-primary":"!bg-amber-500"}`})]})}const bZ=He(gZ),xZ={clusterNode:hZ,processNode:bZ},wr={cluster:{width:320,height:170},process:{width:240,height:100},processExpanded:{width:240,height:240}};function yZ(e){return typeof e=="object"&&e!==null&&typeof e.x=="number"&&typeof e.y=="number"}function vZ(e,t){const n=new Qh.graphlib.Graph;n.setGraph({rankdir:"TB",nodesep:40,ranksep:80,marginx:30,marginy:30}),n.setDefaultEdgeLabel(()=>({}));for(const s of e){const a=s.type==="processNode"&&!!s.data?.isExpanded,i=s.type==="clusterNode"?wr.cluster:a?wr.processExpanded:wr.process;n.setNode(s.id,{width:i.width,height:i.height})}for(const s of t)n.setEdge(s.source,s.target);Qh.layout(n);const r=new Map;for(const s of e){const a=n.node(s.id);if(!yZ(a))continue;const i=s.type==="processNode"&&!!s.data?.isExpanded,l=s.type==="clusterNode"?wr.cluster:i?wr.processExpanded:wr.process;r.set(s.id,{x:a.x-l.width/2,y:a.y-l.height/2})}return r}function wZ({topology:e}){const{resolvedMode:t}=Hr(),n=Sx(),r=za(),[,s]=_(null),[a,i]=_(()=>e.length<=1?new Set(e.map(M=>M.id)):new Set),[l,c]=_(null),[d,u]=_(null),p=U((M,P)=>{u(I=>I?.addonId===M&&I?.agentId===P?null:{addonId:M,agentId:P})},[]),h=U(M=>{u(P=>P?.agentId===M&&!P?.addonId?null:{agentId:M})},[]),m=U(async M=>{try{await n.mutateAsync({nodeId:M})}catch(P){console.error("Failed to restart node:",P)}},[n]),g=U(async(M,P)=>{try{await r.mutateAsync({nodeId:P,addonId:M})}catch(I){console.error("Failed to restart addon:",I)}},[r]),b=U(M=>{i(P=>{const I=new Set(P);return I.has(M)?I.delete(M):I.add(M),I})},[]),x=U(M=>{c(P=>P===M?null:M)},[]),y=U(M=>{s(M)},[]),w=q(()=>{const M=e.filter(E=>E.isHub),P=e.filter(E=>!E.isHub),I=[],z=[],A=M[0]?.id;function O(E,D){const L=[...D];if(L.length!==0)for(const T of L){const B=`proc:${E}/${T.name}`,F=T.services??[],j=l===B;I.push({id:B,type:"processNode",position:{x:0,y:0},data:{...T,addonId:T.name.includes("(core)")?void 0:F.length>1?T.name:F[0]?.addonId??T.name,parentNodeId:E,services:F,isExpanded:j,onToggleServices:()=>x(B),onShowLogs:p,onRestartAddon:g}}),z.push({id:`edge:${E}-${B}`,source:E,target:B,animated:!0,style:{stroke:"var(--amber-500, #f59e0b)",strokeWidth:1,strokeDasharray:"4 4"}})}}for(const E of M)I.push({id:E.id,type:"clusterNode",position:{x:0,y:0},data:{...E,label:E.name,isExpanded:a.has(E.id),onToggleExpand:()=>b(E.id),onShowDetail:()=>y(E.id),onShowNodeLogs:()=>h(E.id),onRestartNode:()=>m(E.id)}}),a.has(E.id)&&O(E.id,E.processes??[]);for(const E of P)I.push({id:E.id,type:"clusterNode",position:{x:0,y:0},data:{...E,label:E.name,isExpanded:a.has(E.id),onToggleExpand:()=>b(E.id),onShowDetail:()=>y(E.id),onShowNodeLogs:()=>h(E.id),onRestartNode:()=>m(E.id)}}),A&&E.isOnline&&z.push({id:`${A}-${E.id}`,source:A,target:E.id,animated:!0,style:{stroke:"var(--border)",strokeWidth:1.5}}),a.has(E.id)&&O(E.id,E.processes??[]);const R=vZ(I,z);for(const E of I){const D=R.get(E.id);D&&(E.position=D)}return{nodes:I,edges:z}},[e,a,l,b,x,y,p,h,m,g]),v=te(new Map),N=q(()=>{const M=v.current;return w.nodes.map(I=>({...I,position:M.get(I.id)??I.position}))},[w.nodes]),k=U(M=>{for(const P of M)P.type==="position"&&P.position&&v.current.set(P.id,P.position)},[]),C=U(()=>s(null),[]);return o("div",{className:"flex flex-col gap-4 flex-1",children:f("div",{className:"relative flex-1 min-h-[350px] border border-border rounded-xl overflow-hidden",children:[f(mK,{nodes:N,edges:w.edges,onNodesChange:k,onPaneClick:C,nodeTypes:xZ,nodesConnectable:!1,fitView:!0,fitViewOptions:{padding:.2,maxZoom:1.2},proOptions:{hideAttribution:!0},className:"bg-background",colorMode:t,children:[o(vK,{gap:20,size:1}),o(EK,{showInteractive:!1})]}),d&&o(fy,{addonId:d.addonId,agentId:d.agentId,showScope:!0,onClose:()=>u(null)})]})})}function NZ({onlineNodeIds:e}){const t=ke(),n=rt(),{data:r,isLoading:s}=Yr(),a=Wx({onSuccess:()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","listAgentSettings"]]})}}),i=q(()=>{if(!r)return[];const c=new Set(e);return c.add("hub"),r.filter(d=>!c.has(d.nodeId))},[r,e]);if(s)return o("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?o("section",{className:"rounded-lg border border-border bg-surface p-6",children:f("div",{className:"flex flex-col items-center gap-2 text-center text-muted-foreground",children:[o(Kl,{className:"h-6 w-6 opacity-40"}),o("p",{className:"text-xs",children:"No stale agent entries."}),o("p",{className:"text-[11px] opacity-60",children:"Every persisted nodeId matches a node currently online in the cluster."})]})}):f("section",{className:"rounded-lg border border-border bg-surface",children:[f("header",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[o(Kl,{className:"h-4 w-4 text-muted-foreground"}),o("h2",{className:"text-sm font-semibold",children:"Offline agents"}),f("span",{className:"ml-auto text-[11px] text-muted-foreground",children:[i.length," stale ",i.length===1?"entry":"entries"]})]}),o("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."}),o("ul",{className:"divide-y divide-border",children:i.map(c=>{const d=Object.keys(c.settings.addonDefaults??{}).length,u=Object.values(c.settings.addonDefaults??{}).filter(p=>p?.enabled).length;return f("li",{className:"flex items-center gap-3 px-4 py-2 text-xs",children:[o("span",{className:"font-mono text-foreground",children:c.nodeId}),f("span",{className:"text-muted-foreground",children:[d," addons configured",d>0&&f(he,{children:[" · ",u," enabled"]})]}),f("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:[o(Ze,{className:"h-3 w-3"}),"Remove"]})]},c.nodeId)})})]})}function kZ(e){const[t,n]=_(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return Y(()=>{const r=window.matchMedia(e),s=a=>n(a.matches);return r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[e]),t}function SZ(){const{data:e,isLoading:t}=Bn(void 0,{staleTime:1/0}),[n,r]=_(null);return bt("cluster.topology-snapshot",a=>{const i=a.data?.nodes;Array.isArray(i)&&r(i)}),{nodes:q(()=>n??e??[],[n,e]),isLoading:t&&!n}}function CZ(){const[e,t]=_("diagram"),n=kZ("(max-width: 767px)"),r=n&&e==="diagram"?"table":e,{nodes:s,isLoading:a}=SZ(),i=s.filter(h=>h.isOnline).length,l=s.filter(h=>!h.isOnline).length,c=q(()=>s.map(h=>h.id??"").filter(Boolean),[s]),{data:d}=Yr(),u=q(()=>{if(!d)return 0;const h=new Set(c);return h.add("hub"),d.filter(m=>!h.has(m.nodeId)).length},[d,c]),p=(h,m,g,b)=>f("button",{onClick:()=>t(h),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${e===h?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:[o(g,{className:"h-3.5 w-3.5"}),m,b!==void 0&&b>0&&o("span",{className:`ml-1 inline-flex h-4 min-w-[1rem] items-center justify-center rounded-full px-1 text-[10px] font-semibold ${e===h?"bg-primary-foreground/20 text-primary-foreground":"bg-destructive/15 text-destructive"}`,children:b})]});return f("div",{className:"flex flex-col h-full gap-4 p-4",children:[f("div",{className:"flex items-center justify-between",children:[f("div",{className:"flex items-center gap-2",children:[i>0&&f("span",{className:"text-xs px-2 py-0.5 rounded-full bg-success/10 text-success",children:[i," online"]}),l>0&&f("span",{className:"text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:[l," offline"]})]}),f("div",{className:"flex gap-0.5 p-1 rounded-lg bg-muted",children:[!n&&p("diagram","Diagram",_n),p("table","Table",FO),p("offline-agents","Offline agents",Kl,u)]})]}),a?o("div",{className:"flex items-center justify-center flex-1 text-muted-foreground",children:"Loading cluster topology..."}):r==="diagram"?o(wZ,{topology:s}):r==="table"?o("div",{className:"flex-1 overflow-auto",children:o(Dj,{nodes:s})}):o("div",{className:"flex-1 overflow-auto",children:o(NZ,{onlineNodeIds:c})})]})}function cn({title:e,children:t}){return f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o("div",{className:"border-b border-border px-4 py-2.5",children:o("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:e})}),o("div",{className:"p-4",children:t})]})}function st({name:e,cssVar:t,hex:n}){const r=t?`var(${t})`:n;return f("div",{className:"flex flex-col items-center gap-1.5",children:[o("div",{className:"h-10 w-10 rounded-lg border border-border shadow-inner",style:{backgroundColor:r}}),o("span",{className:"text-[10px] text-foreground-subtle text-center leading-tight",children:e})]})}const MZ={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 EZ(){const[e,t]=_({name:"Example",count:10,enabled:!0,mode:"a",tags:["camera"],confidence:60});return f("div",{className:"p-6 space-y-6 max-w-5xl mx-auto",children:[f("div",{className:"mb-6",children:[o("h1",{className:"text-xl font-bold text-foreground",children:"Component Showroom"}),o("p",{className:"text-sm text-foreground-subtle mt-1",children:"All UI components at a glance"})]}),o(cn,{title:"Typography",children:f("div",{className:"space-y-3",children:[o("h1",{className:"text-2xl font-bold text-foreground",children:"Heading 1 — Display title"}),o("h2",{className:"text-xl font-semibold text-foreground",children:"Heading 2 — Section title"}),o("h3",{className:"text-base font-semibold text-foreground",children:"Heading 3 — Card title"}),o("h4",{className:"text-sm font-semibold text-foreground",children:"Heading 4 — Sub-section"}),o("p",{className:"text-sm text-foreground",children:"Body text — Regular paragraph content goes here. It uses the foreground color."}),o("p",{className:"text-sm text-foreground-subtle",children:"Subtle text — Secondary/descriptive text with reduced emphasis."}),o("p",{className:"text-xs text-foreground-subtle uppercase tracking-wider font-semibold",children:"Label / Caption"}),o("p",{className:"text-xs text-foreground-disabled",children:"Disabled / placeholder text"})]})}),o(cn,{title:"Colors",children:f("div",{className:"flex flex-wrap gap-4",children:[o(st,{name:"primary",cssVar:"--color-primary"}),o(st,{name:"background",cssVar:"--color-background"}),o(st,{name:"surface",cssVar:"--color-surface"}),o(st,{name:"foreground",cssVar:"--color-foreground"}),o(st,{name:"success",cssVar:"--color-success"}),o(st,{name:"warning",cssVar:"--color-warning"}),o(st,{name:"danger",cssVar:"--color-danger"}),o(st,{name:"info",cssVar:"--color-info"}),o(st,{name:"border",cssVar:"--color-border"}),o("div",{className:"w-px"}),o(st,{name:"frigate",hex:"#3b82f6"}),o(st,{name:"scrypted",hex:"#a855f7"}),o(st,{name:"reolink",hex:"#06b6d4"}),o(st,{name:"ha",hex:"#22d3ee"}),o(st,{name:"rtsp",hex:"#78716c"})]})}),o(cn,{title:"Buttons",children:f("div",{className:"flex flex-wrap gap-3",children:[o("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"}),o("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"}),o("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"}),o("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"}),o("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"}),o("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"})]})}),o(cn,{title:"Inputs",children:f("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[f("div",{children:[o("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Text input"}),o("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..."})]}),f("div",{children:[o("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Number input"}),o("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"})]}),f("div",{children:[o("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Password input"}),o("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:"••••••••"})]}),f("div",{children:[o("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Select"}),f("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:[o("option",{children:"Option A"}),o("option",{children:"Option B"}),o("option",{children:"Option C"})]})]}),f("div",{className:"md:col-span-2",children:[o("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Textarea"}),o("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})]}),o("div",{children:f("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[o("input",{type:"checkbox",className:"h-3.5 w-3.5 rounded border-border accent-primary",defaultChecked:!0}),o("span",{className:"text-xs font-medium text-foreground",children:"Checkbox (checked)"})]})}),o("div",{children:f("div",{className:"flex items-center justify-between",children:[o("span",{className:"text-xs font-medium text-foreground",children:"Toggle switch"}),o(IZ,{})]})}),f("div",{children:[o("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Slider"}),o("input",{type:"range",className:"w-full h-1 accent-primary cursor-pointer",min:0,max:100,defaultValue:60})]}),f("div",{children:[o("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Tags example"}),o("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=>o("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))})]})]})}),o(cn,{title:"Badges",children:f("div",{className:"space-y-3",children:[f("div",{children:[o("p",{className:"text-xs text-foreground-subtle mb-2",children:"StatusBadge"}),o("div",{className:"flex flex-wrap gap-2",children:["running","stopped","error","online","offline","idle"].map(n=>o(ni,{status:n},n))})]}),f("div",{children:[o("p",{className:"text-xs text-foreground-subtle mb-2",children:"CapabilityBadges"}),o(ei,{capabilities:["streaming","detection","recording","audio"]})]})]})}),o(cn,{title:"Cards",children:f("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[f("div",{className:"rounded-lg bg-surface p-4",children:[o("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Surface card"}),o("p",{className:"text-xs text-foreground-subtle",children:"Uses `bg-surface`. Default card background."})]}),f("div",{className:"rounded-lg border border-border bg-surface p-4",children:[o("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Bordered card"}),o("p",{className:"text-xs text-foreground-subtle",children:"Uses `border border-border bg-surface`."})]}),f("div",{className:"rounded-lg border border-primary/30 bg-primary/5 p-4",children:[o("h3",{className:"text-sm font-semibold text-primary mb-1",children:"Accent card"}),o("p",{className:"text-xs text-foreground-subtle",children:"Highlighted with primary color."})]}),f("div",{className:"rounded-lg bg-background p-4",children:[o("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Background card"}),o("p",{className:"text-xs text-foreground-subtle",children:"Uses `bg-background`. Inset card."})]})]})}),o(cn,{title:"Provider Icons",children:o("div",{className:"flex flex-wrap gap-4",children:["frigate","scrypted","reolink","homeassistant","rtsp","onvif"].map(n=>o(bn,{type:n,size:"lg",showLabel:!0},n))})}),f(cn,{title:"Form Builder Demo",children:[o($n,{schema:MZ,values:e,onChange:t}),f("details",{className:"mt-3",children:[o("summary",{className:"text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground",children:"View current values"}),o("pre",{className:"mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto",children:JSON.stringify(e,null,2)})]})]}),o(cn,{title:"Info Boxes",children:o("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:r,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 f("div",{className:`rounded-md border-l-4 px-3 py-2.5 ${i.border} ${i.bg}`,children:[o("p",{className:`text-xs font-semibold mb-0.5 ${i.text}`,children:r}),o("p",{className:"text-xs text-foreground-subtle leading-relaxed",children:s})]},n)})})})]})}function IZ(){const[e,t]=_(!0);return o("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:o("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 Gh={info:{bg:"bg-blue-500/10",border:"border-blue-500/30",icon:rr},warning:{bg:"bg-orange-500/10",border:"border-orange-500/30",icon:tt},critical:{bg:"bg-red-500/10",border:"border-red-500/30",icon:nr}};function AZ({toast:e,onDismiss:t}){const n=Gh[e.severity]??Gh.info,r=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]),f("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:[o(r,{className:"h-4 w-4 shrink-0 mt-0.5 text-foreground-subtle"}),f("div",{className:"flex-1 min-w-0",children:[o("div",{className:"text-xs font-semibold text-foreground",children:e.title}),o("div",{className:"text-[11px] text-foreground-subtle mt-0.5",children:e.message})]}),o("button",{type:"button",onClick:()=>t(e.id),className:"shrink-0 p-0.5 rounded hover:bg-surface-hover transition-colors",children:o(Fe,{className:"h-3.5 w-3.5 text-foreground-subtle"})})]})}function PZ(){const[e,t]=_([]),n=U(r=>{t(s=>s.filter(a=>a.id!==r))},[]);return w0(void 0,{onData:r=>{const s=r,a=`toast-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;t(i=>[...i,{...s,id:a,timestamp:Date.now()}])}}),e.length===0?null:o("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(r=>o("div",{className:"pointer-events-auto",children:o(AZ,{toast:r,onDismiss:n})},r.id))})}const kc=new em({defaultOptions:{queries:{staleTime:3e4,retry:!1,refetchOnWindowFocus:!1}}});function _Z({field:e,value:t,onChange:n,disabled:r}){return o(d8,{field:e,value:t,onChange:n,disabled:r})}function $Z({field:e,value:t,onChange:n,disabled:r}){return o(v8,{field:e,value:t,onChange:n,disabled:r})}const DZ={"zone-editor":o8,"live-stats":a8,"pipeline-editor":_Z,"model-selector":$Z,"live-stream-viewer":N8,"pipeline-stats":k8,"stream-network-stats":S8,"doorbell-recent":M8,"device-info":av};function LZ({children:e}){const{user:t}=rn(),[n,r]=_(0),s=te(t?.username??null);Y(()=>{const p=t?.username??null;p!==s.current&&(s.current=p,Sr(),r(h=>h+1))},[t]);const a=q(()=>Us(),[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)},h=>{if(p)return;const m=h instanceof Error?h.message:String(h);d(m),l(!0)}),()=>{p=!0}},[a,t]);const u=U(()=>{Sr(),r(p=>p+1),kc.invalidateQueries()},[]);return lR(u),o(Gc,{system:a,children:o(S.Provider,{client:a.trpcClient,queryClient:kc,children:f(O0,{children:[i?e:o(TZ,{}),i&&o(e8,{}),c!==null&&i&&f("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 TZ(){return o("div",{className:"flex min-h-screen items-center justify-center bg-background",children:f("div",{className:"flex items-center gap-3 text-sm text-foreground-subtle",children:[o("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary"}),"Connecting…"]})})}function RZ(){return o(Xs,{defaultMode:"dark",children:o(tm,{client:kc,children:o(H8,{children:o(LZ,{children:o(Lg,{children:f(eb,{renderers:DZ,children:[o(ZT,{children:f(MT,{children:[o(Te,{path:"/login",element:o(Q9,{})}),o(Te,{path:"/change-password",element:o(Dt,{children:o(K9,{})})}),o(Te,{path:"/showroom",element:o(EZ,{})}),f(Te,{element:o(Dt,{children:o(U9,{})}),children:[o(Te,{index:!0,element:o(kt,{to:"/dashboard",replace:!0})}),o(Te,{path:"/access-denied",element:o(W9,{})}),o(Te,{path:"/dashboard",element:o(a7,{})}),o(Te,{path:"/devices",element:o(i7,{})}),o(Te,{path:"/cameras",element:o(kt,{to:"/devices",replace:!0})}),o(Te,{path:"/integrations",element:o(x7,{})}),o(Te,{path:"/integrations/:integrationId",element:o(w7,{})}),o(Te,{path:"/timeline",element:o(_7,{})}),o(Te,{path:"/pipeline",element:o(pB,{})}),o(Te,{path:"/devices/:deviceId",element:o(uz,{})}),o(Te,{path:"/system/logs",element:o(Dt,{requireAdmin:!0,children:o($z,{})})}),o(Te,{path:"/system/addons",element:o(Dt,{requireAdmin:!0,children:o(Mz,{})})}),o(Te,{path:"/system/settings",element:o(Dt,{requireAdmin:!0,children:o(bj,{})})}),o(Te,{path:"/system/cluster",element:o(Dt,{requireAdmin:!0,children:o(CZ,{})})}),o(Te,{path:"/system/identity",element:o(Dt,{requireAdmin:!0,children:o(Wz,{})})}),o(Te,{path:"/system/my-access",element:o(Az,{})}),o(Te,{path:"/system/network",element:o(Dt,{requireAdmin:!0,children:o(mF,{})})}),o(Te,{path:"/system/integrations",element:o(Dt,{requireAdmin:!0,children:o(AF,{})})}),o(Te,{path:"/system/data",element:o(Dt,{requireAdmin:!0,children:o(gj,{})})}),o(Te,{path:"/system/users",element:o(kt,{to:"/system/identity?tab=users",replace:!0})}),o(Te,{path:"/system/api-keys",element:o(kt,{to:"/system/identity?tab=api-keys",replace:!0})}),o(Te,{path:"/system/authentication",element:o(kt,{to:"/system/identity?tab=authentication",replace:!0})}),o(Te,{path:"/system/remote-access",element:o(kt,{to:"/system/network?tab=remote-access",replace:!0})}),o(Te,{path:"/system/turn",element:o(kt,{to:"/system/network?tab=turn",replace:!0})}),o(Te,{path:"/system/storage",element:o(kt,{to:"/system/data?tab=storage",replace:!0})}),o(Te,{path:"/system/backup",element:o(kt,{to:"/system/data?tab=backup",replace:!0})}),o(Te,{path:"/addon/:pagePath",element:o(Dt,{requireAdmin:!0,children:o(V9,{})})})]})]})}),o(PZ,{})]})})})})})})}const OZ={dashboard:"Dashboard",integrations:"Integrations",metrics:"Metrics"},BZ={title:"System",addons:"Addons",agents:"Agents",processes:"Processes",logs:"Logs",users:"Users",settings:"Settings",repl:"REPL",models:"Models",integrations:"Integrations"},zZ={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"},FZ={disconnected:"Server unreachable — reconnecting…",connected:"Connected"},jZ={online:"Online",offline:"Offline",connecting:"Connecting",error:"Error",disabled:"Disabled",enabled:"Enabled",active:"Active",inactive:"Inactive",running:"Running",stopped:"Stopped",pending:"Pending",unknown:"Unknown"},VZ={login:"Login",logout:"Logout",username:"Username",password:"Password",signIn:"Sign In",invalidCredentials:"Invalid username or password"},HZ={dark:"Dark",light:"Light",system:"System"},qZ={select:"Language",en:"English",it:"Italian"},UZ={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"}},QZ={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"},GZ={nav:OZ,system:BZ,common:zZ,connection:FZ,status:jZ,auth:VZ,theme:HZ,language:qZ,pages:UZ,integrations:QZ},KZ={dashboard:"Dashboard",integrations:"Integrazioni",metrics:"Metriche"},WZ={title:"Sistema",addons:"Addon",agents:"Agenti",processes:"Processi",logs:"Log",users:"Utenti",settings:"Impostazioni",repl:"REPL",models:"Modelli",integrations:"Integrazioni"},YZ={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"},ZZ={disconnected:"Server non raggiungibile — riconnessione in corso…",connected:"Connesso"},XZ={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"},JZ={login:"Accesso",logout:"Esci",username:"Nome utente",password:"Password",signIn:"Accedi",invalidCredentials:"Nome utente o password non validi"},eX={dark:"Scuro",light:"Chiaro",system:"Sistema"},tX={select:"Lingua",en:"Inglese",it:"Italiano"},nX={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"}},rX={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"},oX={nav:KZ,system:WZ,common:YZ,connection:ZZ,status:XZ,auth:JZ,theme:eX,language:tX,pages:nX,integrations:rX},rN="camstack_language",sX=localStorage.getItem(rN)??"en";et.use(k9).init({resources:{en:{translation:GZ},it:{translation:oX}},lng:sX,fallbackLng:"en",interpolation:{escapeValue:!1}});et.on("languageChanged",e=>{localStorage.setItem(rN,e)});window.__camstackUiLibrary=CL;window.__camstackSdk=v2;window.__camstackTypes=N2;Xh(document.getElementById("root")).render(o(i2,{children:o(RZ,{})}));
|