@camstack/addon-admin-ui 0.1.31 → 0.1.32
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-BMrP2H8p.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BvoC1uIr.js} +1 -1
- package/dist/assets/{devices-CZsVkxKZ.js → devices-CcY42G4T.js} +1 -1
- package/dist/assets/{hostInit-DIOhqSQ8.js → hostInit-CD-dnMZ2.js} +1 -1
- package/dist/assets/{index-B7F0mwMZ.js → index-BNUjZ59A.js} +1 -1
- package/dist/assets/index-BpxWBuRz.js +1 -0
- package/dist/assets/index-C8aWpOFF.js +1 -0
- package/dist/assets/index-C9g_lFQt.css +1 -0
- package/dist/assets/index-CC-f1IDN.js +1 -0
- package/dist/assets/{index-DUfO0e8s.js → index-CKhqqfAc.js} +25 -25
- package/dist/assets/{index-DSFtUS7Z.js → index-DSlV9M7V.js} +1 -1
- package/dist/assets/{index-B4mdRb1N.js → index-Dof0D05-.js} +1 -1
- package/dist/assets/{index-B3ayOsQz.js → index-Dq8saJUq.js} +24 -24
- package/dist/assets/index-Dyl6moOt.js +1128 -0
- package/dist/assets/{index-Dc2Moq2w.js → index-XLuKU1k9.js} +1 -1
- package/dist/assets/index-dYszggWP.js +1 -0
- package/dist/assets/method-access-map-DMzoJQA1.js +1 -0
- package/dist/assets/{remoteEntry-6Pin_7dI.js → remoteEntry-E_9jWgvF.js} +1 -1
- package/dist/assets/{schemas-XgIEoUz3.js → schemas-DZqswtjx.js} +4 -4
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-8g-kqXK4.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-FAYxIu3o.js} +2 -2
- package/dist/index.html +7 -7
- package/dist/mf-entry-bootstrap-0.js +2 -2
- package/dist/server/addon.js +2 -2
- package/dist/server/addon.js.map +1 -1
- package/dist/sw.js +1 -1
- package/package.json +1 -1
- package/dist/assets/index-4wFotr3p.js +0 -1
- package/dist/assets/index-CMnchRgf.css +0 -1
- package/dist/assets/index-DJIpFuqj.js +0 -1
- package/dist/assets/index-FDG6Ru4K.js +0 -1
- package/dist/assets/index-Z_9-zlb_.js +0 -1
- package/dist/assets/index-lh_RKGLY.js +0 -1118
- package/dist/assets/method-access-map-D3ooxuVS.js +0 -1
|
@@ -1,1118 +0,0 @@
|
|
|
1
|
-
import"./virtualExposes-_ivNhQLP.js";import{d as wr}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-8g-kqXK4.js";import{c as o,a as mh,d as u,e as me,g as oN}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-C_6K4VBY.js";import{b as Oe,e as _,h as U,c as Y,f as q,d as ve,a as gh,j as qe,k as Me,i as ne,l as Nr,m as fa,g as ha,R as ec,n as tc,o as sN,p as aN,q as kr,r as je,s as iN,t as lN,u as cN,v as dN}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-Dl4u0xYE.js";import{a as bh,b as _o}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-CzO_Esxm.js";import{a as xh,b as yh}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-DNpf5SLz.js";import{_ as vh,m as Jn,n as ke,o as wh,p as Nh,h as nc,j as uN}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-CeLhKMin.js";import{_ as kh,c as Sh,s as Ch,n as pN,B as fN,F as hN}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.mjs-DIkg6-MH.js";import{_ as Mh,a as mN}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-OcRSBqRe.js";import{c as gN,D as Hn,a as at,M as bN,W as ol,S as Ss}from"./index-DJIpFuqj.js";import{S as sl,c as Eh}from"./devices-CZsVkxKZ.js";import{E as Ne,A as xN,K as yN}from"./method-access-map-D3ooxuVS.js";import{s as vN}from"./index-B7F0mwMZ.js";import{a as au,S as iu,s as wN}from"./index-FDG6Ru4K.js";import{r as Ih}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-CSyOECfO.js";import{_ as NN}from"./preload-helper-BlTxHScW.js";import"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-xw6c6JeS.js";import"./schemas-XgIEoUz3.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))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 Ah={frigate:"#3b82f6",scrypted:"#a855f7",reolink:"#06b6d4",homeAssistant:"#22d3ee",rtsp:"#78716c"},_h={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:Ah},Ph={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:Ah},al={colors:{dark:_h,light:Ph},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 $h(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]=$h(a,s):s!==void 0&&(n[r]=s)}return n}function kN(e){return e?$h(structuredClone(al),e):structuredClone(al)}function Dh(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function SN(e){return`--color-${Dh(e)}`}function lu(e){const t=[];for(const[n,r]of Object.entries(e))n!=="provider"&&t.push(` ${SN(n)}: ${r};`);return t.join(`
|
|
2
|
-
`)}function CN(e){const t=[];for(const[n,r]of Object.entries(e))t.push(` --color-provider-${Dh(n)}: ${r};`);return t.join(`
|
|
3
|
-
`)}function MN(e){const t=[];for(const[n,r]of Object.entries(e))t.push(` --spacing-${n}: ${r}px;`);return t.join(`
|
|
4
|
-
`)}function EN(e){const t=[];for(const[n,r]of Object.entries(e))t.push(` --radius-${n}: ${r}px;`);return t.join(`
|
|
5
|
-
`)}function IN(e){const t=lu(e.colors.dark),n=lu(e.colors.light),r=CN(e.colors.dark.provider),s=MN(e.spacing),a=EN(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 Th=Oe(null),oi=["dark","light","system"];function Lh(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function AN(e,t){if(typeof window>"u")return t;const n=localStorage.getItem(e);return n==="dark"||n==="light"||n==="system"?n:t}function cu(e){return e==="system"?Lh():e}function Rs({children:e,defaultMode:t="system",storageKey:n="camstack-theme-mode"}){const[r,s]=_(()=>AN(n,t)),[a,i]=_(()=>cu(r)),l=U(f=>{s(f),i(cu(f)),typeof window<"u"&&localStorage.setItem(n,f)},[n]),c=U(()=>{const p=(oi.indexOf(r)+1)%oi.length;l(oi[p]??"dark")},[r,l]);Y(()=>{if(typeof document>"u")return;const f=document.documentElement;f.classList.remove("dark","light"),f.classList.add(a)},[r,a]),Y(()=>{if(typeof window>"u"||r!=="system")return;const f=window.matchMedia("(prefers-color-scheme: dark)"),p=()=>{i(Lh())};return f.addEventListener("change",p),()=>f.removeEventListener("change",p)},[r]);const d=q(()=>({mode:r,resolvedMode:a,setMode:l,toggleMode:c}),[r,a,l,c]);return o(Th.Provider,{value:d,children:e})}function Rr(){const e=ve(Th);if(!e)throw new Error("useThemeMode must be used within a ThemeProvider");return e}function Rh(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=Rh(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Oh(){for(var e,t,n=0,r="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=Rh(e))&&(r&&(r+=" "),r+=t);return r}const _N=(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},PN=(e,t)=>({classGroupId:e,validator:t}),zh=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Os="-",du=[],$N="arbitrary..",DN=e=>{const t=LN(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return TN(i);const l=i.split(Os),c=l[0]===""&&l.length>1?1:0;return Bh(l,c,t)},getConflictingClassGroupIds:(i,l)=>{if(l){const c=r[i],d=n[i];return c?d?_N(d,c):c:d||du}return n[i]||du}}},Bh=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const s=e[t],a=n.nextPart.get(s);if(a){const d=Bh(e,t+1,a);if(d)return d}const i=n.validators;if(i===null)return;const l=t===0?e.join(Os):e.slice(t).join(Os),c=i.length;for(let d=0;d<c;d++){const f=i[d];if(f.validator(l))return f.classGroupId}},TN=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?$N+r:void 0})(),LN=e=>{const{theme:t,classGroups:n}=e;return RN(n,t)},RN=(e,t)=>{const n=zh();for(const r in e){const s=e[r];rc(s,n,r,t)}return n},rc=(e,t,n,r)=>{const s=e.length;for(let a=0;a<s;a++){const i=e[a];ON(i,t,n,r)}},ON=(e,t,n,r)=>{if(typeof e=="string"){zN(e,t,n);return}if(typeof e=="function"){BN(e,t,n,r);return}FN(e,t,n,r)},zN=(e,t,n)=>{const r=e===""?t:Fh(t,e);r.classGroupId=n},BN=(e,t,n,r)=>{if(jN(e)){rc(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(PN(n,e))},FN=(e,t,n,r)=>{const s=Object.entries(e),a=s.length;for(let i=0;i<a;i++){const[l,c]=s[i];rc(c,Fh(t,l),n,r)}},Fh=(e,t)=>{let n=e;const r=t.split(Os),s=r.length;for(let a=0;a<s;a++){const i=r[a];let l=n.nextPart.get(i);l||(l=zh(),n.nextPart.set(i,l)),n=l}return n},jN=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,HN=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)}}},il="!",uu=":",VN=[],pu=(e,t,n,r,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:s}),qN=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=s=>{const a=[];let i=0,l=0,c=0,d;const f=s.length;for(let b=0;b<f;b++){const x=s[b];if(i===0&&l===0){if(x===uu){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(il)?(h=p.slice(0,-1),m=!0):p.startsWith(il)&&(h=p.slice(1),m=!0);const g=d&&d>c?d-c:void 0;return pu(a,m,h,g)};if(t){const s=t+uu,a=r;r=i=>i.startsWith(s)?a(i.slice(s.length)):pu(VN,!1,i,void 0,!0)}if(n){const s=r;r=a=>n({className:a,parseClassName:s})}return r},UN=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}},QN=e=>({cache:HN(e.cacheSize),parseClassName:qN(e),sortModifiers:UN(e),...DN(e)}),KN=/\s+/,GN=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:s,sortModifiers:a}=t,i=[],l=e.trim().split(KN);let c="";for(let d=l.length-1;d>=0;d-=1){const f=l[d],{isExternal:p,modifiers:h,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:b}=n(f);if(p){c=f+(c.length>0?" "+c:c);continue}let x=!!b,y=r(x?g.substring(0,b):g);if(!y){if(!x){c=f+(c.length>0?" "+c:c);continue}if(y=r(g),!y){c=f+(c.length>0?" "+c:c);continue}x=!1}const w=h.length===0?"":h.length===1?h[0]:a(h).join(":"),v=m?w+il:w,N=v+y;if(i.indexOf(N)>-1)continue;i.push(N);const k=s(y,x);for(let S=0;S<k.length;++S){const E=k[S];i.push(v+E)}c=f+(c.length>0?" "+c:c)}return c},WN=(...e)=>{let t=0,n,r,s="";for(;t<e.length;)(n=e[t++])&&(r=jh(n))&&(s&&(s+=" "),s+=r);return s},jh=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=jh(e[r]))&&(n&&(n+=" "),n+=t);return n},YN=(e,...t)=>{let n,r,s,a;const i=c=>{const d=t.reduce((f,p)=>p(f),e());return n=QN(d),r=n.cache.get,s=n.cache.set,a=l,l(c)},l=c=>{const d=r(c);if(d)return d;const f=GN(c,n);return s(c,f),f};return a=i,(...c)=>a(WN(...c))},ZN=[],Ke=e=>{const t=n=>n[e]||ZN;return t.isThemeGetter=!0,t},Hh=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Vh=/^\((?:(\w[\w-]*):)?(.+)\)$/i,XN=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,JN=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,e2=/\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$/,t2=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,n2=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,r2=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,bn=e=>XN.test(e),Ae=e=>!!e&&!Number.isNaN(Number(e)),xn=e=>!!e&&Number.isInteger(Number(e)),si=e=>e.endsWith("%")&&Ae(e.slice(0,-1)),Xt=e=>JN.test(e),qh=()=>!0,o2=e=>e2.test(e)&&!t2.test(e),oc=()=>!1,s2=e=>n2.test(e),a2=e=>r2.test(e),i2=e=>!xe(e)&&!ye(e),l2=e=>An(e,Kh,oc),xe=e=>Hh.test(e),Rn=e=>An(e,Gh,o2),fu=e=>An(e,g2,Ae),c2=e=>An(e,Yh,qh),d2=e=>An(e,Wh,oc),hu=e=>An(e,Uh,oc),u2=e=>An(e,Qh,a2),Wo=e=>An(e,Zh,s2),ye=e=>Vh.test(e),Gr=e=>er(e,Gh),p2=e=>er(e,Wh),mu=e=>er(e,Uh),f2=e=>er(e,Kh),h2=e=>er(e,Qh),Yo=e=>er(e,Zh,!0),m2=e=>er(e,Yh,!0),An=(e,t,n)=>{const r=Hh.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},er=(e,t,n=!1)=>{const r=Vh.exec(e);return r?r[1]?t(r[1]):n:!1},Uh=e=>e==="position"||e==="percentage",Qh=e=>e==="image"||e==="url",Kh=e=>e==="length"||e==="size"||e==="bg-size",Gh=e=>e==="length",g2=e=>e==="number",Wh=e=>e==="family-name",Yh=e=>e==="number"||e==="weight",Zh=e=>e==="shadow",b2=()=>{const e=Ke("color"),t=Ke("font"),n=Ke("text"),r=Ke("font-weight"),s=Ke("tracking"),a=Ke("leading"),i=Ke("breakpoint"),l=Ke("container"),c=Ke("spacing"),d=Ke("radius"),f=Ke("shadow"),p=Ke("inset-shadow"),h=Ke("text-shadow"),m=Ke("drop-shadow"),g=Ke("blur"),b=Ke("perspective"),x=Ke("aspect"),y=Ke("ease"),w=Ke("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],S=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto","contain","none"],A=()=>[ye,xe,c],I=()=>[bn,"full","auto",...A()],B=()=>[xn,"none","subgrid",ye,xe],$=()=>["auto",{span:["full",xn,ye,xe]},xn,ye,xe],z=()=>[xn,"auto",ye,xe],R=()=>["auto","min","max","fr",ye,xe],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],T=()=>["start","end","center","stretch","center-safe","end-safe"],P=()=>["auto",...A()],L=()=>[bn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...A()],O=()=>[bn,"screen","full","dvw","lvw","svw","min","max","fit",...A()],j=()=>[bn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...A()],F=()=>[e,ye,xe],H=()=>[...N(),mu,hu,{position:[ye,xe]}],D=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Q=()=>["auto","cover","contain",f2,l2,{size:[ye,xe]}],K=()=>[si,Gr,Rn],ee=()=>["","none","full",d,ye,xe],oe=()=>["",Ae,Gr,Rn],te=()=>["solid","dashed","dotted","double"],Z=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],re=()=>[Ae,si,mu,hu],be=()=>["","none",g,ye,xe],X=()=>["none",Ae,ye,xe],G=()=>["none",Ae,ye,xe],J=()=>[Ae,ye,xe],ae=()=>[bn,"full",...A()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Xt],breakpoint:[Xt],color:[qh],container:[Xt],"drop-shadow":[Xt],ease:["in","out","in-out"],font:[i2],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Xt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Xt],shadow:[Xt],spacing:["px",Ae],text:[Xt],"text-shadow":[Xt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",bn,xe,ye,x]}],container:["container"],columns:[{columns:[Ae,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:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],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:[xn,"auto",ye,xe]}],basis:[{basis:[bn,"full","auto",l,...A()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ae,bn,"auto","initial","none",xe]}],grow:[{grow:["",Ae,ye,xe]}],shrink:[{shrink:["",Ae,ye,xe]}],order:[{order:[xn,"first","last","none",ye,xe]}],"grid-cols":[{"grid-cols":B()}],"col-start-end":[{col:$()}],"col-start":[{"col-start":z()}],"col-end":[{"col-end":z()}],"grid-rows":[{"grid-rows":B()}],"row-start-end":[{row:$()}],"row-start":[{"row-start":z()}],"row-end":[{"row-end":z()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:A()}],"gap-x":[{"gap-x":A()}],"gap-y":[{"gap-y":A()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...T(),"normal"]}],"justify-self":[{"justify-self":["auto",...T()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...T(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...T(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...T(),"baseline"]}],"place-self":[{"place-self":["auto",...T()]}],p:[{p:A()}],px:[{px:A()}],py:[{py:A()}],ps:[{ps:A()}],pe:[{pe:A()}],pbs:[{pbs:A()}],pbe:[{pbe:A()}],pt:[{pt:A()}],pr:[{pr:A()}],pb:[{pb:A()}],pl:[{pl:A()}],m:[{m:P()}],mx:[{mx:P()}],my:[{my:P()}],ms:[{ms:P()}],me:[{me:P()}],mbs:[{mbs:P()}],mbe:[{mbe:P()}],mt:[{mt:P()}],mr:[{mr:P()}],mb:[{mb:P()}],ml:[{ml:P()}],"space-x":[{"space-x":A()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":A()}],"space-y-reverse":["space-y-reverse"],size:[{size:L()}],"inline-size":[{inline:["auto",...O()]}],"min-inline-size":[{"min-inline":["auto",...O()]}],"max-inline-size":[{"max-inline":["none",...O()]}],"block-size":[{block:["auto",...j()]}],"min-block-size":[{"min-block":["auto",...j()]}],"max-block-size":[{"max-block":["none",...j()]}],w:[{w:[l,"screen",...L()]}],"min-w":[{"min-w":[l,"screen","none",...L()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...L()]}],h:[{h:["screen","lh",...L()]}],"min-h":[{"min-h":["screen","lh","none",...L()]}],"max-h":[{"max-h":["screen","lh",...L()]}],"font-size":[{text:["base",n,Gr,Rn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,m2,c2]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",si,xe]}],"font-family":[{font:[p2,d2,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":[Ae,"none",ye,fu]}],leading:[{leading:[a,...A()]}],"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:F()}],"text-color":[{text:F()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...te(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ae,"from-font","auto",ye,Rn]}],"text-decoration-color":[{decoration:F()}],"underline-offset":[{"underline-offset":[Ae,"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:A()}],"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:H()}],"bg-repeat":[{bg:D()}],"bg-size":[{bg:Q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},xn,ye,xe],radial:["",ye,xe],conic:[xn,ye,xe]},h2,u2]}],"bg-color":[{bg:F()}],"gradient-from-pos":[{from:K()}],"gradient-via-pos":[{via:K()}],"gradient-to-pos":[{to:K()}],"gradient-from":[{from:F()}],"gradient-via":[{via:F()}],"gradient-to":[{to:F()}],rounded:[{rounded:ee()}],"rounded-s":[{"rounded-s":ee()}],"rounded-e":[{"rounded-e":ee()}],"rounded-t":[{"rounded-t":ee()}],"rounded-r":[{"rounded-r":ee()}],"rounded-b":[{"rounded-b":ee()}],"rounded-l":[{"rounded-l":ee()}],"rounded-ss":[{"rounded-ss":ee()}],"rounded-se":[{"rounded-se":ee()}],"rounded-ee":[{"rounded-ee":ee()}],"rounded-es":[{"rounded-es":ee()}],"rounded-tl":[{"rounded-tl":ee()}],"rounded-tr":[{"rounded-tr":ee()}],"rounded-br":[{"rounded-br":ee()}],"rounded-bl":[{"rounded-bl":ee()}],"border-w":[{border: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:[...te(),"hidden","none"]}],"divide-style":[{divide:[...te(),"hidden","none"]}],"border-color":[{border:F()}],"border-color-x":[{"border-x":F()}],"border-color-y":[{"border-y":F()}],"border-color-s":[{"border-s":F()}],"border-color-e":[{"border-e":F()}],"border-color-bs":[{"border-bs":F()}],"border-color-be":[{"border-be":F()}],"border-color-t":[{"border-t":F()}],"border-color-r":[{"border-r":F()}],"border-color-b":[{"border-b":F()}],"border-color-l":[{"border-l":F()}],"divide-color":[{divide:F()}],"outline-style":[{outline:[...te(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ae,ye,xe]}],"outline-w":[{outline:["",Ae,Gr,Rn]}],"outline-color":[{outline:F()}],shadow:[{shadow:["","none",f,Yo,Wo]}],"shadow-color":[{shadow:F()}],"inset-shadow":[{"inset-shadow":["none",p,Yo,Wo]}],"inset-shadow-color":[{"inset-shadow":F()}],"ring-w":[{ring:oe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:F()}],"ring-offset-w":[{"ring-offset":[Ae,Rn]}],"ring-offset-color":[{"ring-offset":F()}],"inset-ring-w":[{"inset-ring":oe()}],"inset-ring-color":[{"inset-ring":F()}],"text-shadow":[{"text-shadow":["none",h,Yo,Wo]}],"text-shadow-color":[{"text-shadow":F()}],opacity:[{opacity:[Ae,ye,xe]}],"mix-blend":[{"mix-blend":[...Z(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Z()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ae]}],"mask-image-linear-from-pos":[{"mask-linear-from":re()}],"mask-image-linear-to-pos":[{"mask-linear-to":re()}],"mask-image-linear-from-color":[{"mask-linear-from":F()}],"mask-image-linear-to-color":[{"mask-linear-to":F()}],"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":F()}],"mask-image-t-to-color":[{"mask-t-to":F()}],"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":F()}],"mask-image-r-to-color":[{"mask-r-to":F()}],"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":F()}],"mask-image-b-to-color":[{"mask-b-to":F()}],"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":F()}],"mask-image-l-to-color":[{"mask-l-to":F()}],"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":F()}],"mask-image-x-to-color":[{"mask-x-to":F()}],"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":F()}],"mask-image-y-to-color":[{"mask-y-to":F()}],"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":F()}],"mask-image-radial-to-color":[{"mask-radial-to":F()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":N()}],"mask-image-conic-pos":[{"mask-conic":[Ae]}],"mask-image-conic-from-pos":[{"mask-conic-from":re()}],"mask-image-conic-to-pos":[{"mask-conic-to":re()}],"mask-image-conic-from-color":[{"mask-conic-from":F()}],"mask-image-conic-to-color":[{"mask-conic-to":F()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:D()}],"mask-size":[{mask:Q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ye,xe]}],filter:[{filter:["","none",ye,xe]}],blur:[{blur:be()}],brightness:[{brightness:[Ae,ye,xe]}],contrast:[{contrast:[Ae,ye,xe]}],"drop-shadow":[{"drop-shadow":["","none",m,Yo,Wo]}],"drop-shadow-color":[{"drop-shadow":F()}],grayscale:[{grayscale:["",Ae,ye,xe]}],"hue-rotate":[{"hue-rotate":[Ae,ye,xe]}],invert:[{invert:["",Ae,ye,xe]}],saturate:[{saturate:[Ae,ye,xe]}],sepia:[{sepia:["",Ae,ye,xe]}],"backdrop-filter":[{"backdrop-filter":["","none",ye,xe]}],"backdrop-blur":[{"backdrop-blur":be()}],"backdrop-brightness":[{"backdrop-brightness":[Ae,ye,xe]}],"backdrop-contrast":[{"backdrop-contrast":[Ae,ye,xe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ae,ye,xe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ae,ye,xe]}],"backdrop-invert":[{"backdrop-invert":["",Ae,ye,xe]}],"backdrop-opacity":[{"backdrop-opacity":[Ae,ye,xe]}],"backdrop-saturate":[{"backdrop-saturate":[Ae,ye,xe]}],"backdrop-sepia":[{"backdrop-sepia":["",Ae,ye,xe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":A()}],"border-spacing-x":[{"border-spacing-x":A()}],"border-spacing-y":[{"border-spacing-y":A()}],"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:[Ae,"initial",ye,xe]}],ease:[{ease:["linear","initial",y,ye,xe]}],delay:[{delay:[Ae,ye,xe]}],animate:[{animate:["none",w,ye,xe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,ye,xe]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:X()}],"rotate-x":[{"rotate-x":X()}],"rotate-y":[{"rotate-y":X()}],"rotate-z":[{"rotate-z":X()}],scale:[{scale:G()}],"scale-x":[{"scale-x":G()}],"scale-y":[{"scale-y":G()}],"scale-z":[{"scale-z":G()}],"scale-3d":["scale-3d"],skew:[{skew:J()}],"skew-x":[{"skew-x":J()}],"skew-y":[{"skew-y":J()}],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:F()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:F()}],"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":A()}],"scroll-mx":[{"scroll-mx":A()}],"scroll-my":[{"scroll-my":A()}],"scroll-ms":[{"scroll-ms":A()}],"scroll-me":[{"scroll-me":A()}],"scroll-mbs":[{"scroll-mbs":A()}],"scroll-mbe":[{"scroll-mbe":A()}],"scroll-mt":[{"scroll-mt":A()}],"scroll-mr":[{"scroll-mr":A()}],"scroll-mb":[{"scroll-mb":A()}],"scroll-ml":[{"scroll-ml":A()}],"scroll-p":[{"scroll-p":A()}],"scroll-px":[{"scroll-px":A()}],"scroll-py":[{"scroll-py":A()}],"scroll-ps":[{"scroll-ps":A()}],"scroll-pe":[{"scroll-pe":A()}],"scroll-pbs":[{"scroll-pbs":A()}],"scroll-pbe":[{"scroll-pbe":A()}],"scroll-pt":[{"scroll-pt":A()}],"scroll-pr":[{"scroll-pr":A()}],"scroll-pb":[{"scroll-pb":A()}],"scroll-pl":[{"scroll-pl":A()}],"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",...F()]}],"stroke-w":[{stroke:[Ae,Gr,Rn,fu]}],stroke:[{stroke:["none",...F()]}],"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"]}},x2=YN(b2);function W(...e){return x2(Oh(e))}const y2="rounded-lg border border-border bg-surface overflow-hidden",v2="border-b border-border px-3 sm:px-4 py-1.5 sm:py-2",w2="p-2 sm:p-3 lg:p-4",Xh="space-y-3 sm:space-y-4",Jh="gap-2 sm:gap-3",em="px-3 sm:px-4 py-1.5 sm:py-2",N2="grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4",k2="grid grid-cols-1 lg:grid-cols-2",S2="flex flex-col-reverse md:flex-row",C2="w-full md:w-44 lg:w-52 md:flex-shrink-0 border-b md:border-b-0 md:border-l border-border",M2="text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider",E2="text-[11px] sm:text-xs text-foreground",zs="text-[10px] text-foreground-subtle",I2="text-[11px] sm:text-xs font-medium text-foreground",ll="text-base sm:text-lg font-semibold leading-tight text-foreground",A2="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",_2="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",P2="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",$2="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",D2="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",T2="inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors",L2="border-primary/50 bg-primary/15 text-primary",R2="border-border bg-surface text-foreground-subtle hover:bg-surface-hover";function O2(e,t){for(const n of e.slots)for(const r of n.addons)if(r.id===t)return r;return null}function z2(e,t){return e.models.find(n=>n.id===t)??null}function B2(e,t){return e.models.find(n=>!!n.formats[t])??null}function F2(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=O2(r,i);if(!c){a.push({addonId:i,outcome:"skip",modelId:null,reason:"addon not in target catalog",patch:null});continue}const d=z2(c,l.modelId),f=d!==null&&!!d.formats[n.engine.format];let p,h;if(f)p=l.modelId,h="exact";else{const g=B2(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:F2(l.settings,c)};a.push({addonId:i,outcome:h,modelId:p,patch:m})}return a}const cl={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 tr(e){return cl[e]??cl.watching}function fn(e,t){if(typeof globalThis>"u")return Oe(t);const n=globalThis.__camstackSharedContexts,r=n??new Map;n||(globalThis.__camstackSharedContexts=r);const s=r.get(e);if(s)return s;const a=Oe(t);return r.set(e,a),a}function gr(e){const n=(typeof globalThis<"u"?globalThis:void 0)?.[e];return n&&typeof n=="object"?n:{}}const j2={singleton:!0,requiredVersion:!1,eager:!0},Bt=e=>({version:"0.0.0",scope:"default",lib:e,shareConfig:j2}),gu="__mf_module_cache__";function H2(){const e=globalThis,t=e[gu];if(t&&typeof t=="object"){const r=t;return r.share??={},r.remote??={},r}const n={share:{},remote:{}};return e[gu]=n,n}function V2(){const e=H2();e.share.react??=gh,e.share["react-dom"]??=bh,e.share["react-dom/client"]??=xh,e.share["react/jsx-runtime"]??=mh,e.share["@tanstack/react-query"]??=vh,e.share["@trpc/client"]??=kh,e.share["@trpc/react-query"]??=Mh,e.share["@camstack/ui-library"]??=gr("__camstackUiLibrary"),e.share["@camstack/sdk"]??=gr("__camstackSdk"),e.share["@camstack/types"]??=gr("__camstackTypes")}function sc(){V2(),wr.getInstance()===null&&wr.init({name:"admin_ui_host",remotes:[],shared:{react:Bt(()=>gh),"react-dom":Bt(()=>bh),"react-dom/client":Bt(()=>xh),"react/jsx-runtime":Bt(()=>mh),"@tanstack/react-query":Bt(()=>vh),"@trpc/client":Bt(()=>kh),"@trpc/react-query":Bt(()=>Mh),"@camstack/ui-library":Bt(()=>gr("__camstackUiLibrary")),"@camstack/sdk":Bt(()=>gr("__camstackSdk")),"@camstack/types":Bt(()=>gr("__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 nm=(...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 q2=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 U2=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 bu=e=>{const t=U2(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 Q2={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 K2=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 G2=qe(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:i,...l},c)=>Me("svg",{ref:c,...Q2,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:nm("lucide",s),...!a&&!K2(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,f])=>Me(d,f)),...Array.isArray(a)?a:[a]]));/**
|
|
66
|
-
* @license lucide-react v0.576.0 - ISC
|
|
67
|
-
*
|
|
68
|
-
* This source code is licensed under the ISC license.
|
|
69
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
70
|
-
*/const le=(e,t)=>{const n=qe(({className:r,...s},a)=>Me(G2,{ref:a,iconNode:t,className:nm(`lucide-${q2(bu(e))}`,`lucide-${e}`,r),...s}));return n.displayName=bu(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 W2=[["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"}]],Nn=le("activity",W2);/**
|
|
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 Y2=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Z2=le("arrow-down",Y2);/**
|
|
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 X2=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],J2=le("arrow-left",X2);/**
|
|
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 ek=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],tk=le("arrow-right",ek);/**
|
|
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 nk=[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]],ac=le("arrow-up-to-line",nk);/**
|
|
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 rk=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ok=le("arrow-up",rk);/**
|
|
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 sk=[["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"}]],ak=le("battery-full",sk);/**
|
|
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 ik=[["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"}]],lk=le("battery-low",ik);/**
|
|
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 ck=[["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"}]],dk=le("battery-warning",ck);/**
|
|
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 uk=[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],rm=le("battery",uk);/**
|
|
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 pk=[["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"}]],fk=le("bell-ring",pk);/**
|
|
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 hk=[["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"}]],ma=le("bell",hk);/**
|
|
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 mk=[["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"}]],gk=le("bug",mk);/**
|
|
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 bk=[["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"}]],ic=le("camera",bk);/**
|
|
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 xk=[["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"}]],yk=le("cast",xk);/**
|
|
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 vk=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Po=le("check",vk);/**
|
|
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 wk=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],nr=le("chevron-down",wk);/**
|
|
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 Nk=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],kk=le("chevron-left",Nk);/**
|
|
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 Sk=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],_n=le("chevron-right",Sk);/**
|
|
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 Ck=[["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"}]],ga=le("circle-alert",Ck);/**
|
|
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 Mk=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ek=le("circle-check-big",Mk);/**
|
|
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 Ik=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ak=le("circle-check",Ik);/**
|
|
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 _k=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Pk=le("circle-dot",_k);/**
|
|
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 $k=[["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"}]],Dk=le("circle-pause",$k);/**
|
|
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 Tk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],Lk=le("circle-plus",Tk);/**
|
|
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 Rk=[["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"}]],om=le("circle-question-mark",Rk);/**
|
|
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 Ok=[["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"}]],zk=le("circle-x",Ok);/**
|
|
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 Bk=[["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"}]],Fk=le("copy-plus",Bk);/**
|
|
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 jk=[["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"}]],Pn=le("copy",jk);/**
|
|
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 Hk=[["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"}]],Vk=le("cpu",Hk);/**
|
|
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 qk=[["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"}]],sm=le("crosshair",qk);/**
|
|
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 Uk=[["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"}]],Qk=le("database",Uk);/**
|
|
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 Kk=[["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"}]],am=le("door-open",Kk);/**
|
|
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 Gk=[["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"}]],dl=le("download",Gk);/**
|
|
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 Wk=[["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"}]],im=le("ellipsis-vertical",Wk);/**
|
|
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 Yk=[["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"}]],lm=le("external-link",Yk);/**
|
|
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 Zk=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],cm=le("eye-off",Zk);/**
|
|
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 Xk=[["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"}]],$o=le("eye",Xk);/**
|
|
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 Jk=[["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"}]],dm=le("funnel",Jk);/**
|
|
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 e5=[["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"}]],t5=le("grip-horizontal",e5);/**
|
|
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 n5=[["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"}]],um=le("house",n5);/**
|
|
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 r5=[["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"}]],o5=le("image",r5);/**
|
|
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 s5=[["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"}]],a5=le("inbox",s5);/**
|
|
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 i5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],l5=le("info",i5);/**
|
|
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 c5=[["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"}]],d5=le("layout-grid",c5);/**
|
|
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 u5=[["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"}]],pm=le("lightbulb",u5);/**
|
|
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 p5=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Lt=le("loader-circle",p5);/**
|
|
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 f5=[["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"}]],h5=le("locate-fixed",f5);/**
|
|
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 m5=[["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"}]],xu=le("maximize-2",m5);/**
|
|
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 g5=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],b5=le("menu",g5);/**
|
|
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 x5=[["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"}]],fm=le("mic",x5);/**
|
|
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 y5=[["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"}]],yu=le("minimize-2",y5);/**
|
|
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 v5=[["path",{d:"M5 12h14",key:"1ays0h"}]],hm=le("minus",v5);/**
|
|
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 w5=[["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"}]],lc=le("moon",w5);/**
|
|
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 N5=[["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"}]],k5=le("music",N5);/**
|
|
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 S5=[["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"}]],ul=le("network",S5);/**
|
|
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 C5=[["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"}]],M5=le("pencil",C5);/**
|
|
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 E5=[["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"}]],pl=le("play",E5);/**
|
|
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 I5=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Do=le("plus",I5);/**
|
|
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 A5=[["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"}]],_5=le("plug",A5);/**
|
|
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 P5=[["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"}]],$5=le("power-off",P5);/**
|
|
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 D5=[["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"}]],mm=le("radar",D5);/**
|
|
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 T5=[["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"}]],L5=le("radio",T5);/**
|
|
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 R5=[["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"}]],cc=le("refresh-cw",R5);/**
|
|
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 O5=[["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"}]],gm=le("rotate-ccw",O5);/**
|
|
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 z5=[["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"}]],bm=le("rotate-cw",z5);/**
|
|
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 B5=[["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"}]],F5=le("save",B5);/**
|
|
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 j5=[["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"}]],H5=le("scan",j5);/**
|
|
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 V5=[["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"}]],q5=le("scroll-text",V5);/**
|
|
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 U5=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],mo=le("search",U5);/**
|
|
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 Q5=[["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"}]],K5=le("server",Q5);/**
|
|
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 G5=[["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"}]],W5=le("shield",G5);/**
|
|
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 Y5=[["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"}]],Z5=le("ship",Y5);/**
|
|
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 X5=[["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"}]],J5=le("sliders-horizontal",X5);/**
|
|
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 eS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],vu=le("square",eS);/**
|
|
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 tS=[["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"}]],nS=le("star",tS);/**
|
|
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 rS=[["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"}]],xm=le("sun",rS);/**
|
|
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 oS=[["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"}]],sS=le("table-2",oS);/**
|
|
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 aS=[["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"}]],wu=le("target",aS);/**
|
|
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 iS=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],lS=le("thermometer",iS);/**
|
|
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 cS=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],dS=le("toggle-left",cS);/**
|
|
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 uS=[["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"}]],Kt=le("trash-2",uS);/**
|
|
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 pS=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],fS=le("trending-up",pS);/**
|
|
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 hS=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],mS=le("trending-down",hS);/**
|
|
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 gS=[["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"}]],To=le("triangle-alert",gS);/**
|
|
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 bS=[["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"}]],ym=le("upload",bS);/**
|
|
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 xS=[["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"}]],yS=le("wifi-off",xS);/**
|
|
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 vS=[["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"}]],vm=le("wifi",vS);/**
|
|
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 wS=[["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=le("wrench",wS);/**
|
|
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 NS=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],We=le("x",NS);/**
|
|
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 kS=[["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"}]],Nu=le("zap",kS);/**
|
|
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 SS=[["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"}]],CS=le("zoom-in",SS);/**
|
|
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 MS=[["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"}]],ES=le("zoom-out",MS),IS={frigate:Z5,scrypted:W5,reolink:L5,homeAssistant:um,rtsp:yk},AS={online:Ak,offline:zk,degraded:ga,unknown:om},ku=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Su=Oh,rr=(e,t)=>n=>{var r;if(t?.variants==null)return Su(e,n?.class,n?.className);const{variants:s,defaultVariants:a}=t,i=Object.keys(s).map(d=>{const f=n?.[d],p=a?.[d];if(f===null)return null;const h=ku(f)||ku(p);return s[d][h]}),l=n&&Object.entries(n).reduce((d,f)=>{let[p,h]=f;return h===void 0||(d[p]=h),d},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,f)=>{let{class:p,className:h,...m}=f;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 Su(e,i,c,n?.class,n?.className)},_S=rr("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"}}),Ve=qe(({className:e,variant:t,size:n,...r},s)=>o("button",{ref:s,className:W(_S({variant:t,size:n}),e),...r}));Ve.displayName="Button";const PS=rr("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"}}),uc=qe(({className:e,variant:t,size:n,icon:r,...s},a)=>o("button",{ref:a,className:W(PS({variant:t,size:n}),e),...s,children:o(r,{className:"h-4 w-4"})}));uc.displayName="IconButton";const $S=rr("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"}}),br=qe(({className:e,variant:t,style:n,...r},s)=>o("span",{ref:s,className:W($S({variant:t,styleVariant:n}),e),...r}));br.displayName="Badge";const DS=rr("rounded-lg p-3",{variants:{variant:{flat:"bg-surface",bordered:"bg-surface border border-border"}},defaultVariants:{variant:"bordered"}}),on=qe(({className:e,variant:t,...n},r)=>o("div",{ref:r,className:W(DS({variant:t}),e),...n}));on.displayName="Card";function wm({expanded:e,onExpandedChange:t,header:n,children:r,dimmed:s=!1,hideChevron:a=!1,className:i}){return u("div",{className:W("rounded-lg border border-border bg-surface overflow-hidden",s&&"opacity-[0.45]",i),children:[u("div",{role:"button",tabIndex:0,className:"flex items-center gap-2.5 px-3 py-2.5 cursor-pointer select-none",onClick:()=>t(!e),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),t(!e))},children:[!a&&o("span",{className:"text-foreground-subtle shrink-0",children:e?o(nr,{className:"h-4 w-4"}):o(_n,{className:"h-4 w-4"})}),n]}),e&&r&&o("div",{className:"border-t border-border px-3 py-3",children:r})]})}const pc=qe(({className:e,...t},n)=>o("label",{ref:n,className:W("text-[10px] uppercase tracking-wider text-foreground-muted font-medium",e),...t}));pc.displayName="Label";const TS=rr("",{variants:{orientation:{horizontal:"h-px w-full bg-border-subtle",vertical:"w-px h-full bg-border-subtle"}},defaultVariants:{orientation:"horizontal"}}),fc=qe(({className:e,orientation:t,...n},r)=>o("div",{ref:r,role:"separator",className:W(TS({orientation:t}),e),...n}));fc.displayName="Separator";const Nm=qe(({className:e,...t},n)=>o("div",{ref:n,className:W("animate-pulse bg-surface-hover rounded-md h-4 w-full",e),...t}));Nm.displayName="Skeleton";const Cu=rr("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"}}),Bs=qe(({className:e,state:t,leftSlot:n,rightSlot:r,...s},a)=>n||r?u("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:W(Cu({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:W(Cu({state:t}),e),...s}));Bs.displayName="Input";const Fs=qe(({className:e,options:t,...n},r)=>u("div",{className:"relative w-full",children:[o("select",{ref:r,className:W("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(nr,{className:"h-3.5 w-3.5"})})]}));Fs.displayName="Select";const km=qe(({className:e,...t},n)=>o("input",{ref:n,type:"checkbox",className:W("w-3.5 h-3.5 rounded-sm border border-border accent-primary",e),...t}));km.displayName="Checkbox";const hc=qe(({className:e,checked:t,onCheckedChange:n,label:r,...s},a)=>u("button",{ref:a,role:"switch","aria-checked":t,type:"button",onClick:()=>n(!t),className:W("inline-flex items-center gap-2",e),...s,children:[o("span",{className:W("w-8 h-4 rounded-full transition-colors",t?"bg-primary":"bg-surface-hover"),children:o("span",{className:W("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})]}));hc.displayName="Switch";const Sm=Oe(null);function Cm(){const e=ve(Sm);if(!e)throw new Error("Dialog compound components must be used within <Dialog>");return e}function Mm({children:e,open:t,onOpenChange:n}){const[r,s]=_(!1),a=t??r,i=Nr(),l=U(c=>{n?.(c),t===void 0&&s(c)},[t,n]);return o(Sm.Provider,{value:{open:a,setOpen:l,contentId:i},children:e})}function LS({children:e,...t}){const{setOpen:n}=Cm();return o("button",{type:"button",onClick:()=>n(!0),...t,children:e})}const RS=rr("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"}}),mc=qe(({className:e,width:t,children:n,...r},s)=>{const{open:a,setOpen:i,contentId:l}=Cm(),c=ne(null),d=s??c;Y(()=>{const p=d.current;p&&(a&&!p.open&&p.showModal(),!a&&p.open&&p.close())},[a,d]);const f=p=>{p.target===p.currentTarget&&i(!1)};return o("dialog",{ref:d,id:l,className:W(RS({width:t}),"w-full",e),onClick:f,onClose:()=>i(!1),...r,children:n})});mc.displayName="DialogContent";function Em({className:e,...t}){return o("div",{className:W("flex flex-col gap-1 mb-3",e),...t})}function Im({className:e,...t}){return o("div",{className:W("flex justify-end gap-2 mt-4",e),...t})}function Am({className:e,...t}){return o("h2",{className:W("text-sm font-semibold text-foreground",e),...t})}function _m({className:e,...t}){return o("p",{className:W("text-xs text-foreground-muted",e),...t})}const Pm=Oe(null);function gc(){const e=ve(Pm);if(!e)throw new Error("Dropdown compound components must be used within <Dropdown>");return e}function $m({children:e}){const[t,n]=_(!1),r=Nr(),s=Nr(),a=ne(null);return o(Pm.Provider,{value:{open:t,setOpen:n,triggerId:r,contentId:s,triggerRef:a},children:o("div",{className:"relative inline-block",children:e})})}function Dm({children:e,...t}){const{open:n,setOpen:r,triggerId:s,contentId:a,triggerRef:i}=gc();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 Tm({className:e,children:t,align:n="start",offset:r=4,...s}){const{open:a,setOpen:i,contentId:l,triggerId:c,triggerRef:d}=gc(),f=ne(null),[p,h]=_(null);if(fa(()=>{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=f.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 _o(o("div",{ref:f,id:l,role:"menu","aria-labelledby":c,style:m,className:W("z-50 bg-background-elevated border border-border rounded-md shadow-lg py-1 min-w-[160px]",e),...s,children:t}),document.body)}function Lm({className:e,icon:t,variant:n="default",children:r,onClick:s,...a}){const{setOpen:i}=gc(),l=U(c=>{s?.(c),i(!1)},[s,i]);return u("button",{type:"button",role:"menuitem",className:W("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 Rm=Oe(null);function Om(){const e=ve(Rm);if(!e)throw new Error("Tooltip compound components must be used within <Tooltip>");return e}function OS({children:e}){const[t,n]=_(!1),r=ne(null),s=Nr(),a=()=>{r.current=setTimeout(()=>n(!0),300)},i=()=>{r.current&&clearTimeout(r.current),n(!1)};return o(Rm.Provider,{value:{open:t,show:a,hide:i,tooltipId:s},children:o("div",{className:"relative inline-block",children:e})})}function zS({children:e,...t}){const{show:n,hide:r,tooltipId:s,open:a}=Om();return o("div",{onMouseEnter:n,onMouseLeave:r,onFocus:n,onBlur:r,"aria-describedby":a?s:void 0,...t,children:e})}function BS({className:e,children:t,...n}){const{open:r,tooltipId:s}=Om();return o("div",{id:s,role:"tooltip",className:W("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 Mu="(max-width: 767px)",Eu="(min-width: 768px) and (max-width: 1023px)";function zm(e){return t=>{const n=window.matchMedia(e);return n.addEventListener("change",t),()=>n.removeEventListener("change",t)}}function Bm(e){return()=>window.matchMedia(e).matches}function Fm(){return!1}function or(){return ha(zm(Mu),Bm(Mu),Fm)}function jm(){return ha(zm(Eu),Bm(Eu),Fm)}function bc({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]),u(me,{children:[o("div",{className:W("fixed inset-0 z-40 bg-black/50 transition-opacity duration-200",e?"opacity-100":"pointer-events-none opacity-0"),onClick:t,"aria-hidden":"true"}),u("div",{role:"dialog","aria-modal":"true",className:W("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&&u("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(We,{className:"h-4 w-4"})})]}),o("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:r})]})]})}const Hm=Oe(null);function Vm(){const e=ve(Hm);if(!e)throw new Error("Popover compound components must be used within <Popover>");return e}function qm({children:e,open:t,onOpenChange:n}){const[r,s]=_(!1),a=t??r,i=Nr(),l=Nr(),c=U(d=>{n?.(d),t===void 0&&s(d)},[t,n]);return o(Hm.Provider,{value:{open:a,setOpen:c,triggerId:i,contentId:l},children:o("div",{className:"relative inline-block",children:e})})}function Um({children:e,...t}){const{open:n,setOpen:r,triggerId:s,contentId:a}=Vm();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 Qm({className:e,children:t,...n}){const{open:r,setOpen:s,contentId:a,triggerId:i}=Vm(),l=or(),c=ne(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)},f=p=>{p.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",d),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",f)}},[r,s,i,l]),r?l?o(bc,{open:r,onClose:()=>s(!1),children:t}):o("div",{ref:c,id:a,role:"dialog","aria-labelledby":i,className:W("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 Km=Oe(null);function Gm(){const e=ve(Km);if(!e)throw new Error("Tabs compound components must be used within <Tabs>");return e}function FS({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(Km.Provider,{value:{value:l,setValue:c},children:o("div",{className:r,...s})})}function jS({className:e,...t}){return o("div",{role:"tablist",className:W("flex flex-row border-b border-border-subtle",e),...t})}function HS({value:e,className:t,...n}){const{value:r,setValue:s}=Gm(),a=e===r,i=`tabpanel-${e}`;return o("button",{type:"button",role:"tab","aria-selected":a,"aria-controls":i,tabIndex:a?0:-1,className:W("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 VS({value:e,className:t,...n}){const{value:r}=Gm();return e!==r?null:o("div",{role:"tabpanel",id:`tabpanel-${e}`,className:W("pt-3",t),...n})}const xc=qe(({className:e,...t},n)=>o("div",{ref:n,className:W("overflow-auto [&::-webkit-scrollbar]:w-1 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-surface-hover [&::-webkit-scrollbar-thumb]:rounded-full",e),...t}));xc.displayName="ScrollArea";function qS({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,f]=_({x:80+l*30,y:80+l*30}),[p,h]=_({w:r,h:s}),[m,g]=_(!1),b=ne(!1),x=ne(!1),y=ne({x:0,y:0}),w=or(),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=E=>{if(b.current&&f({x:E.clientX-y.current.x,y:E.clientY-y.current.y}),x.current){const A=E.clientX-y.current.x,I=E.clientY-y.current.y;y.current={x:E.clientX,y:E.clientY},h(B=>({w:Math.max(a,B.w+A),h:Math.max(i,B.h+I)}))}},S=()=>{b.current=!1,x.current=!1};return window.addEventListener("mousemove",k),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",S)}},[a,i]),w?u("div",{className:W("fixed inset-x-0 bottom-0 z-50 rounded-t-xl border-t border-border bg-background-elevated shadow-2xl flex flex-col overflow-hidden",c),style:{maxHeight:"60dvh"},children:[u("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border shrink-0 bg-surface",children:[o("span",{className:"text-[11px] font-medium truncate",children:e}),u("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(xu,{size:12}):o(yu,{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(We,{size:12})})]})]}),!m&&o("div",{className:"flex-1 min-h-0 overflow-y-auto",children:n})]}):u("div",{className:W("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:[u("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:[u("div",{className:"flex items-center gap-2 min-w-0",children:[o(t5,{size:12,className:"text-foreground-subtle shrink-0"}),o("span",{className:"text-[11px] font-medium truncate",children:e})]}),u("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(xu,{size:12}):o(yu,{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(We,{size:12})})]})]}),!m&&u("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 yc({open:e,onClose:t,children:n,className:r,width:s="w-64"}){const a=ne(null);return Y(()=>{if(!e)return;const i=l=>{l.key==="Escape"&&t()};return document.addEventListener("keydown",i),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",i),document.body.style.overflow=""}},[e,t]),u(me,{children:[o("div",{className:W("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:W("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 vc({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 u(ec.Fragment,{children:[r>0&&o(_n,{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 Iu={left:"text-left",right:"text-right",center:"text-center"};function Wm({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:u("table",{className:"w-full text-xs",style:{minWidth:`${s}px`},children:[o("thead",{className:"bg-surface",children:o("tr",{children:e.map(f=>{const p=f.align??"left",h=f.nowrap??!0;return o("th",{className:["px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border",Iu[p],h?"whitespace-nowrap":"",f.width??""].filter(Boolean).join(" "),children:f.headerRender?f.headerRender():f.header},f.key)})})}),o("tbody",{children:t.map((f,p)=>{const h=n?n(f,p):p,m=c?.(f,p)??"",g=r!==void 0;return o("tr",{onClick:g?()=>r(f,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",Iu[x],y?"whitespace-nowrap":""].filter(Boolean).join(" "),children:b.render(f,p)},b.key)})},h)})})]})})}function wc({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?u("aside",{className:W("absolute top-0 right-0 bottom-0 z-20 flex flex-col","bg-surface border-l border-border shadow-xl",i),role:"dialog","aria-modal":"false",children:[u("header",{className:"flex items-start justify-between gap-2 px-4 py-3 border-b border-border",children:[u("div",{className:"min-w-0",children:[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(We,{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 US={inherit:"bg-muted",on:"bg-emerald-500",off:"bg-orange-500",na:"bg-gray-300 opacity-50"};function Ym({node:e,depth:t,selectedAddonId:n,onSelect:r,agentDots:s}){const a=e.addonId===n,i=s?.[e.addonId]??[];return u("div",{children:[u("button",{type:"button",onClick:()=>r(e.addonId),className:W("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:W("w-2 h-2 rounded-full",US[l.state])},l.agentNodeId))})]}),e.children.map(l=>o(Ym,{node:l,depth:t+1,selectedAddonId:n,onSelect:r,agentDots:s},l.addonId))]})}function Zm({tree:e,selectedAddonId:t,onSelect:n,agentDots:r,className:s}){return o("div",{className:W("flex flex-col py-2",s),children:e.map(a=>o(Ym,{node:a,depth:0,selectedAddonId:t,onSelect:n,agentDots:r},a.addonId))})}function ba(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 QS(e){return e?e.models.map(t=>({id:t.id,name:t.name})):[]}function Cs({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:f,hideModelAndSettings:p=!1}){const[h,m]=_(!1),g=QS(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=u(me,{children:[u("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}),u("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:W("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:W("inline-block h-4 w-4 rounded-full bg-white shadow transition-transform",e.enabled?"translate-x-6":"translate-x-1")})}),!i&&l==="threeState"&&d&&u("div",{className:"flex items-center gap-0.5 rounded-md border border-border p-0.5",onClick:x=>x.stopPropagation(),children:[o(ai,{label:"Inherit",active:c===null,variant:"inherit",subtext:f===void 0?void 0:f?"on":"off",onClick:()=>d(null)}),o(ai,{label:"On",active:c===!0,variant:"on",onClick:()=>d(!0)}),o(ai,{label:"Off",active:c===!1,variant:"off",onClick:()=>d(!1)})]})]});return o(wm,{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."}):u("div",{className:"space-y-3",children:[o(fl,{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(fl,{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(xa,{field:x,allFields:t.configSchema??[],step:e,disabled:i,onChange:s},x.key))]})})}function fl({label:e,value:t,options:n,disabled:r,onChange:s}){return u("div",{children:[o("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e}),u("select",{value:t,onChange:a=>s(a.target.value),disabled: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 KS({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 u("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:W("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 GS(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 xa({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:f,notIn:p}=a,h=GS(l,n,t);if(c!==void 0&&h!==c||d!==void 0&&h===d||f!==void 0&&!f.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(fl,{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(KS,{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,f=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 u("div",{children:[u("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&&u("span",{className:"text-xs font-medium text-foreground tabular-nums",children:[typeof x=="number"?x.toFixed(2).replace(/\.?0+$/,""):x,g?` ${g}`:""]})]}),e.description&&o("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:e.description}),o("input",{type:"range",min:f,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 u("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 u("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:f=>i(f.target.value),rows:3,className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground focus:outline-none focus:border-primary/50 resize-y"}):o("input",{type:d,value:c,disabled:r||e.disabled,placeholder:e.placeholder,onChange:f=>i(f.target.value),className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground focus:outline-none focus:border-primary/50"})]})}return e.type==="separator"?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 ai({label:e,active:t,variant:n,subtext:r,onClick:s}){return u("button",{type:"button",onClick:s,className:W("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&&u("span",{className:"ml-1 opacity-60",children:["(",r,")"]})]})}function Xm(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 WS(e,t,n){return n?{enabled:n.enabled??t.enabled,modelId:n.modelId??t.modelId,settings:n.settings??t.settings}:t}function YS({addon:e,agentDefault:t,modelsForFormat:n,onChangeAgentConfig:r}){const s=a=>{r?.({...t,...a})};return u("div",{className:"space-y-4 text-xs",children:[u("label",{className:"flex items-center gap-2",children:[o("input",{type:"checkbox",checked:t.enabled,onChange:a=>s({enabled:a.target.checked})}),u("span",{children:["Enabled on this agent (",e.name,")"]})]}),u("div",{children:[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&&u("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(xa,{field:a,allFields:e.configSchema??[],step:Xm(e,t),disabled:!1,onChange:i=>s({settings:{...i.settings}})},a.key))]})]})}function ZS({addon:e,agentDefault:t,agentNodeId:n,currentPatch:r,modelsForFormat:s,onChangePatch:a}){const i=WS("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)},f=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 u("div",{className:"space-y-4 text-xs",children:[u("div",{className:"flex items-center gap-1",children:[["inherit","on","off"].map(m=>o("button",{type:"button",onClick:()=>c(m),className:W("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)),u("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["agent default: ",o("span",{className:"font-semibold",children:t.enabled?"on":"off"})]})]}),u("div",{children:[u("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&&u("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 u("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[u("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:()=>f(void 0),children:"Clear"}):o("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>f({...t.settings}),children:"Override"})]}),e.configSchema?.map(g=>o(xa,{field:g,allFields:e.configSchema??[],step:Xm(e,i),disabled:!m,onChange:b=>f({...b.settings})},g.key)),!m&&u("div",{className:"text-[10px] text-foreground-subtle",children:["inherits from ",n]})]})})(),u("div",{className:"rounded bg-muted/40 px-3 py-2 text-[11px] text-foreground-subtle",children:[o("div",{className:"font-semibold text-foreground mb-0.5",children:"Effective config preview"}),u("div",{className:"font-mono truncate",children:[e.id," · model: ",i.modelId," · ",i.enabled?"on":"off"]})]})]})}function ya(e){const{mode:t,addon:n,agentDefault:r,agentNodeId:s,currentPatch:a,onChangeAgentConfig:i,onChangePatch:l,engineFormat:c}=e,d=q(()=>n.models.filter(f=>!!f.formats[c]),[n.models,c]);return t==="agent"?o(YS,{addon:n,agentDefault:r,modelsForFormat:d,onChangeAgentConfig:i}):o(ZS,{addon:n,agentDefault:r,agentNodeId:s,currentPatch:a,modelsForFormat:d,onChangePatch:l})}function XS(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 Au={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 JS({slot:e}){const t=Au[e]??Au.classifier;return o("span",{className:W("text-[9px] font-semibold uppercase tracking-widest leading-none",t.className),children:t.label})}const _u="inline-flex items-center rounded bg-muted px-1.5 py-px text-[9px] font-medium text-foreground-subtle";function eC({inputs:e,outputs:t}){return e.length===0&&t.length===0?null:u("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[e.map(n=>o("span",{className:W(_u,"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:W(_u,"bg-emerald-500/10 text-emerald-500"),children:n},`out-${n}`))]})}function tC({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:W("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:W("inline-block h-3 w-3 rounded-full bg-white shadow transition-transform",e?"translate-x-3.5":"translate-x-0.5")})})}function nC(e){return e.kind==="enabled"?u("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"?u("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"]}):u("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 rC({node:e,depth:t,agents:n,getCellState:r,onCellClick:s,selectedCell:a,toggleProps:i}){return u(me,{children:[u("div",{className:"sticky left-0 z-10 bg-surface px-3 py-2 border-b border-border text-xs flex items-start gap-2",style:{paddingLeft:`${12+t*14}px`},children:[u("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:[o(JS,{slot:e.slot}),u("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"font-semibold truncate",children:e.addonName}),o(eC,{inputs:e.inputClasses,outputs:e.outputClasses})]})]}),i&&o("span",{className:"pl-2 pt-0.5 shrink-0",children:o(tC,{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:W("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:nC(c)},l.agentNodeId)})]})}function Nc({tree:e,agents:t,getCellState:n,onCellClick:r,selectedCell:s,onToggleEnabled:a}){const i=q(()=>XS(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:u("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(f=>u("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:f.agentNodeId}),o("div",{className:"text-[10px] text-foreground-subtle truncate",children:f.engineLabel})]},f.agentNodeId)),i.map(({node:f,depth:p})=>{const h=c&&d!==void 0?n(f.addonId,d):null,m=c&&h!==null?{enabled:h.kind==="enabled",onChange:g=>a?.(f.addonId,g),disabled:h.kind==="na"}:void 0;return o(rC,{node:f,depth:p,agents:t,getCellState:n,onCellClick:r,selectedCell:s,toggleProps:m},f.addonId)})]})})}const Jm=typeof globalThis<"u"?globalThis.__camstackTrpcReact:void 0,C=Jm??mN();typeof globalThis<"u"&&!Jm&&(globalThis.__camstackTrpcReact=C);const kc=fn("camstack:system",null);function Sc({system:e,children:t}){return o(kc.Provider,{value:e,children:t})}function Te(){const e=ve(kc);if(!e)throw new Error("useSystem(): no <SystemProvider> in tree");return e}function oC(){return ve(kc)}function ut(e,t){const n=Te(),r=ne(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 hl(e){const t=ne(e);return t.current=e,t}function Or(e,t){const[n,r]=_(null),s=hl(t);return ut(e,a=>{const i=a.data,l=s.current;l&&!l(i)||r(i)}),n}function Cc(e,t,n){const[r,s]=_(()=>new Map),a=hl(t),i=hl(n);ut(e,c=>{const d=c.data,f=i.current;if(f&&!f(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 zr(){const{data:e,isLoading:t}=C.nodes.topology.useQuery(void 0,{staleTime:6e4}),r=Or("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 eg({selectedNodeId:e,onSelect:t,label:n="Node",hideIcon:r=!1,alwaysShow:s=!1}){const{nodes:a}=zr();return!s&&a.length<=1?null:u("div",{className:"flex items-center gap-1.5",children:[!r&&o(K5,{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:W("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 sC={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 aC({status:e,showDot:t=!0,showLabel:n=!0,size:r="sm",className:s}){const a=sC[e];return u("span",{className:W("inline-flex items-center gap-1.5",r==="sm"?"text-xs":"text-sm",s),children:[t&&o("span",{className:W("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 iC={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 lC({provider:e,showLabel:t=!0,className:n}){const r=iC[e];return u("span",{className:W("inline-flex items-center gap-1.5 text-xs",n),children:[o("span",{className:W("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 cC={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 tg({children:e,variant:t="neutral",mono:n,className:r}){return o("span",{className:W("inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-bold leading-tight",n&&"font-mono",cC[t],r),children:e})}function dC({version:e,preRelease:t,className:n}){const r=t??/-(alpha|beta|rc|dev|canary|next)/i.test(e);return o(tg,{variant:r?"warning":"success",mono:!0,className:n,children:e})}function uC({label:e,description:t,error:n,required:r,children:s,orientation:a="vertical",className:i}){const l=a==="horizontal";return u("div",{className:W("flex gap-2",l?"flex-row items-center justify-between":"flex-col",i),children:[u("div",{className:W(l?"flex-1":""),children:[u(pc,{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:W(l?"shrink-0":""),children:s}),n&&o("p",{className:"text-danger text-xs",children:n})]})}function pC({title:e,subtitle:t,actions:n,className:r}){return u("div",{className:W("flex flex-col gap-2 mb-3 sm:flex-row sm:items-center sm:justify-between",r),children:[u("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 ng({icon:e,title:t,description:n,action:r,className:s}){return u("div",{className:W("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"}),u("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 rg=fn("camstack:confirm-dialog",null);function Xe(){const e=ve(rg);if(!e)throw new Error("useConfirm must be used within ConfirmDialogProvider");return e.confirm}function og({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 u(rg.Provider,{value:{confirm:r},children:[e,t&&u("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}),u("div",{className:"relative z-10 w-full max-w-sm mx-4 rounded-xl border border-border bg-surface shadow-2xl overflow-hidden animate-in fade-in zoom-in-95 duration-150",onClick:c=>c.stopPropagation(),children:[u("div",{className:"px-5 pt-5 pb-4",children:[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})]}),u("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 fC({value:e,label:t,trend:n,className:r}){return u(on,{className:W("flex flex-col gap-1",r),children:[u("div",{className:"flex items-baseline gap-2",children:[o("span",{className:"text-2xl font-semibold text-foreground",children:e}),n&&u("span",{className:W("inline-flex items-center gap-0.5 text-xs font-medium",n.direction==="up"?"text-success":"text-danger"),children:[n.direction==="up"?o(fS,{className:"h-3 w-3"}):o(mS,{className:"h-3 w-3"}),n.value,"%"]})]}),o("span",{className:"text-xs text-foreground-muted",children:t})]})}function hC({items:e,className:t}){return o("dl",{className:W("flex flex-col",t),children:e.map(n=>u("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 mC({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 u("div",{className:W("relative group",n),children:[o(xc,{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(uc,{icon:r?Po:Pn,"aria-label":"Copy code",variant:"ghost",size:"sm",onClick:a})})]})}function gC({filters:e,values:t,onChange:n,className:r}){const s=or(),[a,i]=_(!1),l=(d,f)=>{n({...t,[d]:f})},c=Object.values(t).filter(d=>d!==void 0&&d!=="").length;if(s){const d=e.find(p=>p.type==="search"),f=e.some(p=>p.type!=="search");return u("div",{className:W("flex items-center gap-2",r),children:[d&&o(Bs,{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"}),f&&u(me,{children:[u("button",{onClick:()=>i(!0),className:"flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-foreground-muted hover:bg-surface-hover transition-colors shrink-0",children:[o(J5,{className:"h-3.5 w-3.5"}),"Filters",c>0&&o(br,{variant:"info",className:"ml-1 text-[10px] px-1 py-0",children:c})]}),o(bc,{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 u("div",{children:[o("label",{className:"text-xs text-foreground-muted mb-1 block",children:p.label}),o(Fs,{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(br,{variant:g?"info":"default",className:"cursor-pointer",children:h.label})},h.value)})},p.key);default:return null}})})})]})]})}return o("div",{className:W("flex items-center gap-2 flex-wrap",r),children:e.map(d=>{switch(d.type){case"search":return o(Bs,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:f=>l(d.key,f.target.value),leftSlot:o(mo,{className:"h-3 w-3 text-foreground-subtle"}),className:"w-48"},d.key);case"select":return o(Fs,{options:d.options,value:t[d.key]??"",onChange:f=>l(d.key,f.target.value),className:"w-36"},d.key);case"badge-toggle":return o("div",{className:"flex items-center gap-1",children:d.options.map(f=>{const h=t[d.key]===f.value;return o("button",{type:"button",onClick:()=>l(d.key,h?void 0:f.value),children:o(br,{variant:h?"info":"default",className:"cursor-pointer",children:f.label})},f.value)})},d.key);default:return null}})})}function ml({label:e,icon:t,href:n,badge:r,active:s=!1,className:a}){return u("a",{href:n,className:W("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(br,{className:"ml-auto text-[10px] px-1.5 py-0",children:r})]})}function gl({logo:e,sections:t,footer:n,onNavigate:r,className:s}){return u("nav",{className:W("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)=>u("div",{className:W(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(ml,{...l},l.href))})]},i))}),n&&n.length>0&&u("div",{className:"shrink-0 px-1 pb-1",children:[o(fc,{className:"mb-1"}),o("div",{className:"flex flex-col gap-0.5",onClick:r,children:n.map(a=>o(ml,{...a},a.href))})]})]})}function bC({sidebar:e,header:t,mobileLogo:n,mobileActions:r,children:s,className:a}){const i=or(),[l,c]=_(!1);return u("div",{className:W("flex h-screen",a),children:[!i&&o(gl,{...e,className:W("w-44",e.className)}),i&&o(yc,{open:l,onClose:()=>c(!1),width:"w-64",children:o(gl,{...e,onNavigate:()=>c(!1),className:"w-full border-r-0"})}),u("div",{className:"flex flex-1 flex-col min-w-0",children:[i&&u("header",{className:"flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm",children:[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(b5,{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&&u("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,f)=>{const p=f===t.breadcrumbs.length-1;return u("span",{className:"flex items-center gap-1",children:[f>0&&o(_n,{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})]},f)})}),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 xC={online:"bg-success",offline:"bg-danger",warning:"bg-warning",unknown:"bg-foreground-subtle"};function yC({title:e,subtitle:t,status:n,selected:r,onClick:s,badges:a,actions:i,offlineAction:l,className:c}){const d=n==="offline";return u("div",{onClick:s,className:W("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:[u("div",{className:"flex items-center justify-between mb-2",children:[o("span",{className:"text-sm font-medium truncate",children:e}),n&&o("span",{className:W("h-2 w-2 rounded-full shrink-0",xC[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((f,p)=>{const h=W("rounded px-1.5 py-0.5 text-[10px] flex items-center gap-0.5",r?"bg-primary/20":"bg-surface-hover",f.onClick&&"hover:opacity-80 transition-opacity cursor-pointer");return f.onClick?u("button",{onClick:m=>{m.stopPropagation(),f.onClick()},className:h,children:[f.icon,f.label]},p):u("span",{className:h,children:[f.icon,f.label]},p)})}),!d&&i&&i.length>0&&o("div",{className:"flex items-center gap-0.5 mt-2 -mb-1",children:i.map((f,p)=>o("button",{onClick:h=>{h.stopPropagation(),f.onClick()},className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",title:f.label,"aria-label":f.label,children:f.icon},p))}),d&&l&&o("div",{className:"mt-2",onClick:f=>f.stopPropagation(),children:l})]})}function vC({children:e,minCardWidth:t=220,gap:n=3,className:r}){return o("div",{className:W("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 wC="capability.binding-changed";function St(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:wC},{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?gN(e,n):null,[e,n])}function sn(e){const t=U(r=>e?e.subscribe(()=>r()):()=>{},[e]),n=U(()=>e?.value,[e]);return ha(t,n,n)}function sg(e,t,n){const r=St(e,t),s=r?n(r.state):void 0;return sn(s)}function Br(e){const t=St(e.trpc,e.deviceId),n=t!==null?e.slice(t):void 0,r=sn(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 NC(e){return e.parentDeviceId===null?"top-level":e.role?"accessory":"adopted"}const kC={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 SC(e){const t=kC[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 CC={siren:ma,floodlight:pm,spotlight:xm,"pir-sensor":mm,chime:k5,autotrack:sm,nightvision:lc,"privacy-mask":cm,doorbell:am},MC={camera:ic,hub:ul,nvr:ul,light:pm,siren:ma,switch:dS,sensor:mm,thermostat:lS,button:Pk,generic:dc};function ag(e){return e.role?CC[e.role]??dc:MC[e.type.toLowerCase()]??ic}const ig={"native-snapshot":o5,"two-way-audio":fm,"pan-tilt-zoom":sm,"ptz-autotrack":h5,"doorbell-button":am,"motion-trigger":Nn,"battery-operated":rm,rebootable:bm},lg={"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"},EC={"native-snapshot":"snapshot",rebootable:"reboot","pan-tilt-zoom":"ptz","ptz-autotrack":"ptz-autotrack","two-way-audio":"intercom","motion-trigger":"motion-trigger"},cg=new Set(["camera","hub","nvr"]);function dg(e){return!cg.has(e.type.toLowerCase())}function Pu(e){return e.role?!0:!cg.has(e.type.toLowerCase())}function ug(e){return(e.features??[]).includes("motion-trigger")}function IC(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 AC({trpc:e,accessoryChildren:t,adoptedChildren:n,onNavigate:r}){return u("div",{className:"border-t border-border-subtle/50",children:[n.length>0&&o($u,{trpc:e,label:"Adopted devices",rows:n,onNavigate:r}),t.length>0&&o($u,{trpc:e,label:"Accessories",rows:t,onNavigate:r})]})}function $u({trpc:e,label:t,rows:n,onNavigate:r}){return u("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(_C,{trpc:e,child:s,onNavigate:r},s.id))})]})}function _C({trpc:e,child:t,onNavigate:n}){const r=!t.disabled,s=r&&dg(t),a=r&&ug(t),i=ag(t);return o("li",{children:u("div",{onClick:l=>{l.stopPropagation(),n(t.id)},className:"w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-surface-hover transition-colors cursor-pointer",children:[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($C,{trpc:e,deviceId:t.id,features:t.features}),s&&o(PC,{trpc:e,deviceId:t.id}),o("span",{className:W("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 PC({trpc:e,deviceId:t}){const{dev:n,cap:r,slice:s,available:a}=Br({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)"},f=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=>{f(p)},disabled:i||!a,className:W("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:W("absolute h-3 w-3 rounded-full transition-all",c?"bg-success":"bg-foreground-subtle"),style:d})})}function $C({trpc:e,deviceId:t,features:n}){const{dev:r,cap:s,slice:a,available:i}=Br({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,f=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=>{f(p)},disabled:l||!i,className:W("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(Nn,{className:"h-2.5 w-2.5"})})}function pg({trpc:e,device:t,flags:n}){if(!!t.disabled)return null;const s=t.type.toLowerCase(),a=n.showSwitchToggle&&dg(t),i=ug(t),l=s==="hub"||s==="nvr",c=(t.features??[]).includes("rebootable"),d=l&&c;return u(me,{children:[i&&o(TC,{trpc:e,deviceId:t.id,features:t.features}),a&&o(DC,{trpc:e,deviceId:t.id}),d&&o(RC,{trpc:e,deviceId:t.id})]})}function DC({trpc:e,deviceId:t}){const{dev:n,cap:r,slice:s,available:a}=Br({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)"},f=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=>{f(p)},disabled:i||!a,className:W("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:W("absolute h-3 w-3 rounded-full transition-all",c?"bg-success":"bg-foreground-subtle"),style:d})})}function TC({trpc:e,deviceId:t,features:n}){const{dev:r,cap:s,slice:a,available:i}=Br({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,f=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=>{f(p)},disabled:l||!i,className:W("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(Nn,{className:"h-2.5 w-2.5"})})}const ii=168,LC=4;function RC({trpc:e,deviceId:t}){const{dev:n,cap:r}=Br({trpc:e,deviceId:t,cap:x=>x.reboot,slice:()=>{}}),s=ne(null),a=ne(null),[i,l]=_(null),[c,d]=_(!1),f=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-ii,v=Math.max(8,Math.min(w,window.innerWidth-ii-8)),N=y.bottom+LC;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||!f||!r)){d(!0),h();try{await r.reboot({})}finally{d(!1)}}};return u(me,{children:[o("button",{ref:s,type:"button",onClick:g,disabled:c||!f,className:W("inline-flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors flex-shrink-0",(c||!f)&&"opacity-50",p&&"bg-surface-hover text-foreground"),title:"More actions","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":p,children:o(im,{className:"h-3 w-3"})}),i&&_o(o("div",{ref:a,role:"menu",style:{position:"fixed",top:i.top,left:i.left,width:ii},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-1",onClick:x=>x.stopPropagation(),children:u("button",{type:"button",role:"menuitem",onClick:()=>{b()},disabled:c||!f,className:W("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(bm,{className:"h-3 w-3 shrink-0 text-foreground-subtle"}),o("span",{children:"Reboot device"})]})}),document.body)]})}const OC=Object.freeze([]);function zC(e){return e==="native"?"native":"enhanced"}function BC(e){return e.map(t=>({kind:"marker",feature:t}))}function FC(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=EC[a];if(i===void 0){s.push({kind:"marker",feature:a});continue}const l=n.get(i);l&&s.push({kind:zC(l.kind),feature:a,capName:i})}return s}function jC(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 f=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)}};f();const p=e.live?.onEvent.subscribe({category:"capability.binding-changed"},{onData:h=>{const m=h.data?.source;if(!m){f();return}m.type==="device"&&m.id===t&&f()}});return()=>{d=!0,p?.unsubscribe()}},[e,t]),n.length===0?{loading:l,resolved:OC}:l||a||!r?{loading:l,resolved:BC(n)}:{loading:!1,resolved:FC(n,r)}}const HC=[];function fg({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??HC,d=a&&c.length>0,{resolved:f}=jC(e,d?t.id:null,c),p=d&&f.length>0;return!l&&!p?null:u("div",{className:"flex items-center gap-1.5 flex-nowrap whitespace-nowrap min-w-0",children:[l&&o(VC,{accessoryCount:r,adoptedCount:s}),p&&o(qC,{resolved:f})]})}function VC({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 u("span",{className:"text-[9px] font-medium text-foreground-subtle bg-surface-elevated/60 rounded px-1.5 py-0.5 flex-shrink-0",title:r,children:["+",n]})}const hg=240,Du=200;function qC({resolved:e}){const t=ne(null),[n,r]=_(null);return u("span",{ref:t,className:"relative inline-flex items-center gap-1 cursor-help",onMouseEnter:()=>{const i=t.current;if(!i)return;const l=i.getBoundingClientRect(),f=window.innerHeight-l.bottom>=Du?l.bottom+4:l.top-Du-4,p=Math.max(8,Math.min(l.left,window.innerWidth-hg-8));r({top:f,left:p})},onMouseLeave:()=>r(null),children:[e.map(i=>{const l=ig[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:lg[i.feature]??i.feature,children:o(l,{className:"h-2.5 w-2.5"})},i.feature):null}),n&&_o(o(UC,{resolved:e,position:n}),document.body)]})}function UC({resolved:e,position:t}){return u("div",{style:{position:"fixed",top:t.top,left:t.left,width:hg,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(QC,{entry:n},n.feature))})]})}function QC({entry:e}){const t=ig[e.feature],n=lg[e.feature]??e.feature;return u("li",{className:"flex items-center justify-between gap-2 text-[10px]",children:[u("span",{className:"flex items-center gap-1.5 text-foreground",children:[t&&o(t,{className:"h-3 w-3 text-foreground-subtle"}),o("span",{children:n})]}),o(KC,{kind:e.kind})]})}function KC({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:W("text-[8.5px] px-1 rounded",e==="native"?"bg-success/15 text-success":"bg-primary/15 text-primary"),children:e})}function mg({device:e,variant:t,flags:n,parent:r,integrationIcon:s,hasChildren:a,expanded:i,onToggleExpand:l,onNavigateToParent:c}){const d=ag(e);return u("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[n.showChildrenAccordion&&a?o("button",{type:"button",onClick:f=>{f.stopPropagation(),l()},className:"flex h-3.5 w-3.5 items-center justify-center text-foreground-subtle hover:text-foreground transition-colors flex-shrink-0","aria-label":i?"Collapse children":"Expand children","aria-expanded":i,children:i?o(nr,{className:"h-3 w-3"}):o(_n,{className:"h-3 w-3"})}):n.showChildrenAccordion?o("span",{className:"h-3.5 w-3.5 flex-shrink-0"}):null,o(d,{className:W("text-foreground-subtle flex-shrink-0",t==="minimal"?"h-3 w-3":"h-3.5 w-3.5")}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.showIntegrationIcon&&s&&o("span",{className:"flex-shrink-0",children:s}),o("span",{className:W("font-semibold text-foreground truncate",t==="minimal"?"text-[10.5px]":"text-[11px]"),title:e.name,children:e.name})]}),(n.showId||n.showStableId)&&u("div",{className:"mt-0.5 flex items-center gap-1 text-[9px] text-foreground-subtle font-mono truncate",title:n.showStableId?`stableId: ${e.stableId}`:void 0,children:[n.showId&&u("span",{className:"flex-shrink-0 tabular-nums",children:["#",String(e.id)]}),n.showId&&n.showStableId&&o("span",{className:"flex-shrink-0 opacity-50",children:"·"}),n.showStableId&&o("span",{className:"truncate",children:IC(e.stableId)})]}),n.showParentBadge&&r&&u("button",{type:"button",onClick:f=>{f.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(ul,{className:"h-2.5 w-2.5 shrink-0"}),u("span",{className:"truncate",children:["Under: ",r.name]})]})]})]})}function Mc(e,t){return sg(e,t,r=>r.battery)??null}function Ec(e,t){const n=St(e,t),r=ne(!1),{data:s,isLoading:a,isFetching:i,refetch:l}=Jn({queryKey:["device",t,"snapshot"],queryFn:()=>{if(!n)throw new Error("useDeviceSnapshotImage: device proxy not ready");const f=r.current;return r.current=!1,n.snapshot?.getSnapshot({force:f})??null},enabled:n!==null&&t!==null,staleTime:1e4,gcTime:1440*60*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:!1}),c=s?`data:${s.contentType};base64,${s.base64}`:null;function d(){r.current=!0,l()}return{src:c,loading:a||i,refresh:d}}function GC(e){return e<=10?dk:e<=30?lk:e>=95?ak:rm}function WC(e,t){return t!=="none"?"text-emerald-400":e<=10?"text-rose-400":e<=30?"text-amber-400":"text-foreground-subtle"}function Ic({status:e,variant:t="compact",className:n}){if(!e)return null;const r=GC(e.percentage),s=WC(e.percentage,e.charging),a=e.charging==="solar"?xm:e.charging==="dc"?_5:null,i=e.sleeping;return u("span",{className:W("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"}),u("span",{children:[Math.round(e.percentage),"%"]}),a&&o(a,{className:"h-3 w-3"}),i&&o(lc,{className:"h-3 w-3 text-blue-300"}),t==="full"&&e.charging!=="none"&&o("span",{className:"text-foreground-subtle",children:e.charging})]})}function gg({trpc:e,device:t,status:n,enabled:r,showStatusPills:s=!1}){const a=r&&t.online,i=Ec(e,a?t.id:null),l=(t.features??[]).includes("battery-operated"),c=s&&l&&!t.disabled,d=Mc(e,c?t.id:null);return!r&&!c?null:u("span",{className:"inline-flex items-center gap-1.5 flex-nowrap whitespace-nowrap",children:[c&&d&&o(Ic,{status:d}),r&&o(YC,{deviceName:t.name,snapshotUrl:i.src,status:n})]})}const li=288,Tu=196,ci=8;function YC({deviceName:e,snapshotUrl:t,status:n}){const r=ne(null),[s,a]=_(null),i=n==="offline"||n==="disabled",l=()=>{const d=r.current;if(!d)return;const f=d.getBoundingClientRect(),p=f.top,h=window.innerHeight-f.bottom,m=p<Tu+ci&&h>p,g=m?f.bottom+ci:f.top-Tu-ci,b=f.right-li,x=Math.max(8,Math.min(b,window.innerWidth-li-8));a({top:g,left:x,placeBelow:m})},c=()=>a(null);return u(me,{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($o,{className:"h-3.5 w-3.5"})}),s&&_o(u("div",{style:{position:"fixed",top:s.top,left:s.left,width:li,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 bg({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:W("h-1.5 w-1.5 rounded-full flex-shrink-0",t),title:n})}function go(e){const{trpc:t,device:n,parent:r,integrationIcon:s,onNavigate:a,className:i}=e,l=SC(e),c=e.variant??"compact",d=e.view??"card",f=!n.disabled,p=n.isCamera??n.type.toLowerCase()==="camera",h=e.children??[],m=h.filter(Pu),g=h.filter(E=>!Pu(E)),b=h.length>0,[x,y]=_(!1),w=e.expanded??x,v=e.onToggleExpand??(()=>y(E=>!E)),N=E=>{a?.(E)},k=e.indentLevel??(e.isAccessoryRow?2:0),S=f?n.online?"online":"offline":"disabled";return d==="table"?o(XC,{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:S,isCamera:p,showSnapshot:l.showSnapshot&&p,isAccessoryRow:e.isAccessoryRow??!1,indentLevel:k,className:i}):u("div",{className:W("rounded-lg border border-border bg-surface transition-colors",!f&&"opacity-60",i),children:[u("div",{onClick:()=>N(n.id),className:W("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(mg,{device:n,variant:c,flags:l,parent:r??null,integrationIcon:s??null,hasChildren:b,expanded:w,onToggleExpand:v,onNavigateToParent:N}),o(fg,{trpc:t,device:n,flags:l,accessoryCount:m.length,adoptedCount:g.length,showFeatureRow:!1}),o(gg,{trpc:t,device:n,status:S,enabled:l.showSnapshot&&p,showStatusPills:!0}),o(pg,{trpc:t,device:n,flags:l}),o(bg,{status:S})]}),w&&b&&o(AC,{trpc:t,accessoryChildren:m,adoptedChildren:g,onNavigate:N})]})}const ZC={0:"pl-2",1:"pl-6",2:"pl-8"};function XC(e){const{trpc:t,device:n,variant:r,flags:s,parent:a,integrationIcon:i,accessoryCount:l,adoptedCount:c,hasChildren:d,expanded:f,onToggleExpand:p,onNavigate:h,displayStatus:m,isCamera:g,showSnapshot:b,isAccessoryRow:x,indentLevel:y,className:w}=e;return u("tr",{onClick:()=>h(n.id),className:W("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:W("py-2 align-middle pr-2",ZC[y]),children:o(mg,{device:n,variant:r,flags:s,parent:a,integrationIcon:i,hasChildren:d,expanded:f,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(fg,{trpc:t,device:n,flags:s,accessoryCount:l,adoptedCount:c,showFeatureRow:!0})}),o("td",{className:"px-2 py-2 align-middle",children:o(gg,{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:u("span",{className:"inline-flex items-center gap-1.5",children:[o(pg,{trpc:t,device:n,flags:s}),o(bg,{status:m})]})})]})}function xg(e,t){const[n,r]=_(e);return Y(()=>{const s=setTimeout(()=>r(e),t);return()=>clearTimeout(s)},[e,t]),n}const JC=new Set(["hub","nvr"]);function e3(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(JC.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 Lu=2;function t3(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-Lu),s=Math.min(t-1,e+Lu);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 n3({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=t3(e,a);return u("div",{className:"flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle",children:[u("span",{children:["Showing ",i,"–",l," of ",t," ",s]}),u("span",{className:"inline-flex items-center gap-1",children:[o("button",{type:"button","aria-label":"Previous page",disabled:e===1,onClick:()=>r(e-1),className:W("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(kk,{className:"h-3 w-3"})}),c.map((d,f)=>{if(d.kind==="ellipsis")return o("span",{className:"px-1 text-foreground-subtle/60 select-none",children:"…"},`e-${f}`);const p=d.n===e;return o("button",{type:"button",onClick:()=>r(d.n),className:W("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:W("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(_n,{className:"h-3 w-3"})})]})]})}function r3({view:e,onViewChange:t,types:n,currentType:r,onTypeChange:s,addons:a,currentAddon:i,onAddonChange:l,hideAddons:c=!1}){return u("div",{className:"flex items-center gap-2 flex-wrap",children:[u("span",{className:"inline-flex border border-border rounded-md overflow-hidden",children:[o("button",{type:"button",onClick:()=>t("cards"),className:W("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(d5,{className:"h-3.5 w-3.5"})}),o("button",{type:"button",onClick:()=>t("table"),className:W("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(sS,{className:"h-3.5 w-3.5"})})]}),n&&n.length>0&&u(me,{children:[o(Ru,{children:"Type"}),o(di,{active:r===null,onClick:()=>s(null),children:"All"}),n.map(d=>o(di,{active:r===d,onClick:()=>s(r===d?null:d),children:o3(d)},d))]}),!c&&a&&a.length>0&&u(me,{children:[o(Ru,{children:"Integration"}),a.map(d=>o(di,{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 Ru({children:e}){return o("span",{className:"text-[10px] font-medium uppercase tracking-wider text-foreground-subtle ml-1",children:e})}function di({active:e,icon:t,onClick:n,showClearIcon:r,children:s}){return u("button",{type:"button",onClick:n,className:W("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(We,{className:"h-2.5 w-2.5 opacity-70"})]})}function o3(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function s3({variant:e,onClearFilters:t}){return u("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[o(a5,{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 Vt(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 Ou(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 a3(e,t){try{localStorage.setItem(`camstack:${e}:lastFilters`,JSON.stringify(t))}catch{}}function zu(e,t,n){const r=new URLSearchParams(window.location.search),s=r.get(Vt(e,"view")),a=s==="cards"||s==="table"?s:n.view??t,i=r.get(Vt(e,"page")),l=i?parseInt(i,10):1,c=Number.isFinite(l)&&l>=1?l:1,d=r.get(Vt(e,"addon"))??n.addon??null,f=r.get(Vt(e,"type"))??n.type??null,p=r.get(Vt(e,"q"))??n.q??"";return{view:a,page:c,addon:d,type:f,q:p}}function i3(e,t,n){const r=new URLSearchParams(window.location.search),s=(l,c)=>{c===null||c===""?r.delete(l):r.set(l,c)};s(Vt(e,"view"),t.view===n?null:t.view),s(Vt(e,"page"),t.page===1?null:String(t.page)),s(Vt(e,"addon"),t.addon),s(Vt(e,"type"),t.type),s(Vt(e,"q"),t.q||null);const a=r.toString(),i=a?`${window.location.pathname}?${a}`:window.location.pathname;window.history.replaceState(null,"",i)}function l3(e){const{scope:t,defaultView:n,lsKey:r}=e,[s,a]=_(()=>{const g=Ou(r);return zu(t,n,g)}),i=ne(s);i.current=s,Y(()=>{const g=()=>{const b=Ou(r),x=zu(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),i3(t,b,n),a3(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]),f=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:f,setType:p,setQ:h,clearFilters:m}}const c3={cards:24,table:50};function bo(e){const{devices:t,trpc:n,defaultView:r="table",filters:s,forceAddon:a,resolveIntegrationIcon:i,resolveParent:l,onNavigate:c,pageSize:d=c3,urlScope:f="root",lsKey:p=f==="root"?"devices":"integrations:nested"}=e,h=l3({scope:f,defaultView:r,lsKey:p}),m=h.state.view,g=m==="cards"?d.cards:d.table,[b,x]=_(h.state.q),y=xg(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(M=>!(w&&M.addonId!==w||h.state.type&&M.type!==h.state.type||R&&!M.name.toLowerCase().includes(R)&&!M.stableId.toLowerCase().includes(R)))},[t,w,h.state.type,h.state.q]),N=q(()=>e3(v),[v]),k=q(()=>{if(h.state.q.trim()==="")return new Set;const R=h.state.q.toLowerCase().trim(),M=new Set;for(const[T,P]of N.accessoriesByParent.entries())P.some(L=>L.name.toLowerCase().includes(R)||L.stableId.toLowerCase().includes(R))&&M.add(T);return M},[N.accessoriesByParent,h.state.q]),S=N.topLevel.length,E=Math.max(1,Math.ceil(S/g)),A=Math.min(h.state.page,E),I=(A-1)*g,B=N.topLevel.slice(I,I+g);Y(()=>{A!==h.state.page&&h.setPage(A)},[A]),m3();const $=w!=null||h.state.type!==null||h.state.q!=="",z=S===0;return u("div",{className:"flex flex-col gap-3",children:[u("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[o(r3,{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}),u("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"})]})]}),z?o(s3,{variant:$?"filtered":"nofilter",onClearFilters:$?h.clearFilters:void 0}):m==="cards"?o(d3,{rows:B,accessoriesByParent:N.accessoriesByParent,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:c??null}):o(f3,{rows:B,accessoriesByParent:N.accessoriesByParent,autoExpandedParents:k,devices:v,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:c??null}),o(n3,{currentPage:A,totalItems:S,pageSize:g,onPageChange:h.setPage}),a===void 0&&$&&S>0&&u("p",{className:"text-[11px] text-foreground-subtle",children:["Showing ",S," of ",t.length," devices",w&&u(me,{children:[" ","· filtered by"," ",o("strong",{className:"text-primary",children:s?.addons?.find(R=>R.id===w)?.name??w})]})]})]})}function d3({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(go,{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 u3=new Set(["hub","nvr"]);function p3(e,t){return e.parentDeviceId===null||t===null?0:u3.has(t.toLowerCase())?1:0}function f3({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 f of r)d.set(f.id,f.type);return d},[r]);return o("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:u("table",{className:"w-full border-collapse",children:[o("thead",{children:u("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 f=t.get(d.id)??[],p=f.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(h3,{parent:d,accessories:f,hasAccessories:p,forceExpanded:h,trpc:s,integrationIcon:a?.(d.addonId)??null,parentRowParent:m,indentLevel:p3(d,g),onNavigate:l??null},d.id)})})]})})}function h3({parent:e,accessories:t,hasAccessories:n,forceExpanded:r,trpc:s,integrationIcon:a,parentRowParent:i,indentLevel:l,onNavigate:c}){const[d,f]=_(r),p=ne(r);return Y(()=>{p.current!==r&&(f(r),p.current=r)},[r]),u(me,{children:[o(go,{trpc:s,device:e,view:"table",integrationIcon:a,parent:i,children:t,onNavigate:c??void 0,showChildrenAccordion:n,expanded:d,onToggleExpand:()=>f(g=>!g),indentLevel:l}),n&&d&&t.map(g=>o(go,{trpc:s,device:g,view:"table",integrationIcon:null,parent:null,isAccessoryRow:!0,showChildrenAccordion:!1,onNavigate:c??void 0},g.id))]})}function m3(){ke()}function g3({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 u("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(Vk,{className:"h-3.5 w-3.5 shrink-0"}),r.label,r.isBest&&u("span",{className:"inline-flex items-center gap-0.5 rounded-full bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-amber-400",children:[o(nS,{className:"h-2.5 w-2.5"}),"Best"]}),r.platformScore!=null&&u("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 b3(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(f=>f.addons).find(f=>f.id===i.addonId);let c=i.modelId;if(l&&!l.models.some(f=>f.id===c)){const f=l.defaultModelId;r.push(`Model "${c}" not available for ${i.addonId} — using "${f}"`),c=f}const d=i.children.map(f=>s(f)).filter(f=>f!==null);return{...i,modelId:c,children:d}}const a=e.map(i=>s(i)).filter(i=>i!==null);return{valid:r.length===0,steps:a,warnings:r}}function x3(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 ui(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:u("div",{className:"flex items-center gap-3",children:[o(Lk,{className:"h-[18px] w-[18px] text-foreground-subtle/30 group-hover:text-primary/60 shrink-0"}),u("div",{className:"flex-1 min-w-0",children:[o("span",{className:"text-[13px] font-medium text-foreground-subtle/50 group-hover:text-foreground-subtle block truncate",children:e.name}),u("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(n=>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 Ac({schema:e,steps:t,onChange:n,templates:r,selectedTemplateId:s,onSelectTemplate:a,onSaveTemplate:i,onUpdateTemplate:l,onDeleteTemplate:c,readOnly:d=!1,excludeAddons:f=[],hideTemplates:p=!1,showOnlyEnabled:h=!1,showSlotLabels:m=!1,toggleMode:g="simple",overrides:b={},onOverrideChange:x,inheritedEnabledByAddon:y={},hideModelAndSettings:w=!1}){const v=H=>({toggleMode:g,hideModelAndSettings:w,...g==="threeState"?{overrideState:b[H]!==void 0?b[H]:null,onOverrideChange:x?D=>x(H,D):void 0,inheritedEnabled:y[H]}:{}}),N=q(()=>new Set(f),[f]),k=q(()=>x3(e),[e]),[S,E]=_([]),A=s?JSON.stringify(t)!==JSON.stringify(r.find(H=>H.id===s)?.steps):!1;function I(H){const D=H.target.value||null;if(D){const Q=r.find(K=>K.id===D);if(Q){const K=b3(Q.steps,e);E([...K.warnings])}}else E([]);a(D)}function B(){s&&l(s,t)}function $(){const H=window.prompt("Template name:");H?.trim()&&i(H.trim(),t)}function z(){if(!s)return;const H=r.find(D=>D.id===s);H&&window.confirm(`Delete template "${H.name}"?`)&&c(s)}function R(H){n(t.map(D=>D.addonId!==H.addonId?D:M(H)))}function M(H){const D=H.children.some(Q=>Q.enabled||Q.children.some(K=>K.enabled));return{...H,enabled:H.enabled||D,children:H.children.map(Q=>{const K=Q.children.some(ee=>ee.enabled);return{...Q,enabled:Q.enabled||K}})}}function T(H,D){const Q=ui(D);n(t.map(K=>K.addonId!==H?K:{...K,children:[...K.children,Q]}))}function P(H){const D=new Set;for(const Q of H){D.add(Q.addonId);for(const ee of Q.children)D.add(ee.addonId);const K=P(Q.children);for(const ee of K)D.add(ee)}return D}const L=P(t);function O(H){const D=k.get(H.addonId);if(!D)return[];const K=e.slots.find(Z=>Z.id===D.slot)?.parentSlot==null,ee=D.childSlots,oe=new Set(H.children.map(Z=>Z.addonId)),te=[];for(const Z of e.slots)if(ee.includes(Z.id))for(const re of Z.addons){if(oe.has(re.id)||N.has(re.id))continue;const be=re.inputClasses.length===0;if(be&&!K)continue;(be||re.inputClasses.some(G=>H.outputClasses.includes(G)))&&te.push(re)}return te}function j(H){const D=h?{...H,children:H.children.filter(K=>K.enabled).map(K=>({...K,children:K.children.filter(ee=>ee.enabled)}))}:H,Q=h?[]:O(D);return u("div",{className:"space-y-1.5",children:[o(Cs,{step:D,schema:k.get(D.addonId)??null,allSchemas:k,onChange:R,onDelete:d?void 0:K=>n(t.filter(ee=>ee.addonId!==K)),readOnly:d,...v(D.addonId)}),(D.children.length>0||Q.length>0)&&u("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"}),D.children.map(K=>{const ee=O(K);return u("div",{className:"space-y-1.5",children:[o(Cs,{step:K,schema:k.get(K.addonId)??null,allSchemas:k,depth:1,onChange:oe=>{R({...D,children:D.children.map(te=>te.addonId===oe.addonId?oe:te)})},onDelete:d?void 0:oe=>{R({...D,children:D.children.filter(te=>te.addonId!==oe)})},readOnly:d,...v(K.addonId)}),(K.children.length>0||ee.length>0)&&u("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"}),K.children.map(oe=>o(Cs,{step:oe,schema:k.get(oe.addonId)??null,allSchemas:k,depth:2,onChange:te=>{R({...D,children:D.children.map(Z=>Z.addonId===K.addonId?{...Z,children:Z.children.map(re=>re.addonId===te.addonId?te:re)}:Z)})},onDelete:d?void 0:te=>{R({...D,children:D.children.map(Z=>Z.addonId===K.addonId?{...Z,children:Z.children.filter(re=>re.addonId!==te)}:Z)})},readOnly:d,...v(oe.addonId)},oe.addonId)),!d&&ee.map(oe=>o(pi,{addon:oe,onClick:()=>{const te=ui(oe);R({...D,children:D.children.map(Z=>Z.addonId===K.addonId?{...Z,children:[...Z.children,te]}:Z)})}},oe.id))]})]},K.addonId)}),!d&&Q.map(K=>o(pi,{addon:K,onClick:()=>T(D.addonId,K)},K.id))]})]},D.addonId)}const F=e.slots.filter(H=>H.parentSlot===null).sort((H,D)=>H.priority-D.priority);return u("div",{className:"space-y-4",children:[!p&&o("div",{className:"rounded-lg border border-border bg-surface p-3",children:u("div",{className:"flex items-center gap-2",children:[o("div",{className:"relative flex-1 min-w-0",children:u("select",{value:s??"",onChange:I,className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:border-primary/50",children:[o("option",{value:"",children:"No template"}),r.map(H=>o("option",{value:H.id,children:H.name},H.id))]})}),A&&o("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500 shrink-0"}),o("button",{onClick:B,disabled:!s||d,title:"Save",className:W("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(F5,{className:"h-4 w-4"})}),o("button",{onClick:$,disabled:d,title:"Save As",className:W("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(Fk,{className:"h-4 w-4"})}),o("button",{onClick:z,disabled:!s||d,title:"Delete",className:W("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(Kt,{className:"h-4 w-4"})})]})}),S.length>0&&u("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 text-xs text-amber-400 space-y-1",children:[u("div",{className:"flex items-center justify-between",children:[o("span",{className:"font-medium",children:"Template loaded with warnings:"}),o("button",{onClick:()=>E([]),className:"text-amber-400/60 hover:text-amber-400",children:o(We,{className:"h-3.5 w-3.5"})})]}),S.map((H,D)=>u("div",{children:["• ",H]},D))]}),F.map(H=>{const D=t.filter(te=>te.slot===H.id&&!N.has(te.addonId)),Q=h?D.filter(te=>te.enabled):D,K=h?[]:H.addons.filter(te=>!L.has(te.id)&&!N.has(te.id)),ee=new Map,oe=[];for(const te of Q)te.group?(ee.has(te.group)||ee.set(te.group,[]),ee.get(te.group).push(te)):oe.push(te);return u("div",{className:"space-y-2",children:[m&&u("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50",children:["Slot: ",H.label]}),oe.map(te=>j(te)),[...ee.entries()].map(([te,Z])=>u("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:te}),Z.map(re=>j(re))]},te)),!d&&K.map(te=>o(pi,{addon:te,onClick:()=>{n([...t,ui(te)])}},te.id))]},H.id)})]})}const to={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"},Bu=["#ef4444","#8b5cf6","#06b6d4","#f97316","#10b981","#6366f1","#e11d48","#0891b2","#7c3aed","#059669"],yg="#f59e42";function ct(e,t){if(t?.[e])return t[e];if(t?.[e.toLowerCase()])return t[e.toLowerCase()];if(to[e])return to[e];if(to[e.toLowerCase()])return to[e.toLowerCase()];let n=0;for(let r=0;r<e.length;r++)n=n*31+(e.codePointAt(r)??0)>>>0;return Bu[n%Bu.length]??yg}function y3({src:e,imageWidth:t,imageHeight:n,detections:r=[],classColors:s,aspectRatio:a,className:i,placeholder:l,showConfidence:c=!0,minConfidence:d=0,borderWidth:f=2}){function p(y){return ct(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=N3(b,y=>y.parentId??"");return o("div",{className:W("rounded-lg border border-border bg-surface overflow-hidden relative",i),style:{aspectRatio:h},children:e?u(me,{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(v3,{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(Fu,{detection:y,imageWidth:t,imageHeight:n,color:p(y.macroClass),showConfidence:c,borderWidth:y.debug?.mask?1:f,children:w.map(v=>o(w3,{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(Fu,{detection:y,imageWidth:t,imageHeight:n,color:p(y.macroClass),showConfidence:c,borderWidth:f},`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 Fu({detection:e,imageWidth:t,imageHeight:n,color:r,showConfidence:s,borderWidth:a,children:i}){const{x:l,y:c,width:d,height:f}=e.bbox,p=u("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"2px"},children:[u("span",{className:"text-[10px] px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:r},children:[e.macroClass,s&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((h,m)=>u("span",{className:"text-[9px] font-semibold px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:ct(h.label)},children:[h.label," ",(h.score*100).toFixed(0),"%"]},`${e.id}-lbl-${m}`))]});return u("div",{className:"absolute rounded-sm",style:{left:`${l/t*100}%`,top:`${c/n*100}%`,width:`${d/t*100}%`,height:`${f/n*100}%`,borderWidth:`${a}px`,borderStyle:"solid",borderColor:r},children:[p,i]})}function v3({mask:e,maskWidth:t,maskHeight:n,bbox:r,imageWidth:s,imageHeight:a,color:i}){const l=ne(null);return Y(()=>{const c=l.current;if(!c)return;const d=c.getContext("2d");if(!d)return;const f=atob(e),p=new Uint8Array(f.length);for(let y=0;y<f.length;y++)p[y]=f.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 w3({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:u("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"1px"},children:[u("span",{className:"text-[9px] px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:n},children:[e.macroClass,r&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((c,d)=>u("span",{className:"text-[8px] font-semibold px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:ct(c.label)},children:[c.label," ",(c.score*100).toFixed(0),"%"]},`${e.id}-lbl-${d}`))]})})}function N3(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 k3({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(f=>f.kind==="first-level"),l=e.filter(f=>f.kind==="detail"),c=new Map;for(const f of l){if(!f.parentId)continue;const p=c.get(f.parentId)??[];p.push(f),c.set(f.parentId,p)}const d=l.filter(f=>!f.parentId||!i.some(p=>p.id===f.parentId));return u("div",{className:n,children:[u("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Detections (",e.length,")"]}),u("div",{className:"space-y-2",children:[i.map(f=>o(ju,{detection:f,children_:c.get(f.id)??[],colors:a,hiddenKeys:r,onToggleVisibility:s},f.id)),d.map(f=>o(ju,{detection:f,children_:[],colors:a,hiddenKeys:r,onToggleVisibility:s},f.id))]})]})}function ju({detection:e,children_:t,colors:n,hiddenKeys:r,onToggleVisibility:s}){const a=ct(e.macroClass,n),i=!r?.has(e.id),l=e.debug?.mask,c=e.debug?.maskWidth,d=e.debug?.maskHeight,f=e.debug?.alternateLabels;return u("div",{className:`rounded-md border border-border bg-surface p-3 space-y-1 ${i?"":"opacity-40"}`,children:[u("div",{className:"flex justify-between items-center",children:[u("div",{className:"flex items-center gap-2",children:[s&&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&&u("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:["mask ",c,"x",d]})]}),o(M3,{confidence:e.score})]}),u("div",{className:"text-[10px] text-foreground-subtle font-mono",children:["bbox: [",Math.round(e.bbox.x),", ",Math.round(e.bbox.y),","," ",Math.round(e.bbox.x+e.bbox.width),","," ",Math.round(e.bbox.y+e.bbox.height),"]"]}),e.labels.length>0&&o("div",{className:"flex flex-wrap gap-1 mt-1",children:e.labels.map((p,h)=>u("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{backgroundColor:ct(p.label,n)+"20",color:ct(p.label,n)},children:[p.label,u("span",{className:"opacity-60",children:[(p.score*100).toFixed(0),"%"]}),p.detectionId&&u("span",{className:"opacity-40 text-[8px]",children:["→ ",p.detectionId]})]},h))}),f&&Object.keys(f).length>0&&o(C3,{alternateLabels:f,colors:n}),t.length>0&&o(S3,{items:t,colors:n,hiddenKeys:r,onToggleVisibility:s})]})}function S3({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=ct(s.macroClass,t),i=!n?.has(s.id),l=s.debug?.mask,c=s.debug?.maskWidth,d=s.debug?.maskHeight;return u("div",{className:`text-xs space-y-0.5 ${i?"":"opacity-40"}`,children:[u("div",{className:"flex items-center gap-1.5",children:[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}),u("span",{className:"text-foreground-subtle",children:[(s.score*100).toFixed(0),"%"]}),l&&c&&d&&u("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:["mask ",c,"x",d]})]}),s.labels.length>0&&o("div",{className:"flex flex-wrap gap-1 ml-5 mt-0.5",children:s.labels.map((f,p)=>u("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-medium px-1 py-0.5 rounded-full",style:{backgroundColor:ct(f.label,t)+"20",color:ct(f.label,t)},children:[f.label," ",u("span",{className:"opacity-60",children:[(f.score*100).toFixed(0),"%"]})]},p))})]},s.id)})})}function C3({alternateLabels:e,colors:t}){const[n,r]=_(!1),s=Object.keys(e);return u("div",{className:"mt-1",children:[u("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:u("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)=>u("span",{className:"inline-flex items-center gap-0.5 text-[9px] px-1 py-0.5 rounded-full",style:{backgroundColor:ct(a,t)+"10",color:ct(a,t),opacity:Math.max(.4,l.score)},children:[l.label,u("span",{className:"opacity-60",children:[(l.score*100).toFixed(1),"%"]})]},c))})]},a)})})]})}function M3({confidence:e}){const t=e>=.8?"bg-success/10 text-success":e>=.5?"bg-warning/10 text-warning":"bg-danger/10 text-danger";return u("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${t}`,children:[(e*100).toFixed(1),"%"]})}function E3({timings:e,totalMs:t,className:n}){const r=Object.entries(e);return r.length===0&&t===void 0?null:u("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"}),u("div",{className:"space-y-1 text-xs",children:[r.map(([s,a])=>u("div",{className:"flex justify-between",children:[o("span",{className:"text-foreground-subtle",children:s}),u("span",{className:"font-mono text-foreground",children:[a.toFixed(1),"ms"]})]},s)),t!==void 0&&u("div",{className:"flex justify-between pt-1 border-t border-border font-medium text-foreground",children:[o("span",{children:"Total"}),u("span",{className:"font-mono",children:[t.toFixed(1),"ms"]})]})]})]})}function I3({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 f=d.files?.[0];if(!f)return;const p=new FileReader;p.onload=()=>{const h=p.result,m=h.split(",")[1];m&&s(m,f.name,h)},p.readAsDataURL(f)},d.click()};return u("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 Zo="w-full px-3 py-2 text-sm rounded-md border border-border bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-primary/50";function A3({runtime:e,backend:t,modelId:n,agentId:r="hub",runtimes:s,backends:a,models:i,agents:l=[],onRuntimeChange:c,onBackendChange:d,onModelChange:f,onAgentChange:p,layout:h="grid",className:m,showAgent:g=!1}){return u("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&&u("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:Zo,children:l.map(x=>u("option",{value:x.id,children:[x.name," (",x.status,")"]},x.id))})]}),u("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:Zo,children:s.map(x=>u("option",{value:x.value,disabled:!x.available,children:[x.label,x.available?"":" (unavailable)"]},x.value))})]}),u("label",{className:"space-y-1",children:[o("span",{className:"text-xs font-medium text-foreground-subtle",children:"Backend"}),o("select",{value:t,onChange:x=>d(x.target.value),className:Zo,children:a.map(x=>u("option",{value:x.id,disabled:!x.available,children:[x.label,x.available?"":" (unavailable)"]},x.id))})]}),u("label",{className:"space-y-1",children:[o("span",{className:"text-xs font-medium text-foreground-subtle",children:"Model"}),o("select",{value:n,onChange:x=>f(x.target.value),className:Zo,children:i.length===0?o("option",{value:"",children:"No compatible models"}):i.map(x=>u("option",{value:x.id,children:[x.name,x.downloaded?" ✓":""]},x.id))})]})]})}function _3({className:e}){return u("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[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 P3({className:e}){return u("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[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 $3({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 vg({onLogin:e,serverUrl:t,logoSrc:n,error:r,className:s}){const[a,i]=_(""),[l,c]=_(""),[d,f]=_(!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:W("flex min-h-screen items-center justify-center bg-background p-4",s),children:u("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}),u("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}),u("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"})]}),u("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"Password"}),u("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:()=>f(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(P3,{className:"h-4 w-4"}):o(_3,{className:"h-4 w-4"})})]})]}),u("button",{type:"submit",disabled:p,className:"w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2",children:[p&&o($3,{className:"h-4 w-4 animate-spin"}),p?"Logging in...":"Log in"]})]})]})})}const bl="camstack_dev_token",wg=Oe(null);function D3(){const e=ve(wg);if(!e)throw new Error("useDevShell must be used within a DevShell");return e}function T3(){return typeof window>"u"?null:localStorage.getItem(bl)}function L3({className:e}){return u("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[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 R3({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 O3({children:e,serverUrl:t,title:n,token:r,onLogout:s}){const a=Rr(),i=q(()=>{const h=t.replace(/^http/,"ws")+"/trpc",m=pN({url:h,connectionParams:()=>({token:r})});return[fN({condition:g=>g.type==="subscription",true:hN({client:m,transformer:sl}),false:Ch({url:`${t}/trpc`,transformer:sl,headers:()=>({authorization:`Bearer ${r}`})})})]},[t,r]),l=q(()=>Sh({links:i}),[i]),c=q(()=>C.createClient({links:i}),[i]),d=q(()=>Eh({serverUrl:t,token:r}),[t,r]);Y(()=>(d.init().catch(()=>{}),()=>{d.close()}),[d]);const f=q(()=>new wh,[]),p=q(()=>({trpc:l,token:r,logout:s}),[l,r,s]);return o(Sc,{system:d,children:o(C.Provider,{client:c,queryClient:f,children:o(Nh,{client:f,children:o(wg.Provider,{value:p,children:u("div",{className:"min-h-screen bg-background text-foreground",children:[u("div",{className:"flex items-center justify-between border-b border-border bg-surface px-4 py-2",children:[u("div",{className:"flex items-center gap-2",children:[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})]}),u("div",{className:"flex items-center gap-2",children:[u("button",{type:"button",onClick:a.toggleMode,className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",title:`Theme: ${a.mode}`,children:[a.resolvedMode==="dark"?o(L3,{className:"h-3.5 w-3.5"}):o(R3,{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 Ng({children:e,serverUrl:t="https://localhost:4443",title:n}){const[r,s]=_(T3),a=U(async(l,c)=>{const p=await Sh({links:[Ch({url:`${t}/trpc`,transformer:sl})]}).auth.login.mutate({username:l,password:c});if(!p.token)throw new Error("No token returned");localStorage.setItem(bl,p.token),s(p.token)},[t]),i=U(()=>{localStorage.removeItem(bl),s(null)},[]);return r?o(Rs,{children:o(O3,{serverUrl:t,title:n,token:r,onLogout:i,children:e})}):o(Rs,{children:o(vg,{onLogin:a,serverUrl:t})})}function z3(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}yh(a).render(Me(Ng,{serverUrl:n,title:r,children:({trpc:i,theme:l})=>Me(e,{trpc:i,theme:{isDark:l.resolvedMode==="dark"},navigate:c=>{console.log("[dev] navigate:",c)}})}))}const kg=fn("camstack:custom-field-renderers",{});function Sg({renderers:e,children:t}){return o(kg.Provider,{value:e,children:t})}function Cg(e){return ve(kg)[e]??null}const _c=fn("camstack:device-context",null);function Mg({deviceId:e,device:t,children:n}){const r={deviceId:e,device:t??null};return o(_c.Provider,{value:r,children:n})}function hn(){return ve(_c)?.deviceId??null}function Pc(){return ve(_c)?.device??null}const B3=C.accessories.getStatus.useQuery,$c=C.addonPages.listPages.useQuery,va=C.addons.list.useQuery,F3=C.addons.getLogs.useQuery,j3=C.addons.listPackages.useQuery,Dc=C.addons.installPackage.useMutation,H3=C.addons.installFromWorkspace.useMutation,V3=C.addons.isWorkspaceAvailable.useQuery,q3=C.addons.listWorkspacePackages.useQuery,Eg=C.addons.uninstallPackage.useMutation,Ig=C.addons.reloadPackages.useMutation,Ag=C.addons.searchAvailable.useQuery,Tc=C.addons.listUpdates.useQuery,xl=C.addons.updatePackage.useMutation,U3=C.addons.rollbackPackage.useMutation,_g=C.addons.forceRefresh.useMutation,Pg=C.addons.restartServer.useMutation,$g=C.addons.getVersions.useQuery,wa=C.addons.restartAddon.useMutation,Dg=C.addons.retryLoad.useMutation,Tg=C.addons.getAutoUpdateSettings.useQuery,Q3=C.addons.setAutoUpdateSettings.useMutation,Lg=C.addons.getAddonAutoUpdate.useQuery,Rg=C.addons.setAddonAutoUpdate.useMutation,Og=C.addons.applyAutoUpdateToAll.useMutation,K3=C.addons.custom.useMutation,G3=C.addons.onAddonLogs.useSubscription,Lc=C.addonSettings.getGlobalSettings.useQuery,zg=C.addonSettings.updateGlobalSettings.useMutation,W3=C.addonSettings.getDeviceSettings.useQuery,Bg=C.addonSettings.updateDeviceSettings.useMutation,Fg=C.addonWidgets.listWidgets.useQuery,Y3=C.alerts.emit.useMutation,Z3=C.alerts.update.useMutation,jg=C.alerts.list.useQuery,Hg=C.alerts.getUnreadCount.useQuery,Vg=C.alerts.markRead.useMutation,qg=C.alerts.markAllRead.useMutation,Ug=C.alerts.dismiss.useMutation,X3=C.audioAnalysis.resolveDeviceSettings.useQuery,J3=C.audioAnalysis.getDeviceSettingsContribution.useQuery,eM=C.audioAnalysis.getDeviceLiveContribution.useQuery,tM=C.audioAnalysis.applyDeviceSettingsPatch.useMutation,nM=C.audioAnalyzer.analyseChunk.useMutation,rM=C.audioAnalyzer.classify.useQuery,oM=C.audioAnalyzer.isReady.useQuery,sM=C.audioAnalyzer.dispose.useMutation,Qg=C.audioAnalyzer.reprobeAudioEngine.useMutation,aM=C.audioCodec.listSupportedCodecs.useQuery,iM=C.audioCodec.canHandle.useQuery,lM=C.audioCodec.createDecodeSession.useMutation,cM=C.audioCodec.createEncodeSession.useMutation,dM=C.audioCodec.closeSession.useMutation,uM=C.audioCodec.pushEncodedFrame.useMutation,pM=C.audioCodec.pullPcm.useQuery,fM=C.audioCodec.pushPcm.useMutation,hM=C.audioCodec.pullEncoded.useQuery,mM=C.audioCodec.flushEncode.useMutation,gM=C.audioCodec.listActiveSessions.useQuery,bM=C.audioMetrics.getCurrentSnapshot.useQuery,xM=C.audioMetrics.getHistory.useQuery,Rc=C.authentication.listProviders.useQuery,yM=C.authentication.setProviderEnabled.useMutation,Oc=C.backup.listDestinations.useQuery,Kg=C.backup.trigger.useMutation,vM=C.backup.list.useQuery,Gg=C.backup.listLocations.useQuery,Wg=C.backup.getEntries.useQuery,Yg=C.backup.restore.useMutation,Zg=C.backup.delete.useMutation,zc=C.backup.listArchives.useQuery,Xg=C.backup.upsertDestinationPolicy.useMutation,Jg=C.backup.previewSchedule.useQuery,wM=C.battery.getStatus.useQuery,NM=C.brightness.setBrightness.useMutation,kM=C.brightness.getStatus.useQuery,SM=C.cameraStreams.getCameraStreams.useQuery,CM=C.cameraStreams.getBrokerStreams.useQuery,MM=C.cameraStreams.getRtspEntries.useQuery,EM=C.decoder.supportsCodec.useQuery,IM=C.decoder.getInfo.useQuery,AM=C.decoder.createSession.useQuery,_M=C.decoder.destroySession.useQuery,PM=C.decoder.pushPacket.useQuery,$M=C.decoder.openStream.useQuery,DM=C.decoder.pullFrames.useQuery,TM=C.decoder.updateConfig.useQuery,LM=C.decoder.getStats.useQuery,RM=C.decoder.listActiveSessions.useQuery,eb=C.decoder.reprobeHwaccel.useMutation,OM=C.detectionPipeline.getDeviceSettingsContribution.useQuery,zM=C.detectionPipeline.getDeviceLiveContribution.useQuery,BM=C.detectionPipeline.applyDeviceSettingsPatch.useMutation,tb=C.deviceDiscovery.listDiscovered.useQuery,nb=C.deviceDiscovery.refreshDiscovery.useMutation,FM=C.deviceDiscovery.adoptDevice.useMutation,jM=C.deviceDiscovery.releaseDevice.useMutation,HM=C.deviceDiscovery.getStatus.useQuery,VM=C.deviceManager.allocateDeviceId.useMutation,qM=C.deviceManager.registerDevice.useMutation,UM=C.deviceManager.removeDevice.useMutation,QM=C.deviceManager.persistConfig.useMutation,KM=C.deviceManager.loadConfig.useQuery,GM=C.deviceManager.loadRuntimeState.useQuery,WM=C.deviceManager.loadMeta.useQuery,rb=C.deviceManager.setName.useMutation,ob=C.deviceManager.setLocation.useMutation,YM=C.deviceManager.setMetadata.useMutation,sb=C.deviceManager.listLocations.useQuery,ZM=C.deviceManager.addLocation.useMutation,XM=C.deviceManager.removeLocation.useMutation,JM=C.deviceManager.setDisabled.useMutation,e4=C.deviceManager.listPersistedByAddon.useQuery,$n=C.deviceManager.listAll.useQuery,Qn=C.deviceManager.getDevice.useQuery,ab=C.deviceManager.getChildren.useQuery,t4=C.deviceManager.getStreamSources.useQuery,n4=C.deviceManager.getConfigSchema.useQuery,r4=C.deviceManager.getSettingsSchema.useQuery,o4=C.deviceManager.updateConfig.useMutation,ib=C.deviceManager.enable.useMutation,lb=C.deviceManager.disable.useMutation,cb=C.deviceManager.remove.useMutation,s4=C.deviceManager.getStreamProfileMap.useQuery,a4=C.deviceManager.setStreamProfileMap.useMutation,i4=C.deviceManager.probeStreams.useMutation,db=C.deviceManager.getBindings.useQuery,l4=C.deviceManager.getAllBindings.useQuery,ub=C.deviceManager.setWrapperActive.useMutation,c4=C.deviceManager.listWrappersForCap.useQuery,pb=C.deviceManager.listBindableCapsForDeviceType.useQuery,d4=C.deviceManager.getDeviceSettingsAggregate.useQuery,u4=C.deviceManager.getDeviceLiveInfoAggregate.useQuery,Bc=C.deviceManager.getDeviceAggregate.useQuery,p4=C.deviceManager.updateDeviceField.useMutation,fb=C.deviceManager.updateDeviceFieldsBatch.useMutation,Fc=C.deviceManager.discoverDevices.useMutation,hb=C.deviceManager.adoptDevice.useMutation,mb=C.deviceManager.getCreationSchema.useQuery,gb=C.deviceManager.createDevice.useMutation,jc=C.deviceManager.testCreationField.useMutation,f4=C.deviceManager.testField.useMutation,h4=C.deviceManager.getDeviceStatusAggregate.useQuery,m4=C.deviceOps.getStreamSources.useQuery,g4=C.deviceOps.getConfigEntries.useQuery,b4=C.deviceOps.setConfig.useMutation,x4=C.deviceOps.removeDevice.useMutation,y4=C.deviceOps.getSettingsSchema.useQuery,v4=C.deviceProvider.start.useMutation,w4=C.deviceProvider.stop.useMutation,N4=C.deviceProvider.getStatus.useQuery,k4=C.deviceProvider.getDevices.useQuery,S4=C.deviceProvider.supportsDiscovery.useQuery,C4=C.deviceProvider.discoverDevices.useMutation,M4=C.deviceProvider.adoptDiscoveredDevice.useMutation,E4=C.deviceProvider.supportsManualCreation.useQuery,I4=C.deviceProvider.getChildCreationSchema.useQuery,A4=C.deviceProvider.createDevice.useMutation,_4=C.deviceProvider.testCreationField.useMutation,P4=C.deviceState.getSnapshot.useQuery,$4=C.deviceState.getCapSlice.useQuery,D4=C.deviceState.getAllSnapshots.useQuery,T4=C.deviceState.setCapSlice.useMutation,L4=C.doorbell.getStatus.useQuery,R4=C.events.getEvents.useQuery,O4=C.events.getEventThumbnail.useQuery,z4=C.events.getEventClipUrl.useQuery,Hc=C.integrations.list.useQuery,bb=C.integrations.get.useQuery,xb=C.integrations.getByAddonId.useQuery,yb=C.integrations.create.useMutation,vb=C.integrations.update.useMutation,wb=C.integrations.delete.useMutation,B4=C.integrations.getSettings.useQuery,F4=C.integrations.setSettings.useMutation,Nb=C.integrations.getAvailableTypes.useQuery,kb=C.integrations.testConnection.useMutation,Sb=C.intercom.startSession.useMutation,Cb=C.intercom.handleAnswer.useMutation,Mb=C.intercom.stopSession.useMutation,j4=C.intercom.getStatus.useQuery,Eb=C.localNetwork.list.useQuery,H4=C.localNetwork.getPreferred.useQuery,Ib=C.localNetwork.getConnectionEndpoints.useQuery,Ab=C.localNetwork.getAllowedAddresses.useQuery,_b=C.localNetwork.setAllowedAddresses.useMutation,Pb=C.localNetwork.resetAllowlistToBestMatch.useMutation,$b=C.meshOrchestrator.listProviders.useQuery,Db=C.meshOrchestrator.joinProvider.useMutation,Tb=C.meshOrchestrator.leaveProvider.useMutation,V4=C.metricsProvider.collectSnapshot.useQuery,q4=C.metricsProvider.getCached.useQuery,U4=C.metricsProvider.getCurrent.useQuery,Q4=C.metricsProvider.getDiskSpace.useQuery,K4=C.metricsProvider.getGpuInfo.useQuery,G4=C.metricsProvider.getCpuTemperature.useQuery,W4=C.metricsProvider.getProcessStats.useQuery,Y4=C.metricsProvider.listAddonInstances.useQuery,Z4=C.metricsProvider.getAddonStats.useQuery,Lb=C.metricsProvider.listNodeProcesses.useQuery,Rb=C.metricsProvider.killProcess.useMutation,X4=C.motion.isDetected.useQuery,J4=C.motion.getStatus.useQuery,eE=C.motionDetection.analyze.useMutation,tE=C.motionDetection.removeCamera.useMutation,nE=C.motionDetection.reset.useMutation,rE=C.motionDetection.getDeviceSettingsContribution.useQuery,oE=C.motionDetection.getDeviceLiveContribution.useQuery,sE=C.motionDetection.applyDeviceSettingsPatch.useMutation,aE=C.motionTrigger.setMotionTrigger.useMutation,iE=C.motionTrigger.getStatus.useQuery,lE=C.nativeObjectDetection.getStatus.useQuery,Vc=C.networkQuality.getDeviceStats.useQuery,cE=C.networkQuality.getAllStats.useQuery,dE=C.networkQuality.reportClientStats.useMutation,Dn=C.nodes.topology.useQuery,uE=C.nodes.deployAddon.useMutation,Ob=C.nodes.undeployAddon.useMutation,Na=C.nodes.restartAddon.useMutation,zb=C.nodes.restartProcess.useMutation,Bb=C.nodes.restartNode.useMutation,pE=C.nodes.shutdownNode.useMutation,Fb=C.nodes.renameNode.useMutation,jb=C.nodes.clusterAddonStatus.useQuery,Hb=C.nodes.setProcessLogLevel.useMutation,fE=C.nodes.executeQuery.useMutation,hE=C.notificationOutput.send.useMutation,mE=C.notificationOutput.sendTest.useMutation,gE=C.osd.setOverlay.useMutation,bE=C.osd.getStatus.useQuery,xE=C.pipelineAnalytics.getActiveTracks.useQuery,yE=C.pipelineAnalytics.getTrack.useQuery,vE=C.pipelineAnalytics.listTracks.useQuery,wE=C.pipelineAnalytics.clearTracks.useMutation,NE=C.pipelineAnalytics.getMotionEvents.useQuery,kE=C.pipelineAnalytics.getObjectEvents.useQuery,SE=C.pipelineAnalytics.getAudioEvents.useQuery,CE=C.pipelineAnalytics.getEventMedia.useQuery,ME=C.pipelineAnalytics.getTrackMedia.useQuery,EE=C.pipelineAnalytics.getDeviceSettingsContribution.useQuery,IE=C.pipelineAnalytics.getDeviceLiveContribution.useQuery,AE=C.pipelineAnalytics.applyDeviceSettingsPatch.useMutation,Vb=C.pipelineExecutor.getAvailableEngines.useQuery,qb=C.pipelineExecutor.getSelectedEngine.useQuery,_E=C.pipelineExecutor.getDefaultSteps.useQuery,Ub=C.pipelineExecutor.reprobeEngine.useMutation,PE=C.pipelineExecutor.getVideoPipelineSteps.useQuery,$E=C.pipelineExecutor.setVideoPipelineSteps.useMutation,Lo=C.pipelineExecutor.getSchema.useQuery,DE=C.pipelineExecutor.getGlobalSteps.useQuery,TE=C.pipelineExecutor.getGlobalPipelineConfig.useQuery,LE=C.pipelineExecutor.getOrchestratorConfigSchema.useQuery,RE=C.pipelineExecutor.listTemplates.useQuery,OE=C.pipelineExecutor.saveTemplate.useMutation,zE=C.pipelineExecutor.updateTemplate.useMutation,BE=C.pipelineExecutor.deleteTemplate.useMutation,FE=C.pipelineExecutor.getCapabilities.useQuery,jE=C.pipelineExecutor.getAddonModels.useQuery,Qb=C.pipelineExecutor.downloadModel.useMutation,Kb=C.pipelineExecutor.deleteModel.useMutation,HE=C.pipelineExecutor.detect.useQuery,VE=C.pipelineExecutor.runPipeline.useMutation,qE=C.pipelineExecutor.runPipelineBatch.useMutation,UE=C.pipelineExecutor.cacheFrameInPool.useMutation,QE=C.pipelineExecutor.inferCached.useMutation,KE=C.pipelineExecutor.uncacheFrame.useMutation,GE=C.pipelineExecutor.getEffectiveTuning.useQuery,Gb=C.pipelineExecutor.listLoadedEngines.useQuery,WE=C.pipelineExecutor.spinEngine.useMutation,Wb=C.pipelineExecutor.killEngine.useMutation,YE=C.pipelineExecutor.listReferenceImages.useQuery,ZE=C.pipelineExecutor.getReferenceImage.useQuery,XE=C.pipelineExecutor.getReferenceAudioFiles.useQuery,JE=C.pipelineExecutor.getReferenceAudio.useQuery,eI=C.pipelineExecutor.getAudioCapabilities.useQuery,tI=C.pipelineExecutor.runAudioTest.useMutation,nI=C.pipelineExecutor.getDetectionConfigSchema.useQuery,Yb=C.pipelineOrchestrator.assignPipeline.useMutation,Zb=C.pipelineOrchestrator.unassignPipeline.useMutation,Xb=C.pipelineOrchestrator.rebalance.useMutation,ka=C.pipelineOrchestrator.getPipelineAssignments.useQuery,Sa=C.pipelineOrchestrator.getPipelineAssignment.useQuery,Jb=C.pipelineOrchestrator.getAgentLoad.useQuery,rI=C.pipelineOrchestrator.getGlobalMetrics.useQuery,oI=C.pipelineOrchestrator.getCameraMetrics.useQuery,ex=C.pipelineOrchestrator.getCapabilityBindings.useQuery,tx=C.pipelineOrchestrator.setCapabilityBinding.useMutation,nx=C.pipelineOrchestrator.assignDecoder.useMutation,rx=C.pipelineOrchestrator.unassignDecoder.useMutation,ox=C.pipelineOrchestrator.getDecoderAssignments.useQuery,sx=C.pipelineOrchestrator.assignAudio.useMutation,ax=C.pipelineOrchestrator.unassignAudio.useMutation,sI=C.pipelineOrchestrator.getAudioAssignment.useQuery,ix=C.pipelineOrchestrator.getAudioNodeLoad.useQuery,lx=C.pipelineOrchestrator.getAudioAssignments.useQuery,aI=C.pipelineOrchestrator.getDecoderAssignment.useQuery,qc=C.pipelineOrchestrator.getAgentSettings.useQuery,Fr=C.pipelineOrchestrator.listAgentSettings.useQuery,Uc=C.pipelineOrchestrator.setAgentAddonDefaults.useMutation,cx=C.pipelineOrchestrator.removeAgentSettings.useMutation,Qc=C.pipelineOrchestrator.getCameraSettings.useQuery,dx=C.pipelineOrchestrator.setCameraStepToggle.useMutation,iI=C.pipelineOrchestrator.getCameraStepOverrides.useQuery,ux=C.pipelineOrchestrator.setCameraStepOverride.useMutation,px=C.pipelineOrchestrator.setCameraPipelineForAgent.useMutation,fx=C.pipelineOrchestrator.resolvePipeline.useQuery,hx=C.pipelineOrchestrator.listTemplates.useQuery,lI=C.pipelineOrchestrator.saveTemplate.useMutation,mx=C.pipelineOrchestrator.updateTemplate.useMutation,gx=C.pipelineOrchestrator.deleteTemplate.useMutation,cI=C.pipelineOrchestrator.getDeviceSettingsContribution.useQuery,dI=C.pipelineOrchestrator.getDeviceLiveContribution.useQuery,uI=C.pipelineOrchestrator.applyDeviceSettingsPatch.useMutation,pI=C.pipelineRunner.attachCamera.useMutation,fI=C.pipelineRunner.detachCamera.useMutation,hI=C.pipelineRunner.reportMotion.useMutation,mI=C.pipelineRunner.getLocalLoad.useQuery,gI=C.pipelineRunner.getLocalMetrics.useQuery,Kc=C.pipelineRunner.getCameraMetrics.useQuery,bI=C.pipelineRunner.getAllCameraMetrics.useQuery,bx=C.pipelineRunner.getLocalCameras.useQuery,xI=C.platformProbe.getCapabilities.useQuery,yI=C.platformProbe.getHardware.useQuery,vI=C.platformProbe.resolveInferenceConfig.useQuery,wI=C.platformProbe.resolveHwAccel.useQuery,NI=C.ptz.move.useMutation,kI=C.ptz.continuousMove.useMutation,SI=C.ptz.stop.useMutation,CI=C.ptz.getPresets.useQuery,MI=C.ptz.goToPreset.useMutation,EI=C.ptz.goHome.useMutation,II=C.ptz.getPosition.useQuery,AI=C.ptz.getStatus.useQuery,xx=C.ptzAutotrack.getStatus.useQuery,yx=C.ptzAutotrack.setEnabled.useMutation,_I=C.ptzAutotrack.getSettings.useQuery,vx=C.ptzAutotrack.setSettings.useMutation,wx=C.reboot.reboot.useMutation,PI=C.recording.getSegments.useQuery,$I=C.recording.getPlaybackUrl.useQuery,DI=C.recording.getThumbnailAt.useQuery,TI=C.recordingEngine.getStatus.useQuery,Nx=C.recordingEngine.enable.useMutation,kx=C.recordingEngine.disable.useMutation,Sx=C.recordingEngine.getConfig.useQuery,LI=C.recordingEngine.updateConfig.useMutation,RI=C.recordingEngine.getPlaylist.useQuery,OI=C.recordingEngine.getThumbnail.useQuery,Cx=C.recordingEngine.getSegments.useQuery,zI=C.recordingEngine.getAvailability.useQuery,BI=C.recordingEngine.estimateStorage.useQuery,FI=C.recordingEngine.estimateGlobalStorage.useQuery,Mx=C.recordingEngine.getStorageUsage.useQuery,jI=C.recordingEngine.setPolicy.useMutation,HI=C.recordingEngine.getPolicy.useQuery,Ex=C.recordingEngine.getPolicyStatus.useQuery,Ix=C.recordingEngine.getRetentionConfig.useQuery,VI=C.recordingEngine.updateRetentionConfig.useMutation,qI=C.recordingEngine.getMotionStats.useQuery,Ax=C.remoteAccess.listProviders.useQuery,_x=C.remoteAccess.startProvider.useMutation,Px=C.remoteAccess.stopProvider.useMutation,UI=C.settingsStore.get.useQuery,QI=C.settingsStore.set.useMutation,KI=C.settingsStore.query.useQuery,GI=C.settingsStore.insert.useMutation,WI=C.settingsStore.update.useMutation,YI=C.settingsStore.delete.useMutation,ZI=C.settingsStore.count.useQuery,XI=C.settingsStore.isEmpty.useQuery,JI=C.settingsStore.declareCollection.useMutation,eA=C.snapshot.getSnapshot.useQuery,tA=C.snapshot.invalidateCache.useMutation,nA=C.snapshot.getStatus.useQuery,rA=C.snapshot.getDeviceSettingsContribution.useQuery,oA=C.snapshot.getDeviceLiveContribution.useQuery,sA=C.snapshot.applyDeviceSettingsPatch.useMutation,aA=C.snapshotProvider.supportsDevice.useQuery,iA=C.snapshotProvider.getSnapshot.useQuery,lA=C.storage.resolve.useQuery,cA=C.storage.write.useMutation,dA=C.storage.read.useQuery,uA=C.storage.exists.useQuery,pA=C.storage.list.useQuery,fA=C.storage.delete.useMutation,hA=C.storage.getAvailableSpace.useQuery,mA=C.storage.beginUpload.useMutation,gA=C.storage.writeChunk.useMutation,bA=C.storage.finalizeUpload.useMutation,xA=C.storage.abortUpload.useMutation,yA=C.storage.beginDownload.useMutation,vA=C.storage.readChunk.useQuery,wA=C.storage.endDownload.useMutation,$x=C.storage.listLocations.useQuery,NA=C.storage.getDefaultLocation.useQuery,Ca=C.storage.upsertLocation.useMutation,Dx=C.storage.deleteLocation.useMutation,kA=C.storage.testLocation.useQuery,Gc=C.storage.listProviders.useQuery,SA=C.storage.testConfig.useQuery,CA=C.streamBroker.publishCameraStream.useMutation,MA=C.streamBroker.retractCameraStream.useMutation,EA=C.streamBroker.assignProfile.useMutation,IA=C.streamBroker.unassignProfile.useMutation,AA=C.streamBroker.listAllCameraStreams.useQuery,_A=C.streamBroker.listAllProfileSlots.useQuery,PA=C.streamBroker.getBrokerStats.useQuery,$A=C.streamBroker.listClients.useQuery,DA=C.streamBroker.killClient.useMutation,TA=C.streamBroker.restartProfile.useMutation,LA=C.streamBroker.getStreamUrl.useQuery,RA=C.streamBroker.getBroker.useQuery,OA=C.streamBroker.setPreBufferDuration.useMutation,zA=C.streamBroker.getPreBufferInfo.useQuery,BA=C.streamBroker.getRtspPort.useQuery,FA=C.streamBroker.getAllRtspEntries.useQuery,jA=C.streamBroker.getRtspEntry.useQuery,Tx=C.streamBroker.regenerateRtspToken.useMutation,HA=C.streamBroker.setRtspEnabled.useMutation,VA=C.streamBroker.isRtspEnabled.useQuery,qA=C.streamBroker.getDeviceSettingsContribution.useQuery,UA=C.streamBroker.getDeviceLiveContribution.useQuery,QA=C.streamBroker.applyDeviceSettingsPatch.useMutation,KA=C.switch.setState.useMutation,GA=C.switch.getStatus.useQuery,WA=C.system.info.useQuery,YA=C.system.health.useQuery,ZA=C.system.featureFlags.useQuery,XA=C.system.networkAddresses.useQuery,JA=C.system.getRetentionConfig.useQuery,e_=C.system.setRetentionConfig.useMutation,t_=C.system.forceRetentionCleanup.useMutation,Lx=C.toast.onToast.useSubscription,Rx=C.turnOrchestrator.listProviders.useQuery,Ox=C.turnOrchestrator.getAllServers.useQuery,zx=C.turnOrchestrator.setProviderEnabled.useMutation,n_=C.turnProvider.getTurnServers.useQuery,Wc=C.userManagement.listUsers.useQuery,Bx=C.userManagement.createUser.useMutation,Fx=C.userManagement.updateUser.useMutation,jx=C.userManagement.deleteUser.useMutation,Yc=C.userManagement.resetPassword.useMutation,Hx=C.userManagement.setUserScopes.useMutation,r_=C.userManagement.validateCredentials.useMutation,Vx=C.userManagement.listApiKeys.useQuery,o_=C.userManagement.createApiKey.useMutation,qx=C.userManagement.revokeApiKey.useMutation,s_=C.userManagement.validateApiKey.useMutation,Ux=C.userManagement.createScopedToken.useMutation,Qx=C.userManagement.revokeScopedToken.useMutation,a_=C.userManagement.validateScopedToken.useQuery,Kx=C.userManagement.listScopedTokens.useQuery,Gx=C.userManagement.setupTotp.useMutation,Wx=C.userManagement.confirmTotp.useMutation,Yx=C.userManagement.disableTotp.useMutation,Zx=C.userManagement.getTotpStatus.useQuery,i_=C.userManagement.verifyTotp.useMutation,l_=C.webrtcSession.listStreams.useQuery,c_=C.webrtcSession.createSession.useMutation,d_=C.webrtcSession.handleAnswer.useMutation,u_=C.webrtcSession.closeSession.useMutation,p_=C.webrtcSession.hasAdaptiveBitrate.useQuery,f_=C.zoneAnalytics.getCurrentSnapshot.useQuery,h_=C.zoneAnalytics.getZoneHistory.useQuery,m_=C.zoneAnalytics.getCameraHistory.useQuery,g_=C.zoneAnalytics.getUnzonedHistory.useQuery,b_=C.zoneRules.listRules.useQuery,x_=C.zoneRules.setRules.useMutation,y_=C.zones.listZones.useQuery,v_=C.zones.addZone.useMutation,w_=C.zones.removeZone.useMutation,N_=C.zones.updateZone.useMutation,Xx=fn("camstack:widget-registry",null),js=new Map,Xo=new Map,Hu=new Set;function k_(e){if(!e||typeof e!="object")return!1;const t=e.default;return t!==null&&typeof t=="object"}function S_(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 C_(e,t){const n=js.get(e);if(n)return n;const r=Xo.get(e);if(r)return r;Hu.has(e)||(sc(),wr.registerRemotes([{name:e,entry:t,type:"module"}],{force:!1}),Hu.add(e));const s=wr.loadRemote(`${e}/widgets`).then(a=>{if(!k_(a)){const l=S_(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 js.set(e,i),Xo.delete(e),i}).catch(a=>{throw Xo.delete(e),a});return Xo.set(e,s),s}const M_=3e4,E_=2e3;function Jx({children:e}){const t=ke(),n=ne(Date.now()),{data:r}=Fg(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:l=>{const c=l.state.data;return c&&c.length>0||Date.now()-n.current>=M_?!1:E_}});ut("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),js.has(d.remoteName)))continue;const f=d.bundleUrl;C_(d.remoteName,f).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:f,reason:h})})}return()=>{l=!0}},[r]);const i=q(()=>{const l=r??[],c=new Map;for(const f of l)c.set(`${f.addonId}/${f.stableId}`,f);const d=(f,p)=>({widgetId:f,addonId:p.addonId,stableId:p.stableId,label:p.label,description:p.description,icon:p.icon,remoteName:p.remoteName,bundleUrl:p.bundleUrl,hosts:p.hosts,requires:p.requires,defaultSize:p.defaultSize,allowedSizes:p.allowedSizes,defaultColumns:p.defaultColumns,defaultRows:p.defaultRows});return{resolve:f=>{const p=c.get(f);if(!p)return;const h=js.get(p.remoteName);if(!h)return null;const m=h[p.stableId];if(m)return m},metadata:f=>{const p=c.get(f);if(p)return d(f,p)},listAll:()=>{const f=[];for(const[p,h]of c)f.push(d(p,h));return f}}},[r,s]);return o(Xx.Provider,{value:i,children:e})}function ey(e){return Ma().resolve(e)}function ty(e){return Ma().metadata(e)}function ny(){return Ma().listAll()}function Ma(){const e=ry();if(!e)throw new Error("useWidgetRegistry(): no <WidgetRegistryProvider> in tree");return e}function ry(){return I_(Xx)}function I_(e){return ve(e)}function it(e){const{widgetId:t,host:n="device-tab",config:r,deviceId:s,integrationId:a,instanceId:i,size:l,columns:c,rows:d}=e,f=ey(t),p=ty(t),h=q(()=>i??t,[i,t]);if(f===void 0&&p===void 0)return o(Jo,{widgetId:t,reason:"unknown"});if(f===void 0)return o(Jo,{widgetId:t,reason:"missing-export"});if(f===null)return o(A_,{});if(p){if(p.requires.deviceContext&&s===void 0)return o(Jo,{widgetId:t,reason:"missing-device-context"});if(p.requires.integrationContext&&a===void 0)return o(Jo,{widgetId:t,reason:"missing-integration-context"})}return o(f,{instanceId:h,host:n,config:r,deviceId:s,integrationId:a,size:l,columns:c,rows:d})}function A_(){return u("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 Jo({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 sr="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",Ea="block text-[11px] font-medium text-foreground mb-1",__="text-[10px] text-foreground-subtle mt-0.5";function Ue({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=Rt(e,a),c=Rt(t,a);return u("div",{className:i,children:[l!==void 0&&l!==""&&u("label",{className:Ea,children:[l,n&&o("span",{className:"text-danger ml-0.5",children:"*"})]}),s,c&&o("p",{className:__,children:c})]})}function P_({field:e,value:t,onChange:n,disabled:r,translationFn:s}){return o(Ue,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:o("input",{type:e.inputType??"text",className:sr,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 $_({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const[a,i]=_(t==null?"":String(t)),l=ne(!1);Y(()=>{if(l.current)return;const d=t==null?"":String(t);i(d)},[t]);const c=d=>{if(i(d),d===""||d==="-"){n(void 0);return}const f=Number(d);Number.isNaN(f)||n(f)};return o(Ue,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:"flex items-center gap-1",children:[o("input",{type:"number",className:sr,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 D_({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const a=!!t,i=r||e.disabled;return e.style==="checkbox"?o(Ue,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[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:Rt(e.label,s)}),e.required&&o("span",{className:"text-danger",children:"*"})]})}):o(Ue,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:"flex items-center justify-between",children:[u("span",{className:Ea+" mb-0",children:[Rt(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 T_({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const a=e.options.some(i=>i.value==="");return o(Ue,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("select",{className:sr,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 L_({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(Ue,{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 u("label",{className:["flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs cursor-pointer select-none transition-colors",c?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground hover:bg-surface",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 R_({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const[a,i]=_(!1),l=e.showToggle!==!1;return o(Ue,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:"relative",children:[o("input",{type:a?"text":"password",className:sr+(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(cm,{className:"h-3.5 w-3.5"}):o($o,{className:"h-3.5 w-3.5"})})]})})}function O_({field:e,value:t,onChange:n,disabled:r,translationFn:s}){return o(Ue,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:o("textarea",{className:sr+" 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 z_({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",f=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(Ue,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("button",{className:"w-full rounded-lg border border-dashed border-border px-3 py-2 text-xs text-foreground-subtle hover:border-primary/40 hover:text-primary transition-colors text-left",disabled:f,onClick:()=>n(e.default??e.min),children:[d," — click to set manually"]})});const x=e.showStepper===!0&&c,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(Ue,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[u("div",{className:"flex min-w-0 flex-1 basis-[160px] items-center gap-2",children:[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:f,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)&&u("div",{className:"flex shrink-0 items-center gap-2",children:[x&&o("button",{type:"button",className:w,disabled:f||l<=e.min,onClick:()=>y(-1),title:`Decrease by ${e.step??1}`,"aria-label":"Decrement",children:o(hm,{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:f,onChange:v=>{if(v.target.value===""){n(i?null:e.min);return}const N=Number(v.target.value)*p,k=e.step??1,S=N-e.min,E=e.min+Math.round(S/k)*k;n(Math.min(e.max,Math.max(e.min,E)))}}),x&&o("button",{type:"button",className:w,disabled:f||l>=e.max,onClick:()=>y(1),title:`Increase by ${e.step??1}`,"aria-label":"Increment",children:o(Do,{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:f,onClick:()=>n(null),children:d})]})]})})}function B_({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const a=Array.isArray(t)?t:[],[i,l]=_(""),c=ne(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]),f=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&&f(a[a.length-1])},h=r||e.disabled;return o(Ue,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:["flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px] cursor-text","focus-within:border-primary focus-within:ring-1 focus-within:ring-primary/30",h?"opacity-50 cursor-not-allowed":""].join(" "),onClick:()=>!h&&c.current?.focus(),children:[a.map(m=>u("span",{className:"inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[m,!h&&o("button",{type:"button",onClick:()=>f(m),className:"hover:text-danger",children:o(We,{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 oy({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const{nodes:a}=zr(),i=typeof t=="string"?t:"",l=e.showOffline?a:a.filter(c=>c.isOnline);return o(Ue,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("select",{className:"w-full px-3 py-2 text-sm bg-background border border-border rounded-lg text-foreground focus:outline-none focus:border-primary/50 disabled:opacity-50",value:i,onChange:c=>n(c.target.value),disabled:r,children:[o("option",{value:"",children:"Select node…"}),l.map(c=>u("option",{value:c.id,disabled:!c.isOnline,children:[c.shortName,c.isOnline?"":" (offline)"]},c.id))]})})}function sy({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const{nodes:a}=zr(),i=new Set(Array.isArray(t)?t.map(String):[]),l=e.showOffline?a:a.filter(d=>d.isOnline),c=d=>{const f=new Set(i);f.has(d)?f.delete(d):f.add(d),n([...f])};return o(Ue,{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 f=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 ${f?"border-primary bg-primary/10 text-primary":"border-border bg-surface text-foreground-subtle hover:bg-surface-hover"} ${d.isOnline?"":"opacity-50 cursor-not-allowed"}`,children:d.shortName},d.id)})})})}function F_({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const a=t==null?"#000000":String(t);return u(Ue,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:[u("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:sr+" 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 j_({field:e,value:t,onChange:n,disabled:r,translationFn:s,onTestField:a,onAction:i,externalProbe:l}){const[c,d]=_("idle"),[f,p]=_(null),h=l?.status??c,m=l?.result??f,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(Lt,{className:"h-3 w-3 animate-spin"}):h==="ok"?o(Ek,{className:"h-3 w-3"}):h==="error"?o(ga,{className:"h-3 w-3"}):o(vm,{className:"h-3 w-3"});return u(Ue,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:[u("div",{className:"@container flex items-center gap-2",style:{containerType:"inline-size"},children:[u("button",{type:"button",onClick:b,title:"Test",disabled:e.disabled||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:sr+" 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 H_({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:u("div",{className:"rounded-lg border border-border bg-surface/50 overflow-hidden",children:[u("div",{className:["px-3 py-2 flex items-center justify-between",c?"cursor-pointer hover:bg-surface":""].join(" "),onClick:c?()=>l(f=>!f):void 0,children:[o("span",{className:"text-xs font-semibold text-foreground",children:Rt(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(f=>o(ar,{field:f,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a},f.key))})]})})}function V_({field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,onAction:i}){const l=e.tabs[0]?.id??"",[c,d]=_(l),f=e.span===2?"col-span-2":e.span===3?"col-span-3":e.span===4?"col-span-4":"col-span-1";return e.tabs.length===0?null:u("div",{className:f,children:[e.label&&o("div",{className:Ea,children:Rt(e.label,s)}),u("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 u("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:Rt(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(ar,{field:h,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,onAction:i},g)})},p.id))]})]})}function q_({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 Vu={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 U_(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 Q_({field:e}){const t=e.variant??"info",n=Vu[t]??Vu.info,r=e.format==="html";return o("div",{className:"col-span-full",children:u("div",{className:`rounded-md border-l-4 px-3 py-2.5 ${n.border} ${n.bg}`,children:[e.label&&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:U_(e.content)}}):o("p",{className:"text-xs text-foreground-subtle leading-relaxed whitespace-pre-line",children:e.content})]})})}const qu={ok:"bg-success",warn:"bg-amber-500",danger:"bg-danger",idle:"bg-foreground-subtle/40",unknown:"bg-foreground-subtle/40"};function K_(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 G_(e){return!Number.isFinite(e)||e<=0?"—":new Date(e).toLocaleTimeString()}function W_({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=qu[n]??qu.unknown;return u("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:K_(t)}):e==="timestamp"&&typeof t=="number"?o("span",{className:"font-mono text-[11px]",children:G_(t)}):o("span",{children:String(t)})}function Y_({field:e}){const t=e.value??[],n=e.description;return u("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:u("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(W_,{kind:a.kind,value:r[a.key]})},a.key))},s))})]})})]})}function Z_({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,f=(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 u("div",{className:"col-span-full space-y-2",children:[u("div",{className:"space-y-0.5",children:[e.label&&o("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle",children:Rt(e.label,s)}),e.description&&o("p",{className:"text-[11px] text-foreground-subtle",children:Rt(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)=>u("div",{className:"rounded-md border border-border bg-background",children:[u("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[o("span",{className:"text-xs font-medium text-foreground",children:m(x,y)}),u("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(hm,{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(ar,{field:w,values:x,onChange:(v,N)=>f(y,v,N),disabled:r,translationFn:s,onTestField:a,allFields:e.itemFields,onAction:i},w.key))})]},y))}),u("div",{children:[u("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(Do,{className:"h-3 w-3"}),e.addLabel??"Add"]}),!b&&Number.isFinite(d)&&u("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["(limit: ",d,")"]})]})]})}function X_({field:e,disabled:t,onAction:n}){const[r,s]=_(!1),a=Xe(),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(Ue,{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 ay(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 J_({field:e,value:t,values:n,onChange:r,disabled:s,onAction:a}){const[i,l]=_(!1),[c,d]=_(null),[f,p]=_(null),h=ay(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 S of Object.keys(N)){const E=N[S];if(Array.isArray(E)){k=E;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(Ue,{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?u("div",{className:"flex items-center gap-2 text-[11px] text-foreground-subtle",children:[o(Lt,{className:"h-3 w-3 animate-spin"})," Loading options…"]}):c?o("div",{className:"text-[11px] text-danger",children:c}):f&&f.length===0?o("div",{className:"text-[11px] text-foreground-subtle italic",children:e.emptyResultsMessage??"No options returned."}):(()=>{const w=(f??[]).some(v=>{const N=v[b];return N===""||N===void 0});return u("select",{className:"w-full rounded-md border border-border bg-surface px-2 py-1.5 text-xs text-foreground",value:typeof t=="string"?t:"",disabled:s,onChange:v=>r(v.target.value),children:[!w&&o("option",{value:"",children:"— Select —"}),(f??[]).map((v,N)=>{const k=v[b],S=v[x],E=y?v[y]:void 0,A=typeof k=="string"&&k!==""?k:`row-${N}`;return u("option",{value:typeof k=="string"?k:String(k??""),children:[typeof S=="string"?S:String(S??A),E!==void 0?` (${String(E)})`:""]},A)})]})})()})}function eP({field:e,values:t,disabled:n,onAction:r}){const[s,a]=_(!1),[i,l]=_(null),c=Xe(),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=ay(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)}},f={default:"border border-border text-foreground hover:bg-surface-hover",primary:"bg-primary text-primary-foreground hover:bg-primary/90",danger:"bg-danger text-white hover:bg-danger/90"};return o(Ue,{label:e.label,description:e.description,required:e.required,span:e.span,children:u("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 ${f[e.variant??"default"]??f.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 tP({field:e}){const t=hn();return o(Ue,{label:e.label,description:e.description,required:e.required,span:e.span,children:o(it,{widgetId:e.widgetId,host:"device-tab",config:e.widgetConfig,deviceId:t??void 0,instanceId:e.key})})}function nP(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 rP({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=nP(i,l),d="label"in e?e.label:void 0,f="description"in e?e.description:void 0,p="span"in e?e.span:void 0,h="actions"in e?e.actions??[]:[];return o(Ue,{label:d,description:f,span:p,translationFn:r,children:u("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(sP,{action:m,fieldKey:s,value:i,onAction:n},m.action))})]})})}function oP({name:e}){const t="h-3.5 w-3.5";switch(e){case"copy":return o(Pn,{className:t});case"refresh-cw":return o(cc,{className:t});case"external-link":return o(lm,{className:t});case"trash-2":return o(Kt,{className:t});case"download":return o(dl,{className:t});case"upload":return o(ym,{className:t});default:return o(dc,{className:t})}}function sP({action:e,fieldKey:t,value:n,onAction:r}){const s=Xe(),[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(oP,{name:e.icon})})}function aP(e){return"multiple"in e&&e.multiple!=null}function iP({field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c}){const d=e.multiple,f=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<f;)g.push(b);const x=k=>n(e.key,[...k]),y=(k,S)=>{const E=[...g];E[k]=S,x(E)},w=()=>{g.length>=p||x([...g,b])},v=k=>{g.length<=f||x(g.filter((S,E)=>E!==k))},N=()=>{const{multiple:k,...S}=e;return{...S,...{label:void 0,description:void 0,required:!1}}};return o(Ue,{label:e.label,description:e.description,required:f>0?e.required:!1,span:e.span,translationFn:s,children:u("div",{className:"space-y-2",children:[g.map((k,S)=>{const E=d.itemLabel?.replace("${n}",String(S+1));return u("div",{className:"space-y-1",children:[E&&o("div",{className:Ea,children:E}),u("div",{className:"flex items-center gap-2",children:[o("div",{className:"flex-1 min-w-0",children:o(ar,{field:N(),values:{...t,[e.key]:k},onChange:(A,I)=>y(S,I),disabled:r,translationFn:s,onTestField:a,onAction:c,allFields:l})}),g.length>f&&o("button",{type:"button",onClick:()=>v(S),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(Kt,{className:"h-3.5 w-3.5"})})]})]},S)}),u("div",{className:"flex items-center justify-between pt-1",children:[g.length<p?u("button",{type:"button",onClick:w,disabled: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(Do,{className:"h-3 w-3"}),d.addLabel??"Add"]}):o("span",{}),u("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[g.length,"/",p]})]})]})})}function Zc(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 ar({field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c}){if(aP(e))return o(iP,{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(rP,{field:e,values:t,onAction:c,translationFn:s});if(!Zc(e,t,l))return null;const d=t[e.key],f=d!==void 0?d:"default"in e?e.default:void 0,p=m=>n(e.key,m),h=Cg(e.type);switch(e.type){case"text":return o(P_,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"number":return o($_,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"boolean":return o(D_,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"select":return o(T_,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"multiselect":return o(L_,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"password":return o(R_,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"textarea":return o(O_,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"slider":return o(z_,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"tags":return o(B_,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"color":return o(F_,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"node-select":return o(oy,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"node-multiselect":return o(sy,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"probe":return o(j_,{field:e,value:f,onChange:p,disabled:r,translationFn:s,onTestField:a,onAction:c,externalProbe:i});case"group":return o(H_,{field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a});case"sub-tabs":return o(V_,{field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,onAction:c});case"separator":return o(q_,{});case"info":return o(Q_,{field:e});case"object-array":return o(Y_,{field:e});case"editable-array":return o(Z_,{field:e,value:f,onChange:p,disabled:r,translationFn:s,onTestField:a,onAction:c});case"button":return o(X_,{field:e,disabled:r,onAction:c});case"addon-action-select":return o(J_,{field:e,value:f,values:t,onChange:p,disabled:r,onAction:c});case"addon-action-button":return o(eP,{field:e,values:t,disabled:r,onAction:c});case"widget":return o(tP,{field:e});default:return h?o(h,{field:e,value:f,onChange:p,disabled:r}):null}}function lP(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Rt(e,t){if(e!==void 0)return t&&lP(e)?t(e):e}function cP({section:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,probeResults:i}){const[l,c]=_(e.defaultCollapsed??!1),d=e.style==="accordion",f=e.columns??2,p=f===1?"grid-cols-1":f===3?"grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3":f===4?"grid-cols-1 @[480px]:grid-cols-2 @[1140px]:grid-cols-4":"grid-cols-1 @[640px]:grid-cols-2";return u("div",{className:"@container rounded-lg border border-border bg-surface p-3",style:{containerType:"inline-size"},children:[u("div",{className:["flex items-center justify-between mb-2",d?"cursor-pointer":""].join(" "),onClick:d?()=>c(h=>!h):void 0,children:[u("div",{children:[o("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:Rt(e.title,s)}),e.description&&o("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:Rt(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(ar,{field:h,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i?.[h.key]},h.key))})]})}function iy({schema:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,probeResults:i,onClearProbe:l}){const c=(d,f)=>{n({...t,[d]:f}),l?.(d)};return o("div",{className:"space-y-4",children:e.sections.map(d=>o(cP,{section:d,values:t,onChange:c,disabled:r,translationFn:s,onTestField:a,probeResults:i},d.id))})}const dP=({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 Uu(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 uP(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 pP({trpc:e,addonId:t,nodeId:n,title:r,disabled:s,onAfterChange:a,refreshToken:i,collapsible:l,defaultOpen:c,mode:d,onOverrideChange:f}){const p=d??"persist",[h,m]=_(null),[g,b]=_(!0),[x,y]=_(null),[w,v]=_(!1),[N,k]=_(c??!1),[S,E]=_({}),[A,I]=_(null);Y(()=>{I(null),E({})},[e,t,n,i,p]);const B=JSON.stringify(S);Y(()=>{let P=!1;b(!0),y(null);const L=p==="override"&&Object.keys(S).length>0?S:void 0;return e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n,...L?{overlay:L}:{}}).then(O=>{P||(m(O),L||I(Uu(O)),b(!1))}).catch(O=>{P||(y(O instanceof Error?O.message:String(O)),b(!1))}),()=>{P=!0}},[e,t,n,i,p,B]);const $=q(()=>Uu(h),[h]),z=q(()=>h?uP(h):null,[h]),R=async P=>{if(p==="override"){const O=A??$,j={};for(const H of Object.keys(P))P[H]!==O[H]&&(j[H]=P[H]);const F={...O,...j};E(j),f?.(j,F);return}const L={};for(const O of Object.keys(P))P[O]!==$[O]&&(L[O]=P[O]);if(Object.keys(L).length!==0){v(!0);try{await e.addonSettings.updateGlobalSettings.mutate({addonId:t,nodeId:n,patch:L});const O=await e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n});m(O),a?.()}catch(O){y(O instanceof Error?O.message:String(O))}finally{v(!1)}}};if(g)return u("div",{className:"text-xs text-foreground-subtle animate-pulse",children:["Loading ",r??t,"…"]});if(x)return u("div",{className:"text-xs text-red-400",children:[r??t,": ",x]});if(!h||!z)return u("div",{className:"text-xs text-foreground-subtle",children:[r??t," not available on ",n,"."]});const M=p==="override"?{...$,...S}:$,T=u(me,{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(iy,{schema:z,values:M,onChange:R,disabled:s===!0||w})]});return l===!0?u("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("button",{type:"button",onClick:()=>k(P=>!P),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover text-left","aria-expanded":N,children:[o(dP,{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:T}):null]}):r?u("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:T})]}):o("div",{children:T})}function ly({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,f=i&&n&&n.detections.length>0;return!c&&!d&&!f&&!l?null:u("div",{className:"absolute inset-0 pointer-events-none z-10",children:[l&&o(fP,{phase:r}),d&&o(hP,{raw:t}),c&&o(mP,{motion:e}),f&&o(gP,{detections:n.detections,frameWidth:n.frameWidth,frameHeight:n.frameHeight})]})}function fP({phase:e}){const t=tr(e);return u("div",{className:"absolute top-2 left-2 flex items-center gap-1.5 px-2 py-1 rounded-md bg-black/60 backdrop-blur-sm",children:[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 hP({raw:e}){return e.frameWidth===0||e.frameHeight===0?null:o(me,{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,f=(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:`${f}%`,backgroundColor:`rgba(239, 68, 68, ${p})`}},`mr-${n}`)})})}function mP({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(me,{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 gP({detections:e,frameWidth:t,frameHeight:n}){return t===0||n===0?null:o(me,{children:e.map(r=>{const{x:s,y:a,width:i,height:l}=r.bbox,c=s/t*100,d=a/n*100,f=i/t*100,p=l/n*100,h=ct(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:`${f}%`,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 bP(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 xP=3e3,yP=5;function cy({serverUrl:e,streamKey:t,label:n,autoPlay:r=!0,muted:s=!0,showControls:a=!0,className:i="",onStateChange:l,onError:c,overlay:d,createSession:f,sendAnswer:p,closeSession:h,hintsOverride:m}){const g=ne(null),b=ne(null),x=ne(null),y=ne(new Set),w=ne(null),v=ne(null),N=ne(0),k=ne(!0),[S,E]=_("idle"),[A,I]=_(""),[B,$]=_(s),[z,R]=_(!1),[M,T]=_(!1),P=ne(null),L=ne(!1);(p||f)&&(L.current=!0);const O=L.current,j=U(G=>{E(G),l?.(G)},[l]),F=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 G of y.current)h(G).catch(()=>{});y.current.clear()}g.current&&(g.current.srcObject=null)},[h]),H=U(async()=>{if(!k.current||!f||!p)return;F(),j("connecting");const G=new AbortController;w.current=G;try{const ae={...bP(b.current),...m},{sessionId:fe,sdpOffer:ge}=await f(ae);if(y.current.add(fe),!k.current||G.signal.aborted){h?.(fe).catch(()=>{}),y.current.delete(fe);return}const V=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});x.current=V;const ie=new MediaStream;V.ontrack=pe=>{console.debug("[WebRTC] ontrack",pe.track.kind,pe.track.readyState),ie.addTrack(pe.track),g.current&&(g.current.srcObject=ie,g.current.play().catch(()=>{}))},V.oniceconnectionstatechange=()=>{if(!k.current)return;const pe=V.iceConnectionState;console.debug("[WebRTC] ICE state:",pe),pe==="connected"||pe==="completed"?(N.current=0,j("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")&&(j("disconnected"),ee())},V.onicecandidateerror=pe=>{console.debug("[WebRTC] ICE candidate error:",pe)},console.debug("[WebRTC] Setting remote description (server offer)..."),await V.setRemoteDescription({type:"offer",sdp:ge});const ue=await V.createAnswer();if(await V.setLocalDescription(ue),console.debug("[WebRTC] Local description set, waiting for ICE gathering..."),await Qu(V),!k.current)return;const de=(V.localDescription?.sdp??"").split(`
|
|
536
|
-
`).filter(pe=>pe.startsWith("a=candidate:")).length;console.debug("[WebRTC] Sending answer to server",{localCandidates:de,sessionId:fe.slice(0,8)}),await p(fe,V.localDescription?.sdp??""),console.debug("[WebRTC] Answer sent successfully");const ce=V,Se=()=>{const pe=ce.connectionState;if(pe==="closed"||pe==="failed")return;const Ie=g.current;Ie&&Ie.readyState===0&&console.log(`[WebRTC] no video data yet (ice=${ce.iceConnectionState})`)};setTimeout(Se,3e3),setTimeout(Se,8e3)}catch(J){if(!k.current)return;const ae=J instanceof Error?J.message:String(J);I(ae),j("error"),c?.(ae),ee()}},[e,t,f,p,F,j,c,m]),D=U(async()=>{if(k.current){F(),j("connecting");try{const G=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});x.current=G,G.addTransceiver("video",{direction:"recvonly"}),G.addTransceiver("audio",{direction:"recvonly"});const J=new MediaStream;G.ontrack=ie=>{J.addTrack(ie.track),g.current&&(g.current.srcObject=J,g.current.play().catch(()=>{}))},G.oniceconnectionstatechange=()=>{if(!k.current)return;const ie=G.iceConnectionState;ie==="connected"||ie==="completed"?(N.current=0,j("playing"),g.current?.paused&&g.current.play().catch(()=>{})):(ie==="failed"||ie==="disconnected"||ie==="closed")&&(j("disconnected"),ee())};const ae=await G.createOffer();if(await G.setLocalDescription(ae),await Qu(G),!k.current)return;const fe=`${e}/api/webrtc?src=${encodeURIComponent(t)}`,ge=await fetch(fe,{method:"POST",headers:{"Content-Type":"application/sdp"},body:G.localDescription?.sdp??""});if(!ge.ok)throw new Error(`WHEP ${ge.status}: ${ge.statusText}`);const V=await ge.text();await G.setRemoteDescription({type:"answer",sdp:V})}catch(G){if(!k.current)return;const J=G instanceof Error?G.message:String(G);I(J),j("error"),c?.(J),ee()}}},[e,t,F,j,c]),Q=O?H:D,K=ne(()=>{});K.current=Q;const ee=U(()=>{k.current&&(N.current>=yP||(N.current+=1,v.current=setTimeout(()=>{k.current&&K.current()},xP)))},[]);Y(()=>(k.current=!0,N.current=0,r&&Q(),()=>{k.current=!1,F()}),[e,t]);const oe=ne(!1);Y(()=>{!r||!O||!f||!p||oe.current||x.current||(oe.current=!0,Q())},[r,O,f,p,Q]);const te=()=>{N.current=0,Q()},Z=()=>{g.current&&(g.current.muted=!g.current.muted,$(g.current.muted))},re=async()=>{if(b.current)try{document.fullscreenElement?await document.exitFullscreen():await b.current.requestFullscreen()}catch(G){console.warn(`Fullscreen toggle failed: ${G instanceof Error?G.message:G}`)}},be=()=>{if(!g.current)return;const G=document.createElement("canvas");G.width=g.current.videoWidth||1280,G.height=g.current.videoHeight||720;const J=G.getContext("2d");if(!J)return;J.drawImage(g.current,0,0);const ae=document.createElement("a");ae.download=`${t.replace(/[/:]/g,"-")}-${Date.now()}.jpg`,ae.href=G.toDataURL("image/jpeg",.92),ae.click()};Y(()=>{const G=()=>R(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",G),()=>document.removeEventListener("fullscreenchange",G)},[]);const X=()=>{T(!0),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>T(!1),3e3)};return u("div",{ref:b,className:`relative bg-black overflow-hidden group ${i}`,onMouseMove:X,onMouseEnter:X,children:[o("video",{ref:g,autoPlay:r,muted:B,playsInline:!0,className:"w-full h-full object-contain"}),n&&S==="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,S==="connecting"&&u("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…"})]}),(S==="error"||S==="disconnected")&&u("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:S==="error"?A||"Connection failed":"Disconnected"}),o("button",{onClick:te,className:"mt-1 inline-flex items-center gap-1.5 rounded px-3 py-1 text-xs bg-white/10 text-white hover:bg-white/20 transition-colors",children:"Reconnect"})]}),a&&S==="playing"&&u("div",{className:`absolute bottom-0 inset-x-0 flex items-center justify-between px-3 py-1.5 bg-gradient-to-t from-black/80 to-transparent transition-opacity duration-200 ${M?"opacity-100":"opacity-0"}`,children:[o("div",{className:"flex items-center gap-1",children:o(fi,{onClick:Z,title:B?"Unmute":"Mute",children:B?u("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"})]}):u("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"})]})})}),u("div",{className:"flex items-center gap-1",children:[o(fi,{onClick:be,title:"Take snapshot",children:u("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[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(fi,{onClick:re,title:z?"Exit fullscreen":"Fullscreen",children:z?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 fi({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 Qu(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 Xc=fn("camstack:player-overlays-state",null),Jc=fn("camstack:player-overlays-actions",null);function dy({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]),f=q(()=>({setLayer:a,removeLayer:i,setButton:l,removeButton:c}),[a,i,l,c]);return o(Xc.Provider,{value:d,children:o(Jc.Provider,{value:f,children:e})})}function uy(){const e=ve(Xc);return q(()=>e?[...e.layers.values()].sort((t,n)=>t.order-n.order):[],[e])}function py(){const e=ve(Xc);return q(()=>e?[...e.buttons.values()].sort((t,n)=>t.order-n.order):[],[e])}function vP(e){const t=ve(Jc);Y(()=>{if(!(!t||!e))return t.setLayer(e),()=>t.removeLayer(e.id)},[t,e])}function wP(e){const t=ve(Jc);Y(()=>{if(!(!t||!e))return t.setButton(e),()=>t.removeButton(e.id)},[t,e])}function NP(e){return e==="streaming"?"bg-emerald-500":e==="connecting"?"bg-amber-500":e==="error"?"bg-rose-500":"bg-zinc-500"}function kP(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 yl({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 SP({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 CP({className:e}){return u("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 MP({className:e}){return u("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 hi({label:e,active:t,onClick:n}){return u("button",{type:"button",onClick:n,className:"w-full flex items-center justify-between gap-3 px-3 py-1.5 text-[11px] text-foreground hover:bg-surface-hover transition-colors",children:[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 fy({className:e}){return u("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 EP({className:e}){return u("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 ed({serverUrl:e,createSession:t,sendAnswer:n,closeSession:r,streams:s,activeStreamId:a,onStreamChange:i,deviceName:l,phase:c,pipelineMetrics:d,detections:f,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:S=!1,ptzShown:E=!1,ptzOverlay:A,onPtzToggle:I,intercomAvailable:B=!1,intercomShown:$=!1,onIntercomToggle:z,chromeless:R=!1,className:M}){const T=py(),[P,L]=_(g),[O,j]=_(p),[F,H]=_(h),[D,Q]=_(null),[K,ee]=_(!1),oe=ne(null);Y(()=>{if(!K)return;function ce(Se){oe.current&&!oe.current.contains(Se.target)&&ee(!1)}return document.addEventListener("mousedown",ce),()=>document.removeEventListener("mousedown",ce)},[K]);const te=a??D??s?.[0]?.id??"",Z=s?.find(ce=>ce.id===te)??s?.[0],re=Z?.inputFps!=null?{status:Z.status??"unknown",inputFps:Z.inputFps,bitrateKbps:Z.bitrateKbps??0}:null,be=ce=>{Q(ce),i?.(ce),P&&b&&(L(!1),setTimeout(()=>L(!0),50))},X=q(()=>{const ce=Z?.target;if(ce)return Se=>t(ce,Se)},[t,Z]),G=s,J=()=>L(!0),ae=()=>L(!1),fe=d?.phase??c,ge=fe==="active",V=!!f,ie=V&&(O||F),ue=S&&E&&!!A,de=b?P:!0;return u("div",{className:`overflow-hidden ${R?"":"rounded-xl border border-border bg-surface"} ${M??""}`,children:[u("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[u("div",{className:"flex items-center gap-2",children:[(m??re)&&o("span",{className:`w-2 h-2 rounded-full ${NP((m??re).status)}`}),l&&o("span",{className:"text-xs font-medium text-foreground",children:l}),G&&G.length>1&&u("div",{className:"relative",children:[o("select",{"data-testid":"stream-profile-select",value:te,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:G.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"})})})]})]}),u("div",{className:"flex items-center gap-1.5",children:[B&&u("button",{"data-testid":"stream-intercom-toggle","data-intercom-shown":$?"true":"false",onClick:z,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${$?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:$?"Close intercom":"Open intercom",children:[o(CP,{className:"h-3 w-3"}),o("span",{className:"hidden xl:inline",children:"Intercom"})]}),T.map(ce=>{const pe=ce.tone==="primary"?"bg-primary text-primary-foreground":"bg-primary/15 text-primary";return u("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&&u("button",{"data-testid":"stream-play-toggle","data-stream-playing":de?"true":"false",onClick:de?ae:J,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${de?"bg-danger/10 text-danger hover:bg-danger/20":"bg-primary/10 text-primary hover:bg-primary/20"}`,title:de?"Stop stream":"Start stream",children:[de?o(SP,{className:"h-3 w-3"}):o(yl,{className:"h-3 w-3"}),o("span",{className:"hidden xl:inline",children:de?"Stop":"Play"})]}),w&&u("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(fy,{className:`h-3 w-3 ${y?"animate-spin":""}`}),o("span",{className:"hidden xl:inline",children:"Snapshot"})]}),(V||S||d||fe||m||re&&re.inputFps>0)&&u("div",{ref:oe,className:"relative",children:[o("button",{onClick:()=>ee(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(MP,{className:"h-3.5 w-3.5"})}),K&&u("div",{className:"absolute right-0 top-full mt-1 z-30 min-w-[200px] rounded-lg border border-border bg-surface shadow-xl py-1.5",children:[v&&m&&u("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[u("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Input"}),u("span",{className:"tabular-nums text-foreground",children:[m.inputFps.toFixed(1)," fps"]})]}),u("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Decode"}),u("span",{className:"tabular-nums text-foreground",children:[m.decodeFps.toFixed(1)," fps"]})]}),u("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Uptime"}),o("span",{className:"tabular-nums text-foreground",children:kP(m.uptimeMs)})]})]}),!v&&re&&re.inputFps>0&&u("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[u("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Input"}),u("span",{className:"tabular-nums text-foreground",children:[re.inputFps.toFixed(1)," fps"]})]}),re.bitrateKbps>0&&u("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Bitrate"}),u("span",{className:"tabular-nums text-foreground",children:[re.bitrateKbps," kbps"]})]})]}),(d||V&&fe)&&u("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[u("div",{className:"flex justify-between gap-3 items-center",children:[o("span",{children:"Phase"}),u("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&&u("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Detection"}),u("span",{className:"tabular-nums text-foreground",children:[d.detectionFps.toFixed(1)," det/s"]})]}),d&&d.avgInferenceMs>0&&u("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Inference"}),u("span",{className:"tabular-nums text-foreground",children:[d.avgInferenceMs.toFixed(0)," ms"]})]})]}),V&&u(me,{children:[o(hi,{label:"Show detections",active:O,onClick:()=>j(ce=>!ce)}),o(hi,{label:"Show motion",active:F,onClick:()=>H(ce=>!ce)})]}),S&&o(hi,{label:"PTZ controls",active:E,onClick:()=>{I?.(),ee(!1)}})]})]})]})]}),de?o("div",{className:"aspect-video relative",children:o(cy,{serverUrl:e,streamKey:te,autoPlay:!0,className:"w-full h-full",createSession:X,sendAnswer:n,closeSession:r,overlay:ie||k||ue?u(me,{children:[ie&&o(ly,{detections:f,showPhaseIndicator:!1,showMotionZones:F,showMotionRaw:F,showDetections:O}),k,ue&&A]}):void 0},te)}):o(IP,{src:x??null,isLoading:y,onPlay:J,onRetry:w,extraOverlay:k||ue?u(me,{children:[k,ue&&A]}):null,suppressPlayHover:!!k||ue}),N]})}function IP({src:e,isLoading:t,onPlay:n,onRetry:r,extraOverlay:s,suppressPlayHover:a=!1}){return e?u("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(yl,{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:u("div",{className:"flex flex-col items-center gap-2 text-white/40",children:[o(EP,{className:"h-8 w-8"}),o("span",{className:"text-xs",children:"No snapshot available"}),u("div",{className:"flex items-center gap-2 mt-1",children:[r&&u("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(fy,{className:"h-3 w-3"}),"Retry"]}),u("button",{onClick:n,className:"inline-flex items-center gap-1.5 rounded-md bg-primary/80 px-3 py-1.5 text-xs font-medium text-white hover:bg-primary transition-colors",children:[o(yl,{className:"h-3 w-3"}),"Play Live"]})]})]})})}function AP({samples:e,sampleRate:t=16e3,height:n=96,className:r="",color:s="#3b82f6",bgColor:a="transparent"}){const i=ne(null),l=ne(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,S=0;for(let B=v;B<N;B++){const $=e[B];$<k&&(k=$),$>S&&(S=$)}const E=y-S*y,A=y-k*y,I=Math.max(1,A-E);b.fillRect(w,E,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 f=((e&&t?Math.round(e.length/t*1e3):0)/1e3).toFixed(1);return u("div",{ref:l,className:`relative ${r}`,children:[o("canvas",{ref:i,className:"w-full rounded-md"}),e&&e.length>0&&u("div",{className:"absolute bottom-1 right-2 text-[10px] text-foreground-subtle/60 font-mono",children:[f,"s · ",t/1e3,"kHz · ",e.length.toLocaleString()," samples"]})]})}function _P({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=ne(null),f=ne(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=f.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,S=N-k,E=p.filter($=>$.timestamp>=S);if(E.length===0)return;const A=Math.max(1,Math.floor(y/(t*2))),I=Math.abs(c);for(const $ of E){const z=$.timestamp-S,R=Math.floor(z/k*y),T=(Math.max(c,Math.min(0,$.dbfs))-c)/I,P=Math.max(1,T*r),L=$.dbfs>=l;v.fillStyle=L?i:a,v.globalAlpha=.8,v.fillRect(R,r-P,A,P)}v.globalAlpha=1;const B=r-(l-c)/I*r;v.strokeStyle=i,v.globalAlpha=.25,v.lineWidth=1,v.setLineDash([4,4]),v.beginPath(),v.moveTo(0,B),v.lineTo(y,B),v.stroke(),v.setLineDash([]),v.globalAlpha=1},[p,t,r,a,i,l,c]);Y(()=>{m()},[m]),Y(()=>{const b=new ResizeObserver(()=>m()),x=f.current;return x&&b.observe(x),()=>b.disconnect()},[m]);const g=p.length>0?p[p.length-1].dbfs:null;return u("div",{ref:f,className:`relative ${s}`,children:[o("canvas",{ref:d,className:"w-full rounded-md"}),u("div",{className:"absolute top-1 left-2 text-[9px] text-foreground-subtle/50 font-mono",children:[t,"s"]}),g!==null&&u("div",{className:"absolute bottom-1 right-2 text-[9px] text-foreground-subtle/50 font-mono",children:[g.toFixed(1)," dBFS · ",p.length," samples"]})]})}function PP(e){return e>=.8?"bg-emerald-500":e>=.5?"bg-amber-500":e>=.3?"bg-orange-500":"bg-zinc-500"}function $P(e){return e>=.8?"text-emerald-400":e>=.5?"text-amber-400":e>=.3?"text-orange-400":"text-zinc-400"}function DP({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"})}):u("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${s}`,children:[u("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between",children:[o("h3",{className:"text-xs font-medium text-foreground",children:"Audio Classifications"}),u("div",{className:"flex items-center gap-3 text-[10px] text-foreground-subtle",children:[a.length<e.length&&u("span",{children:["showing ",a.length," of ",e.length]}),n!==void 0&&u("span",{className:"font-mono",children:[n.toFixed(1),"ms"]})]})]}),o("div",{className:"divide-y divide-border/50",children:a.map((l,c)=>{const d=i>0?l.score/i*100:0;return u("div",{className:"px-3 py-1.5 flex items-center gap-3 hover:bg-surface-hover/30",children:[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 ${PP(l.score)}`,style:{width:`${d}%`}})}),u("span",{className:`text-xs font-mono font-semibold w-14 text-right ${$P(l.score)}`,children:[(l.score*100).toFixed(1),"%"]})]},`${l.className}-${c}`)})})]})}function TP({data:e,label:t="Response",className:n=""}){const[r,s]=_(!1);if(!e)return null;const a=JSON.stringify(e,null,2);return u("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${n}`,children:[u("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between cursor-pointer select-none hover:bg-surface-hover/30",onClick:()=>s(i=>!i),children:[u("div",{className:"flex items-center gap-2",children:[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 LP={Activity:Nn,Eye:$o,AlertTriangle:To,PauseCircle:Dk,PowerOff:$5};function td({phase:e,...t}){const n=tr(e),r=LP[n.icon];return o(r,{...t})}function Vn(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 Ku(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 Gu={error:{icon:ga,color:"text-red-400"},warn:{icon:To,color:"text-amber-400"},info:{icon:l5,color:"text-blue-400"},debug:{icon:gk,color:"text-gray-500"}},Wu={debug:0,info:1,warn:2,error:3},RP=["all","debug","info","warn","error"],OP=500;function zP(e,t){return t?(Wu[e]??0)>=(Wu[t]??0):!0}function Yt({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:f,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),S=r,E=s,A=q(()=>{const V={};return v&&(V.agentId=v),N&&(V.addonId=N),k!==void 0&&Number.isFinite(k)&&(V.deviceId=k),S&&(V.integrationId=S),E&&(V.requestId=E),Object.keys(V).length>0?V:void 0},[v,N,k,S,E]),I=Vn(OP),B=f??I,$=B.entries,[z,R]=_(0),[M,T]=_(!1),[P,L]=_(!1),[O,j]=_(new Set),[F,H]=_(""),D=ne(null),Q=`${v??""}:${N??""}:${String(k??"")}:${S??""}:${E??""}`,K=ne(Q);Y(()=>{K.current!==Q&&(K.current=Q,B.reset(),R(0),j(new Set))},[Q,B]);const{data:ee,isLoading:oe}=C.logs.query.useQuery({...A?{tags:A}:{},limit:d},{staleTime:3e4});C.logs.subscribe.useSubscription({...A?{tags:A}:{}},{onData:V=>{B.append(V)}});const te=ne($.length);Y(()=>{const V=D.current;if(!V){te.current=$.length;return}const ie=te.current;if(te.current=$.length,!($.length<=ie)){if(M&&V.scrollTop<=8)V.scrollTo({top:0});else if(!M&&V.scrollTop>0){const ue=V.querySelector("tbody tr"),de=ue instanceof HTMLElement?ue.offsetHeight:24;V.scrollTop+=de*($.length-ie)}}},[$.length,M]);const Z=q(()=>{const V=(ee??[]).map(pe=>({timestamp:pe.timestamp,level:pe.level,message:pe.message,scope:pe.scope,tags:pe.tags,meta:pe.meta})),ie=new Set,ue=[];for(const pe of[...$].reverse()){const Ie=`${pe.timestamp}|${pe.level}|${pe.scope??""}|${pe.message}`;ie.has(Ie)||(ie.add(Ie),ue.push(pe))}for(const pe of V){const Ie=`${pe.timestamp}|${pe.level}|${pe.scope??""}|${pe.message}`;ie.has(Ie)||(ie.add(Ie),ue.push(pe))}const ce=(z>0?ue.filter(pe=>new Date(pe.timestamp).getTime()>z):ue).filter(pe=>zP(pe.level,y)),Se=F.trim().toLowerCase();return Se?ce.filter(pe=>{if(pe.message.toLowerCase().includes(Se)||pe.scope&&pe.scope.toLowerCase().includes(Se))return!0;if(pe.tags){for(const Ie of Object.values(pe.tags))if(Ie!==void 0&&String(Ie).toLowerCase().includes(Se))return!0}if(pe.meta){for(const Ie of Object.values(pe.meta))if(Ie!=null&&Ku(Ie).toLowerCase().includes(Se))return!0}return!1}):ce},[ee,$,y,z,F]),re=U(()=>{const V=Z.map(ie=>{const ue=new Date(ie.timestamp).toLocaleTimeString(),de=ie.tags?" "+Object.entries(ie.tags).filter(([,ce])=>ce).map(([ce,Se])=>`${ce}=${Se}`).join(" "):"";return`${ue} [${ie.level.toUpperCase()}]${ie.scope?` [${ie.scope}]`:""}${de} ${ie.message}`});navigator.clipboard.writeText(V.join(`
|
|
537
|
-
`)).then(()=>{L(!0),setTimeout(()=>L(!1),1500)})},[Z]),be=C.logs.clear.useMutation(),X=U(()=>{R(Date.now()),B.reset(),be.mutate({...A?{tags:A}:{}})},[B,be,A]),G=U(V=>{j(ie=>{const ue=new Set(ie);return ue.has(V)?ue.delete(V):ue.add(V),ue})},[]),[J,ae]=_(null),fe=U((V,ie)=>{const ue=new Date(V.timestamp).toISOString(),de=V.tags?" "+Object.entries(V.tags).filter(([,pe])=>pe).map(([pe,Ie])=>`${pe}=${Ie}`).join(" "):"",ce=V.meta&&Object.keys(V.meta).length>0?` meta=${JSON.stringify(V.meta)}`:"",Se=`${ue} [${V.level.toUpperCase()}]${V.scope?` [${V.scope}]`:""}${de} ${V.message}${ce}`;navigator.clipboard.writeText(Se).then(()=>{ae(ie),setTimeout(()=>ae(pe=>pe===ie?null:pe),1200)})},[]),ge=U(V=>`${V.timestamp}|${V.level}|${V.scope??""}|${V.message}`,[]);return u("div",{className:W("h-full min-h-0 flex flex-col",h),onClick:V=>V.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Logs"}),v&&o(mi,{label:"agent",value:v}),N&&o(mi,{label:"addon",value:N}),k!==void 0&&o(mi,{label:"device",value:`#${k}`}),o("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:RP.map(V=>u("button",{type:"button",onClick:()=>w(V==="all"?void 0:V),className:W("px-1.5 py-0.5 capitalize transition-colors",V==="all"&&!y||y===V?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover",V!=="all"&&"border-l border-border"),children:[V,V!=="all"?"+":""]},V))}),o(gi,{icon:ac,label:M?"Auto":"Paused",active:!M,onClick:()=>{T(V=>!V),!M&&D.current&&D.current.scrollTo({top:0,behavior:"smooth"})}}),o(gi,{icon:Pn,label:P?"Copied!":"Copy",onClick:re,disabled:Z.length===0}),o(gi,{icon:Kt,label:"Clear",onClick:X}),u("div",{className:"relative",children:[o("input",{type:"text",value:F,onChange:V=>H(V.target.value),placeholder:"Search…",className:"w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"}),F&&o("button",{type:"button",onClick:()=>H(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:o(We,{className:"h-2.5 w-2.5"})})]}),$.length>0&&u("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",$.length," live"]})]}),p&&o("button",{type:"button",onClick:p,className:"text-foreground-subtle hover:text-foreground",children:o(We,{className:"h-3.5 w-3.5"})})]}),c&&(!t||!n)&&u("div",{className:"flex items-center gap-2 px-3 py-1 border-b border-border/50 bg-surface/50 text-[10px]",children:[!t&&u("label",{className:"flex items-center gap-1",children:[o("span",{className:"text-foreground-subtle",children:"Addon:"}),o("input",{type:"text",value:m,onChange:V=>g(V.target.value),placeholder:"all",className:"w-28 px-1.5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"})]}),!n&&u("label",{className:"flex items-center gap-1",children:[o("span",{className:"text-foreground-subtle",children:"Device:"}),o("input",{type:"text",inputMode:"numeric",value:b,onChange:V=>x(V.target.value),placeholder:"all",className:"w-16 px-1.5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"})]})]}),u("div",{ref:D,className:W("flex-1 min-h-0 overflow-auto font-mono text-[10px]",i),children:[oe&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[o(Lt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading logs..."]}),!oe&&Z.length===0&&o("div",{className:"py-4 text-center text-foreground-subtle",children:"No logs found"}),Z.length>0&&o("table",{className:"w-full",children:o("tbody",{children:Z.map(V=>{const ie=Gu[V.level]??Gu.info,ue=ie.icon,de=ge(V),ce=O.has(de),Se=V.tags&&Object.keys(V.tags).length>0,pe=V.meta&&Object.keys(V.meta).length>0,Ie=Se||pe;return u("tr",{className:W("hover:bg-surface-hover/30 border-b border-border/30",Ie&&"cursor-pointer"),onClick:Ie?()=>G(de):void 0,children:[o("td",{className:"px-2 py-1 text-foreground-subtle whitespace-nowrap align-top w-[70px]",children:new Date(V.timestamp).toLocaleTimeString()}),o("td",{className:W("px-1 py-1 align-top w-5",ie.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:V.scope,children:V.scope?.replace(/^addon:/,"")??""}),o("td",{className:"px-2 py-1 text-foreground break-all",children:u("div",{className:"flex items-start gap-1",children:[Ie&&(ce?o(nr,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"}):o(_n,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"})),u("div",{className:"flex-1 min-w-0",children:[V.message,ce&&Ie&&u("div",{className:"mt-1 text-[9px] text-foreground-subtle bg-surface rounded px-2 py-1 space-y-0.5",children:[pe&&Object.entries(V.meta).filter(([,Le])=>Le!==void 0&&Le!=="").map(([Le,Ye])=>u("div",{children:[o("span",{className:"text-amber-400/80 font-medium",children:Le}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground break-all",children:Ku(Ye)})]},`m-${Le}`)),Se&&Object.entries(V.tags).filter(([,Le])=>Le!==void 0).map(([Le,Ye])=>u("div",{children:[o("span",{className:"text-primary/70 font-medium",children:Le}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground",children:Ye})]},`t-${Le}`))]})]})]})}),o("td",{className:"px-1 py-1 align-top w-5",children:o(BP,{copied:J===de,onCopy:()=>fe(V,de)})})]},de)})})})]})]})}function hy({position:e="bottom",className:t,...n}){return o("div",{className:W(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(Yt,{maxHeight:"max-h-48",...n})})}function mi({label:e,value:t}){return u("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function BP({copied:e,onCopy:t}){return o("button",{type:"button",title:"Copy this row",onClick:n=>{n.stopPropagation(),t()},className:W("rounded p-0.5 transition-colors",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?o(Po,{className:"h-3 w-3"}):o(Pn,{className:"h-3 w-3"})})}function gi({icon:e,label:t,onClick:n,disabled:r,active:s}){return u("button",{type:"button",onClick:n,disabled:r,className:W("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 FP(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 jP={[Ne.AddonStarted]:{icon:pl,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Started"},[Ne.AddonInstalled]:{icon:dl,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Installed"},[Ne.AddonRestarted]:{icon:cc,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Restarted"},[Ne.AddonUpdated]:{icon:ym,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Updated"},[Ne.AddonStopped]:{icon:vu,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Stopped"},[Ne.AddonUninstalled]:{icon:Kt,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Uninstalled"},[Ne.AddonCrashed]:{icon:ga,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Crashed"},[Ne.AddonError]:{icon:To,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Error"},[Ne.DetectionPhaseTransition]:{icon:Nn,color:"bg-violet-500/15 text-violet-400 border-violet-500/30",label:"Phase"},[Ne.DetectionResult]:{icon:H5,color:"bg-purple-500/15 text-purple-400 border-purple-500/30",label:"Detection"},[Ne.DetectionEvent]:{icon:$o,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Event"},[Ne.DetectionCameraNative]:{icon:wu,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Camera AI"},[Ne.ProviderMotion]:{icon:Nu,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[Ne.MotionOnMotionChanged]:{icon:Nu,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[Ne.MotionAnalysis]:{icon:Nn,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion analysis"},[Ne.MotionZonesRaw]:{icon:Nn,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion zones"},[Ne.ProviderDetection]:{icon:wu,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Provider Det"},[Ne.PipelineAudioInferenceResult]:{icon:fm,color:"bg-pink-500/15 text-pink-400 border-pink-500/30",label:"Audio"},[Ne.AgentOnline]:{icon:pl,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Agent Online"},[Ne.AgentOffline]:{icon:vu,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Agent Offline"},[Ne.DeviceRegistered]:{icon:dl,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Registered"},[Ne.DeviceUnregistered]:{icon:Kt,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Unregistered"},[Ne.DeviceStateChanged]:{icon:Nn,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"State"}};function vl(e,t){const n=jP[e]??{icon:pl,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 pr=Object.freeze([...new Set(Object.values(Ne))].sort()),HP=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]),VP=new Set(HP),qP=Object.freeze(pr.filter(e=>!VP.has(e)));function Ms(e,t){if(e===Ne.DetectionPhaseTransition){const s=t.to,a=t.from,i=typeof t.source=="string"?t.source:null,l=typeof t.cooldownMs=="number"?t.cooldownMs:null,c=i?` (${i}${l?`, ${Math.round(l/1e3)}s cooldown`:""})`:"";return s==="active"?`Motion detected — phase active${c}`:s==="watching"?`Cooldown expired — phase watching${c}`:`Phase: ${String(a)} → ${String(s)}${c}`}if(e===Ne.DetectionResult){const a=t.frame?.detections??[];if(a.length===0)return null;const i=new Map;for(const l of a){const c=l,d=c.class??c.macroClass,f=typeof d=="string"?d:"";f&&i.set(f,(i.get(f)??0)+1)}return[...i.entries()].map(([l,c])=>c>1?`${l} ×${c}`:l).join(", ")}if(e===Ne.PipelineAudioInferenceResult){const a=t.frame?.detections??[];return a.length===0?null:a.map(i=>{const l=i,c=l.macroClass??l.class??l.label,d=typeof c=="string"?c:"",f=l.score;return f?`${d} (${Math.round(f*100)}%)`:d}).filter(Boolean).join(", ")}if(e===Ne.DetectionEvent){const s=t.label??t.class,a=t.score??t.confidence,i=[];return typeof s=="string"&&i.push(s),typeof a=="number"&&i.push(`${Math.round(a*100)}%`),i.length>0?i.join(" — "):null}if(e===Ne.ProviderMotion)return t.active===!0?"motion start":"motion stop";if(e===Ne.DeviceStateChanged){const s=t.slice;if(s&&typeof s=="object"){const a=Object.keys(s).filter(i=>i!=="lastFetchedAt"&&i!=="ts");if(a.length>0)return a.slice(0,4).join(", ")+(a.length>4?"…":"")}return null}if(e===Ne.MotionOnMotionChanged){const s=t.detected,a=typeof t.source=="string"?t.source:null,i=s===!0?"motion start":s===!1?"motion stop":"motion";return a?`${i} (${a})`:i}if(e===Ne.ProviderDetection||e===Ne.DetectionCameraNative){const s=t.detections??[];if(!Array.isArray(s)||s.length===0)return(typeof t.class=="string"?t.class:null)??null;const a=new Map;for(const i of s){const l=i,c=l.class??l.macroClass,d=typeof c=="string"?c:"";d&&a.set(d,(a.get(d)??0)+1)}return[...a.entries()].map(([i,l])=>l>1?`${i} ×${l}`:i).join(", ")}const n=t.addonId,r=t.error;return r||(n?`addon: ${n}`:null)}function UP(e){const t=e.category;return t===Ne.DetectionResult||t===Ne.PipelineAudioInferenceResult?Ms(t,e.data)!==null:!0}const QP=300;function ir({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:f,onClose:p,className:h}){const m=q(()=>r??s??qP,[r,s]),g=q(()=>[...m].sort().join(","),[m]),[b,x]=_(()=>new Set(m)),y=ne(g);Y(()=>{y.current!==g&&(y.current=g,x(new Set(m)))},[g,m]);const w=Vn(QP),v=f??w,N=v.entries,[k,S]=_(!0),[E,A]=_(new Set),[I,B]=_(""),[$,z]=_(!1),[R,M]=_(""),[T,P]=_(0),L=ne(null),O=ne(null),j=`${e??""}:${t??""}:${String(n??"")}:${a??""}`,F=ne(j);Y(()=>{F.current!==j&&(F.current=j,v.reset(),A(new Set),P(0))},[j,v]),Y(()=>{if(!$)return;const he=_e=>{const De=O.current;De&&_e.target instanceof Node&&!De.contains(_e.target)&&z(!1)};return document.addEventListener("mousedown",he),()=>{document.removeEventListener("mousedown",he)}},[$]);const H=q(()=>{const he={};return e&&(he.agentId=e),t&&(he.addonId=t),n!==void 0&&(he.deviceId=n),a&&(he.category=a),he},[e,t,n,a]),D=q(()=>[...b].sort(),[b]),Q=q(()=>D.join(","),[D]),K=q(()=>{const he={...H,limit:l};return D.length>0&&D.length<pr.length&&(he.category=D),he},[H,l,Q,D]),{data:ee,isLoading:oe}=C.systemEvents.getRecent.useQuery(K,{staleTime:3e4}),te=ne(b);Y(()=>{te.current=b},[b]);const Z=H;C.systemEvents.subscribe.useSubscription(Z,{onData:he=>{const _e=he;_e?.id&&FP(_e,e,t,n)&&te.current.has(_e.category)&&v.append(_e)}});const re=ne(N.length);Y(()=>{const he=L.current;if(!he){re.current=N.length;return}const _e=re.current;if(re.current=N.length,!(N.length<=_e)){if(k&&he.scrollTop<=8)he.scrollTo({top:0});else if(!k&&he.scrollTop>0){const De=he.firstElementChild?.firstElementChild,Re=De instanceof HTMLElement?De.offsetHeight:28;he.scrollTop+=Re*(N.length-_e)}}},[N.length,k]);const be=q(()=>{const he=new Map;for(const Re of ee??[])he.set(Re.id,Re);for(const Re of N)he.set(Re.id,Re);let _e=[...he.values()].filter(Re=>b.has(Re.category)).filter(UP);T>0&&(_e=_e.filter(Re=>new Date(Re.timestamp).getTime()>T));const De=I.trim().toLowerCase();return De&&(_e=_e.filter(Re=>{if(Re.category.toLowerCase().includes(De)||vl(Re.category,Re.data).label.toLowerCase().includes(De))return!0;const Ln=Ms(Re.category,Re.data);if(Ln&&Ln.toLowerCase().includes(De))return!0;try{if(new Date(Re.timestamp).toLocaleTimeString().toLowerCase().includes(De))return!0}catch{}try{if(JSON.stringify(Re.data).toLowerCase().includes(De)||JSON.stringify(Re.source).toLowerCase().includes(De))return!0}catch{}return!1})),_e.sort((Re,Tn)=>new Date(Tn.timestamp).getTime()-new Date(Re.timestamp).getTime())},[ee,N,b,I,T]),X=U(he=>{A(_e=>{const De=new Set(_e);return De.has(he)?De.delete(he):De.add(he),De})},[]),G=U(he=>{x(_e=>{const De=new Set(_e);return De.has(he)?De.delete(he):De.add(he),De})},[]),J=U(()=>{x(new Set(m)),B(""),P(0)},[m]),ae=U(()=>{P(Date.now()),v.reset()},[v]),[fe,ge]=_(!1),[V,ie]=_(null),ue=U(he=>{const _e=new Date(he.timestamp).toISOString(),De=Ms(he.category,he.data)??"",Re=De?` ${De}`:"";return`${_e} [${he.category}]${Re} data=${JSON.stringify(he.data)}`},[]),de=U(()=>{const he=be.map(ue);navigator.clipboard.writeText(he.join(`
|
|
538
|
-
`)).then(()=>{ge(!0),setTimeout(()=>ge(!1),1500)})},[be,ue]),ce=U(he=>{navigator.clipboard.writeText(ue(he)).then(()=>{ie(he.id),setTimeout(()=>ie(_e=>_e===he.id?null:_e),1200)})},[ue]),Se=U(()=>{x(new Set(pr))},[]),pe=U(()=>{x(new Set)},[]),Ie=q(()=>{const he=R.trim().toLowerCase();return he?pr.filter(_e=>_e.toLowerCase().includes(he)):pr},[R]),Le=pr.length,Ye=b.size,ot=Ye===Le,cr=ot?"All":`${Ye}/${Le}`;return u("div",{className:W("h-full min-h-0 flex flex-col",h),onClick:he=>he.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Events"}),e&&o(es,{label:"agent",value:e}),t&&o(es,{label:"addon",value:t}),n!==void 0&&o(es,{label:"device",value:`#${n}`}),a&&o(es,{label:"category",value:a}),u("button",{type:"button",onClick:()=>{S(he=>!he),!k&&L.current&&L.current.scrollTo({top:0,behavior:"smooth"})},className:W("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(ac,{className:"h-2.5 w-2.5"}),k?"Auto":"Paused"]}),c&&u("div",{className:"relative",ref:O,children:[u("button",{type:"button",onClick:()=>z(he=>!he),className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",ot?"border-border text-foreground-subtle hover:text-foreground":"border-violet-500/30 bg-violet-500/10 text-violet-400"),title:"Pick events to track",children:[o(dm,{className:"h-2.5 w-2.5"}),"Filter (",cr,")"]}),$&&o(KP,{search:R,onSearchChange:M,categories:Ie,active:b,onToggle:G,onSelectAll:Se,onSelectNone:pe,onResetDefaults:J})]}),u("button",{type:"button",onClick:J,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Reset filters to defaults",children:[o(gm,{className:"h-2.5 w-2.5"}),"Reset"]}),u("button",{type:"button",onClick:ae,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Clear visible entries",children:[o(Kt,{className:"h-2.5 w-2.5"}),"Clear"]}),u("button",{type:"button",onClick:de,disabled:be.length===0,className:W("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(Pn,{className:"h-2.5 w-2.5"}),fe?"Copied!":"Copy"]}),u("div",{className:"relative",children:[o("input",{type:"text",value:I,onChange:he=>B(he.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:()=>B(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:o(We,{className:"h-2.5 w-2.5"})})]}),N.length>0&&u("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",N.length," live"]})]}),p&&o("button",{type:"button",onClick:p,className:"text-foreground-subtle hover:text-foreground",children:o(We,{className:"h-3.5 w-3.5"})})]}),u("div",{ref:L,className:W("flex-1 min-h-0 overflow-auto text-[10px]",i),children:[oe&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[o(Lt,{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(he=>{const _e=vl(he.category,he.data),De=_e.icon,Re=Ms(he.category,he.data),Tn=E.has(he.id);return u("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>X(he.id),children:[o("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(he.timestamp).toLocaleTimeString()}),o(WP,{copied:V===he.id,onCopy:()=>ce(he)}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5",children:[Tn?o(nr,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):o(_n,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),u("span",{className:W("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[9px] font-medium",_e.color),children:[o(De,{className:"h-2.5 w-2.5"}),_e.label]}),he.source.nodeId&&he.source.nodeId!=="hub"&&o("span",{className:"text-[9px] px-1 py-0.5 rounded bg-foreground-subtle/10 text-foreground-subtle font-mono",children:he.source.nodeId})]}),Re&&o("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5",children:Re}),Tn&&u("div",{className:"mt-1 ml-5 text-[9px] bg-surface rounded px-2 py-1.5 space-y-0.5 font-mono overflow-x-auto",children:[u("div",{children:[o("span",{className:"text-primary/70",children:"source"}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground",children:JSON.stringify(he.source)})]}),u("div",{children:[o("span",{className:"text-primary/70",children:"category"}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground",children:he.category})]}),Object.entries(he.data).map(([Ln,Kr])=>u("div",{children:[o("span",{className:"text-primary/70",children:Ln}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground break-all",children:typeof Kr=="object"?JSON.stringify(Kr):String(Kr)})]},Ln))]})]})]},he.id)})})]})]})}function KP({search:e,onSearchChange:t,categories:n,active:r,onToggle:s,onSelectAll:a,onSelectNone:i,onResetDefaults:l}){return u("div",{className:"absolute z-20 top-full mt-1 left-0 w-72 max-h-80 rounded-md border border-border bg-surface shadow-lg flex flex-col",onClick:c=>c.stopPropagation(),children:[u("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[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(We,{className:"h-2.5 w-2.5"})})]}),u("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[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"})]}),u("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),f=vl(c),p=f.icon;return u("button",{type:"button",onClick:()=>s(c),className:"w-full flex items-center gap-2 px-2 py-1 text-left hover:bg-surface-hover/40 text-[10px]",children:[o("input",{type:"checkbox",readOnly:!0,checked:d,className:"accent-violet-500"}),u("span",{className:W("inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[9px] font-medium shrink-0",f.color),children:[o(p,{className:"h-2.5 w-2.5"}),f.label]}),o("span",{className:"text-foreground-subtle font-mono truncate",children:c})]},c)})]})]})}function GP({position:e="bottom",className:t,...n}){return o("div",{className:W(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(ir,{maxHeight:"max-h-48",...n})})}function es({label:e,value:t}){return u("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function WP({copied:e,onCopy:t}){return o("button",{type:"button",title:"Copy this event",onClick:n=>{n.stopPropagation(),t()},className:W("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(Po,{className:"h-3 w-3"}):o(Pn,{className:"h-3 w-3"})})}function my({deviceId:e,className:t="",onOpenChild:n}){const r=C.useUtils(),s=C.deviceDiscovery.listDiscovered.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),a=C.deviceDiscovery.getStatus.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),i=C.deviceDiscovery.refreshDiscovery.useMutation({onSuccess:()=>{r.deviceDiscovery.listDiscovered.invalidate({deviceId:e}),r.deviceDiscovery.getStatus.invalidate({deviceId:e})}}),l=C.deviceDiscovery.adoptDevice.useMutation({onSuccess:()=>{r.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),c=C.deviceDiscovery.releaseDevice.useMutation({onSuccess:()=>{r.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),[d,f]=_(null),{available:p,adopted:h}=q(()=>{const v=s.data??[],N=S=>typeof S.metadata.rtspChannel=="number"?S.metadata.rtspChannel:Number.POSITIVE_INFINITY,k=(S,E)=>{const A=N(S),I=N(E);return A!==I?A-I:S.name.localeCompare(E.name)};return{available:v.filter(S=>!S.alreadyAdopted).sort(k),adopted:v.filter(S=>S.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){f(v.childNativeId);try{await l.mutateAsync({deviceId:e,childNativeId:v.childNativeId})}finally{f(null)}}async function w(v){if(v.adoptedDeviceId!=null){f(v.childNativeId);try{await c.mutateAsync({deviceId:e,childDeviceId:v.adoptedDeviceId})}finally{f(null)}}}return u("div",{className:`rounded-xl border border-border bg-surface ${t}`,children:[u("div",{className:"flex items-start justify-between gap-2 border-b border-border px-3 py-2 sm:px-5 sm:py-3",children:[u("div",{className:"min-w-0",children:[o("h3",{className:"text-sm font-semibold text-foreground",children:"Discovered devices"}),u("p",{className:"text-[11px] text-foreground-subtle",children:["Channels behind this hub. Click ",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."]})]}),u("button",{type:"button",onClick:x,disabled:i.isPending,className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-2 py-1.5 sm:px-3 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 shrink-0",children:[i.isPending?o(Lt,{className:"h-3.5 w-3.5 animate-spin"}):o(cc,{className:"h-3.5 w-3.5"}),o("span",{className:"hidden sm:inline",children:"Refresh"})]})]}),g?u("div",{className:"flex items-start gap-2 border-b border-border bg-destructive/10 px-5 py-2 text-[11px] text-destructive",children:[o(To,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),u("span",{children:["Last refresh failed: ",g]})]}):null,s.isLoading?o("div",{className:"flex items-center justify-center py-8 text-foreground-subtle",children:o(Lt,{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."}):u(me,{children:[p.length>0?o(Yu,{title:"Available to add",count:p.length,tone:"primary",children:p.map(v=>o(Zu,{child:v,busy:d===v.childNativeId,onAdopt:y,onRelease:w,onOpenChild:n},v.childNativeId))}):null,h.length>0?o(Yu,{title:"Already adopted",count:h.length,tone:"muted",children:h.map(v=>o(Zu,{child:v,busy:d===v.childNativeId,onAdopt:y,onRelease:w,onOpenChild:n},v.childNativeId))}):null]}),b!=null?u("div",{className:"border-t border-border px-5 py-2 text-[10px] text-foreground-subtle",children:["Last refreshed ",new Date(b).toLocaleString()]}):null]})}function Yu({title:e,count:t,tone:n,children:r}){return u("div",{className:"border-t border-border",children:[u("div",{className:`flex items-center justify-between border-b px-3 sm:px-5 py-1.5 text-[10px] uppercase tracking-wider ${n==="primary"?"bg-primary/5 text-primary border-primary/30":"bg-surface text-foreground-subtle border-border"}`,children:[o("span",{className:"font-semibold",children:e}),o("span",{className:"font-mono",children:t})]}),o("div",{className:"divide-y divide-border",children:r})]})}function Zu({child:e,busy:t,onAdopt:n,onRelease:r,onOpenChild:s}){return u("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2 sm:px-5 sm:py-3 sm:flex-nowrap sm:gap-3",children:[u("div",{className:"min-w-0 flex-1",children:[u("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[o(YP,{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]}),u("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-foreground-subtle",children:[typeof e.metadata.rtspChannel=="number"?u("span",{children:["ch ",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?u("span",{className:"font-mono truncate max-w-[140px]",children:[e.metadata.uid.slice(0,12),"…"]}):null]})]}),e.alreadyAdopted?u("div",{className:"flex items-center gap-2",children:[s&&e.adoptedDeviceId!==null?u("button",{type:"button",onClick:()=>s(e.adoptedDeviceId),className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",title:"Open device detail",children:[o(lm,{className:"h-3.5 w-3.5"}),"Open"]}):null,u("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(Lt,{className:"h-3.5 w-3.5 animate-spin"}):o(Kt,{className:"h-3.5 w-3.5"}),"Remove"]})]}):u("button",{type:"button",onClick:()=>{n(e)},disabled:t,className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:[t?o(Lt,{className:"h-3.5 w-3.5 animate-spin"}):o(Do,{className:"h-3.5 w-3.5"}),"Add"]})]})}function YP({status:e}){switch(e){case"online":return u("span",{className:"inline-flex items-center gap-1 rounded-full border border-emerald-500/40 bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-500",children:[o(vm,{className:"h-2.5 w-2.5"})," online"]});case"sleeping":return u("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-500",children:[o(lc,{className:"h-2.5 w-2.5"})," sleeping"]});case"offline":return u("span",{className:"inline-flex items-center gap-1 rounded-full border border-destructive/40 bg-destructive/10 px-2 py-0.5 text-[10px] font-medium text-destructive",children:[o(yS,{className:"h-2.5 w-2.5"})," offline"]});case"unknown":default:return u("span",{className:"inline-flex items-center gap-1 rounded-full border border-border bg-surface px-2 py-0.5 text-[10px] font-medium text-foreground-subtle",children:[o(om,{className:"h-2.5 w-2.5"})," unknown"]})}}function ZP(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 bi(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 XP=300,JP=Object.freeze([...new Set(xN.filter(e=>e.scope==="device").map(e=>e.name))].sort());function nd({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),[f,p]=_(""),[h,m]=_(!0),[g,b]=_(new Set),[x,y]=_(0),[w,v]=_(!1),[N,k]=_(""),S=ne(null),E=Vn(XP),A=s??E,I=A.entries,B=ne(null),$=ne(e);Y(()=>{$.current!==e&&($.current=e,A.reset(),b(new Set),y(0))},[e,A]);const z=q(()=>({deviceId:e,category:Ne.DeviceStateChanged,limit:r}),[e,r]),{data:R,isLoading:M}=C.systemEvents.getRecent.useQuery(z,{staleTime:3e4}),T=ne(c);Y(()=>{T.current=c},[c]),C.systemEvents.subscribe.useSubscription({deviceId:e,category:Ne.DeviceStateChanged},{onData:V=>{if(!ZP(V,e))return;const ie=bi(V);if(!ie)return;const ue=T.current;ue.size>0&&!ue.has(ie.capName)||A.append(ie)}});const P=ne(I.length);Y(()=>{const V=B.current;if(!V){P.current=I.length;return}const ie=P.current;if(P.current=I.length,!(I.length<=ie)){if(h&&V.scrollTop<=8)V.scrollTo({top:0});else if(!h&&V.scrollTop>0){const ue=V.firstElementChild?.firstElementChild,de=ue instanceof HTMLElement?ue.offsetHeight:28,ce=I.length-ie;V.scrollTop+=de*ce}}},[I.length,h]);const L=q(()=>{const V=new Map;for(const de of R??[]){const ce=bi(de);ce&&V.set(ce.id,ce)}for(const de of I)V.set(de.id,de);let ie=[...V.values()];x>0&&(ie=ie.filter(de=>new Date(de.timestamp).getTime()>x)),c.size>0&&(ie=ie.filter(de=>c.has(de.capName)));const ue=f.trim().toLowerCase();return ue&&(ie=ie.filter(de=>{if(de.capName.toLowerCase().includes(ue))return!0;try{if(new Date(de.timestamp).toLocaleTimeString().toLowerCase().includes(ue))return!0}catch{}try{if(Object.entries(de.slice).map(([Se,pe])=>`${Se}=${xi(pe)}`).join(" · ").toLowerCase().includes(ue))return!0}catch{}try{if(JSON.stringify(de.slice).toLowerCase().includes(ue))return!0}catch{}return!1})),ie.sort((de,ce)=>new Date(ce.timestamp).getTime()-new Date(de.timestamp).getTime())},[R,I,c,f,x]),O=q(()=>{const V=new Set(JP);for(const ie of R??[]){const ue=bi(ie);ue&&V.add(ue.capName)}for(const ie of I)V.add(ie.capName);return[...V].sort()},[R,I]),j=U(V=>{b(ie=>{const ue=new Set(ie);return ue.has(V)?ue.delete(V):ue.add(V),ue})},[]),F=U(V=>{d(ie=>{const ue=new Set(ie);return ue.has(V)?ue.delete(V):ue.add(V),ue})},[]),H=U(()=>{d(new Set(t??[])),p("")},[t]),D=U(()=>{y(Date.now()),A.reset()},[A]),[Q,K]=_(!1),[ee,oe]=_(null),te=U(V=>`${new Date(V.timestamp).toISOString()} [${V.capName}] slice=${JSON.stringify(V.slice)}`,[]),Z=U(()=>{const V=L.map(te);navigator.clipboard.writeText(V.join(`
|
|
539
|
-
`)).then(()=>{K(!0),setTimeout(()=>K(!1),1500)})},[L,te]),re=U(V=>{navigator.clipboard.writeText(te(V)).then(()=>{oe(V.id),setTimeout(()=>oe(ie=>ie===V.id?null:ie),1200)})},[te]),be=U(()=>{d(new Set(O))},[O]),X=U(()=>{d(new Set)},[]),G=q(()=>{const V=N.trim().toLowerCase();return V?O.filter(ie=>ie.toLowerCase().includes(V)):O},[N,O]),J=O.length,ae=c.size,fe=ae===0||ae===J,ge=fe?"All":`${ae}/${J}`;return Y(()=>{if(!w)return;const V=ie=>{const ue=S.current;ue&&!ue.contains(ie.target)&&v(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[w]),u("div",{className:W("h-full min-h-0 flex flex-col",i),onClick:V=>V.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"State"}),o(e$,{label:"device",value:`#${e}`}),u("button",{type:"button",onClick:()=>{m(V=>!V),!h&&B.current&&B.current.scrollTo({top:0,behavior:"smooth"})},className:W("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(ac,{className:"h-2.5 w-2.5"}),h?"Auto":"Paused"]}),u("div",{className:"relative",ref:S,children:[u("button",{type:"button",onClick:()=>v(V=>!V),className:W("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(dm,{className:"h-2.5 w-2.5"}),"Filter (",ge,")"]}),w&&o(t$,{search:N,onSearchChange:k,caps:G,active:c,onToggle:F,onSelectAll:be,onSelectNone:X,onResetDefaults:H})]}),u("button",{type:"button",onClick:H,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Reset filters",children:[o(gm,{className:"h-2.5 w-2.5"}),"Reset"]}),u("button",{type:"button",onClick:D,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(Kt,{className:"h-2.5 w-2.5"}),"Clear"]}),u("button",{type:"button",onClick:Z,disabled:L.length===0,className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",Q?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",L.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible state changes",children:[o(Pn,{className:"h-2.5 w-2.5"}),Q?"Copied!":"Copy"]}),u("div",{className:"relative",children:[o("input",{type:"text",value:f,onChange:V=>p(V.target.value),placeholder:"Search…",className:"w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"}),f&&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(We,{className:"h-2.5 w-2.5"})})]}),I.length>0&&u("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",I.length," live"]})]}),a&&o("button",{type:"button",onClick:a,className:"text-foreground-subtle hover:text-foreground",children:o(We,{className:"h-3.5 w-3.5"})})]}),u("div",{ref:B,className:W("flex-1 min-h-0 overflow-auto text-[10px]",n),children:[M&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[o(Lt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading state changes..."]}),!M&&L.length===0&&o("div",{className:"py-4 text-center text-foreground-subtle",children:"No state changes"}),L.length>0&&o("div",{className:"divide-y divide-border/30",children:L.map(V=>{const ie=g.has(V.id),ue=Object.entries(V.slice),de=ue.slice(0,3).map(([ce,Se])=>`${ce}=${xi(Se)}`).join(" · ");return u("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>j(V.id),children:[o("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(V.timestamp).toLocaleTimeString()}),o(n$,{copied:ee===V.id,onCopy:()=>re(V)}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5",children:[ie?o(nr,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):o(_n,{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:V.capName}),ue.length>3&&u("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}),ie&&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,Se])=>u("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:xi(Se)})]},ce))})]})]},V.id)})})]})]})}function xi(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 e$({label:e,value:t}){return u("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function t$({search:e,onSearchChange:t,caps:n,active:r,onToggle:s,onSelectAll:a,onSelectNone:i,onResetDefaults:l}){return u("div",{className:"absolute z-20 top-full mt-1 left-0 w-72 max-h-80 rounded-md border border-border bg-surface shadow-lg flex flex-col",onClick:c=>c.stopPropagation(),children:[u("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[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(We,{className:"h-2.5 w-2.5"})})]}),u("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[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"})]}),u("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 u("button",{type:"button",onClick:()=>s(c),className:"w-full flex items-center gap-2 px-2 py-1 text-left hover:bg-surface-hover/40 text-[10px]",children:[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 n$({copied:e,onCopy:t}){return o("button",{type:"button",title:"Copy this state change",onClick:n=>{n.stopPropagation(),t()},className:W("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(Po,{className:"h-3 w-3"}):o(Pn,{className:"h-3 w-3"})})}const yi=500,r$=[{id:"logs",label:"Logs",icon:q5},{id:"events",label:"Events",icon:ma},{id:"state",label:"State",icon:Qk}];function o$({deviceId:e,defaultEventCategories:t,defaultStateCaps:n,initialTab:r="events",className:s,maxHeight:a="max-h-96"}){const[i,l]=_(r),c=Vn(yi),d=Vn(yi),f=Vn(yi),p=c.reset,h=d.reset,m=f.reset;return Y(()=>{p(),h(),m()},[e,p,h,m]),u("div",{className:W("flex flex-col h-full min-h-0",s),children:[o("div",{className:"flex items-center gap-1 mb-2 shrink-0",children:r$.map(({id:g,label:b,icon:x})=>u("button",{type:"button",onClick:()=>l(g),className:W("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))}),u("div",{className:"flex-1 min-h-0 overflow-hidden",children:[i==="logs"&&o(Yt,{deviceId:e,maxHeight:a,showFilters:!1,liveBuffer:c}),i==="events"&&o(ir,{deviceId:e,defaultCategories:t,maxHeight:a,showCategoryFilter:!0,liveBuffer:d}),i==="state"&&o(nd,{deviceId:e,defaultCaps:n,maxHeight:a,liveBuffer:f})]})]})}function gy({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:f,onSuccess:p}){const[h,m]=_(!1),[g,b]=_(!1),[x,y]=_(null),w=async()=>{y(null),b(!0);try{const v=await f();p?.(v),m(!1)}catch(v){y(v instanceof Error?v.message:String(v))}finally{b(!1)}};return u(me,{children:[u(Ve,{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(Mm,{open:h,onOpenChange:v=>!g&&m(v),children:u(mc,{children:[u(Em,{children:[u(Am,{className:"flex items-center gap-2",children:[o(To,{className:"h-4 w-4 text-amber-400"}),n]}),typeof r=="string"?o(_m,{children:r}):r]}),x&&o("div",{className:W("mt-2 px-3 py-2 rounded border border-danger/40 bg-danger/10","text-xs text-danger"),children:x}),u(Im,{children:[o(Ve,{type:"button",variant:"ghost",size:l,disabled:g,onClick:()=>m(!1),children:"Cancel"}),u(Ve,{type:"button",variant:i,size:l,disabled:g,onClick:()=>{w()},children:[g&&o(Lt,{className:"h-3.5 w-3.5 animate-spin"}),s??e]})]})]})})]})}function ts({direction:e,icon:t,disabled:n,className:r,variant:s,onMove:a,onStart:i,onStop:l}){const[c,d]=_(null),[f,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="",f?l():c!==null&&a(e),d(null),p(!1)},[f,e,a,l,c]),g=U(w=>{const v=Number(w.currentTarget.dataset.timer);v&&clearTimeout(v),w.currentTarget.dataset.timer="",f&&l(),d(null),p(!1)},[f,l]),b=s==="panel"?"h-9 w-9":"h-7 w-7",x=s==="panel"?"h-4 w-4":"h-3.5 w-3.5";return o("button",{type:"button",disabled:n,onPointerDown:h,onPointerUp:m,onPointerCancel:g,className:W("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 rd({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:f,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=W(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",S=w?"h-4 w-4":"h-3.5 w-3.5",E=w?"text-foreground hover:bg-surface-hover":"text-white hover:bg-white/15",A=w?"h-12 w-px bg-border mx-1":"h-12 w-px bg-white/15 mx-1";return u("div",{className:W(v,a),children:[g&&u("div",{className:"rounded bg-danger/90 px-2 py-1 text-[10px] font-medium text-white shadow-lg max-w-[200px] self-center",children:["PTZ: ",g]}),u("div",{className:W(N,w&&"justify-center"),children:[u("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(ts,{direction:"up",icon:ok,variant:t,onMove:i,onStart:l,onStop:c}),o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),o(ts,{direction:"left",icon:J2,variant:t,onMove:i,onStart:l,onStop:c}),o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),o(ts,{direction:"right",icon:tk,variant:t,onMove:i,onStart:l,onStop:c}),o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),o(ts,{direction:"down",icon:Z2,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:A}),u("div",{className:"flex flex-col gap-0.5",children:[r&&u(me,{children:[o("button",{type:"button",onClick:()=>d("in"),disabled:m,title:"Zoom in",className:W("flex items-center justify-center rounded disabled:opacity-40",k,E),children:o(CS,{className:S})}),o("button",{type:"button",onClick:()=>d("out"),disabled:m,title:"Zoom out",className:W("flex items-center justify-center rounded disabled:opacity-40",k,E),children:o(ES,{className:S})})]}),s&&o("button",{type:"button",onClick:()=>f(),disabled:m,title:"Go home",className:W("flex items-center justify-center rounded disabled:opacity-40",k,E),children:o(um,{className:S})})]}),y&&u("div",{className:"relative",children:[u("button",{type:"button",onClick:()=>x(I=>!I),disabled:m,className:W("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(nr,{className:W("h-3 w-3 transition-transform",b&&"rotate-180")})]}),b&&o("div",{className:W("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:W("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 s$(e,t){const n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function a$({trpc:e,deviceId:t,deviceName:n,size:r="sm",className:s}){const[a,i]=_(!1),[l,c]=_(!1),[d,f]=_(null),p=n.replace(/[^a-zA-Z0-9_.-]+/g,"_"),h=U(async k=>{i(!0),f(null),c(!1);try{const S=await e.snapshot.getSnapshot.query({deviceId:t,force:!0});if(!S)throw new Error("No snapshot available");const E=`data:${S.contentType};base64,${S.base64}`;if(k==="copy")try{await navigator.clipboard.writeText(E)}catch{throw new Error("Clipboard unavailable")}else{const A=S.contentType.includes("png")?"png":"jpg",I=new Date().toISOString().replace(/[:.]/g,"-");s$(`${p}-${I}.${A}`,E)}c(!0),setTimeout(()=>c(!1),1500)}catch(S){f(S instanceof Error?S.message:String(S))}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 u("button",{type:"button",title:"Click to download · long-press to copy",disabled:a,onPointerDown:w,onPointerUp:v,onPointerLeave:N,onPointerCancel:N,className:W("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(Lt,{className:"h-3.5 w-3.5 animate-spin"}):l?o(Po,{className:"h-3.5 w-3.5 text-success"}):o(ic,{className:"h-3.5 w-3.5"}),"Snapshot"]})}function i$(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 od({history:e,limit:t=5,latestIsFresh:n,className:r}){if(e.length===0)return null;const s=n?fk:ma,a=e.slice(0,t);return u("div",{className:W("rounded-lg border border-border bg-surface px-3 py-2",r),children:[u("div",{className:"flex items-center gap-2 mb-2",children:[o(s,{className:W("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=>u("li",{className:"flex items-center justify-between text-[11px]",title:new Date(i.timestamp).toLocaleString(),children:[o("span",{className:"text-foreground",children:i$(i.timestamp)}),o("span",{className:"text-foreground-subtle font-mono text-[10px]",children:new Date(i.timestamp).toLocaleTimeString()})]},`${i.deviceId}-${i.timestamp}`))})]})}function by({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:u(qm,{open:s,onOpenChange:a,children:[o(Um,{title:r,className:W("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(im,{className:"h-4 w-4"})}),u(Qm,{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)=>u("li",{children:[l.separatorBefore&&c>0&&o("div",{className:"my-1 h-px bg-border"}),u("button",{type:"button",disabled:l.disabled,onClick:()=>{l.disabled||(l.onClick(),a(!1))},className:W("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:W("h-3.5 w-3.5 shrink-0 mt-0.5",l.danger&&"text-danger/80")}),u("span",{className:"flex-1 min-w-0",children:[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 l$=[{value:"view",label:"View",icon:$o,hint:"Read-only — queries + subscriptions"},{value:"create",label:"Create",icon:M5,hint:"Mutations that create or update"},{value:"delete",label:"Delete",icon:Kt,hint:"Destructive ops (delete/revoke/reset/…)"}],c$=["device","system"];function d$(){return{type:"capability",target:"",access:["view"]}}function u$(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 p$(e,t,n,r){let s;switch(e){case"addon":s=n;break;case"capability":s=r;break;case"category":s=c$.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 f$(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 sd({value:e,onChange:t,clampToParent:n,emptyHint:r}){const{data:s}=va(),{data:a}=$n({}),i=q(()=>(s??[]).map(g=>({value:g.manifest.id,label:g.manifest.id})).sort((g,b)=>g.label.localeCompare(b.label)),[s]),l=q(()=>[...yN].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:u$(n),[n]),f=(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 f(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,d$()])};return u("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=f$(g,n);return u("div",{className:"flex flex-wrap items-start gap-1.5 rounded border border-border bg-surface px-2 py-1.5",children:[u("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(h$,{value:g.targets,choices:c,clampToParent:d,onChange:y=>p(b,{targets:y})}):u("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:[u("option",{value:"",children:["— pick ",g.type," —"]}),p$(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:l$.map(({value:y,label:w,icon:v,hint:N})=>{const k=g.access.includes(y),S=n!=null&&!x.includes(y)&&!k;return u("label",{title:S?`${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"} ${S?"opacity-40 cursor-not-allowed":""}`,children:[o("input",{type:"checkbox",checked:k,disabled:S,onChange:E=>{const A=new Set(g.access);E.target.checked?A.add(y):A.delete(y),p(b,{access:[...A]})},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(We,{className:"h-3 w-3"})})]},b)}),u("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(Do,{className:"h-3 w-3"}),"Add scope"]})]})}function h$({value:e,choices:t,clampToParent:n,onChange:r}){const[s,a]=_(""),i=q(()=>{const f=n==null?t:t.filter(h=>n.includes(h.value)),p=new Set(e);return f.filter(h=>!p.has(h.value))},[t,n,e]),l=f=>t.find(p=>p.value===f)?.label??`#${f}`,c=f=>{f&&(r([...e,f]),a(""))},d=f=>{r(e.filter(p=>p!==f))};return u("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(f=>u("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(f),o("button",{type:"button",onClick:()=>d(f),className:"hover:text-danger transition-colors",title:"Remove device",children:o(We,{className:"h-2.5 w-2.5"})})]},f)),i.length>0&&u("select",{value:s,onChange:f=>c(f.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(f=>o("option",{value:f.value,children:f.label},f.value))]})]})}function ad(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 xy=fn("camstack:zone-editing",null);function yy({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))},[]),f=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:f,setSelectedZoneId:p,startDrawing:h,exitEditing:m,enterDraft:g,updateDraft:b,discardDraft:x}),[t,r,a,l,d,f,p,h,m,g,b,x]);return o(xy.Provider,{value:y,children:e})}function m$(){return ve(xy)}const Xu=500,g$=800;function ns(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 rs(e,t){return e?.id===t}function vy(e,t){const[n,r]=_(null),[s,a]=_(null),[i,l]=_(null),[c,d]=_("watching"),f=ne(void 0),p=ne(void 0),h=ne(void 0);return Y(()=>{if(t===null)return;const m=ns(e,"detection.motion-analysis",g=>{const b=g;if(!rs(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}),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>r(null),Xu))});return()=>{m?.unsubscribe(),f.current&&clearTimeout(f.current)}},[e,t]),Y(()=>{if(t===null)return;const m=ns(e,"detection.motion-zones-raw",g=>{const b=g;if(!rs(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),Xu))});return()=>{m?.unsubscribe(),p.current&&clearTimeout(p.current)}},[e,t]),Y(()=>{if(t===null)return;const m=ns(e,"detection.result",g=>{const b=g;if(!rs(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),g$))});return()=>{m?.unsubscribe(),h.current&&clearTimeout(h.current)}},[e,t]),Y(()=>{if(t===null)return;const m=ns(e,"detection.phase-transition",g=>{const b=g;rs(b?.source,t)&&b.data?.to&&d(b.data.to)});return()=>{m?.unsubscribe()}},[e,t]),{motion:n,motionRaw:s,detection:i,phase:c}}function id(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]),ut("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]),f=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:f,closeSession:p}}const Ju={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 ld(e,t,n){const r=n?.defaultSpeed??.5,s=n?.pulseMs??250,a=n?.enabled??!0,l=St(e,a?t:null)?.ptz,[c,d]=_([]),[f,p]=_(!1),[h,m]=_(null),g=U(async()=>{if(!(!a||!l))try{const S=await l.getPresets({});d(S)}catch(S){const E=S instanceof Error?S.message:String(S);if(E.includes("provider not available")||E.includes("no 'ptz' binding"))return;m(E)}},[l,a]);Y(()=>{g()},[g]);const b=U(async S=>{if(!(!a||!l)){m(null),p(!0);try{return await S()}catch(E){m(E instanceof Error?E.message:String(E));return}finally{p(!1)}}},[a,l]),x=U(async(S,E)=>{if(!l)return;const A=Ju[S],I=E??r;await b(async()=>{await l.move({pan:A.pan,tilt:A.tilt,speed:I}),await new Promise(B=>setTimeout(B,s)),await l.stop({})})},[l,r,s,b]),y=U(async(S,E)=>{if(!l)return;const A=Ju[S],I=E??r;await b(()=>l.continuousMove({pan:A.pan,tilt:A.tilt,speed:I}))},[l,r,b]),w=U(async()=>{l&&await b(()=>l.stop({}))},[l,b]),v=U(async(S,E)=>{if(!l)return;const A=S==="in"?1:-1,I=E??r;await b(async()=>{await l.move({zoom:A,speed:I}),await new Promise(B=>setTimeout(B,s)),await l.stop({})})},[l,r,s,b]),N=U(async()=>{l&&await b(()=>l.goHome({}))},[l,b]),k=U(async S=>{l&&await b(()=>l.goToPreset({presetId:S}))},[l,b]);return{move:x,startContinuous:y,stopContinuous:w,zoom:v,goHome:N,goToPreset:k,presets:c,refreshPresets:g,busy:f,error:h}}function cd(e){const t=e?.deviceId??null,n=e?.historyLimit??20,r=Or("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 b$(e){const t=Te(),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 x$(e){const t=Te(),[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 y$(e,t,n){const r=Te();return Jn({queryKey:e,queryFn:()=>t(r)(),...n})}function v$(e,t){const n=Te();return nc({mutationFn:r=>e(n)(r),...t})}function w$(e,t){const n=Te(),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 f=JSON.parse(l),h=f.length===1&&Array.isArray(f[0])?f:[f];r.invalidateQueries({queryKey:h})};d();for(const f of i.split("|"))if(f)try{c.push(n.subscribeEvent(f,d))}catch{}return()=>{for(const f of c)f()}},[n,r,i,l,s])}const N$=Object.freeze(Object.defineProperty({__proto__:null,AddonGlobalSettingsForm:pP,AgentStepEditor:ya,AppShell:bC,AudioClassificationList:DP,AudioLevelWaveform:_P,AudioWaveform:AP,BTN_COMPACT:A2,BTN_COMPACT_DANGER:P2,BTN_COMPACT_PRIMARY:_2,BTN_COMPACT_WARNING:$2,Badge:br,BatteryBadge:Ic,BottomSheet:bc,Breadcrumb:vc,Button:Ve,CHIP_ACTIVE:L2,CHIP_BASE:T2,CHIP_INACTIVE:R2,CLASS_COLORS:to,CameraStreamPlayer:cy,Card:on,Checkbox:km,CodeBlock:mC,CollapsibleCard:wm,ConfigFormBuilder:iy,ConfigFormField:ar,ConfigSchemaField:xa,ConfirmActionButton:gy,ConfirmDialogProvider:og,CustomFieldRenderersProvider:Sg,DEFAULT_COLOR:yg,DataTable:Wm,DetectionCanvas:y3,DetectionOverlay:ly,DetectionResultTree:k3,DevShell:Ng,DeviceActivityPanel:o$,DeviceCard:yC,DeviceContextProvider:Mg,DeviceGrid:vC,DeviceItem:go,DeviceList:bo,Dialog:Mm,DialogContent:mc,DialogDescription:_m,DialogFooter:Im,DialogHeader:Em,DialogTitle:Am,DialogTrigger:LS,DiscoveryPanel:my,DoorbellRecentPanel:od,Dropdown:$m,DropdownContent:Tm,DropdownItem:Lm,DropdownTrigger:Dm,EmptyState:ng,EventStream:ir,FilterBar:gC,FloatingEventStream:GP,FloatingLogStream:hy,FloatingPanel:qS,FormField:uC,GRID_GAP:Jh,GRID_PAIRED:k2,GRID_QUICK_STATS:N2,INPUT_COMPACT:D2,IconButton:uc,ImageSelector:I3,InferenceConfigSelector:A3,Input:Bs,KebabMenu:by,KeyValueList:hC,LIST_ROW:em,Label:pc,LogStream:Yt,LoginForm:vg,MobileDrawer:yc,NodeMultiSelectField:sy,NodePicker:eg,NodeSelectField:oy,PHASE_CONFIG:cl,PTZOverlay:rd,PageHeader:pC,PhaseIcon:td,PipelineBuilder:Ac,PipelineRuntimeSelector:g3,PipelineStep:Cs,PipelineTreeMatrix:Nc,PlayerOverlaysProvider:dy,Popover:qm,PopoverContent:Qm,PopoverTrigger:Um,ProviderBadge:lC,ResponseLog:TP,SECTION_BODY:w2,SECTION_CARD:y2,SECTION_HEADER:v2,SPLIT_PANEL_OUTER:S2,SPLIT_PANEL_SIDE:C2,STACK_GAP:Xh,ScopePicker:sd,ScrollArea:xc,Select:Fs,SemanticBadge:tg,Separator:fc,Sidebar:gl,SidebarItem:ml,Skeleton:Nm,SlideOverPanel:wc,SnapshotButton:a$,StatCard:fC,StateValuesStream:nd,StatusBadge:aC,StepTimings:E3,StepTreeMaster:Zm,StreamPanel:ed,Switch:hc,SystemProvider:Sc,TEXT_FIELD_LABEL:E2,TEXT_HINT:zs,TEXT_METRIC:ll,TEXT_SECTION_LABEL:M2,TEXT_VALUE:I2,Tabs:FS,TabsContent:VS,TabsList:jS,TabsTrigger:HS,ThemeProvider:Rs,Tooltip:OS,TooltipContent:BS,TooltipTrigger:zS,VersionBadge:dC,WidgetRegistryProvider:Jx,WidgetSlot:it,ZoneEditingProvider:yy,buildStepTreeFromSchema:ba,cn:W,createSharedContext:fn,createTheme:kN,darkColors:_h,defaultTheme:al,deriveDeviceKind:NC,ensureMfHostInit:sc,getClassColor:ct,getPhaseVisual:tr,isFieldVisible:Zc,lightColors:Ph,mirror:tm,mountAddonPage:z3,providerIcons:IS,statusIcons:AS,themeToCss:IN,trpc:C,useAccessoriesGetStatus:B3,useAddonPagesListPages:$c,useAddonSettingsGetDeviceSettings:W3,useAddonSettingsGetGlobalSettings:Lc,useAddonSettingsUpdateDeviceSettings:Bg,useAddonSettingsUpdateGlobalSettings:zg,useAddonWidgetsListWidgets:Fg,useAddonsApplyAutoUpdateToAll:Og,useAddonsCustom:K3,useAddonsForceRefresh:_g,useAddonsGetAddonAutoUpdate:Lg,useAddonsGetAutoUpdateSettings:Tg,useAddonsGetLogs:F3,useAddonsGetVersions:$g,useAddonsInstallFromWorkspace:H3,useAddonsInstallPackage:Dc,useAddonsIsWorkspaceAvailable:V3,useAddonsList:va,useAddonsListPackages:j3,useAddonsListUpdates:Tc,useAddonsListWorkspacePackages:q3,useAddonsOnAddonLogs:G3,useAddonsReloadPackages:Ig,useAddonsRestartAddon:wa,useAddonsRestartServer:Pg,useAddonsRetryLoad:Dg,useAddonsRollbackPackage:U3,useAddonsSearchAvailable:Ag,useAddonsSetAddonAutoUpdate:Rg,useAddonsSetAutoUpdateSettings:Q3,useAddonsUninstallPackage:Eg,useAddonsUpdatePackage:xl,useAlertsDismiss:Ug,useAlertsEmit:Y3,useAlertsGetUnreadCount:Hg,useAlertsList:jg,useAlertsMarkAllRead:qg,useAlertsMarkRead:Vg,useAlertsUpdate:Z3,useAllWidgets:ny,useAudioAnalysisApplyDeviceSettingsPatch:tM,useAudioAnalysisGetDeviceLiveContribution:eM,useAudioAnalysisGetDeviceSettingsContribution:J3,useAudioAnalysisResolveDeviceSettings:X3,useAudioAnalyzerAnalyseChunk:nM,useAudioAnalyzerClassify:rM,useAudioAnalyzerDispose:sM,useAudioAnalyzerIsReady:oM,useAudioAnalyzerReprobeAudioEngine:Qg,useAudioCodecCanHandle:iM,useAudioCodecCloseSession:dM,useAudioCodecCreateDecodeSession:lM,useAudioCodecCreateEncodeSession:cM,useAudioCodecFlushEncode:mM,useAudioCodecListActiveSessions:gM,useAudioCodecListSupportedCodecs:aM,useAudioCodecPullEncoded:hM,useAudioCodecPullPcm:pM,useAudioCodecPushEncodedFrame:uM,useAudioCodecPushPcm:fM,useAudioMetricsGetCurrentSnapshot:bM,useAudioMetricsGetHistory:xM,useAuthenticationListProviders:Rc,useAuthenticationSetProviderEnabled:yM,useBackupDelete:Zg,useBackupGetEntries:Wg,useBackupList:vM,useBackupListArchives:zc,useBackupListDestinations:Oc,useBackupListLocations:Gg,useBackupPreviewSchedule:Jg,useBackupRestore:Yg,useBackupTrigger:Kg,useBackupUpsertDestinationPolicy:Xg,useBatteryGetStatus:wM,useBrightnessGetStatus:kM,useBrightnessSetBrightness:NM,useCameraStreamsGetBrokerStreams:CM,useCameraStreamsGetCameraStreams:SM,useCameraStreamsGetRtspEntries:MM,useClusterNodes:zr,useConfirm:Xe,useCustomFieldRenderer:Cg,useDebouncedString:xg,useDecoderCreateSession:AM,useDecoderDestroySession:_M,useDecoderGetInfo:IM,useDecoderGetStats:LM,useDecoderListActiveSessions:RM,useDecoderOpenStream:$M,useDecoderPullFrames:DM,useDecoderPushPacket:PM,useDecoderReprobeHwaccel:eb,useDecoderSupportsCodec:EM,useDecoderUpdateConfig:TM,useDetectionPipelineApplyDeviceSettingsPatch:BM,useDetectionPipelineGetDeviceLiveContribution:zM,useDetectionPipelineGetDeviceSettingsContribution:OM,useDevShell:D3,useDevice:x$,useDeviceBattery:Mc,useDeviceCapability:Br,useDeviceDetections:vy,useDeviceDiscoveryAdoptDevice:FM,useDeviceDiscoveryGetStatus:HM,useDeviceDiscoveryListDiscovered:tb,useDeviceDiscoveryRefreshDiscovery:nb,useDeviceDiscoveryReleaseDevice:jM,useDeviceId:hn,useDeviceManagerAddLocation:ZM,useDeviceManagerAdoptDevice:hb,useDeviceManagerAllocateDeviceId:VM,useDeviceManagerCreateDevice:gb,useDeviceManagerDisable:lb,useDeviceManagerDiscoverDevices:Fc,useDeviceManagerEnable:ib,useDeviceManagerGetAllBindings:l4,useDeviceManagerGetBindings:db,useDeviceManagerGetChildren:ab,useDeviceManagerGetConfigSchema:n4,useDeviceManagerGetCreationSchema:mb,useDeviceManagerGetDevice:Qn,useDeviceManagerGetDeviceAggregate:Bc,useDeviceManagerGetDeviceLiveInfoAggregate:u4,useDeviceManagerGetDeviceSettingsAggregate:d4,useDeviceManagerGetDeviceStatusAggregate:h4,useDeviceManagerGetSettingsSchema:r4,useDeviceManagerGetStreamProfileMap:s4,useDeviceManagerGetStreamSources:t4,useDeviceManagerListAll:$n,useDeviceManagerListBindableCapsForDeviceType:pb,useDeviceManagerListLocations:sb,useDeviceManagerListPersistedByAddon:e4,useDeviceManagerListWrappersForCap:c4,useDeviceManagerLoadConfig:KM,useDeviceManagerLoadMeta:WM,useDeviceManagerLoadRuntimeState:GM,useDeviceManagerPersistConfig:QM,useDeviceManagerProbeStreams:i4,useDeviceManagerRegisterDevice:qM,useDeviceManagerRemove:cb,useDeviceManagerRemoveDevice:UM,useDeviceManagerRemoveLocation:XM,useDeviceManagerSetDisabled:JM,useDeviceManagerSetLocation:ob,useDeviceManagerSetMetadata:YM,useDeviceManagerSetName:rb,useDeviceManagerSetStreamProfileMap:a4,useDeviceManagerSetWrapperActive:ub,useDeviceManagerTestCreationField:jc,useDeviceManagerTestField:f4,useDeviceManagerUpdateConfig:o4,useDeviceManagerUpdateDeviceField:p4,useDeviceManagerUpdateDeviceFieldsBatch:fb,useDeviceOpsGetConfigEntries:g4,useDeviceOpsGetSettingsSchema:y4,useDeviceOpsGetStreamSources:m4,useDeviceOpsRemoveDevice:x4,useDeviceOpsSetConfig:b4,useDeviceProviderAdoptDiscoveredDevice:M4,useDeviceProviderCreateDevice:A4,useDeviceProviderDiscoverDevices:C4,useDeviceProviderGetChildCreationSchema:I4,useDeviceProviderGetDevices:k4,useDeviceProviderGetStatus:N4,useDeviceProviderStart:v4,useDeviceProviderStop:w4,useDeviceProviderSupportsDiscovery:S4,useDeviceProviderSupportsManualCreation:E4,useDeviceProviderTestCreationField:_4,useDeviceProxy:St,useDeviceSnapshot:Pc,useDeviceSnapshotImage:Ec,useDeviceState:sg,useDeviceStateGetAllSnapshots:D4,useDeviceStateGetCapSlice:$4,useDeviceStateGetSnapshot:P4,useDeviceStateSetCapSlice:T4,useDeviceStateSlice:sn,useDeviceWebrtc:id,useDevices:b$,useDoorbellEvents:cd,useDoorbellGetStatus:L4,useEventInvalidation:w$,useEventStreamLatest:Or,useEventStreamMap:Cc,useEventsGetEventClipUrl:z4,useEventsGetEventThumbnail:O4,useEventsGetEvents:R4,useIntegrationsCreate:yb,useIntegrationsDelete:wb,useIntegrationsGet:bb,useIntegrationsGetAvailableTypes:Nb,useIntegrationsGetByAddonId:xb,useIntegrationsGetSettings:B4,useIntegrationsList:Hc,useIntegrationsSetSettings:F4,useIntegrationsTestConnection:kb,useIntegrationsUpdate:vb,useIntercomGetStatus:j4,useIntercomHandleAnswer:Cb,useIntercomStartSession:Sb,useIntercomStopSession:Mb,useIsMidWidth:jm,useIsMobile:or,useLiveBuffer:Vn,useLiveEvent:ut,useLocalNetworkGetAllowedAddresses:Ab,useLocalNetworkGetConnectionEndpoints:Ib,useLocalNetworkGetPreferred:H4,useLocalNetworkList:Eb,useLocalNetworkResetAllowlistToBestMatch:Pb,useLocalNetworkSetAllowedAddresses:_b,useMeshOrchestratorJoinProvider:Db,useMeshOrchestratorLeaveProvider:Tb,useMeshOrchestratorListProviders:$b,useMetricsProviderCollectSnapshot:V4,useMetricsProviderGetAddonStats:Z4,useMetricsProviderGetCached:q4,useMetricsProviderGetCpuTemperature:G4,useMetricsProviderGetCurrent:U4,useMetricsProviderGetDiskSpace:Q4,useMetricsProviderGetGpuInfo:K4,useMetricsProviderGetProcessStats:W4,useMetricsProviderKillProcess:Rb,useMetricsProviderListAddonInstances:Y4,useMetricsProviderListNodeProcesses:Lb,useMotionDetectionAnalyze:eE,useMotionDetectionApplyDeviceSettingsPatch:sE,useMotionDetectionGetDeviceLiveContribution:oE,useMotionDetectionGetDeviceSettingsContribution:rE,useMotionDetectionRemoveCamera:tE,useMotionDetectionReset:nE,useMotionGetStatus:J4,useMotionIsDetected:X4,useMotionTriggerGetStatus:iE,useMotionTriggerSetMotionTrigger:aE,useNativeObjectDetectionGetStatus:lE,useNetworkQualityGetAllStats:cE,useNetworkQualityGetDeviceStats:Vc,useNetworkQualityReportClientStats:dE,useNodesClusterAddonStatus:jb,useNodesDeployAddon:uE,useNodesExecuteQuery:fE,useNodesRenameNode:Fb,useNodesRestartAddon:Na,useNodesRestartNode:Bb,useNodesRestartProcess:zb,useNodesSetProcessLogLevel:Hb,useNodesShutdownNode:pE,useNodesTopology:Dn,useNodesUndeployAddon:Ob,useNotificationOutputSend:hE,useNotificationOutputSendTest:mE,useOptionalSystem:oC,useOptionalWidgetRegistry:ry,useOsdGetStatus:bE,useOsdSetOverlay:gE,usePTZ:ld,usePipelineAnalyticsApplyDeviceSettingsPatch:AE,usePipelineAnalyticsClearTracks:wE,usePipelineAnalyticsGetActiveTracks:xE,usePipelineAnalyticsGetAudioEvents:SE,usePipelineAnalyticsGetDeviceLiveContribution:IE,usePipelineAnalyticsGetDeviceSettingsContribution:EE,usePipelineAnalyticsGetEventMedia:CE,usePipelineAnalyticsGetMotionEvents:NE,usePipelineAnalyticsGetObjectEvents:kE,usePipelineAnalyticsGetTrack:yE,usePipelineAnalyticsGetTrackMedia:ME,usePipelineAnalyticsListTracks:vE,usePipelineExecutorCacheFrameInPool:UE,usePipelineExecutorDeleteModel:Kb,usePipelineExecutorDeleteTemplate:BE,usePipelineExecutorDetect:HE,usePipelineExecutorDownloadModel:Qb,usePipelineExecutorGetAddonModels:jE,usePipelineExecutorGetAudioCapabilities:eI,usePipelineExecutorGetAvailableEngines:Vb,usePipelineExecutorGetCapabilities:FE,usePipelineExecutorGetDefaultSteps:_E,usePipelineExecutorGetDetectionConfigSchema:nI,usePipelineExecutorGetEffectiveTuning:GE,usePipelineExecutorGetGlobalPipelineConfig:TE,usePipelineExecutorGetGlobalSteps:DE,usePipelineExecutorGetOrchestratorConfigSchema:LE,usePipelineExecutorGetReferenceAudio:JE,usePipelineExecutorGetReferenceAudioFiles:XE,usePipelineExecutorGetReferenceImage:ZE,usePipelineExecutorGetSchema:Lo,usePipelineExecutorGetSelectedEngine:qb,usePipelineExecutorGetVideoPipelineSteps:PE,usePipelineExecutorInferCached:QE,usePipelineExecutorKillEngine:Wb,usePipelineExecutorListLoadedEngines:Gb,usePipelineExecutorListReferenceImages:YE,usePipelineExecutorListTemplates:RE,usePipelineExecutorReprobeEngine:Ub,usePipelineExecutorRunAudioTest:tI,usePipelineExecutorRunPipeline:VE,usePipelineExecutorRunPipelineBatch:qE,usePipelineExecutorSaveTemplate:OE,usePipelineExecutorSetVideoPipelineSteps:$E,usePipelineExecutorSpinEngine:WE,usePipelineExecutorUncacheFrame:KE,usePipelineExecutorUpdateTemplate:zE,usePipelineOrchestratorApplyDeviceSettingsPatch:uI,usePipelineOrchestratorAssignAudio:sx,usePipelineOrchestratorAssignDecoder:nx,usePipelineOrchestratorAssignPipeline:Yb,usePipelineOrchestratorDeleteTemplate:gx,usePipelineOrchestratorGetAgentLoad:Jb,usePipelineOrchestratorGetAgentSettings:qc,usePipelineOrchestratorGetAudioAssignment:sI,usePipelineOrchestratorGetAudioAssignments:lx,usePipelineOrchestratorGetAudioNodeLoad:ix,usePipelineOrchestratorGetCameraMetrics:oI,usePipelineOrchestratorGetCameraSettings:Qc,usePipelineOrchestratorGetCameraStepOverrides:iI,usePipelineOrchestratorGetCapabilityBindings:ex,usePipelineOrchestratorGetDecoderAssignment:aI,usePipelineOrchestratorGetDecoderAssignments:ox,usePipelineOrchestratorGetDeviceLiveContribution:dI,usePipelineOrchestratorGetDeviceSettingsContribution:cI,usePipelineOrchestratorGetGlobalMetrics:rI,usePipelineOrchestratorGetPipelineAssignment:Sa,usePipelineOrchestratorGetPipelineAssignments:ka,usePipelineOrchestratorListAgentSettings:Fr,usePipelineOrchestratorListTemplates:hx,usePipelineOrchestratorRebalance:Xb,usePipelineOrchestratorRemoveAgentSettings:cx,usePipelineOrchestratorResolvePipeline:fx,usePipelineOrchestratorSaveTemplate:lI,usePipelineOrchestratorSetAgentAddonDefaults:Uc,usePipelineOrchestratorSetCameraPipelineForAgent:px,usePipelineOrchestratorSetCameraStepOverride:ux,usePipelineOrchestratorSetCameraStepToggle:dx,usePipelineOrchestratorSetCapabilityBinding:tx,usePipelineOrchestratorUnassignAudio:ax,usePipelineOrchestratorUnassignDecoder:rx,usePipelineOrchestratorUnassignPipeline:Zb,usePipelineOrchestratorUpdateTemplate:mx,usePipelineRunnerAttachCamera:pI,usePipelineRunnerDetachCamera:fI,usePipelineRunnerGetAllCameraMetrics:bI,usePipelineRunnerGetCameraMetrics:Kc,usePipelineRunnerGetLocalCameras:bx,usePipelineRunnerGetLocalLoad:mI,usePipelineRunnerGetLocalMetrics:gI,usePipelineRunnerReportMotion:hI,usePlatformProbeGetCapabilities:xI,usePlatformProbeGetHardware:yI,usePlatformProbeResolveHwAccel:wI,usePlatformProbeResolveInferenceConfig:vI,usePlayerOverlayLayer:vP,usePlayerOverlayLayers:uy,usePlayerToolbarButton:wP,usePlayerToolbarButtons:py,usePtzAutotrackGetSettings:_I,usePtzAutotrackGetStatus:xx,usePtzAutotrackSetEnabled:yx,usePtzAutotrackSetSettings:vx,usePtzContinuousMove:kI,usePtzGetPosition:II,usePtzGetPresets:CI,usePtzGetStatus:AI,usePtzGoHome:EI,usePtzGoToPreset:MI,usePtzMove:NI,usePtzStop:SI,useRebootReboot:wx,useRecordingEngineDisable:kx,useRecordingEngineEnable:Nx,useRecordingEngineEstimateGlobalStorage:FI,useRecordingEngineEstimateStorage:BI,useRecordingEngineGetAvailability:zI,useRecordingEngineGetConfig:Sx,useRecordingEngineGetMotionStats:qI,useRecordingEngineGetPlaylist:RI,useRecordingEngineGetPolicy:HI,useRecordingEngineGetPolicyStatus:Ex,useRecordingEngineGetRetentionConfig:Ix,useRecordingEngineGetSegments:Cx,useRecordingEngineGetStatus:TI,useRecordingEngineGetStorageUsage:Mx,useRecordingEngineGetThumbnail:OI,useRecordingEngineSetPolicy:jI,useRecordingEngineUpdateConfig:LI,useRecordingEngineUpdateRetentionConfig:VI,useRecordingGetPlaybackUrl:$I,useRecordingGetSegments:PI,useRecordingGetThumbnailAt:DI,useRemoteAccessListProviders:Ax,useRemoteAccessStartProvider:_x,useRemoteAccessStopProvider:Px,useSettingsStoreCount:ZI,useSettingsStoreDeclareCollection:JI,useSettingsStoreDelete:YI,useSettingsStoreGet:UI,useSettingsStoreInsert:GI,useSettingsStoreIsEmpty:XI,useSettingsStoreQuery:KI,useSettingsStoreSet:QI,useSettingsStoreUpdate:WI,useSnapshotApplyDeviceSettingsPatch:sA,useSnapshotGetDeviceLiveContribution:oA,useSnapshotGetDeviceSettingsContribution:rA,useSnapshotGetSnapshot:eA,useSnapshotGetStatus:nA,useSnapshotInvalidateCache:tA,useSnapshotProviderGetSnapshot:iA,useSnapshotProviderSupportsDevice:aA,useStorageAbortUpload:xA,useStorageBeginDownload:yA,useStorageBeginUpload:mA,useStorageDelete:fA,useStorageDeleteLocation:Dx,useStorageEndDownload:wA,useStorageExists:uA,useStorageFinalizeUpload:bA,useStorageGetAvailableSpace:hA,useStorageGetDefaultLocation:NA,useStorageList:pA,useStorageListLocations:$x,useStorageListProviders:Gc,useStorageRead:dA,useStorageReadChunk:vA,useStorageResolve:lA,useStorageTestConfig:SA,useStorageTestLocation:kA,useStorageUpsertLocation:Ca,useStorageWrite:cA,useStorageWriteChunk:gA,useStreamBrokerApplyDeviceSettingsPatch:QA,useStreamBrokerAssignProfile:EA,useStreamBrokerGetAllRtspEntries:FA,useStreamBrokerGetBroker:RA,useStreamBrokerGetBrokerStats:PA,useStreamBrokerGetDeviceLiveContribution:UA,useStreamBrokerGetDeviceSettingsContribution:qA,useStreamBrokerGetPreBufferInfo:zA,useStreamBrokerGetRtspEntry:jA,useStreamBrokerGetRtspPort:BA,useStreamBrokerGetStreamUrl:LA,useStreamBrokerIsRtspEnabled:VA,useStreamBrokerKillClient:DA,useStreamBrokerListAllCameraStreams:AA,useStreamBrokerListAllProfileSlots:_A,useStreamBrokerListClients:$A,useStreamBrokerPublishCameraStream:CA,useStreamBrokerRegenerateRtspToken:Tx,useStreamBrokerRestartProfile:TA,useStreamBrokerRetractCameraStream:MA,useStreamBrokerSetPreBufferDuration:OA,useStreamBrokerSetRtspEnabled:HA,useStreamBrokerUnassignProfile:IA,useSwitchGetStatus:GA,useSwitchSetState:KA,useSystem:Te,useSystemFeatureFlags:ZA,useSystemForceRetentionCleanup:t_,useSystemGetRetentionConfig:JA,useSystemHealth:YA,useSystemInfo:WA,useSystemMutation:v$,useSystemNetworkAddresses:XA,useSystemQuery:y$,useSystemSetRetentionConfig:e_,useThemeMode:Rr,useToastOnToast:Lx,useTurnOrchestratorGetAllServers:Ox,useTurnOrchestratorListProviders:Rx,useTurnOrchestratorSetProviderEnabled:zx,useTurnProviderGetTurnServers:n_,useUserManagementConfirmTotp:Wx,useUserManagementCreateApiKey:o_,useUserManagementCreateScopedToken:Ux,useUserManagementCreateUser:Bx,useUserManagementDeleteUser:jx,useUserManagementDisableTotp:Yx,useUserManagementGetTotpStatus:Zx,useUserManagementListApiKeys:Vx,useUserManagementListScopedTokens:Kx,useUserManagementListUsers:Wc,useUserManagementResetPassword:Yc,useUserManagementRevokeApiKey:qx,useUserManagementRevokeScopedToken:Qx,useUserManagementSetUserScopes:Hx,useUserManagementSetupTotp:Gx,useUserManagementUpdateUser:Fx,useUserManagementValidateApiKey:s_,useUserManagementValidateCredentials:r_,useUserManagementValidateScopedToken:a_,useUserManagementVerifyTotp:i_,useWebrtcSessionCloseSession:u_,useWebrtcSessionCreateSession:c_,useWebrtcSessionHandleAnswer:d_,useWebrtcSessionHasAdaptiveBitrate:p_,useWebrtcSessionListStreams:l_,useWidget:ey,useWidgetMetadata:ty,useWidgetRegistry:Ma,useZoneAnalyticsGetCameraHistory:m_,useZoneAnalyticsGetCurrentSnapshot:f_,useZoneAnalyticsGetUnzonedHistory:g_,useZoneAnalyticsGetZoneHistory:h_,useZoneEditing:m$,useZoneRulesListRules:b_,useZoneRulesSetRules:x_,useZonesAddZone:v_,useZonesListZones:y_,useZonesRemoveZone:w_,useZonesUpdateZone:N_,validateScopes:ad},Symbol.toStringTag,{value:"Module"}));/**
|
|
540
|
-
* react-router v7.15.0
|
|
541
|
-
*
|
|
542
|
-
* Copyright (c) Remix Software Inc.
|
|
543
|
-
*
|
|
544
|
-
* This source code is licensed under the MIT license found in the
|
|
545
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
546
|
-
*
|
|
547
|
-
* @license MIT
|
|
548
|
-
*/var ep="popstate";function tp(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function k$(e={}){function t(r,s){let a=s.state?.masked,{pathname:i,search:l,hash:c}=a||r.location;return wl("",{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:xo(s)}return C$(t,n,null,e)}function ze(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function vt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function S$(){return Math.random().toString(36).substring(2,10)}function np(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 wl(e,t,n=null,r,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?jr(t):t,state:n,key:t&&t.key||r||S$(),mask:s}}function xo({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 jr(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 C$(e,t,n,r={}){let{window:s=document.defaultView,v5Compat:a=!1}=r,i=s.history,l="POP",c=null,d=f();d==null&&(d=0,i.replaceState({...i.state,idx:d},""));function f(){return(i.state||{idx:null}).idx}function p(){l="POP";let x=f(),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=tp(x)?x:wl(b.location,x,y);d=f()+1;let v=np(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=tp(x)?x:wl(b.location,x,y);d=f();let v=np(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 M$(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(ep,p),c=x,()=>{s.removeEventListener(ep,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 M$(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ze(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:xo(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function wy(e,t,n="/"){return E$(e,t,n,!1)}function E$(e,t,n,r,s){let a=typeof t=="string"?jr(t):t,i=an(a.pathname||"/",n);if(i==null)return null;let l=I$(e),c=null,d=F$(i);for(let f=0;c==null&&f<l.length;++f)c=z$(l[f],d,r);return c}function I$(e){let t=Ny(e);return A$(t),t}function Ny(e,t=[],n=[],r="",s=!1){let a=(i,l,c=s,d)=>{let f={relativePath:d===void 0?i.path||"":d,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(r)&&c)return;ze(f.relativePath.startsWith(r),`Absolute route path "${f.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),f.relativePath=f.relativePath.slice(r.length)}let p=Tt([r,f.relativePath]),h=n.concat(f);i.children&&i.children.length>0&&(ze(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${p}".`),Ny(i.children,t,h,p,c)),!(i.path==null&&!i.index)&&t.push({path:p,score:R$(p,i.index),routesMeta:h})};return e.forEach((i,l)=>{if(i.path===""||!i.path?.includes("?"))a(i,l);else for(let c of ky(i.path))a(i,l,!0,c)}),t}function ky(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=ky(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 A$(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:O$(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var _$=/^:[\w-]+$/,P$=3,$$=2,D$=1,T$=10,L$=-2,rp=e=>e==="*";function R$(e,t){let n=e.split("/"),r=n.length;return n.some(rp)&&(r+=L$),t&&(r+=$$),n.filter(s=>!rp(s)).reduce((s,a)=>s+(_$.test(a)?P$:a===""?D$:T$),r)}function O$(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 z$(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,f=a==="/"?t:t.slice(a.length)||"/",p=Hs({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},f),h=c.route;if(!p&&d&&n&&!r[r.length-1].route.index&&(p=Hs({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!p)return null;Object.assign(s,p.params),i.push({params:s,pathname:Tt([a,p.pathname]),pathnameBase:q$(Tt([a,p.pathnameBase])),route:h}),p.pathnameBase!=="/"&&(a=Tt([a,p.pathnameBase]))}return i}function Hs(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=B$(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:f,isOptional:p},h)=>{if(f==="*"){let g=l[h]||"";i=a.slice(0,a.length-g.length).replace(/(.)\/+$/,"$1")}const m=l[h];return p&&!m?d[f]=void 0:d[f]=(m||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:i,pattern:e}}function B$(e,t=!1,n=!0){vt(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,c,d,f)=>{if(r.push({paramName:l,isOptional:c!=null}),c){let p=f.charAt(d+i.length);return p&&p!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function F$(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return vt(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function an(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 j$=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function H$(e,t="/"){let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?jr(e):e,a;return n?(n=Sy(n),n.startsWith("/")?a=op(n.substring(1),"/"):a=op(n,t)):a=t,{pathname:a,search:U$(r),hash:Q$(s)}}function op(e,t){let n=Vs(t).split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function vi(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 V$(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function dd(e){let t=V$(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Ia(e,t,n,r=!1){let s;typeof e=="string"?s=jr(e):(s={...e},ze(!s.pathname||!s.pathname.includes("?"),vi("?","pathname","search",s)),ze(!s.pathname||!s.pathname.includes("#"),vi("#","pathname","hash",s)),ze(!s.search||!s.search.includes("#"),vi("#","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=H$(s,l),d=i&&i!=="/"&&i.endsWith("/"),f=(a||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var Sy=e=>e.replace(/\/\/+/g,"/"),Tt=e=>Sy(e.join("/")),Vs=e=>e.replace(/\/+$/,""),q$=e=>Vs(e).replace(/^\/*/,"/"),U$=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Q$=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,K$=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 G$(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function W$(e){let t=e.map(n=>n.route.path).filter(Boolean);return Tt(t)||"/"}var Cy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function My(e,t){let n=e;if(typeof n!="string"||!j$.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,s=!1;if(Cy)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=an(i.pathname,t);i.origin===a.origin&&l!=null?n=l+i.search+i.hash:s=!0}catch{vt(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:s,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Ey=["POST","PUT","PATCH","DELETE"];new Set(Ey);var Y$=["GET",...Ey];new Set(Y$);var Hr=Oe(null);Hr.displayName="DataRouter";var Aa=Oe(null);Aa.displayName="DataRouterState";var Iy=Oe(!1);function Z$(){return ve(Iy)}var Ay=Oe({isTransitioning:!1});Ay.displayName="ViewTransition";var X$=Oe(new Map);X$.displayName="Fetchers";var J$=Oe(null);J$.displayName="Await";var mt=Oe(null);mt.displayName="Navigation";var Ro=Oe(null);Ro.displayName="Location";var Ct=Oe({outlet:null,matches:[],isDataRoute:!1});Ct.displayName="Route";var ud=Oe(null);ud.displayName="RouteError";var _y="REACT_ROUTER_ERROR",eD="REDIRECT",tD="ROUTE_ERROR_RESPONSE";function nD(e){if(e.startsWith(`${_y}:${eD}:{`))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 rD(e){if(e.startsWith(`${_y}:${tD}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new K$(t.status,t.statusText,t.data)}catch{}}function oD(e,{relative:t}={}){ze(Vr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=ve(mt),{hash:s,pathname:a,search:i}=Oo(e,{relative:t}),l=a;return n!=="/"&&(l=a==="/"?n:Tt([n,a])),r.createHref({pathname:l,search:i,hash:s})}function Vr(){return ve(Ro)!=null}function gt(){return ze(Vr(),"useLocation() may be used only in the context of a <Router> component."),ve(Ro).location}var Py="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function $y(e){ve(mt).static||fa(e)}function Je(){let{isDataRoute:e}=ve(Ct);return e?yD():sD()}function sD(){ze(Vr(),"useNavigate() may be used only in the context of a <Router> component.");let e=ve(Hr),{basename:t,navigator:n}=ve(mt),{matches:r}=ve(Ct),{pathname:s}=gt(),a=JSON.stringify(dd(r)),i=ne(!1);return $y(()=>{i.current=!0}),U((c,d={})=>{if(vt(i.current,Py),!i.current)return;if(typeof c=="number"){n.go(c);return}let f=Ia(c,JSON.parse(a),s,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Tt([t,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,a,s,e])}var aD=Oe(null);function iD(e){let t=ve(Ct).outlet;return q(()=>t&&Me(aD.Provider,{value:e},t),[t,e])}function pd(){let{matches:e}=ve(Ct);return e[e.length-1]?.params??{}}function Oo(e,{relative:t}={}){let{matches:n}=ve(Ct),{pathname:r}=gt(),s=JSON.stringify(dd(n));return q(()=>Ia(e,JSON.parse(s),r,t==="path"),[e,s,r,t])}function lD(e,t){return Dy(e,t)}function Dy(e,t,n){ze(Vr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=ve(mt),{matches:s}=ve(Ct),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||"";Ly(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.
|
|
549
|
-
|
|
550
|
-
Please change the parent <Route path="${x}"> to <Route path="${x==="/"?"*":`${x}/*`}">.`)}let f=gt(),p;if(t){let x=typeof t=="string"?jr(t):t;ze(c==="/"||x.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${x.pathname}" was given in the \`location\` prop.`),p=x}else p=f;let 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})):wy(e,{pathname:m});vt(d||g!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),vt(g==null||g[g.length-1].route.element!==void 0||g[g.length-1].route.Component!==void 0||g[g.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let b=fD(g&&g.map(x=>Object.assign({},x,{params:Object.assign({},i,x.params),pathname:Tt([c,r.encodeLocation?r.encodeLocation(x.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?c:Tt([c,r.encodeLocation?r.encodeLocation(x.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathnameBase])})),s,n);return t&&b?Me(Ro.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...p},navigationType:"POP"}},b):b}function cD(){let e=xD(),t=G$(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=Me(kr,null,Me("p",null,"💿 Hey developer 👋"),Me("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",Me("code",{style:a},"ErrorBoundary")," or"," ",Me("code",{style:a},"errorElement")," prop on your route.")),Me(kr,null,Me("h2",null,"Unexpected Application Error!"),Me("h3",{style:{fontStyle:"italic"}},t),n?Me("pre",{style:s},n):null,i)}var dD=Me(cD,null),Ty=class extends iN{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=rD(e.digest);n&&(e=n)}let t=e!==void 0?Me(Ct.Provider,{value:this.props.routeContext},Me(ud.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?Me(uD,{error:e},t):t}};Ty.contextType=Iy;var wi=new WeakMap;function uD({children:e,error:t}){let{basename:n}=ve(mt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=nD(t.digest);if(r){let s=wi.get(t);if(s)throw s;let a=My(r.location,n);if(Cy&&!wi.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 wi.set(t,i),i}return Me("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function pD({routeContext:e,match:t,children:n}){let r=ve(Hr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),Me(Ct.Provider,{value:e},n)}function fD(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 f=s.findIndex(p=>p.route.id&&a?.[p.route.id]!==void 0);ze(f>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),s=s.slice(0,Math.min(s.length,f+1))}let i=!1,l=-1;if(n&&r){i=r.renderFallback;for(let f=0;f<s.length;f++){let p=s[f];if((p.route.HydrateFallback||p.route.hydrateFallbackElement)&&(l=f),p.route.id){let{loaderData: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?(f,p)=>{c(f,{location:r.location,params:r.matches?.[0]?.params??{},pattern:W$(r.matches),errorInfo:p})}:void 0;return s.reduceRight((f,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||dD,i&&(l<0&&h===0?(Ly("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=Me(p.route.Component,null):p.route.element?v=p.route.element:v=f,Me(pD,{match:p,routeContext:{outlet:f,matches:y,isDataRoute:r!=null},children:v})};return r&&(p.route.ErrorBoundary||p.route.errorElement||h===0)?Me(Ty,{location:r.location,revalidation:r.revalidation,component:b,error:m,children:w(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:d}):w()},null)}function fd(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function hD(e){let t=ve(Hr);return ze(t,fd(e)),t}function mD(e){let t=ve(Aa);return ze(t,fd(e)),t}function gD(e){let t=ve(Ct);return ze(t,fd(e)),t}function hd(e){let t=gD(e),n=t.matches[t.matches.length-1];return ze(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function bD(){return hd("useRouteId")}function xD(){let e=ve(ud),t=mD("useRouteError"),n=hd("useRouteError");return e!==void 0?e:t.errors?.[n]}function yD(){let{router:e}=hD("useNavigate"),t=hd("useNavigate"),n=ne(!1);return $y(()=>{n.current=!0}),U(async(s,a={})=>{vt(n.current,Py),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:t,...a}))},[e,t])}var sp={};function Ly(e,t,n){!t&&!sp[e]&&(sp[e]=!0,vt(!1,n))}je(vD);function vD({routes:e,manifest:t,future:n,state:r,isStatic:s,onError:a}){return Dy(e,void 0,{manifest:t,state:r,isStatic:s,onError:a})}function bt({to:e,replace:t,state:n,relative:r}){ze(Vr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:s}=ve(mt);vt(!s,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:a}=ve(Ct),{pathname:i}=gt(),l=Je(),c=Ia(e,dd(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 wD(e){return iD(e.context)}function $e(e){ze(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function ND({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:s,static:a=!1,useTransitions:i}){ze(!Vr(),"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=jr(n));let{pathname:d="/",search:f="",hash:p="",state:h=null,key:m="default",mask:g}=n,b=q(()=>{let x=an(d,l);return x==null?null:{location:{pathname:x,search:f,hash:p,state:h,key:m,mask:g},navigationType:r}},[l,d,f,p,h,m,r,g]);return vt(b!=null,`<Router basename="${l}"> is not able to match the URL "${d}${f}${p}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:Me(mt.Provider,{value:c},Me(Ro.Provider,{children:t,value:b}))}function kD({children:e,location:t}){return lD(Nl(e),t)}function Nl(e,t=[]){let n=[];return sN.forEach(e,(r,s)=>{if(!aN(r))return;let a=[...t,s];if(r.type===kr){n.push.apply(n,Nl(r.props.children,a));return}ze(r.type===$e,`[${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>`),ze(!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=Nl(r.props.children,a)),n.push(i)}),n}var Es="get",Is="application/x-www-form-urlencoded";function _a(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function SD(e){return _a(e)&&e.tagName.toLowerCase()==="button"}function CD(e){return _a(e)&&e.tagName.toLowerCase()==="form"}function MD(e){return _a(e)&&e.tagName.toLowerCase()==="input"}function ED(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ID(e,t){return e.button===0&&(!t||t==="_self")&&!ED(e)}function kl(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 AD(e,t){let n=kl(e);return t&&t.forEach((r,s)=>{n.has(s)||t.getAll(s).forEach(a=>{n.append(s,a)})}),n}var os=null;function _D(){if(os===null)try{new FormData(document.createElement("form"),0),os=!1}catch{os=!0}return os}var PD=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ni(e){return e!=null&&!PD.has(e)?(vt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Is}"`),null):e}function $D(e,t){let n,r,s,a,i;if(CD(e)){let l=e.getAttribute("action");r=l?an(l,t):null,n=e.getAttribute("method")||Es,s=Ni(e.getAttribute("enctype"))||Is,a=new FormData(e)}else if(SD(e)||MD(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?an(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||Es,s=Ni(e.getAttribute("formenctype"))||Ni(l.getAttribute("enctype"))||Is,a=new FormData(l,e),!_D()){let{name:d,type:f,value:p}=e;if(f==="image"){let h=d?`${d}.`:"";a.append(`${h}x`,"0"),a.append(`${h}y`,"0")}else d&&a.append(d,p)}}else{if(_a(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Es,r=null,s=Is,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 md(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ry(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&&an(s.pathname,t)==="/"?s.pathname=`${Vs(t)}/_root.${r}`:s.pathname=`${Vs(s.pathname)}.${r}`,s}async function DD(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 TD(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 LD(e,t,n){let r=await Promise.all(e.map(async s=>{let a=t.routes[s.route.id];if(a){let i=await DD(a,n);return i.links?i.links():[]}return[]}));return BD(r.flat(1).filter(TD).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function ap(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 f=r.routes[c.route.id];if(!f||!f.hasLoader)return!1;if(i(c,d)||l(c,d))return!0;if(c.route.shouldRevalidate){let p=c.route.shouldRevalidate({currentUrl:new URL(s.pathname+s.search+s.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof p=="boolean")return p}return!0}):[]}function RD(e,t,{includeHydrateFallback:n}={}){return OD(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 OD(e){return[...new Set(e)]}function zD(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function BD(e,t){let n=new Set;return new Set(t),e.reduce((r,s)=>{let a=JSON.stringify(zD(s));return n.has(a)||(n.add(a),r.push({key:a,link:s})),r},[])}function gd(){let e=ve(Hr);return md(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function FD(){let e=ve(Aa);return md(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var bd=Oe(void 0);bd.displayName="FrameworkContext";function xd(){let e=ve(bd);return md(e,"You must render this element inside a <HydratedRouter> element"),e}function jD(e,t){let n=ve(bd),[r,s]=_(!1),[a,i]=_(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:f,onTouchStart:p}=t,h=ne(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:Wr(l,m),onBlur:Wr(c,g),onMouseEnter:Wr(d,m),onMouseLeave:Wr(f,g),onTouchStart:Wr(p,m)}]:[!1,h,{}]}function Wr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function HD({page:e,...t}){let n=Z$(),{router:r}=gd(),s=q(()=>wy(r.routes,e,r.basename),[r.routes,e,r.basename]);return s?n?Me(qD,{page:e,matches:s,...t}):Me(UD,{page:e,matches:s,...t}):null}function VD(e){let{manifest:t,routeModules:n}=xd(),[r,s]=_([]);return Y(()=>{let a=!1;return LD(e,t,n).then(i=>{a||s(i)}),()=>{a=!0}},[e,t,n]),r}function qD({page:e,matches:t,...n}){let r=gt(),{future:s}=xd(),{basename:a}=gd(),i=q(()=>{if(e===r.pathname+r.search+r.hash)return[];let l=Ry(e,a,s.unstable_trailingSlashAwareDataRequests,"rsc"),c=!1,d=[];for(let f of t)typeof f.route.shouldRevalidate=="function"?c=!0:d.push(f.route.id);return c&&d.length>0&&l.searchParams.set("_routes",d.join(",")),[l.pathname+l.search]},[a,s.unstable_trailingSlashAwareDataRequests,e,r,t]);return Me(kr,null,i.map(l=>Me("link",{key:l,rel:"prefetch",as:"fetch",href:l,...n})))}function UD({page:e,matches:t,...n}){let r=gt(),{future:s,manifest:a,routeModules:i}=xd(),{basename:l}=gd(),{loaderData:c,matches:d}=FD(),f=q(()=>ap(e,t,d,a,r,"data"),[e,t,d,a,r]),p=q(()=>ap(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||(!f.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=Ry(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,f,t,e,i]),m=q(()=>RD(p,a),[p,a]),g=VD(p);return Me(kr,null,h.map(b=>Me("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),m.map(b=>Me("link",{key:b,rel:"modulepreload",href:b,...n})),g.map(({key:b,link:x})=>Me("link",{key:b,nonce:n.nonce,...x,crossOrigin:x.crossOrigin??n.crossOrigin})))}function QD(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var KD=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{KD&&(window.__reactRouterVersion="7.15.0")}catch{}function GD({basename:e,children:t,useTransitions:n,window:r}){let s=ne();s.current==null&&(s.current=k$({window:r,v5Compat:!0}));let a=s.current,[i,l]=_({action:a.action,location:a.location}),c=U(d=>{n===!1?l(d):tc(()=>l(d))},[n]);return fa(()=>a.listen(c),[a,c]),Me(ND,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a,useTransitions:n})}var Oy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,qs=qe(function({onClick:t,discover:n="render",prefetch:r="none",relative:s,reloadDocument:a,replace:i,mask:l,state:c,target:d,to:f,preventScrollReset:p,viewTransition:h,defaultShouldRevalidate:m,...g},b){let{basename:x,navigator:y,useTransitions:w}=ve(mt),v=typeof f=="string"&&Oy.test(f),N=My(f,x);f=N.to;let k=oD(f,{relative:s}),S=gt(),E=null;if(l){let T=Ia(l,[],S.mask?S.mask.pathname:"/",!0);x!=="/"&&(T.pathname=T.pathname==="/"?x:Tt([x,T.pathname])),E=y.createHref(T)}let[A,I,B]=jD(r,g),$=XD(f,{replace:i,mask:l,state:c,target:d,preventScrollReset:p,relative:s,viewTransition:h,defaultShouldRevalidate:m,useTransitions:w});function z(T){t&&t(T),T.defaultPrevented||$(T)}let R=!(N.isExternal||a),M=Me("a",{...g,...B,href:(R?E:void 0)||N.absoluteURL||k,onClick:R?z:t,ref:QD(b,I),target:d,"data-discover":!v&&n==="render"?"true":void 0});return A&&!v?Me(kr,null,M,Me(HD,{page:k})):M});qs.displayName="Link";var WD=qe(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:s=!1,style:a,to:i,viewTransition:l,children:c,...d},f){let p=Oo(i,{relative:d.relative}),h=gt(),m=ve(Aa),{navigator:g,basename:b}=ve(mt),x=m!=null&&rT(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=an(v,b)||v);const N=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let k=w===y||!s&&w.startsWith(y)&&w.charAt(N)==="/",S=v!=null&&(v===y||!s&&v.startsWith(y)&&v.charAt(y.length)==="/"),E={isActive:k,isPending:S,isTransitioning:x},A=k?t:void 0,I;typeof r=="function"?I=r(E):I=[r,k?"active":null,S?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let B=typeof a=="function"?a(E):a;return Me(qs,{...d,"aria-current":A,className:I,ref:f,style:B,to:i,viewTransition:l},typeof c=="function"?c(E):c)});WD.displayName="NavLink";var YD=qe(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:s,state:a,method:i=Es,action:l,onSubmit:c,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:h,...m},g)=>{let{useTransitions:b}=ve(mt),x=tT(),y=nT(l,{relative:d}),w=i.toLowerCase()==="get"?"get":"post",v=typeof l=="string"&&Oy.test(l);return Me("form",{ref:g,method:w,action:y,onSubmit:r?c:k=>{if(c&&c(k),k.defaultPrevented)return;k.preventDefault();let S=k.nativeEvent.submitter,E=S?.getAttribute("formmethod")||i,A=()=>x(S||k.currentTarget,{fetcherKey:t,method:E,navigate:n,replace:s,state:a,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:h});b&&n!==!1?tc(()=>A()):A()},...m,"data-discover":!v&&e==="render"?"true":void 0})});YD.displayName="Form";function ZD(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function zy(e){let t=ve(Hr);return ze(t,ZD(e)),t}function XD(e,{target:t,replace:n,mask:r,state:s,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:c,useTransitions:d}={}){let f=Je(),p=gt(),h=Oo(e,{relative:i});return U(m=>{if(ID(m,t)){m.preventDefault();let g=n!==void 0?n:xo(p)===xo(h),b=()=>f(e,{replace:g,mask:r,state:s,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:c});d?tc(()=>b()):b()}},[p,f,h,n,r,s,t,e,a,i,l,c,d])}function Pa(e){vt(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=ne(kl(e)),n=ne(!1),r=gt(),s=q(()=>AD(r.search,n.current?null:t.current),[r.search]),a=Je(),i=U((l,c)=>{const d=kl(typeof l=="function"?l(new URLSearchParams(s)):l);n.current=!0,a("?"+d,c)},[a,s]);return[s,i]}var JD=0,eT=()=>`__${String(++JD)}__`;function tT(){let{router:e}=zy("useSubmit"),{basename:t}=ve(mt),n=bD(),r=e.fetch,s=e.navigate;return U(async(a,i={})=>{let{action:l,method:c,encType:d,formData:f,body:p}=$D(a,t);if(i.navigate===!1){let h=i.fetcherKey||eT();await r(h,n,i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:p,formMethod:i.method||c,formEncType:i.encType||d,flushSync:i.flushSync})}else await s(i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:p,formMethod:i.method||c,formEncType:i.encType||d,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[r,s,t,n])}function nT(e,{relative:t}={}){let{basename:n}=ve(mt),r=ve(Ct);ze(r,"useFormAction must be used inside a RouteContext");let[s]=r.matches.slice(-1),a={...Oo(e||".",{relative:t})},i=gt();if(e==null){a.search=i.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(f=>f==="")){l.delete("index"),c.filter(p=>p).forEach(p=>l.append("index",p));let f=l.toString();a.search=f?`?${f}`:""}}return(!e||e===".")&&s.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Tt([n,a.pathname])),xo(a)}function rT(e,{relative:t}={}){let n=ve(Ay);ze(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=zy("useViewTransitionState"),s=Oo(e,{relative:t});if(!n.isTransitioning)return!1;let a=an(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=an(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Hs(s.pathname,i)!=null||Hs(s.pathname,a)!=null}const oT=3e4;function sT(e){const t=ne(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>=oT&&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 Sl="disconnected";const Cl=new Set;function aT(){for(const e of Cl)e()}function iT(e){Sl!==e&&(Sl=e,aT())}function lT(e){return Cl.add(e),()=>{Cl.delete(e)}}function ip(){return Sl}function cT(){return ha(lT,ip,ip)}let ao=null;function As(){if(!ao){const e=window.location.origin,t=localStorage.getItem("camstack_admin_token")??void 0;ao=Eh({serverUrl:e,token:t,onConnectionChange:n=>iT(n)})}return ao}function fr(){ao?.close(),ao=null}function dT(e){const t=hn();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(it,{widgetId:"pipeline-orchestrator/zone-editor",host:"device-tab",deviceId:t})}function uT({deviceId:e}){return u("div",{className:Xh,children:[u("div",{className:`grid ${Jh}`,style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 340px), 1fr))"},children:[o(it,{widgetId:"pipeline-analytics/live-occupancy-panel",host:"device-tab",deviceId:e}),o(it,{widgetId:"pipeline-analytics/audio-metrics-panel",host:"device-tab",deviceId:e})]}),o(it,{widgetId:"pipeline-analytics/audio-history-chart",host:"device-tab",deviceId:e}),o(it,{widgetId:"pipeline-analytics/occupancy-history-chart",host:"device-tab",deviceId:e}),o(it,{widgetId:"pipeline-analytics/motion-history-chart",host:"device-tab",deviceId:e}),o(it,{widgetId:"pipeline-analytics/detection-history-chart",host:"device-tab",deviceId:e})]})}function pT(e){const t=hn();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(uT,{deviceId:t})}/**
|
|
551
|
-
* @license lucide-react v0.511.0 - ISC
|
|
552
|
-
*
|
|
553
|
-
* This source code is licensed under the ISC license.
|
|
554
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
555
|
-
*/const fT=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),hT=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),lp=e=>{const t=hT(e);return t.charAt(0).toUpperCase()+t.slice(1)},By=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),mT=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/**
|
|
556
|
-
* @license lucide-react v0.511.0 - ISC
|
|
557
|
-
*
|
|
558
|
-
* This source code is licensed under the ISC license.
|
|
559
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
560
|
-
*/var gT={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"};/**
|
|
561
|
-
* @license lucide-react v0.511.0 - ISC
|
|
562
|
-
*
|
|
563
|
-
* This source code is licensed under the ISC license.
|
|
564
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
565
|
-
*/const bT=qe(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:i,...l},c)=>Me("svg",{ref:c,...gT,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:By("lucide",s),...!a&&!mT(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,f])=>Me(d,f)),...Array.isArray(a)?a:[a]]));/**
|
|
566
|
-
* @license lucide-react v0.511.0 - ISC
|
|
567
|
-
*
|
|
568
|
-
* This source code is licensed under the ISC license.
|
|
569
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
570
|
-
*/const se=(e,t)=>{const n=qe(({className:r,...s},a)=>Me(bT,{ref:a,iconNode:t,className:By(`lucide-${fT(lp(e))}`,`lucide-${e}`,r),...s}));return n.displayName=lp(e),n};/**
|
|
571
|
-
* @license lucide-react v0.511.0 - ISC
|
|
572
|
-
*
|
|
573
|
-
* This source code is licensed under the ISC license.
|
|
574
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
575
|
-
*/const xT=[["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"}]],zo=se("activity",xT);/**
|
|
576
|
-
* @license lucide-react v0.511.0 - ISC
|
|
577
|
-
*
|
|
578
|
-
* This source code is licensed under the ISC license.
|
|
579
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
580
|
-
*/const yT=[["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"}]],Fy=se("archive",yT);/**
|
|
581
|
-
* @license lucide-react v0.511.0 - ISC
|
|
582
|
-
*
|
|
583
|
-
* This source code is licensed under the ISC license.
|
|
584
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
585
|
-
*/const vT=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],yd=se("arrow-left",vT);/**
|
|
586
|
-
* @license lucide-react v0.511.0 - ISC
|
|
587
|
-
*
|
|
588
|
-
* This source code is licensed under the ISC license.
|
|
589
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
590
|
-
*/const wT=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],NT=se("arrow-right",wT);/**
|
|
591
|
-
* @license lucide-react v0.511.0 - ISC
|
|
592
|
-
*
|
|
593
|
-
* This source code is licensed under the ISC license.
|
|
594
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
595
|
-
*/const kT=[["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"}]],ST=se("battery-full",kT);/**
|
|
596
|
-
* @license lucide-react v0.511.0 - ISC
|
|
597
|
-
*
|
|
598
|
-
* This source code is licensed under the ISC license.
|
|
599
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
600
|
-
*/const CT=[["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"}]],Bo=se("bell",CT);/**
|
|
601
|
-
* @license lucide-react v0.511.0 - ISC
|
|
602
|
-
*
|
|
603
|
-
* This source code is licensed under the ISC license.
|
|
604
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
605
|
-
*/const MT=[["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"}]],ET=se("book-open",MT);/**
|
|
606
|
-
* @license lucide-react v0.511.0 - ISC
|
|
607
|
-
*
|
|
608
|
-
* This source code is licensed under the ISC license.
|
|
609
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
610
|
-
*/const IT=[["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"}]],AT=se("bot",IT);/**
|
|
611
|
-
* @license lucide-react v0.511.0 - ISC
|
|
612
|
-
*
|
|
613
|
-
* This source code is licensed under the ISC license.
|
|
614
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
615
|
-
*/const _T=[["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"}]],$a=se("box",_T);/**
|
|
616
|
-
* @license lucide-react v0.511.0 - ISC
|
|
617
|
-
*
|
|
618
|
-
* This source code is licensed under the ISC license.
|
|
619
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
620
|
-
*/const PT=[["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"}]],Da=se("boxes",PT);/**
|
|
621
|
-
* @license lucide-react v0.511.0 - ISC
|
|
622
|
-
*
|
|
623
|
-
* This source code is licensed under the ISC license.
|
|
624
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
625
|
-
*/const $T=[["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"}]],DT=se("calendar-clock",$T);/**
|
|
626
|
-
* @license lucide-react v0.511.0 - ISC
|
|
627
|
-
*
|
|
628
|
-
* This source code is licensed under the ISC license.
|
|
629
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
630
|
-
*/const TT=[["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"}]],jy=se("calendar",TT);/**
|
|
631
|
-
* @license lucide-react v0.511.0 - ISC
|
|
632
|
-
*
|
|
633
|
-
* This source code is licensed under the ISC license.
|
|
634
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
635
|
-
*/const LT=[["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"}]],Sr=se("camera",LT);/**
|
|
636
|
-
* @license lucide-react v0.511.0 - ISC
|
|
637
|
-
*
|
|
638
|
-
* This source code is licensed under the ISC license.
|
|
639
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
640
|
-
*/const RT=[["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"}]],Hy=se("cctv",RT);/**
|
|
641
|
-
* @license lucide-react v0.511.0 - ISC
|
|
642
|
-
*
|
|
643
|
-
* This source code is licensed under the ISC license.
|
|
644
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
645
|
-
*/const OT=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],zT=se("check-check",OT);/**
|
|
646
|
-
* @license lucide-react v0.511.0 - ISC
|
|
647
|
-
*
|
|
648
|
-
* This source code is licensed under the ISC license.
|
|
649
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
650
|
-
*/const BT=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Mt=se("check",BT);/**
|
|
651
|
-
* @license lucide-react v0.511.0 - ISC
|
|
652
|
-
*
|
|
653
|
-
* This source code is licensed under the ISC license.
|
|
654
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
655
|
-
*/const FT=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],wt=se("chevron-down",FT);/**
|
|
656
|
-
* @license lucide-react v0.511.0 - ISC
|
|
657
|
-
*
|
|
658
|
-
* This source code is licensed under the ISC license.
|
|
659
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
660
|
-
*/const jT=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],vd=se("chevron-left",jT);/**
|
|
661
|
-
* @license lucide-react v0.511.0 - ISC
|
|
662
|
-
*
|
|
663
|
-
* This source code is licensed under the ISC license.
|
|
664
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
665
|
-
*/const HT=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Et=se("chevron-right",HT);/**
|
|
666
|
-
* @license lucide-react v0.511.0 - ISC
|
|
667
|
-
*
|
|
668
|
-
* This source code is licensed under the ISC license.
|
|
669
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
670
|
-
*/const VT=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],qT=se("chevron-up",VT);/**
|
|
671
|
-
* @license lucide-react v0.511.0 - ISC
|
|
672
|
-
*
|
|
673
|
-
* This source code is licensed under the ISC license.
|
|
674
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
675
|
-
*/const UT=[["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"}]],Cr=se("circle-alert",UT);/**
|
|
676
|
-
* @license lucide-react v0.511.0 - ISC
|
|
677
|
-
*
|
|
678
|
-
* This source code is licensed under the ISC license.
|
|
679
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
680
|
-
*/const QT=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],ki=se("circle-check-big",QT);/**
|
|
681
|
-
* @license lucide-react v0.511.0 - ISC
|
|
682
|
-
*
|
|
683
|
-
* This source code is licensed under the ISC license.
|
|
684
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
685
|
-
*/const KT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Vy=se("circle-check",KT);/**
|
|
686
|
-
* @license lucide-react v0.511.0 - ISC
|
|
687
|
-
*
|
|
688
|
-
* This source code is licensed under the ISC license.
|
|
689
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
690
|
-
*/const GT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],qy=se("circle-dot",GT);/**
|
|
691
|
-
* @license lucide-react v0.511.0 - ISC
|
|
692
|
-
*
|
|
693
|
-
* This source code is licensed under the ISC license.
|
|
694
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
695
|
-
*/const WT=[["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"}]],YT=se("circle-help",WT);/**
|
|
696
|
-
* @license lucide-react v0.511.0 - ISC
|
|
697
|
-
*
|
|
698
|
-
* This source code is licensed under the ISC license.
|
|
699
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
700
|
-
*/const ZT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],XT=se("clock",ZT);/**
|
|
701
|
-
* @license lucide-react v0.511.0 - ISC
|
|
702
|
-
*
|
|
703
|
-
* This source code is licensed under the ISC license.
|
|
704
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
705
|
-
*/const JT=[["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"}]],Uy=se("copy",JT);/**
|
|
706
|
-
* @license lucide-react v0.511.0 - ISC
|
|
707
|
-
*
|
|
708
|
-
* This source code is licensed under the ISC license.
|
|
709
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
710
|
-
*/const eL=[["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"}]],pt=se("cpu",eL);/**
|
|
711
|
-
* @license lucide-react v0.511.0 - ISC
|
|
712
|
-
*
|
|
713
|
-
* This source code is licensed under the ISC license.
|
|
714
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
715
|
-
*/const tL=[["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"}]],nL=se("crosshair",tL);/**
|
|
716
|
-
* @license lucide-react v0.511.0 - ISC
|
|
717
|
-
*
|
|
718
|
-
* This source code is licensed under the ISC license.
|
|
719
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
720
|
-
*/const rL=[["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"}]],Qy=se("database",rL);/**
|
|
721
|
-
* @license lucide-react v0.511.0 - ISC
|
|
722
|
-
*
|
|
723
|
-
* This source code is licensed under the ISC license.
|
|
724
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
725
|
-
*/const oL=[["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"}]],Cn=se("download",oL);/**
|
|
726
|
-
* @license lucide-react v0.511.0 - ISC
|
|
727
|
-
*
|
|
728
|
-
* This source code is licensed under the ISC license.
|
|
729
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
730
|
-
*/const sL=[["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"}]],aL=se("ellipsis-vertical",sL);/**
|
|
731
|
-
* @license lucide-react v0.511.0 - ISC
|
|
732
|
-
*
|
|
733
|
-
* This source code is licensed under the ISC license.
|
|
734
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
735
|
-
*/const iL=[["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"}]],wd=se("external-link",iL);/**
|
|
736
|
-
* @license lucide-react v0.511.0 - ISC
|
|
737
|
-
*
|
|
738
|
-
* This source code is licensed under the ISC license.
|
|
739
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
740
|
-
*/const lL=[["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"}]],Ky=se("eye-off",lL);/**
|
|
741
|
-
* @license lucide-react v0.511.0 - ISC
|
|
742
|
-
*
|
|
743
|
-
* This source code is licensed under the ISC license.
|
|
744
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
745
|
-
*/const cL=[["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"}]],Fo=se("eye",cL);/**
|
|
746
|
-
* @license lucide-react v0.511.0 - ISC
|
|
747
|
-
*
|
|
748
|
-
* This source code is licensed under the ISC license.
|
|
749
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
750
|
-
*/const dL=[["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"}]],io=se("film",dL);/**
|
|
751
|
-
* @license lucide-react v0.511.0 - ISC
|
|
752
|
-
*
|
|
753
|
-
* This source code is licensed under the ISC license.
|
|
754
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
755
|
-
*/const uL=[["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"}]],pL=se("flame",uL);/**
|
|
756
|
-
* @license lucide-react v0.511.0 - ISC
|
|
757
|
-
*
|
|
758
|
-
* This source code is licensed under the ISC license.
|
|
759
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
760
|
-
*/const fL=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Gy=se("gauge",fL);/**
|
|
761
|
-
* @license lucide-react v0.511.0 - ISC
|
|
762
|
-
*
|
|
763
|
-
* This source code is licensed under the ISC license.
|
|
764
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
765
|
-
*/const hL=[["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"}]],Ml=se("ghost",hL);/**
|
|
766
|
-
* @license lucide-react v0.511.0 - ISC
|
|
767
|
-
*
|
|
768
|
-
* This source code is licensed under the ISC license.
|
|
769
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
770
|
-
*/const mL=[["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"}]],gL=se("git-branch",mL);/**
|
|
771
|
-
* @license lucide-react v0.511.0 - ISC
|
|
772
|
-
*
|
|
773
|
-
* This source code is licensed under the ISC license.
|
|
774
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
775
|
-
*/const bL=[["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"}]],ln=se("globe",bL);/**
|
|
776
|
-
* @license lucide-react v0.511.0 - ISC
|
|
777
|
-
*
|
|
778
|
-
* This source code is licensed under the ISC license.
|
|
779
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
780
|
-
*/const xL=[["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"}]],Us=se("hard-drive",xL);/**
|
|
781
|
-
* @license lucide-react v0.511.0 - ISC
|
|
782
|
-
*
|
|
783
|
-
* This source code is licensed under the ISC license.
|
|
784
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
785
|
-
*/const yL=[["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"}]],vL=se("house",yL);/**
|
|
786
|
-
* @license lucide-react v0.511.0 - ISC
|
|
787
|
-
*
|
|
788
|
-
* This source code is licensed under the ISC license.
|
|
789
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
790
|
-
*/const wL=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],kn=se("info",wL);/**
|
|
791
|
-
* @license lucide-react v0.511.0 - ISC
|
|
792
|
-
*
|
|
793
|
-
* This source code is licensed under the ISC license.
|
|
794
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
795
|
-
*/const NL=[["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"}]],kL=se("key-round",NL);/**
|
|
796
|
-
* @license lucide-react v0.511.0 - ISC
|
|
797
|
-
*
|
|
798
|
-
* This source code is licensed under the ISC license.
|
|
799
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
800
|
-
*/const SL=[["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"}]],Wy=se("key-square",SL);/**
|
|
801
|
-
* @license lucide-react v0.511.0 - ISC
|
|
802
|
-
*
|
|
803
|
-
* This source code is licensed under the ISC license.
|
|
804
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
805
|
-
*/const CL=[["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"}]],ML=se("key",CL);/**
|
|
806
|
-
* @license lucide-react v0.511.0 - ISC
|
|
807
|
-
*
|
|
808
|
-
* This source code is licensed under the ISC license.
|
|
809
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
810
|
-
*/const EL=[["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"}]],IL=se("layers",EL);/**
|
|
811
|
-
* @license lucide-react v0.511.0 - ISC
|
|
812
|
-
*
|
|
813
|
-
* This source code is licensed under the ISC license.
|
|
814
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
815
|
-
*/const AL=[["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"}]],Yy=se("layout-dashboard",AL);/**
|
|
816
|
-
* @license lucide-react v0.511.0 - ISC
|
|
817
|
-
*
|
|
818
|
-
* This source code is licensed under the ISC license.
|
|
819
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
820
|
-
*/const _L=[["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"}]],PL=se("lightbulb",_L);/**
|
|
821
|
-
* @license lucide-react v0.511.0 - ISC
|
|
822
|
-
*
|
|
823
|
-
* This source code is licensed under the ISC license.
|
|
824
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
825
|
-
*/const $L=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ee=se("loader-circle",$L);/**
|
|
826
|
-
* @license lucide-react v0.511.0 - ISC
|
|
827
|
-
*
|
|
828
|
-
* This source code is licensed under the ISC license.
|
|
829
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
830
|
-
*/const DL=[["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"}]],Zy=se("lock",DL);/**
|
|
831
|
-
* @license lucide-react v0.511.0 - ISC
|
|
832
|
-
*
|
|
833
|
-
* This source code is licensed under the ISC license.
|
|
834
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
835
|
-
*/const TL=[["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"}]],LL=se("log-in",TL);/**
|
|
836
|
-
* @license lucide-react v0.511.0 - ISC
|
|
837
|
-
*
|
|
838
|
-
* This source code is licensed under the ISC license.
|
|
839
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
840
|
-
*/const RL=[["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"}]],Nd=se("log-out",RL);/**
|
|
841
|
-
* @license lucide-react v0.511.0 - ISC
|
|
842
|
-
*
|
|
843
|
-
* This source code is licensed under the ISC license.
|
|
844
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
845
|
-
*/const OL=[["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"}]],zL=se("map-pin",OL);/**
|
|
846
|
-
* @license lucide-react v0.511.0 - ISC
|
|
847
|
-
*
|
|
848
|
-
* This source code is licensed under the ISC license.
|
|
849
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
850
|
-
*/const BL=[["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"}]],kd=se("memory-stick",BL);/**
|
|
851
|
-
* @license lucide-react v0.511.0 - ISC
|
|
852
|
-
*
|
|
853
|
-
* This source code is licensed under the ISC license.
|
|
854
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
855
|
-
*/const FL=[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]],jL=se("menu",FL);/**
|
|
856
|
-
* @license lucide-react v0.511.0 - ISC
|
|
857
|
-
*
|
|
858
|
-
* This source code is licensed under the ISC license.
|
|
859
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
860
|
-
*/const HL=[["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"}]],El=se("mic",HL);/**
|
|
861
|
-
* @license lucide-react v0.511.0 - ISC
|
|
862
|
-
*
|
|
863
|
-
* This source code is licensed under the ISC license.
|
|
864
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
865
|
-
*/const VL=[["path",{d:"M5 12h14",key:"1ays0h"}]],qL=se("minus",VL);/**
|
|
866
|
-
* @license lucide-react v0.511.0 - ISC
|
|
867
|
-
*
|
|
868
|
-
* This source code is licensed under the ISC license.
|
|
869
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
870
|
-
*/const UL=[["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"}]],QL=se("monitor",UL);/**
|
|
871
|
-
* @license lucide-react v0.511.0 - ISC
|
|
872
|
-
*
|
|
873
|
-
* This source code is licensed under the ISC license.
|
|
874
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
875
|
-
*/const KL=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],Xy=se("moon",KL);/**
|
|
876
|
-
* @license lucide-react v0.511.0 - ISC
|
|
877
|
-
*
|
|
878
|
-
* This source code is licensed under the ISC license.
|
|
879
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
880
|
-
*/const GL=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],WL=se("move",GL);/**
|
|
881
|
-
* @license lucide-react v0.511.0 - ISC
|
|
882
|
-
*
|
|
883
|
-
* This source code is licensed under the ISC license.
|
|
884
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
885
|
-
*/const YL=[["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"}]],Mn=se("network",YL);/**
|
|
886
|
-
* @license lucide-react v0.511.0 - ISC
|
|
887
|
-
*
|
|
888
|
-
* This source code is licensed under the ISC license.
|
|
889
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
890
|
-
*/const ZL=[["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"}]],XL=se("octagon-alert",ZL);/**
|
|
891
|
-
* @license lucide-react v0.511.0 - ISC
|
|
892
|
-
*
|
|
893
|
-
* This source code is licensed under the ISC license.
|
|
894
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
895
|
-
*/const JL=[["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"}]],Jy=se("package",JL);/**
|
|
896
|
-
* @license lucide-react v0.511.0 - ISC
|
|
897
|
-
*
|
|
898
|
-
* This source code is licensed under the ISC license.
|
|
899
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
900
|
-
*/const eR=[["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"}]],qr=se("pencil",eR);/**
|
|
901
|
-
* @license lucide-react v0.511.0 - ISC
|
|
902
|
-
*
|
|
903
|
-
* This source code is licensed under the ISC license.
|
|
904
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
905
|
-
*/const tR=[["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"}]],e0=se("pin",tR);/**
|
|
906
|
-
* @license lucide-react v0.511.0 - ISC
|
|
907
|
-
*
|
|
908
|
-
* This source code is licensed under the ISC license.
|
|
909
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
910
|
-
*/const nR=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],Ta=se("play",nR);/**
|
|
911
|
-
* @license lucide-react v0.511.0 - ISC
|
|
912
|
-
*
|
|
913
|
-
* This source code is licensed under the ISC license.
|
|
914
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
915
|
-
*/const rR=[["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"}]],Sd=se("plug",rR);/**
|
|
916
|
-
* @license lucide-react v0.511.0 - ISC
|
|
917
|
-
*
|
|
918
|
-
* This source code is licensed under the ISC license.
|
|
919
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
920
|
-
*/const oR=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Nt=se("plus",oR);/**
|
|
921
|
-
* @license lucide-react v0.511.0 - ISC
|
|
922
|
-
*
|
|
923
|
-
* This source code is licensed under the ISC license.
|
|
924
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
925
|
-
*/const sR=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],t0=se("power",sR);/**
|
|
926
|
-
* @license lucide-react v0.511.0 - ISC
|
|
927
|
-
*
|
|
928
|
-
* This source code is licensed under the ISC license.
|
|
929
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
930
|
-
*/const aR=[["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"}]],Qs=se("puzzle",aR);/**
|
|
931
|
-
* @license lucide-react v0.511.0 - ISC
|
|
932
|
-
*
|
|
933
|
-
* This source code is licensed under the ISC license.
|
|
934
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
935
|
-
*/const iR=[["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"}]],lR=se("radar",iR);/**
|
|
936
|
-
* @license lucide-react v0.511.0 - ISC
|
|
937
|
-
*
|
|
938
|
-
* This source code is licensed under the ISC license.
|
|
939
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
940
|
-
*/const cR=[["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"}]],Cd=se("radio",cR);/**
|
|
941
|
-
* @license lucide-react v0.511.0 - ISC
|
|
942
|
-
*
|
|
943
|
-
* This source code is licensed under the ISC license.
|
|
944
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
945
|
-
*/const dR=[["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"}]],ft=se("refresh-cw",dR);/**
|
|
946
|
-
* @license lucide-react v0.511.0 - ISC
|
|
947
|
-
*
|
|
948
|
-
* This source code is licensed under the ISC license.
|
|
949
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
950
|
-
*/const uR=[["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"}]],n0=se("rotate-ccw",uR);/**
|
|
951
|
-
* @license lucide-react v0.511.0 - ISC
|
|
952
|
-
*
|
|
953
|
-
* This source code is licensed under the ISC license.
|
|
954
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
955
|
-
*/const pR=[["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"}]],xt=se("rotate-cw",pR);/**
|
|
956
|
-
* @license lucide-react v0.511.0 - ISC
|
|
957
|
-
*
|
|
958
|
-
* This source code is licensed under the ISC license.
|
|
959
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
960
|
-
*/const fR=[["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"}]],hR=se("save",fR);/**
|
|
961
|
-
* @license lucide-react v0.511.0 - ISC
|
|
962
|
-
*
|
|
963
|
-
* This source code is licensed under the ISC license.
|
|
964
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
965
|
-
*/const mR=[["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"}]],nt=se("scroll-text",mR);/**
|
|
966
|
-
* @license lucide-react v0.511.0 - ISC
|
|
967
|
-
*
|
|
968
|
-
* This source code is licensed under the ISC license.
|
|
969
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
970
|
-
*/const gR=[["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"}]],bR=se("search-x",gR);/**
|
|
971
|
-
* @license lucide-react v0.511.0 - ISC
|
|
972
|
-
*
|
|
973
|
-
* This source code is licensed under the ISC license.
|
|
974
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
975
|
-
*/const xR=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],r0=se("search",xR);/**
|
|
976
|
-
* @license lucide-react v0.511.0 - ISC
|
|
977
|
-
*
|
|
978
|
-
* This source code is licensed under the ISC license.
|
|
979
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
980
|
-
*/const yR=[["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"}]],cn=se("server",yR);/**
|
|
981
|
-
* @license lucide-react v0.511.0 - ISC
|
|
982
|
-
*
|
|
983
|
-
* This source code is licensed under the ISC license.
|
|
984
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
985
|
-
*/const vR=[["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"}]],Gt=se("settings",vR);/**
|
|
986
|
-
* @license lucide-react v0.511.0 - ISC
|
|
987
|
-
*
|
|
988
|
-
* This source code is licensed under the ISC license.
|
|
989
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
990
|
-
*/const wR=[["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"}]],dn=se("shield-check",wR);/**
|
|
991
|
-
* @license lucide-react v0.511.0 - ISC
|
|
992
|
-
*
|
|
993
|
-
* This source code is licensed under the ISC license.
|
|
994
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
995
|
-
*/const NR=[["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"}]],kR=se("shield-x",NR);/**
|
|
996
|
-
* @license lucide-react v0.511.0 - ISC
|
|
997
|
-
*
|
|
998
|
-
* This source code is licensed under the ISC license.
|
|
999
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1000
|
-
*/const SR=[["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"}]],CR=se("shield",SR);/**
|
|
1001
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1002
|
-
*
|
|
1003
|
-
* This source code is licensed under the ISC license.
|
|
1004
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1005
|
-
*/const MR=[["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"}]],ss=se("skull",MR);/**
|
|
1006
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1007
|
-
*
|
|
1008
|
-
* This source code is licensed under the ISC license.
|
|
1009
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1010
|
-
*/const ER=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Mr=se("smartphone",ER);/**
|
|
1011
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1012
|
-
*
|
|
1013
|
-
* This source code is licensed under the ISC license.
|
|
1014
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1015
|
-
*/const IR=[["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"}]],AR=se("sparkles",IR);/**
|
|
1016
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1017
|
-
*
|
|
1018
|
-
* This source code is licensed under the ISC license.
|
|
1019
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1020
|
-
*/const _R=[["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"}]],o0=se("square-check-big",_R);/**
|
|
1021
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1022
|
-
*
|
|
1023
|
-
* This source code is licensed under the ISC license.
|
|
1024
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1025
|
-
*/const PR=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],jo=se("square",PR);/**
|
|
1026
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1027
|
-
*
|
|
1028
|
-
* This source code is licensed under the ISC license.
|
|
1029
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1030
|
-
*/const $R=[["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"}]],Si=se("star",$R);/**
|
|
1031
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1032
|
-
*
|
|
1033
|
-
* This source code is licensed under the ISC license.
|
|
1034
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1035
|
-
*/const DR=[["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"}]],TR=se("sun",DR);/**
|
|
1036
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1037
|
-
*
|
|
1038
|
-
* This source code is licensed under the ISC license.
|
|
1039
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1040
|
-
*/const LR=[["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"}]],RR=se("table-2",LR);/**
|
|
1041
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1042
|
-
*
|
|
1043
|
-
* This source code is licensed under the ISC license.
|
|
1044
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1045
|
-
*/const OR=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],s0=se("terminal",OR);/**
|
|
1046
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1047
|
-
*
|
|
1048
|
-
* This source code is licensed under the ISC license.
|
|
1049
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1050
|
-
*/const zR=[["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"}]],Ge=se("trash-2",zR);/**
|
|
1051
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1052
|
-
*
|
|
1053
|
-
* This source code is licensed under the ISC license.
|
|
1054
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1055
|
-
*/const BR=[["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"}]],dt=se("triangle-alert",BR);/**
|
|
1056
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1057
|
-
*
|
|
1058
|
-
* This source code is licensed under the ISC license.
|
|
1059
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1060
|
-
*/const FR=[["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"}]],La=se("upload",FR);/**
|
|
1061
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1062
|
-
*
|
|
1063
|
-
* This source code is licensed under the ISC license.
|
|
1064
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1065
|
-
*/const jR=[["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"}]],HR=se("users",jR);/**
|
|
1066
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1067
|
-
*
|
|
1068
|
-
* This source code is licensed under the ISC license.
|
|
1069
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1070
|
-
*/const VR=[["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"}]],a0=se("video",VR);/**
|
|
1071
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1072
|
-
*
|
|
1073
|
-
* This source code is licensed under the ISC license.
|
|
1074
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1075
|
-
*/const qR=[["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"}]],i0=se("wifi-off",qR);/**
|
|
1076
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1077
|
-
*
|
|
1078
|
-
* This source code is licensed under the ISC license.
|
|
1079
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1080
|
-
*/const UR=[["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"}]],Kn=se("wifi",UR);/**
|
|
1081
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1082
|
-
*
|
|
1083
|
-
* This source code is licensed under the ISC license.
|
|
1084
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1085
|
-
*/const QR=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Be=se("x",QR);/**
|
|
1086
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1087
|
-
*
|
|
1088
|
-
* This source code is licensed under the ISC license.
|
|
1089
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1090
|
-
*/const KR=[["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"}]],GR=se("wrench",KR);/**
|
|
1091
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1092
|
-
*
|
|
1093
|
-
* This source code is licensed under the ISC license.
|
|
1094
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1095
|
-
*/const WR=[["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"}]],Md=se("zap",WR);function YR(e){const t=Te();return Jn({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 ZR(e){return typeof e=="string"&&e.length>0&&e!=="undefined"&&e!=="null"}function XR(e={}){const t=ke(),n=Fr(void 0,{staleTime:1e4,enabled:e.enabled??!0}),r=q(()=>(n.data??[]).filter(i=>ZR(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 JR({field:e,disabled:t}){const n=ke(),r=e.deviceId,s=YR(e.catalogResolver),a=qc({agentNodeId:e.nodeId}),i=Qc({deviceId:r}),c=dx({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),d=s.data,f=a.data??null,p=i.data??null,h=q(()=>d?t6(d,f,p):[],[d,f,p]),m=q(()=>{if(!f)return{};const g={};for(const[b,x]of Object.entries(f.addonDefaults))g[b]=x.enabled;return g},[f]);return s.error?u("div",{className:"text-xs text-red-400",children:["Failed to load pipeline catalog for ",o("code",{children:e.nodeId}),": ",String(s.error.message??s.error)]}):s.isLoading||!d||a.isLoading?u("div",{className:"text-xs text-foreground-subtle animate-pulse",children:["Loading pipeline for ",e.nodeId,"…"]}):u("div",{className:"col-span-full space-y-4",children:[u("div",{className:"flex items-center gap-2 text-[11px] text-foreground-subtle",children:["Agent: ",o("span",{className:"text-foreground",children:e.nodeId}),u("span",{className:"ml-2",children:["Engine: ",o("span",{className:"text-foreground font-mono",children:`${d.selectedEngine.runtime}/${d.selectedEngine.backend}`})]}),u("span",{className:"ml-auto text-[10px]",children:["Model + settings edited on Pipeline → ",e.nodeId,"."]})]}),o(Ac,{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(e6,{deviceId:r,currentAgentNodeId:e.nodeId,catalog:d,pipelineByAgent:p?.pipelineByAgent??{},disabled:t===!0})]})}function e6({deviceId:e,currentAgentNodeId:t,catalog:n,pipelineByAgent:r,disabled:s}){const a=ke(),[i,l]=_(!1),[c,d]=_(t),{agents:f}=XR({enabled:i}),p=fx({deviceId:e,agentNodeId:c},{enabled:i}),m=px({onSuccess:()=>{a.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),a.invalidateQueries({queryKey:[["pipelineOrchestrator","resolvePipeline"]]})}}),g=r[c]??null,b=f,x=q(()=>g?n6(g.steps,n):[],[g,n]),y=w=>{const v=g?.audio??null;m.mutate({deviceId:e,agentNodeId:c,pipeline:{steps:r6(w),audio:v?{modelId:v.modelId,enabled:v.enabled}:null}})};return u("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("button",{type:"button",onClick:()=>l(w=>!w),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover",children:[i?o(wt,{className:"h-3 w-3"}):o(Et,{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&&u("div",{className:"border-t border-border px-4 py-3 space-y-3",children:[u("div",{className:"flex items-center gap-2 text-xs",children:[o("span",{className:"text-foreground-subtle",children:"Agent:"}),u("select",{value:c,disabled:s,onChange:w=>d(w.target.value),className:"rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary",children:[typeof t=="string"&&t.length>0&&t!=="undefined"&&u("option",{value:t,children:[t," (current)"]}),b.filter(w=>w.nodeId!==t).map(w=>o("option",{value:w.nodeId,children:w.nodeId},w.nodeId))]}),r[c]&&u("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(Ge,{className:"h-3 w-3"}),"Remove override"]})]}),g?o(Ac,{schema:n,steps:x,onChange:y,templates:[],selectedTemplateId:null,onSelectTemplate:()=>{},onSaveTemplate:()=>{},onUpdateTemplate:()=>{},onDeleteTemplate:()=>{},readOnly:s,hideTemplates:!0}):u("div",{className:"text-xs text-foreground-subtle space-y-2",children:[u("p",{children:["No custom pipeline for ",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 t6(e,t,n){const r=d=>{for(const f of e.slots)for(const p of f.addons)if(p.id===d)return p;return null},s=d=>{const f=t?.addonDefaults[d.id],p=f?.enabled??d.enabledByDefault??!0,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:f?.modelId??d.defaultModelId,children:[],...f?.settings&&Object.keys(f.settings).length>0?{settings:f.settings}:{}}},a=new Map;for(const d of e.slots)for(const f of d.addons)a.set(f.id,s(f));const i=[],l=new Set;for(const[d,f]of a){const p=r(d);p&&p.inputClasses.length===0&&(i.push(f),l.add(d))}let c=!0;for(;c;){c=!1;for(const[d,f]of a){if(l.has(d))continue;const p=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(f),l.add(d),c=!0;break}}}}return i}function n6(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 r6(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 o6({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 s6(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 a6(e){return`${e.inputSize.width}x${e.inputSize.height}`}function i6(e){return e.formats?Object.keys(e.formats).filter(t=>e.formats[t]!==void 0):[]}function l6({entry:e,selected:t,onSelect:n,disabled:r}){const s=s6(e),a=a6(e),i=i6(e);return u("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:u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-xs font-semibold text-foreground truncate",children:e.name}),t&&o(Mt,{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})]})}),u("div",{className:"flex items-center gap-3 mt-2 flex-wrap",children:[u("span",{className:"inline-flex items-center gap-1 text-[10px] text-foreground-subtle",children:[o(pt,{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&&u("span",{className:"text-[10px] text-foreground-subtle",children:[e.labels.length," label",e.labels.length!==1?"s":""]})]})]})}function c6({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"),f=t==null?"":String(t);return u("div",{className:"space-y-3",children:[l.length>1&&o(o6,{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(l6,{entry:p,selected:f===p.id,onSelect:()=>n(p.id),disabled:r||e.disabled},p.id))}),c==="catalog"&&!a&&u("div",{className:"rounded-md border border-info/30 bg-info/5 px-3 py-2 flex items-start gap-2",children:[o(kn,{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&&u("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:f,disabled:r||e.disabled,onChange:p=>n(p.target.value)}),e.acceptFormats&&e.acceptFormats.length>0&&u("p",{className:"text-[10px] text-foreground-subtle",children:["Accepted formats: ",e.acceptFormats.join(", ")]})]}),(e.compatibilityNote||e.conversionGuideUrl)&&u("div",{className:"flex items-start justify-between gap-3 pt-1",children:[e.compatibilityNote&&u("p",{className:"flex items-start gap-1 text-[10px] text-foreground-subtle",children:[o(kn,{className:"h-3 w-3 mt-0.5 shrink-0"}),e.compatibilityNote]}),e.conversionGuideUrl&&u("a",{href:e.conversionGuideUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-[11px] text-primary hover:underline shrink-0",children:["How to convert your model",o(wd,{className:"h-3 w-3"})]})]})]})}function l0(e){const t=Te();return vy(t.trpcClient,e)}function d6({deviceId:e,deviceName:t,hasPTZ:n=!1,className:r}){const s=Te(),a=typeof window<"u"?window.location.origin:"",i=Number.isFinite(e),[l,c]=_(!1),d=i&&n&&l,f=St(s.trpcClient,i?e:null),p=ne(!1),{data:h,isLoading:m,isFetching:g,refetch:b}=Jn({queryKey:["device",e,"snapshot.getSnapshot"],queryFn:()=>{const I=p.current;return p.current=!1,f?.snapshot?.getSnapshot({force:I})??null},enabled:!!f&&i,staleTime:5e3,retry:!1}),x=()=>{p.current=!0,b()},{streams:y,pipelineMetrics:w,createSession:v,sendAnswer:N,closeSession:k}=id(s.trpcClient,i?e:null),S=l0(i?e:null),E=ld(s.trpcClient,i?e:0,{enabled:d}),A=h?`data:${h.contentType};base64,${h.base64}`:null;return o(ed,{serverUrl:a,createSession:v,sendAnswer:N,closeSession:k,streams:y,pipelineMetrics:w,deviceName:t,phase:S.phase,detections:S,defaultShowDetections:!1,defaultShowMotion:!1,autoPlay:!1,showPlayStop:!0,snapshotSrc:A,snapshotLoading:m||g,onRefreshSnapshot:x,ptzAvailable:i&&n,ptzShown:d,onPtzToggle:()=>c(I=>!I),ptzOverlay:d?o(rd,{controls:E}):void 0,className:r})}function u6(){const e=hn(),t=Pc();if(e===null)return null;const n=typeof t?.name=="string"?t.name:"",s=(t?.features??[]).includes(Hn.PanTiltZoom);return o(d6,{deviceId:e,deviceName:n,hasPTZ:s})}function yt(e,t){const n=Te(),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 f=JSON.parse(l),h=f.length===1&&Array.isArray(f[0])?f:[f];r.invalidateQueries({queryKey:h})};d();for(const f of i.split("|"))if(f)try{c.push(n.subscribeEvent(f,d))}catch{}return()=>{for(const f of c)f()}},[n,r,i,l,s])}function as({icon:e,label:t,value:n,subtext:r,color:s}){return u("div",{className:"rounded-lg border border-border bg-surface p-2 sm:p-2.5 min-w-0",children:[u("div",{className:"flex items-center gap-1.5 mb-0.5 min-w-0",children:[o(e,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),o("span",{className:`${zs} uppercase tracking-wider whitespace-nowrap overflow-hidden text-ellipsis min-w-0`,children:t})]}),o("p",{className:`${s?`${ll.replace("text-foreground","")} ${s}`:ll} whitespace-nowrap overflow-hidden text-ellipsis`,children:n}),r&&o("p",{className:`${zs} mt-0.5 truncate`,children:r})]})}function is({label:e,value:t,warning:n}){return u("div",{className:"min-w-0",children:[o("p",{className:`${zs} truncate`,children:e}),o("p",{className:`text-[11px] font-medium truncate ${n?"text-warning":"text-foreground"}`,children:t})]})}function nn({label:e,value:t}){return u("div",{className:`${em} 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 p6(){const e=hn();yt(["pipelineOrchestrator","getPipelineAssignment"],["pipeline.camera-assigned","pipeline.camera-unassigned","pipeline.camera-updated"]),yt(["pipelineRunner","getCameraMetrics"],["pipeline.camera-metrics-snapshot"]);const{data:t}=Sa({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}=Kc({deviceId:e??0,...s?{nodeId:s}:{}},{enabled:e!==null,staleTime:2e3,retry:!1}),i=Te(),l=St(i.trpcClient,e),{data:c}=Jn({queryKey:["device",e,"pipelineAnalytics.getActiveTracks"],queryFn:()=>l?.pipelineAnalytics?.getActiveTracks({})??[],enabled:!!l&&e!==null,refetchInterval:5e3,retry:!1});if(e===null)return null;const d=a?.phase??null,f=a?.detectionMode??null,p=Number(a?.actualFps??0),h=Number(a?.configuredFps??0),m=Number(a?.avgInferenceTimeMs??0),g=Number(a?.queueDepth??0),b=Number(a?.droppedFrames??0),x=tr(d??"watching"),y=c?.length??0;return u("div",{className:"grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4 gap-2 sm:gap-3",children:[o(as,{icon:zo,label:"Phase",value:x.label,color:x.textColor,subtext:f??void 0}),o(as,{icon:Gy,label:"Detection FPS",value:`${p.toFixed(1)}`,subtext:h>0?`target: ${h}`:void 0}),o(as,{icon:pt,label:"Inference",value:`${m.toFixed(1)} ms`,subtext:g>0?`queue: ${g}`:void 0}),o(as,{icon:Fo,label:"Active Tracks",value:String(y),subtext:b>0?`dropped: ${b}`:void 0})]})}function Ci(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function f6(){const e=hn(),{data:t}=Vc({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:u("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])=>u("div",{className:"px-3 sm:px-4 py-2",children:[u("div",{className:"flex items-center gap-1.5 mb-1.5",children:[o(Kn,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),o("span",{className:"text-[11px] font-medium text-foreground truncate",children:s})]}),u("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-2",children:[o(is,{label:"Nominal",value:Ci(a.nominalBitrateKbps??0)}),o(is,{label:"Observed",value:Ci(a.observedBitrateKbps??0)}),o(is,{label:"Peak",value:Ci(a.peakBitrateKbps??0)}),o(is,{label:"Packet Loss",value:`${(a.packetLossPercent??0).toFixed(2)}%`,warning:(a.packetLossPercent??0)>1})]})]},s))})]})}const h6=3e4;function m6({field:e}){const t=hn(),n=e.type==="doorbell-recent"&&typeof e.historyLimit=="number"?e.historyLimit:10,r=cd({deviceId:t??void 0,historyLimit:n});if(t===null)return null;const s=r.latest?Date.now()-r.latest.timestamp<h6:!1;return o(od,{history:r.history,latestIsFresh:s})}const g6={streaming:{icon:a0,label:"Streaming"},detection:{icon:Fo,label:"Detection"},recording:{icon:qy,label:"Recording"},audio:{icon:El,label:"Audio"},snapshot:{icon:Sr,label:"Snapshot"},motion:{icon:Md,label:"Motion"},ptz:{icon:Gt,label:"PTZ"},webrtc:{icon:Cd,label:"WebRTC"},onvif:{icon:CR,label:"ONVIF"},analytics:{icon:pt,label:"Analytics"},"battery-operated":{icon:ST,label:"Battery"},"native-snapshot":{icon:Sr,label:"Native Snapshot"},"pan-tilt-zoom":{icon:Gt,label:"PTZ"},"two-way-audio":{icon:El,label:"Two-way Audio"},"doorbell-button":{icon:Bo,label:"Doorbell"},rebootable:{icon:ft,label:"Rebootable"}},b6=$a;function Ra({capabilities:e,showLabels:t=!1}){return o("div",{className:"flex items-center gap-1 flex-wrap",children:e.map(n=>{const r=g6[n],s=r?.icon??b6,a=r?.label??n;return u("span",{className:"inline-flex items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] text-foreground-subtle",title:a,children:[o(s,{className:"h-3 w-3"}),t&&o("span",{children:a})]},n)})})}const x6={frigate:{icon:Hy,color:"#3b82f6",label:"Frigate"},scrypted:{icon:cn,color:"#a855f7",label:"Scrypted"},reolink:{icon:Cd,color:"#06b6d4",label:"Reolink"},homeassistant:{icon:vL,color:"#22d3ee",label:"Home Assistant"},rtsp:{icon:Kn,color:"#78716c",label:"RTSP"},onvif:{icon:Kn,color:"#78716c",label:"ONVIF"}},cp={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6"},y6={sm:"h-7 w-7",md:"h-8 w-8",lg:"h-10 w-10"};function c0(e){const t=e.toLowerCase();return t.startsWith("provider-")?t.slice(9):t}function v6(e){const t=c0(e);return x6[t]??{icon:Hy,color:"#78716c",label:e}}function w6(e){const t=c0(e);return`/api/addon-assets/${e.toLowerCase().startsWith("provider-")?e:`provider-${t}`}/assets/icon.svg`}function un({type:e,size:t="md",showLabel:n}){const r=v6(e),s=r.icon,[a,i]=_(!1),l=w6(e);return u("div",{className:"flex items-center gap-2",children:[o("div",{className:`flex items-center justify-center rounded-lg ${y6[t]}`,style:{backgroundColor:`${r.color}15`},children:a?o(s,{className:cp[t],style:{color:r.color}}):o("img",{src:l,alt:r.label,className:cp[t],onError:()=>i(!0)})}),n&&o("span",{className:"text-xs font-medium text-foreground-subtle",children:r.label})]})}function N6({deviceId:e,initialName:t}){const n=ke(),[r,s]=_(!1),[a,i]=_(t),[l,c]=_(!1),d=ne(null);Y(()=>{r||i(t)},[t,r]),Y(()=>{r&&d.current?.focus()},[r]);const f=rb({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 f.mutateAsync({deviceId:e,name:m}),s(!1)}catch{}finally{c(!1)}},h=()=>{i(t),s(!1)};return r?o(nn,{label:"Name",value:u("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(Mt,{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(Be,{className:"h-3 w-3"})})]})}):o(nn,{label:"Name",value:u("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(qr,{className:"h-3 w-3 text-foreground-subtle"})})]})})}function k6({deviceId:e,initialLocation:t}){const n=ke(),[r,s]=_(!1),[a,i]=_(t??""),[l,c]=_(!1),d=ne(null),{data:f}=sb(void 0,{staleTime:3e4,enabled:r}),p=f??[];Y(()=>{r||i(t??"")},[t,r]),Y(()=>{r&&d.current?.focus()},[r]);const h=ob({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(nn,{label:"Location",value:u("div",{className:"relative",children:[u("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(Mt,{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(Be,{className:"h-3 w-3"})})]}),(m.length>0||g)&&u("div",{className:"absolute z-10 left-0 right-0 mt-0.5 max-h-40 overflow-y-auto rounded-md border border-border bg-surface shadow-md",children:[m.map(y=>u("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(zL,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),o("span",{className:"truncate",children:y})]},y)),g&&u("button",{type:"button",onClick:()=>void b(),className:"w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover border-t border-border",children:[o("span",{className:"text-foreground-subtle",children:"Create"}),u("span",{className:"font-medium truncate",children:['"',a.trim(),'"']})]})]})]})}):o(nn,{label:"Location",value:u("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(qr,{className:"h-3 w-3 text-foreground-subtle"})})]})})}const dp=["manufacturer","model","hardware","firmware","serialNumber","uid","mac","itemNo"];function S6(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}function C6(e){return e==null?"—":typeof e=="string"||typeof e=="number"||typeof e=="boolean"?String(e):JSON.stringify(e)}function d0(){const e=hn(),t=Pc(),{data:n}=Qn({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??""),f=r.features??[],p=r.location??null,h=r.metadata??null,m=h!==null&&Object.keys(h).length>0;return u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3",children:[o("h2",{className:"text-[11px] font-semibold text-foreground uppercase tracking-wider",children:"Device Info"}),m&&u("div",{className:"flex items-center gap-1 rounded-md bg-surface-hover p-0.5",children:[o(up,{active:s==="identity",onClick:()=>a("identity"),label:"Identity"}),o(up,{active:s==="hardware",onClick:()=>a("hardware"),label:"Hardware"})]})]}),(!m||s==="identity")&&u("div",{className:"divide-y divide-border",children:[o(nn,{label:"ID",value:u("span",{className:"font-mono text-[11px] text-foreground",children:[`#${e}`,u("span",{className:"ml-1.5 text-foreground-subtle",children:["(",i,")"]})]})}),o(N6,{deviceId:e,initialName:l}),o(k6,{deviceId:e,initialLocation:p}),o(nn,{label:"Type",value:c}),o(nn,{label:"Provider",value:o(un,{type:d,size:"sm",showLabel:!0})}),o(nn,{label:"Capabilities",value:f.length>0?o(Ra,{capabilities:f,showLabels:!0}):o("span",{className:"text-[11px] text-foreground-subtle",children:"None"})})]}),m&&s==="hardware"&&o(M6,{metadata:h})]})}function up({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 M6({metadata:e}){const t=dp.filter(s=>s in e),n=Object.keys(e).filter(s=>!dp.includes(s)).sort(),r=[...t,...n];return u("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(nn,{label:S6(s),value:o("span",{className:"font-mono text-[11px] text-foreground break-all",children:C6(e[s])})},s))})]})}function _s(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:A6(n.scopes)}}catch{return null}}const E6=new Set(["view","create","delete"]),I6=new Set(["category","capability","addon","device"]);function A6(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"||!I6.has(s)||!Array.isArray(a))continue;const i=a.filter(c=>typeof c=="string"&&E6.has(c));if(i.length===0)continue;if(s==="device"){const c=r.targets;if(!Array.isArray(c))continue;const d=c.filter(f=>typeof f=="string"&&f.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 _6(e){const t=_s(e);return t?t.exp*1e3<Date.now():!0}const P6="changeme",u0=Oe(null);function $6({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(_6(p)){localStorage.removeItem("camstack_admin_token"),s(!1);return}const h=_s(p);if(!h){localStorage.removeItem("camstack_admin_token"),s(!1);return}As().trpcClient.system.info.query().then(()=>n(h)).catch(b=>{const x=b?.data?.code;x==="UNAUTHORIZED"||x==="FORBIDDEN"?(localStorage.removeItem("camstack_admin_token"),fr()):n(h)}).finally(()=>s(!1))},[]);const l=U(async(p,h)=>{const g=await As().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),fr(),n(_s(b)),i(h===P6),{kind:"ok"}},[]),c=U(async(p,h)=>{const b=(await As().loginVerifyTotp(p,h)).token;localStorage.setItem("camstack_admin_token",b),fr(),n(_s(b)),i(!1)},[]),d=U(()=>{localStorage.removeItem("camstack_admin_token"),fr(),n(null),i(!1)},[]),f=U(()=>{i(!1)},[]);return o(u0.Provider,{value:{user:t,loading:r,mustChangePassword:a,login:l,verifyTotp:c,logout:d,clearMustChangePassword:f},children:e})}function mn(){const e=ve(u0);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}function Ft({children:e,requireAdmin:t}){const{user:n,loading:r,mustChangePassword:s}=mn(),a=gt();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(bt,{to:"/change-password",replace:!0}):t&&!n.isAdmin?o(bt,{to:"/access-denied",replace:!0}):o(me,{children:e}):o(bt,{to:"/login",replace:!0})}var Mi={};const Ce=e=>typeof e=="string",Yr=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},pp=e=>e==null?"":""+e,D6=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},T6=/###/g,fp=e=>e&&e.indexOf("###")>-1?e.replace(T6,"."):e,hp=e=>!e||Ce(e),lo=(e,t,n)=>{const r=Ce(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(hp(e))return{};const a=fp(r[s]);!e[a]&&n&&(e[a]=new n),Object.prototype.hasOwnProperty.call(e,a)?e=e[a]:e={},++s}return hp(e)?{}:{obj:e,k:fp(r[s])}},mp=(e,t,n)=>{const{obj:r,k:s}=lo(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=lo(e,i,Object);for(;l.obj===void 0&&i.length;)a=`${i[i.length-1]}.${a}`,i=i.slice(0,i.length-1),l=lo(e,i,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},L6=(e,t,n,r)=>{const{obj:s,k:a}=lo(e,t,Object);s[a]=s[a]||[],s[a].push(n)},Ks=(e,t)=>{const{obj:n,k:r}=lo(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},R6=(e,t,n)=>{const r=Ks(e,n);return r!==void 0?r:Ks(t,n)},p0=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?Ce(e[r])||e[r]instanceof String||Ce(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):p0(e[r],t[r],n):e[r]=t[r]);return e},On=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var O6={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const z6=e=>Ce(e)?e.replace(/[&<>"'\/]/g,t=>O6[t]):e;class B6{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 F6=[" ",",","?","!",";"],j6=new B6(20),H6=(e,t,n)=>{t=t||"",n=n||"";const r=F6.filter(i=>t.indexOf(i)<0&&n.indexOf(i)<0);if(r.length===0)return!0;const s=j6.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},Il=(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},yo=e=>e?.replace(/_/g,"-"),V6={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 Gs{constructor(t,n={}){this.init(t,n)}init(t,n={}){this.prefix=n.prefix||"i18next:",this.logger=t||V6,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:(Ce(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new Gs(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new Gs(this.logger,t)}}var qt=new Gs;class Oa{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 gp extends Oa{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):Ce(r)&&a?l.push(...r.split(a)):l.push(r)));const c=Ks(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!i||!Ce(r)?c:Il(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),mp(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)(Ce(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=Ks(this.data,l)||{};i.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?p0(c,r,a):c={...c,...r},mp(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 f0={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 h0=Symbol("i18next/PATH_KEY");function q6(){const e=[],t=Object.create(null);let n;return t.get=(r,s)=>(n?.revoke?.(),s===h0?e:(e.push(s),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function xr(e,t){const{[h0]:n}=e(q6()),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 bp={},Ei=e=>!Ce(e)&&typeof e!="boolean"&&typeof e!="number";class Ws extends Oa{constructor(t,n={}){super(),D6(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=qt.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t,n={interpolation:{}}){const r={...n};if(t==null)return!1;const s=this.resolve(t,r);if(s?.res===void 0)return!1;const a=Ei(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&&!H6(t,r,s);if(i&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:Ce(a)?[a]:a};const d=t.split(r);(r!==s||r===s&&this.options.ns.indexOf(d[0])>-1)&&(a=d.shift()),t=d.join(s)}return{key:t,namespaces:Ce(a)?[a]:a}}translate(t,n,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=xr(t,{...this.options,...s})),Array.isArray(t)||(t=[String(t)]),t=t.map(R=>typeof R=="function"?xr(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 f=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;f===void 0&&(f=":");const p=s.lng||this.language,h=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p?.toLowerCase()==="cimode")return h?a?{res:`${d}${f}${l}`,usedKey:l,exactUsedKey:l,usedLng:p,usedNS:d,usedParams:this.getUsedParamsDetails(s)}:`${d}${f}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:p,usedNS:d,usedParams:this.getUsedParamsDetails(s)}:l;const 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&&!Ce(s.count),k=Ws.hasDefaultValue(s),S=N?this.pluralResolver.getSuffix(p,s.count,s):"",E=s.ordinal&&N?this.pluralResolver.getSuffix(p,s.count,{ordinal:!1}):"",A=N&&!s.ordinal&&s.count===0,I=A&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${S}`]||s[`defaultValue${E}`]||s.defaultValue;let B=g;v&&!g&&k&&(B=I);const $=Ei(B),z=Object.prototype.toString.apply(B);if(v&&B&&$&&y.indexOf(z)<0&&!(Ce(w)&&Array.isArray(B))){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,B,{...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(B),M=R?[]:{},T=R?x:b;for(const P in B)if(Object.prototype.hasOwnProperty.call(B,P)){const L=`${T}${i}${P}`;k&&!g?M[P]=this.translate(L,{...s,defaultValue:Ei(I)?I[P]:void 0,joinArrays:!1,ns:c}):M[P]=this.translate(L,{...s,joinArrays:!1,ns:c}),M[P]===L&&(M[P]=B[P])}g=M}}else if(v&&Ce(w)&&Array.isArray(g))g=g.join(w),g&&(g=this.extendTranslation(g,t,s,r));else{let R=!1,M=!1;!this.isValidLookup(g)&&k&&(R=!0,g=I),this.isValidLookup(g)||(M=!0,g=l);const P=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&M?void 0:g,L=k&&I!==g&&this.options.updateMissing;if(M||R||L){if(this.logger.log(L?"updateKey":"missingKey",p,d,l,L?I:g),i){const H=this.resolve(l,{...s,keySeparator:!1});H&&H.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let O=[];const j=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&j&&j[0])for(let H=0;H<j.length;H++)O.push(j[H]);else this.options.saveMissingTo==="all"?O=this.languageUtils.toResolveHierarchy(s.lng||this.language):O.push(s.lng||this.language);const F=(H,D,Q)=>{const K=k&&Q!==g?Q:P;this.options.missingKeyHandler?this.options.missingKeyHandler(H,d,D,K,L,s):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(H,d,D,K,L,s),this.emit("missingKey",H,d,D,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?O.forEach(H=>{const D=this.pluralResolver.getSuffixes(H,s);A&&s[`defaultValue${this.options.pluralSeparator}zero`]&&D.indexOf(`${this.options.pluralSeparator}zero`)<0&&D.push(`${this.options.pluralSeparator}zero`),D.forEach(Q=>{F([H],l+Q,s[`defaultValue${Q}`]||I)})}):F(O,l,I))}g=this.extendTranslation(g,t,s,m,r),M&&g===l&&this.options.appendNamespaceToMissingKey&&(g=`${d}${f}${l}`),(M||R)&&this.options.parseMissingKeyHandler&&(g=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${f}${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=Ce(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 f=r.replace&&!Ce(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),t=this.interpolator.interpolate(t,f,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=Ce(i)?[i]:i;return t!=null&&l?.length&&r.applyPostProcessor!==!1&&(t=f0.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 Ce(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(c=>typeof c=="function"?xr(c,{...this.options,...n}):c)),t.forEach(c=>{if(this.isValidLookup(r))return;const d=this.extractFromKey(c,n),f=d.key;s=f;let p=d.namespaces;this.options.fallbackNS&&(p=p.concat(this.options.fallbackNS));const h=n.count!==void 0&&!Ce(n.count),m=h&&!n.ordinal&&n.count===0,g=n.context!==void 0&&(Ce(n.context)||typeof n.context=="number")&&n.context!=="",b=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);p.forEach(x=>{this.isValidLookup(r)||(l=x,!bp[`${b[0]}-${x}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(bp[`${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=[f];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(w,f,y,x,n);else{let N;h&&(N=this.pluralResolver.getSuffix(y,n.count,n));const k=`${this.options.pluralSeparator}zero`,S=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(h&&(n.ordinal&&N.indexOf(S)===0&&w.push(f+N.replace(S,this.options.pluralSeparator)),w.push(f+N),m&&w.push(f+k)),g){const E=`${f}${this.options.contextSeparator||"_"}${n.context}`;w.push(E),h&&(n.ordinal&&N.indexOf(S)===0&&w.push(E+N.replace(S,this.options.pluralSeparator)),w.push(E+N),m&&w.push(E+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&&!Ce(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 xp{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=qt.create("languageUtils")}getScriptPartFromCode(t){if(t=yo(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=yo(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(Ce(t)&&t.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(t)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let n;return t.forEach(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)),Ce(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 Ce(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(t))):Ce(t)&&a(this.formatLanguageCode(t)),r.forEach(i=>{s.indexOf(i)<0&&a(this.formatLanguageCode(i))}),s}}const yp={zero:0,one:1,two:2,few:3,many:4,other:5},vp={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class U6{constructor(t,n={}){this.languageUtils=t,this.options=n,this.logger=qt.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,n={}){const r=yo(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!"),vp;if(!t.match(/-|_/))return vp;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)=>yp[s]-yp[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 wp=(e,t,n,r=".",s=!0)=>{let a=R6(e,t,n);return!a&&s&&Ce(n)&&(a=Il(e,n,r),a===void 0&&(a=Il(t,n,r))),a},Ii=e=>e.replace(/\$/g,"$$$$");class Np{constructor(t={}){this.logger=qt.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(n=>n),this.init(t)}init(t={}){t.interpolation||(t.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:s,prefix:a,prefixEscaped:i,suffix:l,suffixEscaped:c,formatSeparator:d,unescapeSuffix:f,unescapePrefix:p,nestingPrefix:h,nestingPrefixEscaped:m,nestingSuffix:g,nestingSuffixEscaped:b,nestingOptionsSeparator:x,maxReplaces:y,alwaysFormat:w}=t.interpolation;this.escape=n!==void 0?n:z6,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=a?On(a):i||"{{",this.suffix=l?On(l):c||"}}",this.formatSeparator=d||",",this.unescapePrefix=f?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=h?On(h):m||On("$t("),this.nestingSuffix=g?On(g):b||On(")"),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=wp(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(wp(n,c,b,this.options.keySeparator,this.options.ignoreJSONStructure),x,r,{...s,...n,interpolationkey:b})};this.resetRegExp();const f=s?.missingInterpolationHandler||this.options.missingInterpolationHandler,p=s?.interpolation?.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>Ii(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?Ii(this.escape(m)):Ii(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 f=="function"){const x=f(t,a,s);i=Ce(x)?x:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))i="";else if(p){i=a[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`),i="";else!Ce(i)&&!this.useRawValueToEscape&&(i=pp(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 f=this.nestingOptionsSeparator;if(c.indexOf(f)<0)return c;const p=c.split(new RegExp(`${On(f)}[ ]*{`));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}${f}${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&&!Ce(i.replace)?i.replace:i,i.applyPostProcessor=!1,delete i.defaultValue;const d=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(d!==-1&&(c=s[1].slice(d).split(this.formatSeparator).map(f=>f.trim()).filter(Boolean),s[1]=s[1].slice(0,d)),a=n(l.call(this,s[1].trim(),i),i),a&&s[0]===t&&!Ce(a))return a;Ce(a)||(a=pp(a)),a||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),a=""),c.length&&(a=c.reduce((f,p)=>this.format(f,p,r.lng,{...r,interpolationkey:s[1].trim()}),a.trim())),t=t.replace(s[0],a),this.regexp.lastIndex=0}return t}}const Q6=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,""),f=l.trim();n[f]||(n[f]=d),d==="false"&&(n[f]=!1),d==="true"&&(n[f]=!0),isNaN(d)||(n[f]=parseInt(d,10))}})}return{formatName:t,formatOptions:n}},kp=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(yo(r),s),t[i]=l),l(n)}},K6=e=>(t,n,r)=>e(yo(n),r)(t);class G6{constructor(t={}){this.logger=qt.create("formatter"),this.options=t,this.init(t)}init(t,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?kp:K6;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()]=kp(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:f}=Q6(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,{...f,...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 W6=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class Y6 extends Oa{constructor(t,n,r,s={}){super(),this.backend=t,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=s,this.logger=qt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,s.backend,s)}queueLoad(t,n,r,s){const a={},i={},l={},c={};return t.forEach(d=>{let f=!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,f=!1,i[h]===void 0&&(i[h]=!0),a[h]===void 0&&(a[h]=!0),c[p]===void 0&&(c[p]=!0)))}),f||(l[d]=!0)}),(Object.keys(a).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(a),pending:Object.keys(i),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(t,n,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=>{L6(c.loaded,[a],i),W6(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(d=>{l[d]||(l[d]={});const f=c.loaded[d];f.length&&f.forEach(p=>{l[d][p]===void 0&&(l[d][p]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,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,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const p=this.waitingReads.shift();this.read(p.lng,p.ns,p.fcName,p.tried,p.wait,p.callback)}if(d&&f&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,a*2,i)},a);return}i(d,f)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const d=c(t,n);d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}return}return c(t,n,l)}prepareLoading(t,n,r={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();Ce(t)&&(t=this.languageUtils.toResolveHierarchy(t)),Ce(n)&&(n=[n]);const a=this.queueLoad(t,n,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 f;d.length===5?f=d(t,n,r,s,c):f=d(t,n,r,s),f&&typeof f.then=="function"?f.then(p=>l(null,p)).catch(l):l(null,f)}catch(f){l(f)}else d(t,n,r,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const Ai=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),Ce(e[1])&&(t.defaultValue=e[1]),Ce(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(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}),Sp=e=>(Ce(e.ns)&&(e.ns=[e.ns]),Ce(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),Ce(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),typeof e.initImmediate=="boolean"&&(e.initAsync=e.initImmediate),e),ls=()=>{},Z6=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})},m0="__i18next_supportNoticeShown",X6=()=>!!(typeof globalThis<"u"&&globalThis[m0]||typeof process<"u"&&Mi&&Mi.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&Mi),J6=()=>{typeof globalThis<"u"&&(globalThis[m0]=!0)},eO=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 co extends Oa{constructor(t={},n){if(super(),this.options=Sp(t),this.services={},this.logger=qt,this.modules={external:[]},Z6(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(t={},n){this.isInitializing=!0,typeof t=="function"&&(n=t,t={}),t.defaultNS==null&&t.ns&&(Ce(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const r=Ai();this.options={...r,...this.options,...Sp(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&&!eO(this)&&!X6()&&(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 💙"),J6());const s=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?qt.init(s(this.modules.logger),this.options):qt.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=G6;const f=new xp(this.options);this.store=new gp(this.options.resources,this.options);const p=this.services;p.logger=qt,p.resourceStore=this.store,p.languageUtils=f,p.pluralResolver=new U6(f,{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 Np(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new Y6(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 Ws(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=ls),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(d=>{this[d]=(...f)=>this.store[d](...f)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=(...f)=>(this.store[d](...f),this)});const l=Yr(),c=()=>{const d=(f,p)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(p),n(f,p)};if(this.languages&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(t,n=ls){let r=n;const s=Ce(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=Yr();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=ls),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"&&f0.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=Yr();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=Ce(l)?l:l&&l[0],d=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(Ce(l)?[l]:l);d&&(this.language||s(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector?.cacheUserLanguage?.(d)),this.loadResources(d,f=>{a(f,d)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?i(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(i):this.services.languageDetector.detect(i):i(t),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=xr(c.keyPrefix,d));const f=this.options.keySeparator||".";let p;return c.keyPrefix&&Array.isArray(a)?p=a.map(h=>(typeof h=="function"&&(h=xr(h,d)),`${c.keyPrefix}${f}${h}`)):(typeof a=="function"&&(a=xr(a,d)),p=c.keyPrefix?`${c.keyPrefix}${f}${a}`:a),this.t(p,c)};return Ce(t)?s.lng=t:s.lngs=t,s.ns=n,s.keyPrefix=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=Yr();return this.options.ns?(Ce(t)&&(t=[t]),t.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{r.resolve(),n&&n(s)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=Yr();Ce(t)&&(t=[t]);const s=this.options.preload||[],a=t.filter(i=>s.indexOf(i)<0&&this.services.languageUtils.isSupportedCode(i));return a.length?(this.options.preload=s.concat(a),this.loadResources(i=>{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 xp(Ai());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 co(t,n);return r.createInstance=co.createInstance,r}cloneInstance(t={},n=ls){const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},a=new co(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((f,p)=>(f[p]={...c[d][p]},f),c[d]),c),{});a.store=new gp(l,s),a.services.resourceStore=a.store}if(t.interpolation){const c={...Ai().interpolation,...this.options.interpolation,...t.interpolation},d={...s,interpolation:c};a.services.interpolator=new Np(d)}return a.translator=new Ws(a.services,s),a.translator.on("*",(l,...c)=>{a.emit(l,...c)}),a.init(s,n),a.translator.options=s,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Ze=co.createInstance();Ze.createInstance;Ze.dir;Ze.init;Ze.loadResources;Ze.reloadResources;Ze.use;Ze.changeLanguage;Ze.getFixedT;Ze.t;Ze.exists;Ze.setDefaultNamespace;Ze.hasLoadedNamespace;Ze.loadNamespaces;Ze.loadLanguages;const tO=(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);Gn(s[0])&&(s[0]=`react-i18next:: ${s[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...s):console?.warn&&console.warn(...s)},Cp={},Al=(e,t,n,r)=>{Gn(n)&&Cp[n]||(Gn(n)&&(Cp[n]=new Date),tO(e,t,n,r))},g0=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}},_l=(e,t,n)=>{e.loadNamespaces(t,g0(e,n))},Mp=(e,t,n,r)=>{if(Gn(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return _l(e,n,r);n.forEach(s=>{e.options.ns.indexOf(s)<0&&e.options.ns.push(s)}),e.loadLanguages(t,g0(e,r))},nO=(e,t,n={})=>!t.languages||!t.languages.length?(Al(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}}),Gn=e=>typeof e=="string",rO=e=>typeof e=="object"&&e!==null,oO=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,sO={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},aO=e=>sO[e],iO=e=>e.replace(oO,aO);let Pl={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:iO,transDefaultProps:void 0};const lO=(e={})=>{Pl={...Pl,...e}},cO=()=>Pl;let b0;const dO=e=>{b0=e},uO=()=>b0,pO={type:"3rdParty",init(e){lO(e.options.react),dO(e)}},fO=Oe();class hO{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var x0={exports:{}},y0={};/**
|
|
1096
|
-
* @license React
|
|
1097
|
-
* use-sync-external-store-shim.production.js
|
|
1098
|
-
*
|
|
1099
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1100
|
-
*
|
|
1101
|
-
* This source code is licensed under the MIT license found in the
|
|
1102
|
-
* LICENSE file in the root directory of this source tree.
|
|
1103
|
-
*/var Er=Ih;function mO(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var gO=typeof Object.is=="function"?Object.is:mO,bO=Er.useState,xO=Er.useEffect,yO=Er.useLayoutEffect,vO=Er.useDebugValue;function wO(e,t){var n=t(),r=bO({inst:{value:n,getSnapshot:t}}),s=r[0].inst,a=r[1];return yO(function(){s.value=n,s.getSnapshot=t,_i(s)&&a({inst:s})},[e,n,t]),xO(function(){return _i(s)&&a({inst:s}),e(function(){_i(s)&&a({inst:s})})},[e]),vO(n),n}function _i(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!gO(e,n)}catch{return!0}}function NO(e,t){return t()}var kO=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?NO:wO;y0.useSyncExternalStore=Er.useSyncExternalStore!==void 0?Er.useSyncExternalStore:kO;x0.exports=y0;var v0=x0.exports;const SO=(e,t)=>{if(Gn(t))return t;if(rO(t)&&Gn(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},CO={t:SO,ready:!1},MO=()=>()=>{},Ot=(e,t={})=>{const{i18n:n}=t,{i18n:r,defaultNS:s}=ve(fO)||{},a=n||r||uO();a&&!a.reportNamespaces&&(a.reportNamespaces=new hO),a||Al(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const i=q(()=>({...cO(),...a?.options?.react,...t}),[a,t]),{useSuspense:l,keyPrefix:c}=i,d=s||a?.options?.defaultNS,f=Gn(d)?[d]:d||["translation"],p=q(()=>f,f);a?.reportNamespaces?.addUsedNamespaces?.(p);const h=ne(0),m=U(I=>{if(!a)return MO;const{bindI18n:B,bindI18nStore:$}=i,z=()=>{h.current+=1,I()};return B&&a.on(B,z),$&&a.store.on($,z),()=>{B&&B.split(" ").forEach(R=>a.off(R,z)),$&&$.split(" ").forEach(R=>a.store.off(R,z))}},[a,i]),g=ne(),b=U(()=>{if(!a)return CO;const I=!!(a.isInitialized||a.initializedStoreOnce)&&p.every(T=>nO(T,a,i)),B=t.lng||a.language,$=h.current,z=g.current;if(z&&z.ready===I&&z.lng===B&&z.keyPrefix===c&&z.revision===$)return z;const M={t:a.getFixedT(B,i.nsMode==="fallback"?p:p[0],c),ready:I,lng:B,keyPrefix:c,revision:$};return g.current=M,M},[a,p,c,i,t.lng]),[x,y]=_(0),{t:w,ready:v}=v0.useSyncExternalStore(m,b,b);Y(()=>{if(a&&!v&&!l){const I=()=>y(B=>B+1);t.lng?Mp(a,t.lng,p,I):_l(a,p,I)}},[a,t.lng,p,v,l,x]);const N=a||{},k=ne(null),S=ne(),E=I=>{const B=Object.getOwnPropertyDescriptors(I);B.__original&&delete B.__original;const $=Object.create(Object.getPrototypeOf(I),B);if(!Object.prototype.hasOwnProperty.call($,"__original"))try{Object.defineProperty($,"__original",{value:I,writable:!1,enumerable:!1,configurable:!1})}catch{}return $},A=q(()=>{const I=N,B=I?.language;let $=I;I&&(k.current&&k.current.__original===I?S.current!==B?($=E(I),k.current=$,S.current=B):$=k.current:($=E(I),k.current=$,S.current=B));const z=!v&&!l?(...M)=>(Al(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(...M)):w,R=[z,$,v];return R.t=z,R.i18n=$,R.ready=v,R},[w,N,v,N.resolvedLanguage,N.language,N.languages]);if(a&&l&&!v)throw new Promise(I=>{const B=()=>I();t.lng?Mp(a,t.lng,p,B):_l(a,p,B)});return A},Ep={info:kn,success:Vy,warning:dt,error:Cr},EO={info:"text-blue-400",success:"text-green-400",warning:"text-amber-400",error:"text-red-400"},Ip={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 IO(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 Ap({alert:e,onMarkRead:t,onDismiss:n}){const r=e.severity in Ep?e.severity:"info",s=e.status in Ip?e.status:"active",a=Ep[r],i=EO[r],l=Ip[s];return u("div",{className:`flex items-start gap-2.5 px-3 py-2.5 border-l-2 ${l} ${e.read?"opacity-60":""} hover:bg-surface-hover transition-colors`,children:[o(a,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${i}`}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5",children:[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&&u("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)))}%`}})}),u("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:IO(e.updatedAt)})]}),u("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(Mt,{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(Be,{className:"h-3 w-3 text-foreground-subtle"})})]})]})}function _p({variant:e="icon",compact:t=!1}={}){const[n,r]=_(!1),[s,a]=_(!1),i=ne(null),l=ne(null),c=ke(),{data:d=0}=Hg(void 0,{staleTime:1e4,refetchInterval:3e4}),{data:f=[],isLoading:p}=jg({limit:50},{enabled:n,staleTime:5e3}),h=s?f:f.filter(I=>!I.read),m=f.filter(I=>I.read).length,g=()=>{c.invalidateQueries({queryKey:[["alerts"]]})},b=Vg({onSuccess:g}),x=qg({onSuccess:g}),y=Ug({onSuccess:g});ut("alert.created",()=>{c.invalidateQueries({queryKey:[["alerts"]]})}),ut("alert.updated",()=>{c.invalidateQueries({queryKey:[["alerts"]]})}),Y(()=>{if(!n)return;const I=B=>{const $=B.target;i.current&&!i.current.contains($)&&l.current&&!l.current.contains($)&&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"),S=h.filter(I=>I.status!=="in-progress"),[E,A]=_({});return Y(()=>{if(n&&l.current){const I=l.current.getBoundingClientRect();A({position:"fixed",left:I.left,bottom:window.innerHeight-I.top+4,zIndex:9999})}},[n]),u("div",{children:[e==="sidebar"?u("button",{ref:l,type:"button",onClick:()=>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:[u("span",{className:"relative inline-flex shrink-0",children:[o(nt,{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)})]}):u("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(nt,{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&&_o(u("div",{ref:i,style:E,className:"w-80 max-h-[28rem] bg-surface border border-border rounded-lg shadow-xl flex flex-col overflow-hidden",children:[u("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border shrink-0",children:[o("span",{className:"text-[12px] font-semibold text-foreground",children:"Alerts"}),u("div",{className:"flex items-center gap-2",children:[m>0&&u("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&&u("button",{type:"button",onClick:N,className:"flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors",children:[o(zT,{className:"h-3 w-3"}),"Mark all read"]})]})]}),u("div",{className:"flex-1 overflow-y-auto",children:[p&&o("div",{className:"flex items-center justify-center py-8",children:o(Ee,{className:"h-4 w-4 animate-spin text-foreground-subtle"})}),!p&&h.length===0&&u("div",{className:"flex flex-col items-center justify-center py-8 text-foreground-subtle",children:[o(nt,{className:"h-6 w-6 mb-2 opacity-40"}),o("span",{className:"text-[11px]",children:f.length>0?"No unread alerts":"No alerts"}),f.length>0&&!s&&u("button",{type:"button",onClick:()=>a(!0),className:"text-[10px] text-primary mt-1 hover:underline",children:["Show ",m," read alert",m!==1?"s":""]})]}),k.length>0&&u("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(Ap,{alert:I,onMarkRead:w,onDismiss:v},I.id))]}),S.map(I=>o(Ap,{alert:I,onMarkRead:w,onDismiss:v},I.id))]})]}),document.body)]})}function w0(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 Pp=new Map,cs=new Map,$p=new Set;function AO(e){return!e||typeof e!="object"?!1:typeof e.default=="function"}async function _O(e,t){const n=Pp.get(e);if(n)return n;const r=cs.get(e);if(r)return r;$p.has(e)||(sc(),wr.registerRemotes([{name:e,entry:t,type:"module"}],{force:!1}),$p.add(e));const s=wr.loadRemote(`${e}/page`).then(a=>{if(!AO(a))throw new Error(`Addon page remote ${e} (${t}) does not expose a default React component on './page'`);return Pp.set(e,a.default),cs.delete(e),a.default}).catch(a=>{throw cs.delete(e),a});return cs.set(e,s),s}function PO(){const{pagePath:e}=pd(),t=Te(),{data:n}=$c(void 0,{staleTime:6e4}),r=q(()=>n?w0(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 _O(s.remoteName,s.bundleUrl).then(f=>{d||i(()=>f)}).catch(f=>{if(d)return;const p=f instanceof Error?f.message:String(f);c(`Failed to load addon page: ${p}`)}),()=>{d=!0}},[s]),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 $O={dark:Xy,light:TR,system:QL},DO={gauge:Gy,puzzle:Qs,bot:AT,cpu:pt,terminal:s0,box:$a,wrench:GR,activity:zo,plug:Sd};function TO(){const e=gt(),t=Je(),{user:n,logout:r}=mn(),s=Rr(),{t:a}=Ot(),i=or(),l=jm(),c=cT(),d=c!=="connected",f=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 F=window.localStorage.getItem("camstack:sidebar-collapsed-groups");if(!F)return new Set;const H=JSON.parse(F);return Array.isArray(H)?new Set(H.filter(D=>typeof D=="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=[]}=Tc(void 0,{staleTime:3e4,refetchInterval:3e4}),w=y.length,v=ke(),N=ne(Date.now()),k=3e4,S=2e3,{data:E}=$c(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:F=>{const H=F.state.data;return H&&H.length>0||Date.now()-N.current>=k?!1:S}}),A=q(()=>E?w0(E):[],[E]);ut("addon.page-ready",()=>{v.invalidateQueries({queryKey:[["addonPages","listPages"]]})});const I=()=>{r(),t("/login")},B=F=>!!(e.pathname===F||e.pathname.startsWith(F+"/")),z=["/pipeline","/timeline"].some(F=>e.pathname===F||e.pathname.startsWith(F+"/")),R=[{label:a("nav.devices","Devices"),icon:Sr,path:"/devices"},{label:a("nav.integrations"),icon:Sd,path:"/integrations"},{label:a("nav.timeline","Timeline"),icon:XT,path:"/timeline"},{label:a("nav.pipeline","Pipeline"),icon:gL,path:"/pipeline"}],M=[{label:a("system.identity","Identity & Access"),icon:Zy,path:"/system/identity"},{label:a("system.network","Network"),icon:ln,path:"/system/network"},{label:a("system.data","Data"),icon:Qy,path:"/system/data"},{label:a("system.cluster","Cluster"),icon:Mn,path:"/system/cluster"},{label:a("system.addons"),icon:Qs,path:"/system/addons"},{label:a("system.addonSettings","Addon Settings"),icon:Gt,path:"/system/settings"},{label:a("system.logs","Logs"),icon:nt,path:"/system/logs"}],T=s?.mode??"system",P={dark:a("theme.dark"),light:a("theme.light"),system:a("theme.system")},L=m&&!i,O=(F,H="md")=>`flex w-full items-center gap-2.5 rounded-md ${L?"justify-center px-0 py-2":"px-2.5 py-1.5"} ${H==="lg"?"text-[13px] font-medium":"text-[12px]"} transition-all ${F?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"}`,j=u(me,{children:[u("div",{className:`flex h-14 items-center border-b border-border ${L?"justify-center px-1":"pl-3 pr-4 gap-2"}`,children:[!L&&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(F=>!F),className:`p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle transition-colors flex-shrink-0 ${L?"":"mr-2"}`,"aria-label":m?"Expand sidebar":"Collapse sidebar",title:m?"Expand sidebar":"Collapse sidebar",children:m?o(Et,{className:"h-4 w-4"}):o(vd,{className:"h-4 w-4"})})]}),u("nav",{className:`flex-1 overflow-y-auto py-3 ${L?"px-1.5":"px-2"} space-y-0.5`,children:[(()=>{const F=B("/dashboard");return u("button",{"data-testid":"nav-dashboard",onClick:()=>{t("/dashboard"),h(!1)},className:O(F,"lg"),title:L?a("nav.dashboard"):void 0,children:[o(Yy,{className:`h-4 w-4 shrink-0 ${F?"text-primary":""}`}),!L&&a("nav.dashboard")]})})(),!L&&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")})}),L&&o("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),R.map(F=>{const H=F.icon,D=B(F.path),Q=`nav-${F.path.replace(/^\//,"").replace(/\//g,"-")}`;return u("button",{"data-testid":Q,onClick:()=>{t(F.path),h(!1)},className:O(D),title:L?F.label:void 0,children:[o(H,{className:`h-3.5 w-3.5 shrink-0 ${D?"text-primary":""}`}),!L&&F.label]},F.path)}),!L&&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")})}),L&&o("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),M.map(F=>{const H=F.icon,D=B(F.path),Q=F.path==="/system/addons",K=`nav-${F.path.replace(/^\//,"").replace(/\//g,"-")}`;return u("button",{"data-testid":K,onClick:()=>{t(F.path),h(!1)},className:O(D),title:L?F.label:void 0,children:[o(H,{className:`h-3.5 w-3.5 shrink-0 ${D?"text-primary":""}`}),!L&&u(me,{children:[o("span",{className:"flex-1 text-left",children:F.label}),Q&&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})]}),L&&Q&&w>0&&o("span",{className:"absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary"})]},F.path)}),A&&A.length>0&&!L&&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")})}),L&&A&&A.length>0&&o("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),A?.map(F=>{const H=B(F.path),D=DO[F.icon]??Qs;return u("button",{onClick:()=>{t(F.path),h(!1)},className:O(H),title:L?F.label:void 0,children:[o(D,{className:`h-3.5 w-3.5 shrink-0 ${H?"text-primary":""}`}),!L&&F.label]},F.id)})]}),u("div",{className:`border-t border-border ${L?"p-1.5":"p-2"} space-y-0.5`,children:[u("button",{onClick:()=>s?.toggleMode(),className:O(!1),title:L?P[T]:void 0,children:[(()=>{const F=$O[T];return o(F,{className:"h-3.5 w-3.5 shrink-0"})})(),!L&&o("span",{children:P[T]})]}),o(_p,{variant:"sidebar",compact:L}),u("button",{type:"button",onClick:()=>t("/system/my-access"),className:O(B("/system/my-access")),title:L?a("system.myAccess","My access"):void 0,children:[o(dn,{className:"h-3.5 w-3.5 shrink-0"}),!L&&o("span",{className:"truncate",children:a("system.myAccess","My access")})]}),u("button",{onClick:I,className:O(!1).replace("hover:text-foreground","hover:text-danger"),title:L?n?.username??"Logout":void 0,children:[o(Nd,{className:"h-3.5 w-3.5 shrink-0"}),!L&&o("span",{className:"truncate",children:n?.username??"User"})]})]})]});return u("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 ${L?"w-12":"w-48"}`,children:j}),i&&o(yc,{open:p,onClose:()=>h(!1),width:"w-64",children:j}),u("div",{className:"flex flex-1 flex-col min-w-0",children:[d&&u("div",{className:"flex items-center justify-center gap-2 bg-danger/90 px-3 py-2 text-[12px] font-medium text-white shrink-0",children:[o(i0,{className:"h-3.5 w-3.5"}),o("span",{children:f?a("connection.reconnecting","Reconnecting…"):a("connection.disconnected","Server unreachable — reconnecting…")}),o(Ee,{className:"h-3.5 w-3.5 animate-spin"})]}),i&&u("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(jL,{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(_p,{})]}),u("main",{className:`relative flex-1 min-h-0 bg-background ${z?"overflow-hidden":"overflow-auto"}`,children:[d&&o("div",{className:"absolute inset-0 z-40 bg-background/60 backdrop-blur-[2px]"}),o(wD,{})]})]})]})}function LO(){const{login:e,verifyTotp:t}=mn(),n=Rr(),r=Je(),[s,a]=_(""),[i,l]=_(""),[c,d]=_(!1),[f,p]=_(""),[h,m]=_(!1),[g,b]=_("credentials"),[x,y]=_(""),[w,v]=_(""),N=async E=>{E.preventDefault(),p(""),m(!0);try{const A=await e(s,i);if(A.kind==="totp-required"){y(A.challengeToken),b("totp");return}r(i==="changeme"?"/change-password":"/dashboard",{replace:!0})}catch(A){p(A instanceof Error?A.message:"Login failed")}finally{m(!1)}},k=async E=>{E.preventDefault(),p(""),m(!0);try{await t(x,w.trim()),r("/dashboard",{replace:!0})}catch(A){p(A instanceof Error?A.message:"TOTP verification failed"),v("")}finally{m(!1)}},S=()=>{b("credentials"),y(""),v(""),p("")};return o("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:u("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"?u("form",{onSubmit:N,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[f&&o("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:f}),u("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:E=>a(E.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all",autoFocus:!0})]}),u("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"Password"}),u("div",{className:"relative",children:[o("input",{"data-testid":"login-password",type:c?"text":"password",placeholder:"Password",value:i,onChange:E=>l(E.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(Ky,{className:"h-4 w-4"}):o(Fo,{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?u("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"})]}):u("form",{onSubmit:k,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[u("div",{className:"flex items-center gap-2 pb-1 border-b border-border",children:[o(Mr,{className:"h-4 w-4 text-primary"}),o("div",{className:"text-sm font-medium text-foreground",children:"Two-factor authentication"})]}),u("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}),"."]}),f&&o("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:f}),u("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:E=>v(E.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?u("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"}),u("button",{type:"button",onClick:S,className:"w-full flex items-center justify-center gap-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors",children:[o(yd,{className:"h-3 w-3"}),"Back to username + password"]})]}),g==="credentials"&&o(RO,{}),o("p",{className:"mt-6 text-center text-[10px] text-foreground-subtle/50",children:"CamStack v0.1.0"})]})})}function RO(){const t=(Rc().data??[]).filter(n=>n.enabled&&n.hasRedirectFlow);return t.length===0?null:u("div",{className:"mt-6 space-y-3",children:[u("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 u("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(dn,{className:"h-4 w-4 text-primary"}),n.displayName]},s)})})]})}const Dp=8;function OO(){const{user:e,mustChangePassword:t,clearMustChangePassword:n,logout:r}=mn(),s=Rr(),a=Je(),[i,l]=_(""),[c,d]=_(""),[f,p]=_(!1),[h,m]=_(""),g=Yc({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<Dp){m(`Password must be at least ${Dp} 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:u("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"})}),u("form",{onSubmit:b,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[u("div",{className:"space-y-1",children:[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}),u("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"New password"}),u("div",{className:"relative",children:[o("input",{"data-testid":"change-password-new",type:f?"text":"password",value:i,onChange:x=>l(x.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all",autoFocus:!0}),o("button",{type:"button",onClick:()=>p(!f),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors",tabIndex:-1,children:f?o(Ky,{className:"h-4 w-4"}):o(Fo,{className:"h-4 w-4"})})]})]}),u("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:f?"text":"password",value:c,onChange:x=>d(x.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all"})]}),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 zO(){const e=Je();return u("div",{className:"flex min-h-screen flex-col items-center justify-center bg-background text-foreground p-4",children:[o("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-danger/10 mb-4",children:o(kR,{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 N0="camstack:dashboard-layout",Pi={version:1,widgets:[]};function BO(){try{const e=localStorage.getItem(N0);if(!e)return Pi;const t=JSON.parse(e);return t&&t.version===1&&Array.isArray(t.widgets)?{version:1,widgets:t.widgets}:Pi}catch{return Pi}}function FO(e){try{localStorage.setItem(N0,JSON.stringify(e))}catch{}}function jO(){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 HO(){const[e,t]=_(BO),[n,r]=_(!1),s=ny(),a=q(()=>s.filter(d=>d.hosts.includes("dashboard")),[s]),i=U(d=>{t(d),FO(d)},[]),l=U(d=>{i({version:1,widgets:[...e.widgets,d]})},[e,i]),c=U(d=>{i({version:1,widgets:e.widgets.filter(f=>f.instanceId!==d)})},[e,i]);return u("div",{className:"p-4",children:[u("div",{className:"flex items-center justify-between mb-4",children:[o("h1",{className:"text-lg font-semibold text-foreground",children:"Dashboard"}),u("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(Nt,{className:"h-3.5 w-3.5"}),"Add widget"]})]}),e.widgets.length===0?o(VO,{onAdd:()=>r(!0)}):o("div",{className:"grid grid-cols-12 gap-3 auto-rows-[minmax(80px,_auto)]",children:e.widgets.map(d=>o(qO,{entry:d,onRemove:()=>c(d.instanceId)},d.instanceId))}),n&&o(QO,{widgets:a,onClose:()=>r(!1),onAdd:d=>{l(d),r(!1)}})]})}function VO({onAdd:e}){return u("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(Yy,{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"}),u("button",{onClick:e,className:"flex items-center gap-1.5 rounded-lg bg-primary px-4 py-2 text-xs font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg transition-all",children:[o(Nt,{className:"h-3.5 w-3.5"}),"Add your first widget"]})]})}function qO({entry:e,onRemove:t}){const n=UO(e.columns),r=Math.max(1,Math.min(12,e.rows));return u("div",{className:"relative group rounded-lg border border-border bg-surface overflow-hidden flex flex-col",style:{gridColumn:`span ${n} / span ${n}`,gridRow:`span ${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(Be,{className:"h-3 w-3"})}),o("div",{className:"flex-1 min-h-0 overflow-auto p-2",children:o(it,{widgetId:e.widgetId,host:"dashboard",instanceId:e.instanceId,config:e.config,deviceId:e.deviceId,size:e.size,columns:e.columns,rows:e.rows})})]})}function UO(e){return!Number.isFinite(e)||e<1?6:Math.min(12,Math.floor(e))}function QO({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:u("div",{className:"w-full max-w-2xl rounded-xl border border-border bg-surface p-5 shadow-2xl shadow-black/20",onClick:a=>a.stopPropagation(),children:[u("div",{className:"flex items-center justify-between mb-4",children:[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(Be,{className:"h-4 w-4"})})]}),r===null?o(KO,{widgets:e,onSelect:s}):o(GO,{widget:r,onCancel:()=>s(null),onAdd:n})]})})}function KO({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=>u("button",{onClick:()=>t(n),className:"flex flex-col rounded-lg border border-border p-3 text-left hover:bg-surface-hover hover:border-primary/30 transition-all group",children:[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 GO({widget:e,onCancel:t,onAdd:n}){const[r,s]=_(e.defaultSize),[a,i]=_(e.defaultColumns),[l,c]=_(e.defaultRows),[d,f]=_(null),{data:p}=$n({},{enabled:e.requires.deviceContext,staleTime:3e4}),h=!e.requires.deviceContext||d!==null&&d>0,m=()=>{if(!h)return;const g={instanceId:jO(),widgetId:e.widgetId,size:r,columns:a,rows:l,...e.requires.deviceContext&&d!==null?{deviceId:d}:{}};n(g)};return u("div",{className:"space-y-3",children:[u("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))})]}),u("div",{className:"grid grid-cols-2 gap-3",children:[o(Tp,{label:"Columns (1-12)",value:a,min:1,max:12,onChange:i}),o(Tp,{label:"Rows (1-12)",value:l,min:1,max:12,onChange:c})]}),e.requires.deviceContext&&u("div",{children:[o("label",{className:"block text-[11px] font-medium text-foreground-subtle mb-1",children:"Device"}),u("select",{value:d??"",onChange:g=>f(g.target.value===""?null:Number(g.target.value)),className:"w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none",children:[o("option",{value:"",children:"— select a device —"}),(p??[]).map(g=>u("option",{value:g.id,children:[g.name??g.stableId," (#",g.id,")"]},g.id))]})]}),u("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-border",children:[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 Tp({label:e,value:t,min:n,max:r,onChange:s}){return u("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 WO(){return o(HO,{})}function rt({icon:e,title:t,subtitle:n,actions:r,children:s}){const a=!!t||n!=null||r!=null;return u("div",{className:"p-4 space-y-4",children:[a&&u("div",{className:"flex items-center justify-between gap-4",children:[u("div",{className:"min-w-0",children:[t&&u("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 Lp=["camera","hub","nvr","light","siren","switch","sensor","thermostat","button","generic"];function YO(){const{t:e}=Ot(),t=Je(),n=Te();yt(["deviceManager"],["device.registered","device.unregistered","device.online","device.offline","device.disabled","device.enabled"]),yt(["integrations"],["integration.enabled","integration.disabled","integration.deleted","provider.started","provider.stopped","addon.installed","addon.uninstalled","addon.started","addon.stopped"]);const{data:r}=$n({},{staleTime:3e4}),{data:s}=Hc(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,S=0)=>{if(S>32)return!1;if(b.has(k.id))return!0;if(k.parentDeviceId==null)return!1;const E=y.get(k.parentDeviceId);return E?w(E,S+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]),f=q(()=>(s??[]).map(m=>({id:m.addonId,name:m.name??m.addonId,icon:o(un,{type:m.addonId,size:"sm"})})),[s]),p=U(m=>o(un,{type:m,size:"sm"}),[]),h=U(m=>t(`/devices/${String(m)}`),[t]);return u(rt,{icon:Sr,title:e("nav.devices","Devices"),children:[o(bo,{devices:i,trpc:n.trpcClient,filters:{types:Lp,addons:f},resolveIntegrationIcon:p,resolveParent:d,onNavigate:h}),l.length>0&&u("div",{className:"mt-6 space-y-2",children:[u("div",{className:"flex items-baseline gap-2",children:[o(dt,{className:"h-3.5 w-3.5 text-warning shrink-0"}),o("h2",{className:"text-sm font-semibold text-foreground",children:"Orphan devices"}),u("span",{className:"text-[10px] text-foreground-subtle",children:[l.length," device",l.length===1?"":"s"," pointing at integrations no longer registered"]})]}),u("div",{className:"rounded-lg border border-warning/30 bg-warning/5 p-2",children:[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(bo,{devices:l,trpc:n.trpcClient,filters:{types:Lp,addons:f},urlScope:"nested",lsKey:"devices:orphan",resolveIntegrationIcon:p,resolveParent:d,onNavigate:h})]})]})]})}function ZO({onSelect:e,onClose:t,pendingAddonId:n=null}){const{t:r}=Ot(),s=Je(),{data:a,isLoading:i}=Nb();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 u("div",{className:"space-y-2",children:[(a??[]).map(c=>{const d=c.instanceMode==="unique"&&c.existingInstances.length>0,f=n===c.addonId,p=l;return u("button",{disabled:p,onClick:()=>{if(!p)if(d){const 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:"◉"})}),u("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})]}),f?o(Ee,{className:"h-4 w-4 animate-spin text-primary flex-shrink-0"}):d?u("span",{className:"flex items-center gap-1 text-[10px] font-medium text-foreground-subtle",children:[o(Gt,{className:"h-3 w-3"}),r("integrations.manage")]}):o(Et,{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 XO(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Rp(e,t){if(e!==void 0)return t&&XO(e)?t(e):e}function JO({section:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,probeResults:i,onAction:l}){const[c,d]=_(e.defaultCollapsed??!1),f=e.style==="accordion";if(e.fields.reduce((b,x)=>b+(Zc(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 u("div",{className:"@container rounded-lg border border-border bg-surface p-3",style:{containerType:"inline-size"},children:[!g&&u("div",{className:["flex items-center justify-between mb-2",f?"cursor-pointer":""].join(" "),onClick:f?()=>d(b=>!b):void 0,children:[u("div",{children:[e.title&&o("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:Rp(e.title,s)}),e.description&&o("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:Rp(e.description,s)})]}),f&&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(ar,{field:b,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i?.[b.key],allFields:e.fields,onAction:l},b.key))})]})}function En({schema:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,probeResults:i,onClearProbe:l,onAction:c}){const d=(f,p)=>{n({...t,[f]:p}),l?.(f)};return o("div",{className:"space-y-4",children:e.sections.map((f,p)=>o(JO,{section:f,values:t,onChange:d,disabled:r,translationFn:s,onTestField:a,probeResults:i,onAction:c},`${f.id}-${p}`))})}function e8({addonId:e,configSchema:t,onSave:n,onBack:r}){const{t:s}=Ot(),[a,i]=_(""),[l,c]=_({}),[d,f]=_(null),p=kb({onSuccess:h=>f(h),onError:h=>f({success:!1,error:String(h)})});return u("div",{className:"space-y-4",children:[u("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(En,{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}`}),u("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")}),u("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 t8({providerId:e,onImport:t,onSkip:n}){const{t:r}=Ot(),[s,a]=_(new Set),i=Fc(),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 u("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 f=l??[];return u("div",{className:"space-y-4",children:[o("p",{className:"text-xs text-foreground-subtle",children:f.length>0?r("integrations.foundDevices",{count:f.length}):r("integrations.noDevicesFound")}),f.length>0&&o("div",{className:"space-y-1.5 max-h-64 overflow-y-auto",children:f.map(p=>{const h=p.stableId,m=p.suggestedName??h,g=s.has(h);return u("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(Mt,{className:"h-3 w-3 text-primary-foreground"})}),o(Sr,{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)})}),u("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")}),f.length>0&&u("button",{onClick:()=>t(Array.from(s)),disabled:s.size===0,className:"rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:[r("integrations.importSelected")," (",s.size,")"]})]})]})}function n8(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 r8({open:e,onClose:t}){const{t:n}=Ot(),r=Je(),s=ke(),[a,i]=_("picker"),[l,c]=_(null),[d,f]=_(null),[p,h]=_("manual"),{data:m}=Lc({addonId:l??"",nodeId:"hub"},{enabled:l!=null}),g=q(()=>m?n8(m):null,[m]),b=yb({onSuccess:()=>s.invalidateQueries({queryKey:[["integrations"]]})}),x=Fc(),y=x.data;Y(()=>{a!=="discovery"||!d||!l||x.isPending||x.data||x.mutate({addonId:l})},[a,d,l,x]);const w=hb({onSuccess:()=>s.invalidateQueries({queryKey:[["deviceManager"]]})});async function v(R,M,T,P){if(!b.isPending){if(c(R),h(T),M==="unique"){try{const L=await b.mutateAsync({addonId:R,name:P,settings:{}});t(),E(),r(`/integrations/${L.id}`)}catch{}return}i("config")}}async function N(R){if(l)try{const M=await b.mutateAsync({addonId:l,name:R.name,settings:R.config});f(M.id),p==="auto"||p==="both"?i("discovery"):S(M.id)}catch{}}async function k(R){if(l){for(const M of R){const T=y?.find(P=>P.stableId===M);T&&await w.mutateAsync({addonId:l,candidate:T})}S()}}function S(R){const M=R??d??l;t(),E(),M&&r(`/integrations/${M}`)}function E(){i("picker"),c(null),f(null),h("manual")}function A(){t(),E()}if(!e)return null;const I={picker:n("integrations.newIntegration"),config:n("integrations.configureIntegration"),discovery:n("integrations.importDevices")},B=b.isPending,$=B?l:null,z=b.error;return u("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[o("div",{className:"absolute inset-0 bg-black/60",onClick:B?void 0:A}),u("div",{className:"relative z-10 w-full max-w-lg rounded-xl border border-border bg-background shadow-2xl",children:[u("div",{className:"flex items-center justify-between border-b border-border px-5 py-4",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:I[a]}),o("button",{onClick:A,disabled:B,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(Be,{className:"h-4 w-4"})})]}),u("div",{className:"relative px-5 py-4",children:[z&&!B&&o("div",{className:"mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:z instanceof Error?z.message:String(z)}),a==="picker"&&o(ZO,{onSelect:v,onClose:A,pendingAddonId:$}),a==="config"&&l&&o(e8,{addonId:l,configSchema:g??null,onSave:N,onBack:()=>i("picker")}),a==="discovery"&&d&&o(t8,{providerId:d,onImport:k,onSkip:S}),B&&u("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background/85 backdrop-blur-sm",children:[o(Ee,{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 Op={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 za({status:e}){const t=Op[e]??Op.stopped;return u("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[10px] font-medium ${t.bg} ${t.text}`,children:[o("span",{className:`h-1.5 w-1.5 rounded-full ${t.dot}`}),t.label]})}const $i="px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle";function o8({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:u("table",{className:"w-full table-fixed text-xs",children:[o("thead",{className:"bg-surface-hover/40",children:u("tr",{children:[o("th",{className:W($i,"w-[60%]"),children:"Integration"}),o("th",{className:W($i,"w-[15%]"),children:"Devices"}),o("th",{className:W($i,"w-[25%]"),children:"Status"})]})}),o("tbody",{children:e.map(i=>{const l=t===i.addonId;return o(s8,{integration:i,isExpanded:l,onClick:a,onOpenSettings:r,renderExpanded:s},i.id)})})]})})}function s8({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 u(me,{children:[u("tr",{role:"button",tabIndex:0,"aria-expanded":t,className:W("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:u("div",{className:"flex items-center gap-2.5",children:[t?o(wt,{className:"h-3.5 w-3.5 flex-shrink-0 text-foreground-subtle"}):o(Et,{className:"h-3.5 w-3.5 flex-shrink-0 text-foreground-subtle"}),o(un,{type:e.addonId,size:"sm"}),u("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})]})]})}),u("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:u("div",{className:"flex items-center justify-between gap-2",children:[o(za,{status:e.status}),u("button",{type:"button",onClick:a,className:"flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary",title:"Open integration settings",children:[o(Gt,{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 a8(e){if(!e.enabled)return"disabled";switch(e.processState){case"running":return"running";case"stopped":case"crashed":case"unknown":default:return"stopped"}}const ds="expand";function i8(){const{t:e}=Ot(),t=Je(),n=Te(),[r]=Pa(),[s,a]=_(!1),i=U(()=>a(!0),[]),l=U(()=>a(!1),[]);yt(["integrations"],["integration.enabled","integration.disabled","integration.deleted","provider.started","provider.stopped","addon.installed","addon.uninstalled","addon.started","addon.stopped","addon.updated"]),yt(["deviceManager"],["device.registered","device.unregistered","device.online","device.offline","device.disabled","device.enabled"]);const{data:c,isLoading:d,refetch:f}=Hc(void 0,{staleTime:3e4}),{data:p,isLoading:h,refetch:m}=$n({},{staleTime:3e4}),g=q(()=>p??[],[p]),b=q(()=>c??[],[c]),x=q(()=>{const R=new Map;for(const M of g)R.set(M.id,{id:M.id,name:M.name??M.stableId??`#${String(M.id)}`});return R},[g]),y=q(()=>{const R=new Map;for(const M of g){if(M.parentDeviceId!==null&&M.parentDeviceId!==void 0&&!!M.role)continue;const P=M.addonId??"";P&&R.set(P,(R.get(P)??0)+1)}return R},[g]),w=q(()=>b.map(R=>({id:R.id,addonId:R.addonId,name:R.name,enabled:R.enabled,status:a8(R),deviceCount:y.get(R.addonId)??0})),[b,y]),v=r.get(ds),N=U(R=>{const M=new URLSearchParams(window.location.search);M.get(ds)===R?M.delete(ds):M.set(ds,R);const P=M.toString(),L=`${window.location.pathname}${P?`?${P}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",L),window.dispatchEvent(new PopStateEvent("popstate"))},[]),k=U(R=>t(`/integrations/${R}`),[t]),S=U(R=>x.get(R)??null,[x]),E=U(R=>o(un,{type:R,size:"sm"}),[]),A=U(R=>t(`/devices/${String(R)}`),[t]),I=U(R=>o(bo,{devices:g,trpc:n.trpcClient,forceAddon:R,urlScope:"nested",lsKey:`integrations:nested:${R}`,resolveIntegrationIcon:E,resolveParent:S,onNavigate:A}),[g,n.trpcClient,E,S,A]),B=U(()=>{f(),m()},[f,m]),$=d||h,z=b.length>0;return u(rt,{icon:Sd,title:e("nav.integrations","Integrations"),actions:u(me,{children:[o("button",{onClick:B,disabled:$,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(ft,{className:W("h-3.5 w-3.5",$&&"animate-spin")})}),u("button",{onClick:i,className:"flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm",children:[o(Nt,{className:"h-3.5 w-3.5"}),"New Integration"]})]}),children:[$&&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))}),!$&&!z&&u("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.'})]}),!$&&z&&o(o8,{integrations:w,expandedAddonId:v,onToggleExpand:N,onOpenSettings:k,renderExpanded:I}),o(r8,{open:s,onClose:l})]})}function k0(e){const t=[];for(const n of e)n.type==="probe"&&t.push(n.key),n.type==="group"&&"fields"in n&&t.push(...k0(n.fields));return t}function l8(e,t,n){const[r,s]=_("idle"),[a,i]=_({}),l=q(()=>{const p=[];for(const h of e.sections)p.push(...k0(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})},[]),f=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:f,clearProbeResult:d}}function S0(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(...S0(n.fields));return t}function Di(e){return e==null?!0:typeof e=="string"?e.trim()==="":!1}function $l(e,t={}){for(const n of e){if(n.type==="group"&&"fields"in n){$l(n.fields,t);continue}"key"in n&&n.key&&"default"in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function zp(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function c8({open:e,integrationId:t,addonId:n,onClose:r}){const{t:s}=Ot(),a=ke(),[i,l]=_({}),[c,d]=_(!1),[f,p]=_(null),[h,m]=_(zp),g=mb({addonId:n,type:at.Camera},{enabled:e}),b=g.data??null;Y(()=>{if(e){const M=b?$l(b.sections.flatMap(T=>T.fields)):{};l(M),m(zp()),d(!1),p(null)}},[e,t,b]);const x=q(()=>({...i,_probeRequestId:h}),[i,h]),y=gb({onSuccess:()=>{a.invalidateQueries({queryKey:[["deviceManager"]]})}}),w=jc(),v=U(async(M,T)=>{d(!0);const P=await w.mutateAsync({addonId:n,type:at.Camera,key:M,value:T,formValues:x});return P.status==="ok"&&P.suggestedValues&&l(L=>{let O=!1;const j={...L};for(const[F,H]of Object.entries(P.suggestedValues??{}))Di(L[F])&&!Di(H)&&(j[F]=H,O=!0);return O?j:L}),P},[w,n,x]),{testAllStatus:N,hasProbeFields:k,probeResults:S,handleTestAll:E,clearProbeResult:A}=l8(b??{sections:[]},i,v);async function I(M){p(null);try{if(await y.mutateAsync({addonId:n,type:at.Camera,config:i}),M){const T=b?$l(b.sections.flatMap(P=>P.fields)):{};l(T)}else r()}catch(T){p(T instanceof Error?T.message:String(T))}}if(!e)return null;const $=S0((b?.sections??[]).flatMap(M=>M.fields)).filter(M=>Di(i[M])),z=$.length===0,R=!g.isLoading&&(g.isError||b===null);return u("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[o("div",{className:"absolute inset-0 bg-black/60",onClick:r}),u("div",{className:"relative z-10 flex w-full max-w-2xl flex-col max-h-[90vh] rounded-xl border border-border bg-background shadow-2xl",children:[u("div",{className:"flex items-center justify-between border-b border-border px-5 py-4 shrink-0",children:[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(Be,{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(Ee,{className:"h-5 w-5 animate-spin text-primary"})}):R?u("div",{className:"flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3",children:[o(dt,{className:"h-4 w-4 text-destructive mt-0.5 shrink-0"}),u("div",{className:"space-y-1",children:[o("p",{className:"text-xs font-medium text-destructive",children:"Provider unavailable"}),u("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(En,{schema:b,values:i,onChange:l,onTestField:v,probeResults:S,onClearProbe:A})}),!R&&!g.isLoading&&u("div",{className:"border-t border-border bg-surface/50 shrink-0",children:[u("button",{type:"button",onClick:()=>d(M=>!M),className:"flex w-full items-center justify-between px-5 py-2 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:[u("span",{className:"flex items-center gap-2",children:[o(nt,{className:"h-3.5 w-3.5"}),"Test logs",o("span",{className:"font-mono text-[9px] opacity-60",children:h.slice(0,14)})]}),o(wt,{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(Yt,{addonId:n,requestId:h,limit:50,maxHeight:"max-h-64",showFilters:!1,showScope:!1,className:"border-0 rounded-none"})})]}),!R&&!g.isLoading&&(f||$.length>0)&&o("div",{className:"border-t border-destructive/30 bg-destructive/5 px-5 py-2 shrink-0",children:u("div",{className:"flex items-start gap-2",children:[o(dt,{className:"h-3.5 w-3.5 text-destructive mt-0.5 shrink-0"}),o("p",{className:"text-[11px] text-destructive",children:f||`Required: ${$.join(", ")}`})]})}),u("div",{className:"flex items-center justify-between border-t border-border px-5 py-3 shrink-0",children:[u("div",{className:"flex items-center gap-2",children:[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&&u("button",{type:"button",onClick:E,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(Ee,{className:"h-3.5 w-3.5 animate-spin"}):o(Kn,{className:"h-3.5 w-3.5"}),"Test All"]})]}),u("div",{className:"flex items-center gap-2",children:[o("button",{onClick:()=>I(!0),disabled:R||!z||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||!z||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 d8(){const{t:e}=Ot(),{integrationId:t}=pd(),n=ke(),r=Je(),s=Te(),[a,i]=_(!1),[l,c]=_(!1),[d,f]=_(!1),[p,h]=_(!1),{data:m,isLoading:g}=bb({id:t??""},{enabled:!!t}),{data:b}=Lc({addonId:m?.addonId??"",nodeId:"hub"},{enabled:!!m?.addonId}),x=b!=null&&Array.isArray(b.sections)&&b.sections.some(z=>z.fields.length>0),{data:y}=$n({},{refetchInterval:5e3}),w=[["integrations","get"],{input:{id:t??""},type:"query"}],v=vb({onMutate:async z=>{await n.cancelQueries({queryKey:w});const R=n.getQueryData(w);return R!=null&&n.setQueryData(w,{...R,enabled:z.enabled}),{previous:R}},onError:(z,R,M)=>{const T=M;T?.previous!=null&&n.setQueryData(w,T.previous)},onSettled:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),N=wb({onSuccess:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]}),f(!1),r("/integrations")}}),k=wa({onSuccess:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),S=q(()=>y??[],[y]),E=q(()=>{const z=new Map;for(const R of S)z.set(R.id,{id:R.id,name:R.name??R.stableId??`#${String(R.id)}`});return z},[S]),A=U(z=>E.get(z)??null,[E]),I=U(z=>o(un,{type:z,size:"sm"}),[]),B=U(z=>r(`/devices/${String(z)}`),[r]),$=q(()=>{const z=m?.addonId;if(!z)return 0;let R=0;for(const M of S)M.addonId!==z||M.parentDeviceId!==null&&M.parentDeviceId!==void 0&&M.role||(R+=1);return R},[S,m?.addonId]);return g?u("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?u("div",{className:"p-4 space-y-4",children:[o(vc,{items:[{label:"Integrations",onClick:()=>r("/integrations")},{label:m.name}]}),u("div",{className:"flex items-center justify-between",children:[u("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:z=>{z.target.style.display="none"}}),u("div",{children:[o("h1",{className:"text-lg font-semibold text-foreground",children:m.name}),u("p",{className:"text-[11px] text-foreground-subtle mt-0.5",children:[m.addonId," · ",$," ",e("integrations.devices")]})]})]}),u("div",{className:"flex items-center gap-3",children:[u("div",{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${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(hc,{checked:m.enabled,onCheckedChange:z=>v.mutate({id:t,enabled:z}),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(Ee,{className:"h-3 w-3 animate-spin text-foreground-subtle"})]}),x&&u("button",{onClick:()=>c(!0),className:"flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:[o(Gt,{className:"h-3 w-3"}),e("integrations.config")]}),u("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(nt,{className:"h-3 w-3"}),e("integrations.logs",{defaultValue:"Logs"})]}),o(gy,{label:"Restart",icon:ft,title:`Restart "${m.name}"?`,description:`Restarting the addon will briefly disconnect every device backed by it (${$} active). Streams will reconnect automatically.`,confirmLabel:"Restart",triggerVariant:"outline",confirmVariant:"danger",disabled:k.isPending,action:()=>k.mutateAsync({addonId:m.addonId})}),u("button",{onClick:()=>f(!0),className:"flex items-center gap-1.5 rounded-lg border border-danger bg-danger/10 px-3 py-1.5 text-[11px] font-medium text-danger hover:bg-danger hover:text-background transition-colors",title:e("integrations.delete",{defaultValue:"Delete integration"}),children:[o(Ge,{className:"h-3 w-3"}),e("integrations.delete",{defaultValue:"Delete"})]})]})]}),o(bo,{devices:S,trpc:s.trpcClient,defaultView:"cards",forceAddon:m.addonId,urlScope:"root",lsKey:`integration-detail:${m.addonId}`,resolveIntegrationIcon:I,resolveParent:A,onNavigate:B}),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(Nt,{className:"h-5 w-5 text-primary-foreground"})}),a&&t&&o(c8,{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:u("div",{className:"rounded-xl border border-border bg-surface p-6 shadow-xl w-80",onClick:z=>z.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:u("div",{className:"flex flex-col rounded-xl border border-border bg-surface shadow-xl w-full max-w-5xl h-[80vh]",onClick:z=>z.stopPropagation(),children:[u("div",{className:"flex items-center justify-between border-b border-border px-4 py-2.5",children:[u("div",{className:"flex items-center gap-2 min-w-0",children:[o(nt,{className:"h-4 w-4 text-primary shrink-0"}),o("h2",{className:"text-sm font-semibold text-foreground truncate",children:m.name}),u("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(Be,{className:"h-4 w-4"})})]}),o("div",{className:"flex-1 min-h-0 overflow-hidden",children:o(Yt,{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&&f(!1),children:u("div",{className:"rounded-xl border border-border bg-background p-5 shadow-2xl w-96 space-y-3",onClick:z=>z.stopPropagation(),children:[u("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(dt,{className:"h-4 w-4 text-danger"})}),u("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:$})})]})]}),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)}),u("div",{className:"flex items-center justify-end gap-2 pt-1",children:[o("button",{onClick:()=>f(!1),disabled:N.isPending,className:"rounded-lg border border-border px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:e("integrations.cancel",{defaultValue:"Cancel"})}),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?u(me,{children:[o(Ee,{className:"h-3 w-3 animate-spin"}),e("integrations.deleting",{defaultValue:"Deleting…"})]}):u(me,{children:[o(Ge,{className:"h-3 w-3"}),e("integrations.confirmDelete",{defaultValue:"Delete integration"})]})})]})]})})]}):u("div",{className:"flex flex-col items-center justify-center py-20 px-6 text-center gap-4",children:[o("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10",children:o(bR,{className:"h-6 w-6 text-foreground-subtle"})}),u("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??""})})]}),u("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(yd,{className:"h-3 w-3"}),e("integrations.backToList",{defaultValue:"Back to integrations"})]})]})}function u8({label:e,color:t,title:n,style:r}){return u("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:u("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 Ti=36e5;function p8(e){return String(e).padStart(2,"0")}function f8(e){const t=new Date(e);return`${p8(t.getHours())}:00`}function h8({startMs:e,endMs:t,segments:n,events:r,playheadMs:s,onSeek:a}){const i=ne(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 f=[],p=Math.floor(e/Ti),h=Math.ceil(t/Ti);for(let m=p;m<=h;m++){const g=m*Ti;g<e||g>t||f.push({percent:c(g),label:f8(g)})}return u("div",{className:"select-none",children:[o("div",{className:"relative h-5 mb-1",children:f.map(({percent:m,label:g})=>o("span",{className:"absolute -translate-x-1/2 text-[10px] text-foreground-subtle",style:{left:`${m}%`},children:g},g))}),u("div",{ref:i,className:"relative h-8 rounded bg-surface-hover cursor-pointer overflow-hidden border border-border",onClick:d,onPointerMove: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(u8,{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 Bp={person:"#f59e0b",vehicle:"#3b82f6",car:"#3b82f6",face:"#a855f7",plate:"#ec4899",animal:"#10b981",motion:"#ef4444",unknown:"#6b7280"};function Dl(e){return Bp[e.toLowerCase()]??Bp.unknown}function m8(e){const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function g8(e){return new Date(e).toISOString().slice(0,10)}function b8(e){return new Date(e+"T00:00:00").getTime()}function x8(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 y8(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:Dl(t[r%t.length])})).sort((n,r)=>n.timestampMs-r.timestampMs)}function v8(){const{t:e}=Ot(),t=m8(new Date),[n,r]=_(t),[s,a]=_(null),[i,l]=_(t+12*36e5),c=n,d=n+24*36e5,{data:f,isLoading:p}=$n({},{staleTime:3e4}),h=f??[],m=q(()=>h.filter(N=>{const k=N.type.toLowerCase();return k==="camera"||k.includes("camera")||N.features.some(S=>S.toLowerCase().includes("video")||S.toLowerCase().includes("stream"))}).map(N=>({id:N.id,name:N.name??N.stableId})),[h]),g=s??m[0]?.id??null,{data:b}=Jn({queryKey:["events",g,c],queryFn:()=>Promise.resolve(null),enabled:!!g,staleTime:6e4}),x=q(()=>{const v=Array.isArray(b)?b:(()=>{const k=au(b)?.events;return Array.isArray(k)?k:[]})();return v.length===0?g?y8(c):[]:v.flatMap((N,k)=>{const S=au(N);if(!S)return[];const E=String(S.class??S.type??S.label??"unknown").toLowerCase(),A=typeof S.timestamp=="number"?S.timestamp:c;return[{id:String(S.id??k),timestampMs:A,label:E,color:Dl(E)}]})},[b,g,c]),y=q(()=>g?x8(c):[],[g,c]);function w(v){r(N=>N+v*24*36e5),l(N=>N+v*24*36e5)}return u("div",{className:"flex flex-col h-full p-4 gap-4 overflow-hidden",children:[u("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")}),u("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(vd,{className:"h-4 w-4"})}),u("div",{className:"relative flex items-center",children:[o(jy,{className:"absolute left-2 h-3.5 w-3.5 text-foreground-subtle pointer-events-none"}),o("input",{type:"date",value:g8(n),onChange:v=>{if(v.target.value){const N=b8(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(Et,{className:"h-4 w-4"})})]})]}),u("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)})]}),u("div",{className:"relative w-full aspect-video rounded-xl border border-border bg-black shrink-0 overflow-hidden max-h-[45vh]",children:[u("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 text-foreground-subtle",children:[o(io,{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()})]}),u("div",{className:"rounded-xl border border-border bg-surface px-4 pt-3 pb-4 shrink-0",children:[u("div",{className:"flex flex-wrap items-center gap-4 mb-3",children:[o("span",{className:"text-[10px] font-semibold text-foreground-subtle uppercase tracking-wider",children:"Timeline"}),u("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=>u("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{backgroundColor:Dl(v)}}),o("span",{className:"text-[10px] text-foreground-subtle capitalize",children:v})]},v))]}),g?o(h8,{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 w8({selectedNodeId:e,onSelect:t,refreshToken:n}){const{data:r}=Dn(void 0,{staleTime:3e4}),{data:s}=ka(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 u("div",{className:"flex flex-col h-full",children:[u("button",{type:"button",onClick:()=>t(uo),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===uo?"bg-primary/10 text-primary":"text-foreground hover:bg-surface-hover"}`,children:[o(ln,{className:"h-4 w-4 flex-shrink-0"}),u("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 f=e===d.id,p=a.get(d.id)??0,h=d.isHub?cn:pt;return u("button",{type:"button",onClick:()=>t(d.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${f?"bg-primary/10 text-primary":"text-foreground hover:bg-surface-hover"}`,children:[o(h,{className:"h-4 w-4 flex-shrink-0"}),u("div",{className:"min-w-0 flex-1",children:[u("div",{className:"flex items-center gap-2",children:[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"})]}),u("div",{className:"text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5",children:[u("span",{children:[d.cpuCores," cores"]}),o("span",{children:"•"}),u("span",{children:[Math.round(d.memoryMB/1024)," GB"]}),p>0&&u(me,{children:[o("span",{children:"•"}),u("span",{className:"inline-flex items-center gap-0.5 text-foreground",children:[o(a0,{className:"h-2.5 w-2.5"}),p]})]})]})]})]},d.id)})}),u("div",{className:"px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between",children:[u("span",{children:[l," online"]}),c>0&&u("span",{className:"text-destructive",children:[c," offline"]})]})]})}function N8({nodeId:e,refreshToken:t}){const{data:n}=Dn(void 0,{staleTime:3e4}),r=n?.find(i=>i.id===e),a=Or("pipeline.runner-load-snapshot",i=>i.nodeId===e)?.load??null;return r?u("div",{className:"px-6 py-4 border-b border-border",children:[u("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"})]}),u("div",{className:"text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap",children:[o("span",{children:r.cpuModel??"CPU"}),o("span",{children:"•"}),u("span",{children:[r.cpuCores," cores"]}),o("span",{children:"•"}),u("span",{children:[Math.round(r.memoryMB/1024)," GB"]}),a&&u(me,{children:[o("span",{children:"•"}),u("span",{children:[a.attachedCameras," cameras (",a.activeCameras," active)"]}),o("span",{children:"•"}),u("span",{children:[a.avgInferenceTimeMs.toFixed(0),"ms avg inference"]}),o("span",{children:"•"}),u("span",{children:["queue ",a.queueDepthTotal]}),a.hardware.hasGpu&&u(me,{children:[o("span",{children:"•"}),o("span",{className:"text-success",children:"GPU"})]})]})]})]}):o("div",{className:"px-6 py-4 border-b border-border",children:u("div",{className:"text-xs text-foreground-subtle",children:["Node not found: ",e]})})}function C0({refreshToken:e,nodeId:t}){const[n,r]=_(new Map),{nodes:s}=zr();ut("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}=ix(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 u("div",{className:"@container/liveload",children:[o("h3",{className:"text-sm font-semibold text-foreground mb-2",children:"Live load"}),u("div",{className:"grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3",children:[o(jt,{label:"FPS",value:p?p.totalFps.toFixed(1):"—"}),o(jt,{label:"Cameras",value:p?`${p.activeCameras}/${p.attachedCameras}`:"—"}),o(jt,{label:"Avg infer ms",value:p&&p.attachedCameras>0?(p.totalInferenceWeighted/p.attachedCameras).toFixed(0):"—"}),o(jt,{label:"Queue",value:p?String(p.queueDepth):"—"}),o(jt,{label:"Audio",value:String(i.get(t)??"—")})]})]})}const f=[...l.entries()].sort(([p],[h])=>p==="hub"?-1:h==="hub"?1:p.localeCompare(h));return u("div",{className:"@container/liveload",children:[o("h3",{className:"text-sm font-semibold text-foreground mb-2",children:"Live load"}),u("div",{className:"grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3",children:[o(jt,{label:"Total agents",value:`${d.onlineAgents}/${d.totalAgents}`}),o(jt,{label:"Cameras",value:`${d.activeCameras}/${d.attachedCameras}`}),o(jt,{label:"Total FPS",value:d.totalFps.toFixed(1)}),o(jt,{label:"Avg inference ms",value:d.avgInferenceTimeMs.toFixed(0)}),o(jt,{label:"Queue depth",value:String(d.queueDepth)})]}),o("div",{className:"rounded-lg border border-border overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[480px]",children:[o("thead",{className:"bg-surface",children:u("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"})]})}),u("tbody",{children:[f.map(([p,h])=>u("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)),f.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 jt({label:e,value:t}){return u("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 M0(e){return $n({addonId:e})}function k8(e){return Qn({deviceId:e},{enabled:Number.isFinite(e)})}const S8=3e4,C8=2e3;function E0(e){const t=ne(0);return t.current===0&&(t.current=Date.now()),ab({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>=S8?!1:C8}})}const Li={active:!1,pinned:!1,nodeId:null,reason:""},Ri=["pipeline.camera-assigned","pipeline.camera-unassigned","pipeline.camera-updated","agent.online","agent.offline"],M8={pipeline:pt,decoder:io,audio:El},Fp={pipeline:"Pipeline",decoder:"Decoder",audio:"Audio"};function I0({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);yt(["pipelineOrchestrator","getPipelineAssignments"],Ri),yt(["pipelineOrchestrator","getDecoderAssignments"],Ri),yt(["pipelineOrchestrator","getAudioAssignments"],Ri);const{data:f}=ka(void 0,{staleTime:3e4}),{data:p}=ox(void 0,{staleTime:3e4}),{data:h}=lx(void 0,{staleTime:3e4}),{nodes:m}=zr(),{data:g}=M0();ut("pipeline.camera-metrics-snapshot",$=>{const z=$.data;typeof z.deviceId=="number"&&d(R=>{const M=new Map(R);return M.set(z.deviceId,z),M})}),Y(()=>{if(c.size===0)return;const $=setInterval(()=>{d(z=>{const R=Date.now()-1e4;let M=!1;const T=new Map(z);for(const[P,L]of z)L.timestamp<R&&(T.delete(P),M=!0);return M?T:z})},5e3);return()=>clearInterval($)},[c.size]);const b=q(()=>{const $=new Map;for(const z of g??[])$.set(z.id,z.name);return $},[g]),x=q(()=>{const $=new Map,z=M=>{const T=$.get(M);if(T)return T;const P={deviceId:M,deviceName:b.get(M)??`Device ${M}`,pipeline:Li,decoder:Li,audio:Li};return $.set(M,P),P};for(const M of f??[]){const T=z(M.deviceId);$.set(M.deviceId,{...T,pipeline:{active:e==="cluster"?!0:M.agentNodeId===t,pinned:M.pinned,nodeId:M.agentNodeId,reason:M.reason??""}})}for(const M of p??[]){const T=z(M.deviceId);$.set(M.deviceId,{...T,decoder:{active:e==="cluster"?!0:M.decoderNodeId===t,pinned:M.pinned,nodeId:M.decoderNodeId,reason:M.reason??""}})}for(const M of h??[]){const T=z(M.deviceId);$.set(M.deviceId,{...T,audio:{active:e==="cluster"?!0:M.nodeId===t,pinned:M.pinned,nodeId:M.nodeId,reason:"capacity"}})}let R=[...$.values()];return e==="agent"&&(R=R.filter(M=>M.pipeline.active||M.decoder.active||M.audio.active)),R.sort((M,T)=>M.deviceId-T.deviceId),R},[f,p,h,b,e,t]),y=q(()=>(m??[]).filter($=>$.isOnline).map($=>({id:$.id,name:$.name})),[m]),w=()=>{r.invalidateQueries({queryKey:[["pipelineOrchestrator","getPipelineAssignments"]]}),r.invalidateQueries({queryKey:[["pipelineOrchestrator","getDecoderAssignments"]]}),r.invalidateQueries({queryKey:[["pipelineOrchestrator","getAudioAssignments"]]})},v=Yb({onSuccess:w}),N=Zb({onSuccess:w}),k=nx({onSuccess:w}),S=rx({onSuccess:w}),E=sx({onSuccess:w}),A=ax({onSuccess:w}),I=($,z,R)=>{z==="pipeline"?v.mutate({deviceId:$,agentNodeId:R}):z==="decoder"?k.mutate({deviceId:$,nodeId:R}):E.mutate({deviceId:$,nodeId:R}),a(null)},B=($,z)=>{z==="pipeline"?N.mutate({deviceId:$}):z==="decoder"?S.mutate({deviceId:$}):A.mutate({deviceId:$}),a(null)};return o("div",{className:"rounded-lg border border-border overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[640px]",children:[o("thead",{className:"bg-surface",children:u("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"})]})}),u("tbody",{children:[x.map($=>{const z=c.get($.deviceId),R=i===$.deviceId;return u(ec.Fragment,{children:[u("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:$.deviceId),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle","aria-label":R?"Collapse broker details":"Expand broker details",children:R?o(wt,{className:"h-3.5 w-3.5"}):o(Et,{className:"h-3.5 w-3.5"})})}),u("td",{className:"px-3 py-2 align-middle",children:[o("div",{className:"text-foreground font-medium leading-tight",children:$.deviceName}),u("div",{className:"text-[10px] text-foreground-subtle leading-tight",children:["#",$.deviceId]})]}),o(Oi,{role:"pipeline",state:$.pipeline,mode:e,deviceId:$.deviceId,onlineNodes:y,isMenuOpen:s?.deviceId===$.deviceId&&s.role==="pipeline",onToggleMenu:()=>a(s?.deviceId===$.deviceId&&s.role==="pipeline"?null:{deviceId:$.deviceId,role:"pipeline"}),onCloseMenu:()=>a(null),onMove:M=>I($.deviceId,"pipeline",M),onUnpin:()=>B($.deviceId,"pipeline")}),o(Oi,{role:"decoder",state:$.decoder,mode:e,deviceId:$.deviceId,onlineNodes:y,isMenuOpen:s?.deviceId===$.deviceId&&s.role==="decoder",onToggleMenu:()=>a(s?.deviceId===$.deviceId&&s.role==="decoder"?null:{deviceId:$.deviceId,role:"decoder"}),onCloseMenu:()=>a(null),onMove:M=>I($.deviceId,"decoder",M),onUnpin:()=>B($.deviceId,"decoder")}),o(Oi,{role:"audio",state:$.audio,mode:e,deviceId:$.deviceId,onlineNodes:y,isMenuOpen:s?.deviceId===$.deviceId&&s.role==="audio",onToggleMenu:()=>a(s?.deviceId===$.deviceId&&s.role==="audio"?null:{deviceId:$.deviceId,role:"audio"}),onCloseMenu:()=>a(null),onMove:M=>I($.deviceId,"audio",M),onUnpin:()=>B($.deviceId,"audio")}),o("td",{className:"px-3 py-2 align-middle",children:o(A8,{snap:z})})]}),R&&!n&&u("tr",{className:"bg-surface/50",children:[o("td",{}),o("td",{colSpan:5,className:"px-3 py-2",children:o(it,{widgetId:"stream-broker/stream-broker-panel",host:"device-tab",deviceId:$.deviceId,instanceId:`pipeline-row/${$.deviceId}`,config:{variant:"compact",title:"Stream brokers & clients"}})})]})]},$.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 Oi({role:e,state:t,mode:n,onlineNodes:r,isMenuOpen:s,onToggleMenu:a,onCloseMenu:i,onMove:l,onUnpin:c}){const d=M8[e],f=r.filter(m=>m.id!==(t.nodeId??"")),h=(t.active||n==="cluster")&&(f.length>0||t.pinned);return u("td",{className:"px-3 py-2 align-middle relative",children:[u("div",{className:"flex items-center gap-2",children:[n==="agent"?o(E8,{state:t,Icon:d}):o(I8,{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":`${Fp[e]} actions`,children:o(aL,{className:"h-3 w-3 text-foreground-subtle"})})})]}),s&&h&&o(_8,{title:Fp[e],targets:f,pinned:t.pinned,onMove:l,onUnpin:c,onClose:i})]})}function E8({state:e,Icon:t}){const n=e.active?o0:jo;return u("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(e0,{className:"h-2.5 w-2.5 text-amber-400"})]})}function I8({state:e,Icon:t}){return!e.active||!e.nodeId?u("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:"—"})]}):u("div",{className:"flex items-center gap-1.5 min-w-0",children:[o(t,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),u("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?u("span",{className:"inline-flex items-center gap-0.5 text-amber-400",children:[o(e0,{className:"h-2.5 w-2.5"})," manual"]}):u("span",{className:"text-foreground-subtle truncate",children:["auto · ",e.reason||"capacity"]})})]})]})}function A8({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=tr(t);return u("div",{className:"flex flex-col gap-0.5 font-mono text-[10px] tabular-nums leading-tight",children:[u("span",{className:`inline-flex items-center gap-1 ${i.textColor}`,children:[o(td,{phase:t,className:"h-2.5 w-2.5"}),o("span",{className:"font-semibold uppercase tracking-wider",children:i.label})]}),u("span",{className:"text-foreground-subtle",children:[o("span",{className:"text-foreground",children:n.toFixed(1)}),u("span",{children:["/",a.toFixed(0)," fps"]})]}),u("span",{className:"text-foreground-subtle",children:[o("span",{className:"text-foreground",children:r.toFixed(0)}),o("span",{children:" ms"}),s>0&&u("span",{className:"text-warning ml-1",children:["q",s]})]})]})}function _8({title:e,targets:t,pinned:n,onMove:r,onUnpin:s,onClose:a}){const i=ne(null);return Y(()=>{const l=c=>{i.current?.contains(c.target)||a()};return window.addEventListener("mousedown",l),()=>window.removeEventListener("mousedown",l)},[a]),u("div",{ref:i,className:"absolute right-2 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-lg z-20 text-left",children:[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=>u("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&&u("button",{type:"button",onClick:s,className:"block w-full text-left px-3 py-1.5 text-[11px] text-destructive hover:bg-destructive/10 border-t border-border",children:["Unpin ",e.toLowerCase()]}),t.length===0&&!n&&o("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle italic",children:"Already auto · no other nodes online"})]})}function P8({nodeId:e,refreshToken:t}){return u("div",{className:"space-y-6",children:[o(C0,{refreshToken:t,nodeId:e}),u("div",{children:[o("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Cameras on this node"}),u("p",{className:"text-[11px] text-foreground-subtle",children:["Checkboxes mark the roles currently running on ",e,". Use the kebab to move a role to another node or unpin it; live KPIs come from the runner snapshot stream."]})]}),o(I0,{mode:"agent",nodeId:e,compact:!0})]})}function $8(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 D8({nodeId:e,refreshToken:t}){const n=ke(),r=Wb({onSettled:()=>{n.invalidateQueries({queryKey:["pipelineExecutor","listLoadedEngines"]})}}),{data:s}=Gb({nodeId:e},{staleTime:5e3}),i=Or("pipeline.engine-metrics-snapshot",h=>h.nodeId===e)?.engines??s??null,l=i===null;yt(["pipelineRunner","getLocalCameras"],["pipeline.camera-assigned","pipeline.camera-unassigned"]);const{data:c}=bx({nodeId:e},{staleTime:3e4}),{values:d}=Cc("pipeline.camera-metrics-snapshot",h=>h.deviceId,h=>h.nodeId===e),f=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 u("div",{className:"space-y-6",children:[u("div",{children:[o("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Inference engines on this node"}),u("p",{className:"text-[11px] text-foreground-subtle",children:[(i??[]).length," engine(s) resident in RAM. ",(c??[]).length," camera(s) attached, ",f," actively dispatching frames. Refreshes every 5s."]})]}),o("div",{className:"rounded-lg border border-border overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[640px]",children:[o("thead",{className:"bg-surface",children:u("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"})]})}),u("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 u("tr",{className:`border-t border-border ${m?"bg-amber-500/5":""}`,children:[o("td",{className:"px-3 py-2",children:u("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${m?"bg-amber-500/15 text-amber-400":"bg-success/15 text-success"}`,children:[m?o(pL,{className:"h-3 w-3"}):o(pt,{className:"h-3 w-3"}),m?"warm":"runtime"]})}),o("td",{className:"px-3 py-2",children:u("span",{className:"inline-flex items-center gap-1 text-[11px] text-sky-400",children:[o(Md,{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:$8(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:u("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(Ge,{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."})})]})]})}),u("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&&u("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 kt(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 A0(e){return kt(e*1024*1024)}const T8=new Set(bN);function jp(e){return T8.has(e)}function zi(e,t,n){return`${e}/${t}/${n}`}function Tl(e){return{coreml:"CoreML",openvino:"OpenVINO",onnx:"ONNX"}[e.format]??e.format.toUpperCase()}function Hp(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 zn(e){return e.format}function L8(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 R8({addonId:e,model:t,format:n,isActive:r,progress:s,errorMsg:a,onDownload:i,onDelete:l}){const c=t.formats[n];return c?u("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/50 last:border-b-0 hover:bg-surface-hover/30 transition-colors",children:[o("div",{className:`h-2 w-2 rounded-full shrink-0 ${c.downloaded?"bg-success":"bg-foreground-subtle/30"}`}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-sm font-medium text-foreground",children:t.name}),u("span",{className:"text-[10px] text-foreground-subtle font-mono",children:["(",t.id,")"]})]}),s&&s.progress>=0&&s.progress<100&&u("div",{className:"mt-1.5 flex items-center gap-2 max-w-xs",children:[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}%`}})}),u("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:A0(c.sizeMB)}),a&&u("span",{className:"flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0",title:a,children:[o(Cr,{className:"h-3 w-3 shrink-0"}),a]}),c.downloaded?u("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(Ee,{className:"h-3 w-3 animate-spin"}):o(Ge,{className:"h-3 w-3"}),r?"Deleting...":"Delete"]}):u("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(Ee,{className:"h-3 w-3 animate-spin"}):o(Cn,{className:"h-3 w-3"}),r?"Downloading...":"Download"]})]}):null}function O8({engines:e,activeEngine:t,viewEngine:n,onSelect:r}){const[s,a]=_(!1);return u("div",{className:"relative",children:[u("button",{type:"button",onClick:()=>a(!s),className:"flex items-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 w-full text-left hover:bg-surface-hover transition-colors",children:[o(pt,{className:"h-4 w-4 text-primary shrink-0"}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-sm font-medium text-foreground",children:Tl(n)}),zn(n)===zn(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:Hp(n)})]}),o(wt,{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=zn(i)===zn(n),c=zn(i)===zn(t);return u("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(pt,{className:`h-4 w-4 shrink-0 ${l?"text-primary":"text-foreground-subtle"}`}),u("div",{className:"flex-1",children:[u("div",{className:"flex items-center gap-2",children:[o("span",{className:`text-sm font-medium ${l?"text-primary":"text-foreground"}`,children:Tl(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:Hp(i)})]}),l&&o(Vy,{className:"h-4 w-4 text-primary shrink-0"})]},zn(i))})})]})}function z8({embedded:e=!1,nodeId:t}={}){const n=ke(),r=t??"hub",[s,a]=_(null),[i,l]=_(new Set),[c,d]=_(new Map),[f,p]=_(new Map),[h,m]=_(""),{data:g=[]}=Vb({nodeId:r},{staleTime:6e4}),x=g.filter((O,j,F)=>F.findIndex(H=>H.format===O.format)===j),{data:y}=qb({nodeId:r},{staleTime:3e4}),w=y,{data:v,isLoading:N}=Lo({nodeId:r},{staleTime:1e4}),k=Qb(),S=Kb();ut("model.download.progress",O=>{const j=O.data,F=typeof j.modelId=="string"?j.modelId:void 0,H=typeof j.progress=="number"?j.progress:void 0,D=typeof j.totalMB=="number"?j.totalMB:0;F===void 0||H===void 0||(d(Q=>{const K=new Map(Q);return H===100||H===-1?K.delete(F):K.set(F,{modelId:F,progress:H,totalMB:D}),K}),H===100&&n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]}))});const E=w??{runtime:"node",backend:"cpu",format:"onnx"},A=x.find(O=>O.format===s)??E,I=A.format,B=v?.slots??[],$=B.map(O=>({...O,addons:O.addons.map(j=>({...j,models:j.models.filter(F=>F.formats[I]!==void 0)})).filter(j=>j.models.length>0)})).filter(O=>O.addons.length>0),z=L8($,I),R=U(async(O,j,F)=>{if(!jp(F))return;const H=zi(O,j,F);l(D=>new Set([...D,H])),p(D=>{const Q=new Map(D);return Q.delete(H),Q});try{await k.mutateAsync({addonId:O,modelId:j,format:F,nodeId:r}),n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]})}catch(D){p(Q=>new Map([...Q,[H,D instanceof Error?D.message:"Download failed"]]))}finally{l(D=>{const Q=new Set(D);return Q.delete(H),Q})}},[k,n,r]),M=U(async(O,j,F)=>{if(!jp(F))return;const H=zi(O,j,F);l(D=>new Set([...D,H])),p(D=>{const Q=new Map(D);return Q.delete(H),Q});try{await S.mutateAsync({addonId:O,modelId:j,format:F,nodeId:r}),n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]})}catch(D){p(Q=>new Map([...Q,[H,D instanceof Error?D.message:"Delete failed"]]))}finally{l(D=>{const Q=new Set(D);return Q.delete(H),Q})}},[S,n,r]),T=U(O=>{a(O.format)},[]),P=h.trim()?$.map(O=>({...O,addons:O.addons.map(j=>({...j,models:j.models.filter(F=>F.name.toLowerCase().includes(h.toLowerCase())||F.id.toLowerCase().includes(h.toLowerCase())||j.name.toLowerCase().includes(h.toLowerCase()))})).filter(j=>j.models.length>0)})).filter(O=>O.addons.length>0):$,L=u(me,{children:[N&&o("div",{className:"flex items-center justify-center py-16",children:o(Ee,{className:"h-5 w-5 animate-spin text-foreground-subtle"})}),!N&&B.length===0&&u("div",{className:"flex flex-col items-center justify-center py-16 text-foreground-subtle",children:[o(Us,{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&&B.length>0&&u(me,{children:[o(O8,{engines:x,activeEngine:E,viewEngine:A,onSelect:T}),u("div",{className:"flex items-center gap-4 text-xs text-foreground-subtle",children:[u("span",{children:[o("span",{className:"font-semibold text-foreground tabular-nums",children:z.total}),o("span",{className:"ml-1",children:"compatible models"})]}),o("span",{className:"text-border",children:"|"}),u("span",{children:[o("span",{className:"font-semibold text-success tabular-nums",children:z.downloaded}),o("span",{className:"ml-1",children:"downloaded"})]}),o("span",{className:"text-border",children:"|"}),u("span",{className:"tabular-nums",children:[A0(z.downloadedSizeMB),o("span",{className:"ml-1",children:"on disk"})]})]}),z.total>5&&u("div",{className:"relative",children:[o(r0,{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:O=>m(O.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"})]}),P.map(O=>{const j=O.addons.reduce((H,D)=>H+D.models.length,0),F=O.addons.reduce((H,D)=>H+D.models.filter(Q=>Q.formats[I]?.downloaded).length,0);return u("div",{children:[u("div",{className:"flex items-center gap-2 mb-2",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:O.label}),o("div",{className:"flex-1 h-px bg-border"}),u("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[F,"/",j]})]}),o("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:O.addons.map(H=>H.models.map(D=>{const Q=zi(H.id,D.id,I);return o(R8,{addonId:H.id,model:D,format:I,isActive:i.has(Q),progress:c.get(D.id),errorMsg:f.get(Q),onDownload:()=>R(H.id,D.id,I),onDelete:()=>M(H.id,D.id,I)},`${H.id}/${D.id}`)}))})]},O.id)}),P.length===0&&o("div",{className:"text-center py-8 text-sm text-foreground-subtle",children:h.trim()?u(me,{children:["No models matching “",h,"”"]}):u(me,{children:["No models available for ",Tl(A)," format"]})})]})]});return e?o("div",{className:"space-y-4",children:L}):o(rt,{children:L})}function B8({nodeId:e,refreshToken:t}){return o(z8,{embedded:!0,nodeId:e})}function _0({nodeId:e,title:t}){const{data:n}=M0(),{data:r}=ka(void 0,{staleTime:3e4}),s=q(()=>{const d=new Map;for(const f of n??[])d.set(f.id,f.name);return d},[n]),a=q(()=>{if(!e)return null;const d=new Set;for(const f of r??[])f.agentNodeId===e&&d.add(f.deviceId);return d},[e,r]),[i,l]=_(new Map);ut("pipeline.camera-metrics-snapshot",d=>{const f=d.data;typeof f.deviceId=="number"&&(e&&f.nodeId!==e||l(p=>{const h=new Map(p);return h.set(f.deviceId,f),h}))}),Y(()=>{if(i.size===0)return;const d=setInterval(()=>{l(f=>{const p=Date.now()-1e4;let h=!1;const m=new Map(f);for(const[g,b]of f)b.timestamp<p&&(m.delete(g),h=!0);return h?m:f})},5e3);return()=>clearInterval(d)},[i.size]);const c=q(()=>{const d=[];for(const f of i.values())a&&!a.has(f.deviceId)||d.push(f);return d.sort((f,p)=>f.deviceId-p.deviceId),d},[i,a]);return c.length===0?u("div",{className:"rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic",children:[t??"Cameras",": no live snapshots yet"]}):u("div",{className:"rounded-md border border-border bg-surface px-3 py-2",children:[u("div",{className:"flex items-center gap-2 mb-1.5",children:[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 f=s.get(d.deviceId)??`#${d.deviceId}`,p=tr(d.metrics.phase);return u("div",{title:`${f} · ${p.label} · ${d.metrics.actualFps.toFixed(1)} fps · ${d.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${d.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${p.badgeClass}`,children:[o(td,{phase:d.metrics.phase,className:"h-2.5 w-2.5"}),o("span",{className:"font-medium text-foreground/90 max-w-[120px] truncate",children:f}),o("span",{className:"font-mono tabular-nums",children:d.metrics.actualFps.toFixed(1)}),o("span",{className:"opacity-60",children:"fps"})]},d.deviceId)})})]})}function Bi(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 F8({nodeId:e,refreshToken:t}){const n=ke(),[r,s]=_(null),[a,i]=_(null),l=Lo({nodeId:e},{refetchOnMount:"always"}),c=qc({agentNodeId:e},{refetchOnMount:"always"}),d=Uc({onSuccess:()=>{n.invalidateQueries({queryKey:[["addonSettings"]]}),n.invalidateQueries({queryKey:[["pipelineOrchestrator"]]}),n.invalidateQueries({queryKey:[["pipelineExecutor"]]})}}),f=l.data??null,p=c.data,h=f?.selectedEngine.format??"coreml",m=q(()=>f?ba(f):[],[f]),g=q(()=>[{agentNodeId:e,engineLabel:h}],[e,h]),b=(S,E)=>{const A=p?.addonDefaults[S];return Bi(f,S)?.models.some($=>!!$.formats[h])?A?A.enabled?{kind:"enabled",modelId:A.modelId}:{kind:"disabled"}:{kind:"na"}:{kind:"na"}},x=r&&f?Bi(f,r.addonId):null,y=S=>{const E=p?.addonDefaults[S]??null;s({addonId:S,agentNodeId:e}),i(E)},w=(S,E)=>{if(!p)return;const A=p.addonDefaults[S],I=Bi(f,S);if(!A&&!I)return;const B={enabled:E,modelId:A?.modelId??I?.defaultModelId??"",settings:A?.settings??{}};d.mutate({agentNodeId:e,defaults:{...p.addonDefaults,[S]:B}})},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 u("div",{className:"text-xs text-red-400",children:["Failed to load catalog: ",String(l.error)]});if(!f)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 u("div",{className:"relative h-full w-full space-y-3",children:[o(_0,{nodeId:e}),o("div",{className:k?"pr-[360px]":"",children:m.length>0?o(Nc,{tree:m,agents:g,getCellState:b,onCellClick:y,selectedCell:r,onToggleEnabled:w}):o("div",{className:"text-xs text-foreground-subtle",children:"Catalog empty."})}),o(wc,{open:k,onClose:v,title:x?.name??"",subtitle:r?`${r.agentNodeId} · ${h}`:"",footer:u(me,{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(ya,{mode:"agent",addon:x,agentDefault:a,agentNodeId:r.agentNodeId,engineFormat:h,onChangeAgentConfig:S=>i(S)})})]})}function P0({pendingCount:e,onSave:t,onDiscard:n,saving:r=!1,saveLabel:s="Save",discardLabel:a="Discard"}){return e<=0?null:u("div",{className:"sticky bottom-0 -mb-3 flex items-center justify-between gap-3 rounded-lg border border-primary/40 bg-primary/5 px-3 py-2 shadow-sm z-10",children:[u("span",{className:"text-xs text-foreground",children:[e," unsaved change",e===1?"":"s"]}),u("div",{className:"flex items-center gap-2",children:[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 $0({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 u("button",{type:"button",onClick:()=>n(a.id),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${i?"text-primary border-primary bg-primary/5":"text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover"}`,children:[a.label,l>0&&u("span",{className:"ml-1.5 text-[10px] opacity-60",children:["(",l,")"]}),c>0&&o("span",{className:"ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-primary"})]},a.id)})})}function j8(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 D0({schema:e,serverValues:t,onImmediateSave:n,onDeferredSave:r}){const[s,a]=_({}),[i,l]=_(!1),c=ne(null),d=e?.sections??[],f=Object.keys(s).length>0,p=q(()=>({...t,...s}),[t,s]);Y(()=>{if(f){l(!0);return}c.current&&clearTimeout(c.current),c.current=setTimeout(()=>l(!1),500)},[f]);const 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,S]of Object.entries(y))N[k]!==S&&(j8(d,k)?w[k]=S:v[k]=S);Object.keys(w).length>0&&n(w),a(k=>{const S={...k};for(const E of Object.keys(w))delete S[E];for(const[E,A]of Object.entries(v))S[E]=A;return S})},[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:f,editingPaused:i,handleChange:m,handleSave:g,handleDiscard:b,resetAll:x}}const H8=qe(function({addonId:t,schema:n,serverValues:r,onImmediateSave:s,onStateChange:a,onAction:i,disabled:l},c){const d=D0({schema:n,serverValues:r,onImmediateSave:U(b=>s(t,b),[t,s]),onDeferredSave:U(()=>{},[])});lN(c,()=>({flush:()=>{const b={};for(const x of d.pendingKeys)b[x]=d.values[x];return d.handleDiscard(d.pendingKeys),b},discard:()=>d.resetAll()}),[d]);const f=d.pendingKeys,p=f.join("|"),h=q(()=>f.map(b=>`${b}=${JSON.stringify(d.values[b])}`).join(","),[f,d.values]),m=ne(a);Y(()=>{m.current=a},[a]),Y(()=>{const b={};for(const x of f)b[x]=d.values[x];m.current({addonId:t,pendingKeys:f,pendingValues:b})},[t,p,h]);const g=q(()=>{if(i)return(b,x,y)=>i(t,b,x,y)},[t,i]);return o(En,{schema:n,values:d.values,onChange:d.handleChange,disabled:l,onAction:g})});function T0(e,t){if(e.type==="separator"||e.type==="info"||e.type==="button")return e;if(e.type==="group"){const a=e.fields.map(i=>T0(i,t));return{...e,fields:a}}const n=e;t[e.key]=n.value;const{value:r,...s}=n;return s}function V8(e,t){return{...e,fields:e.fields.map(n=>T0(n,t))}}function q8(e){const t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(r=>V8(r,t))},values:t}}function Ur({nodeId:e,addonIds:t,level:n,deviceId:r,sectionIds:s,sectionTab:a,extraTabs:i,title:l,description:c}){const d=ke(),f=Te().trpcClient,p=zg(),h=Bg(),m=Ub(),g=eb(),b=Qg(),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=uN({queries:t.map(X=>({queryKey:[["addonSettings",n==="global"?"getGlobalSettings":"getDeviceSettings"],{addonId:X,nodeId:v,deviceId:r??null}],queryFn:async()=>{if(n==="global"){const J=await f.addonSettings.getGlobalSettings.query({addonId:X,nodeId:v});return{addonId:X,result:J}}const G=await f.addonSettings.getDeviceSettings.query({addonId:X,deviceId:r,nodeId:v});return{addonId:X,result:G}},staleTime:3e4}))}),k=N.some(X=>X.isLoading),S=N.map(X=>{if(!X.data)return"-";if(X.data.result===null)return`${X.data.addonId}:n`;const G=[];for(const J of X.data.result.sections){G.push(`s:${J.id}:${J.tab??"general"}`);for(const ae of J.fields){if(!("key"in ae))continue;const fe="options"in ae&&Array.isArray(ae.options)?ae.options.map(ie=>ie.value).join(","):"",ge=ae.value,V=ge===void 0?"":typeof ge=="string"?ge:JSON.stringify(ge);G.push(`f:${ae.key}:${fe}:${V}`)}}return`${X.data.addonId}:${G.join("|")}`}).join("||"),E=q(()=>{const X=new Set;for(const G of N){const J=G.data?.result?.sections;if(J)for(const ae of J)X.add(ae.tab??"general")}return[...X]},[S+"::"+N.map(X=>(X.data?.result?.sections??[]).map(G=>G.tab??"general").join(",")).join("::")]),A=q(()=>new Map((i??[]).map(X=>[X.id,X])),[i]),I=q(()=>{if(!x)return[];const X=[...new Set([...E,...(i??[]).map(J=>J.id)])],G=J=>{const ae=A.get(J);if(ae?.order!==void 0)return ae.order;const fe=ol[J];return fe?fe.order:50};return X.sort((J,ae)=>{const fe=G(J),ge=G(ae);return fe!==ge?fe-ge:J.localeCompare(ae)})},[x,E,i,A]),B=q(()=>{const X=new Map;for(const G of E){const J=ol[G];X.set(G,J?.label??G.charAt(0).toUpperCase()+G.slice(1))}for(const G of i??[])X.set(G.id,G.label);return X},[E,i]),$=x?y&&I.includes(y)?y:I[0]??null:null,z=$!==null&&A.has($),R=x?$&&!z?$:void 0:a,{data:M}=va(void 0,{staleTime:6e4}),T=q(()=>{const X=new Map;for(const G of M??[]){const J=G.manifest?.id;if(!J)continue;const ae=G.manifest?.name??G.manifest?.packageDisplayName??J;X.set(J,ae)}return X},[M]),P=q(()=>{const X=s?new Set(s):null,G=[];for(const J of N){if(!J.data||J.data.result===null)continue;const{schema:ae,values:fe}=q8(J.data.result),ge=ae.sections.filter(ue=>X?X.has(ue.id):!0);if(ge.length===0)continue;const V={...J.data.result,sections:J.data.result.sections.filter(ue=>X?X.has(ue.id):!0)},ie={...ae,sections:ge};G.push({addonId:J.data.addonId,schemaWithValues:V,schema:ie,serverValues:fe})}return G},[S,s]),[L,O]=_(new Map),j=U(X=>{O(G=>{const J=new Map(G);return J.set(X.addonId,X),J})},[]),F=ne(new Map),H=U(X=>G=>{G?F.current.set(X,G):F.current.delete(X)},[]),D=U(async(X,G)=>{n==="global"?await p.mutateAsync({addonId:X,nodeId:v,patch:G}):await h.mutateAsync({addonId:X,deviceId:r,nodeId:v,patch:G}),d.invalidateQueries({queryKey:[["addonSettings"]]})},[p,h,v,n,r,d]),Q=U(async(X,G,J,ae)=>{const fe=v;try{switch(G){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 f.addons.custom.mutate({addonId:X,action:G,input:ae});return d.invalidateQueries({queryKey:[["addonSettings"]]}),ge}}}catch(ge){throw console.error("[NodeAddonsSettingsPanel] action failed",{addonId:X,action:G,err:ge}),ge}},[m,g,b,v,d,f]),K=U((X,G)=>{D(X,G)},[D]),ee=nc({mutationFn:async()=>{const X=[];for(const J of P){const ae=L.get(J.addonId);!ae||ae.pendingKeys.length===0||X.push({addonId:J.addonId,patch:ae.pendingValues})}return X.length===0?{saved:[]}:{saved:await Promise.all(X.map(async({addonId:J,patch:ae})=>(n==="global"?await p.mutateAsync({addonId:J,nodeId:v,patch:ae}):await h.mutateAsync({addonId:J,deviceId:r,nodeId:v,patch:ae}),J)))}},onSuccess:({saved:X})=>{for(const G of X)F.current.get(G)?.discard();d.invalidateQueries({queryKey:[["addonSettings"]]})}}),oe=U(()=>{for(const X of F.current.values())X.discard()},[]),te=q(()=>{let X=0;for(const G of P){const J=L.get(G.addonId);J&&(X+=J.pendingKeys.length)}return X},[P,L]),Z=q(()=>{const X=new Map;for(const G of P){const J=L.get(G.addonId);if(!J||J.pendingKeys.length===0)continue;const ae=new Set(J.pendingKeys);for(const fe of G.schema.sections){const ge=fe.tab??"general";for(const V of fe.fields)"key"in V&&ae.has(V.key)&&X.set(ge,(X.get(ge)??0)+1)}}return X},[P,L]);if(k)return o("div",{className:"h-24 rounded-lg border border-border bg-surface animate-pulse"});const re=$&&z?A.get($):void 0;if(!x&&P.length===0)return u("div",{className:"text-[11px] text-foreground-subtle italic",children:["No addons in ",t.length>0?`[${t.join(", ")}]`:"the current selection"," ","expose ",n,"-level settings on this node."]});const be=ee.isPending;return u("div",{className:"space-y-4",children:[(l||c)&&u("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($0,{tabs:I.map(X=>({id:X,label:B.get(X)??X})),activeId:$,onChange:w,pendingByTab:Z}),ee.isError&&u("div",{className:"rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400",children:["Save failed: ",String(ee.error?.message??ee.error)]}),re?re.content:(()=>{const X=R?P.reduce((ae,fe)=>ae+fe.schemaWithValues.sections.filter(ge=>(ge.tab??"general")===R).length,0):0,G=R!==null&&X<=1,J=P.map(ae=>({...ae,renderedWithValues:{...ae.schemaWithValues,sections:ae.schemaWithValues.sections.filter(fe=>R?(fe.tab??"general")===R:!0).map(fe=>G?{...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},V=ge(ae.renderedWithValues.sections),ie=ge(fe.renderedWithValues.sections);return V!==ie?V-ie:0});return J.length===0?o("div",{className:"text-[11px] text-foreground-subtle italic",children:"Nothing to configure here for this node."}):o(U8,{entries:J,paneStates:L,displayNames:T,disabled:be,setPaneRef:H,onPaneStateChange:j,onImmediateSave:K,onAction:Q,inline:x||!!a})})(),!k&&o(P0,{pendingCount:te,onSave:()=>ee.mutate(),onDiscard:oe,saving:be})]})}function U8({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]),f=d[0]?.addonId??"",[p,h]=_(f);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(H8,{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)}):u("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 u("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 Q8=["detection-pipeline","decoder-nodeav","audio-analyzer","pipeline-runner"];function K8({nodeId:e,refreshToken:t}){return u("div",{className:"flex flex-col h-full",children:[o(N8,{nodeId:e,refreshToken:t}),o("div",{className:"flex-1 min-h-0 overflow-y-auto p-6",children:o(Ur,{nodeId:e,addonIds:Q8,level:"global",extraTabs:[{id:"assignments",label:"Assignments",order:-10,content:o(P8,{nodeId:e,refreshToken:t})},{id:"tree",label:"Pipeline",order:39,content:o(F8,{nodeId:e,refreshToken:t})},{id:"engines",label:"Warm instances",order:180,content:o(D8,{nodeId:e,refreshToken:t})},{id:"models",label:"Models",order:200,content:o(B8,{nodeId:e,refreshToken:t})}]})})]})}function G8({refreshToken:e}){const t=ke(),n=Xb({onSuccess:()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","getPipelineAssignments"]]}),t.invalidateQueries({queryKey:[["pipelineOrchestrator","getDecoderAssignments"]]}),t.invalidateQueries({queryKey:[["pipelineOrchestrator","getAudioAssignments"]]})}});return u("div",{className:"space-y-6",children:[o(C0,{refreshToken:e}),u("div",{className:"flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between",children:[u("div",{className:"min-w-0",children:[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."})]}),u("button",{type:"button",onClick:()=>n.mutate(void 0),disabled:n.isPending,className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-white hover:bg-primary/90 disabled:opacity-50 shrink-0 self-start @md/clustertab:self-auto whitespace-nowrap",children:[o(Md,{className:"h-3.5 w-3.5"}),n.isPending?"Rebalancing…":"Rebalance pipelines"]})]}),o(I0,{mode:"cluster"})]})}const W8=["pipeline-orchestrator"];function Y8({refreshToken:e}){return o("div",{className:"space-y-4 max-w-3xl",children:o(Ur,{nodeId:"hub",addonIds:W8,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 Z8({refreshToken:e}){const t=ke(),{data:n,isLoading:r}=hx(),[s,a]=_(null),[i,l]=_(""),[c,d]=_(""),f=()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","listTemplates"]]})},p=mx({onSuccess:()=>{a(null),f()}}),h=gx({onSuccess:f}),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:u("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"border-b border-border px-4 py-3 flex items-center justify-between",children:[u("div",{children:[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."})]}),u("div",{className:"text-[11px] text-foreground-subtle",children:[x.length," template",x.length===1?"":"s"]})]}),x.length===0?u("div",{className:"px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2",children:[o(Nt,{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:u("div",{className:"flex items-start gap-3",children:[o("div",{className:"flex-1 min-w-0",children:w?u("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)"})]}):u(me,{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}),u("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":"",u("span",{className:"ml-2",children:["updated ",new Date(y.updatedAt).toLocaleString()]})]})]})}),o("div",{className:"flex items-center gap-1 shrink-0",children:w?u(me,{children:[u("button",{type:"button",onClick:b,disabled:p.isPending,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-50",children:[o(Mt,{className:"h-3 w-3"}),"Save"]}),u("button",{type:"button",onClick:g,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover",children:[o(Be,{className:"h-3 w-3"}),"Cancel"]})]}):u(me,{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(qr,{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(Ge,{className:"h-3 w-3"})})]})})]})},y.id)})})]})})}function Vp(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 X8({nodeId:e,refreshToken:t}){const n=ke(),r=Te().trpcClient,[s,a]=_(null),[i,l]=_(null),c=Fr(void 0,{refetchOnMount:"always"});yt(["nodes","topology"],["agent.online","agent.offline","agent.unregistered","addon.installed","addon.uninstalled","addon.updated"]);const d=Dn(void 0,{staleTime:3e4,refetchOnMount:"always"}),f=q(()=>{const I=new Set;for(const B of d.data??[])B.isOnline&&I.add(B.id);return I},[d.data]),p=Lo({nodeId:e},{refetchOnMount:"always"}),h=q(()=>(c.data??[]).filter(I=>f.has(I.nodeId)).map(I=>I.nodeId),[c.data,f]),m=Jn({enabled:h.length>0,queryKey:[["pipelineExecutor","getSchema"],"schema-by-agent",h.join(","),t],queryFn:async()=>{const I={};for(const B of h)try{const $=await r.pipelineExecutor.getSchema.query({nodeId:B});I[B]=$.selectedEngine.format}catch{I[B]="coreml"}return I}}),g=Uc({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator"]]}),n.invalidateQueries({queryKey:[["pipelineExecutor"]]}),n.invalidateQueries({queryKey:[["addonSettings"]]})}}),b=q(()=>p.data?ba(p.data):[],[p.data]),x=q(()=>{const I=c.data??[],B=f;return(B.size===0?[]:I.filter(z=>B.has(z.nodeId))).map(z=>{const R=m.data?.[z.nodeId];return{agentNodeId:z.nodeId,engineLabel:R??"(engine unknown)"}})},[c.data,m.data,f]),y=(I,B)=>{const z=c.data?.find(P=>P.nodeId===B)?.settings.addonDefaults[I],R=m.data?.[B];return Vp(p.data??null,I)?.models.some(P=>R!==void 0&&!!P.formats[R])?z?z.enabled?{kind:"enabled",modelId:z.modelId}:{kind:"disabled"}:{kind:"na"}:{kind:"na"}},w=s?c.data?.find(I=>I.nodeId===s.agentNodeId)??null:null,v=s&&p.data?Vp(p.data,s.addonId):null,N=s?m.data?.[s.agentNodeId]??"coreml":"coreml",k=()=>{a(null),l(null)},S=(I,B)=>{const z=c.data?.find(R=>R.nodeId===B)?.settings.addonDefaults[I]??null;a({addonId:I,agentNodeId:B}),l(z)},E=()=>{!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 u("div",{className:"text-xs text-foreground-subtle",children:["Catalog unavailable for ",e,"."]});const A=s!==null&&v!==null&&i!==null;return u("div",{className:"relative h-full w-full space-y-3",children:[o(_0,{title:"Cluster cameras"}),o("div",{className:A?"pr-[360px]":"",children:b.length>0&&x.length>0?o(Nc,{tree:b,agents:x,getCellState:y,onCellClick:S,selectedCell:s}):o("div",{className:"text-xs text-foreground-subtle",children:"No agents or catalog empty."})}),o(wc,{open:A,onClose:k,title:v?.name??"",subtitle:s?`${s.agentNodeId} · ${N}`:"",footer:u(me,{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:E,children:g.isPending?"Saving…":"Save"})]}),children:v&&i&&s&&o(ya,{mode:"agent",addon:v,agentDefault:i,agentNodeId:s.agentNodeId,engineFormat:N,onChangeAgentConfig:I=>l(I)})})]})}const J8=[{id:"assignments",label:"Assignments"},{id:"pipeline",label:"Pipeline"},{id:"settings",label:"Settings"},{id:"templates",label:"Templates"}];function e9({refreshToken:e}){const[t,n]=_("assignments"),{data:r}=Dn(void 0,{staleTime:3e4}),s=r?.find(a=>a.isHub&&a.isOnline)?.id??r?.find(a=>a.isOnline)?.id??null;return u("div",{className:"flex flex-col h-full",children:[u("div",{className:"px-6 py-4 border-b border-border",children:[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:J8.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))}),u("div",{className:"flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab",children:[t==="assignments"&&o(G8,{refreshToken:e}),t==="pipeline"&&(s?o(X8,{nodeId:s,refreshToken:e}):o("div",{className:"text-xs text-foreground-subtle",children:"No online node available — schema unreachable."})),t==="settings"&&o(Y8,{refreshToken:e}),t==="templates"&&o(Z8,{refreshToken:e})]})]})}const uo="__cluster__";function t9(){const[e,t]=Pa(),n=e.get("node")??uo,[r,s]=_(0);return Y(()=>{e.get("node")||t({node:uo},{replace:!0})},[e,t]),u("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:u("button",{type:"button",onClick:()=>s(i=>i+1),title:"Refresh",className:"inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:[o(ft,{className:"h-3.5 w-3.5"}),"Refresh"]})}),u("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden min-h-0",children:[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(w8,{selectedNodeId:n,onSelect:i=>{t({node:i},{replace:!0})},refreshToken:r})}),o("section",{className:"flex-1 min-h-0 overflow-hidden",children:n===uo?o(e9,{refreshToken:r}):o(K8,{nodeId:n,refreshToken:r})})]})]})}function n9(e){const[t,n]=_("idle"),[r,s]=_(null),a=ne(null),i=ne(null),l=ne(null),c=ne(!0),d=Sb(),f=Cb(),p=Mb(),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 f.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,f,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 r9=0;function st(){return++r9}function Fi(e){switch(e.type){case"system":return"system";case"device":return`#${e.deviceId}`;case"provider":return e.providerId;case"addon":return e.addonId}}function o9(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 s9(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 a9(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 i9({scope:e,greeting:t,className:n}){const r=Te(),[s,a]=_(()=>{const v=[];return t&&v.push({id:st(),kind:"info",text:t}),v.push({id:st(),kind:"info",text:`scope: ${Fi(e)} — type help or context for available commands`}),v}),[i,l]=_(""),[c,d]=_([]),[f,p]=_(-1),h=ne(null),m=ne(null);Y(()=>{const v=m.current;v&&(v.scrollTop=v.scrollHeight)},[s]);const g=U(()=>{h.current?.focus()},[]),b=nc({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),S=N.type==="error";a(E=>[...E,{id:st(),kind:S?"error":"result",text:k}])},onError:v=>{const N=v instanceof Error?v.message:String(v);a(k=>[...k,{id:st(),kind:"error",text:N}])}});function x(v){const N=v.trim();if(N){if(N==="clear"){a([{id:st(),kind:"info",text:`scope: ${Fi(e)}`}]),l("");return}if(N==="help"){a(k=>[...k,{id:st(),kind:"input",text:`> ${N}`},...o9(e).map(S=>({id:st(),kind:"info",text:S}))]),l("");return}if(N==="context"){a(k=>[...k,{id:st(),kind:"input",text:`> ${N}`},...a9(e).map(S=>({id:st(),kind:"info",text:S}))]),l("");return}if(N==="examples"){a(k=>[...k,{id:st(),kind:"input",text:`> ${N}`},...s9(e).map(S=>({id:st(),kind:"info",text:S}))]),l("");return}d(k=>[...k,N]),p(-1),a(k=>[...k,{id:st(),kind:"input",text:`> ${N}`}]),l(""),b.mutate(N)}}function y(v){if(v.key==="Enter"){v.preventDefault(),x(i);return}if(v.key==="ArrowUp"){if(v.preventDefault(),c.length===0)return;const N=f===-1?c.length-1:Math.max(0,f-1);p(N),l(c[N]??"");return}if(v.key==="ArrowDown"){if(v.preventDefault(),f===-1)return;const N=f+1;N>=c.length?(p(-1),l("")):(p(N),l(c[N]??""));return}v.ctrlKey&&v.key==="l"&&(v.preventDefault(),a([{id:st(),kind:"info",text:`scope: ${Fi(e)}`}]))}const w={input:"text-zinc-300",result:"text-emerald-300",error:"text-red-300",info:"text-zinc-400"};return u("div",{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${n??""}`,onClick:g,children:[u("div",{ref: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"})]}),u("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 l9(e){const t=ke(),n=e!==null&&Number.isFinite(e),r=xx({deviceId:e??0},{enabled:n,refetchInterval:5e3,retry:1}),s=yx({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),a=vx({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 c9({deviceId:e}){const{status:t,isLoading:n,isPending:r,error:s,setEnabled:a,setSettings:i}=l9(Number.isFinite(e)?e:null),[l,c]=_({targetType:"",stopDelaySeconds:30,disappearDelaySeconds:15}),[d,f]=_(!1);return Y(()=>{if(d)return;const p=t?.currentSettings;p&&c({targetType:p.targetType,stopDelaySeconds:p.stopDelaySeconds,disappearDelaySeconds:p.disappearDelaySeconds})},[t,d]),n&&!t?u("div",{className:"flex items-center gap-2 px-3 py-2 text-[10.5px] text-foreground-subtle",children:[o(Ee,{className:"h-3 w-3 animate-spin"}),"Loading autotrack…"]}):u("div",{className:"border-t border-border/40 mt-2 pt-2 px-1 space-y-2",children:[u("div",{className:"flex items-center justify-between px-2",children:[u("div",{className:"flex items-center gap-1.5 text-[10.5px] font-semibold text-foreground",children:[o(nL,{className:"h-3 w-3 text-primary"}),"Autotracking"]}),u("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&&u("div",{className:"flex items-start gap-1.5 rounded-md border border-danger/30 bg-danger/5 px-2 py-1.5 text-[10px] text-danger",children:[o(Cr,{className:"h-3 w-3 flex-shrink-0 mt-0.5"}),o("span",{className:"leading-snug break-words",children:s})]}),u("div",{className:"grid grid-cols-2 gap-2 px-2",children:[(t?.supportedTargetTypes?.length??0)>0&&u("label",{className:"col-span-2 flex flex-col gap-1",children:[o("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Target type"}),o("select",{value:l.targetType,onFocus:()=>f(!0),onChange:p=>c(h=>({...h,targetType:p.target.value})),onBlur:()=>{f(!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))})]}),u("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:()=>f(!0),onChange:p=>c(h=>({...h,stopDelaySeconds:Number(p.target.value)||0})),onBlur:()=>{f(!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"})]}),u("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:()=>f(!0),onChange:p=>c(h=>({...h,disappearDelaySeconds:Number(p.target.value)||0})),onBlur:()=>{f(!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 d9({deviceId:e,intercomAvailable:t=!1}){const n=Te(),r=typeof window<"u"?window.location.origin:"",s=Number.isFinite(e),a=l0(s?e:null),{streams:i,pipelineMetrics:l,createSession:c,sendAnswer:d,closeSession:f}=id(n.trpcClient,s?e:null),p=Ec(n.trpcClient,s?e:null),h=n9(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=uy(),y=x.length>0?o(me,{children:x.map(w=>o("div",{className:"absolute inset-0",children:w.node},w.id))}):null;return o(ed,{serverUrl:r,createSession:c,sendAnswer:d,closeSession:f,streams:i,pipelineMetrics:l,phase:a.phase,detections:a,defaultShowDetections:!0,defaultShowMotion:!0,showPlayStop:!0,snapshotSrc:p.src,snapshotLoading:p.loading,onRefreshSnapshot:p.refresh,intercomAvailable:t,intercomShown:g,onIntercomToggle:b,extraOverlay:y,chromeless:!0,className:"h-full"})}function u9({deviceId:e}){return Number.isFinite(e)?o("div",{className:"flex flex-col h-full",children:o(Yt,{deviceId:e,limit:50,maxHeight:"max-h-full",showScope:!1,showFilters:!1})}):u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function p9({deviceId:e}){if(!Number.isFinite(e))return u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]});const t=[`CamStack REPL — device #${e}`,""," device.state.battery.value sync state read"," await device.snapshot.getSnapshot({}) cap action",""," type 'examples' for more, 'context' for the full API"].join(`
|
|
1104
|
-
`);return o(i9,{scope:{type:"device",deviceId:e},greeting:t,className:"h-full border-0 rounded-none"})}function f9({deviceId:e}){const t=Te(),n=Number.isFinite(e),r=ld(t.trpcClient,n?e:0,{enabled:n}),{data:s}=k8(n?e:0);if(!n)return u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]});const a=(s?.features??[]).includes(Hn.PtzAutotrack);return u("div",{className:"flex flex-col h-full overflow-y-auto",children:[o(rd,{controls:r,mode:"panel"}),a&&o(c9,{deviceId:e})]})}function h9({deviceId:e}){return Number.isFinite(e)?o("div",{className:"flex flex-col h-full overflow-y-auto",children:o(ir,{deviceId:e,limit:50,maxHeight:"max-h-full"})}):u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function m9({deviceId:e}){return Number.isFinite(e)?o("div",{className:"flex flex-col h-full overflow-y-auto",children:o(nd,{deviceId:e,limit:50,maxHeight:"max-h-full"})}):u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function g9({parentDeviceId:e}){const{t}=Ot(),n=Je(),r=Te(),{data:s,isLoading:a,isError:i}=E0(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),f=c&&!d?t("device.accessories",{defaultValue:"Accessories"}):!c&&d?t("device.adoptedDevices",{defaultValue:"Adopted devices"}):t("device.children",{defaultValue:"Children"});return u("div",{className:"rounded-lg border border-border bg-surface p-3",children:[o("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5",children:f}),o("div",{className:"space-y-1",children:l.map(p=>o(go,{trpc:r.trpcClient,device:p,variant:"minimal",onNavigate:h=>n(`/devices/${String(h)}`)},p.id))})]})}function ji(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function b9({device:e}){const t=Je(),n=typeof e.id=="number"?e.id:null,r=String(e.type??""),s=r===at.Camera,a=r===at.Hub,i=e.features??[],{data:l}=Vc({deviceId:n??0},{enabled:n!==null&&s,refetchInterval:5e3}),c=l?.streams??{},d=Object.entries(c),f=i.includes(Hn.DoorbellButton),p=cd(f?{deviceId:n??void 0,historyLimit:10}:void 0),h=p.latest?Date.now()-p.latest.timestamp<3e4:!1;return u("div",{className:"space-y-5",children:[a&&n!==null&&o(my,{deviceId:n,onOpenChild:m=>t(`/devices/${m}`)}),s&&n!==null&&o(it,{widgetId:"pipeline-orchestrator/pipeline-quick-stats",host:"device-tab",deviceId:n}),f&&o(od,{history:p.history,latestIsFresh:h}),s&&n!==null&&o(it,{widgetId:"stream-broker/stream-broker-panel",host:"device-tab",deviceId:n}),s&&d.length>0&&u("div",{className:"@container rounded-lg border border-border bg-surface overflow-hidden",style:{containerType:"inline-size"},children:[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])=>u("div",{className:"px-4 py-2.5",children:[u("div",{className:"flex items-center gap-2 mb-2",children:[o(Kn,{className:"h-3 w-3 text-foreground-subtle"}),o("span",{className:"text-[11px] font-medium text-foreground",children:m})]}),u("div",{className:"grid grid-cols-2 @[640px]:grid-cols-4 gap-2",children:[o(us,{label:"Nominal",value:ji(g.nominalBitrateKbps??0)}),o(us,{label:"Observed",value:ji(g.observedBitrateKbps??0)}),o(us,{label:"Peak",value:ji(g.peakBitrateKbps??0)}),o(us,{label:"Packet Loss",value:`${(g.packetLossPercent??0).toFixed(2)}%`,warning:(g.packetLossPercent??0)>1})]})]},m))})]}),o(d0,{})]})}function us({label:e,value:t,warning:n}){return u("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 x9({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 S of e.sections){const E=S.tab??"general",A=k.get(E)??[];A.push(S),k.set(E,A)}return k},[e.sections]),f=new Set(c.map(k=>k.id)),p=[...c,...[...d.keys()].filter(k=>!f.has(k)).map(k=>({id:k,label:k,icon:"wrench",order:100}))],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(S=>!S.title)?[{...b[0],title:"",fields:b.flatMap(S=>S.fields)}]:b},w=o(P0,{pendingCount:n.length,onSave:()=>a(n),onDiscard:()=>i(n),saving:l});if(p.length<=1)return u("div",{className:"flex flex-col gap-3",children:[o(En,{schema:e,values:t,onChange:r,onAction:s,disabled:l}),w]});const v=new Map,N=new Map;for(const[k,S]of d){v.set(k,S.length);const E=new Set,A=B=>{for(const $ of B)if("key"in $&&typeof $.key=="string"&&E.add($.key),$.type==="group")A($.fields);else if($.type==="sub-tabs")for(const z of $.tabs)A(z.fields)};for(const B of S)A(B.fields);const I=n.filter(B=>E.has(B)).length;I>0&&N.set(k,I)}return u("div",{className:"flex flex-col gap-3",children:[o($0,{tabs:p.map(k=>({id:k.id,label:k.label})),activeId:m,onChange:g,countByTab:v,pendingByTab:N}),o(En,{schema:y,values:t,onChange:r,onAction:s,disabled:l}),w]})}function y9(e,t){return t&&t==="admin"?e:!0}function v9(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):(r.order??0)-(s.order??0)})};return e.tabs?{...n,tabs:e.tabs}:n}function L0(e){return e.type==="separator"||e.type==="info"||e.type==="button"||e.type==="widget"||e.type==="addon-action-button"}function R0(e){return e.key}function w9(e){if(!L0(e))return e.value}function O0(e){return L0(e)?null:e}function Ys(e,t){for(const n of e)if(t(n),n.type==="group")Ys(n.fields,t);else if(n.type==="sub-tabs")for(const r of n.tabs)Ys(r.fields,t)}function N9(e){if(!e)return{};const t={};for(const n of e.sections)Ys(n.fields,r=>{const s=R0(r);s!==null&&(t[s]=w9(r))});return t}function qp(e,t){if(!e)return null;let n=null;for(const r of e.sections)if(Ys(r.fields,s=>{if(n!==null||R0(s)!==t)return;const a=O0(s);a&&a.writerCapName&&a.writerAddonId&&(n={capName:a.writerCapName,addonId:a.writerAddonId})}),n!==null)break;return n}function k9(e){return{...e,fields:e.fields.map(z0)}}function z0(e){return e.type==="separator"||e.type==="info"||e.type==="button"||e.type==="object-array"?e:{...e,readonlyField:!0}}function S9(e,t){return e&&{...e,sections:e.sections.map(n=>({...n,fields:n.fields.map(r=>{const s=O0(r);return s?y9(t,s.minRole)?r:z0(r):r})}))}}function B0({deviceId:e,sectionFilter:t}){const n=ke(),{user:r}=mn(),s=r?.isAdmin===!0,a=ne(!1),{data:i,isLoading:l}=Bc({deviceId:e},{refetchInterval:()=>a.current?!1:2500,staleTime:6e4,enabled:Number.isFinite(e)}),{data:c}=Qn({deviceId:e},{staleTime:6e4,enabled:Number.isFinite(e)}),d=i?.settings??null,f=i?.live??null,p=q(()=>{if(!d&&!f)return null;const z=d?.sections??[],R=(f?.sections??[]).map(k9),M=[...z,...R],T=t?M.filter(t):M.filter(j=>j.location!=="top-tab");if(T.length===0)return null;const P=new Set;for(const j of T)P.add(j.tab??"general");const O=[...d?.tabs??[],...(f?.tabs??[]).filter(j=>!(d?.tabs??[]).some(F=>F.id===j.id))].filter(j=>P.has(j.id));return O.length>0?{tabs:O,sections:T}:{sections:T}},[d,f,t]),h=q(()=>v9(p),[p]),m=q(()=>S9(h,s),[h,s]),g=q(()=>N9(m),[m]),b=Tx(),x=jc(),y=fb({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]})}}),w={isPending:y.isPending,mutate:z=>{y.mutate({deviceId:e,changes:[...z]})}},v=U(z=>{const R=Object.entries(z).map(([M,T])=>{const P=qp(m,M);return P?{writerCapName:P.capName,writerAddonId:P.addonId,key:M,value:T}:null}).filter(M=>M!==null);R.length>0&&w.mutate(R)},[m,w]),N=U(z=>{const R=Object.entries(z).map(([M,T])=>{const P=qp(m,M);return P?{writerCapName:P.capName,writerAddonId:P.addonId,key:M,value:T}:null}).filter(M=>M!==null);R.length>0&&w.mutate(R)},[m,w]),k=D0({schema:m,serverValues:g,onImmediateSave:v,onDeferredSave:N}),{values:S,pendingKeys:E,handleChange:A,handleSave:I,handleDiscard:B}=k;if(a.current=k.editingPaused,l)return u("div",{className:"flex items-center justify-center py-12 text-foreground-subtle",children:[o(Ee,{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 $(z,R,M){if(z==="regenerate-rtsp-token"){const T=["rtspUrl:","regenerateToken:"].find(O=>R.startsWith(O));if(!T)throw new Error(`regenerate-rtsp-token: unrecognised key "${R}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);const P=R.slice(T.length);if(!P)throw new Error(`regenerate-rtsp-token: key "${R}" has no streamId after prefix`);const L=`${e}/${P}`;await b.mutateAsync({brokerId:L}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]});return}if(z==="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:M})}catch(T){return{status:"error",error:T instanceof Error?T.message:String(T)}}}if(z==="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 "${z}"`)}return o(x9,{schema:m,values:S,pendingKeys:E,onChange:A,onAction:$,onSave:I,onDiscard:B,disabled:w.isPending})}function C9({deviceId:e}){return o(B0,{deviceId:e})}const F0=6e4,Ll=60*F0,Up=24*Ll;function Ba(e){if(e==null||e<=0)return"—";const t=Date.now()-e;return t<0||t<3e4?"just now":t<Ll?`${String(Math.floor(t/F0))}m ago`:t<Up?`${String(Math.floor(t/Ll))}h ago`:`${String(Math.floor(t/Up))}d ago`}function M9(e,t=new Date){const n=new Date(e);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()}function j0({dev:e,busy:t,setBusy:n}){const r=e?.motionTrigger,s=sn(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 u("button",{type:"button",onClick:()=>{d()},disabled:t||!c,title:c?l?"Disable trigger on motion":"Enable trigger on motion":"Awaiting state…","aria-pressed":l,className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${l?"border-primary/50 bg-primary/15 text-primary":"border-border bg-surface text-foreground-subtle hover:text-foreground"}`,children:[o(zo,{className:"h-3 w-3"}),o("span",{children:a?l?"Disabling…":"Enabling…":c?l?"On motion: on":"On motion: off":"On motion: …"})]})}function H0({deviceId:e,deviceName:t,useSiren:n=!1}){const r=Te(),s=St(r.trpcClient,e),a=sn(s?.state.switch),[i,l]=_(!1),c=a?.on??!1,d=a?.lastChangedAt??null,f=a!==void 0,p=n?Bo:t0,h=async()=>{if(!(i||!f||!s?.switch)){l(!0);try{await s.switch.setState({on:!c})}finally{l(!1)}}};return u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[o("button",{type:"button",onClick:()=>{h()},disabled:i||!f||!s?.switch,title:f?c?`Turn off ${t}`:`Turn on ${t}`:"Awaiting state…","aria-pressed":c,className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all disabled:cursor-not-allowed disabled:opacity-50 ${c?"border-success bg-success/20 text-success shadow-lg shadow-success/20":"border-border bg-surface text-foreground-subtle hover:border-foreground-subtle hover:text-foreground"}`,children:o(p,{className:"h-10 w-10"})}),o(j0,{dev:s,busy:i,setBusy:l}),u("div",{className:"text-center",children:[o("div",{className:`text-sm font-semibold ${c?"text-success":"text-foreground-subtle"}`,children:f?c?"On":"Off":"Unknown"}),o("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:f?`Changed ${Ba(d)}`:"Awaiting state…"})]})]})}function E9({deviceId:e,deviceName:t}){const n=Te(),r=St(n.trpcClient,e),s=sn(r?.state.switch),a=sn(r?.state.brightness),i=s?.on??!1,l=s?.lastChangedAt??null,c=s!==void 0,d=a!==void 0,f=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 u("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(PL,{className:"h-9 w-9"})}),f?u("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(j0,{dev:r,busy:p,setBusy:h}),u("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 ${Ba(l)}`:"Awaiting state…"})]})]})}function I9({deviceId:e}){const t=Te(),n=St(t.trpcClient,e),r=sn(n?.state.motion),s=r?.detected??!1,a=r?.lastDetectedAt??null,i=r!==void 0;return u("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(lR,{className:"h-10 w-10"}):o(zo,{className:"h-10 w-10"})}),u("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 ${Ba(a)}`:"Awaiting state…"})]})]})}function A9({deviceId:e}){const t=Te(),n=St(t.trpcClient,e),r=sn(n?.state.doorbell),s=r?.lastPressedAt??null,a=r!==void 0,i=s!==null&&Date.now()-s<6e4,[l,c]=_(0),[d,f]=_(null);return Y(()=>{s===null||s===d||(f(s),M9(s)&&c(p=>p+1))},[s,d]),u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[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(Bo,{className:"h-10 w-10"})}),u("div",{className:"text-center",children:[o("div",{className:`text-sm font-semibold ${i?"text-primary":"text-foreground-subtle"}`,children:a?`Last press ${Ba(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 _9({deviceName:e,deviceType:t,provider:n,isOnline:r,features:s}){return u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border bg-surface p-6 text-center",children:[o(un,{type:n,size:"lg"}),u("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})]}),u("div",{className:"flex items-center gap-2 flex-wrap justify-center",children:[o(za,{status:r?"online":"offline"}),s.length>0&&o(Ra,{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 P9({deviceId:e}){const t=ke(),n=tb({deviceId:e},{refetchInterval:1e4,retry:!1}),r=nb({onSuccess:()=>{t.invalidateQueries({queryKey:[["deviceDiscovery","listDiscovered"]]}),t.invalidateQueries({queryKey:[["deviceDiscovery","getStatus"]]})}}),s=q(()=>$9(n.data??[]),[n.data]);return u("div",{className:"flex h-full w-full flex-col gap-3 p-3 sm:p-4",children:[u("div",{className:"flex flex-wrap items-stretch gap-2 sm:gap-3",children:[o(Hi,{label:"Discovered",value:s.total,icon:o(Mn,{className:"h-3.5 w-3.5"})}),o(Hi,{label:"Adopted",value:s.adopted,accent:"success"}),o(Hi,{label:"Available",value:s.available,accent:s.available>0?"primary":void 0}),u("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(Ee,{className:"h-3.5 w-3.5 animate-spin"}):o(ft,{className:"h-3.5 w-3.5"}),o("span",{className:"hidden sm:inline",children:"Discover"})]})]}),u("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-foreground-subtle border-t border-border-subtle pt-2",children:[o(ps,{icon:o(Kn,{className:"h-3 w-3 text-emerald-500"}),label:`${s.online} online`}),o(ps,{icon:o(Xy,{className:"h-3 w-3 text-amber-500"}),label:`${s.sleeping} sleeping`}),o(ps,{icon:o(i0,{className:"h-3 w-3 text-destructive"}),label:`${s.offline} offline`}),s.unknown>0?o(ps,{icon:o(YT,{className:"h-3 w-3 text-foreground-subtle"}),label:`${s.unknown} unknown`}):null]})]})}function $9(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 Hi({label:e,value:t,icon:n,accent:r}){return u("div",{className:`flex flex-1 basis-[140px] min-w-0 flex-col gap-1 rounded-lg border px-2 py-1.5 sm:px-3 sm:py-2 ${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:[u("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 ps({icon:e,label:t}){return u("span",{className:"inline-flex items-center gap-1",children:[e,o("span",{children:t})]})}const D9=e=>o(H0,{...e,useSiren:!0}),T9={[at.Switch]:H0,[at.Siren]:D9,[at.Light]:E9,[at.Sensor]:I9,[at.Button]:A9,[at.Hub]:P9};function L9(e){const t=T9[e.deviceType]??_9;return o(t,{...e})}function Ed(e){if(e<60)return`${Math.round(e)}s`;const t=Math.floor(e/60),n=Math.round(e%60);if(t<60)return n>0?`${t}m ${n}s`:`${t}m`;const r=Math.floor(t/60),s=t%60;return s>0?`${r}h ${s}m`:`${r}h`}function Zs(e){return new Date(e).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Xs(e){return e.toISOString().slice(0,10)}function R9(e,t){return Xs(e)===Xs(t)}function no(e){const t=new Date(e);return t.setHours(0,0,0,0),t}function O9(e){const t=new Date(e);return t.setHours(23,59,59,999),t}function At({className:e=""}){return o("div",{className:`animate-pulse rounded bg-foreground-subtle/10 ${e}`})}function Bn(){return u("div",{className:"flex items-center gap-3 px-4 py-3",children:[o(At,{className:"h-4 w-4"}),o(At,{className:"h-3 w-24"}),o(At,{className:"h-3 w-16 ml-auto"})]})}function Zr({children:e,actions:t}){return u("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 Qp({icon:e,label:t,value:n}){return u("div",{className:"flex items-center gap-2",children:[o(e,{className:"h-3.5 w-3.5 text-foreground-subtle flex-shrink-0"}),u("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 z9({segments:e,selectedDate:t}){const n=no(t).getTime(),r=1440*60*1e3,s=Array.from({length:25},(a,i)=>i);return u("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))}),u("div",{className:"relative h-6 rounded bg-background border border-border overflow-hidden",children:[e.map(a=>{const i=new Date(a.startTime).getTime()-n,l=new Date(a.endTime).getTime()-n,c=Math.max(0,i/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:`${Zs(a.startTime)} - ${Zs(a.endTime)} (${Ed(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 B9({segment:e,selected:t,onToggle:n,onPlay:r,onDownload:s,onDelete:a}){return u("div",{className:`flex items-center gap-3 px-4 py-2 border-b border-border last:border-b-0 hover:bg-background/50 transition-colors ${t?"bg-primary/5":""}`,children:[o("button",{onClick:n,className:"flex-shrink-0 text-foreground-subtle hover:text-foreground",children:t?o(o0,{className:"h-4 w-4 text-primary"}):o(jo,{className:"h-4 w-4"})}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-xs font-mono text-foreground",children:[Zs(e.startTime)," - ",Zs(e.endTime)]}),u("p",{className:"text-[10px] text-foreground-subtle",children:[Ed(e.duration),e.sizeBytes!=null&&` · ${kt(e.sizeBytes)}`]})]}),u("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(Ta,{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(Cn,{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(Ge,{className:"h-3.5 w-3.5"})})]})]})}function F9({deviceId:e}){const t=ke(),[n,r]=_(()=>no(new Date)),[s,a]=_(new Set),i=Ex({deviceId:e},{refetchInterval:5e3}),l=Sx({deviceId:e}),c=l.data?.streams[0]?.streamId??"stream0",d=Cx({deviceId:e,streamId:c,startTime:no(n).getTime(),endTime:O9(n).getTime()}),f=Mx({deviceId:e,streamId:c},{refetchInterval:3e4}),p=Ix({deviceId:e,dataCategory:"recording:main"}),h=U(()=>{t.invalidateQueries({queryKey:["recordingEngine","getPolicyStatus"]}),t.invalidateQueries({queryKey:["recordingEngine","getSegments"]}),t.invalidateQueries({queryKey:["recordingEngine","getStorageUsage"]})},[t]),m=Nx({onSuccess:h}),g={isPending:m.isPending,error:m.error,mutate:()=>{const P=l.data,L=P?{mode:P.mode,streams:P.streams,enabled:!0,preBufferSec:P.preBufferSec,postBufferSec:P.postBufferSec,scheduleRules:P.scheduleRules}:{mode:"continuous",streams:[{streamId:c,mode:"always"}],enabled:!0,preBufferSec:10,postBufferSec:5};m.mutate({deviceId:e,policy:L})}},b=kx({onSuccess:h}),x=i.data??void 0,y=l.data??void 0,w=d.data??[],v=f.data,N=p.data??void 0,k=(x?.enabled??!1)&&(x?.activeStreams??0)>0,S=g.isPending||b.isPending,E=R9(n,new Date),A=q(()=>[...w].sort((P,L)=>new Date(L.startTime).getTime()-new Date(P.startTime).getTime()),[w]),I=q(()=>w.reduce((P,L)=>P+(L.duration??0),0),[w]),B=q(()=>w.reduce((P,L)=>P+(L.sizeBytes??0),0),[w]);function $(){k?b.mutate({deviceId:e}):g.mutate()}function z(){r(P=>{const L=new Date(P);return L.setDate(L.getDate()-1),no(L)}),a(new Set)}function R(){E||(r(P=>{const L=new Date(P);return L.setDate(L.getDate()+1),no(L)}),a(new Set))}function M(P){a(L=>{const O=new Set(L);return O.has(P)?O.delete(P):O.add(P),O})}function T(){s.size===A.length?a(new Set):a(new Set(A.map(P=>P.id)))}return i.isLoading&&l.isLoading?u("div",{className:"space-y-4",children:[u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(Zr,{children:"Recording Status"}),u("div",{className:"px-4 py-4 space-y-3",children:[o(At,{className:"h-10 w-full"}),o(At,{className:"h-4 w-48"})]})]}),u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(Zr,{children:"Segments"}),u("div",{className:"divide-y divide-border",children:[o(Bn,{}),o(Bn,{}),o(Bn,{})]})]})]}):u("div",{className:"space-y-4",children:[u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(Zr,{children:"Recording Status"}),u("div",{className:"px-4 py-4 flex items-center justify-between gap-4",children:[u("div",{className:"flex items-center gap-3 min-w-0",children:[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(qy,{className:`h-5 w-5 ${k?"text-danger animate-pulse":"text-foreground-subtle"}`})}),u("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:$,disabled:S,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors flex-shrink-0 disabled:opacity-50 ${k?"bg-danger/10 text-danger hover:bg-danger/20":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:k?u(me,{children:[o(jo,{className:"h-3.5 w-3.5"}),S?"Stopping...":"Stop Recording"]}):u(me,{children:[o(Ta,{className:"h-3.5 w-3.5"}),S?"Starting...":"Start Recording"]})})]}),k&&x&&u("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-[11px] text-foreground-subtle",children:[o(io,{className:"h-3.5 w-3.5 text-primary flex-shrink-0"}),u("span",{children:[x.activeStreams," active stream",x.activeStreams!==1?"s":""," · mode: ",x.mode]})]})]}),u("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(Zr,{children:u("span",{className:"flex items-center gap-1.5",children:[o(Gt,{className:"h-3.5 w-3.5"}),"Settings"]})}),l.isLoading?u("div",{className:"px-4 py-3 space-y-2",children:[o(At,{className:"h-3 w-32"}),o(At,{className:"h-3 w-40"}),o(At,{className:"h-3 w-28"})]}):u("div",{className:"divide-y divide-border",children:[o(Xr,{label:"Stream",value:c}),o(Xr,{label:"Pre-buffer",value:y?`${y.preBufferSec}s`:"N/A"}),o(Xr,{label:"Mode",value:y?.mode??"continuous"}),o(Xr,{label:"Retention",value:N?.retentionDays!=null?`${N.retentionDays} days`:"N/A"}),N?.retentionGb!=null&&o(Xr,{label:"Max Storage",value:`${N.retentionGb} GB`})]})]}),u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(Zr,{children:u("span",{className:"flex items-center gap-1.5",children:[o(Us,{className:"h-3.5 w-3.5"}),"Storage"]})}),f.isLoading?u("div",{className:"px-4 py-3 space-y-2",children:[o(At,{className:"h-3 w-28"}),o(At,{className:"h-3 w-36"}),o(At,{className:"h-3 w-24"})]}):f.error?u("div",{className:"px-4 py-4 flex items-center gap-2 text-xs text-danger",children:[o(dt,{className:"h-4 w-4"}),"Failed to load storage info"]}):u("div",{className:"px-4 py-3 grid grid-cols-2 gap-3",children:[o(Qp,{icon:Us,label:"Total",value:v?.totalBytes!=null?kt(v.totalBytes):"N/A"}),o(Qp,{icon:io,label:"Segments",value:v?.segmentCount!=null?String(v.segmentCount):"N/A"})]})]})]}),u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"border-b border-border px-4 py-2.5 flex items-center justify-between",children:[o("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:"Segment Browser"}),u("div",{className:"flex items-center gap-2",children:[o("button",{onClick:z,className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:o(vd,{className:"h-4 w-4"})}),u("div",{className:"flex items-center gap-1.5 text-xs text-foreground font-medium",children:[o(jy,{className:"h-3.5 w-3.5 text-foreground-subtle"}),E?"Today":Xs(n)]}),o("button",{onClick:R,disabled:E,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(Et,{className:"h-4 w-4"})})]})]}),u("div",{className:"px-4 py-3 border-b border-border",children:[o(z9,{segments:w,selectedDate:n}),u("div",{className:"flex items-center gap-4 mt-2 text-[10px] text-foreground-subtle",children:[u("span",{children:[w.length," segment",w.length!==1?"s":""]}),I>0&&u("span",{children:[Ed(I)," recorded"]}),B>0&&o("span",{children:kt(B)})]})]}),A.length>0&&u("div",{className:"border-b border-border px-4 py-2 flex items-center justify-between",children:[o("button",{onClick:T,className:"text-[11px] text-foreground-subtle hover:text-foreground transition-colors",children:s.size===A.length?"Deselect All":"Select All"}),s.size>0&&u("div",{className:"flex items-center gap-2",children:[u("span",{className:"text-[10px] text-foreground-subtle",children:[s.size," selected"]}),u("button",{className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-medium bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",title:"Download selected",children:[o(Cn,{className:"h-3 w-3"}),"Download"]}),u("button",{className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-medium bg-danger/10 text-danger hover:bg-danger/20 transition-colors",title:"Delete selected",children:[o(Ge,{className:"h-3 w-3"}),"Delete"]})]})]}),d.isLoading?u("div",{className:"divide-y divide-border",children:[o(Bn,{}),o(Bn,{}),o(Bn,{}),o(Bn,{})]}):A.length===0?u("div",{className:"flex flex-col items-center justify-center py-12 text-foreground-subtle",children:[o(io,{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:E?"Recorded clips will appear here as they are created":`No recordings found for ${Xs(n)}`})]}):o("div",{className:"max-h-[400px] overflow-y-auto",children:A.map(P=>o(B9,{segment:P,selected:s.has(P.id),onToggle:()=>M(P.id),onPlay:()=>{},onDownload:()=>{},onDelete:()=>{}},P.id))})]}),i.error&&u("div",{className:"rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 flex items-center gap-2 text-xs text-danger",children:[o(dt,{className:"h-4 w-4 flex-shrink-0"}),"Failed to load recording status. Will retry automatically."]}),(g.error||b.error)&&u("div",{className:"rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 flex items-center gap-2 text-xs text-danger",children:[o(dt,{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 Xr({label:e,value:t}){return u("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 j9({deviceId:e}){const t=ke(),n=Number.isFinite(e),{data:r}=Qn({deviceId:e},{enabled:n}),s=typeof r?.type=="string"?r.type:"camera";yt(["deviceManager","getBindings"],["capability.binding-changed"]);const{data:a,isLoading:i,isError:l,error:c}=db({deviceId:e},{staleTime:3e4,enabled:n}),{data:d}=pb({deviceType:s},{staleTime:3e4,enabled:!!s}),f=ub({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 u("div",{className:"p-4 text-xs text-red-400",children:["Failed to load bindings: ",c instanceof Error?c.message:String(c)]});const p=new Map,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 u("div",{className:"flex flex-col items-center justify-center gap-2 p-8 text-foreground-subtle",children:[o(Da,{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 u("div",{className:"flex flex-col gap-3 p-1",children:[u("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:u("table",{className:"w-full border-collapse text-[11px]",children:[o("thead",{children:u("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 u("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(H9,{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(V9,{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(q9,{wrappers:b.wrappers,activeWrapperId:x,disabled:f.isPending,onPick:y=>{const w=x===y;f.mutate({deviceId:e,capName:b.capName,wrapperAddonId:y,active:!w})}})})]},b.capName)})})]})})]})}function H9({kind:e}){return e==="native"?u("span",{className:"inline-flex items-center gap-1 rounded-md border border-success/30 text-success bg-success/5 px-1.5 py-0.5 text-[10px] font-medium",children:[o(cn,{className:"h-3 w-3"}),"native"]}):e==="wrapped"?u("span",{className:"inline-flex items-center gap-1 rounded-md border border-primary/30 text-primary bg-primary/5 px-1.5 py-0.5 text-[10px] font-medium",children:[o(IL,{className:"h-3 w-3"}),"wrapped"]}):u("span",{className:"inline-flex items-center gap-1 rounded-md border border-border text-foreground-subtle/70 px-1.5 py-0.5 text-[10px] font-medium",children:[o(qL,{className:"h-3 w-3"}),"unbound"]})}function V9({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 q9({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 u("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(Mt,{className:"h-3 w-3"}):o(n0,{className:"h-3 w-3"}),s]},s)})})}function U9(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 Q9(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 K9({agents:e,currentAgent:t,onPick:n}){const[r,s]=_(!1);return u("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 G9({deviceId:e,refreshToken:t}){const n=ke(),[r,s]=_(null),[a,i]=_(null),[l,c]=_(null),[d,f]=_(null),p=Qc({deviceId:e}),h=Fr(),m=Sa({deviceId:e}),g=Jb(),b=q(()=>{const T=m.data?.agentNodeId;if(T)return T;const P=g.data?.find(L=>L.online)?.nodeId;return P||"hub"},[m.data?.agentNodeId,g.data]),x=a??b,y=Lo({nodeId:x??""},{enabled:!!x}),w=ux({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),c(null)}}),v=q(()=>y.data?ba(y.data):[],[y.data]),N=q(()=>{const T=p.data??null,P={};for(const L of h.data??[])for(const O of Object.keys(L.settings.addonDefaults)){const j=P[O]??[];j.push({agentNodeId:L.nodeId,state:Q9(T,L.nodeId,O)}),P[O]=j}return P},[p.data,h.data]),k=r?U9(y.data??null,r):null,S=x?h.data?.find(T=>T.nodeId===x)??null:null,E=r&&S?S.settings.addonDefaults[r]??null:null,A=r&&x?p.data?.stepOverridesByAgent?.[x]?.[r]??null:null,I=y.data?.selectedEngine.format??"coreml",B=T=>{i(T),c(null),f(null)},$=T=>{s(T),c(null),f(null)},z=T=>{if(!x||!r||!y.data||!h.data)return;const P=h.data.find(j=>j.nodeId===T),L=h.data.find(j=>j.nodeId===x);if(!P||!L)return;const[O]=tm({source:{nodeId:P.nodeId,engine:{format:I},defaults:P.settings.addonDefaults},target:{nodeId:L.nodeId,engine:{format:I},defaults:L.settings.addonDefaults},catalog:y.data,addonIds:[r]});if(!O){f("no mirror result");return}if(O.outcome==="skip"){f(`skipped: ${O.reason??"no candidate"}`);return}c(O.patch),f(`${O.outcome} from ${T}`)},R=()=>{!x||!r||w.mutate({deviceId:e,agentNodeId:x,addonId:r,patch:l})},M=()=>{!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:u("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(Zm,{tree:v,selectedAddonId:r,onSelect:$,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."}):u("div",{className:"space-y-4",children:[u("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})]}),u("div",{className:"flex items-end gap-3 flex-wrap",children:[u("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(T=>o("button",{type:"button",onClick:()=>B(T.nodeId),className:`px-3 py-1 text-xs ${x===T.nodeId?"bg-primary text-primary-foreground":"bg-surface hover:bg-muted"}`,children:T.nodeId},T.nodeId))})]}),o(K9,{agents:(h.data??[]).map(T=>T.nodeId),currentAgent:x,onPick:z}),d&&o("div",{className:"text-[10px] text-foreground-subtle",children:d})]}),E&&o(ya,{mode:"device",addon:k,agentDefault:E,agentNodeId:x??"",currentPatch:l??A,engineFormat:I,onChangePatch:c}),u("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:!A||w.isPending,onClick:M,children:"Clear override"}),u("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 W9=[{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 Y9(e){const t=e===at.Camera;return W9.filter(n=>t||!n.cameraOnly).map(({id:n,label:r})=>({id:n,label:r}))}const Z9=[{id:"logs",icon:nt,label:"Logs"},{id:"repl",icon:s0,label:"REPL"},{id:"events",icon:Bo,label:"Events"},{id:"state",icon:Qy,label:"State"},{id:"ptz",icon:WL,label:"PTZ",featureGate:Hn.PanTiltZoom}];function X9(){const e=pd(),t=Number(e.deviceId),n=Number.isFinite(t),r=Je(),s=ke(),a=Xe(),i=Te(),[l,c]=_("overview"),[d,f]=_("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=ne(h);g.current=h;function b(de){de.preventDefault();const ce=de.clientX,Se=de.currentTarget.previousElementSibling?.getBoundingClientRect().width??h??0,pe=280,Ie=Math.max(pe+50,Math.floor(window.innerWidth*.7)),Le=ot=>{const cr=Math.max(pe,Math.min(Ie,Se+(ot.clientX-ce)));m(cr)},Ye=()=>{document.removeEventListener("mousemove",Le),document.removeEventListener("mouseup",Ye);const ot=g.current;if(ot!==null)try{window.localStorage.setItem(p,String(Math.round(ot)))}catch{}document.body.style.userSelect="",document.body.style.cursor=""};document.body.style.userSelect="none",document.body.style.cursor="col-resize",document.addEventListener("mousemove",Le),document.addEventListener("mouseup",Ye)}const{data:x,isLoading:y,isError:w}=Qn({deviceId:t},{enabled:n,refetchInterval:5e3,retry:1}),{data:v}=Bc({deviceId:t},{enabled:n,staleTime:3e4}),N=q(()=>{const de=v?.settings?.sections??[],ce=v?.live?.sections??[],Se=[...de,...ce],pe=new Set;for(const Ie of Se)Ie.location==="top-tab"&&Ie.tab&&pe.add(Ie.tab);return[...pe].map(Ie=>{const Le=ol[Ie];return{id:Ie,label:Le?.label??Ie,isAddonContrib:!0}})},[v]),k=x,S=String(k?.name??e.deviceId??"Device"),E=k?.online===!0,A=E?"online":"offline",I=String(k?.addonId??"rtsp"),B=k?.features??[],$=k?.type,z=$===at.Camera,R=typeof k?.parentDeviceId=="number"?k.parentDeviceId:null,{data:M}=Qn({deviceId:R??0},{enabled:R!==null,staleTime:3e4}),T=or(),P=q(()=>[...Y9($),...N],[$,N]),{data:L}=E0(n?t:0),O=(L??[]).length>0,j=q(()=>Z9.filter(({featureGate:de})=>!de||B.includes(de)),[B]),{data:F}=xb({addonId:I},{enabled:!!I&&I!=="rtsp"}),H=cb({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]}),r(F?.id?`/integrations/${F.id}`:"/integrations")}}),D=ib({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),Q=lb({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),K=wx(),ee=wa({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),oe=B.includes(Hn.Rebootable),te=B.includes(Hn.BatteryOperated),Z=Mc(i.trpcClient,te&&n?t:null),[re,be]=_(!1),X=St(i.trpcClient,n?t:null),G=async()=>{if(!(re||!X)){be(!0);try{await X.snapshot?.invalidateCache({});const de=await X.snapshot?.getSnapshot({});if(!de)return;const ce=`data:${de.contentType};base64,${de.base64}`,Se=de.contentType.includes("png")?"png":"jpg",pe=S.replace(/[^a-zA-Z0-9_.-]+/g,"_"),Ie=new Date().toISOString().replace(/[:.]/g,"-"),Le=document.createElement("a");Le.href=ce,Le.download=`${pe}-${Ie}.${Se}`,document.body.appendChild(Le),Le.click(),document.body.removeChild(Le)}finally{be(!1)}}},J=D.isPending||Q.isPending,{data:ae}=Sa({deviceId:t},{enabled:n,refetchInterval:1e4}),fe=ae?.agentNodeId??null,V=typeof fe=="string"&&fe.length>0&&!fe.startsWith("addon:")?fe:void 0,{data:ie}=Kc({deviceId:t,...V?{nodeId:V}:{}},{enabled:n,refetchInterval:3e3,retry:!1});function ue(){if(!n)return null;switch(l){case"overview":return o(b9,{device:k??{}});case"config":return o(C9,{deviceId:t});case"pipeline":return o(G9,{deviceId:t,refreshToken:0});case"bindings":return o(j9,{deviceId:t});case"recording":return o(F9,{deviceId:t});default:{const de=l;return N.some(Se=>Se.id===de)?o(B0,{deviceId:t,sectionFilter:Se=>Se.location==="top-tab"&&Se.tab===de}):null}}}return n?y?u("div",{className:"flex flex-col h-full",children:[u("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?u("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"}),u("p",{className:"text-xs",children:["No device with ID ",u("code",{className:"font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]",children:["#",t]})]}),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"})]}):u("div",{className:"absolute inset-0 flex flex-col overflow-hidden",children:[u("div",{className:"border-b border-border bg-surface px-6 py-3 flex-shrink-0",children:[o("div",{className:"mb-2",children:o(vc,{items:[{label:"Integrations",onClick:()=>r("/integrations")},{label:F?.name??I,onClick:()=>F?.id&&r(`/integrations/${F.id}`)},{label:S}]})}),u("div",{className:"flex items-center gap-2 sm:gap-3",children:[o(un,{type:I,size:"lg"}),u("div",{className:"min-w-0 flex-1",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[o("h1",{className:"text-sm sm:text-base font-semibold text-foreground truncate",children:S}),o(za,{status:A}),te&&o(Ic,{status:Z,variant:"full"})]}),R!==null&&M&&u("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 ${M.name}`,children:[o("span",{children:"↑"}),o("span",{className:"truncate",children:String(M.name??`Device #${R}`)})]}),o("div",{className:"hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle",children:B.length>0&&o(Ra,{capabilities:B})})]}),ie&&o("div",{className:"hidden lg:flex",children:o(J9,{metrics:ie})}),u("div",{className:"flex items-center gap-1 shrink-0",children:[u("button",{onClick:async()=>{await a({title:`Disable "${S}"?`,message:"The device will stop processing streams and events. You can re-enable it later.",confirmLabel:"Disable",variant:"danger"})&&Q.mutate({deviceId:t})},disabled:J,title:"Disable device",className:"inline-flex items-center gap-1.5 rounded-lg px-2 sm:px-2.5 py-1.5 text-[11px] font-medium border transition-colors disabled:opacity-50 border-success/30 text-success hover:bg-success/10",children:[o(t0,{className:"h-3.5 w-3.5"}),o("span",{className:"hidden sm:inline",children:J?"Updating…":"Enabled"})]}),o("div",{className:"hidden sm:block h-5 w-px bg-border mx-1"}),o(by,{triggerClassName:"ml-1",items:[{id:"snapshot",label:"Take snapshot",description:"Fetch a fresh frame and download it.",icon:Sr,disabled:re,onClick:()=>{G()}},{id:"reboot",label:"Reboot device",description:"Camera goes offline for ~30 seconds.",icon:xt,hidden:!oe,disabled:K.isPending,danger:!0,onClick:async()=>{await a({title:`Reboot "${S}"?`,message:"The camera will go offline for around 30 seconds while the firmware reboots.",confirmLabel:"Reboot",variant:"danger"})&&K.mutate({deviceId:t})}},{id:"restart-addon",label:"Restart addon",description:`Bounces every device served by ${F?.name??I}.`,icon:ft,disabled:ee.isPending,danger:!0,onClick:async()=>{await a({title:`Restart "${F?.name??I}"?`,message:`Restarting the addon will briefly disconnect every device served by it (not just "${S}"). Streams will reconnect automatically.`,confirmLabel:"Restart",variant:"danger"})&&ee.mutate({addonId:I})}},{id:"delete",label:"Delete device",description:"Remove the device and all its settings.",icon:Ge,separatorBefore:!0,disabled:H.isPending,danger:!0,onClick:async()=>{await a({title:`Delete "${S}"?`,message:"This will remove the device and all its settings. This action cannot be undone.",confirmLabel:"Delete",variant:"danger"})&&H.mutate({deviceId:t})}}]})]})]})]}),o(Mg,{deviceId:t,device:k??void 0,children:o(dy,{children:o(yy,{children:u("main",{className:T?"flex-1 overflow-y-auto flex flex-col":"flex-1 min-h-0 overflow-hidden flex flex-row",children:[u("div",{className:T?"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:!T&&h!==null?{width:`${String(h)}px`}:void 0,children:[o("div",{className:`flex-shrink-0 border-b border-border-subtle ${z?"aspect-video bg-black":"bg-surface"}`,children:z?o(d9,{deviceId:t,intercomAvailable:B.includes(Hn.TwoWayAudio)}):o(L9,{deviceId:t,deviceName:S,deviceType:$??"unknown",provider:I,isOnline:E,features:B})}),u("div",{className:T?"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:j.map(({id:de,label:ce,icon:Se})=>u("button",{onClick:()=>f(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(Se,{className:"h-3 w-3"}),ce]},de))})}),u("div",{className:T?"h-72 overflow-hidden":"flex-1 min-h-0 overflow-hidden",children:[d==="logs"&&o(u9,{deviceId:t}),d==="repl"&&o(p9,{deviceId:t}),d==="events"&&o(h9,{deviceId:t}),d==="state"&&o(m9,{deviceId:t}),d==="ptz"&&o(f9,{deviceId:t})]})]})]}),!T&&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"})}),u("div",{className:T?"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:P.map(de=>{const ce=l===de.id;return u("button",{onClick:()=>c(de.id),className:`relative flex-shrink-0 px-3 py-2 text-xs font-medium transition-colors ${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)})})}),u("div",{className:T?"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"&&O&&o(g9,{parentDeviceId:t}),ue()]})]})]})})})})]}):u("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"}),u("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 J9({metrics:e}){const t=e.phase??"idle",n=tr(t);return u("div",{className:"flex items-center gap-3 flex-shrink-0",children:[u("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"}),u("div",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle",children:[o(zo,{className:"h-3 w-3"}),o("span",{className:"text-foreground tabular-nums",children:(e.actualFps??0).toFixed(1)}),o("span",{children:"fps"})]}),u("div",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle",children:[o(pt,{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&&u("span",{className:"text-[10px] text-warning tabular-nums",children:["q:",e.queueDepth]})]})}function e7({packageName:e,currentVersion:t,installSource:n,onInstall:r,onClose:s}){const a=n==="upload"||n==="local",{data:i,isLoading:l}=$g({name:e},{staleTime:5*6e4});return u("div",{className:"fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden",style:{top:"auto",bottom:"auto"},ref:c=>{if(!c)return;const d=c.parentElement?.getBoundingClientRect();if(!d)return;const f=window.innerHeight-d.bottom,p=d.top;f<280&&p>f?(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:[u("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(Be,{className:"h-3 w-3"})})]}),a&&u("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]",children:[o(La,{className:"h-3 w-3 mt-0.5 text-cyan-500 shrink-0"}),u("div",{className:"text-cyan-700 dark:text-cyan-200",children:[u("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&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle",children:[o(Ee,{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,f=/-(alpha|beta|rc|dev|canary|next)/i.test(c.version);return u("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":f?"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(Mt,{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(Cn,{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"})]})}function t7({isBundle:e,installSource:t}){return u("div",{className:"relative flex-shrink-0",children:[o("div",{className:`h-9 w-9 rounded-lg flex items-center justify-center ${e?"bg-indigo-500/20 text-indigo-700 dark:text-indigo-300":"bg-purple-500/20 text-purple-700 dark:text-purple-300"}`,children:e?o(Jy,{className:"h-4 w-4"}):o(Qs,{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(La,{className:"h-2.5 w-2.5 text-white"})})]})}function n7({addonId:e}){const t=ke(),{data:n="inherit"}=Lg({addonId:e},{staleTime:3e4}),r=Rg({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 Rl({addon:e,agents:t=[],clusterStatus:n,hideVersion:r,availableUpdate:s,onUpdate:a,isUpdating:i,bundle:l}){const[c,d]=_(!1),[f,p]=_(!1),[h,m]=_(!1),[g,b]=_(!1),[x,y]=_(!1),[w,v]=_("logs"),N=ke(),k=Xe(),{manifest:S}=e,E=e.installedOn??[],A=!l&&!S.protected&&S.removable!==!1,I=!!l,B=l?.displayName??S.name,$=l?.packageName??S.packageName,z=l?.version??S.packageVersion??S.version,R=l?.installSource??e.installSource,M=l?l.bundle?.description??l.addons[0]?.manifest.description:S.description;!l&&(S.components&&S.components.length>0||t.length>=2);const T=Eg({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["addonPages"]]}),N.invalidateQueries({queryKey:[["capabilities"]]})}}),P=wa({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]})}}),L=Dc({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["addonPages"]]}),N.invalidateQueries({queryKey:[["capabilities"]]}),N.invalidateQueries({queryKey:[["integrations"]]})}}),O=Dg({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["alerts"]]})}}),j=e.health,F=j?.phase==="failed"&&!j.inGracePeriod,H=F&&j?.nextRetryAt&&!j.retrying;return u("div",{className:`rounded-lg border bg-surface overflow-hidden ${F?"border-red-500/50":"border-border"}`,children:[F&&j&&u("div",{className:"bg-danger/10 border-b border-danger/30 px-4 py-2.5 flex items-start gap-2.5",children:[o(XL,{className:"h-4 w-4 text-danger shrink-0 mt-0.5"}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"text-xs font-semibold text-danger",children:["Failed to load (attempt #",j.retryCount,")"]}),o("div",{className:"text-[11px] text-foreground mt-0.5 break-words font-mono",children:j.lastError?.message??"Unknown error"}),H&&j.nextRetryAt&&u("div",{className:"text-[10px] text-foreground-subtle mt-1",children:["Auto-retry at ",new Date(j.nextRetryAt).toLocaleTimeString()]})]}),u("button",{type:"button",disabled:O.isPending||j.retrying,onClick:D=>{D.stopPropagation(),O.mutate({packageName:$})},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(ft,{className:`h-3 w-3 ${O.isPending||j.retrying?"animate-spin":""}`}),"Retry now"]})]}),u("div",{className:"flex items-start gap-3 px-4 py-3",children:[o(t7,{isBundle:I||!!S.components&&S.components.length>1,installSource:R}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-sm font-semibold text-foreground truncate",children:B}),u("span",{className:"text-[10px] text-foreground-subtle font-mono shrink-0",children:["(",$,")"]}),I&&u("span",{className:"text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1",children:[o(Jy,{className:"h-3 w-3"}),l.addons.length]})]}),M&&o("p",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-1",children:M}),!I&&e.process&&u("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&&u("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&&u("div",{className:"relative inline-flex items-center gap-1.5 shrink-0 pt-0.5",children:[i?u("span",{className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400",children:[o(Ee,{className:"h-3 w-3 animate-spin"}),"Updating to ",s,"…"]}):s&&a?u("button",{type:"button",onClick:D=>{D.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(Cn,{className:"h-3 w-3"}),s]}):null,u("button",{type:"button",onClick:D=>{D.stopPropagation(),m(Q=>!Q)},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 ${z} — newer ${s} available`:"View all versions",children:[z,o(wt,{className:"h-3 w-3 opacity-50"})]}),h&&o(e7,{packageName:$,currentVersion:z,...R?{installSource:R}:{},onInstall:D=>{m(!1),L.mutate({packageName:$,version:D})},onClose:()=>m(!1)})]})]}),!I&&u("div",{className:"flex items-center gap-1 px-4 py-1.5 border-t border-border/50 bg-surface-hover/20",children:[u("button",{type:"button",onClick:D=>{D.stopPropagation(),P.mutate({addonId:S.id})},disabled:P.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(ft,{className:`h-3 w-3 ${P.isPending?"animate-spin":""}`}),"Restart"]}),u("button",{type:"button",onClick:D=>{D.stopPropagation(),b(Q=>!Q)},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(nt,{className:"h-3 w-3"}),"Logs"]}),!I&&u("button",{type:"button",onClick:D=>{D.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(Gt,{className:"h-3 w-3"}),"Settings"]}),o("div",{className:"flex-1"}),A&&u("button",{type:"button",onClick:async D=>{D.stopPropagation(),await k({title:`Uninstall ${S.name}?`,message:"This will remove the addon package and all its data. This action cannot be undone.",confirmLabel:"Uninstall",variant:"danger"})&&T.mutate({packageName:S.packageName})},disabled:T.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(Ge,{className:"h-3 w-3"}),T.isPending?"Removing...":"Uninstall"]})]}),n&&n.nodes.length>1&&!I&&u("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(D=>u("div",{className:"flex items-center gap-2 text-[10px]",children:[o("div",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${D.status==="offline"?"bg-muted-foreground/30":D.synced?"bg-success":"bg-amber-500"}`}),o("span",{className:"font-medium text-foreground min-w-[60px]",children:D.name}),o("span",{className:"font-mono text-foreground-subtle",children:D.version}),!D.synced&&D.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"}),D.status==="offline"&&o("span",{className:"text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground",children:"offline"}),D.synced&&D.status!=="offline"&&o("span",{className:"text-[9px] text-success",children:"synced"})]},D.nodeId))})]}),g&&!I&&u("div",{className:"border-t border-border",children:[u("div",{className:"flex items-center px-4 py-1 bg-surface-hover/20 border-b border-border/50",children:[u("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:[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:D=>{D.stopPropagation(),b(!1)},className:"text-foreground-subtle hover:text-foreground",children:o(Be,{className:"h-3.5 w-3.5"})})]}),w==="logs"&&o(Yt,{addonId:S.id,maxHeight:"max-h-64",showFilters:!1}),w==="events"&&o(ir,{addonId:S.id,category:"addon.*",maxHeight:"max-h-64"})]}),I&&u(me,{children:[o("button",{type:"button",onClick:()=>d(D=>!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(qT,{className:"h-3.5 w-3.5 text-foreground-subtle"}):o(wt,{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(D=>o(Rl,{addon:D,agents:t,hideVersion:!0},D.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:u("div",{className:"w-full max-w-lg max-h-[80vh] rounded-xl border border-border bg-surface shadow-2xl flex flex-col overflow-hidden",onClick:D=>D.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border flex-shrink-0",children:[u("div",{className:"flex items-center gap-2",children:[o(Gt,{className:"h-4 w-4 text-primary"}),u("h2",{className:"text-sm font-semibold text-foreground",children:[B," Settings"]})]}),o("button",{onClick:()=>y(!1),className:"text-foreground-subtle hover:text-foreground transition-colors p-1 rounded",children:o(Be,{className:"h-4 w-4"})})]}),u("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[o(Ur,{nodeId:"hub",addonIds:[S.id],level:"global"}),R==="npm"&&u("div",{children:[o("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:"Auto-Update"}),o(n7,{addonId:S.id})]}),S.components&&S.components.length>0&&u("div",{children:[u("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Components (",S.components.length,")"]}),o("div",{className:"flex flex-wrap gap-1",children:S.components.map(D=>o("span",{className:"text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono",children:D},D))})]}),t.length>=2&&u("div",{children:[o("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:"Installed on"}),u("div",{className:"flex items-center gap-1.5 flex-wrap",children:[E.length===0&&o("span",{className:"text-[10px] text-foreground-subtle",children:"Hub (local)"}),E.map(D=>o("span",{className:"rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle",children:D},D)),u("div",{className:"relative",children:[u("button",{type:"button",onClick:D=>{D.stopPropagation(),p(Q=>!Q)},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(Nt,{className:"h-3 w-3"}),"Add agent"]}),f&&u("div",{className:"absolute left-0 top-full mt-1 z-10 min-w-[160px] rounded-md border border-border bg-surface shadow-lg overflow-hidden",children:[t.filter(D=>!D.isHub&&!E.includes(D.name)).map(D=>o("button",{type:"button",onClick:Q=>{Q.stopPropagation(),p(!1)},className:"w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors",children:D.name},D.id)),t.filter(D=>!D.isHub&&!E.includes(D.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 r7=".tgz,.tar.gz,.zip";function o7({onUploadSuccess:e}){const[t,n]=_(!1),r=ne(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 u(me,{children:[o("input",{ref:r,type:"file",accept:r7,onChange:a,className:"hidden"}),u("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(Ee,{className:"w-3.5 h-3.5 animate-spin"}):o(La,{className:"w-3.5 h-3.5"}),t?"Uploading...":"Upload"]})]})}function s7(e,t){const n=e??"hub-only";return n==="any-node"?!0:n==="hub-only"?t:!t}function a7(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;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...s?{process:s}:{},hasBackup:t.hasBackup,...a?{health:a}:{}}}function i7(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 Jt(e){return"bundle"in e}function l7({addons:e,clusterStatus:t,selectedNode:n,onRefresh:r,isRefreshing:s}){const a=ke(),[i,l]=_(""),c=cN(i),[d,f]=_(!1),p=ne(null);Y(()=>{if(!d)return;const D=Q=>{p.current&&!p.current.contains(Q.target)&&f(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[d]);const{data:h}=Tc(void 0,{staleTime:5*6e4}),m=q(()=>{const D=new Map;for(const Q of h??[])D.set(Q.name,Q.latestVersion);return D},[h]),[g,b]=_(null),[x,y]=_(null),w=xl({onMutate:D=>{b(D.name),y(null)},onSuccess:(D,Q)=>{b(null);const K=D;if(K&&K.success===!1){y({name:Q.name,message:K.error??"Update failed (no error message returned by server)"});return}a.invalidateQueries({queryKey:[["addons"]]}),a.invalidateQueries({queryKey:[["addons","listUpdates"]]})},onError:(D,Q)=>{b(null),y({name:Q.name,message:D instanceof Error?D.message:String(D)})}}),{data:v}=Tg(void 0,{staleTime:3e4}),N=Og({onSuccess:()=>{a.invalidateQueries({queryKey:[["addons","getAutoUpdateSettings"]]})}}),{data:k,isFetching:S}=Ag({query:c||void 0},{enabled:d,staleTime:6e4}),E=xl(),A=async()=>{const D=h??[];for(const Q of D)await E.mutateAsync({name:Q.name,version:Q.latestVersion});a.invalidateQueries({queryKey:[["addons"]]})},I=Dc({onSuccess:()=>{a.invalidateQueries({queryKey:[["addons"]]}),a.invalidateQueries({queryKey:[["addonPages"]]}),a.invalidateQueries({queryKey:[["capabilities"]]}),a.invalidateQueries({queryKey:[["integrations"]]})}}),[B,$]=_("type"),[z,R]=_(()=>typeof window>"u"?"grouped":window.localStorage.getItem("camstack.addons.viewMode")==="flat"?"flat":"grouped"),M=D=>{R(D),typeof window<"u"&&window.localStorage.setItem("camstack.addons.viewMode",D)},[T,P]=Pa(),L=T.get("capability"),O=q(()=>{let D=n.isHub?e:e.filter(Q=>{const K=Q.manifest.execution;return s7(K?.placement,n.isHub)});return L&&(D=D.filter(Q=>(Q.manifest.capabilities??[]).some(ee=>(typeof ee=="string"?ee:ee.name)===L))),D},[e,n.isHub,L]),j=()=>{const D=new URLSearchParams(T);D.delete("capability"),P(D,{replace:!0})},F=z==="flat"?O:i7(O),H=q(()=>{const D=[...F];switch(B){case"type":D.sort((Q,K)=>{const ee=Jt(Q)?0:1,oe=Jt(K)?0:1;if(ee!==oe)return ee-oe;const te=Jt(Q)?Q.bundle.displayName:Q.manifest.name,Z=Jt(K)?K.bundle.displayName:K.manifest.name;return te.localeCompare(Z)});break;case"name":D.sort((Q,K)=>{const ee=Jt(Q)?Q.bundle.displayName:Q.manifest.name,oe=Jt(K)?K.bundle.displayName:K.manifest.name;return ee.localeCompare(oe)});break;case"source":D.sort((Q,K)=>{const ee=Jt(Q)?Q.bundle.installSource??"":Q.installSource??"",oe=Jt(K)?K.bundle.installSource??"":K.installSource??"";return ee.localeCompare(oe)});break}return D},[F,B]);return u("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:u("div",{className:"flex items-start justify-between gap-3",children:[u("div",{className:"space-y-0.5",children:[u("div",{className:"font-medium text-danger",children:["Failed to update ",x.name]}),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"})]})}),u("div",{className:"flex items-center gap-2 flex-wrap",children:[u("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"text-[10px] text-foreground-subtle",children:"Sort:"}),u("select",{value:B,onChange:D=>$(D.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"})]})]}),u("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(D=>o("button",{type:"button",onClick:()=>M(D),className:`px-2.5 py-1.5 transition-colors capitalize ${z===D?"bg-primary/10 text-primary":"bg-transparent text-foreground-subtle hover:bg-surface-hover"}`,title:D==="grouped"?"Group multi-addon packages into a bundle card":"Show every addon as its own card",children:D},D))})]}),u("div",{className:"flex items-center gap-1.5",children:[o(ft,{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(D=>o("button",{type:"button",onClick:()=>N.mutate({channel:D}),disabled:N.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${v?.channel===D?D==="off"?"bg-gray-700 text-gray-200":D==="latest"?"bg-blue-500/20 text-blue-400":"bg-amber-500/20 text-amber-400":"bg-transparent text-foreground-subtle hover:bg-surface-hover"} ${D!=="off"?"border-l border-border":""}`,children:D},D))})]}),(h?.length??0)>0&&u("button",{type:"button",onClick:()=>void A(),disabled:E.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(Cn,{className:`w-3 h-3 ${E.isPending?"animate-bounce":""}`}),"Update All (",h.length,")"]}),u("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(ft,{className:`w-3 h-3 ${s?"animate-spin":""}`}),"Refresh"]})]}),u("div",{className:"flex items-center gap-3",children:[u("div",{className:"relative flex-1 min-w-[200px]",ref:p,children:[o(r0,{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:D=>{l(D.target.value),f(!0)},onFocus:()=>f(!0),placeholder:"Search addons on npm...",className:"w-full rounded-lg border border-border bg-background pl-9 pr-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"}),S&&o(Ee,{className:"absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin"}),d&&k&&k.length>0&&u("div",{className:"absolute left-0 right-0 top-full mt-1 z-40 rounded-lg border border-border bg-surface shadow-xl overflow-hidden",children:[k.length>0&&u("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border",children:["npm results (",k.length,")"]}),k&&k.length>0&&o("div",{className:"max-h-72 overflow-auto divide-y divide-border",children:k.map(D=>u("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:D.name.replace("@camstack/addon-","").charAt(0).toUpperCase()}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-[11px] font-semibold truncate",children:D.name}),u("span",{className:"text-[10px] text-foreground-subtle",children:["v",D.version]})]}),D.description&&o("div",{className:"text-[10px] text-foreground-subtle truncate",children:D.description})]}),D.installed?u("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md border border-emerald-500/30 bg-emerald-500/10 text-emerald-400 shrink-0",children:[o(Mt,{className:"h-3 w-3"}),D.installedVersion??"Installed"]}):u("button",{type:"button",onClick:()=>I.mutate({packageName:D.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(Ee,{className:"h-3 w-3 animate-spin"}):o(Cn,{className:"h-3 w-3"}),"Install"]})]},D.name))})]})]}),o(o7,{onUploadSuccess:()=>{a.invalidateQueries({queryKey:[["addons"]]}),r()}})]}),L&&u("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:L}),o("button",{type:"button",onClick:j,className:"ml-auto text-xs text-foreground-subtle hover:text-foreground underline",children:"Clear"})]}),O.length===0&&o("div",{className:"text-xs text-foreground-subtle",children:e.length===0?"No addons installed":L?`No installed addons declare the "${L}" 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:H.map(D=>{if(Jt(D)){const ee=D.bundle.packageName,oe=m.get(ee);return o(Rl,{addon:D.representative,clusterStatus:t?.[D.representative.manifest.id],bundle:D.bundle,availableUpdate:oe,isUpdating:g===ee,onUpdate:oe?()=>w.mutate({name:ee,version:oe}):void 0},ee)}const Q=D.manifest.packageName,K=m.get(Q);return o(Rl,{addon:D,clusterStatus:t?.[D.manifest.id],availableUpdate:K,isUpdating:g===Q,onUpdate:K?()=>w.mutate({name:D.manifest.packageName,version:K}):void 0},D.manifest.id)})})]})}function c7(){const e=ke(),{data:t,isLoading:n,isError:r}=va(),{data:s}=jb(void 0,{staleTime:15e3}),{data:a}=Dn(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],f=_g(),p=Ig(),h=f.isPending||p.isPending,m=async()=>{await f.mutateAsync(),await p.mutateAsync(),e.invalidateQueries({queryKey:[["addons"]]})},g=ne(f);g.current=f,Y(()=>{g.current.mutate()},[]);const b=(t??[]).map(a7).filter(x=>x!==null);return u(rt,{children:[u("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[o(eg,{selectedNodeId:l,onSelect:c}),u("div",{className:"flex items-center gap-3 flex-wrap",children:[!n&&!r&&u("span",{className:"text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium",children:[b.length," installed"]}),u("button",{type:"button",onClick:()=>void 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(ft,{className:`w-3 h-3 ${h?"animate-spin":""}`}),"Check for updates"]})]})]}),!d.isHub&&u("div",{className:"rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle",children:["Showing only addons compatible with"," ",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"}),!n&&!r&&o(l7,{addons:b,clusterStatus:s,selectedNode:d,onRefresh:()=>void m(),isRefreshing:h})]})}const d7={view:{icon:Fo,cls:"bg-foreground-subtle/15 text-foreground-subtle"},create:{icon:qr,cls:"bg-primary/15 text-primary"},delete:{icon:Ge,cls:"bg-danger/15 text-danger"}};function u7(){const{user:e,logout:t}=mn();if(!e)return o(rt,{children:o("div",{className:"text-xs text-foreground-subtle",children:"Not signed in."})});const n=e.isAdmin,r=e.scopes??[];return u(rt,{children:[u("div",{className:"text-xs text-foreground-subtle",children:["Signed in as ",o("span",{className:"font-medium text-foreground",children:e.username}),n?" (admin)":""]}),n&&u("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(kn,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),u("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."})]})]}),r.length===0&&!n&&u("div",{className:"rounded-lg border border-warning/30 bg-warning/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5",children:[o(kn,{className:"h-4 w-4 text-warning mt-0.5 shrink-0"}),u("div",{children:[o("div",{className:"font-semibold text-foreground",children:"No scopes granted"}),u("p",{className:"text-foreground-subtle mt-0.5",children:["Your account doesn't have any capability or addon grants yet. Every protected endpoint will return 403 until an admin assigns you scopes from ",o("span",{className:"font-mono",children:"/system/users"}),"."]})]})]}),r.length>0&&u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("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)=>u("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}=d7[i];return u("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))})]}),u("div",{className:"rounded-lg border border-border bg-surface px-4 py-3 text-xs text-foreground-subtle flex items-start gap-2.5",children:[o(kn,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),u("div",{className:"flex-1",children:[o("div",{className:"font-semibold text-foreground",children:"Updating access"}),u("p",{className:"mt-0.5",children:["Scopes are baked into your session token at login. Changes an admin makes via ",o("span",{className:"font-mono",children:"setUserScopes"})," take effect on your"," ",o("span",{className:"font-medium text-foreground",children:"next login"}),". Sign out and back in to refresh."]})]}),u("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 shrink-0",children:[o(Nd,{className:"h-3 w-3"}),"Sign out"]})]})]})}function p7(){return o(rt,{children:o("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:o(Yt,{limit:500,maxHeight:"max-h-[calc(100vh-250px)]",showScope:!0,showFilters:!0})})})}function Id({tabs:e,defaultTab:t}){const[n,r]=Pa(),s=n.get("tab"),a=t??e[0]?.id??"",i=e.some(d=>d.id===s)?s:a,l=e.find(d=>d.id===i)??e[0],c=d=>{const f=new URLSearchParams(n);f.set("tab",d),r(f,{replace:!0})};return u("div",{className:"space-y-3",children:[o("div",{className:"flex border-b border-border",children:e.map(d=>{const f=d.icon,p=d.id===i;return u("button",{onClick:()=>c(d.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium border-b-2 transition-colors ${p?"border-primary text-primary":"border-transparent text-foreground-subtle hover:text-foreground"}`,children:[f&&o(f,{className:"h-3.5 w-3.5"}),d.label]},d.id)})}),o("div",{children:l?.content})]})}function f7({value:e,size:t=192}){const[n,r]=_(null),[s,a]=_(null);if(Y(()=>{let d=!1;return NN(()=>import("./browser-BXdiCFWD.js").then(f=>f.b),[]).then(async f=>{if(d)return;const p=f.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 f=0;f<i;f++)n.modules.data[d*i+f]&&c.push(o("rect",{x:f*l,y:d*l,width:l,height:l,fill:"currentColor"},`${f}-${d}`));return u("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]})}function h7({userId:e,username:t,onClose:n}){const r=ke(),s=Xe(),a=Zx({userId:e}),i=a.data,[l,c]=_(null),[d,f]=_(""),[p,h]=_(null),[m,g]=_(!1),b=()=>r.invalidateQueries({queryKey:[["userManagement","getTotpStatus"]]}),x=Gx({onSuccess:A=>{c({secret:A.secret,otpauthUrl:A.otpauthUrl}),h(null),f(""),b()}}),y=Wx({onSuccess:()=>{c(null),f(""),h(null),b()},onError:A=>{h(A instanceof Error?A.message:"Confirmation failed — code did not match")}}),w=Yx({onSuccess:b}),v=q(()=>a.isLoading?"loading":l?"setup_in_progress":i?.enabled?"enrolled":i&&i.confirmedAt===null&&x.isSuccess?"setup_in_progress":"not_enrolled",[a.isLoading,i,l,x.isSuccess]);Y(()=>{if(!m)return;const A=setTimeout(()=>g(!1),1500);return()=>clearTimeout(A)},[m]);const N=()=>{c(null),x.mutate({userId:e})},k=()=>{h(null),y.mutate({userId:e,code:d.trim()})},S=async()=>{await s({title:"Disable TOTP",message:`Disable two-factor authentication for "${t}"? They'll be able to log in with just their password until a new TOTP enrollment is completed.`,confirmLabel:"Disable",variant:"danger"})&&w.mutate({userId:e})},E=()=>{l&&navigator.clipboard.writeText(l.secret).then(()=>g(!0))};return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm p-4",children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl overflow-hidden",children:[u("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[u("div",{className:"flex items-center gap-2",children:[o(Mr,{className:"h-4 w-4 text-primary"}),u("div",{children:[o("div",{className:"text-sm font-medium text-foreground",children:"Two-factor authentication"}),u("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(Be,{className:"h-4 w-4"})})]}),u("div",{className:"p-4 space-y-4",children:[v==="loading"&&u("div",{className:"flex items-center gap-2 text-xs text-foreground-subtle",children:[o(Ee,{className:"h-3.5 w-3.5 animate-spin"}),"Checking status…"]}),v==="not_enrolled"&&u(me,{children:[u("div",{className:"space-y-2",children:[o("div",{className:"text-xs text-foreground",children:"TOTP is not enrolled for this user. Click below to generate a fresh secret + QR code."}),u("ul",{className:"text-[11px] text-foreground-subtle pl-4 list-disc space-y-1",children:[o("li",{children:"Compatible with Google Authenticator, Aegis, 1Password, Bitwarden, etc."}),o("li",{children:"The secret is shown ONCE — copy it to a secure place if you can't scan the QR."}),o("li",{children:"Enrollment isn't active until the user submits a valid 6-digit code below."})]})]}),x.isError&&u("div",{className:"rounded border border-danger/40 bg-danger/5 px-3 py-2 flex items-start gap-2 text-[11px] text-danger",children:[o(Cr,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),x.error instanceof Error?x.error.message:"Setup failed"]}),o("div",{className:"flex justify-end",children:u(Ve,{onClick:N,disabled:x.isPending,children:[x.isPending?o(Ee,{className:"h-3 w-3 animate-spin"}):o(Mr,{className:"h-3 w-3"}),"Enable TOTP"]})})]}),v==="setup_in_progress"&&l&&u(me,{children:[u("div",{className:"flex flex-col items-center gap-3",children:[o("div",{className:"rounded-lg border border-border bg-white p-3",children:o(f7,{value:l.otpauthUrl,size:180})}),u("div",{className:"w-full",children:[o("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle mb-1",children:"Secret (manual entry)"}),u("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:l.secret}),u("button",{onClick:E,className:"inline-flex items-center gap-1 text-[10px] text-foreground-subtle hover:text-foreground",children:[m?o(ki,{className:"h-3 w-3 text-emerald-500"}):o(Uy,{className:"h-3 w-3"}),m?"Copied":"Copy"]})]})]})]}),u("div",{className:"space-y-1.5",children:[o("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Enter the 6-digit code from the authenticator app"}),o("input",{type:"text",inputMode:"numeric",autoComplete:"one-time-code",placeholder:"123456",value:d,onChange:A=>f(A.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"}),p&&u("div",{className:"rounded border border-danger/40 bg-danger/5 px-2 py-1.5 flex items-start gap-1.5 text-[11px] text-danger",children:[o(Cr,{className:"h-3 w-3 mt-0.5 shrink-0"}),p]})]}),u("div",{className:"flex justify-end gap-2",children:[o("button",{onClick:()=>c(null),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),u(Ve,{onClick:k,disabled:y.isPending||d.length!==6,variant:"primary",children:[y.isPending?o(Ee,{className:"h-3 w-3 animate-spin"}):o(ki,{className:"h-3 w-3"}),"Confirm"]})]})]}),v==="enrolled"&&i&&u(me,{children:[u("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(ki,{className:"h-4 w-4 mt-0.5 text-emerald-500 shrink-0"}),u("div",{className:"text-xs text-foreground space-y-0.5",children:[o("div",{className:"font-medium",children:"TOTP is active"}),u("div",{className:"text-foreground-subtle",children:["Enrolled on ",i.confirmedAt?new Date(i.confirmedAt).toLocaleString():"—"]})]})]}),o("div",{className:"text-[11px] text-foreground-subtle",children:"The user must enter a code from their authenticator app at every login. Disabling here removes the secret from the server; the user keeps their app entry until they remove it manually."}),u("div",{className:"flex justify-end gap-2",children:[o(Ve,{onClick:n,variant:"secondary",children:"Close"}),u("button",{onClick:S,disabled:w.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:[w.isPending?o(Ee,{className:"h-3 w-3 animate-spin"}):o(Be,{className:"h-3 w-3"}),"Disable TOTP"]})]})]})]})]})})}function m7(){const e=ke(),[t,n]=_(!1),[r,s]=_(""),[a,i]=_(""),[l,c]=_(!1),[d,f]=_(null),{data:p,isLoading:h,isError:m}=Wc(),g=Xe(),b=()=>e.invalidateQueries({queryKey:[["userManagement","listUsers"]]}),x=Bx({onSuccess:()=>{b(),n(!1),s(""),i(""),c(!1),f(null)},onError:M=>{f(M instanceof Error?M.message:"Failed to create user")}}),y=jx({onSuccess:b}),w=Fx({onSuccess:b}),v=Yc({onSuccess:b}),N=Hx({onSuccess:()=>{b(),S(null)}}),[k,S]=_(null),[E,A]=_(null),I=p??[];async function B(M){await g({title:"Delete user",message:`Permanently delete user "${M.username}"? This cannot be undone — any active sessions will be revoked on next request.`,confirmLabel:"Delete",variant:"danger"})&&y.mutate({id:M.id})}async function $(M){const T=window.prompt(`New password for "${M.username}":`);if(!T)return;if(T.length<8){window.alert("Password must be at least 8 characters.");return}await g({title:"Reset password",message:`Reset the password for "${M.username}"? They will need to use the new password on their next login.`,confirmLabel:"Reset"})&&v.mutate({id:M.id,newPassword:T})}function z(M,T){T!==M.isAdmin&&w.mutate({id:M.id,isAdmin:T})}function R(M){return M?new Date(typeof M=="number"?M:String(M)).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}):"—"}return u(rt,{children:[o("div",{className:"flex items-center justify-end",children:u("button",{onClick:()=>n(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm hover:bg-primary/90",children:[o(Nt,{className:"h-3.5 w-3.5"}),"Create User"]})}),t&&u("div",{className:"rounded-lg border border-border bg-surface p-4 space-y-3",children:[u("div",{className:"flex items-center justify-between",children:[o("span",{className:"text-xs font-medium text-foreground",children:"New User"}),o("button",{onClick:()=>n(!1),className:"text-foreground-subtle hover:text-foreground",children:o(Be,{className:"h-4 w-4"})})]}),u("div",{className:"grid grid-cols-3 gap-3",children:[u("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Username"}),o("input",{type:"text",value:r,onChange:M=>s(M.target.value),placeholder:"john",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),u("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Password"}),o("input",{type:"password",value:a,onChange:M=>i(M.target.value),placeholder:"••••••••",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),u("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Admin"}),u("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:l,onChange:M=>c(M.target.checked),className:"rounded border-border focus:ring-primary"}),o("span",{className:"text-foreground-subtle",children:"Unrestricted access"})]})]})]}),d&&o("p",{className:"text-[10px] text-danger",children:d}),u("div",{className:"flex justify-end gap-2",children:[o("button",{onClick:()=>n(!1),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),o("button",{onClick:()=>x.mutate({username:r,password:a,isAdmin:l}),disabled:x.isPending||!r||!a,className:"rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:x.isPending?"Creating...":"Create"})]})]}),h&&o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading..."}),m&&o("div",{className:"text-xs text-danger",children:"Failed to load"}),!h&&!m&&I.length===0&&o("div",{className:"text-xs text-foreground-subtle",children:"No data"}),(()=>{const M=P=>y.isPending&&y.variables?.id===P.id||w.isPending&&w.variables?.id===P.id||v.isPending&&v.variables?.id===P.id;return o(Wm,{columns:[{key:"username",header:"Username",render:P=>P.username},{key:"isAdmin",header:"Admin",render:P=>u("label",{className:"inline-flex items-center gap-1.5 text-xs cursor-pointer",children:[o("input",{type:"checkbox",checked:P.isAdmin,onChange:L=>z(P,L.target.checked),disabled:M(P),className:"rounded border-border focus:ring-primary disabled:opacity-50"}),o("span",{className:P.isAdmin?"text-primary font-medium":"text-foreground-subtle",children:P.isAdmin?"Admin":"Regular"})]})},{key:"scopes",header:"Scopes",render:P=>{if(P.isAdmin)return o("span",{className:"text-[10px] text-foreground-subtle italic",children:"unscoped"});const L=P.scopes??[];return u("button",{onClick:()=>S(P),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(dn,{className:"h-3 w-3"}),L.length===0?"no access":`${L.length} grant${L.length===1?"":"s"}`]})}},{key:"createdAt",header:"Created",render:P=>o("span",{className:"text-foreground-subtle",children:R(P.createdAt)})},{key:"actions",header:"Actions",align:"right",render:P=>{const L=M(P);return u("div",{className:"flex items-center justify-end gap-1",children:[u("button",{onClick:()=>A(P),disabled:L,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:"Two-factor authentication",children:[o(Mr,{className:"h-3 w-3"}),"2FA"]}),u("button",{onClick:()=>$(P),disabled:L,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(ML,{className:"h-3 w-3"}),"Reset password"]}),u("button",{onClick:()=>B(P),disabled:L,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:[L?o(Ee,{className:"h-3 w-3 animate-spin"}):o(Ge,{className:"h-3 w-3"}),"Delete"]})]})}}],rows:I,rowKey:P=>P.id,minWidthPx:560})})(),E&&o(h7,{userId:E.id,username:E.username,onClose:()=>A(null)}),k&&o(g7,{user:k,onClose:()=>S(null),onSubmit:M=>N.mutate({userId:k.id,scopes:M}),submitting:N.isPending})]})}function g7(e){const{user:t}=mn(),n=t?.isAdmin===!0;return o(b7,{...e,callerScopes:n?null:t?.scopes??[]})}function b7({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=ad(i);return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:u("div",{className:"w-full max-w-2xl rounded-lg border border-border bg-surface shadow-xl",children:[u("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[u("div",{children:[u("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(Be,{className:"h-4 w-4"})})]}),u("div",{className:"px-4 py-4",children:[o(sd,{value:i,onChange:l,clampToParent:s,emptyHint:u(me,{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})]}),u("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(Ee,{className:"h-3 w-3 animate-spin"}):"Save scopes"})]})]})})}const x7="bg-primary/10 text-primary",y7="bg-foreground-subtle/10 text-foreground-subtle";function po(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString()}function v7(e){return e?e==="*"?"*":e.join(", "):""}function w7(){const e=ke(),t=Xe(),{data:n,isLoading:r}=Vx(),{data:s}=Wc(),a=q(()=>n??[],[n]),i=q(()=>s??[],[s]),l=()=>e.invalidateQueries({queryKey:[["userManagement","listApiKeys"]]}),c=()=>e.invalidateQueries({queryKey:[["userManagement","listScopedTokens"]]}),[d,f]=_(!1),[p,h]=_(null),m=qx({onSuccess:l}),g=Ux({onSuccess:({token:w,record:v})=>{c(),f(!1),h({token:w,label:v.name})}}),b=Qx({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 u(rt,{children:[u("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."}),u("button",{onClick:()=>f(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",disabled:i.length===0,title:i.length===0?"Create a user first":"Issue a scoped token",children:[o(dn,{className:"h-3.5 w-3.5"}),"New token"]})]}),u(Kp,{title:"Scoped tokens",subtitle:"Grouped per user",children:[i.length===0&&o(k7,{text:"No users yet — scoped tokens are issued on behalf of an existing user."}),i.map(w=>o(S7,{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(Kp,{title:"Legacy API keys",subtitle:`${a.length} pre-existing — revoke only`,children:o(V0,{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 u("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?x7:y7}`,children:v?"admin":"regular"})}),u("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:v7(w.allowedProviders)||"all"}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:po(w.createdAt)}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:po(w.lastUsedAt)}),o("td",{className:"px-3 py-2 border-b border-border text-right",children:u("button",{onClick:()=>{x(w.id,w.label)},disabled:N,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50",title:"Revoke",children:[N?o(Ee,{className:"h-3 w-3 animate-spin"}):o(Ge,{className:"h-3 w-3"}),"Revoke"]})})]},w.id)})})}),r&&o(N7,{}),d&&o(C7,{users:i.map(w=>({id:w.id,username:w.username})),onClose:()=>f(!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(M7,{token:p.token,label:p.label,onClose:()=>h(null)})]})}function Kp({title:e,subtitle:t,children:n}){return u("div",{className:"space-y-2",children:[u("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 N7(){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 k7({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 V0({headers:e,rows:t}){return o("div",{className:"rounded-lg border border-border bg-surface overflow-x-auto",children:u("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 S7({userId:e,username:t,onRevoke:n,revokePending:r,revokeId:s}){const{data:a,isLoading:i}=Kx({userId:e}),l=a??[];return i||l.length===0?null:u("div",{className:"space-y-1.5",children:[o("div",{className:"text-[11px] font-medium text-foreground",children:t}),o(V0,{headers:["Name","Prefix","Scopes","Expires","Last used","Created",""],rows:l.map(c=>{const d=r&&s===c.id;return u("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}),u("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((f,p)=>u("span",{className:"inline-block rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-mono",children:[f.type,":",f.type==="device"?`[${f.targets.join(",")}]`:f.target]},p))})}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:po(c.expiresAt)}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:po(c.lastUsedAt)}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:po(c.createdAt)}),o("td",{className:"px-3 py-2 border-b border-border text-right",children:u("button",{onClick:()=>n(c.id,c.name),disabled:d,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50",children:[d?o(Ee,{className:"h-3 w-3 animate-spin"}):o(Ge,{className:"h-3 w-3"}),"Revoke"]})})]},c.id)})})]})}function C7({users:e,onClose:t,onSubmit:n,submitting:r}){const{user:s}=mn(),i=s?.isAdmin===!0?null:s?.scopes??[],[l,c]=_(e[0]?.id??""),[d,f]=_(""),[p,h]=_([{type:"capability",target:"",access:["view","create"]}]),[m,g]=_(""),b=ad(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 u(q0,{title:"Create scoped token",onClose:t,children:[u("div",{className:"space-y-3",children:[o(fs,{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(fs,{label:"Name",children:o("input",{value:d,onChange:w=>f(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"})}),u(fs,{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(sd,{value:p,onChange:h,clampToParent:i}),b&&o("p",{className:"mt-1 text-[10px] text-danger",children:b})]}),o(fs,{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"})})]}),u(U0,{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"}),u("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(Ee,{className:"h-3.5 w-3.5 animate-spin"}):o(dn,{className:"h-3.5 w-3.5"}),"Issue token"]})]})]})}function M7({token:e,label:t,onClose:n}){const[r,s]=_(!1),a=async()=>{try{await navigator.clipboard.writeText(e),s(!0)}catch{}};return u(q0,{title:`Token: ${t}`,onClose:n,children:[u("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})]}),u(U0,{children:[u("button",{onClick:()=>{a()},className:"inline-flex items-center gap-1.5 rounded bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30",children:[r?o(Mt,{className:"h-3.5 w-3.5 text-primary"}):o(Uy,{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 q0({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:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:r=>r.stopPropagation(),children:[u("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(Be,{className:"h-4 w-4"})})]}),o("div",{className:"p-4",children:n})]})})}function U0({children:e}){return o("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:e})}function fs({label:e,hint:t,children:n}){return u("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 Fa(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:f,itemIconColor:p,renderStatusBadges:h,renderActionButtons:m,renderExpandedBody:g,trailing:b,showChrome:x=!1}=e,y=l.length>1,[w,v]=_(()=>l[0]?.addonId??null);Y(()=>{w&&(l.some(S=>S.addonId===w)||v(l[0]?.addonId??null))},[l,w]);const N=S=>v(E=>E===S?null:S),k=a?`/system/addons?capability=${encodeURIComponent(a)}`:null;return o(rt,{icon:x?r:void 0,title:x?t:void 0,subtitle:x?n:void 0,actions:x&&k?o(qs,{to:k,children:u(Ve,{variant:"primary",size:"sm",children:[o(Nt,{className:"h-3.5 w-3.5 mr-1"}),i]})}):void 0,children:c?o(on,{children:o("div",{className:"p-6 text-sm text-foreground-subtle",children:"Loading…"})}):l.length===0?o(on,{children:o(ng,{title:d,description:f??(k?`Install an addon that declares the "${a}" capability to get started.`:void 0),action:x&&k?o(qs,{to:k,children:u(Ve,{variant:"primary",size:"sm",children:[o(Nt,{className:"h-3.5 w-3.5 mr-1"}),i]})}):void 0})}):u("div",{className:"flex flex-col gap-4",children:[l.map(S=>{const E=!y||w===S.addonId,A=p?.(S)??"bg-primary/15 text-primary";return u(on,{children:[u("div",{className:`flex items-center gap-4 p-4 ${E?"border-b border-border":""}`,children:[u("button",{type:"button",onClick:()=>y&&N(S.addonId),className:`flex items-center gap-4 flex-1 min-w-0 text-left ${y?"hover:opacity-80 transition-opacity":""}`,disabled:!y,children:[o("div",{className:`h-10 w-10 rounded-lg flex items-center justify-center shrink-0 ${A}`,children:o(s,{className:"h-5 w-5"})}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"font-semibold text-foreground",children:S.displayName}),h?.(S)]}),u("div",{className:"text-xs text-foreground-subtle mt-1 font-mono",children:["@camstack/addon-",S.addonId]})]}),y&&o(wt,{className:`h-4 w-4 text-foreground-subtle shrink-0 transition-transform ${E?"rotate-180":""}`})]}),m&&o("div",{className:"flex items-center gap-1 shrink-0",children:m(S)})]}),E&&g?.(S)]},S.addonId)}),b]})})}function ja({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 u("div",{className:"flex flex-col gap-4",children:[o(Ur,{nodeId:"hub",addonIds:[e],level:"global"}),n&&u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border bg-surface-hover/20",children:[o("span",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Activity"}),u("div",{className:"flex items-center gap-1",children:[o(Gp,{kind:"logs",active:i==="logs",onClick:()=>l("logs")}),o(Gp,{kind:"events",active:i==="events",onClick:()=>l("events")})]})]}),i==="logs"?o(Yt,{addonId:e,maxHeight:r,showFilters:!1}):o(ir,{addonId:e,category:"addon.*",maxHeight:r})]})]})}function Gp({kind:e,active:t,onClick:n}){return u("button",{onClick:n,className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${t?"bg-primary/10 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,children:[o(e==="logs"?nt:Bo,{className:"h-3 w-3"}),e==="logs"?"Logs":"Events"]})}function E7(e){const t=e.kind??"";return t==="local"||e.addonId==="local-auth"?{headline:"Username + password (local).",icon:Wy,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:ln,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:ln,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:Mr,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:Mr,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:dn,bullets:["Generic authentication provider. No additional hints registered."]}}function I7(){const e=Rc(),t=e.data??[];return o(Fa,{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:dn,itemIcon:dn,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=>u(me,{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&&u("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(Wy,{className:"inline h-2.5 w-2.5 mr-0.5"}),"Credential"]}),n.hasRedirectFlow&&u("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(ln,{className:"inline h-2.5 w-2.5 mr-0.5"}),"Redirect SSO"]}),n.status&&u("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(dt,{className:"inline h-2.5 w-2.5 mr-0.5"}),n.status]})]}),renderExpandedBody:n=>{const r=E7(n),s=r.icon;return u(me,{children:[u("div",{className:"p-4 space-y-3 border-b border-border",children:[u("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&&u("div",{className:"rounded-md border border-border bg-surface-hover/40 px-3 py-2.5 space-y-1.5",children:[u("div",{className:"flex items-center gap-1.5 text-[10px] font-semibold text-foreground-subtle uppercase tracking-wide",children:[o(ET,{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"&&u("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(kn,{className:"h-3.5 w-3.5 mt-0.5 text-blue-500 shrink-0"}),u("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(ja,{addonId:n.addonId,maxHeight:"max-h-64"})})]})}})}function A7(){return o("div",{className:"flex flex-col p-4",children:o(Id,{tabs:[{id:"users",label:"Users",icon:HR,content:o(m7,{})},{id:"api-keys",label:"Tokens",icon:kL,content:o(w7,{})},{id:"authentication",label:"Authentication",icon:dn,content:o(I7,{})}]})})}function _7(){const e=ke(),t=Ax(void 0,{refetchInterval:5e3}),n=t.data??[],[r,s]=_(null),a=()=>{e.invalidateQueries({queryKey:[["remoteAccess"]]}),s(null)},i=_x({onSuccess:a,onError:()=>s(null)}),l=Px({onSuccess:a,onError:()=>s(null)});return o(Fa,{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:ln,itemIcon:ln,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:c=>c.connected?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle",renderStatusBadges:c=>u(me,{children:[o("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${c.connected?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:c.connected?"Connected":"Disconnected"}),c.endpoint&&u("a",{href:c.endpoint.url,target:"_blank",rel:"noopener noreferrer",onClick:d=>d.stopPropagation(),className:"text-[10px] text-emerald-700 dark:text-emerald-300 hover:underline flex items-center gap-1",children:[o(wd,{className:"h-3 w-3"}),c.endpoint.url]}),c.error&&o("span",{className:"text-[10px] text-danger",children:c.error})]}),renderActionButtons:c=>{const d=r===c.addonId;return c.connected?u(Ve,{size:"sm",variant:"secondary",disabled:d,onClick:()=>{s(c.addonId),l.mutate({addonId:c.addonId})},children:[d?o(Ee,{className:"h-3 w-3 animate-spin"}):o(jo,{className:"h-3 w-3"}),"Stop"]}):u(Ve,{size:"sm",variant:"primary",disabled:d,onClick:()=>{s(c.addonId),i.mutate({addonId:c.addonId})},children:[d?o(Ee,{className:"h-3 w-3 animate-spin"}):o(Ta,{className:"h-3 w-3"}),"Start"]})},renderExpandedBody:c=>o("div",{className:"p-4",children:o(ja,{addonId:c.addonId,maxHeight:"max-h-72"})})})}function P7(){const e=ke(),t=Rx(void 0,{refetchInterval:3e4}),n=Ox(),r=t.data??[],s=n.data??[],[a,i]=_(null),l=zx({onSuccess:()=>{e.invalidateQueries({queryKey:[["turnOrchestrator"]]}),i(null)},onError:()=>i(null)});return o(Fa,{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:Mn,itemIcon:Mn,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=>u(me,{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"}),u("span",{className:"text-[10px] text-foreground-subtle",children:["· ",c.serverCount," server",c.serverCount===1?"":"s"]}),c.error&&o("span",{className:"text-[10px] text-danger",children:c.error})]}),renderActionButtons:c=>{const d=a===c.addonId;return c.enabled?u(Ve,{size:"sm",variant:"secondary",disabled:d,onClick:()=>{i(c.addonId),l.mutate({addonId:c.addonId,enabled:!1})},children:[d?o(Ee,{className:"h-3 w-3 animate-spin"}):o(jo,{className:"h-3 w-3"}),"Disable"]}):u(Ve,{size:"sm",variant:"primary",disabled:d,onClick:()=>{i(c.addonId),l.mutate({addonId:c.addonId,enabled:!0})},children:[d?o(Ee,{className:"h-3 w-3 animate-spin"}):o(Ta,{className:"h-3 w-3"}),"Enable"]})},renderExpandedBody:c=>u(me,{children:[c.urls.length>0&&u("div",{className:"px-4 py-3 border-b border-border",children:[u("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(ja,{addonId:c.addonId,maxHeight:"max-h-72"})})]}),trailing:u(on,{children:[u("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[u("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(Ve,{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 f=Array.isArray(c.urls)?c.urls:[c.urls];return u("div",{className:"rounded border border-border bg-surface",children:[(c.username||c.credential)&&u("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&&u("span",{children:[o("span",{className:"text-foreground-subtle",children:"user:"})," ",o("span",{className:"text-foreground",children:c.username})]}),c.credential&&u("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:f.map(p=>o("li",{className:"px-3 py-1.5 font-mono text-xs text-foreground break-all",children:p},p))})]},d)})})})]})})}const $7={lan:Mn,wifi:Kn,docker:Da,vpn:Zy,loopback:cn,other:cn},D7={lan:"LAN",wifi:"Wi-Fi",docker:"Docker",vpn:"VPN",loopback:"Loopback",other:"Other"},T7=["lan","wifi","vpn","docker","other","loopback"];function L7(e){const{interfaces:t,disabled:n,hideLoopback:r,ipv4Only:s,emptyMessage:a}=e,i=q(()=>t.filter(f=>!(r&&f.kind==="loopback"||s&&f.family!=="IPv4")),[t,r,s]),l=q(()=>{const f=new Map;for(const p of i){const h=f.get(p.kind)??[];h.push(p),f.set(p.kind,h)}return T7.filter(p=>f.has(p)).map(p=>({kind:p,items:f.get(p)}))},[i]),c=f=>e.mode==="single"?e.value===f:e.value.includes(f),d=f=>{if(n||f.kind==="loopback")return;if(e.mode==="single"){e.onChange(e.value===f.address?null:f.address);return}const p=new Set(e.value);p.has(f.address)?p.delete(f.address):p.add(f.address),e.onChange([...p])};return i.length===0?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:f,items:p})=>{const h=$7[f]??cn;return u("div",{className:"rounded-md border border-border overflow-hidden",children:[u("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border",children:[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:D7[f]??f}),u("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 u("li",{className:`flex items-center gap-3 px-3 py-2 ${b?"opacity-60 cursor-not-allowed":n?"opacity-60":x?"cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]":"cursor-pointer hover:bg-surface-hover/30"}`,onClick:()=>d(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(Mt,{className:"h-3 w-3"})}),u("div",{className:`flex-1 min-w-0 ${x?"text-foreground-subtle":""}`,children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[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&&u("span",{className:"inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300",title:m.plausibleReason||void 0,children:[o(dt,{className:"h-2.5 w-2.5"}),"Unlikely usable"]})]}),u("div",{className:"text-xs text-foreground-subtle mt-0.5 font-mono break-all",children:[m.address,m.cidr&&m.cidr!==m.address?` (${m.cidr})`:""]})]})]},`${m.name}-${m.family}-${m.address}`)})})]},f)})})}const Wp={"lan-ipv4":"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300","lan-ipv6":"bg-violet-500/15 text-violet-700 dark:text-violet-300",public:"bg-blue-500/15 text-blue-700 dark:text-blue-300",loopback:"bg-foreground-subtle/15 text-foreground-subtle"};function R7(){const e=ke(),t=Te(),n=Eb(void 0,{refetchInterval:3e4}),r=Ab(void 0),s=_b({onSuccess:()=>{e.invalidateQueries({queryKey:[["localNetwork"]]})}}),a=Pb({onSuccess:S=>{p(S.addresses),e.invalidateQueries({queryKey:[["localNetwork"]]})}}),i=q(()=>n.data?.interfaces??[],[n.data]),l=typeof window<"u"?Number(window.location.port)||(window.location.protocol==="https:"?443:80):4e3,c=typeof window<"u"&&window.location.protocol==="https:"?"https":"http",d=Ib({port:l,scheme:c},{refetchInterval:3e4}),[f,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(f.length!==g.length)return!0;const S=[...f].sort(),E=[...g].sort();return S.some((A,I)=>A!==E[I])},[f,g]),x=()=>{s.mutate({addresses:[...f]})},y=()=>{p(g)},w=()=>{p([])},v=()=>{n.refetch(),d.refetch(),r.refetch()},N=async()=>{try{const S=await t.raceConnectionEndpoints({perCandidateTimeoutMs:1500});console.info("[network-addresses] race result",S)}catch(S){console.warn("[network-addresses] race failed",S)}},k=d.data?.endpoints??[];return u(rt,{children:[u("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."}),u("div",{className:"flex items-center gap-2 shrink-0",children:[u(Ve,{size:"sm",variant:"secondary",onClick:v,disabled:n.isLoading,children:[o(ft,{className:`h-3 w-3 ${n.isLoading?"animate-spin":""}`}),"Refresh"]}),o(Ve,{size:"sm",variant:"secondary",onClick:N,children:"Probe race"})]})]}),u("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[u(on,{children:[u("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[u("div",{children:[o("div",{className:"text-sm font-semibold",children:"Allowed addresses"}),o("div",{className:"text-xs text-foreground-subtle",children:f.length===0?"Auto — every non-loopback / non-link-local interface participates.":`${f.length} pinned`})]}),u("div",{className:"flex items-center gap-1",children:[u(Ve,{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(AR,{className:"h-3 w-3"}),a.isPending?"Detecting…":"Best match"]}),u(Ve,{size:"sm",variant:"secondary",onClick:w,disabled:f.length===0||s.isPending,children:[o(n0,{className:"h-3 w-3"}),"Clear"]}),b&&o(Ve,{size:"sm",variant:"secondary",onClick:y,disabled:s.isPending,children:"Discard"}),u(Ve,{size:"sm",variant:"primary",onClick:x,disabled:!b||s.isPending,children:[o(hR,{className:"h-3 w-3"}),s.isPending?"Saving…":"Save"]})]})]}),o("div",{className:"p-4",children:o(L7,{mode:"multiple",interfaces:i,value:f,onChange:p,disabled:s.isPending,emptyMessage:n.isLoading?"Loading interfaces…":"No interfaces detected."})})]}),u(on,{children:[u("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(S=>u("li",{className:`flex items-center gap-2 flex-wrap ${S.plausible?"":"opacity-80"}`,children:[o("span",{className:"font-mono text-[10px] w-10 text-foreground-subtle",children:String(S.priority).padStart(4,"0")}),o("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${Wp[S.kind]??Wp.loopback}`,children:S.kind}),S.interfaceKind!=="lan"&&S.interfaceKind!=="public"&&o("span",{className:"text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-medium uppercase",children:S.interfaceKind}),!S.plausible&&S.interfaceKind!=="loopback"&&u("span",{className:"inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300",title:S.plausibleReason||void 0,children:[o(dt,{className:"h-2.5 w-2.5"}),"Unlikely usable"]}),o("span",{className:`font-mono break-all ${S.plausible?"text-foreground":"text-foreground-subtle"}`,children:S.baseUrl}),u("span",{className:"text-foreground-subtle",children:["— ",S.label]})]},`${S.priority}-${S.baseUrl}`))})})]})]})]})}const O7={mesh:"bg-violet-500/15 text-violet-700 dark:text-violet-300",public:"bg-blue-500/15 text-blue-700 dark:text-blue-300"};function z7(){const e=ke(),t=$b(void 0,{refetchInterval:5e3}),n=t.data??[],[r,s]=_(null),[a,i]=_({}),[l,c]=_({}),d=()=>{e.invalidateQueries({queryKey:[["meshOrchestrator"]]}),s(null)},f=Db({onSuccess:d,onError:()=>s(null)}),p=Tb({onSuccess:d,onError:()=>s(null)});return o(Fa,{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:Da,itemIcon:Mn,capability:"mesh-network",installButtonLabel:"Add mesh",items:n,isLoading:t.isLoading,emptyTitle:"No mesh-network providers installed",emptyDescription:"Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.",itemIconColor:h=>h.joined?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle",renderStatusBadges:h=>u(me,{children:[o("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${h.joined?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:h.joined?"Joined":"Not joined"}),h.joined&&u("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle",children:[h.peerCount," peer",h.peerCount===1?"":"s"]})]}),renderActionButtons:h=>{const m=r===h.addonId;return h.joined?u(Ve,{size:"sm",variant:"secondary",disabled:m,onClick:()=>{s(h.addonId),p.mutate({addonId:h.addonId})},children:[m?o(Ee,{className:"h-3 w-3 animate-spin"}):o(Nd,{className:"h-3 w-3"}),"Leave"]}):null},renderExpandedBody:h=>{const m=r===h.addonId,g=a[h.addonId]??"",b=l[h.addonId]??"",x=g.trim().length>=8;return u(me,{children:[h.joined?u("div",{className:"p-4 space-y-3",children:[u("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[h.meshIp&&u("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"text-foreground-subtle",children:"Mesh IP:"}),o("span",{className:"font-mono text-foreground",children:h.meshIp})]}),h.magicDnsHostname&&u("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"text-foreground-subtle",children:"MagicDNS:"}),o("span",{className:"font-mono text-foreground break-all",children:h.magicDnsHostname})]})]}),h.endpoints.length>0&&u("div",{className:"flex flex-col gap-1",children:[o("div",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Endpoints"}),h.endpoints.map(y=>u("div",{className:"flex items-center gap-2 text-xs",children:[u("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${O7[y.scope]??"bg-foreground-subtle/15 text-foreground-subtle"}`,children:[y.scope==="public"?o(ln,{className:"inline h-2.5 w-2.5 mr-0.5"}):null,y.label]}),u("a",{href:y.url,target:"_blank",rel:"noopener noreferrer",onClick:w=>w.stopPropagation(),className:"text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1",children:[o(wd,{className:"h-3 w-3 shrink-0"}),y.url]})]},y.id))]}),h.error&&o("div",{className:"text-xs text-danger",children:h.error})]}):u("div",{className:"p-4 space-y-3",children:[o("div",{className:"text-xs text-foreground-subtle",children:"Provide an auth key to join this hub into the mesh. The key is forwarded to the daemon and never persisted in clear."}),u("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[o("input",{type:"password",autoComplete:"off",placeholder:"Auth key (tskey-auth-…)",value:g,onChange:y=>i(w=>({...w,[h.addonId]:y.target.value})),className:"rounded-md border border-border bg-surface px-2 py-1 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"}),o("input",{type:"text",placeholder:"Hostname (optional)",value:b,onChange:y=>c(w=>({...w,[h.addonId]:y.target.value})),className:"rounded-md border border-border bg-surface px-2 py-1 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),o("div",{className:"flex justify-end",children:u(Ve,{size:"sm",variant:"primary",disabled:m||!x,onClick:()=>{s(h.addonId),f.mutate({addonId:h.addonId,authKey:g.trim(),hostname:b.trim()?b.trim():void 0})},children:[m?o(Ee,{className:"h-3 w-3 animate-spin"}):o(LL,{className:"h-3 w-3"}),"Join"]})}),h.error&&o("div",{className:"text-xs text-danger",children:h.error})]}),o("div",{className:"p-4 border-t border-border",children:o(ja,{addonId:h.addonId,maxHeight:"max-h-72"})})]})}})}function B7(){return o("div",{className:"flex flex-col p-4",children:o(Id,{tabs:[{id:"addresses",label:"Network Addresses",icon:cn,content:o(R7,{})},{id:"remote-access",label:"Remote Access",icon:ln,content:o(_7,{})},{id:"mesh",label:"Mesh Networks",icon:Da,content:o(z7,{})},{id:"turn",label:"TURN Servers",icon:Mn,content:o(P7,{})}]})})}function F7(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 j7({location:e,onEdit:t,onDelete:n,onSetDefault:r}){const s=F7(e.config);return u("div",{className:"flex items-center gap-3 px-3 py-2 border-t border-border first:border-t-0 hover:bg-primary/5",children:[u("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o("div",{className:"w-[88px] shrink-0",children:e.isDefault?u("span",{className:"inline-flex items-center gap-0.5 rounded bg-primary/10 border border-primary/20 px-1.5 py-0.5 text-[10px] font-semibold text-primary uppercase tracking-wide",title:"Default location for this type",children:[o(Si,{className:"h-2.5 w-2.5 fill-primary"}),"Default"]}):u("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(Si,{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"}),u("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})]})]}),u("div",{className:"flex items-center gap-1 shrink-0",children:[!e.isDefault&&u("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(Si,{className:"h-3 w-3"}),"Set default"]}),u("button",{onClick:()=>t(e),className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10",children:[o(qr,{className:"h-3 w-3"}),"Edit"]}),!e.isSystem&&Ss[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(Ge,{className:"h-3 w-3"})})]})]})}function H7({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((f,p)=>f.isDefault!==p.isDefault?f.isDefault?-1:1:f.displayName.localeCompare(p.displayName)),d},[r]);return u("div",{className:"rounded-lg border border-border bg-surface",children:[u("div",{className:"flex items-start justify-between border-b border-border px-3 py-2",children:[u("div",{className:"space-y-0.5",children:[u("div",{className:"flex items-center gap-2",children:[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}),Ss[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."})]}),Ss[e]==="multi"&&u("button",{onClick:()=>s(e),className:"inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90",children:[o(Nt,{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:Ss[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(j7,{location:d,onEdit:a,onDelete:i,onSetDefault:l},d.id))})]})}function V7(e){const t=e.trim().toLowerCase();return t.length===0?"":t.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Yp(e,t){const n=V7(t),r=n.length>0?n:"default";return`${e}:${r}`}function Q0({initialType:e,onClose:t,onCreated:n}){const r=ke(),s=Te().trpcClient,[a,i]=_("picker"),[l,c]=_(e),[d,f]=_(null),[p,h]=_({}),[m,g]=_(""),[b,x]=_(null),[y,w]=_(!1),[v,N]=_(null),[k,S]=_(!1),E=Gc(),A=q(()=>{const T=E.data;return Array.isArray(T)?T.filter(L=>L.supportedLocationTypes.includes(l)):[]},[E.data,l]),I=E.isLoading,B=Ca({onSuccess:()=>{r.invalidateQueries({queryKey:[["storage","listLocations"]]}),n()}}),$=q(()=>b!==null&&b.length>0?b:Yp(l,m),[l,m,b]),z=async()=>{if(d){S(!0),N(null);try{const L=await(O=>s.storage.testConfig.query(O))({providerId:d.providerId,config:p});N(L)}catch(T){N({ok:!1,error:T instanceof Error?T.message:String(T)})}finally{S(!1)}}},R=()=>{d&&B.mutate({id:$,type:l,displayName:m.trim(),providerId:d.providerId,config:p,isDefault:y})},M={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:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:T=>T.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:M[a]}),u("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(Be,{className:"h-4 w-4"})})]}),a==="picker"&&u("div",{className:"p-4 space-y-2",children:[I&&o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading providers…"}),!I&&A.length===0&&u("div",{className:"rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle",children:['No storage-provider supports type "',l,'". Install a compatible addon (e.g. ',o("code",{className:"font-mono",children:"remote-storage"}),") to enable it."]}),A.map(T=>u("button",{onClick:()=>{f(T),i("config")},className:"flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors",children:[u("div",{className:"flex-1 min-w-0",children:[o("p",{className:"text-xs font-semibold text-foreground",children:T.displayName}),o("p",{className:"text-[10px] text-foreground-subtle font-mono mt-0.5 truncate",children:T.providerId})]}),o(Et,{className:"h-4 w-4 text-foreground-subtle flex-shrink-0"})]},T.providerId))]}),a==="config"&&d&&u("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[o(En,{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"}`}),u("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"}),u("div",{className:"flex items-center gap-2",children:[o("button",{onClick:()=>{z()},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&&u("div",{className:"p-4 space-y-3",children:[u("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:T=>g(T.target.value),placeholder:`${l} on ${d.displayName}`,className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary"})]}),u("div",{className:"space-y-1",children:[u("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:["Id ",o("span",{className:"lowercase tracking-normal text-foreground-subtle",children:"— auto-derived; override if needed"})]}),o("input",{type:"text",value:$,onChange:T=>x(T.target.value),placeholder:Yp(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"}),u("p",{className:"text-[10px] text-foreground-subtle",children:["Format: ",o("code",{className:"font-mono",children:"<type>:<slug>"}),". Lowercase letters, digits, and hyphens only."]})]}),u("label",{className:"flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5",children:[o("input",{type:"checkbox",checked:y,onChange:T=>w(T.target.checked),className:"accent-primary mt-0.5"}),u("div",{className:"space-y-0.5",children:[u("div",{className:"text-xs font-medium text-foreground",children:['Mark as default for type "',l,'"']}),u("div",{className:"text-[10px] text-foreground-subtle",children:["Setting this as default will demote the current default for this type. References like"," ",u("code",{className:"font-mono",children:['"',l,'"']})," resolve to whichever location is the default."]})]})]}),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)}),u("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"}),u("div",{className:"flex items-center gap-2",children:[o("button",{onClick:()=>{c(e),f(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"}),u("button",{onClick:R,disabled:B.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:[B.isPending?o(Ee,{className:"h-3.5 w-3.5 animate-spin"}):null,B.isPending?"Saving…":"Save"]})]})]})]})]})})}function q7({location:e,onClose:t,onSaved:n}){const r=ke(),s=Te().trpcClient,[a,i]=_({...e.config}),[l,c]=_(e.displayName),[d,f]=_(null),[p,h]=_(!1),m=Gc(),g=q(()=>{const w=m.data;return Array.isArray(w)?w.find(N=>N.providerId===e.providerId)??null:null},[m.data,e.providerId]),b=Ca({onSuccess:()=>{r.invalidateQueries({queryKey:[["storage","listLocations"]]}),n()}}),x=async()=>{h(!0),f(null);try{const v=await(N=>s.storage.testConfig.query(N))({providerId:e.providerId,config:a});f(v)}catch(w){f({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:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:w=>w.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[u("h2",{className:"text-sm font-semibold text-foreground",children:["Edit ",e.displayName]}),u("p",{className:"text-xs text-foreground-subtle",children:[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(Be,{className:"h-4 w-4"})})]}),u("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[u("div",{className:"space-y-1",children:[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(En,{schema:g.configSchema,values:a,onChange:i}),!g&&!m.isLoading&&u("div",{className:"rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300",children:["Provider ",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)})]}),u("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"}),u("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"}),u("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(Ee,{className:"h-3.5 w-3.5 animate-spin"}):null,b.isPending?"Saving…":"Save"]})]})]})]})})}const U7={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"},Q7={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 K7(){const e=ke(),t=Xe(),{data:n,isLoading:r,isError:s}=$x({}),[a,i]=_(null),[l,c]=_(null),d=Dx({onSuccess:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]})}}),f=Ca({onSuccess:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]})}}),p=g=>{g.isDefault||f.mutate({id:g.id,type:g.type,providerId:g.providerId,displayName:g.displayName,config:g.config,isDefault:!0})},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 iu)g.set(b,[]);for(const b of n??[]){const x=g.get(b.type);x?x.push(b):g.set(b.type,[b])}return g},[n]);return u(rt,{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:iu.map(g=>o(H7,{type:g,displayName:U7[g],description:Q7[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(Q0,{initialType:a,onClose:()=>i(null),onCreated:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]}),i(null)}}),l!==null&&o(q7,{location:l,onClose:()=>c(null),onSaved:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]}),c(null)}})]})}const G7=[["backup","listDestinations"]],W7=["backup","listArchives"];function Y7({destinationId:e,restoreSupported:t,onOpenRestoreWizard:n}){const r=ke(),s=Xe(),{data:a,isLoading:i,isError:l}=zc({destinationId:e}),c=a??[],d=Zg({onSuccess:()=>{r.invalidateQueries({queryKey:[[...W7]]}),r.invalidateQueries({queryKey:G7})}}),f=U(async b=>{await s({title:"Delete this archive?",message:`Permanently deletes "${b.label??b.id}" and frees ${kt(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(Z7(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:u("table",{className:"w-full text-xs min-w-[640px]",children:[o("thead",{children:u("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=>u("tr",{className:"border-t border-border hover:bg-primary/5",children:[o("td",{className:"px-3 py-1.5 text-foreground tabular-nums",children:X7(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:kt(b.sizeBytes)}),o("td",{className:"px-3 py-1.5",children:u("div",{className:"flex items-center justify-end gap-1",children:[u("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(Ee,{className:"h-3 w-3 animate-spin"}):o(Cn,{className:"h-3 w-3"}),"Download"]}),t&&n&&u("button",{onClick:()=>n({destinationId:e,archiveId:b.id}),className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-primary hover:bg-primary/10",title:"Restore from this archive",children:[o(xt,{className:"h-3 w-3"}),"Restore"]}),o("button",{onClick:()=>{f(b)},disabled:d.isPending,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50",title:"Delete archive",children:d.isPending?o(Ee,{className:"h-3 w-3 animate-spin"}):o(Ge,{className:"h-3 w-3"})})]})})]},b.id))})]})})}function Z7(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function X7(e){return new Date(e).toLocaleString(void 0,{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}const K0=[{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 J7(e){const t=e.trim();for(const n of K0)if(n.cron===t)return n.id;return"custom"}function ez({value:e,onChange:t,previewCount:n=5,disabled:r=!1}){const s=J7(e),[a,i]=_(s==="custom");Y(()=>{s!=="custom"&&i(!1)},[s]);const l=rz(e,250),c=Jg({cron:l,count:n},{enabled:l.trim().length>0}),d=c.data??null,f=h=>{i(!1),t(h.cron)},p=a||s==="custom";return u("div",{className:"space-y-3",children:[u("div",{className:"space-y-1",children:[o("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Schedule preset"}),u("div",{className:"flex flex-wrap gap-1.5",children:[K0.map(h=>{const m=!a&&s===h.id;return o("button",{type:"button",onClick:()=>f(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&&u("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"}),u("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(tz,{cron:l,preview:d,loading:c.isFetching})]})}function tz({cron:e,preview:t,loading:n}){return n&&t===null?u("div",{className:"flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle",children:[o(Ee,{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."}):u("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)=>u("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:nz(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 nz(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 rz(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 oz=[["backup","listDestinations"]];function sz({onCreateAt:e,onOpenRestoreWizard:t}){const{data:n,isLoading:r,isError:s}=Oc(),a=n??[],[i,l]=_(null),c=f=>{l(p=>p===f?null:f)},d=dz();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:u("table",{className:"w-full text-xs min-w-[720px]",children:[o("thead",{children:u("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(f=>{const p=d.get(f.id);return o(az,{row:f,isOpen:i===f.id,onToggle:()=>c(f.id),onCreateAt:e,liveLastSuccessAt:p?.at,liveLastSuccessSizeBytes:p?.sizeBytes,...t?{onOpenRestoreWizard:t}:{}},f.id)})})]})})}function az({row:e,isOpen:t,onToggle:n,onCreateAt:r,onOpenRestoreWizard:s,liveLastSuccessAt:a,liveLastSuccessSizeBytes:i}){const l=ke(),c=Xg({onSuccess:()=>{l.invalidateQueries({queryKey:oz})}}),[d,f]=_(String(e.retentionCount));Y(()=>{f(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){f(String(e.retentionCount));return}x!==e.retentionCount&&c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:x,...e.label!==void 0?{label:e.label}:{},...e.cron!==void 0?{cron:e.cron}:{}})},[c,d,e.id,e.enabled,e.retentionCount,e.label,e.cron]),b=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 u(me,{children:[u("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(wt,{className:"h-3.5 w-3.5"}):o(Et,{className:"h-3.5 w-3.5"})})}),o("td",{className:"px-3 py-2",children:u("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}),u("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=>f(x.target.value),onBlur:g,onKeyDown:x=>{x.key==="Enter"&&x.target.blur(),x.key==="Escape"&&f(String(e.retentionCount))},className:"w-16 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary"})}),o("td",{className:"px-3 py-2",children:o(iz,{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=uz(a,e.lastSuccessAt),y=x===a?i:e.lastSuccessSizeBytes;return x!==void 0?o(pz,{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&&u("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(Nt,{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(Y7,{destinationId:e.id,restoreSupported:e.restoreSupported,...s?{onOpenRestoreWizard:s}:{}})})}),p&&o(cz,{destinationName:e.displayName,currentCron:e.cron??"",onSave:b,onClose:()=>h(!1),saving:c.isPending,saveError:c.error instanceof Error?c.error.message:null})]})}function iz({cron:e,nextRunAt:t,onEdit:n,disabled:r}){const s=typeof e=="string"&&e.trim().length>0;return u("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:[u("div",{className:"flex items-center gap-1.5",children:[o(DT,{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&&u("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:["next ",lz(t)]})]})}function lz(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 cz({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:u("div",{className:"w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl",onClick:c=>c.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:"Schedule"}),u("p",{className:"text-xs text-foreground-subtle",children:["→ ",e]})]}),o("button",{onClick:r,className:"text-foreground-subtle hover:text-foreground",title:"Close",children:o(Be,{className:"h-4 w-4"})})]}),u("div",{className:"p-4",children:[o(ez,{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})]}),u("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 dz(){const{map:e}=Cc(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 uz(e,t){return e===void 0?t:t===void 0||e>t?e:t}function pz({at:e,sizeBytes:t}){const n=fz(e),r=q(()=>new Date(e).toLocaleString(),[e]);return u("span",{title:r,className:"text-foreground tabular-nums",children:[n,t!==void 0&&u("span",{className:"ml-1 text-foreground-subtle",children:["· ",kt(t)]})]})}function fz(e){const[,t]=_(0);return Y(()=>{const n=setInterval(()=>t(r=>r+1),3e4);return()=>clearInterval(n)},[]),hz(e)}function hz(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 mz=[["backup","list"]];function gz({initialDestinationId:e,initialArchiveId:t,onClose:n,onScheduled:r}){const s=ke(),[a,i]=_(e&&t?2:1),[l,c]=_(e),[d,f]=_(t),[p,h]=_(new Set),{data:m}=Oc(),g=m??[],{data:b,isLoading:x}=zc({destinationId:l??""},{enabled:!!l}),y=b??[];Y(()=>{if(l!==void 0)return;const B=g.filter($=>$.restoreSupported);B.length===1&&c(B[0].id)},[l,g]);const{data:w}=Wg({destinationId:l??"",backupId:d??""},{enabled:!!l&&!!d}),v=q(()=>w?.locations??[],[w]);Y(()=>{v.length!==0&&h(B=>B.size===0?new Set(v):B)},[v]);const N=Yg({onSuccess:()=>{s.invalidateQueries({queryKey:mz}),r(),n()}}),k=B=>{h($=>{const z=new Set($);return z.has(B)?z.delete(B):z.add(B),z})},S=!!l&&!!d,E=p.size>0,A=S&&E&&!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:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:B=>B.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:"Restore Backup"}),u("p",{className:"text-xs text-foreground-subtle",children:["Step ",a," of 3 — ",a===1?"pick source":a===2?"pick locations":"confirm"]})]}),o("button",{onClick:n,className:"text-foreground-subtle hover:text-foreground",children:o(Be,{className:"h-4 w-4"})})]}),a===1&&o(bz,{destinations:g,destinationId:l,onPickDestination:B=>{c(B),f(void 0),h(new Set)},archives:y,archivesLoading:x,archiveId:d,onPickArchive:f}),a===2&&o(xz,{locations:v,picked:p,onToggle:k}),a===3&&o(yz,{destinationName:g.find(B=>B.id===l)?.displayName??l??"",archive:y.find(B=>B.id===d),picked:[...p]}),u("div",{className:"flex justify-between gap-2 border-t border-border px-4 py-3",children:[o("div",{children:a>1&&u("button",{onClick:()=>i(B=>B===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(yd,{className:"h-3 w-3"}),"Back"]})}),u("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?u("button",{disabled:a===1&&!S||a===2&&!E,onClick:()=>i(B=>B===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(NT,{className:"h-3 w-3"})]}):u("button",{onClick:I,disabled:!A,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(Ee,{className:"h-3.5 w-3.5 animate-spin"}):o(xt,{className:"h-3.5 w-3.5"}),"Schedule Restore"]})]})]})]})})}function bz({destinations:e,destinationId:t,onPickDestination:n,archives:r,archivesLoading:s,archiveId:a,onPickArchive:i}){const l=e.filter(c=>c.restoreSupported);return u("div",{className:"p-4 space-y-3",children:[u("div",{className:"space-y-1.5",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Destination"}),u("select",{value:t??"",onChange:c=>n(c.target.value),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary",children:[o("option",{value:"",disabled:!0,children:"Select destination…"}),l.map(c=>u("option",{value:c.id,children:[c.displayName," (",c.kind,")"]},c.id))]})]}),u("div",{className:"space-y-1.5",children:[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 u("label",{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${d?"bg-primary/10":"hover:bg-primary/5"}`,children:[u("div",{className:"flex items-center gap-2",children:[o("input",{type:"radio",name:"archive",checked:d,onChange:()=>i(c.id),className:"accent-primary"}),u("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:kt(c.sizeBytes)})]},c.id)})})]})]})}function xz({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."})}):u("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."}),u("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=>u("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:wz(r)})]},r))})]})]})}function yz({destinationName:e,archive:t,picked:n}){return u("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."}),u("dl",{className:"space-y-1.5",children:[o(hs,{term:"Destination",value:e}),o(hs,{term:"Archive",value:t?.label??t?.id??"—"}),t&&o(hs,{term:"Created",value:`${new Date(t.createdAt).toLocaleString()} · ${kt(t.sizeBytes)}`}),o(hs,{term:"Locations",value:n.length>0?n.join(", "):"— (full archive)"})]})]})}function hs({term:e,value:t}){return u("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 vz={db:"Database",addons:"Addon configs","addons-data":"Addon data",tls:"TLS certificates",cache:"Cache",data:"Top-level data"};function wz(e){return vz[e]??""}const Nz=[["backup","list"]],kz=[["backup","listLocations"]];function Sz(){const e=ke(),t=Xe(),{data:n}=Gg(),r=Kg({onSuccess:()=>{e.invalidateQueries({queryKey:Nz}),e.invalidateQueries({queryKey:[["backup","listDestinations"]]}),e.invalidateQueries({queryKey:[["backup","listArchives"]]})}}),s=Pg(),[a,i]=_(null),[l,c]=_(null),[d,f]=_(!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 u(rt,{children:[u("div",{className:"flex items-center justify-end gap-2 flex-wrap",children:[u("button",{onClick:()=>f(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30",children:[o(xt,{className:"h-3.5 w-3.5"}),"Restore…"]}),u("button",{onClick:()=>g(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:[o(Nt,{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:u("div",{className:"flex items-center justify-between gap-3",children:[u("div",{className:"flex items-center gap-2",children:[o(xt,{className:"h-3.5 w-3.5"}),o("span",{children:"Restore scheduled. Restart the server to apply."})]}),u("button",{onClick:()=>{b()},disabled:s.isPending,className:"inline-flex items-center gap-1.5 rounded bg-amber-500/20 px-2 py-1 font-medium text-amber-800 dark:text-amber-200 hover:bg-amber-500/30 disabled:opacity-50",children:[s.isPending?o(Ee,{className:"h-3.5 w-3.5 animate-spin"}):o(xt,{className:"h-3.5 w-3.5"}),"Restart Now"]})]})}),o(sz,{onCreateAt:x=>i(x),onOpenRestoreWizard:x=>c(x)}),a&&o(Cz,{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:kz})}})},submitting:r.isPending}),(l||d)&&o(gz,{...l?{initialDestinationId:l.destinationId,initialArchiveId:l.archiveId}:{},onClose:()=>{c(null),f(!1)},onScheduled:()=>h(!0)}),m&&o(Q0,{initialType:"backups",onClose:()=>g(!1),onCreated:()=>{g(!1),e.invalidateQueries({queryKey:[["backup","listDestinations"]]})}})]})}function Cz({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))),f=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:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:p=>p.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:"Create Backup"}),u("p",{className:"text-xs text-foreground-subtle",children:["→ ",e.displayName]})]}),o("button",{onClick:n,className:"text-foreground-subtle hover:text-foreground",children:o(Be,{className:"h-4 w-4"})})]}),u("div",{className:"p-4 space-y-3",children:[u("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"})]}),u("div",{className:"space-y-1.5",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Include"}),u("div",{className:"rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto",children:[a.length===0&&o("div",{className:"px-3 py-2 text-xs text-foreground-subtle italic",children:"Nothing to back up."}),a.map(p=>u("label",{className:"flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer",children:[u("div",{className:"flex items-center gap-2",children:[o("input",{type:"checkbox",checked:c.has(p.name),onChange:()=>f(p.name),className:"accent-primary"}),o("span",{className:"font-mono text-foreground",children:p.name})]}),u("div",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[kt(p.sizeBytes)," · ",p.fileCount," files"]})]},p.name))]})]})]}),u("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"}),u("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(Ee,{className:"h-3.5 w-3.5 animate-spin"}):o(Fy,{className:"h-3.5 w-3.5"}),s?"Creating…":"Create"]})]})]})})}function Mz(){return o("div",{className:"flex flex-col p-4",children:o(Id,{tabs:[{id:"storage",label:"Storage",icon:Us,content:o(K7,{})},{id:"backup",label:"Backup",icon:Fy,content:o(Sz,{})}]})})}function Ez(){const{data:e,isLoading:t}=Dn(void 0,{staleTime:3e4}),n=(e??[]).find(s=>s.isHub&&s.isOnline),r=n?.addons.map(s=>s.id)??[];return o(rt,{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(Ur,{nodeId:n.id,addonIds:r,level:"global"}):u("div",{className:"flex flex-col items-center justify-center text-muted-foreground text-sm gap-2 py-12",children:[o(Gt,{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 Iz(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 Az({nodeId:e,addons:t,isHub:n}){const r=ke(),s=Xe(),[a,i]=_(null),[l,c]=_(null),[d,f]=_(!1),[p,h]=_(null),[m,g]=_(0),b=ne(null),x=Na(),y=Ob(),w=()=>{r.invalidateQueries({queryKey:[["nodes","topology"]]})},v=async E=>{i(E);try{await x.mutateAsync({nodeId:e,addonId:E}),w()}catch(A){console.error("Failed to restart addon:",A)}finally{i(null)}},N=async E=>{if(await s({title:"Uninstall addon",message:`Remove "${E}" from ${e}? The addon directory will be deleted on disk.`,confirmLabel:"Uninstall",variant:"danger"})){c(E);try{await y.mutateAsync({nodeId:e,addonId:E}),w()}catch(I){console.error("Failed to uninstall addon:",I)}finally{c(null)}}},S=u("div",{className:"flex items-center gap-2 mb-2",children:[o("input",{ref:b,type:"file",accept:".tgz,.tar.gz",className:"hidden",onChange:async E=>{const A=E.target.files?.[0];if(A){E.target.value="",h(null),f(!0),g(0);try{const I=localStorage.getItem("camstack_admin_token");await Iz({file:A,nodeId:e,token:I,onProgress:g}),w()}catch(I){h(I instanceof Error?I.message:String(I))}finally{f(!1),g(0)}}}}),u("button",{onClick:()=>b.current?.click(),disabled:d,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:[d?o(Ee,{className:"h-3 w-3 animate-spin"}):o(La,{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 t.length===0?u("div",{children:[S,o("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No addons on this node"})]}):u("div",{children:[S,u("table",{className:"w-full text-xs",children:[o("thead",{children:u("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:"Capabilities"}),o("th",{className:"py-2 font-medium",children:"Status"}),o("th",{className:"py-2 font-medium w-16"})]})}),o("tbody",{children:t.map(E=>u("tr",{className:"border-t border-border/50",children:[o("td",{className:"py-2 font-medium",children:E.id}),o("td",{className:"py-2",children:o("div",{className:"flex flex-wrap gap-1",children:E.capabilities.length>0?E.capabilities.map(A=>o("span",{className:"text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400",children:A},A)):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 ${E.status==="running"?"bg-success/10 text-success":E.status==="error"?"bg-destructive/10 text-destructive":"bg-muted text-muted-foreground"}`,children:E.status})}),o("td",{className:"py-2",children:u("div",{className:"flex items-center gap-1 justify-end",children:[o("button",{onClick:()=>v(E.id),disabled:a===E.id||l===E.id,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:`Restart ${E.id}`,children:o(xt,{className:`h-3 w-3 ${a===E.id?"animate-spin":""}`})}),o("button",{onClick:()=>N(E.id),disabled:a===E.id||l===E.id,className:"p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50",title:`Uninstall ${E.id}`,children:l===E.id?o(Ee,{className:"h-3 w-3 animate-spin"}):o(Ge,{className:"h-3 w-3"})})]})})]},E.id))})]})]})}function _z(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 Pz({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 $z=["trace","debug","info","warn","error"];function Dz({proc:e,nodeId:t,defaultExpanded:n,activePanel:r,onTogglePanel:s}){const a=e.services??[],i=a.length===1,[l,c]=_(i||n),[d,f]=_(null),[p,h]=_("info"),m=e.name.includes("(core)"),g=Na(),b=zb(),x=Hb(),y=async N=>{f(N);try{await g.mutateAsync({nodeId:t,addonId:N})}catch(k){console.error("Failed to restart addon:",k)}finally{f(null)}},w=async()=>{f(e.name);try{await b.mutateAsync({nodeId:t,processName:e.name})}catch(N){console.error("Failed to restart process:",N)}finally{f(null)}},v=async N=>{const k=`${t}/${e.name}`;try{await x.mutateAsync({nodeId:k,level:N}),h(N)}catch(S){console.error("Failed to set log level:",S)}};return u("div",{className:"border border-border/50 rounded-lg overflow-hidden",children:[u("div",{role:i?void 0:"button",tabIndex:i?void 0:0,onClick:i?void 0:()=>c(!l),onKeyDown:i?void 0:N=>{(N.key==="Enter"||N.key===" ")&&c(!l)},className:`flex items-center gap-2 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${i?"":"hover:bg-muted/40 cursor-pointer"}`,children:[i?o("span",{className:"h-3 w-3 shrink-0"}):l?o(wt,{className:"h-3 w-3 text-muted-foreground shrink-0"}):o(Et,{className:"h-3 w-3 text-muted-foreground shrink-0"}),m?o(cn,{className:"h-3.5 w-3.5 text-primary shrink-0"}):o($a,{className:"h-3.5 w-3.5 text-amber-500 shrink-0"}),o("span",{className:"text-xs font-semibold flex-1",children:e.name}),u("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:["PID ",e.pid]}),o(Pz,{state:e.state}),u("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[e.cpuPercent,"% CPU"]}),o("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:kt(e.memoryRss)}),o("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:_z(e.uptimeSeconds)}),!m&&u("div",{className:"flex items-center gap-1",onClick:N=>N.stopPropagation(),children:[u($m,{children:[o(Dm,{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(Tm,{align:"end",className:"min-w-[70px] py-0.5",children:$z.map(N=>o(Lm,{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(xt,{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=>u("div",{children:[u("div",{className:"flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors",children:[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&&u("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&&u("span",{className:"text-[9px] text-muted-foreground",children:["+",N.capabilities.length-3]})]}),u("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(nt,{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(Cd,{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(xt,{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(Yt,{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(ir,{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 Tz({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(Dz,{proc:a,nodeId:e,defaultExpanded:i===0,activePanel:n,onTogglePanel:s},a.name))})}function Lz(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 Rz(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function Oz({nodeId:e}){const t=ke(),n=Xe(),[r,s]=_("all"),a=Or("metrics.node-processes-snapshot",k=>k.nodeId===e),{data:i}=Lb({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]),f=q(()=>{const k=c.filter(E=>E.classification==="ghost"),S=new Map;for(const E of k)S.has(E.ppid)||S.set(E.ppid,[]),S.get(E.ppid).push(E);return[...S.entries()].filter(([,E])=>E.length>1).map(([E,A])=>({ppid:E,children:A})).sort((E,A)=>A.children.length-E.children.length)},[c]),p=Rb({onSettled:()=>{t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]})}}),h=q(()=>{const k=new Map;for(const S of c)k.set(S.pid,S.classification);return k},[c]),m=async(k,S)=>{if(k.classification==="root"||k.classification==="system")return;const E=k.classification==="ghost"?"ghost":k.addonId??"process",A=S?"SIGKILL":"SIGTERM";await n({title:`Send ${A}?`,message:`Target pid ${k.pid} (${E}) on node ${e}.`,confirmLabel:`Send ${A}`,variant:"danger"})&&p.mutate({nodeId:e,pid:k.pid,force:S})},g=async(k,S)=>{try{await p.mutateAsync({nodeId:e,pid:k,force:S})}catch{}},b=async k=>{const S=h.get(k.ppid);if(S==="root"||S==="system"){await n({title:"Cannot kill protected ancestor",message:S==="root"?`pid ${k.ppid} is the current node supervisor. Restart the node via the cluster page instead.`:`pid ${k.ppid} is a system ancestor (concurrently / vite / npm wrapper). Killing it would tear down the dev tree.`,confirmLabel:"OK",cancelLabel:"Close",variant:"warning"});return}await n({title:`Kill ghost parent + ${k.children.length} child(ren)?`,message:`SIGKILL parent pid ${k.ppid} and SIGTERM ${k.children.length} ghost child(ren) on node ${e}.`,confirmLabel:"Kill all",variant:"danger"})&&(await Promise.all([g(k.ppid,!0),...k.children.map(A=>g(A.pid,!1))]),t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]}))},x=async()=>{const k=c.filter(E=>E.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(E=>g(E.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 u("div",{className:"space-y-4",children:[u("div",{className:"flex items-start justify-between gap-4",children:[u("p",{className:"text-[11px] text-foreground-subtle",children:["ps"," scan + kernel `$process.list` cross-reference. Ghosts = camstack-shaped commands with no managed binding (usually orphaned to ppid=1). Refreshes every 10s."]}),u("button",{type:"button",onClick:()=>t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]}),className:"inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover",children:[o(ft,{className:"h-3 w-3"})," Refresh"]})]}),u("div",{className:"grid grid-cols-4 gap-3",children:[u("div",{className:"rounded-lg border border-border p-3",children:[o("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"Root"}),o("div",{className:"text-xl font-semibold text-foreground",children:v})]}),u("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})]}),u("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})]}),u("div",{className:`rounded-lg border p-3 ${y>0?"border-destructive/40 bg-destructive/5":"border-border"}`,children:[u("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle flex items-center gap-1",children:[y>0&&o(ss,{className:"h-3 w-3 text-destructive"})," Ghosts"]}),o("div",{className:`text-xl font-semibold ${y>0?"text-destructive":"text-foreground"}`,children:y})]})]}),f.length>0&&u("div",{className:"rounded-lg border border-amber-500/40 bg-amber-500/5 p-3",children:[u("div",{className:"flex items-center gap-1 text-[11px] font-semibold text-amber-400 mb-2",children:[o(dt,{className:"h-3 w-3"})," Recurring ghost parents (",f.length,")"]}),o("div",{className:"space-y-1.5",children:f.map(k=>u("div",{className:"text-[11px] text-foreground flex items-center justify-between gap-2",children:[u("div",{className:"flex items-center gap-2",children:[u("span",{className:"font-mono text-foreground-subtle",children:["ppid ",k.ppid]}),u("span",{children:["→ ",k.children.length," ghost(s)"]})]}),u("button",{type:"button",disabled:p.isPending,onClick:()=>{b(k)},className:"inline-flex items-center gap-1 rounded border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] text-amber-400 hover:bg-amber-500/20 disabled:opacity-30",children:[o(ss,{className:"h-3 w-3"})," Kill parent + ",k.children.length]})]},k.ppid))})]}),u("div",{className:"flex items-center justify-between gap-2 text-[11px]",children:[u("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-foreground-subtle",children:"Filter:"}),u("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,")"]}),u("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&&u("button",{type:"button",disabled:p.isPending,onClick:()=>{x()},className:"inline-flex items-center gap-1 rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive/20 disabled:opacity-30",children:[o(ss,{className:"h-3 w-3"})," Kill all ",y," ghost(s)"]})]}),o("div",{className:"rounded-lg border border-border overflow-hidden",children:u("table",{className:"w-full text-xs",children:[o("thead",{className:"bg-surface",children:u("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"})]})}),u("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=>u("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}),u("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:Rz(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:kt(k.memoryRssBytes)}),o("td",{className:"px-3 py-2 text-right text-foreground-subtle",children:Lz(k.uptimeSec)}),o("td",{className:"px-3 py-2 text-right",children:u("div",{className:"inline-flex gap-1",children:[u("button",{type:"button",disabled:p.isPending||k.classification==="root"||k.classification==="system",onClick:()=>{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(Ge,{className:"h-3 w-3"})," Term"]}),u("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(ss,{className:"h-3 w-3"})," Kill"]})]})})]},k.pid))]})]})}),p.isError&&u("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive",children:["Kill failed: ",p.error instanceof Error?p.error.message:"unknown"]})]})}function zz({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(Ur,{nodeId:e,addonIds:t,level:"global"})})}function Bz({nodeId:e,addons:t}){const n=ke(),{data:r,isLoading:s}=ex({nodeId:e}),a=q(()=>{const l=new Map;for(const c of t)for(const d of c.capabilities){const f=l.get(d)??[];f.push(c.id),l.set(d,f)}return[...l.entries()].sort(([c],[d])=>c.localeCompare(d)).map(([c,d])=>({capName:c,providers:d}))},[t]),i=tx({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"}):u("table",{className:"w-full text-xs",children:[o("thead",{children:u("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 f=r?.[l]??c[0]??"",p=c.length===1;return u("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:f,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 Fz(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 jz(e){const[t,n]=_(!1),[r,s]=_(e.name),a=ke(),i=Fb({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)}},f=[["Node ID",o("span",{className:"font-mono text-xs",children:e.nodeId})],["Display Name",t?u("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(Mt,{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(Be,{className:"h-3.5 w-3.5"})})]}):u("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(qr,{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",u("span",{className:"text-xs",children:[e.platform," / ",e.arch]})],["CPU",u("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:Fz(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&&f.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&&f.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:f.map(([p,h],m)=>u("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 Hz({node:e}){const[t,n]=_("info"),r=e.processes??[],s=e.addons.map(a=>a.id);return e.isOnline?u("div",{className:"border border-border rounded-xl overflow-hidden",children:[u("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/30 border-b border-border",children:[o("div",{className:"w-2.5 h-2.5 rounded-full bg-success"}),o("span",{className:"text-sm font-semibold",children:e.name}),u("span",{className:"text-xs text-muted-foreground",children:[e.cpuModel??e.platform," · ",e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:""," · ",e.arch]}),e.engines.map(a=>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)),u("div",{className:"ml-auto flex gap-3 text-xs text-muted-foreground",children:[u("span",{className:"flex items-center gap-1",children:[o(pt,{className:"h-3 w-3"})," ",e.cpuPercent,"%"]}),u("span",{className:"flex items-center gap-1",children:[o(kd,{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))}),u("div",{className:"px-4 py-2",children:[t==="info"&&o(jz,{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(Az,{nodeId:e.id,addons:e.addons,isHub:e.isHub}),t==="forks"&&o(Tz,{nodeId:e.id,processes:r}),t==="processes"&&o(Oz,{nodeId:e.id}),t==="settings"&&o(zz,{nodeId:e.id,addonIds:s}),t==="capabilities"&&o(Bz,{nodeId:e.id,addons:e.addons})]})]}):u("div",{className:"border border-border rounded-xl overflow-hidden opacity-60",children:[u("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/30",children:[o("div",{className:"w-2.5 h-2.5 rounded-full bg-destructive"}),o("span",{className:"text-sm font-semibold",children:e.name}),u("span",{className:"text-xs text-muted-foreground",children:[e.cpuModel??e.platform," · ",e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:""," · ",e.arch]}),e.engines.map(a=>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"})]}),u("div",{className:"px-4 py-3 text-xs text-muted-foreground",children:[e.addons.length," addon",e.addons.length!==1?"s":""," assigned — will resume when node reconnects"]})]})}function Vz({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(Hz,{node:n},n.id))})}function Qe(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=Qe(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var qz={value:()=>{}};function Ha(){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 Ps(n)}function Ps(e){this._=e}function Uz(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}})}Ps.prototype=Ha.prototype={constructor:Ps,on:function(e,t){var n=this._,r=Uz(e+"",n),s,a=-1,i=r.length;if(arguments.length<2){for(;++a<i;)if((s=(e=r[a]).type)&&(s=Qz(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]=Zp(n[s],e.name,t);else if(t==null)for(s in n)n[s]=Zp(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 Ps(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 Qz(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function Zp(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=qz,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Ol="http://www.w3.org/1999/xhtml";const Xp={svg:"http://www.w3.org/2000/svg",xhtml:Ol,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Va(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Xp.hasOwnProperty(t)?{space:Xp[t],local:e}:e}function Kz(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Ol&&t.documentElement.namespaceURI===Ol?t.createElement(e):t.createElementNS(n,e)}}function Gz(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function G0(e){var t=Va(e);return(t.local?Gz:Kz)(t)}function Wz(){}function Ad(e){return e==null?Wz:function(){return this.querySelector(e)}}function Yz(e){typeof e!="function"&&(e=Ad(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,f=0;f<i;++f)(c=a[f])&&(d=e.call(c,c.__data__,f,a))&&("__data__"in c&&(d.__data__=c.__data__),l[f]=d);return new ht(r,this._parents)}function Zz(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Xz(){return[]}function W0(e){return e==null?Xz:function(){return this.querySelectorAll(e)}}function Jz(e){return function(){return Zz(e.apply(this,arguments))}}function eB(e){typeof e=="function"?e=Jz(e):e=W0(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 ht(r,s)}function Y0(e){return function(){return this.matches(e)}}function Z0(e){return function(t){return t.matches(e)}}var tB=Array.prototype.find;function nB(e){return function(){return tB.call(this.children,e)}}function rB(){return this.firstElementChild}function oB(e){return this.select(e==null?rB:nB(typeof e=="function"?e:Z0(e)))}var sB=Array.prototype.filter;function aB(){return Array.from(this.children)}function iB(e){return function(){return sB.call(this.children,e)}}function lB(e){return this.selectAll(e==null?aB:iB(typeof e=="function"?e:Z0(e)))}function cB(e){typeof e!="function"&&(e=Y0(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 ht(r,this._parents)}function X0(e){return new Array(e.length)}function dB(){return new ht(this._enter||this._groups.map(X0),this._parents)}function Js(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Js.prototype={constructor:Js,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 uB(e){return function(){return e}}function pB(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 Js(e,a[i]);for(;i<c;++i)(l=t[i])&&(s[i]=l)}function fB(e,t,n,r,s,a,i){var l,c,d=new Map,f=t.length,p=a.length,h=new Array(f),m;for(l=0;l<f;++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 Js(e,a[l]);for(l=0;l<f;++l)(c=t[l])&&d.get(h[l])===c&&(s[l]=c)}function hB(e){return e.__data__}function mB(e,t){if(!arguments.length)return Array.from(this,hB);var n=t?fB:pB,r=this._parents,s=this._groups;typeof e!="function"&&(e=uB(e));for(var a=s.length,i=new Array(a),l=new Array(a),c=new Array(a),d=0;d<a;++d){var f=r[d],p=s[d],h=p.length,m=gB(e.call(f,f&&f.__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(f,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 ht(i,r),i._enter=l,i._exit=c,i}function gB(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function bB(){return new ht(this._exit||this._groups.map(X0),this._parents)}function xB(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 yB(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],f=r[c],p=d.length,h=l[c]=new Array(p),m,g=0;g<p;++g)(m=d[g]||f[g])&&(h[g]=m);for(;c<s;++c)l[c]=n[c];return new ht(l,this._parents)}function vB(){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 wB(e){e||(e=NB);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,f=0;f<l;++f)(d=i[f])&&(c[f]=d);c.sort(t)}return new ht(s,this._parents).order()}function NB(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function kB(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function SB(){return Array.from(this)}function CB(){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 MB(){let e=0;for(const t of this)++e;return e}function EB(){return!this.node()}function IB(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 AB(e){return function(){this.removeAttribute(e)}}function _B(e){return function(){this.removeAttributeNS(e.space,e.local)}}function PB(e,t){return function(){this.setAttribute(e,t)}}function $B(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function DB(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function TB(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 LB(e,t){var n=Va(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?_B:AB:typeof t=="function"?n.local?TB:DB:n.local?$B:PB)(n,t))}function J0(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function RB(e){return function(){this.style.removeProperty(e)}}function OB(e,t,n){return function(){this.style.setProperty(e,t,n)}}function zB(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function BB(e,t,n){return arguments.length>1?this.each((t==null?RB:typeof t=="function"?zB:OB)(e,t,n??"")):Ir(this.node(),e)}function Ir(e,t){return e.style.getPropertyValue(t)||J0(e).getComputedStyle(e,null).getPropertyValue(t)}function FB(e){return function(){delete this[e]}}function jB(e,t){return function(){this[e]=t}}function HB(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function VB(e,t){return arguments.length>1?this.each((t==null?FB:typeof t=="function"?HB:jB)(e,t)):this.node()[e]}function ev(e){return e.trim().split(/^|\s+/)}function _d(e){return e.classList||new tv(e)}function tv(e){this._node=e,this._names=ev(e.getAttribute("class")||"")}tv.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 nv(e,t){for(var n=_d(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function rv(e,t){for(var n=_d(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function qB(e){return function(){nv(this,e)}}function UB(e){return function(){rv(this,e)}}function QB(e,t){return function(){(t.apply(this,arguments)?nv:rv)(this,e)}}function KB(e,t){var n=ev(e+"");if(arguments.length<2){for(var r=_d(this.node()),s=-1,a=n.length;++s<a;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?QB:t?qB:UB)(n,t))}function GB(){this.textContent=""}function WB(e){return function(){this.textContent=e}}function YB(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function ZB(e){return arguments.length?this.each(e==null?GB:(typeof e=="function"?YB:WB)(e)):this.node().textContent}function XB(){this.innerHTML=""}function JB(e){return function(){this.innerHTML=e}}function eF(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function tF(e){return arguments.length?this.each(e==null?XB:(typeof e=="function"?eF:JB)(e)):this.node().innerHTML}function nF(){this.nextSibling&&this.parentNode.appendChild(this)}function rF(){return this.each(nF)}function oF(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function sF(){return this.each(oF)}function aF(e){var t=typeof e=="function"?e:G0(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function iF(){return null}function lF(e,t){var n=typeof e=="function"?e:G0(e),r=t==null?iF:typeof t=="function"?t:Ad(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function cF(){var e=this.parentNode;e&&e.removeChild(this)}function dF(){return this.each(cF)}function uF(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function pF(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function fF(e){return this.select(e?pF:uF)}function hF(e){return arguments.length?this.property("__data__",e):this.node().__data__}function mF(e){return function(t){e.call(this,t,this.__data__)}}function gF(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 bF(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 xF(e,t,n){return function(){var r=this.__on,s,a=mF(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 yF(e,t,n){var r=gF(e+""),s,a=r.length,i;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,d=l.length,f;c<d;++c)for(s=0,f=l[c];s<a;++s)if((i=r[s]).type===f.type&&i.name===f.name)return f.value}return}for(l=t?xF:bF,s=0;s<a;++s)this.each(l(r[s],t,n));return this}function ov(e,t,n){var r=J0(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 vF(e,t){return function(){return ov(this,e,t)}}function wF(e,t){return function(){return ov(this,e,t.apply(this,arguments))}}function NF(e,t){return this.each((typeof t=="function"?wF:vF)(e,t))}function*kF(){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 sv=[null];function ht(e,t){this._groups=e,this._parents=t}function Ho(){return new ht([[document.documentElement]],sv)}function SF(){return this}ht.prototype=Ho.prototype={constructor:ht,select:Yz,selectAll:eB,selectChild:oB,selectChildren:lB,filter:cB,data:mB,enter:dB,exit:bB,join:xB,merge:yB,selection:SF,order:vB,sort:wB,call:kB,nodes:SB,node:CB,size:MB,empty:EB,each:IB,attr:LB,style:BB,property:VB,classed:KB,text:ZB,html:tF,raise:rF,lower:sF,append:aF,insert:lF,remove:dF,clone:fF,datum:hF,on:yF,dispatch:NF,[Symbol.iterator]:kF};function lt(e){return typeof e=="string"?new ht([[document.querySelector(e)]],[document.documentElement]):new ht([[e]],sv)}function CF(e){let t;for(;t=e.sourceEvent;)e=t;return e}function _t(e,t){if(e=CF(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 MF={passive:!1},vo={capture:!0,passive:!1};function Vi(e){e.stopImmediatePropagation()}function yr(e){e.preventDefault(),e.stopImmediatePropagation()}function av(e){var t=e.document.documentElement,n=lt(e).on("dragstart.drag",yr,vo);"onselectstart"in t?n.on("selectstart.drag",yr,vo):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function iv(e,t){var n=e.document.documentElement,r=lt(e).on("dragstart.drag",null);t&&(r.on("click.drag",yr,vo),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 ms=e=>()=>e;function zl(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:a,x:i,y:l,dx:c,dy:d,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value: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:f}})}zl.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function EF(e){return!e.ctrlKey&&!e.button}function IF(){return this.parentNode}function AF(e,t){return t??{x:e.x,y:e.y}}function _F(){return navigator.maxTouchPoints||"ontouchstart"in this}function lv(){var e=EF,t=IF,n=AF,r=_F,s={},a=Ha("start","drag","end"),i=0,l,c,d,f,p=0;function h(N){N.on("mousedown.drag",m).filter(r).on("touchstart.drag",x).on("touchmove.drag",y,MF).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(!(f||!e.call(this,N,k))){var S=v(this,t.call(this,N,k),N,k,"mouse");S&&(lt(N.view).on("mousemove.drag",g,vo).on("mouseup.drag",b,vo),av(N.view),Vi(N),d=!1,l=N.clientX,c=N.clientY,S("start",N))}}function g(N){if(yr(N),!d){var k=N.clientX-l,S=N.clientY-c;d=k*k+S*S>p}s.mouse("drag",N)}function b(N){lt(N.view).on("mousemove.drag mouseup.drag",null),iv(N.view,d),yr(N),s.mouse("end",N)}function x(N,k){if(e.call(this,N,k)){var S=N.changedTouches,E=t.call(this,N,k),A=S.length,I,B;for(I=0;I<A;++I)(B=v(this,E,N,k,S[I].identifier,S[I]))&&(Vi(N),B("start",N,S[I]))}}function y(N){var k=N.changedTouches,S=k.length,E,A;for(E=0;E<S;++E)(A=s[k[E].identifier])&&(yr(N),A("drag",N,k[E]))}function w(N){var k=N.changedTouches,S=k.length,E,A;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),E=0;E<S;++E)(A=s[k[E].identifier])&&(Vi(N),A("end",N,k[E]))}function v(N,k,S,E,A,I){var B=a.copy(),$=_t(I||S,k),z,R,M;if((M=n.call(N,new zl("beforestart",{sourceEvent:S,target:h,identifier:A,active:i,x:$[0],y:$[1],dx:0,dy:0,dispatch:B}),E))!=null)return z=M.x-$[0]||0,R=M.y-$[1]||0,function T(P,L,O){var j=$,F;switch(P){case"start":s[A]=T,F=i++;break;case"end":delete s[A],--i;case"drag":$=_t(O||L,k),F=i;break}B.call(P,N,new zl(P,{sourceEvent:L,subject:M,target:h,identifier:A,active:F,x:$[0]+z,y:$[1]+R,dx:$[0]-j[0],dy:$[1]-j[1],dispatch:B}),E)}}return h.filter=function(N){return arguments.length?(e=typeof N=="function"?N:ms(!!N),h):e},h.container=function(N){return arguments.length?(t=typeof N=="function"?N:ms(N),h):t},h.subject=function(N){return arguments.length?(n=typeof N=="function"?N:ms(N),h):n},h.touchable=function(N){return arguments.length?(r=typeof N=="function"?N:ms(!!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 Pd(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function cv(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Vo(){}var wo=.7,ea=1/wo,vr="\\s*([+-]?\\d+)\\s*",No="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Qt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",PF=/^#([0-9a-f]{3,8})$/,$F=new RegExp(`^rgb\\(${vr},${vr},${vr}\\)$`),DF=new RegExp(`^rgb\\(${Qt},${Qt},${Qt}\\)$`),TF=new RegExp(`^rgba\\(${vr},${vr},${vr},${No}\\)$`),LF=new RegExp(`^rgba\\(${Qt},${Qt},${Qt},${No}\\)$`),RF=new RegExp(`^hsl\\(${No},${Qt},${Qt}\\)$`),OF=new RegExp(`^hsla\\(${No},${Qt},${Qt},${No}\\)$`),Jp={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};Pd(Vo,Wn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ef,formatHex:ef,formatHex8:zF,formatHsl:BF,formatRgb:tf,toString:tf});function ef(){return this.rgb().formatHex()}function zF(){return this.rgb().formatHex8()}function BF(){return dv(this).formatHsl()}function tf(){return this.rgb().formatRgb()}function Wn(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=PF.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?nf(t):n===3?new tt(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?gs(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?gs(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=$F.exec(e))?new tt(t[1],t[2],t[3],1):(t=DF.exec(e))?new tt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=TF.exec(e))?gs(t[1],t[2],t[3],t[4]):(t=LF.exec(e))?gs(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=RF.exec(e))?sf(t[1],t[2]/100,t[3]/100,1):(t=OF.exec(e))?sf(t[1],t[2]/100,t[3]/100,t[4]):Jp.hasOwnProperty(e)?nf(Jp[e]):e==="transparent"?new tt(NaN,NaN,NaN,0):null}function nf(e){return new tt(e>>16&255,e>>8&255,e&255,1)}function gs(e,t,n,r){return r<=0&&(e=t=n=NaN),new tt(e,t,n,r)}function FF(e){return e instanceof Vo||(e=Wn(e)),e?(e=e.rgb(),new tt(e.r,e.g,e.b,e.opacity)):new tt}function Bl(e,t,n,r){return arguments.length===1?FF(e):new tt(e,t,n,r??1)}function tt(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Pd(tt,Bl,cv(Vo,{brighter(e){return e=e==null?ea:Math.pow(ea,e),new tt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?wo:Math.pow(wo,e),new tt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new tt(qn(this.r),qn(this.g),qn(this.b),ta(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:rf,formatHex:rf,formatHex8:jF,formatRgb:of,toString:of}));function rf(){return`#${jn(this.r)}${jn(this.g)}${jn(this.b)}`}function jF(){return`#${jn(this.r)}${jn(this.g)}${jn(this.b)}${jn((isNaN(this.opacity)?1:this.opacity)*255)}`}function of(){const e=ta(this.opacity);return`${e===1?"rgb(":"rgba("}${qn(this.r)}, ${qn(this.g)}, ${qn(this.b)}${e===1?")":`, ${e})`}`}function ta(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function qn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function jn(e){return e=qn(e),(e<16?"0":"")+e.toString(16)}function sf(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Pt(e,t,n,r)}function dv(e){if(e instanceof Pt)return new Pt(e.h,e.s,e.l,e.opacity);if(e instanceof Vo||(e=Wn(e)),!e)return new Pt;if(e instanceof Pt)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 Pt(i,l,c,e.opacity)}function HF(e,t,n,r){return arguments.length===1?dv(e):new Pt(e,t,n,r??1)}function Pt(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Pd(Pt,HF,cv(Vo,{brighter(e){return e=e==null?ea:Math.pow(ea,e),new Pt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?wo:Math.pow(wo,e),new Pt(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 tt(qi(e>=240?e-240:e+120,s,r),qi(e,s,r),qi(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Pt(af(this.h),bs(this.s),bs(this.l),ta(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=ta(this.opacity);return`${e===1?"hsl(":"hsla("}${af(this.h)}, ${bs(this.s)*100}%, ${bs(this.l)*100}%${e===1?")":`, ${e})`}`}}));function af(e){return e=(e||0)%360,e<0?e+360:e}function bs(e){return Math.max(0,Math.min(1,e||0))}function qi(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 $d=e=>()=>e;function VF(e,t){return function(n){return e+n*t}}function qF(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 UF(e){return(e=+e)==1?uv:function(t,n){return n-t?qF(t,n,e):$d(isNaN(t)?n:t)}}function uv(e,t){var n=t-e;return n?VF(e,n):$d(isNaN(e)?t:e)}const na=(function e(t){var n=UF(t);function r(s,a){var i=n((s=Bl(s)).r,(a=Bl(a)).r),l=n(s.g,a.g),c=n(s.b,a.b),d=uv(s.opacity,a.opacity);return function(f){return s.r=i(f),s.g=l(f),s.b=c(f),s.opacity=d(f),s+""}}return r.gamma=e,r})(1);function QF(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 KF(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function GF(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]=fo(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 WF(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Ht(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function YF(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]=fo(e[s],t[s]):r[s]=t[s];return function(a){for(s in n)r[s]=n[s](a);return r}}var Fl=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ui=new RegExp(Fl.source,"g");function ZF(e){return function(){return e}}function XF(e){return function(t){return e(t)+""}}function pv(e,t){var n=Fl.lastIndex=Ui.lastIndex=0,r,s,a,i=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Fl.exec(e))&&(s=Ui.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:Ht(r,s)})),n=Ui.lastIndex;return n<t.length&&(a=t.slice(n),l[i]?l[i]+=a:l[++i]=a),l.length<2?c[0]?XF(c[0].x):ZF(t):(t=c.length,function(d){for(var f=0,p;f<t;++f)l[(p=c[f]).i]=p.x(d);return l.join("")})}function fo(e,t){var n=typeof t,r;return t==null||n==="boolean"?$d(t):(n==="number"?Ht:n==="string"?(r=Wn(t))?(t=r,na):pv:t instanceof Wn?na:t instanceof Date?WF:KF(t)?QF:Array.isArray(t)?GF:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?YF:Ht)(e,t)}var lf=180/Math.PI,jl={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function fv(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)*lf,skewX:Math.atan(c)*lf,scaleX:i,scaleY:l}}var xs;function JF(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?jl:fv(t.a,t.b,t.c,t.d,t.e,t.f)}function ej(e){return e==null||(xs||(xs=document.createElementNS("http://www.w3.org/2000/svg","g")),xs.setAttribute("transform",e),!(e=xs.transform.baseVal.consolidate()))?jl:(e=e.matrix,fv(e.a,e.b,e.c,e.d,e.e,e.f))}function hv(e,t,n,r){function s(d){return d.length?d.pop()+" ":""}function a(d,f,p,h,m,g){if(d!==p||f!==h){var b=m.push("translate(",null,t,null,n);g.push({i:b-4,x:Ht(d,p)},{i:b-2,x:Ht(f,h)})}else(p||h)&&m.push("translate("+p+t+h+n)}function i(d,f,p,h){d!==f?(d-f>180?f+=360:f-d>180&&(d+=360),h.push({i:p.push(s(p)+"rotate(",null,r)-2,x:Ht(d,f)})):f&&p.push(s(p)+"rotate("+f+r)}function l(d,f,p,h){d!==f?h.push({i:p.push(s(p)+"skewX(",null,r)-2,x:Ht(d,f)}):f&&p.push(s(p)+"skewX("+f+r)}function c(d,f,p,h,m,g){if(d!==p||f!==h){var b=m.push(s(m)+"scale(",null,",",null,")");g.push({i:b-4,x:Ht(d,p)},{i:b-2,x:Ht(f,h)})}else(p!==1||h!==1)&&m.push(s(m)+"scale("+p+","+h+")")}return function(d,f){var p=[],h=[];return d=e(d),f=e(f),a(d.translateX,d.translateY,f.translateX,f.translateY,p,h),i(d.rotate,f.rotate,p,h),l(d.skewX,f.skewX,p,h),c(d.scaleX,d.scaleY,f.scaleX,f.scaleY,p,h),d=f=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 tj=hv(JF,"px, ","px)","deg)"),nj=hv(ej,", ",")",")"),rj=1e-12;function cf(e){return((e=Math.exp(e))+1/e)/2}function oj(e){return((e=Math.exp(e))-1/e)/2}function sj(e){return((e=Math.exp(2*e))-1)/(e+1)}const $s=(function e(t,n,r){function s(a,i){var l=a[0],c=a[1],d=a[2],f=i[0],p=i[1],h=i[2],m=f-l,g=p-c,b=m*m+g*g,x,y;if(b<rj)y=Math.log(h/d)/t,x=function(E){return[l+E*m,c+E*g,d*Math.exp(t*E*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),S=Math.log(Math.sqrt(N*N+1)-N);y=(S-k)/t,x=function(E){var A=E*y,I=cf(k),B=d/(n*w)*(I*sj(t*A+k)-oj(k));return[l+B*m,c+B*g,d*I/cf(t*A+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 Ar=0,ro=0,Jr=0,mv=1e3,ra,oo,oa=0,Yn=0,qa=0,ko=typeof performance=="object"&&performance.now?performance:Date,gv=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Dd(){return Yn||(gv(aj),Yn=ko.now()+qa)}function aj(){Yn=0}function sa(){this._call=this._time=this._next=null}sa.prototype=bv.prototype={constructor:sa,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Dd():+n)+(t==null?0:+t),!this._next&&oo!==this&&(oo?oo._next=this:ra=this,oo=this),this._call=e,this._time=n,Hl()},stop:function(){this._call&&(this._call=null,this._time=1/0,Hl())}};function bv(e,t,n){var r=new sa;return r.restart(e,t,n),r}function ij(){Dd(),++Ar;for(var e=ra,t;e;)(t=Yn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ar}function df(){Yn=(oa=ko.now())+qa,Ar=ro=0;try{ij()}finally{Ar=0,cj(),Yn=0}}function lj(){var e=ko.now(),t=e-oa;t>mv&&(qa-=t,oa=e)}function cj(){for(var e,t=ra,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:ra=n);oo=e,Hl(r)}function Hl(e){if(!Ar){ro&&(ro=clearTimeout(ro));var t=e-Yn;t>24?(e<1/0&&(ro=setTimeout(df,e-ko.now()-qa)),Jr&&(Jr=clearInterval(Jr))):(Jr||(oa=ko.now(),Jr=setInterval(lj,mv)),Ar=1,gv(df))}}function uf(e,t,n){var r=new sa;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var dj=Ha("start","end","cancel","interrupt"),uj=[],xv=0,pf=1,Vl=2,Ds=3,ff=4,ql=5,Ts=6;function Ua(e,t,n,r,s,a){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;pj(e,n,{name:t,index:r,group:s,on:dj,tween:uj,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:xv})}function Td(e,t){var n=zt(e,t);if(n.state>xv)throw new Error("too late; already scheduled");return n}function Zt(e,t){var n=zt(e,t);if(n.state>Ds)throw new Error("too late; already running");return n}function zt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function pj(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=bv(a,0,n.time);function a(d){n.state=pf,n.timer.restart(i,n.delay,n.time),n.delay<=d&&i(d-n.delay)}function i(d){var f,p,h,m;if(n.state!==pf)return c();for(f in r)if(m=r[f],m.name===n.name){if(m.state===Ds)return uf(i);m.state===ff?(m.state=Ts,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[f]):+f<t&&(m.state=Ts,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[f])}if(uf(function(){n.state===Ds&&(n.state=ff,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=Vl,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Vl){for(n.state=Ds,s=new Array(h=n.tween.length),f=0,p=-1;f<h;++f)(m=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(s[++p]=m);s.length=p+1}}function l(d){for(var f=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(c),n.state=ql,1),p=-1,h=s.length;++p<h;)s[p].call(e,f);n.state===ql&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Ts,n.timer.stop(),delete r[t];for(var d in r)return;delete e.__transition}}function Ls(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>Vl&&r.state<ql,r.state=Ts,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}a&&delete e.__transition}}function fj(e){return this.each(function(){Ls(this,e)})}function hj(e,t){var n,r;return function(){var s=Zt(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 mj(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var a=Zt(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 gj(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=zt(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?hj:mj)(n,e,t))}function Ld(e,t,n){var r=e._id;return e.each(function(){var s=Zt(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return zt(s,r).value[t]}}function yv(e,t){var n;return(typeof t=="number"?Ht:t instanceof Wn?na:(n=Wn(t))?(t=n,na):pv)(e,t)}function bj(e){return function(){this.removeAttribute(e)}}function xj(e){return function(){this.removeAttributeNS(e.space,e.local)}}function yj(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 vj(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 wj(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 Nj(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 kj(e,t){var n=Va(e),r=n==="transform"?nj:yv;return this.attrTween(e,typeof t=="function"?(n.local?Nj:wj)(n,r,Ld(this,"attr."+e,t)):t==null?(n.local?xj:bj)(n):(n.local?vj:yj)(n,r,t))}function Sj(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Cj(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Mj(e,t){var n,r;function s(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Cj(e,a)),n}return s._value=t,s}function Ej(e,t){var n,r;function s(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Sj(e,a)),n}return s._value=t,s}function Ij(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=Va(e);return this.tween(n,(r.local?Mj:Ej)(r,t))}function Aj(e,t){return function(){Td(this,e).delay=+t.apply(this,arguments)}}function _j(e,t){return t=+t,function(){Td(this,e).delay=t}}function Pj(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Aj:_j)(t,e)):zt(this.node(),t).delay}function $j(e,t){return function(){Zt(this,e).duration=+t.apply(this,arguments)}}function Dj(e,t){return t=+t,function(){Zt(this,e).duration=t}}function Tj(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?$j:Dj)(t,e)):zt(this.node(),t).duration}function Lj(e,t){if(typeof t!="function")throw new Error;return function(){Zt(this,e).ease=t}}function Rj(e){var t=this._id;return arguments.length?this.each(Lj(t,e)):zt(this.node(),t).ease}function Oj(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Zt(this,e).ease=n}}function zj(e){if(typeof e!="function")throw new Error;return this.each(Oj(this._id,e))}function Bj(e){typeof e!="function"&&(e=Y0(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 pn(r,this._parents,this._name,this._id)}function Fj(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],f=c.length,p=i[l]=new Array(f),h,m=0;m<f;++m)(h=c[m]||d[m])&&(p[m]=h);for(;l<r;++l)i[l]=t[l];return new pn(i,this._parents,this._name,this._id)}function jj(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 Hj(e,t,n){var r,s,a=jj(t)?Td:Zt;return function(){var i=a(this,e),l=i.on;l!==r&&(s=(r=l).copy()).on(t,n),i.on=s}}function Vj(e,t){var n=this._id;return arguments.length<2?zt(this.node(),n).on.on(e):this.each(Hj(n,e,t))}function qj(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Uj(){return this.on("end.remove",qj(this._id))}function Qj(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ad(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),f,p,h=0;h<c;++h)(f=l[h])&&(p=e.call(f,f.__data__,h,l))&&("__data__"in f&&(p.__data__=f.__data__),d[h]=p,Ua(d[h],t,n,h,d,zt(f,n)));return new pn(a,this._parents,t,n)}function Kj(e){var t=this._name,n=this._id;typeof e!="function"&&(e=W0(e));for(var r=this._groups,s=r.length,a=[],i=[],l=0;l<s;++l)for(var c=r[l],d=c.length,f,p=0;p<d;++p)if(f=c[p]){for(var h=e.call(f,f.__data__,p,c),m,g=zt(f,n),b=0,x=h.length;b<x;++b)(m=h[b])&&Ua(m,t,n,b,h,g);a.push(h),i.push(f)}return new pn(a,i,t,n)}var Gj=Ho.prototype.constructor;function Wj(){return new Gj(this._groups,this._parents)}function Yj(e,t){var n,r,s;return function(){var a=Ir(this,e),i=(this.style.removeProperty(e),Ir(this,e));return a===i?null:a===n&&i===r?s:s=t(n=a,r=i)}}function vv(e){return function(){this.style.removeProperty(e)}}function Zj(e,t,n){var r,s=n+"",a;return function(){var i=Ir(this,e);return i===s?null:i===r?a:a=t(r=i,n)}}function Xj(e,t,n){var r,s,a;return function(){var i=Ir(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),Ir(this,e))),i===c?null:i===r&&c===s?a:(s=c,a=t(r=i,l))}}function Jj(e,t){var n,r,s,a="style."+t,i="end."+a,l;return function(){var c=Zt(this,e),d=c.on,f=c.value[a]==null?l||(l=vv(t)):void 0;(d!==n||s!==f)&&(r=(n=d).copy()).on(i,s=f),c.on=r}}function eH(e,t,n){var r=(e+="")=="transform"?tj:yv;return t==null?this.styleTween(e,Yj(e,r)).on("end.style."+e,vv(e)):typeof t=="function"?this.styleTween(e,Xj(e,r,Ld(this,"style."+e,t))).each(Jj(this._id,e)):this.styleTween(e,Zj(e,r,t),n).on("end.style."+e,null)}function tH(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function nH(e,t,n){var r,s;function a(){var i=t.apply(this,arguments);return i!==s&&(r=(s=i)&&tH(e,i,n)),r}return a._value=t,a}function rH(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,nH(e,t,n??""))}function oH(e){return function(){this.textContent=e}}function sH(e){return function(){var t=e(this);this.textContent=t??""}}function aH(e){return this.tween("text",typeof e=="function"?sH(Ld(this,"text",e)):oH(e==null?"":e+""))}function iH(e){return function(t){this.textContent=e.call(this,t)}}function lH(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&iH(s)),t}return r._value=e,r}function cH(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,lH(e))}function dH(){for(var e=this._name,t=this._id,n=wv(),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 f=zt(c,t);Ua(c,e,n,d,i,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new pn(r,this._parents,e,n)}function uH(){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=Zt(this,r),f=d.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),d.on=t}),s===0&&a()})}var pH=0;function pn(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function wv(){return++pH}var en=Ho.prototype;pn.prototype={constructor:pn,select:Qj,selectAll:Kj,selectChild:en.selectChild,selectChildren:en.selectChildren,filter:Bj,merge:Fj,selection:Wj,transition:dH,call:en.call,nodes:en.nodes,node:en.node,size:en.size,empty:en.empty,each:en.each,on:Vj,attr:kj,attrTween:Ij,style:eH,styleTween:rH,text:aH,textTween:cH,remove:Uj,tween:gj,delay:Pj,duration:Tj,ease:Rj,easeVarying:zj,end:uH,[Symbol.iterator]:en[Symbol.iterator]};function fH(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var hH={time:null,delay:0,duration:250,ease:fH};function mH(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 gH(e){var t,n;e instanceof pn?(t=e._id,e=e._name):(t=wv(),(n=hH).time=Dd(),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])&&Ua(c,e,t,d,i,n||mH(c,t));return new pn(r,this._parents,e,t)}Ho.prototype.interrupt=fj;Ho.prototype.transition=gH;const ys=e=>()=>e;function bH(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 rn(e,t,n){this.k=e,this.x=t,this.y=n}rn.prototype={constructor:rn,scale:function(e){return e===1?this:new rn(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new rn(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 Qa=new rn(1,0,0);Nv.prototype=rn.prototype;function Nv(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Qa;return e.__zoom}function Qi(e){e.stopImmediatePropagation()}function eo(e){e.preventDefault(),e.stopImmediatePropagation()}function xH(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function yH(){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 hf(){return this.__zoom||Qa}function vH(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function wH(){return navigator.maxTouchPoints||"ontouchstart"in this}function NH(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 kv(){var e=xH,t=yH,n=NH,r=vH,s=wH,a=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,c=$s,d=Ha("start","zoom","end"),f,p,h,m=500,g=150,b=0,x=10;function y(M){M.property("__zoom",hf).on("wheel.zoom",A,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",B).filter(s).on("touchstart.zoom",$).on("touchmove.zoom",z).on("touchend.zoom touchcancel.zoom",R).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(M,T,P,L){var O=M.selection?M.selection():M;O.property("__zoom",hf),M!==O?k(M,T,P,L):O.interrupt().each(function(){S(this,arguments).event(L).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},y.scaleBy=function(M,T,P,L){y.scaleTo(M,function(){var O=this.__zoom.k,j=typeof T=="function"?T.apply(this,arguments):T;return O*j},P,L)},y.scaleTo=function(M,T,P,L){y.transform(M,function(){var O=t.apply(this,arguments),j=this.__zoom,F=P==null?N(O):typeof P=="function"?P.apply(this,arguments):P,H=j.invert(F),D=typeof T=="function"?T.apply(this,arguments):T;return n(v(w(j,D),F,H),O,i)},P,L)},y.translateBy=function(M,T,P,L){y.transform(M,function(){return n(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof P=="function"?P.apply(this,arguments):P),t.apply(this,arguments),i)},null,L)},y.translateTo=function(M,T,P,L,O){y.transform(M,function(){var j=t.apply(this,arguments),F=this.__zoom,H=L==null?N(j):typeof L=="function"?L.apply(this,arguments):L;return n(Qa.translate(H[0],H[1]).scale(F.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof P=="function"?-P.apply(this,arguments):-P),j,i)},L,O)};function w(M,T){return T=Math.max(a[0],Math.min(a[1],T)),T===M.k?M:new rn(T,M.x,M.y)}function v(M,T,P){var L=T[0]-P[0]*M.k,O=T[1]-P[1]*M.k;return L===M.x&&O===M.y?M:new rn(M.k,L,O)}function N(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function k(M,T,P,L){M.on("start.zoom",function(){S(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(L).end()}).tween("zoom",function(){var O=this,j=arguments,F=S(O,j).event(L),H=t.apply(O,j),D=P==null?N(H):typeof P=="function"?P.apply(O,j):P,Q=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),K=O.__zoom,ee=typeof T=="function"?T.apply(O,j):T,oe=c(K.invert(D).concat(Q/K.k),ee.invert(D).concat(Q/ee.k));return function(te){if(te===1)te=ee;else{var Z=oe(te),re=Q/Z[2];te=new rn(re,D[0]-Z[0]*re,D[1]-Z[1]*re)}F.zoom(null,te)}})}function S(M,T,P){return!P&&M.__zooming||new E(M,T)}function E(M,T){this.that=M,this.args=T,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,T),this.taps=0}E.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,T){return this.mouse&&M!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var T=lt(this.that).datum();d.call(M,this.that,new bH(M,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:d}),T)}};function A(M,...T){if(!e.apply(this,arguments))return;var P=S(this,T).event(M),L=this.__zoom,O=Math.max(a[0],Math.min(a[1],L.k*Math.pow(2,r.apply(this,arguments)))),j=_t(M);if(P.wheel)(P.mouse[0][0]!==j[0]||P.mouse[0][1]!==j[1])&&(P.mouse[1]=L.invert(P.mouse[0]=j)),clearTimeout(P.wheel);else{if(L.k===O)return;P.mouse=[j,L.invert(j)],Ls(this),P.start()}eo(M),P.wheel=setTimeout(F,g),P.zoom("mouse",n(v(w(L,O),P.mouse[0],P.mouse[1]),P.extent,i));function F(){P.wheel=null,P.end()}}function I(M,...T){if(h||!e.apply(this,arguments))return;var P=M.currentTarget,L=S(this,T,!0).event(M),O=lt(M.view).on("mousemove.zoom",D,!0).on("mouseup.zoom",Q,!0),j=_t(M,P),F=M.clientX,H=M.clientY;av(M.view),Qi(M),L.mouse=[j,this.__zoom.invert(j)],Ls(this),L.start();function D(K){if(eo(K),!L.moved){var ee=K.clientX-F,oe=K.clientY-H;L.moved=ee*ee+oe*oe>b}L.event(K).zoom("mouse",n(v(L.that.__zoom,L.mouse[0]=_t(K,P),L.mouse[1]),L.extent,i))}function Q(K){O.on("mousemove.zoom mouseup.zoom",null),iv(K.view,L.moved),eo(K),L.event(K).end()}}function B(M,...T){if(e.apply(this,arguments)){var P=this.__zoom,L=_t(M.changedTouches?M.changedTouches[0]:M,this),O=P.invert(L),j=P.k*(M.shiftKey?.5:2),F=n(v(w(P,j),L,O),t.apply(this,T),i);eo(M),l>0?lt(this).transition().duration(l).call(k,F,L,M):lt(this).call(y.transform,F,L,M)}}function $(M,...T){if(e.apply(this,arguments)){var P=M.touches,L=P.length,O=S(this,T,M.changedTouches.length===L).event(M),j,F,H,D;for(Qi(M),F=0;F<L;++F)H=P[F],D=_t(H,this),D=[D,this.__zoom.invert(D),H.identifier],O.touch0?!O.touch1&&O.touch0[2]!==D[2]&&(O.touch1=D,O.taps=0):(O.touch0=D,j=!0,O.taps=1+!!f);f&&(f=clearTimeout(f)),j&&(O.taps<2&&(p=D[0],f=setTimeout(function(){f=null},m)),Ls(this),O.start())}}function z(M,...T){if(this.__zooming){var P=S(this,T).event(M),L=M.changedTouches,O=L.length,j,F,H,D;for(eo(M),j=0;j<O;++j)F=L[j],H=_t(F,this),P.touch0&&P.touch0[2]===F.identifier?P.touch0[0]=H:P.touch1&&P.touch1[2]===F.identifier&&(P.touch1[0]=H);if(F=P.that.__zoom,P.touch1){var Q=P.touch0[0],K=P.touch0[1],ee=P.touch1[0],oe=P.touch1[1],te=(te=ee[0]-Q[0])*te+(te=ee[1]-Q[1])*te,Z=(Z=oe[0]-K[0])*Z+(Z=oe[1]-K[1])*Z;F=w(F,Math.sqrt(te/Z)),H=[(Q[0]+ee[0])/2,(Q[1]+ee[1])/2],D=[(K[0]+oe[0])/2,(K[1]+oe[1])/2]}else if(P.touch0)H=P.touch0[0],D=P.touch0[1];else return;P.zoom("touch",n(v(F,H,D),P.extent,i))}}function R(M,...T){if(this.__zooming){var P=S(this,T).event(M),L=M.changedTouches,O=L.length,j,F;for(Qi(M),h&&clearTimeout(h),h=setTimeout(function(){h=null},m),j=0;j<O;++j)F=L[j],P.touch0&&P.touch0[2]===F.identifier?delete P.touch0:P.touch1&&P.touch1[2]===F.identifier&&delete P.touch1;if(P.touch1&&!P.touch0&&(P.touch0=P.touch1,delete P.touch1),P.touch0)P.touch0[1]=this.__zoom.invert(P.touch0[0]);else if(P.end(),P.taps===2&&(F=_t(F,this),Math.hypot(p[0]-F[0],p[1]-F[1])<x)){var H=lt(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return y.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:ys(+M),y):r},y.filter=function(M){return arguments.length?(e=typeof M=="function"?M:ys(!!M),y):e},y.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:ys(!!M),y):s},y.extent=function(M){return arguments.length?(t=typeof M=="function"?M:ys([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),y):t},y.scaleExtent=function(M){return arguments.length?(a[0]=+M[0],a[1]=+M[1],y):[a[0],a[1]]},y.translateExtent=function(M){return arguments.length?(i[0][0]=+M[0][0],i[1][0]=+M[1][0],i[0][1]=+M[0][1],i[1][1]=+M[1][1],y):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},y.constrain=function(M){return arguments.length?(n=M,y):n},y.duration=function(M){return arguments.length?(l=+M,y):l},y.interpolate=function(M){return arguments.length?(c=M,y):c},y.on=function(){var M=d.on.apply(d,arguments);return M===d?y:M},y.clickDistance=function(M){return arguments.length?(b=(M=+M)*M,y):Math.sqrt(b)},y.tapDistance=function(M){return arguments.length?(x=+M,y):x},y}const Wt={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."},So=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Sv=["Enter"," ","Escape"],Cv={"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 _r;(function(e){e.Strict="strict",e.Loose="loose"})(_r||(_r={}));var Un;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Un||(Un={}));var Co;(function(e){e.Partial="partial",e.Full="full"})(Co||(Co={}));const Mv={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var wn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(wn||(wn={}));var aa;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(aa||(aa={}));var we;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(we||(we={}));const mf={[we.Left]:we.Right,[we.Right]:we.Left,[we.Top]:we.Bottom,[we.Bottom]:we.Top};function Ev(e){return e===null?null:e?"valid":"invalid"}const Iv=e=>"id"in e&&"source"in e&&"target"in e,kH=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Rd=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),qo=(e,t=[0,0])=>{const{width:n,height:r}=gn(e),s=e.origin??t,a=n*s[0],i=r*s[1];return{x:e.position.x-a,y:e.position.y-i}},SH=(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):Rd(s)?s:t.nodeLookup.get(s.id));const l=i?ia(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Ka(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Ga(n)},Uo=(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=Ka(n,ia(s)),r=!0)}),r?Ga(n):{x:0,y:0,width:0,height:0}},Od=(e,t,[n,r,s]=[0,0,1],a=!1,i=!1)=>{const l={...Ko(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const d of e.values()){const{measured:f,selectable:p=!0,hidden:h=!1}=d;if(i&&!p||h)continue;const m=f.width??d.width??d.initialWidth??null,g=f.height??d.height??d.initialHeight??null,b=Mo(l,$r(d)),x=(m??0)*(g??0),y=a&&b>0;(!d.internals.handleBounds||y||b>=x||d.dragging)&&c.push(d)}return c},CH=(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 MH(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 EH({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:a},i){if(e.size===0)return Promise.resolve(!0);const l=MH(e,i),c=Uo(l),d=zd(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 Av({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},f=i.origin??r;let p=i.extent||s;if(i.extent==="parent"&&!i.expandParent)if(!l)a?.("005",Wt.error005());else{const m=l.measured.width,g=l.measured.height;m&&g&&(p=[[c,d],[c+m,d+g]])}else l&&Dr(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=Dr(p)?Zn(t,p,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&a?.("015",Wt.error015()),{position:{x:h.x-c+(i.measured.width??0)*f[0],y:h.y-d+(i.measured.height??0)*f[1]},positionAbsolute:h}}async function IH({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),f=CH(i,c);for(const h of c)l.has(h.id)&&!f.find(g=>g.id===h.id)&&f.push(h);if(!s)return{edges:f,nodes:i};const p=await s({nodes:i,edges:f});return typeof p=="boolean"?p?{edges:f,nodes:i}:{edges:[],nodes:[]}:p}const Pr=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Zn=(e={x:0,y:0},t,n)=>({x:Pr(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Pr(e.y,t[0][1],t[1][1]-(n?.height??0))});function _v(e,t,n){const{width:r,height:s}=gn(n),{x:a,y:i}=n.internals.positionAbsolute;return Zn(e,[[a,i],[a+r,i+s]],t)}const gf=(e,t,n)=>e<t?Pr(Math.abs(e-t),1,t)/t:e>n?-Pr(Math.abs(e-n),1,t)/t:0,Pv=(e,t,n=15,r=40)=>{const s=gf(e.x,r,t.width-r)*n,a=gf(e.y,r,t.height-r)*n;return[s,a]},Ka=(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)}),Ul=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ga=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),$r=(e,t=[0,0])=>{const{x:n,y:r}=Rd(e)?e.internals.positionAbsolute:qo(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}},ia=(e,t=[0,0])=>{const{x:n,y:r}=Rd(e)?e.internals.positionAbsolute:qo(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)}},$v=(e,t)=>Ga(Ka(Ul(e),Ul(t))),Mo=(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)},bf=e=>$t(e.width)&&$t(e.height)&&$t(e.x)&&$t(e.y),$t=e=>!isNaN(e)&&isFinite(e),AH=(e,t)=>{},Qo=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Ko=({x:e,y:t},[n,r,s],a=!1,i=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return a?Qo(l,i):l},la=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function dr(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 _H(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=dr(e,n),s=dr(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=dr(e.top??e.y??0,n),s=dr(e.bottom??e.y??0,n),a=dr(e.left??e.x??0,t),i=dr(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 PH(e,t,n,r,s,a){const{x:i,y:l}=la(e,[t,n,r]),{x:c,y:d}=la({x:e.x+e.width,y:e.y+e.height},[t,n,r]),f=s-c,p=a-d;return{left:Math.floor(i),top:Math.floor(l),right:Math.floor(f),bottom:Math.floor(p)}}const zd=(e,t,n,r,s,a)=>{const i=_H(a,t,n),l=(t-i.x)/e.width,c=(n-i.y)/e.height,d=Math.min(l,c),f=Pr(d,r,s),p=e.x+e.width/2,h=e.y+e.height/2,m=t/2-p*f,g=n/2-h*f,b=PH(e,m,g,f,t,n),x={left:Math.min(b.left-i.left,0),top:Math.min(b.top-i.top,0),right:Math.min(b.right-i.right,0),bottom:Math.min(b.bottom-i.bottom,0)};return{x:m-x.left+x.right,y:g-x.top+x.bottom,zoom:f}},Eo=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Dr(e){return e!=null&&e!=="parent"}function gn(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Dv(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Tv(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 xf(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function $H(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function DH(e){return{...Cv,...e||{}}}function ho(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:a,y:i}=Dt(e),l=Ko({x:a-(s?.left??0),y:i-(s?.top??0)},r),{x:c,y:d}=n?Qo(l,t):l;return{xSnapped:c,ySnapped:d,...l}}const Bd=e=>({width:e.offsetWidth,height:e.offsetHeight}),Lv=e=>e?.getRootNode?.()||window?.document,TH=["INPUT","SELECT","TEXTAREA"];function Rv(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:TH.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Ov=e=>"clientX"in e,Dt=(e,t)=>{const n=Ov(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)}},yf=(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,...Bd(i)}})};function zv({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,f=Math.abs(c-e),p=Math.abs(d-t);return[c,d,f,p]}function vs(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function vf({pos:e,x1:t,y1:n,x2:r,y2:s,c:a}){switch(e){case we.Left:return[t-vs(t-r,a),n];case we.Right:return[t+vs(r-t,a),n];case we.Top:return[t,n-vs(n-s,a)];case we.Bottom:return[t,n+vs(s-n,a)]}}function Bv({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:r,targetY:s,targetPosition:a=we.Top,curvature:i=.25}){const[l,c]=vf({pos:n,x1:e,y1:t,x2:r,y2:s,c:i}),[d,f]=vf({pos:a,x1:r,y1:s,x2:e,y2:t,c:i}),[p,h,m,g]=zv({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:f});return[`M${e},${t} C${l},${c} ${d},${f} ${r},${s}`,p,h,m,g]}function Fv({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 LH({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 RH({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const a=Ka(ia(e),ia(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 Mo(i,Ga(a))>0}const OH=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,zH=(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)),BH=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||OH;let s;return Iv(e)?s={...e}:s={...e,id:r(e)},zH(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function jv({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,a,i,l]=Fv({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,a,i,l]}const wf={[we.Left]:{x:-1,y:0},[we.Right]:{x:1,y:0},[we.Top]:{x:0,y:-1},[we.Bottom]:{x:0,y:1}},FH=({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},Nf=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function jH({source:e,sourcePosition:t=we.Bottom,target:n,targetPosition:r=we.Top,center:s,offset:a,stepPosition:i}){const l=wf[t],c=wf[r],d={x:e.x+l.x*a,y:e.y+l.y*a},f={x:n.x+c.x*a,y:n.y+c.y*a},p=FH({source:d,sourcePosition:t,target:f}),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]=Fv({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+(f.x-d.x)*i,x=s.y??(d.y+f.y)/2):(b=s.x??(d.x+f.x)/2,x=s.y??d.y+(f.y-d.y)*i);const A=[{x:b,y:d.y},{x:b,y:f.y}],I=[{x:d.x,y:x},{x:f.x,y:x}];l[h]===m?g=h==="x"?A:I:g=h==="x"?I:A}else{const A=[{x:d.x,y:f.y}],I=[{x:f.x,y:d.y}];if(h==="x"?g=l.x===m?I:A:g=l.y===m?A:I,t===r){const M=Math.abs(e[h]-n[h]);if(M<=a){const T=Math.min(a-1,a-M);l[h]===m?y[h]=(d[h]>e[h]?-1:1)*T:w[h]=(f[h]>n[h]?-1:1)*T}}if(t!==r){const M=h==="x"?"y":"x",T=l[h]===c[M],P=d[M]>f[M],L=d[M]<f[M];(l[h]===1&&(!T&&P||T&&L)||l[h]!==1&&(!T&&L||T&&P))&&(g=h==="x"?A:I)}const B={x:d.x+y.x,y:d.y+y.y},$={x:f.x+w.x,y:f.y+w.y},z=Math.max(Math.abs(B.x-g[0].x),Math.abs($.x-g[0].x)),R=Math.max(Math.abs(B.y-g[0].y),Math.abs($.y-g[0].y));z>=R?(b=(B.x+$.x)/2,x=g[0].y):(b=g[0].x,x=(B.y+$.y)/2)}const k={x:d.x+y.x,y:d.y+y.y},S={x:f.x+w.x,y:f.y+w.y};return[[e,...k.x!==g[0].x||k.y!==g[0].y?[k]:[],...g,...S.x!==g[g.length-1].x||S.y!==g[g.length-1].y?[S]:[],n],b,x,v,N]}function HH(e,t,n,r){const s=Math.min(Nf(e,t)/2,Nf(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,f=e.y<n.y?1:-1;return`L ${a+s*d},${i}Q ${a},${i} ${a},${i+s*f}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${a},${i+s*c}Q ${a},${i} ${a+s*l},${i}`}function Ql({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:f=.5}){const[p,h,m,g,b]=jH({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:a,center:{x:l,y:c},offset:d,stepPosition:f});let x=`M${p[0].x} ${p[0].y}`;for(let y=1;y<p.length-1;y++)x+=HH(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 kf(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function VH(e){const{sourceNode:t,targetNode:n}=e;if(!kf(t)||!kf(n))return null;const r=t.internals.handleBounds||Sf(t.handles),s=n.internals.handleBounds||Sf(n.handles),a=Cf(r?.source??[],e.sourceHandle),i=Cf(e.connectionMode===_r.Strict?s?.target??[]:(s?.target??[]).concat(s?.source??[]),e.targetHandle);if(!a||!i)return e.onError?.("008",Wt.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=Xn(t,a,l),f=Xn(n,i,c);return{sourceX:d.x,sourceY:d.y,targetX:f.x,targetY:f.y,sourcePosition:l,targetPosition:c}}function Sf(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 Xn(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??gn(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 Cf(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Kl(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function qH(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=Kl(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 Hv=1e3,UH=10,Fd={nodeOrigin:[0,0],nodeExtent:So,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},QH={...Fd,checkEquality:!0};function jd(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function KH(e,t,n){const r=jd(Fd,n);for(const s of e.values())if(s.parentId)Vd(s,e,t,r);else{const a=qo(s,r.nodeOrigin),i=Dr(s.extent)?s.extent:r.nodeExtent,l=Zn(a,i,gn(s));s.internals.positionAbsolute=l}}function GH(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 Hd(e){return e==="manual"}function Gl(e,t,n,r={}){const s=jd(QH,r),a={i:0},i=new Map(t),l=s?.elevateNodesOnSelect&&!Hd(s.zIndexMode)?Hv:0;let c=e.length>0,d=!1;t.clear(),n.clear();for(const f of e){let p=i.get(f.id);if(s.checkEquality&&f===p?.internals.userNode)t.set(f.id,p);else{const h=qo(f,s.nodeOrigin),m=Dr(f.extent)?f.extent:s.nodeExtent,g=Zn(h,m,gn(f));p={...s.defaults,...f,measured:{width:f.measured?.width,height:f.measured?.height},internals:{positionAbsolute:g,handleBounds:GH(f,p),z:Vv(f,l,s.zIndexMode),userNode:f}},t.set(f.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(c=!1),f.parentId&&Vd(p,t,n,r,a),d||=f.selected??!1}return{nodesInitialized:c,hasSelectedNodes:d}}function WH(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 Vd(e,t,n,r,s){const{elevateNodesOnSelect:a,nodeOrigin:i,nodeExtent:l,zIndexMode:c}=jd(Fd,r),d=e.parentId,f=t.get(d);if(!f){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}WH(e,n),s&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++s.i,f.internals.z=f.internals.z+s.i*UH),s&&f.internals.rootParentIndex!==void 0&&(s.i=f.internals.rootParentIndex);const p=a&&!Hd(c)?Hv:0,{x:h,y:m,z:g}=YH(e,f,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 Vv(e,t,n){const r=$t(e.zIndex)?e.zIndex:0;return Hd(n)?r:r+(e.selected?t:0)}function YH(e,t,n,r,s,a){const{x:i,y:l}=t.internals.positionAbsolute,c=gn(e),d=qo(e,n),f=Dr(e.extent)?Zn(d,e.extent,c):d;let p=Zn({x:i+f.x,y:l+f.y},r,c);e.extent==="parent"&&(p=_v(p,c,t));const h=Vv(e,s,a),m=t.internals.z??0;return{x:p.x,y:p.y,z:m>=h?m+1:h}}function qd(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??$r(l),d=$v(c,i.rect);a.set(i.parentId,{expandedRect:d,parent:l})}return a.size>0&&a.forEach(({expandedRect:i,parent:l},c)=>{const d=l.internals.positionAbsolute,f=gn(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(f.width,Math.round(i.width)),b=Math.max(f.height,Math.round(i.height)),x=(g-f.width)*p[0],y=(b-f.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}})})),(f.width<i.width||f.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 ZH(e,t,n,r,s,a,i){const l=r?.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const d=[],f=window.getComputedStyle(l),{m22:p}=new window.DOMMatrixReadOnly(f.transform),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=Bd(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=Dr(g.extent)?g.extent:a;let{positionAbsolute:N}=g.internals;g.parentId&&g.extent==="parent"?N=_v(N,b,t.get(g.parentId)):v&&(N=Zn(N,v,b));const k={...g,measured:b,internals:{...g.internals,positionAbsolute:N,handleBounds:{source:yf("source",m.nodeElement,w,p,g.id),target:yf("target",m.nodeElement,w,p,g.id)}}};t.set(g.id,k),g.parentId&&Vd(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:$r(k,s)}))}}if(h.length>0){const m=qd(h,t,n,s);d.push(...m)}return{changes:d,updatedInternals:c}}async function XH({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 Mf(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 qv(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}`,f=`${a}-${l}--${s}-${i}`;Mf("source",c,f,e,s,i),Mf("target",c,d,e,a,l),t.set(r.id,r)}}function Uv(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Uv(n,t):!1}function Ef(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 JH(e,t,n,r){const s=new Map;for(const[a,i]of e)if((i.selected||i.id===r)&&(!i.parentId||!Uv(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 Ki({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 eV({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=Qo(a,t);return{x:i.x-a.x,y:i.y-a.y}}function tV({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},f=null,p=!1,h=null,m=!1,g=!1,b=null;function x({noDragClassName:w,handleSelector:v,domNode:N,isSelectable:k,nodeId:S,nodeClickDistance:E=0}){h=lt(N);function A({x:z,y:R}){const{nodeLookup:M,nodeExtent:T,snapGrid:P,snapToGrid:L,nodeOrigin:O,onNodeDrag:j,onSelectionDrag:F,onError:H,updateNodePositions:D}=t();a={x:z,y:R};let Q=!1;const K=l.size>1,ee=K&&T?Ul(Uo(l)):null,oe=K&&L?eV({dragItems:l,snapGrid:P,x:z,y:R}):null;for(const[te,Z]of l){if(!M.has(te))continue;let re={x:z-Z.distance.x,y:R-Z.distance.y};L&&(re=oe?{x:Math.round(re.x+oe.x),y:Math.round(re.y+oe.y)}:Qo(re,P));let be=null;if(K&&T&&!Z.extent&&ee){const{positionAbsolute:J}=Z.internals,ae=J.x-ee.x+T[0][0],fe=J.x+Z.measured.width-ee.x2+T[1][0],ge=J.y-ee.y+T[0][1],V=J.y+Z.measured.height-ee.y2+T[1][1];be=[[ae,ge],[fe,V]]}const{position:X,positionAbsolute:G}=Av({nodeId:te,nextPosition:re,nodeLookup:M,nodeExtent:be||T,nodeOrigin:O,onError:H});Q=Q||Z.position.x!==X.x||Z.position.y!==X.y,Z.position=X,Z.internals.positionAbsolute=G}if(g=g||Q,!!Q&&(D(l,!0),b&&(r||j||!S&&F))){const[te,Z]=Ki({nodeId:S,dragItems:l,nodeLookup:M});r?.(b,l,te,Z),j?.(b,te,Z),S||F?.(b,Z)}}async function I(){if(!f)return;const{transform:z,panBy:R,autoPanSpeed:M,autoPanOnNodeDrag:T}=t();if(!T){c=!1,cancelAnimationFrame(i);return}const[P,L]=Pv(d,f,M);(P!==0||L!==0)&&(a.x=(a.x??0)-P/z[2],a.y=(a.y??0)-L/z[2],await R({x:P,y:L})&&A(a)),i=requestAnimationFrame(I)}function B(z){const{nodeLookup:R,multiSelectionActive:M,nodesDraggable:T,transform:P,snapGrid:L,snapToGrid:O,selectNodesOnDrag:j,onNodeDragStart:F,onSelectionDragStart:H,unselectNodesAndEdges:D}=t();p=!0,(!j||!k)&&!M&&S&&(R.get(S)?.selected||D()),k&&j&&S&&e?.(S);const Q=ho(z.sourceEvent,{transform:P,snapGrid:L,snapToGrid:O,containerBounds:f});if(a=Q,l=JH(R,T,Q,S),l.size>0&&(n||F||!S&&H)){const[K,ee]=Ki({nodeId:S,dragItems:l,nodeLookup:R});n?.(z.sourceEvent,l,K,ee),F?.(z.sourceEvent,K,ee),S||H?.(z.sourceEvent,ee)}}const $=lv().clickDistance(E).on("start",z=>{const{domNode:R,nodeDragThreshold:M,transform:T,snapGrid:P,snapToGrid:L}=t();f=R?.getBoundingClientRect()||null,m=!1,g=!1,b=z.sourceEvent,M===0&&B(z),a=ho(z.sourceEvent,{transform:T,snapGrid:P,snapToGrid:L,containerBounds:f}),d=Dt(z.sourceEvent,f)}).on("drag",z=>{const{autoPanOnNodeDrag:R,transform:M,snapGrid:T,snapToGrid:P,nodeDragThreshold:L,nodeLookup:O}=t(),j=ho(z.sourceEvent,{transform:M,snapGrid:T,snapToGrid:P,containerBounds:f});if(b=z.sourceEvent,(z.sourceEvent.type==="touchmove"&&z.sourceEvent.touches.length>1||S&&!O.has(S))&&(m=!0),!m){if(!c&&R&&p&&(c=!0,I()),!p){const F=Dt(z.sourceEvent,f),H=F.x-d.x,D=F.y-d.y;Math.sqrt(H*H+D*D)>L&&B(z)}(a.x!==j.xSnapped||a.y!==j.ySnapped)&&l&&p&&(d=Dt(z.sourceEvent,f),A(j))}}).on("end",z=>{if(!(!p||m)&&(c=!1,p=!1,cancelAnimationFrame(i),l.size>0)){const{nodeLookup:R,updateNodePositions:M,onNodeDragStop:T,onSelectionDragStop:P}=t();if(g&&(M(l,!1),g=!1),s||T||!S&&P){const[L,O]=Ki({nodeId:S,dragItems:l,nodeLookup:R,dragging:!1});s?.(z.sourceEvent,l,L,O),T?.(z.sourceEvent,L,O),S||P?.(z.sourceEvent,O)}}}).filter(z=>{const R=z.target;return!z.button&&(!w||!Ef(R,`.${w}`,N))&&(!v||Ef(R,v,N))});h.call($)}function y(){h?.on(".drag",null)}return{update:x,destroy:y}}function nV(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())Mo(s,$r(a))>0&&r.push(a);return r}const rV=250;function oV(e,t,n,r){let s=[],a=1/0;const i=nV(e,n,t+rV);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:f,y:p}=Xn(l,d,d.position,!0),h=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(p-e.y,2));h>t||(h<a?(s=[{...d,x:f,y:p}],a=h):h===a&&s.push({...d,x:f,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 Qv(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,...Xn(i,c,c.position,!0)}:c}function Kv(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function sV(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Gv=()=>!0;function aV(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:a,isTarget:i,domNode:l,nodeLookup:c,lib:d,autoPanOnConnect:f,flowId:p,panBy:h,cancelConnection:m,onConnectStart:g,onConnect:b,onConnectEnd:x,isValidConnection:y=Gv,onReconnectEnd:w,updateConnection:v,getTransform:N,getFromHandle:k,autoPanSpeed:S,dragThreshold:E=1,handleDomNode:A}){const I=Lv(e.target);let B=0,$;const{x:z,y:R}=Dt(e),M=Kv(a,A),T=l?.getBoundingClientRect();let P=!1;if(!T||!M)return;const L=Qv(s,M,r,c,t);if(!L)return;let O=Dt(e,T),j=!1,F=null,H=!1,D=null;function Q(){if(!f||!T)return;const[X,G]=Pv(O,T,S);h({x:X,y:G}),B=requestAnimationFrame(Q)}const K={...L,nodeId:s,type:M,position:L.position},ee=c.get(s);let te={inProgress:!0,isValid:null,from:Xn(ee,K,we.Left,!0),fromHandle:K,fromPosition:K.position,fromNode:ee,to:O,toHandle:null,toPosition:mf[K.position],toNode:null,pointer:O};function Z(){P=!0,v(te),g?.(e,{nodeId:s,handleId:r,handleType:M})}E===0&&Z();function re(X){if(!P){const{x:V,y:ie}=Dt(X),ue=V-z,de=ie-R;if(!(ue*ue+de*de>E*E))return;Z()}if(!k()||!K){be(X);return}const G=N();O=Dt(X,T),$=oV(Ko(O,G,!1,[1,1]),n,c,K),j||(Q(),j=!0);const J=Wv(X,{handle:$,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:i?"target":"source",isValidConnection:y,doc:I,lib:d,flowId:p,nodeLookup:c});D=J.handleDomNode,F=J.connection,H=sV(!!$,J.isValid);const ae=c.get(s),fe=ae?Xn(ae,K,we.Left,!0):te.from,ge={...te,from:fe,isValid:H,to:J.toHandle&&H?la({x:J.toHandle.x,y:J.toHandle.y},G):O,toHandle:J.toHandle,toPosition:H&&J.toHandle?J.toHandle.position:mf[K.position],toNode:J.toHandle?c.get(J.toHandle.nodeId):null,pointer:O};v(ge),te=ge}function be(X){if(!("touches"in X&&X.touches.length>0)){if(P){($||D)&&F&&H&&b?.(F);const{inProgress:G,...J}=te,ae={...J,toPosition:te.toHandle?te.toPosition:null};x?.(X,ae),a&&w?.(X,ae)}m(),cancelAnimationFrame(B),j=!1,H=!1,F=null,D=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 Wv(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:a,doc:i,lib:l,flowId:c,isValidConnection:d=Gv,nodeLookup:f}){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}=Dt(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=Kv(void 0,x),v=x.getAttribute("data-nodeid"),N=x.getAttribute("data-handleid"),k=x.classList.contains("connectable"),S=x.classList.contains("connectableend");if(!v||!w)return y;const E={source:p?v:r,sourceHandle:p?N:s,target:p?r:v,targetHandle:p?s:N};y.connection=E;const I=k&&S&&(n===_r.Strict?p&&w==="source"||!p&&w==="target":v!==r||N!==s);y.isValid=I&&d(E),y.toHandle=Qv(v,w,N,f,n,!0)}return y}const Wl={onPointerDown:aV,isValid:Wv};function iV({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=lt(e);function a({translateExtent:l,width:c,height:d,zoomStep:f=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&&Eo()?10:1,S=-v.sourceEvent.deltaY*(v.sourceEvent.deltaMode===1?.05:v.sourceEvent.deltaMode?1:.002)*f,E=N[2]*Math.pow(2,S*k);t.scaleTo(E)};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],S=[k[0]-b[0],k[1]-b[1]];b=k;const E=r()*Math.max(N[2],Math.log(N[2]))*(m?-1:1),A={x:N[0]-S[0]*E,y:N[1]-S[1]*E},I=[[0,0],[c,d]];t.setViewportConstrained({x:A.x,y:A.y,zoom:N[2]},I,l)},w=kv().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:_t}}const Wa=e=>({x:e.x,y:e.y,zoom:e.k}),Gi=({x:e,y:t,zoom:n})=>Qa.translate(e,t).scale(n),hr=(e,t)=>e.target.closest(`.${t}`),Yv=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),lV=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Wi=(e,t=0,n=lV,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},Zv=e=>{const t=e.ctrlKey&&Eo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function cV({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:a,zoomOnPinch:i,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:d}){return f=>{if(hr(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(f.ctrlKey&&i){const x=_t(f),y=Zv(f),w=p*Math.pow(2,y);r.scaleTo(n,w,x,f);return}const h=f.deltaMode===1?20:1;let m=s===Un.Vertical?0:f.deltaX*h,g=s===Un.Horizontal?0:f.deltaY*h;!Eo()&&f.shiftKey&&s!==Un.Vertical&&(m=f.deltaY*h,g=0),r.translateBy(n,-(m/p)*a,-(g/p)*a,{internal:!0});const b=Wa(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(f,b),e.panScrollTimeout=setTimeout(()=>{d?.(f,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(f,b))}}function dV({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const a=r.type==="wheel",i=!t&&a&&!r.ctrlKey,l=hr(r,e);if(r.ctrlKey&&a&&l&&r.preventDefault(),i||l)return null;r.preventDefault(),n.call(this,r,s)}}function uV({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;const s=Wa(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 pV({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return a=>{e.usedRightMouseButton=!!(n&&Yv(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),s&&!a.sourceEvent?.internal&&s?.(a.sourceEvent,Wa(a.transform))}}function fV({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:a}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&Yv(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&a(i.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const l=Wa(i.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s?.(i.sourceEvent,l)},n?150:0)}}}function hV({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:a,userSelectionActive:i,noWheelClassName:l,noPanClassName:c,lib:d,connectionInProgress:f}){return p=>{const h=e||t,m=n&&p.ctrlKey,g=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(hr(p,`${d}-flow__node`)||hr(p,`${d}-flow__edge`)))return!0;if(!r&&!h&&!s&&!a&&!n||i||f&&!g||hr(p,l)&&g||hr(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 mV({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},f=e.getBoundingClientRect(),p=kv().scaleExtent([t,n]).translateExtent(r),h=lt(e).call(p);w({x:s.x,y:s.y,zoom:Pr(s.zoom,t,n)},[[0,0],[f.width,f.height]],r);const m=h.on("wheel.zoom"),g=h.on("dblclick.zoom");p.wheelDelta(Zv);function b($,z){return h?new Promise(R=>{p?.interpolate(z?.interpolate==="linear"?fo:$s).transform(Wi(h,z?.duration,z?.ease,()=>R(!0)),$)}):Promise.resolve(!1)}function x({noWheelClassName:$,noPanClassName:z,onPaneContextMenu:R,userSelectionActive:M,panOnScroll:T,panOnDrag:P,panOnScrollMode:L,panOnScrollSpeed:O,preventScrolling:j,zoomOnPinch:F,zoomOnScroll:H,zoomOnDoubleClick:D,zoomActivationKeyPressed:Q,lib:K,onTransformChange:ee,connectionInProgress:oe,paneClickDistance:te,selectionOnDrag:Z}){M&&!d.isZoomingOrPanning&&y();const re=T&&!Q&&!M;p.clickDistance(Z?1/0:!$t(te)||te<0?0:te);const be=re?cV({zoomPanValues:d,noWheelClassName:$,d3Selection:h,d3Zoom:p,panOnScrollMode:L,panOnScrollSpeed:O,zoomOnPinch:F,onPanZoomStart:i,onPanZoom:a,onPanZoomEnd:l}):dV({noWheelClassName:$,preventScrolling:j,d3ZoomHandler:m});if(h.on("wheel.zoom",be,{passive:!1}),!M){const G=uV({zoomPanValues:d,onDraggingChange:c,onPanZoomStart:i});p.on("start",G);const J=pV({zoomPanValues:d,panOnDrag:P,onPaneContextMenu:!!R,onPanZoom:a,onTransformChange:ee});p.on("zoom",J);const ae=fV({zoomPanValues:d,panOnDrag:P,panOnScroll:T,onPaneContextMenu:R,onPanZoomEnd:l,onDraggingChange:c});p.on("end",ae)}const X=hV({zoomActivationKeyPressed:Q,panOnDrag:P,zoomOnScroll:H,panOnScroll:T,zoomOnDoubleClick:D,zoomOnPinch:F,userSelectionActive:M,noPanClassName:z,noWheelClassName:$,lib:K,connectionInProgress:oe});p.filter(X),D?h.on("dblclick.zoom",g):h.on("dblclick.zoom",null)}function y(){p.on("zoom",null)}async function w($,z,R){const M=Gi($),T=p?.constrain()(M,z,R);return T&&await b(T),new Promise(P=>P(T))}async function v($,z){const R=Gi($);return await b(R,z),new Promise(M=>M(R))}function N($){if(h){const z=Gi($),R=h.property("__zoom");(R.k!==$.zoom||R.x!==$.x||R.y!==$.y)&&p?.transform(h,z,null,{sync:!0})}}function k(){const $=h?Nv(h.node()):{x:0,y:0,k:1};return{x:$.x,y:$.y,zoom:$.k}}function S($,z){return h?new Promise(R=>{p?.interpolate(z?.interpolate==="linear"?fo:$s).scaleTo(Wi(h,z?.duration,z?.ease,()=>R(!0)),$)}):Promise.resolve(!1)}function E($,z){return h?new Promise(R=>{p?.interpolate(z?.interpolate==="linear"?fo:$s).scaleBy(Wi(h,z?.duration,z?.ease,()=>R(!0)),$)}):Promise.resolve(!1)}function A($){p?.scaleExtent($)}function I($){p?.translateExtent($)}function B($){const z=!$t($)||$<0?0:$;p?.clickDistance(z)}return{update:x,destroy:y,setViewport:v,setViewportConstrained:w,getViewport:k,scaleTo:S,scaleBy:E,setScaleExtent:A,setTranslateExtent:I,syncViewport:N,setClickDistance:B}}var Tr;(function(e){e.Line="line",e.Handle="handle"})(Tr||(Tr={}));function gV({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 If(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 yn(e,t){return Math.max(0,t-e)}function vn(e,t){return Math.max(0,e-t)}function ws(e,t,n){return Math.max(0,t-e,e-n)}function Af(e,t){return e?!t:t}function bV(e,t,n,r,s,a,i,l){let{affectsX:c,affectsY:d}=t;const{isHorizontal:f,isVertical:p}=t,h=f&&p,{xSnapped:m,ySnapped:g}=n,{minWidth:b,maxWidth:x,minHeight:y,maxHeight:w}=r,{x:v,y:N,width:k,height:S,aspectRatio:E}=e;let A=Math.floor(f?m-e.pointerX:0),I=Math.floor(p?g-e.pointerY:0);const B=k+(c?-A:A),$=S+(d?-I:I),z=-a[0]*k,R=-a[1]*S;let M=ws(B,b,x),T=ws($,y,w);if(i){let O=0,j=0;c&&A<0?O=yn(v+A+z,i[0][0]):!c&&A>0&&(O=vn(v+B+z,i[1][0])),d&&I<0?j=yn(N+I+R,i[0][1]):!d&&I>0&&(j=vn(N+$+R,i[1][1])),M=Math.max(M,O),T=Math.max(T,j)}if(l){let O=0,j=0;c&&A>0?O=vn(v+A,l[0][0]):!c&&A<0&&(O=yn(v+B,l[1][0])),d&&I>0?j=vn(N+I,l[0][1]):!d&&I<0&&(j=yn(N+$,l[1][1])),M=Math.max(M,O),T=Math.max(T,j)}if(s){if(f){const O=ws(B/E,y,w)*E;if(M=Math.max(M,O),i){let j=0;!c&&!d||c&&!d&&h?j=vn(N+R+B/E,i[1][1])*E:j=yn(N+R+(c?A:-A)/E,i[0][1])*E,M=Math.max(M,j)}if(l){let j=0;!c&&!d||c&&!d&&h?j=yn(N+B/E,l[1][1])*E:j=vn(N+(c?A:-A)/E,l[0][1])*E,M=Math.max(M,j)}}if(p){const O=ws($*E,b,x)/E;if(T=Math.max(T,O),i){let j=0;!c&&!d||d&&!c&&h?j=vn(v+$*E+z,i[1][0])/E:j=yn(v+(d?I:-I)*E+z,i[0][0])/E,T=Math.max(T,j)}if(l){let j=0;!c&&!d||d&&!c&&h?j=yn(v+$*E,l[1][0])/E:j=vn(v+(d?I:-I)*E,l[0][0])/E,T=Math.max(T,j)}}}I=I+(I<0?T:-T),A=A+(A<0?M:-M),s&&(h?B>$*E?I=(Af(c,d)?-A:A)/E:A=(Af(c,d)?-I:I)*E:f?(I=A/E,d=c):(A=I*E,c=d));const P=c?v+A:v,L=d?N+I:N;return{width:k+(c?-A:A),height:S+(d?-I:I),x:a[0]*A*(c?-1:1)+P,y:a[1]*I*(d?-1:1)+L}}const Xv={width:0,height:0,x:0,y:0},xV={...Xv,pointerX:0,pointerY:0,aspectRatio:1};function yV(e){return[[0,0],[e.measured.width,e.measured.height]]}function vV(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 wV({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const a=lt(e);let i={controlDirection:If("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:d,boundaries:f,keepAspectRatio:p,resizeDirection:h,onResizeStart:m,onResize:g,onResizeEnd:b,shouldResize:x}){let y={...Xv},w={...xV};i={boundaries:f,resizeDirection:h,keepAspectRatio:p,controlDirection:If(d)};let v,N=null,k=[],S,E,A,I=!1;const B=lv().on("start",$=>{const{nodeLookup:z,transform:R,snapGrid:M,snapToGrid:T,nodeOrigin:P,paneDomNode:L}=n();if(v=z.get(t),!v)return;N=L?.getBoundingClientRect()??null;const{xSnapped:O,ySnapped:j}=ho($.sourceEvent,{transform:R,snapGrid:M,snapToGrid:T,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:O,pointerY:j,aspectRatio:y.width/y.height},S=void 0,v.parentId&&(v.extent==="parent"||v.expandParent)&&(S=z.get(v.parentId),E=S&&v.extent==="parent"?yV(S):void 0),k=[],A=void 0;for(const[F,H]of z)if(H.parentId===t&&(k.push({id:F,position:{...H.position},extent:H.extent}),H.extent==="parent"||H.expandParent)){const D=vV(H,v,H.origin??P);A?A=[[Math.min(D[0][0],A[0][0]),Math.min(D[0][1],A[0][1])],[Math.max(D[1][0],A[1][0]),Math.max(D[1][1],A[1][1])]]:A=D}m?.($,{...y})}).on("drag",$=>{const{transform:z,snapGrid:R,snapToGrid:M,nodeOrigin:T}=n(),P=ho($.sourceEvent,{transform:z,snapGrid:R,snapToGrid:M,containerBounds:N}),L=[];if(!v)return;const{x:O,y:j,width:F,height:H}=y,D={},Q=v.origin??T,{width:K,height:ee,x:oe,y:te}=bV(w,i.controlDirection,P,i.boundaries,i.keepAspectRatio,Q,E,A),Z=K!==F,re=ee!==H,be=oe!==O&&Z,X=te!==j&&re;if(!be&&!X&&!Z&&!re)return;if((be||X||Q[0]===1||Q[1]===1)&&(D.x=be?oe:y.x,D.y=X?te:y.y,y.x=D.x,y.y=D.y,k.length>0)){const fe=oe-O,ge=te-j;for(const V of k)V.position={x:V.position.x-fe+Q[0]*(K-F),y:V.position.y-ge+Q[1]*(ee-H)},L.push(V)}if((Z||re)&&(D.width=Z&&(!i.resizeDirection||i.resizeDirection==="horizontal")?K:y.width,D.height=re&&(!i.resizeDirection||i.resizeDirection==="vertical")?ee:y.height,y.width=D.width,y.height=D.height),S&&v.expandParent){const fe=Q[0]*(D.width??0);D.x&&D.x<fe&&(y.x=fe,w.x=w.x-(D.x-fe));const ge=Q[1]*(D.height??0);D.y&&D.y<ge&&(y.y=ge,w.y=w.y-(D.y-ge))}const G=gV({width:y.width,prevWidth:F,height:y.height,prevHeight:H,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),J={...y,direction:G};x?.($,J)!==!1&&(I=!0,g?.($,J),r(D,L))}).on("end",$=>{I&&(b?.($,{...y}),s?.({...y}),I=!1)});a.call(B)}function c(){a.on(".drag",null)}return{update:l,destroy:c}}var Jv={exports:{}},e1={};/**
|
|
1105
|
-
* @license React
|
|
1106
|
-
* use-sync-external-store-shim/with-selector.production.js
|
|
1107
|
-
*
|
|
1108
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1109
|
-
*
|
|
1110
|
-
* This source code is licensed under the MIT license found in the
|
|
1111
|
-
* LICENSE file in the root directory of this source tree.
|
|
1112
|
-
*/var Ya=Ih,NV=v0;function kV(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var SV=typeof Object.is=="function"?Object.is:kV,CV=NV.useSyncExternalStore,MV=Ya.useRef,EV=Ya.useEffect,IV=Ya.useMemo,AV=Ya.useDebugValue;e1.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var a=MV(null);if(a.current===null){var i={hasValue:!1,value:null};a.current=i}else i=a.current;a=IV(function(){function c(m){if(!d){if(d=!0,f=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,SV(f,m))return g;var b=r(m);return s!==void 0&&s(g,b)?(f=m,g):(f=m,p=b)}var d=!1,f,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=CV(e,a[0],a[1]);return EV(function(){i.hasValue=!0,i.value=l},[l]),AV(l),l};Jv.exports=e1;var _V=Jv.exports;const PV=oN(_V),$V={},_f=e=>{let t;const n=new Set,r=(f,p)=>{const h=typeof f=="function"?f(t):f;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:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{($V?"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},DV=e=>e?_f(e):_f,{useDebugValue:TV}=ec,{useSyncExternalStoreWithSelector:LV}=PV,RV=e=>e;function t1(e,t=RV,n){const r=LV(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return TV(r),r}const Pf=(e,t)=>{const n=DV(e),r=(s,a=t)=>t1(n,s,a);return Object.assign(r,n),r},OV=(e,t)=>e?Pf(e,t):Pf;function Fe(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 Za=Oe(null),zV=Za.Provider,n1=Wt.error001();function Pe(e,t){const n=ve(Za);if(n===null)throw new Error(n1);return t1(n,e,t)}function He(){const e=ve(Za);if(e===null)throw new Error(n1);return q(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const $f={display:"none"},BV={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},r1="react-flow__node-desc",o1="react-flow__edge-desc",FV="react-flow__aria-live",jV=e=>e.ariaLiveMessage,HV=e=>e.ariaLabelConfig;function VV({rfId:e}){const t=Pe(jV);return o("div",{id:`${FV}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:BV,children:t})}function qV({rfId:e,disableKeyboardA11y:t}){const n=Pe(HV);return u(me,{children:[o("div",{id:`${r1}-${e}`,style:$f,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o("div",{id:`${o1}-${e}`,style:$f,children:n["edge.a11yDescription.default"]}),!t&&o(VV,{rfId:e})]})}const Xa=qe(({position:e="top-left",children:t,className:n,style:r,...s},a)=>{const i=`${e}`.split("-");return o("div",{className:Qe(["react-flow__panel",n,...i]),style:r,ref:a,...s,children:t})});Xa.displayName="Panel";function UV({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:o(Xa,{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 QV=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}},Ns=e=>e.id;function KV(e,t){return Fe(e.selectedNodes.map(Ns),t.selectedNodes.map(Ns))&&Fe(e.selectedEdges.map(Ns),t.selectedEdges.map(Ns))}function GV({onSelectionChange:e}){const t=He(),{selectedNodes:n,selectedEdges:r}=Pe(QV,KV);return Y(()=>{const s={nodes:n,edges:r};e?.(s),t.getState().onSelectionChangeHandlers.forEach(a=>a(s))},[n,r,e]),null}const WV=e=>!!e.onSelectionChangeHandlers;function YV({onSelectionChange:e}){const t=Pe(WV);return e||t?o(GV,{onSelectionChange:e}):null}const Yl=typeof window<"u"?fa:Y,s1=[0,0],ZV={x:0,y:0,zoom:1},XV=["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"],Df=[...XV,"rfId"],JV=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}),Tf={translateExtent:So,nodeOrigin:s1,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function eq(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:a,setNodeExtent:i,reset:l,setDefaultNodesAndEdges:c}=Pe(JV,Fe),d=He();Yl(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=Tf,l()}),[]);const f=ne(Tf);return Yl(()=>{for(const p of Df){const h=e[p],m=f.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:DH(h)}):p==="fitView"?d.setState({fitViewQueued:h}):p==="fitViewOptions"?d.setState({fitViewOptions:h}):d.setState({[p]:h})))}f.current=e},Df.map(p=>e[p])),null}function Lf(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function tq(e){const[t,n]=_(e==="system"?null:e);return Y(()=>{if(e!=="system"){n(e);return}const r=Lf(),s=()=>n(r?.matches?"dark":"light");return s(),r?.addEventListener("change",s),()=>{r?.removeEventListener("change",s)}},[e]),t!==null?t:Lf()?.matches?"dark":"light"}const Rf=typeof document<"u"?document:null;function Io(e=null,t={target:Rf,actInsideInputWithModifier:!0}){const[n,r]=_(!1),s=ne(!1),a=ne(new Set([])),[i,l]=q(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",`
|
|
1113
|
-
`).replace(`
|
|
1114
|
-
|
|
1115
|
-
`,`
|
|
1116
|
-
+`).split(`
|
|
1117
|
-
`)),f=d.reduce((p,h)=>p.concat(...h),[]);return[d,f]}return[[],[]]},[e]);return Y(()=>{const c=t?.target??Rf,d=t?.actInsideInputWithModifier??!0;if(e!==null){const f=m=>{if(s.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!s.current||s.current&&!d)&&Rv(m))return!1;const b=zf(m.code,l);if(a.current.add(m[b]),Of(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=zf(m.code,l);Of(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",f),c?.addEventListener("keyup",p),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{c?.removeEventListener("keydown",f),c?.removeEventListener("keyup",p),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[e,r]),n}function Of(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function zf(e,t){return t.includes(e)?"code":"key"}const nq=()=>{const e=He();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=zd(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},f=n.snapGrid??s,p=n.snapToGrid??a;return Ko(d,r,p,f)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:a}=r.getBoundingClientRect(),i=la(t,n);return{x:i.x+s,y:i.y+a}}}),[])};function a1(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)rq(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 rq(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 oq(e,t){return a1(e,t)}function sq(e,t){return a1(e,t)}function Fn(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(Fn(a.id,i)))}return r}function Bf({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 Ff(e){return{id:e.id,type:"remove"}}const jf=e=>kH(e),aq=e=>Iv(e);function i1(e){return qe(e)}function Hf(e){const[t,n]=_(BigInt(0)),[r]=_(()=>iq(()=>n(s=>s+BigInt(1))));return Yl(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function iq(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const l1=Oe(null);function lq({children:e}){const t=He(),n=U(l=>{const{nodes:c=[],setNodes:d,hasDefaultNodes:f,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=Bf({items:b,lookup:h});for(const y of g.values())x=y(x);f&&d(b),x.length>0?p?.(x):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:w,setNodes:v}=t.getState();y&&v(w)})},[]),r=Hf(n),s=U(l=>{const{edges:c=[],setEdges:d,hasDefaultEdges:f,onEdgesChange:p,edgeLookup:h}=t.getState();let m=c;for(const g of l)m=typeof g=="function"?g(m):g;f?d(m):p&&p(Bf({items:m,lookup:h}))},[]),a=Hf(s),i=q(()=>({nodeQueue:r,edgeQueue:a}),[]);return o(l1.Provider,{value:i,children:e})}function cq(){const e=ve(l1);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const dq=e=>!!e.panZoom;function Ud(){const e=nq(),t=He(),n=cq(),r=Pe(dq),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=jf(p)?p:h.get(p.id),b=g.parentId?Tv(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 $r(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&&jf(x)?x:{...b,...x}}return b}))},f=(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&&aq(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:S}=await IH({nodesToRemove:p,edgesToRemove:h,nodes:m,edges:g,onBeforeDelete:N}),E=S.length>0,A=k.length>0;if(E){const I=S.map(Ff);x?.(S),w(I)}if(A){const I=k.map(Ff);b?.(k),y(I)}return(A||E)&&v?.({nodes:k,edges:S}),{deletedNodes:k,deletedEdges:S}},getIntersectingNodes:(p,h=!0,m)=>{const g=bf(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=$r(x?y:w),N=Mo(v,b);return h&&N>0||N>=v.width*v.height||N>=b.width*b.height}):[]},isNodeIntersecting:(p,h,m=!0)=>{const b=bf(p)?p:c(p);if(!b)return!1;const x=Mo(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:f,updateEdgeData:(p,h,m={replace:!1})=>{f(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 SH(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??$H();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:h}),n.nodeQueue.push(m=>[...m]),h.promise}}},[]);return q(()=>({...s,...e,viewportInitialized:r}),[r])}const Vf=e=>e.selected,uq=typeof window<"u"?window:void 0;function pq({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=He(),{deleteElements:r}=Ud(),s=Io(e,{actInsideInputWithModifier:!1}),a=Io(t,{target:uq});Y(()=>{if(s){const{edges:i,nodes:l}=n.getState();r({nodes:l.filter(Vf),edges:i.filter(Vf)}),n.setState({nodesSelectionActive:!1})}},[s]),Y(()=>{n.setState({multiSelectionActive:a})},[a])}function fq(e){const t=He();Y(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const r=Bd(e.current);(r.height===0||r.width===0)&&t.getState().onError?.("004",Wt.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 Ja={position:"absolute",width:"100%",height:"100%",top:0,left:0},hq=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function mq({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:a=Un.Free,zoomOnDoubleClick:i=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:d,minZoom:f,maxZoom:p,zoomActivationKeyCode:h,preventScrolling:m=!0,children:g,noWheelClassName:b,noPanClassName:x,onViewportChange:y,isControlledViewport:w,paneClickDistance:v,selectionOnDrag:N}){const k=He(),S=ne(null),{userSelectionActive:E,lib:A,connectionInProgress:I}=Pe(hq,Fe),B=Io(h),$=ne();fq(S);const z=U(R=>{y?.({x:R[0],y:R[1],zoom:R[2]}),w||k.setState({transform:R})},[y,w]);return Y(()=>{if(S.current){$.current=mV({domNode:S.current,minZoom:f,maxZoom:p,translateExtent:d,viewport:c,onDraggingChange:P=>k.setState(L=>L.paneDragging===P?L:{paneDragging:P}),onPanZoomStart:(P,L)=>{const{onViewportChangeStart:O,onMoveStart:j}=k.getState();j?.(P,L),O?.(L)},onPanZoom:(P,L)=>{const{onViewportChange:O,onMove:j}=k.getState();j?.(P,L),O?.(L)},onPanZoomEnd:(P,L)=>{const{onViewportChangeEnd:O,onMoveEnd:j}=k.getState();j?.(P,L),O?.(L)}});const{x:R,y:M,zoom:T}=$.current.getViewport();return k.setState({panZoom:$.current,transform:[R,M,T],domNode:S.current.closest(".react-flow")}),()=>{$.current?.destroy()}}},[]),Y(()=>{$.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:a,zoomOnDoubleClick:i,panOnDrag:l,zoomActivationKeyPressed:B,preventScrolling:m,noPanClassName:x,userSelectionActive:E,noWheelClassName:b,lib:A,onTransformChange:z,connectionInProgress:I,selectionOnDrag:N,paneClickDistance:v})},[e,t,n,r,s,a,i,l,B,m,x,E,b,A,z,I,N,v]),o("div",{className:"react-flow__renderer",ref:S,style:Ja,children:g})}const gq=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function bq(){const{userSelectionActive:e,userSelectionRect:t}=Pe(gq,Fe);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 Yi=(e,t)=>n=>{n.target===t.current&&e?.(n)},xq=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function yq({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Co.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:a,onSelectionStart:i,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:d,onPaneScroll:f,onPaneMouseEnter:p,onPaneMouseMove:h,onPaneMouseLeave:m,children:g}){const b=He(),{userSelectionActive:x,elementsSelectable:y,dragging:w,connectionInProgress:v}=Pe(xq,Fe),N=y&&(e||x),k=ne(null),S=ne(),E=ne(new Set),A=ne(new Set),I=ne(!1),B=O=>{if(I.current||v){I.current=!1;return}c?.(O),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},$=O=>{if(Array.isArray(r)&&r?.includes(2)){O.preventDefault();return}d?.(O)},z=f?O=>f(O):void 0,R=O=>{I.current&&(O.stopPropagation(),I.current=!1)},M=O=>{const{domNode:j}=b.getState();if(S.current=j?.getBoundingClientRect(),!S.current)return;const F=O.target===k.current;if(!F&&!!O.target.closest(".nokey")||!e||!(a&&F||t)||O.button!==0||!O.isPrimary)return;O.target?.setPointerCapture?.(O.pointerId),I.current=!1;const{x:Q,y:K}=Dt(O.nativeEvent,S.current);b.setState({userSelectionRect:{width:0,height:0,startX:Q,startY:K,x:Q,y:K}}),F||(O.stopPropagation(),O.preventDefault())},T=O=>{const{userSelectionRect:j,transform:F,nodeLookup:H,edgeLookup:D,connectionLookup:Q,triggerNodeChanges:K,triggerEdgeChanges:ee,defaultEdgeOptions:oe,resetSelectedElements:te}=b.getState();if(!S.current||!j)return;const{x:Z,y:re}=Dt(O.nativeEvent,S.current),{startX:be,startY:X}=j;if(!I.current){const ge=t?0:s;if(Math.hypot(Z-be,re-X)<=ge)return;te(),i?.(O)}I.current=!0;const G={startX:be,startY:X,x:Z<be?Z:be,y:re<X?re:X,width:Math.abs(Z-be),height:Math.abs(re-X)},J=E.current,ae=A.current;E.current=new Set(Od(H,G,F,n===Co.Partial,!0).map(ge=>ge.id)),A.current=new Set;const fe=oe?.selectable??!0;for(const ge of E.current){const V=Q.get(ge);if(V)for(const{edgeId:ie}of V.values()){const ue=D.get(ie);ue&&(ue.selectable??fe)&&A.current.add(ie)}}if(!xf(J,E.current)){const ge=mr(H,E.current,!0);K(ge)}if(!xf(ae,A.current)){const ge=mr(D,A.current);ee(ge)}b.setState({userSelectionRect:G,userSelectionActive:!0,nodesSelectionActive:!1})},P=O=>{O.button===0&&(O.target?.releasePointerCapture?.(O.pointerId),!x&&O.target===k.current&&b.getState().userSelectionRect&&B?.(O),b.setState({userSelectionActive:!1,userSelectionRect:null}),I.current&&(l?.(O),b.setState({nodesSelectionActive:E.current.size>0})))},L=r===!0||Array.isArray(r)&&r.includes(0);return u("div",{className:Qe(["react-flow__pane",{draggable:L,dragging:w,selection:e}]),onClick:N?void 0:Yi(B,k),onContextMenu:Yi($,k),onWheel:Yi(z,k),onPointerEnter:N?void 0:p,onPointerMove:N?T:h,onPointerUp:N?P:void 0,onPointerDownCapture:N?M:void 0,onClickCapture:N?R:void 0,onPointerLeave:m,ref:k,style:Ja,children:[g,o(bq,{})]})}function Zl({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",Wt.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&i)&&(a({nodes:[d],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):s([e])}function c1({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:a,nodeClickDistance:i}){const l=He(),[c,d]=_(!1),f=ne();return Y(()=>{f.current=tV({getStoreItems:()=>l.getState(),onNodeMouseDown:p=>{Zl({id:p,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),Y(()=>{if(!(t||!e.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:s,nodeClickDistance:i}),()=>{f.current?.destroy()}},[n,r,t,a,e,s,i]),c}const vq=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function d1(){const e=He();return U(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:a,nodesDraggable:i,onError:l,updateNodePositions:c,nodeLookup:d,nodeOrigin:f}=e.getState(),p=new Map,h=vq(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=Qo(w,a));const{position:v,positionAbsolute:N}=Av({nodeId:y.id,nextPosition:w,nodeLookup:d,nodeExtent:r,nodeOrigin:f,onError:l});y.position=v,y.internals.positionAbsolute=N,p.set(y.id,y)}c(p)},[])}const Qd=Oe(null),wq=Qd.Provider;Qd.Consumer;const u1=()=>ve(Qd),Nq=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),kq=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:a,connection:i}=r,{fromHandle:l,toHandle:c,isValid:d}=i,f=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:l?.nodeId===e&&l?.id===t&&l?.type===n,connectingTo:f,clickConnecting:s?.nodeId===e&&s?.id===t&&s?.type===n,isPossibleEndHandle:a===_r.Strict?l?.type!==n:e!==l?.nodeId||t!==l?.id,connectionInProcess:!!l,clickConnectionInProcess:!!s,valid:f&&d}};function Sq({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:f,onTouchStart:p,...h},m){const g=i||null,b=e==="target",x=He(),y=u1(),{connectOnClick:w,noPanClassName:v,rfId:N}=Pe(Nq,Fe),{connectingFrom:k,connectingTo:S,clickConnecting:E,isPossibleEndHandle:A,connectionInProcess:I,clickConnectionInProcess:B,valid:$}=Pe(kq(y,g,e),Fe);y||x.getState().onError?.("010",Wt.error010());const z=T=>{const{defaultEdgeOptions:P,onConnect:L,hasDefaultEdges:O}=x.getState(),j={...P,...T};if(O){const{edges:F,setEdges:H}=x.getState();H(BH(j,F))}L?.(j),l?.(j)},R=T=>{if(!y)return;const P=Ov(T.nativeEvent);if(s&&(P&&T.button===0||!P)){const L=x.getState();Wl.onPointerDown(T.nativeEvent,{handleDomNode:T.currentTarget,autoPanOnConnect:L.autoPanOnConnect,connectionMode:L.connectionMode,connectionRadius:L.connectionRadius,domNode:L.domNode,nodeLookup:L.nodeLookup,lib:L.lib,isTarget:b,handleId:g,nodeId:y,flowId:L.rfId,panBy:L.panBy,cancelConnection:L.cancelConnection,onConnectStart:L.onConnectStart,onConnectEnd:(...O)=>x.getState().onConnectEnd?.(...O),updateConnection:L.updateConnection,onConnect:z,isValidConnection:n||((...O)=>x.getState().isValidConnection?.(...O)??!0),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:L.autoPanSpeed,dragThreshold:L.connectionDragThreshold})}P?f?.(T):p?.(T)},M=T=>{const{onClickConnectStart:P,onClickConnectEnd:L,connectionClickStartHandle:O,connectionMode:j,isValidConnection:F,lib:H,rfId:D,nodeLookup:Q,connection:K}=x.getState();if(!y||!O&&!s)return;if(!O){P?.(T.nativeEvent,{nodeId:y,handleId:g,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const ee=Lv(T.target),oe=n||F,{connection:te,isValid:Z}=Wl.isValid(T.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:j,fromNodeId:O.nodeId,fromHandleId:O.id||null,fromType:O.type,isValidConnection:oe,flowId:D,doc:ee,lib:H,nodeLookup:Q});Z&&te&&z(te);const re=structuredClone(K);delete re.inProgress,re.toPosition=re.toHandle?re.toHandle.position:null,L?.(T,re),x.setState({connectionClickStartHandle:null})};return o("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${N}-${y}-${g}-${e}`,className:Qe(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",v,d,{source:!b,target:b,connectable:r,connectablestart:s,connectableend:a,clickconnecting:E,connectingfrom:k,connectingto:S,valid:$,connectionindicator:r&&(!I||A)&&(I||B?a:s)}]),onMouseDown:R,onTouchStart:R,onClick:w?M:void 0,ref:m,...h,children:c})}const In=je(i1(Sq));function Cq({data:e,isConnectable:t,sourcePosition:n=we.Bottom}){return u(me,{children:[e?.label,o(In,{type:"source",position:n,isConnectable:t})]})}function Mq({data:e,isConnectable:t,targetPosition:n=we.Top,sourcePosition:r=we.Bottom}){return u(me,{children:[o(In,{type:"target",position:n,isConnectable:t}),e?.label,o(In,{type:"source",position:r,isConnectable:t})]})}function Eq(){return null}function Iq({data:e,isConnectable:t,targetPosition:n=we.Top}){return u(me,{children:[o(In,{type:"target",position:n,isConnectable:t}),e?.label]})}const ca={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},qf={input:Cq,default:Mq,output:Iq,group:Eq};function Aq(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 _q=e=>{const{width:t,height:n,x:r,y:s}=Uo(e.nodeLookup,{filter:a=>!!a.selected});return{width:$t(t)?t:null,height:$t(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${s}px)`}};function Pq({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=He(),{width:s,height:a,transformString:i,userSelectionActive:l}=Pe(_q,Fe),c=d1(),d=ne(null);Y(()=>{n||d.current?.focus({preventScroll:!0})},[n]);const f=!l&&s!==null&&a!==null;if(c1({nodeRef:d,disabled:!f}),!f)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(ca,m.key)&&(m.preventDefault(),c({direction:ca[m.key],factor:m.shiftKey?4:1}))};return o("div",{className:Qe(["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 Uf=typeof window<"u"?window:void 0,$q=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function p1({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:i,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:d,selectionOnDrag:f,selectionMode:p,onSelectionStart:h,onSelectionEnd:m,multiSelectionKeyCode:g,panActivationKeyCode:b,zoomActivationKeyCode:x,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:v,panOnScroll:N,panOnScrollSpeed:k,panOnScrollMode:S,zoomOnDoubleClick:E,panOnDrag:A,defaultViewport:I,translateExtent:B,minZoom:$,maxZoom:z,preventScrolling:R,onSelectionContextMenu:M,noWheelClassName:T,noPanClassName:P,disableKeyboardA11y:L,onViewportChange:O,isControlledViewport:j}){const{nodesSelectionActive:F,userSelectionActive:H}=Pe($q,Fe),D=Io(d,{target:Uf}),Q=Io(b,{target:Uf}),K=Q||A,ee=Q||N,oe=f&&K!==!0,te=D||H||oe;return pq({deleteKeyCode:c,multiSelectionKeyCode:g}),o(mq,{onPaneContextMenu:a,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:v,panOnScroll:ee,panOnScrollSpeed:k,panOnScrollMode:S,zoomOnDoubleClick:E,panOnDrag:!D&&K,defaultViewport:I,translateExtent:B,minZoom:$,maxZoom:z,zoomActivationKeyCode:x,preventScrolling:R,noWheelClassName:T,noPanClassName:P,onViewportChange:O,isControlledViewport:j,paneClickDistance:l,selectionOnDrag:oe,children:u(yq,{onSelectionStart:h,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:i,panOnDrag:K,isSelecting:!!te,selectionMode:p,selectionKeyPressed:D,paneClickDistance:l,selectionOnDrag:oe,children:[e,F&&o(Pq,{onSelectionContextMenu:M,noPanClassName:P,disableKeyboardA11y:L})]})})}p1.displayName="FlowRenderer";const Dq=je(p1),Tq=e=>t=>e?Od(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 Lq(e){return Pe(U(Tq(e),[e]),Fe)}const Rq=e=>e.updateNodeInternals;function Oq(){const e=Pe(Rq),[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 zq({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=He(),a=ne(null),i=ne(null),l=ne(e.sourcePosition),c=ne(e.targetPosition),d=ne(t),f=n&&!!e.internals.handleBounds;return Y(()=>{a.current&&!e.hidden&&(!f||i.current!==a.current)&&(i.current&&r?.unobserve(i.current),r?.observe(a.current),i.current=a.current)},[f,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 Bq({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:a,onDoubleClick:i,nodesDraggable:l,elementsSelectable:c,nodesConnectable:d,nodesFocusable:f,resizeObserver:p,noDragClassName:h,noPanClassName:m,disableKeyboardA11y:g,rfId:b,nodeTypes:x,nodeClickDistance:y,onError:w}){const{node:v,internals:N,isParent:k}=Pe(Z=>{const re=Z.nodeLookup.get(e),be=Z.parentLookup.has(e);return{node:re,internals:re.internals,isParent:be}},Fe);let S=v.type||"default",E=x?.[S]||qf[S];E===void 0&&(w?.("003",Wt.error003(S)),S="default",E=x?.default||qf.default);const A=!!(v.draggable||l&&typeof v.draggable>"u"),I=!!(v.selectable||c&&typeof v.selectable>"u"),B=!!(v.connectable||d&&typeof v.connectable>"u"),$=!!(v.focusable||f&&typeof v.focusable>"u"),z=He(),R=Dv(v),M=zq({node:v,nodeType:S,hasDimensions:R,resizeObserver:p}),T=c1({nodeRef:M,disabled:v.hidden||!A,noDragClassName:h,handleSelector:v.dragHandle,nodeId:e,isSelectable:I,nodeClickDistance:y}),P=d1();if(v.hidden)return null;const L=gn(v),O=Aq(v),j=I||A||t||n||r||s,F=n?Z=>n(Z,{...N.userNode}):void 0,H=r?Z=>r(Z,{...N.userNode}):void 0,D=s?Z=>s(Z,{...N.userNode}):void 0,Q=a?Z=>a(Z,{...N.userNode}):void 0,K=i?Z=>i(Z,{...N.userNode}):void 0,ee=Z=>{const{selectNodesOnDrag:re,nodeDragThreshold:be}=z.getState();I&&(!re||!A||be>0)&&Zl({id:e,store:z,nodeRef:M}),t&&t(Z,{...N.userNode})},oe=Z=>{if(!(Rv(Z.nativeEvent)||g)){if(Sv.includes(Z.key)&&I){const re=Z.key==="Escape";Zl({id:e,store:z,unselect:re,nodeRef:M})}else if(A&&v.selected&&Object.prototype.hasOwnProperty.call(ca,Z.key)){Z.preventDefault();const{ariaLabelConfig:re}=z.getState();z.setState({ariaLiveMessage:re["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),P({direction:ca[Z.key],factor:Z.shiftKey?4:1})}}},te=()=>{if(g||!M.current?.matches(":focus-visible"))return;const{transform:Z,width:re,height:be,autoPanOnNodeFocus:X,setCenter:G}=z.getState();if(!X)return;Od(new Map([[e,v]]),{x:0,y:0,width:re,height:be},Z,!0).length>0||G(v.position.x+L.width/2,v.position.y+L.height/2,{zoom:Z[2]})};return o("div",{className:Qe(["react-flow__node",`react-flow__node-${S}`,{[m]:A},v.className,{selected:v.selected,selectable:I,parent:k,draggable:A,dragging:T}]),ref:M,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:j?"all":"none",visibility:R?"visible":"hidden",...v.style,...O},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:F,onMouseMove:H,onMouseLeave:D,onContextMenu:Q,onClick:ee,onDoubleClick:K,onKeyDown:$?oe:void 0,tabIndex:$?0:void 0,onFocus:$?te:void 0,role:v.ariaRole??($?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${r1}-${b}`,"aria-label":v.ariaLabel,...v.domAttributes,children:o(wq,{value:e,children:o(E,{id:e,data:v.data,type:S,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:v.selected??!1,selectable:I,draggable:A,deletable:v.deletable??!0,isConnectable:B,sourcePosition:v.sourcePosition,targetPosition:v.targetPosition,dragging:T,dragHandle:v.dragHandle,zIndex:N.z,parentId:v.parentId,...L})})})}var Fq=je(Bq);const jq=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function f1(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:a}=Pe(jq,Fe),i=Lq(e.onlyRenderVisibleElements),l=Oq();return o("div",{className:"react-flow__nodes",style:Ja,children:i.map(c=>o(Fq,{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))})}f1.displayName="NodeRenderer";const Hq=je(f1);function Vq(e){return Pe(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&&RH({sourceNode:a,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),Fe)}const qq=({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"})},Uq=({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"})},Qf={[aa.Arrow]:qq,[aa.ArrowClosed]:Uq};function Qq(e){const t=He();return q(()=>Object.prototype.hasOwnProperty.call(Qf,e)?Qf[e]:(t.getState().onError?.("009",Wt.error009(e)),null),[e])}const Kq=({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=Qq(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},h1=({defaultColor:e,rfId:t})=>{const n=Pe(a=>a.edges),r=Pe(a=>a.defaultEdgeOptions),s=q(()=>qH(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(Kq,{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};h1.displayName="MarkerDefinitions";var Gq=je(h1);function m1({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:a,labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...f}){const[p,h]=_({x:1,y:0,width:0,height:0}),m=Qe(["react-flow__edge-textwrapper",d]),g=ne(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?u("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:m,visibility:p.width?"visible":"hidden",...f,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}m1.displayName="EdgeText";const Wq=je(m1);function ei({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:d=20,...f}){return u(me,{children:[o("path",{...f,d:e,fill:"none",className:Qe(["react-flow__edge-path",f.className])}),d?o("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,r&&$t(t)&&$t(n)?o(Wq,{x:t,y:n,label:r,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function Kf({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 g1({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:r,targetY:s,targetPosition:a=we.Top}){const[i,l]=Kf({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,d]=Kf({pos:a,x1:r,y1:s,x2:e,y2:t}),[f,p,h,m]=zv({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}`,f,p,h,m]}function b1(e){return je(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:a,sourcePosition:i,targetPosition:l,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:x,interactionWidth:y})=>{const[w,v,N]=g1({sourceX:n,sourceY:r,sourcePosition:i,targetX:s,targetY:a,targetPosition:l}),k=e.isInternal?void 0:t;return o(ei,{id:k,path:w,labelX:v,labelY:N,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:x,interactionWidth:y})})}const Yq=b1({isInternal:!1}),x1=b1({isInternal:!0});Yq.displayName="SimpleBezierEdge";x1.displayName="SimpleBezierEdgeInternal";function y1(e){return je(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:a,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:h,sourcePosition:m=we.Bottom,targetPosition:g=we.Top,markerEnd:b,markerStart:x,pathOptions:y,interactionWidth:w})=>{const[v,N,k]=Ql({sourceX:n,sourceY:r,sourcePosition:m,targetX:s,targetY:a,targetPosition:g,borderRadius:y?.borderRadius,offset:y?.offset,stepPosition:y?.stepPosition}),S=e.isInternal?void 0:t;return o(ei,{id:S,path:v,labelX:N,labelY:k,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:h,markerEnd:b,markerStart:x,interactionWidth:w})})}const v1=y1({isInternal:!1}),w1=y1({isInternal:!0});v1.displayName="SmoothStepEdge";w1.displayName="SmoothStepEdgeInternal";function N1(e){return je(({id:t,...n})=>{const r=e.isInternal?void 0:t;return o(v1,{...n,id:r,pathOptions:q(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const Zq=N1({isInternal:!1}),k1=N1({isInternal:!0});Zq.displayName="StepEdge";k1.displayName="StepEdgeInternal";function S1(e){return je(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:a,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:h,markerEnd:m,markerStart:g,interactionWidth:b})=>{const[x,y,w]=jv({sourceX:n,sourceY:r,targetX:s,targetY:a}),v=e.isInternal?void 0:t;return o(ei,{id:v,path:x,labelX:y,labelY:w,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:h,markerEnd:m,markerStart:g,interactionWidth:b})})}const Xq=S1({isInternal:!1}),C1=S1({isInternal:!0});Xq.displayName="StraightEdge";C1.displayName="StraightEdgeInternal";function M1(e){return je(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:a,sourcePosition:i=we.Bottom,targetPosition:l=we.Top,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:x,pathOptions:y,interactionWidth:w})=>{const[v,N,k]=Bv({sourceX:n,sourceY:r,sourcePosition:i,targetX:s,targetY:a,targetPosition:l,curvature:y?.curvature}),S=e.isInternal?void 0:t;return o(ei,{id:S,path:v,labelX:N,labelY:k,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:x,interactionWidth:w})})}const Jq=M1({isInternal:!1}),E1=M1({isInternal:!0});Jq.displayName="BezierEdge";E1.displayName="BezierEdgeInternal";const Gf={default:E1,straight:C1,step:k1,smoothstep:w1,simplebezier:x1},Wf={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},eU=(e,t,n)=>n===we.Left?e-t:n===we.Right?e+t:e,tU=(e,t,n)=>n===we.Top?e-t:n===we.Bottom?e+t:e,Yf="react-flow__edgeupdater";function Zf({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:Qe([Yf,`${Yf}-${l}`]),cx:eU(t,r,e),cy:tU(n,r,e),r,stroke:"transparent",fill:"transparent"})}function nU({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:a,targetY:i,sourcePosition:l,targetPosition:c,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,setReconnecting:h,setUpdateHover:m}){const g=He(),b=(N,k)=>{if(N.button!==0)return;const{autoPanOnConnect:S,domNode:E,connectionMode:A,connectionRadius:I,lib:B,onConnectStart:$,cancelConnection:z,nodeLookup:R,rfId:M,panBy:T,updateConnection:P}=g.getState(),L=k.type==="target",O=(H,D)=>{h(!1),p?.(H,n,k.type,D)},j=H=>d?.(n,H),F=(H,D)=>{h(!0),f?.(N,n,k.type),$?.(H,D)};Wl.onPointerDown(N.nativeEvent,{autoPanOnConnect:S,connectionMode:A,connectionRadius:I,domNode:E,handleId:k.id,nodeId:k.nodeId,nodeLookup:R,isTarget:L,edgeUpdaterType:k.type,lib:B,flowId:M,cancelConnection:z,panBy:T,isValidConnection:(...H)=>g.getState().isValidConnection?.(...H)??!0,onConnect:j,onConnectStart:F,onConnectEnd:(...H)=>g.getState().onConnectEnd?.(...H),onReconnectEnd:O,updateConnection:P,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 u(me,{children:[(e===!0||e==="source")&&o(Zf,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:x,onMouseEnter:w,onMouseOut:v,type:"source"}),(e===!0||e==="target")&&o(Zf,{position:c,centerX:a,centerY:i,radius:t,onMouseDown:y,onMouseEnter:w,onMouseOut:v,type:"target"})]})}function rU({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:a,onContextMenu:i,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,reconnectRadius:f,onReconnect:p,onReconnectStart:h,onReconnectEnd:m,rfId:g,edgeTypes:b,noPanClassName:x,onError:y,disableKeyboardA11y:w}){let v=Pe(G=>G.edgeLookup.get(e));const N=Pe(G=>G.defaultEdgeOptions);v=N?{...N,...v}:v;let k=v.type||"default",S=b?.[k]||Gf[k];S===void 0&&(y?.("011",Wt.error011(k)),k="default",S=b?.default||Gf.default);const E=!!(v.focusable||t&&typeof v.focusable>"u"),A=typeof p<"u"&&(v.reconnectable||n&&typeof v.reconnectable>"u"),I=!!(v.selectable||r&&typeof v.selectable>"u"),B=ne(null),[$,z]=_(!1),[R,M]=_(!1),T=He(),{zIndex:P,sourceX:L,sourceY:O,targetX:j,targetY:F,sourcePosition:H,targetPosition:D}=Pe(U(G=>{const J=G.nodeLookup.get(v.source),ae=G.nodeLookup.get(v.target);if(!J||!ae)return{zIndex:v.zIndex,...Wf};const fe=VH({id:e,sourceNode:J,targetNode:ae,sourceHandle:v.sourceHandle||null,targetHandle:v.targetHandle||null,connectionMode:G.connectionMode,onError:y});return{zIndex:LH({selected:v.selected,zIndex:v.zIndex,sourceNode:J,targetNode:ae,elevateOnSelect:G.elevateEdgesOnSelect,zIndexMode:G.zIndexMode}),...fe||Wf}},[v.source,v.target,v.sourceHandle,v.targetHandle,v.selected,v.zIndex]),Fe),Q=q(()=>v.markerStart?`url('#${Kl(v.markerStart,g)}')`:void 0,[v.markerStart,g]),K=q(()=>v.markerEnd?`url('#${Kl(v.markerEnd,g)}')`:void 0,[v.markerEnd,g]);if(v.hidden||L===null||O===null||j===null||F===null)return null;const ee=G=>{const{addSelectedEdges:J,unselectNodesAndEdges:ae,multiSelectionActive:fe}=T.getState();I&&(T.setState({nodesSelectionActive:!1}),v.selected&&fe?(ae({nodes:[],edges:[v]}),B.current?.blur()):J([e])),s&&s(G,v)},oe=a?G=>{a(G,{...v})}:void 0,te=i?G=>{i(G,{...v})}:void 0,Z=l?G=>{l(G,{...v})}:void 0,re=c?G=>{c(G,{...v})}:void 0,be=d?G=>{d(G,{...v})}:void 0,X=G=>{if(!w&&Sv.includes(G.key)&&I){const{unselectNodesAndEdges:J,addSelectedEdges:ae}=T.getState();G.key==="Escape"?(B.current?.blur(),J({edges:[v]})):ae([e])}};return o("svg",{style:{zIndex:P},children:u("g",{className:Qe(["react-flow__edge",`react-flow__edge-${k}`,v.className,x,{selected:v.selected,animated:v.animated,inactive:!I&&!s,updating:$,selectable:I}]),onClick:ee,onDoubleClick:oe,onContextMenu:te,onMouseEnter:Z,onMouseMove:re,onMouseLeave:be,onKeyDown:E?X:void 0,tabIndex:E?0:void 0,role:v.ariaRole??(E?"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":E?`${o1}-${g}`:void 0,ref:B,...v.domAttributes,children:[!R&&o(S,{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:L,sourceY:O,targetX:j,targetY:F,sourcePosition:H,targetPosition:D,data:v.data,style:v.style,sourceHandleId:v.sourceHandle,targetHandleId:v.targetHandle,markerStart:Q,markerEnd:K,pathOptions:"pathOptions"in v?v.pathOptions:void 0,interactionWidth:v.interactionWidth}),A&&o(nU,{edge:v,isReconnectable:A,reconnectRadius:f,onReconnect:p,onReconnectStart:h,onReconnectEnd:m,sourceX:L,sourceY:O,targetX:j,targetY:F,sourcePosition:H,targetPosition:D,setUpdateHover:z,setReconnecting:M})]})})}var oU=je(rU);const sU=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function I1({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:a,onEdgeContextMenu:i,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeClick:f,reconnectRadius:p,onEdgeDoubleClick:h,onReconnectStart:m,onReconnectEnd:g,disableKeyboardA11y:b}){const{edgesFocusable:x,edgesReconnectable:y,elementsSelectable:w,onError:v}=Pe(sU,Fe),N=Vq(t);return u("div",{className:"react-flow__edges",children:[o(Gq,{defaultColor:e,rfId:n}),N.map(k=>o(oU,{id:k,edgesFocusable:x,edgesReconnectable:y,elementsSelectable:w,noPanClassName:s,onReconnect:a,onContextMenu:i,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onClick:f,reconnectRadius:p,onDoubleClick:h,onReconnectStart:m,onReconnectEnd:g,rfId:n,onError:v,edgeTypes:r,disableKeyboardA11y:b},k))]})}I1.displayName="EdgeRenderer";const aU=je(I1),iU=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function lU({children:e}){const t=Pe(iU);return o("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function cU(e){const t=Ud(),n=ne(!1);Y(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const dU=e=>e.panZoom?.syncViewport;function uU(e){const t=Pe(dU),n=He();return Y(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function pU(e){return e.connection.inProgress?{...e.connection,to:Ko(e.connection.to,e.transform)}:{...e.connection}}function fU(e){return pU}function hU(e){const t=fU();return Pe(t,Fe)}const mU=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function gU({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:a,height:i,isValid:l,inProgress:c}=Pe(mU,Fe);return!(a&&s&&c)?null:o("svg",{style:e,width:a,height:i,className:"react-flow__connectionline react-flow__container",children:o("g",{className:Qe(["react-flow__connection",Ev(l)]),children:o(A1,{style:t,type:n,CustomComponent:r,isValid:l})})})}const A1=({style:e,type:t=wn.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:a,fromNode:i,fromHandle:l,fromPosition:c,to:d,toNode:f,toHandle:p,toPosition:h,pointer:m}=hU();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:Ev(r),toNode:f,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 wn.Bezier:[g]=Bv(b);break;case wn.SimpleBezier:[g]=g1(b);break;case wn.Step:[g]=Ql({...b,borderRadius:0});break;case wn.SmoothStep:[g]=Ql(b);break;default:[g]=jv(b)}return o("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};A1.displayName="ConnectionLine";const bU={};function Xf(e=bU){ne(e),He(),Y(()=>{},[e])}function xU(){He(),ne(!1),Y(()=>{},[])}function _1({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:a,onEdgeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,onSelectionContextMenu:p,onSelectionStart:h,onSelectionEnd:m,connectionLineType:g,connectionLineStyle:b,connectionLineComponent:x,connectionLineContainerStyle:y,selectionKeyCode:w,selectionOnDrag:v,selectionMode:N,multiSelectionKeyCode:k,panActivationKeyCode:S,zoomActivationKeyCode:E,deleteKeyCode:A,onlyRenderVisibleElements:I,elementsSelectable:B,defaultViewport:$,translateExtent:z,minZoom:R,maxZoom:M,preventScrolling:T,defaultMarkerColor:P,zoomOnScroll:L,zoomOnPinch:O,panOnScroll:j,panOnScrollSpeed:F,panOnScrollMode:H,zoomOnDoubleClick:D,panOnDrag:Q,onPaneClick:K,onPaneMouseEnter:ee,onPaneMouseMove:oe,onPaneMouseLeave:te,onPaneScroll:Z,onPaneContextMenu:re,paneClickDistance:be,nodeClickDistance:X,onEdgeContextMenu:G,onEdgeMouseEnter:J,onEdgeMouseMove:ae,onEdgeMouseLeave:fe,reconnectRadius:ge,onReconnect:V,onReconnectStart:ie,onReconnectEnd:ue,noDragClassName:de,noWheelClassName:ce,noPanClassName:Se,disableKeyboardA11y:pe,nodeExtent:Ie,rfId:Le,viewport:Ye,onViewportChange:ot}){return Xf(e),Xf(t),xU(),cU(n),uU(Ye),o(Dq,{onPaneClick:K,onPaneMouseEnter:ee,onPaneMouseMove:oe,onPaneMouseLeave:te,onPaneContextMenu:re,onPaneScroll:Z,paneClickDistance:be,deleteKeyCode:A,selectionKeyCode:w,selectionOnDrag:v,selectionMode:N,onSelectionStart:h,onSelectionEnd:m,multiSelectionKeyCode:k,panActivationKeyCode:S,zoomActivationKeyCode:E,elementsSelectable:B,zoomOnScroll:L,zoomOnPinch:O,zoomOnDoubleClick:D,panOnScroll:j,panOnScrollSpeed:F,panOnScrollMode:H,panOnDrag:Q,defaultViewport:$,translateExtent:z,minZoom:R,maxZoom:M,onSelectionContextMenu:p,preventScrolling:T,noDragClassName:de,noWheelClassName:ce,noPanClassName:Se,disableKeyboardA11y:pe,onViewportChange:ot,isControlledViewport:!!Ye,children:u(lU,{children:[o(aU,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:i,onReconnect:V,onReconnectStart:ie,onReconnectEnd:ue,onlyRenderVisibleElements:I,onEdgeContextMenu:G,onEdgeMouseEnter:J,onEdgeMouseMove:ae,onEdgeMouseLeave:fe,reconnectRadius:ge,defaultMarkerColor:P,noPanClassName:Se,disableKeyboardA11y:pe,rfId:Le}),o(gU,{style:b,type:g,component:x,containerStyle:y}),o("div",{className:"react-flow__edgelabel-renderer"}),o(Hq,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,nodeClickDistance:X,onlyRenderVisibleElements:I,noPanClassName:Se,noDragClassName:de,disableKeyboardA11y:pe,nodeExtent:Ie,rfId:Le}),o("div",{className:"react-flow__viewport-portal"})]})})}_1.displayName="GraphView";const yU=je(_1),Jf=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c=.5,maxZoom:d=2,nodeOrigin:f,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=f??[0,0],N=p??So;qv(b,x,y);const{nodesInitialized:k}=Gl(w,m,g,{nodeOrigin:v,nodeExtent:N,zIndexMode:h});let S=[0,0,1];if(i&&s&&a){const E=Uo(m,{filter:$=>!!(($.width||$.initialWidth)&&($.height||$.initialHeight))}),{x:A,y:I,zoom:B}=zd(E,s,a,c,d,l?.padding??.1);S=[A,I,B]}return{rfId:"1",width:s??0,height:a??0,transform:S,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:So,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:_r.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:{...Mv},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:AH,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Cv,zIndexMode:h,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},vU=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:p,zIndexMode:h})=>OV((m,g)=>{async function b(){const{nodeLookup:x,panZoom:y,fitViewOptions:w,fitViewResolver:v,width:N,height:k,minZoom:S,maxZoom:E}=g();y&&(await EH({nodes:x,width:N,height:k,panZoom:y,minZoom:S,maxZoom:E},w),v?.resolve(!0),m({fitViewResolver:null}))}return{...Jf({nodes:e,edges:t,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:p,defaultNodes:n,defaultEdges:r,zIndexMode:h}),setNodes:x=>{const{nodeLookup:y,parentLookup:w,nodeOrigin:v,elevateNodesOnSelect:N,fitViewQueued:k,zIndexMode:S,nodesSelectionActive:E}=g(),{nodesInitialized:A,hasSelectedNodes:I}=Gl(x,y,w,{nodeOrigin:v,nodeExtent:p,elevateNodesOnSelect:N,checkEquality:!0,zIndexMode:S}),B=E&&I;k&&A?(b(),m({nodes:x,nodesInitialized:A,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:B})):m({nodes:x,nodesInitialized:A,nodesSelectionActive:B})},setEdges:x=>{const{connectionLookup:y,edgeLookup:w}=g();qv(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:S,debug:E,fitViewQueued:A,zIndexMode:I}=g(),{changes:B,updatedInternals:$}=ZH(x,w,v,N,k,S,I);$&&(KH(w,v,{nodeOrigin:k,nodeExtent:S,zIndexMode:I}),A?(b(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),B?.length>0&&(E&&console.log("React Flow: trigger node changes",B),y?.(B)))},updateNodePositions:(x,y=!1)=>{const w=[];let v=[];const{nodeLookup:N,triggerNodeChanges:k,connection:S,updateConnection:E,onNodesChangeMiddlewareMap:A}=g();for(const[I,B]of x){const $=N.get(I),z=!!($?.expandParent&&$?.parentId&&B?.position),R={id:I,type:"position",position:z?{x:Math.max(0,B.position.x),y:Math.max(0,B.position.y)}:B.position,dragging:y};if($&&S.inProgress&&S.fromNode.id===$.id){const M=Xn($,S.fromHandle,we.Left,!0);E({...S,from:M})}z&&$.parentId&&w.push({id:I,parentId:$.parentId,rect:{...B.internals.positionAbsolute,width:B.measured.width??0,height:B.measured.height??0}}),v.push(R)}if(w.length>0){const{parentLookup:I,nodeOrigin:B}=g(),$=qd(w,N,I,B);v.push(...$)}for(const I of A.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 S=oq(x,v);w(S)}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 S=sq(x,v);w(S)}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 S=x.map(E=>Fn(E,!0));N(S);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 S=x.map(E=>Fn(E,!0));k(S);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:S}=g(),E=x||v,A=y||w,I=[];for(const $ of E){if(!$.selected)continue;const z=N.get($.id);z&&(z.selected=!1),I.push(Fn($.id,!1))}const B=[];for(const $ of A)$.selected&&B.push(Fn($.id,!1));k(I),S(B)},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((E,A)=>A.selected?[...E,Fn(A.id,!1)]:E,[]),S=x.reduce((E,A)=>A.selected?[...E,Fn(A.id,!1)]:E,[]);w(k),v(S)},setNodeExtent:x=>{const{nodes:y,nodeLookup:w,parentLookup:v,nodeOrigin:N,elevateNodesOnSelect:k,nodeExtent:S,zIndexMode:E}=g();x[0][0]===S[0][0]&&x[0][1]===S[0][1]&&x[1][0]===S[1][0]&&x[1][1]===S[1][1]||(Gl(y,w,v,{nodeOrigin:N,nodeExtent:x,elevateNodesOnSelect:k,checkEquality:!1,zIndexMode:E}),m({nodeExtent:x}))},panBy:x=>{const{transform:y,width:w,height:v,panZoom:N,translateExtent:k}=g();return XH({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:S}=g();if(!S)return Promise.resolve(!1);const E=typeof w?.zoom<"u"?w.zoom:k;return await S.setViewport({x:v/2-x*E,y:N/2-y*E,zoom:E},{duration:w?.duration,ease:w?.ease,interpolate:w?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{m({connection:{...Mv}})},updateConnection:x=>{m({connection:x})},reset:()=>m({...Jf()})}},Object.is);function wU({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:a,initialMinZoom:i,initialMaxZoom:l,initialFitViewOptions:c,fitView:d,nodeOrigin:f,nodeExtent:p,zIndexMode:h,children:m}){const[g]=_(()=>vU({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:a,fitView:d,minZoom:i,maxZoom:l,fitViewOptions:c,nodeOrigin:f,nodeExtent:p,zIndexMode:h}));return o(zV,{value:g,children:o(lq,{children:m})})}function NU({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:a,height:i,fitView:l,fitViewOptions:c,minZoom:d,maxZoom:f,nodeOrigin:p,nodeExtent:h,zIndexMode:m}){return ve(Za)?o(me,{children:e}):o(wU,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:a,initialHeight:i,fitView:l,initialFitViewOptions:c,initialMinZoom:d,initialMaxZoom:f,nodeOrigin:p,nodeExtent:h,zIndexMode:m,children:e})}const kU={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function SU({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:a,edgeTypes:i,onNodeClick:l,onEdgeClick:c,onInit:d,onMove:f,onMoveStart:p,onMoveEnd:h,onConnect:m,onConnectStart:g,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:y,onNodeMouseEnter:w,onNodeMouseMove:v,onNodeMouseLeave:N,onNodeContextMenu:k,onNodeDoubleClick:S,onNodeDragStart:E,onNodeDrag:A,onNodeDragStop:I,onNodesDelete:B,onEdgesDelete:$,onDelete:z,onSelectionChange:R,onSelectionDragStart:M,onSelectionDrag:T,onSelectionDragStop:P,onSelectionContextMenu:L,onSelectionStart:O,onSelectionEnd:j,onBeforeDelete:F,connectionMode:H,connectionLineType:D=wn.Bezier,connectionLineStyle:Q,connectionLineComponent:K,connectionLineContainerStyle:ee,deleteKeyCode:oe="Backspace",selectionKeyCode:te="Shift",selectionOnDrag:Z=!1,selectionMode:re=Co.Full,panActivationKeyCode:be="Space",multiSelectionKeyCode:X=Eo()?"Meta":"Control",zoomActivationKeyCode:G=Eo()?"Meta":"Control",snapToGrid:J,snapGrid:ae,onlyRenderVisibleElements:fe=!1,selectNodesOnDrag:ge,nodesDraggable:V,autoPanOnNodeFocus:ie,nodesConnectable:ue,nodesFocusable:de,nodeOrigin:ce=s1,edgesFocusable:Se,edgesReconnectable:pe,elementsSelectable:Ie=!0,defaultViewport:Le=ZV,minZoom:Ye=.5,maxZoom:ot=2,translateExtent:cr=So,preventScrolling:he=!0,nodeExtent:_e,defaultMarkerColor:De="#b1b1b7",zoomOnScroll:Re=!0,zoomOnPinch:Tn=!0,panOnScroll:Ln=!1,panOnScrollSpeed:Kr=.5,panOnScrollMode:iw=Un.Free,zoomOnDoubleClick:lw=!0,panOnDrag:cw=!0,onPaneClick:dw,onPaneMouseEnter:uw,onPaneMouseMove:pw,onPaneMouseLeave:fw,onPaneScroll:hw,onPaneContextMenu:mw,paneClickDistance:gw=1,nodeClickDistance:bw=0,children:xw,onReconnect:yw,onReconnectStart:vw,onReconnectEnd:ww,onEdgeContextMenu:Nw,onEdgeDoubleClick:kw,onEdgeMouseEnter:Sw,onEdgeMouseMove:Cw,onEdgeMouseLeave:Mw,reconnectRadius:Ew=10,onNodesChange:Iw,onEdgesChange:Aw,noDragClassName:_w="nodrag",noWheelClassName:Pw="nowheel",noPanClassName:Xd="nopan",fitView:Jd,fitViewOptions:eu,connectOnClick:$w,attributionPosition:Dw,proOptions:Tw,defaultEdgeOptions:Lw,elevateNodesOnSelect:Rw=!0,elevateEdgesOnSelect:Ow=!1,disableKeyboardA11y:tu=!1,autoPanOnConnect:zw,autoPanOnNodeDrag:Bw,autoPanSpeed:Fw,connectionRadius:jw,isValidConnection:Hw,onError:Vw,style:qw,id:nu,nodeDragThreshold:Uw,connectionDragThreshold:Qw,viewport:Kw,onViewportChange:Gw,width:Ww,height:Yw,colorMode:Zw="light",debug:Xw,onScroll:ru,ariaLabelConfig:Jw,zIndexMode:ou="basic",...eN},tN){const ri=nu||"1",nN=tq(Zw),rN=U(su=>{su.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),ru?.(su)},[ru]);return o("div",{"data-testid":"rf__wrapper",...eN,onScroll:rN,style:{...qw,...kU},ref:tN,className:Qe(["react-flow",s,nN]),id:nu,role:"application",children:u(NU,{nodes:e,edges:t,width:Ww,height:Yw,fitView:Jd,fitViewOptions:eu,minZoom:Ye,maxZoom:ot,nodeOrigin:ce,nodeExtent:_e,zIndexMode:ou,children:[o(eq,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:g,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:y,nodesDraggable:V,autoPanOnNodeFocus:ie,nodesConnectable:ue,nodesFocusable:de,edgesFocusable:Se,edgesReconnectable:pe,elementsSelectable:Ie,elevateNodesOnSelect:Rw,elevateEdgesOnSelect:Ow,minZoom:Ye,maxZoom:ot,nodeExtent:_e,onNodesChange:Iw,onEdgesChange:Aw,snapToGrid:J,snapGrid:ae,connectionMode:H,translateExtent:cr,connectOnClick:$w,defaultEdgeOptions:Lw,fitView:Jd,fitViewOptions:eu,onNodesDelete:B,onEdgesDelete:$,onDelete:z,onNodeDragStart:E,onNodeDrag:A,onNodeDragStop:I,onSelectionDrag:T,onSelectionDragStart:M,onSelectionDragStop:P,onMove:f,onMoveStart:p,onMoveEnd:h,noPanClassName:Xd,nodeOrigin:ce,rfId:ri,autoPanOnConnect:zw,autoPanOnNodeDrag:Bw,autoPanSpeed:Fw,onError:Vw,connectionRadius:jw,isValidConnection:Hw,selectNodesOnDrag:ge,nodeDragThreshold:Uw,connectionDragThreshold:Qw,onBeforeDelete:F,debug:Xw,ariaLabelConfig:Jw,zIndexMode:ou}),o(yU,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:w,onNodeMouseMove:v,onNodeMouseLeave:N,onNodeContextMenu:k,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:i,connectionLineType:D,connectionLineStyle:Q,connectionLineComponent:K,connectionLineContainerStyle:ee,selectionKeyCode:te,selectionOnDrag:Z,selectionMode:re,deleteKeyCode:oe,multiSelectionKeyCode:X,panActivationKeyCode:be,zoomActivationKeyCode:G,onlyRenderVisibleElements:fe,defaultViewport:Le,translateExtent:cr,minZoom:Ye,maxZoom:ot,preventScrolling:he,zoomOnScroll:Re,zoomOnPinch:Tn,zoomOnDoubleClick:lw,panOnScroll:Ln,panOnScrollSpeed:Kr,panOnScrollMode:iw,panOnDrag:cw,onPaneClick:dw,onPaneMouseEnter:uw,onPaneMouseMove:pw,onPaneMouseLeave:fw,onPaneScroll:hw,onPaneContextMenu:mw,paneClickDistance:gw,nodeClickDistance:bw,onSelectionContextMenu:L,onSelectionStart:O,onSelectionEnd:j,onReconnect:yw,onReconnectStart:vw,onReconnectEnd:ww,onEdgeContextMenu:Nw,onEdgeDoubleClick:kw,onEdgeMouseEnter:Sw,onEdgeMouseMove:Cw,onEdgeMouseLeave:Mw,reconnectRadius:Ew,defaultMarkerColor:De,noDragClassName:_w,noWheelClassName:Pw,noPanClassName:Xd,rfId:ri,disableKeyboardA11y:tu,nodeExtent:_e,viewport:Kw,onViewportChange:Gw}),o(YV,{onSelectionChange:R}),xw,o(UV,{proOptions:Tw,position:Dw}),o(qV,{rfId:ri,disableKeyboardA11y:tu})]})})}var CU=i1(SU);function MU({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:Qe(["react-flow__background-pattern",n,r])})}function EU({radius:e,className:t}){return o("circle",{cx:e,cy:e,r:e,className:Qe(["react-flow__background-pattern","dots",t])})}var Sn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Sn||(Sn={}));const IU={[Sn.Dots]:1,[Sn.Lines]:1,[Sn.Cross]:6},AU=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function P1({id:e,variant:t=Sn.Dots,gap:n=20,size:r,lineWidth:s=1,offset:a=0,color:i,bgColor:l,style:c,className:d,patternClassName:f}){const p=ne(null),{transform:h,patternId:m}=Pe(AU,Fe),g=r||IU[t],b=t===Sn.Dots,x=t===Sn.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,S=[N[0]*h[2]||1+k[0]/2,N[1]*h[2]||1+k[1]/2],E=`${m}${e||""}`;return u("svg",{className:Qe(["react-flow__background",d]),style:{...c,...Ja,"--xy-background-color-props":l,"--xy-background-pattern-color-props":i},ref:p,"data-testid":"rf__background",children:[o("pattern",{id:E,x:h[0]%w[0],y:h[1]%w[1],width:w[0],height:w[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${S[0]},-${S[1]})`,children:b?o(EU,{radius:v/2,className:f}):o(MU,{dimensions:k,lineWidth:s,variant:t,className:f})}),o("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${E})`})]})}P1.displayName="Background";const _U=je(P1);function PU(){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 $U(){return o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:o("path",{d:"M0 0h32v4.2H0z"})})}function DU(){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 TU(){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 LU(){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 ks({children:e,className:t,...n}){return o("button",{type:"button",className:Qe(["react-flow__controls-button",t]),...n,children:e})}const RU=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function $1({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:a,onZoomOut:i,onFitView:l,onInteractiveChange:c,className:d,children:f,position:p="bottom-left",orientation:h="vertical","aria-label":m}){const g=He(),{isInteractive:b,minZoomReached:x,maxZoomReached:y,ariaLabelConfig:w}=Pe(RU,Fe),{zoomIn:v,zoomOut:N,fitView:k}=Ud(),S=()=>{v(),a?.()},E=()=>{N(),i?.()},A=()=>{k(s),l?.()},I=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),c?.(!b)};return u(Xa,{className:Qe(["react-flow__controls",h==="horizontal"?"horizontal":"vertical",d]),position:p,style:e,"data-testid":"rf__controls","aria-label":m??w["controls.ariaLabel"],children:[t&&u(me,{children:[o(ks,{onClick:S,className:"react-flow__controls-zoomin",title:w["controls.zoomIn.ariaLabel"],"aria-label":w["controls.zoomIn.ariaLabel"],disabled:y,children:o(PU,{})}),o(ks,{onClick:E,className:"react-flow__controls-zoomout",title:w["controls.zoomOut.ariaLabel"],"aria-label":w["controls.zoomOut.ariaLabel"],disabled:x,children:o($U,{})})]}),n&&o(ks,{className:"react-flow__controls-fitview",onClick:A,title:w["controls.fitView.ariaLabel"],"aria-label":w["controls.fitView.ariaLabel"],children:o(DU,{})}),r&&o(ks,{className:"react-flow__controls-interactive",onClick:I,title:w["controls.interactive.ariaLabel"],"aria-label":w["controls.interactive.ariaLabel"],children:b?o(LU,{}):o(TU,{})}),f]})}$1.displayName="Controls";const OU=je($1);function zU({id:e,x:t,y:n,width:r,height:s,style:a,color:i,strokeColor:l,strokeWidth:c,className:d,borderRadius:f,shapeRendering:p,selected:h,onClick:m}){const{background:g,backgroundColor:b}=a||{},x=i||g||b;return o("rect",{className:Qe(["react-flow__minimap-node",{selected:h},d]),x:t,y:n,rx:f,ry:f,width:r,height:s,style:{fill:x,stroke:l,strokeWidth:c},shapeRendering:p,onClick:m?y=>m(y,e):void 0})}const BU=je(zU),FU=e=>e.nodes.map(t=>t.id),Zi=e=>e instanceof Function?e:()=>e;function jU({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:a=BU,onClick:i}){const l=Pe(FU,Fe),c=Zi(t),d=Zi(e),f=Zi(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return o(me,{children:l.map(h=>o(VU,{id:h,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:a,onClick:i,shapeRendering:p},h))})}function HU({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:a,shapeRendering:i,NodeComponent:l,onClick:c}){const{node:d,x:f,y:p,width:h,height:m}=Pe(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}=gn(x);return{node:x,x:y,y:w,width:v,height:N}},Fe);return!d||d.hidden||!Dv(d)?null:o(l,{x:f,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 VU=je(HU);var qU=je(jU);const UU=200,QU=150,KU=e=>!e.hidden,GU=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?$v(Uo(e.nodeLookup,{filter:KU}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},WU="react-flow__minimap-desc";function D1({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:a=5,nodeStrokeWidth:i,nodeComponent:l,bgColor:c,maskColor:d,maskStrokeColor:f,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=He(),S=ne(null),{boundingRect:E,viewBB:A,rfId:I,panZoom:B,translateExtent:$,flowWidth:z,flowHeight:R,ariaLabelConfig:M}=Pe(GU,Fe),T=e?.width??UU,P=e?.height??QU,L=E.width/T,O=E.height/P,j=Math.max(L,O),F=j*T,H=j*P,D=N*j,Q=E.x-(F-E.width)/2-D,K=E.y-(H-E.height)/2-D,ee=F+D*2,oe=H+D*2,te=`${WU}-${I}`,Z=ne(0),re=ne();Z.current=j,Y(()=>{if(S.current&&B)return re.current=iV({domNode:S.current,panZoom:B,getTransform:()=>k.getState().transform,getViewScale:()=>Z.current}),()=>{re.current?.destroy()}},[B]),Y(()=>{re.current?.update({translateExtent:$,width:z,height:R,inversePan:w,pannable:b,zoomStep:v,zoomable:x})},[b,x,w,v,$,z,R]);const be=m?J=>{const[ae,fe]=re.current?.pointer(J)||[0,0];m(J,{x:ae,y:fe})}:void 0,X=g?U((J,ae)=>{const fe=k.getState().nodeLookup.get(ae).internals.userNode;g(J,fe)},[]):void 0,G=y??M["minimap.ariaLabel"];return o(Xa,{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 f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*j: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:Qe(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:u("svg",{width:T,height:P,viewBox:`${Q} ${K} ${ee} ${oe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":te,ref:S,onClick:be,children:[G&&o("title",{id:te,children:G}),o(qU,{onClick:X,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:s,nodeStrokeWidth:i,nodeComponent:l}),o("path",{className:"react-flow__minimap-mask",d:`M${Q-D},${K-D}h${ee+D*2}v${oe+D*2}h${-ee-D*2}z
|
|
1118
|
-
M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}D1.displayName="MiniMap";je(D1);const YU=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,ZU={[Tr.Line]:"right",[Tr.Handle]:"bottom-right"};function XU({nodeId:e,position:t,variant:n=Tr.Handle,className:r,style:s=void 0,children:a,color:i,minWidth:l=10,minHeight:c=10,maxWidth:d=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:h,autoScale:m=!0,shouldResize:g,onResizeStart:b,onResize:x,onResizeEnd:y}){const w=u1(),v=typeof e=="string"?e:w,N=He(),k=ne(null),S=n===Tr.Handle,E=Pe(U(YU(S&&m),[S,m]),Fe),A=ne(null),I=t??ZU[n];Y(()=>{if(!(!k.current||!v))return A.current||(A.current=wV({domNode:k.current,nodeId:v,getStoreItems:()=>{const{nodeLookup:$,transform:z,snapGrid:R,snapToGrid:M,nodeOrigin:T,domNode:P}=N.getState();return{nodeLookup:$,transform:z,snapGrid:R,snapToGrid:M,nodeOrigin:T,paneDomNode:P}},onChange:($,z)=>{const{triggerNodeChanges:R,nodeLookup:M,parentLookup:T,nodeOrigin:P}=N.getState(),L=[],O={x:$.x,y:$.y},j=M.get(v);if(j&&j.expandParent&&j.parentId){const F=j.origin??P,H=$.width??j.measured.width??0,D=$.height??j.measured.height??0,Q={id:j.id,parentId:j.parentId,rect:{width:H,height:D,...Tv({x:$.x??j.position.x,y:$.y??j.position.y},{width:H,height:D},j.parentId,M,F)}},K=qd([Q],M,T,P);L.push(...K),O.x=$.x?Math.max(F[0]*H,$.x):void 0,O.y=$.y?Math.max(F[1]*D,$.y):void 0}if(O.x!==void 0&&O.y!==void 0){const F={id:v,type:"position",position:{...O}};L.push(F)}if($.width!==void 0&&$.height!==void 0){const H={id:v,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:$.width,height:$.height}};L.push(H)}for(const F of z){const H={...F,type:"position"};L.push(H)}R(L)},onEnd:({width:$,height:z})=>{const R={id:v,type:"dimensions",resizing:!1,dimensions:{width:$,height:z}};N.getState().triggerNodeChanges([R])}})),A.current.update({controlPosition:I,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:f},keepAspectRatio:p,resizeDirection:h,onResizeStart:b,onResize:x,onResizeEnd:y,shouldResize:g}),()=>{A.current?.destroy()}},[I,l,c,d,f,p,b,x,y,g]);const B=I.split("-");return o("div",{className:Qe(["react-flow__resize-control","nodrag",...B,n,r]),ref:k,style:{...s,scale:E,...i&&{[S?"backgroundColor":"borderColor"]:i}},children:a})}je(XU);var T1=Object.defineProperty,JU=(e,t,n)=>t in e?T1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,eQ=(e,t)=>{for(var n in t)T1(e,n,{get:t[n],enumerable:!0})},tQ=(e,t,n)=>JU(e,t+"",n),L1={};eQ(L1,{Graph:()=>It,alg:()=>Kd,json:()=>O1,version:()=>oQ});var nQ=Object.defineProperty,R1=(e,t)=>{for(var n in t)nQ(e,n,{get:t[n],enumerable:!0})},It=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=so(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 f=rQ(this._isDirected,s,a,i);return s=f.v,a=f.w,Object.freeze(f),this._edgeObjs[d]=f,eh(this._preds[a],s),eh(this._sucs[s],a),this._in[a][d]=f,this._out[s][d]=f,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Xi(this._isDirected,e):so(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?Xi(this._isDirected,e):so(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Xi(this._isDirected,e):so(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],th(this._preds[i],a),th(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 eh(e,t){e[t]?e[t]++:e[t]=1}function th(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function so(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 rQ(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 Xi(e,t){return so(e,t.v,t.w,t.name)}var oQ="4.0.1",O1={};R1(O1,{read:()=>lQ,write:()=>sQ});function sQ(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:aQ(e),edges:iQ(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function aQ(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 iQ(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 lQ(e){let t=new It(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 Kd={};R1(Kd,{CycleException:()=>ua,bellmanFord:()=>z1,components:()=>uQ,dijkstra:()=>da,dijkstraAll:()=>hQ,findCycles:()=>mQ,floydWarshall:()=>bQ,isAcyclic:()=>yQ,postorder:()=>wQ,preorder:()=>NQ,prim:()=>kQ,shortestPaths:()=>SQ,tarjan:()=>F1,topsort:()=>j1});var cQ=()=>1;function z1(e,t,n,r){return dQ(e,String(t),n||cQ,r||function(s){return e.outEdges(s)})}function dQ(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 f=l.length;for(let p=1;p<f&&(a=!1,i++,d(),!!a);p++);if(i===f-1&&(a=!1,d(),a))throw new Error("The graph contains a negative weight cycle");return s}function uQ(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 B1=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}},pQ=()=>1;function da(e,t,n,r){let s=function(a){return e.outEdges(a)};return fQ(e,String(t),n||pQ,r||s)}function fQ(e,t,n,r){let s={},a=new B1,i,l,c=function(d){let f=d.v!==i?d.v:d.w,p=s[f],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(f,m))};for(e.nodes().forEach(function(d){let f=d===t?0:Number.POSITIVE_INFINITY;s[d]={distance:f,predecessor:""},a.add(d,f)});a.size()>0&&(i=a.removeMin(),l=s[i],l.distance!==Number.POSITIVE_INFINITY);)r(i).forEach(c);return s}function hQ(e,t,n){return e.nodes().reduce(function(r,s){return r[s]=da(e,s,t,n),r},{})}function F1(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 mQ(e){return F1(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var gQ=()=>1;function bQ(e,t,n){return xQ(e,t||gQ,n||function(r){return e.outEdges(r)})}function xQ(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 f=c[a],p=i[d],h=c[d],m=f.distance+p.distance;m<h.distance&&(h.distance=m,h.predecessor=p.predecessor)})})}),r}var ua=class extends Error{constructor(...e){super(...e)}};function j1(e){let t={},n={},r=[];function s(a){if(a in n)throw new ua;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 ua;return r}function yQ(e){try{j1(e)}catch(t){if(t instanceof ua)return!1;throw t}return!0}function vQ(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=H1(e,l,n==="post",i,a,r,s)}),s}function H1(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=H1(e,l,n,r,s,a,i)}),n&&(i=a(i,t))),i}function V1(e,t,n){return vQ(e,t,n,function(r,s){return r.push(s),r},[])}function wQ(e,t){return V1(e,t,"post")}function NQ(e,t){return V1(e,t,"pre")}function kQ(e,t){let n=new It,r={},s=new B1,a;function i(c){let d=c.v===a?c.w:c.v,f=s.priority(d);if(f!==void 0){let p=t(c);p<f&&(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 SQ(e,t,n,r){return CQ(e,t,n,r??(s=>{let a=e.outEdges(s);return a??[]}))}function CQ(e,t,n,r){if(n===void 0)return da(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],f=d.v===a[i]?d.v:d.w,p=f===d.v?d.w:d.v;n({v:f,w:p})<0&&(s=!0)}if(s)return z1(e,t,n,r)}return da(e,t,n,r)}function Qr(e,t,n,r){let s=r;for(;e.hasNode(s);)s=Gd(r);return n.dummy=t,e.setNode(s,n),s}function MQ(e){let t=new It().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 q1(e){let t=new It({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 nh(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 Go(e){let t=Ao(Q1(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 EQ(e){let t=e.nodes().map(r=>{let s=e.node(r).rank;return s===void 0?Number.MAX_VALUE:s}),n=Ut(Math.min,t);e.nodes().forEach(r=>{let s=e.node(r);Object.hasOwn(s,"rank")&&(s.rank-=n)})}function IQ(e){let t=e.nodes().map(i=>e.node(i).rank).filter(i=>i!==void 0),n=Ut(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),Qr(e,"border",s,t)}function AQ(e,t=U1){let n=[];for(let r=0;r<e.length;r+=t){let s=e.slice(r,r+t);n.push(s)}return n}var U1=65535;function Ut(e,t){if(t.length>U1){let n=AQ(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function Q1(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return Ut(Math.max,t)}function _Q(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function K1(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function G1(e,t){return t()}var PQ=0;function Gd(e){let t=++PQ;return e+(""+t)}function Ao(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 pa(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function ti(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 $Q(e,t){return e.reduce((n,r,s)=>(n[r]=t[s],n),{})}var ni="\0",DQ="3.0.0",TQ=class{constructor(){tQ(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,LQ)),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 LQ(e,t){if(e!=="_next"&&e!=="_prev")return t}var RQ=TQ,OQ=()=>1;function zQ(e,t){if(e.nodeCount()<=1)return[];let n=FQ(e,t||OQ);return BQ(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function BQ(e,t,n){var r;let s=[],a=t[t.length-1],i=t[0],l;for(;e.nodeCount();){for(;l=i.dequeue();)Ji(e,t,n,l);for(;l=a.dequeue();)Ji(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(Ji(e,t,n,l,!0)||[]);break}}}return s}function Ji(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,Xl(t,n,d)}),(e.outEdges(r.v)||[]).forEach(l=>{let c=e.edge(l),d=l.w,f=e.node(d);f.in-=c,Xl(t,n,f)}),e.removeNode(r.v),i}function FQ(e,t){let n=new It,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),f=c+d;n.setEdge(l.v,l.w,f);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=jQ(s+r+3).map(()=>new RQ),i=r+1;return n.nodes().forEach(l=>{Xl(a,i,n.node(l))}),{graph:n,buckets:a,zeroIdx:i}}function Xl(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 jQ(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function HQ(e){(e.graph().acyclicer==="greedy"?zQ(e,t(e)):VQ(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,Gd("rev"))});function t(n){return r=>n.edge(r).weight}}function VQ(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 qQ(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 UQ(e){e.graph().dummyChains=[],e.edges().forEach(t=>QQ(e,t))}function QQ(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,f,p;for(p=0,++r;r<a;++p,++r)l.points=[],f={width:0,height:0,edgeLabel:l,edgeObj:t,rank:r},d=Qr(e,"edge",f,"_d"),r===c&&(f.width=l.width,f.height=l.height,f.dummy="edge-label",f.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 KQ(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 Wd(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=Ut(Math.min,i);return l===Number.POSITIVE_INFINITY&&(l=0),s.rank=l}e.sources().forEach(n)}function Lr(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var W1=GQ;function GQ(e){let t=new It({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(;WQ(t,e)<s&&(a=YQ(t,e),!!a);)i=t.hasNode(a.v)?Lr(e,a):-Lr(e,a),ZQ(t,e,i);return t}function WQ(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)&&!Lr(t,a)&&(e.setNode(l,{}),e.setEdge(r,l,{}),n(l))})}return e.nodes().forEach(n),e.nodeCount()}function YQ(e,t){return t.edges().reduce((n,r)=>{let s=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(s=Lr(t,r)),s<n[0]?[s,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function ZQ(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:XQ,postorder:JQ}=Kd,eK=lr;lr.initLowLimValues=Zd;lr.initCutValues=Yd;lr.calcCutValue=Y1;lr.leaveEdge=X1;lr.enterEdge=J1;lr.exchangeEdges=ew;function lr(e){e=MQ(e),Wd(e);let t=W1(e);Zd(t),Yd(t,e);let n,r;for(;n=X1(t);)r=J1(t,e,n),ew(t,e,n,r)}function Yd(e,t){let n=JQ(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>tK(e,t,r))}function tK(e,t,n){let r=e.node(n).parent,s=e.edge(n,r);s.cutvalue=Y1(e,t,n)}function Y1(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,f=d?c.w:c.v;if(f!==r){let p=d===s,h=t.edge(c).weight;if(i+=p?h:-h,rK(e,n,f)){let m=e.edge(n,f).cutvalue;i+=p?-m:m}}}),i}function Zd(e,t){arguments.length<2&&(t=e.nodes()[0]),Z1(e,{},1,t)}function Z1(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=Z1(e,t,n,c,r))}),i.low=a,i.lim=n++,s?i.parent=s:delete i.parent,n}function X1(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function J1(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===sh(e,e.node(d.v),l)&&c!==sh(e,e.node(d.w),l)).reduce((d,f)=>Lr(t,f)<Lr(t,d)?f:d)}function ew(e,t,n,r){let s=n.v,a=n.w;e.removeEdge(s,a),e.setEdge(r.v,r.w,{}),Zd(e),Yd(e,t),nK(e,t)}function nK(e,t){let n=e.nodes().find(s=>!e.node(s).parent);if(!n)return;let r=XQ(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 rK(e,t,n){return e.hasEdge(t,n)}function sh(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var oK=sK;function sK(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":ah(e);break;case"tight-tree":iK(e);break;case"longest-path":aK(e);break;case"none":break;default:ah(e)}}var aK=Wd;function iK(e){Wd(e),W1(e)}function ah(e){eK(e)}var lK=cK;function cK(e){let t=uK(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),s=r.edgeObj,a=dK(e,t,s.v,s.w),i=a.path,l=a.lca,c=0,d=i[c],f=!0;for(;n!==s.w;){if(r=e.node(n),f){for(;(d=i[c])!==l&&e.node(d).maxRank<r.rank;)c++;d===l&&(f=!1)}if(!f){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 dK(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,f=r;for(;(f=e.parent(f))!==d;)a.push(f);return{path:s.concat(a.reverse()),lca:d}}function uK(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(ni).forEach(r),t}function pK(e){let t=Qr(e,"root",{},"_root"),n=fK(e),r=Object.values(n),s=Ut(Math.max,r)-1,a=2*s+1;e.graph().nestingRoot=t,e.edges().forEach(l=>e.edge(l).minlen*=a);let i=hK(e)+1;e.children(ni).forEach(l=>tw(e,t,a,i,s,n,l)),e.graph().nodeRankFactor=a}function tw(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"),f=rh(e,"_bb"),p=e.node(i);e.setParent(d,i),p.borderTop=d,e.setParent(f,i),p.borderBottom=f,c.forEach(h=>{var m;tw(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,f,{weight:y,minlen:w,nestingEdge:!0})}),e.parent(i)||e.setEdge(t,d,{weight:0,minlen:s+((l=a[i])!=null?l:0)})}function fK(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(ni).forEach(r=>n(r,1)),t}function hK(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function mK(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var gK=bK;function bK(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)ih(e,"borderLeft","_bl",n,s,a),ih(e,"borderRight","_br",n,s,a)}}e.children(ni).forEach(t)}function ih(e,t,n,r,s,a){let i={width:0,height:0,rank:a,borderType:t},l=s[t][a-1],c=Qr(e,"border",i,n);s[t][a]=c,e.setParent(c,r),l&&e.setEdge(l,c,{weight:1})}function xK(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&nw(e)}function yK(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&vK(e),(n==="lr"||n==="rl")&&(wK(e),nw(e))}function nw(e){e.nodes().forEach(t=>lh(e.node(t))),e.edges().forEach(t=>lh(e.edge(t)))}function lh(e){let t=e.width;e.width=e.height,e.height=t}function vK(e){e.nodes().forEach(t=>el(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(el),Object.hasOwn(r,"y")&&el(r)})}function el(e){e.y=-e.y}function wK(e){e.nodes().forEach(t=>tl(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(tl),Object.hasOwn(r,"x")&&tl(r)})}function tl(e){let t=e.x;e.x=e.y,e.y=t}function NK(e){let t={},n=e.nodes().filter(l=>!e.children(l).length),r=n.map(l=>e.node(l).rank),s=Ut(Math.max,r),a=Ao(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 kK(e,t){let n=0;for(let r=1;r<t.length;++r)n+=SK(e,t[r-1],t[r]);return n}function SK(e,t,n){let r=$Q(n,n.map((d,f)=>f)),s=t.flatMap(d=>{let f=e.outEdges(d);return f?f.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 f=d.pos+a;l[f]+=d.weight;let p=0;for(;f>0;)f%2&&(p+=l[f+1]),f=f-1>>1,l[f]+=d.weight;c+=d.weight*p}),c}function CK(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 MK(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 EK(r)}function EK(e){let t=[];function n(s){return a=>{a.merged||(a.barycenter===void 0||s.barycenter===void 0||a.barycenter>=s.barycenter)&&IK(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=>pa(s,["vs","i","barycenter","weight"]))}function IK(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 AK(e,t){let n=_Q(e,f=>Object.hasOwn(f,"barycenter")),r=n.lhs,s=n.rhs.sort((f,p)=>p.i-f.i),a=[],i=0,l=0,c=0;r.sort(_K(!!t)),c=ch(a,s,c),r.forEach(f=>{c+=f.vs.length,a.push(f.vs),i+=f.barycenter*f.weight,l+=f.weight,c=ch(a,s,c)});let d={vs:a.flat(1)};return l&&(d.barycenter=i/l,d.weight=l),d}function ch(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 _K(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}function rw(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=CK(e,s);d.forEach(h=>{if(e.children(h.v).length){let m=rw(e,h.v,n,r);c[h.v]=m,Object.hasOwn(m,"barycenter")&&$K(h,m)}});let f=MK(d,n);PK(f,c);let p=AK(f,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 PK(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function $K(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 DK(e,t,n,r){r||(r=e.nodes());let s=TK(e),a=new It({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(f=>{let p=f.v===i?f.w:f.v,h=a.edge(p,i),m=h!==void 0?h.weight:0;a.setEdge(p,i,{weight:e.edge(f).weight+m})}),Object.hasOwn(l,"minRank")&&a.setNode(i,{borderLeft:l.borderLeft[t],borderRight:l.borderRight[t]})}}),a}function TK(e){let t;for(;e.hasNode(t=Gd("_root")););return t}function LK(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 ow(e,t={}){if(typeof t.customOrder=="function"){t.customOrder(e,ow);return}let n=Q1(e),r=dh(e,Ao(1,n+1),"inEdges"),s=dh(e,Ao(n-1,-1,-1),"outEdges"),a=NK(e);if(uh(e,a),t.disableOptimalOrderHeuristic)return;let i=Number.POSITIVE_INFINITY,l,c=t.constraints||[];for(let d=0,f=0;f<4;++d,++f){RK(d%2?r:s,d%4>=2,c),a=Go(e);let p=kK(e,a);p<i?(f=0,l=Object.assign({},a),i=p):p===i&&(l=structuredClone(a))}uh(e,l)}function dh(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 DK(e,a,n,r.get(a)||[])})}function RK(e,t,n){let r=new It;e.forEach(function(s){n.forEach(l=>r.setEdge(l.left,l.right));let a=s.graph().root,i=rw(s,a,r,t);i.vs.forEach((l,c)=>s.node(l).order=c),LK(s,r,i.vs)})}function uh(e,t){Object.values(t).forEach(n=>n.forEach((r,s)=>e.node(r).order=s))}function OK(e,t){let n={};function r(s,a){let i=0,l=0,c=s.length,d=a[a.length-1];return a.forEach((f,p)=>{let h=BK(e,f),m=h?e.node(h).order:c;(h||f===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)&&sw(n,x,g)})}),l=p+1,i=m)}),a}return t.length&&t.reduce(r),n}function zK(e,t){let n={};function r(a,i,l,c,d){Ao(i,l).forEach(f=>{let p=a[f];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)&&sw(n,m,p)})}})}function s(a,i){let l=-1,c=-1,d=0;return i.forEach((f,p)=>{if(e.node(f).dummy==="border"){let h=e.predecessors(f);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 BK(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function sw(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 FK(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 jK(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 f=r(d);if(f&&f.length){let p=f.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&&!FK(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 HK(e,t,n,r,s=!1){let a={},i=VK(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 f(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(f,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 VK(e,t,n,r){let s=new It,a=e.graph(),i=GK(a.nodesep,a.edgesep,r);return t.forEach(l=>{let c;l.forEach(d=>{let f=n[d];if(f!==void 0){if(s.setNode(f),c!==void 0){let p=n[c];if(p!==void 0){let h=s.edge(p,f);s.setEdge(p,f,Math.max(i(e,d,c),h||0))}}c=d}})}),s}function qK(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=WK(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 UK(e,t){let n=Object.values(t),r=Ut(Math.min,n),s=Ut(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),f=r-Ut(Math.min,d);i!=="l"&&(f=s-Ut(Math.max,d)),f&&(e[l]=ti(c,p=>p+f))})})}function QK(e,t=void 0){let n=e.ul;return n?ti(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 KK(e){let t=Go(e),n=Object.assign(OK(e,t),zK(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(f=>Object.values(f).reverse()));let c=jK(e,s,n,f=>(i==="u"?e.predecessors(f):e.successors(f))||[]),d=HK(e,s,c.root,c.align,l==="r");l==="r"&&(d=ti(d,f=>-f)),r[i+l]=d})});let a=qK(e,r);return UK(r,a),QK(r,e.graph().align)}function GK(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 WK(e,t){return e.node(t).width}function YK(e){e=q1(e),ZK(e),Object.entries(KK(e)).forEach(([t,n])=>e.node(t).x=n)}function ZK(e){let t=Go(e),n=e.graph(),r=n.ranksep,s=n.rankalign,a=0;t.forEach(i=>{let l=i.reduce((c,d)=>{var f;let p=(f=e.node(d).height)!=null?f: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 XK(e,t={}){let n=t.debugTiming?K1:G1;return n("layout",()=>{let r=n(" buildLayoutGraph",()=>lG(e));return n(" runLayout",()=>JK(r,n,t)),n(" updateInputGraph",()=>eG(e,r)),r})}function JK(e,t,n){t(" makeSpaceForEdgeLabels",()=>cG(e)),t(" removeSelfEdges",()=>xG(e)),t(" acyclic",()=>HQ(e)),t(" nestingGraph.run",()=>pK(e)),t(" rank",()=>oK(q1(e))),t(" injectEdgeLabelProxies",()=>dG(e)),t(" removeEmptyRanks",()=>IQ(e)),t(" nestingGraph.cleanup",()=>mK(e)),t(" normalizeRanks",()=>EQ(e)),t(" assignRankMinMax",()=>uG(e)),t(" removeEdgeLabelProxies",()=>pG(e)),t(" normalize.run",()=>UQ(e)),t(" parentDummyChains",()=>lK(e)),t(" addBorderSegments",()=>gK(e)),t(" order",()=>ow(e,n)),t(" insertSelfEdges",()=>yG(e)),t(" adjustCoordinateSystem",()=>xK(e)),t(" position",()=>YK(e)),t(" positionSelfEdges",()=>vG(e)),t(" removeBorderNodes",()=>bG(e)),t(" normalize.undo",()=>KQ(e)),t(" fixupEdgeLabelCoords",()=>mG(e)),t(" undoCoordinateSystem",()=>yK(e)),t(" translateGraph",()=>fG(e)),t(" assignNodeIntersects",()=>hG(e)),t(" reversePoints",()=>gG(e)),t(" acyclic.undo",()=>qQ(e))}function eG(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 tG=["nodesep","edgesep","ranksep","marginx","marginy"],nG={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},rG=["acyclicer","ranker","rankdir","align","rankalign"],oG=["width","height","rank"],ph={width:0,height:0},sG=["minlen","weight","width","height","labeloffset"],aG={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},iG=["labelpos"];function lG(e){let t=new It({multigraph:!0,compound:!0}),n=rl(e.graph());return t.setGraph(Object.assign({},nG,nl(n,tG),pa(n,rG))),e.nodes().forEach(r=>{let s=rl(e.node(r)),a=nl(s,oG);Object.keys(ph).forEach(l=>{a[l]===void 0&&(a[l]=ph[l])}),t.setNode(r,a);let i=e.parent(r);i!==void 0&&t.setParent(r,i)}),e.edges().forEach(r=>{let s=rl(e.edge(r));t.setEdge(r,Object.assign({},aG,nl(s,sG),pa(s,iG)))}),t}function cG(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 dG(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};Qr(e,"edge-proxy",s,"_ep")}})}function uG(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 pG(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 fG(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 f=d.x,p=d.y,h=d.width,m=d.height;t=Math.min(t,f-h/2),n=Math.max(n,f+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 f=e.edge(d);Object.hasOwn(f,"x")&&c(f)}),t-=i,r-=l,e.nodes().forEach(d=>{let f=e.node(d);f.x-=t,f.y-=r}),e.edges().forEach(d=>{let f=e.edge(d);f.points.forEach(p=>{p.x-=t,p.y-=r}),Object.hasOwn(f,"x")&&(f.x-=t),Object.hasOwn(f,"y")&&(f.y-=r)}),a.width=n-t+i,a.height=s-r+l}function hG(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(nh(r,a)),n.points.push(nh(s,i))})}function mG(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 gG(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function bG(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 xG(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 yG(e){Go(e).forEach(t=>{let n=0;t.forEach((r,s)=>{let a=e.node(r);a.order=s+n,(a.selfEdges||[]).forEach(i=>{Qr(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 vG(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 ti(pa(e,t),Number)}function rl(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}function wG(e){let t=Go(e),n=new It({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 NG={graphlib:L1,version:DQ,layout:XK,debug:wG,util:{time:K1,notime:G1}},fh=NG;/*! For license information please see dagre.esm.js.LEGAL.txt */function kG({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??[],f=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(E=>{E.stopPropagation(),m?.()},[m]),v=U(E=>{E.stopPropagation(),g?.()},[g]),N=U(E=>{E.stopPropagation(),b?.()},[b]);return u("div",{className:`rounded-xl bg-surface px-3 py-2.5 min-w-[180px] max-w-[260px] transition-all duration-200 ${n?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(In,{type:"target",position:we.Top,className:"!bg-border !w-2 !h-2"}),u("div",{className:"flex items-center gap-1.5 mb-1.5",children:[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 E=d.filter(A=>!A.includes(":"));return u("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}),E.length>0&&o("div",{className:"truncate font-mono opacity-70",children:E.join(", ")})]})})(),s.length>0&&o("div",{className:"flex flex-wrap gap-1 mb-1.5",children:s.map(E=>o("span",{className:"text-[8px] px-1 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:E},E))}),a.length>0&&u("div",{className:"text-[9px] text-muted-foreground mb-1",children:[a.length," addon",a.length!==1?"s":""," in-process"]}),n&&u("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground",children:[u("span",{className:"flex items-center gap-0.5",children:[o(pt,{className:"h-2.5 w-2.5"}),f,"%"]}),u("span",{className:"flex items-center gap-0.5",children:[o(kd,{className:"h-2.5 w-2.5"}),p,"%"]}),u("div",{className:"flex items-center gap-1 ml-auto",children:[y>0&&u("button",{onClick:w,className:"flex items-center gap-0.5 px-1 py-0.5 rounded hover:bg-amber-500/10 text-amber-500 transition-colors",title:h?"Collapse processes":`Expand ${y} process${y!==1?"es":""}`,children:[h?o(wt,{className:"h-3 w-3"}):o(Et,{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(nt,{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(xt,{className:"h-3 w-3"})})]})]}),!n&&o("div",{className:"text-[10px] text-muted-foreground",children:"offline"}),o(In,{type:"source",position:we.Bottom,className:"!bg-border !w-2 !h-2"})]})}const SG=je(kG);function CG(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 MG({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,f=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=f??"hub",w=`${y}/${t}`,v=U(E=>{E.stopPropagation(),d?.()},[d]),N=g?cn:$a,k=g?"border-primary/50":m?"border-amber-500/50":"border-destructive/50",S=g?"text-primary":"text-amber-500";return u("div",{className:`rounded-lg bg-surface min-w-[150px] border ${k} ${c?"max-w-[240px]":"max-w-[210px]"}`,children:[o(In,{type:"target",position:we.Top,className:`!w-1.5 !h-1.5 ${g?"!bg-primary":"!bg-amber-500"}`}),u("div",{className:"px-2.5 pt-2 pb-1.5",children:[u("div",{className:"flex items-start gap-1.5 mb-1.5",children:[o(N,{className:`h-3 w-3 ${S} 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})]}),u("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"}`}),u("span",{className:"flex items-center gap-0.5",children:[o(pt,{className:"h-2 w-2"}),s,"%"]}),u("span",{className:"flex items-center gap-0.5",children:[o(kd,{className:"h-2 w-2"}),CG(a)]}),b&&x?u("div",{className:"flex items-center gap-0.5 ml-auto",children:[o("button",{onClick:E=>{E.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(nt,{className:"h-2.5 w-2.5"})}),o("button",{onClick:E=>{E.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(xt,{className:"h-2.5 w-2.5"})})]}):l.length>0?u("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(wt,{className:"h-2.5 w-2.5"}):o(Et,{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(E=>{const A=g?y:`${y}/${t}`;return u("div",{className:"flex items-center gap-1 py-0.5",children:[o("div",{className:`w-1 h-1 rounded-full shrink-0 ${E.status==="running"?"bg-success":"bg-muted-foreground/30"}`}),o("span",{className:"text-[9px] truncate flex-1",children:E.addonId}),o("button",{onClick:I=>{I.stopPropagation(),p?.(E.addonId,y)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Logs: ${E.addonId}`,children:o(nt,{className:"h-2.5 w-2.5"})}),o("button",{onClick:I=>{I.stopPropagation(),h?.(E.addonId,A)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Restart: ${E.addonId}`,children:o(xt,{className:"h-2.5 w-2.5"})})]},E.addonId)})}),o(In,{type:"source",position:we.Bottom,className:`!w-1.5 !h-1.5 ${g?"!bg-primary":"!bg-amber-500"}`})]})}const EG=je(MG),IG={clusterNode:SG,processNode:EG},ur={cluster:{width:320,height:170},process:{width:240,height:100},processExpanded:{width:240,height:240}};function AG(e,t){const n=new fh.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"?ur.cluster:a?ur.processExpanded:ur.process;n.setNode(s.id,{width:i.width,height:i.height})}for(const s of t)n.setEdge(s.source,s.target);fh.layout(n);const r=new Map;for(const s of e){const a=n.node(s.id);if(!a)continue;const i=s.type==="processNode"&&!!s.data?.isExpanded,l=s.type==="clusterNode"?ur.cluster:i?ur.processExpanded:ur.process;r.set(s.id,{x:a.x-l.width/2,y:a.y-l.height/2})}return r}function _G({topology:e}){const{resolvedMode:t}=Rr(),n=Bb(),r=Na(),[,s]=_(null),[a,i]=_(()=>e.length<=1?new Set(e.map(E=>E.id)):new Set),[l,c]=_(null),[d,f]=_(null),p=U((E,A)=>{f(I=>I?.addonId===E&&I?.agentId===A?null:{addonId:E,agentId:A})},[]),h=U(E=>{f(A=>A?.agentId===E&&!A?.addonId?null:{agentId:E})},[]),m=U(async E=>{try{await n.mutateAsync({nodeId:E})}catch(A){console.error("Failed to restart node:",A)}},[n]),g=U(async(E,A)=>{try{await r.mutateAsync({nodeId:A,addonId:E})}catch(I){console.error("Failed to restart addon:",I)}},[r]),b=U(E=>{i(A=>{const I=new Set(A);return I.has(E)?I.delete(E):I.add(E),I})},[]),x=U(E=>{c(A=>A===E?null:E)},[]),y=U(E=>{s(E)},[]),w=q(()=>{const E=e.filter(M=>M.isHub),A=e.filter(M=>!M.isHub),I=[],B=[],$=E[0]?.id;function z(M,T){const P=[...T];if(P.length!==0)for(const L of P){const O=`proc:${M}/${L.name}`,j=L.services??[],F=l===O;I.push({id:O,type:"processNode",position:{x:0,y:0},data:{...L,addonId:L.name.includes("(core)")?void 0:j.length>1?L.name:j[0]?.addonId??L.name,parentNodeId:M,services:j,isExpanded:F,onToggleServices:()=>x(O),onShowLogs:p,onRestartAddon:g}}),B.push({id:`edge:${M}-${O}`,source:M,target:O,animated:!0,style:{stroke:"var(--amber-500, #f59e0b)",strokeWidth:1,strokeDasharray:"4 4"}})}}for(const M of E)I.push({id:M.id,type:"clusterNode",position:{x:0,y:0},data:{...M,label:M.name,isExpanded:a.has(M.id),onToggleExpand:()=>b(M.id),onShowDetail:()=>y(M.id),onShowNodeLogs:()=>h(M.id),onRestartNode:()=>m(M.id)}}),a.has(M.id)&&z(M.id,M.processes??[]);for(const M of A)I.push({id:M.id,type:"clusterNode",position:{x:0,y:0},data:{...M,label:M.name,isExpanded:a.has(M.id),onToggleExpand:()=>b(M.id),onShowDetail:()=>y(M.id),onShowNodeLogs:()=>h(M.id),onRestartNode:()=>m(M.id)}}),$&&M.isOnline&&B.push({id:`${$}-${M.id}`,source:$,target:M.id,animated:!0,style:{stroke:"var(--border)",strokeWidth:1.5}}),a.has(M.id)&&z(M.id,M.processes??[]);const R=AG(I,B);for(const M of I){const T=R.get(M.id);T&&(M.position=T)}return{nodes:I,edges:B}},[e,a,l,b,x,y,p,h,m,g]),v=ne(new Map),N=q(()=>{const E=v.current;return w.nodes.map(I=>({...I,position:E.get(I.id)??I.position}))},[w.nodes]),k=U(E=>{for(const A of E)A.type==="position"&&A.position&&v.current.set(A.id,A.position)},[]),S=U(()=>s(null),[]);return o("div",{className:"flex flex-col gap-4 flex-1",children:u("div",{className:"relative flex-1 min-h-[350px] border border-border rounded-xl overflow-hidden",children:[u(CU,{nodes:N,edges:w.edges,onNodesChange:k,onPaneClick:S,nodeTypes:IG,nodesConnectable:!1,fitView:!0,fitViewOptions:{padding:.2,maxZoom:1.2},proOptions:{hideAttribution:!0},className:"bg-background",colorMode:t,children:[o(_U,{gap:20,size:1}),o(OU,{showInteractive:!1})]}),d&&o(hy,{addonId:d.addonId,agentId:d.agentId,showScope:!0,onClose:()=>f(null)})]})})}function PG({onlineNodeIds:e}){const t=ke(),n=Xe(),{data:r,isLoading:s}=Fr(),a=cx({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:u("div",{className:"flex flex-col items-center gap-2 text-center text-muted-foreground",children:[o(Ml,{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."})]})}):u("section",{className:"rounded-lg border border-border bg-surface",children:[u("header",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[o(Ml,{className:"h-4 w-4 text-muted-foreground"}),o("h2",{className:"text-sm font-semibold",children:"Offline agents"}),u("span",{className:"ml-auto text-[11px] text-muted-foreground",children:[i.length," stale ",i.length===1?"entry":"entries"]})]}),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,f=Object.values(c.settings.addonDefaults??{}).filter(p=>p?.enabled).length;return u("li",{className:"flex items-center gap-3 px-4 py-2 text-xs",children:[o("span",{className:"font-mono text-foreground",children:c.nodeId}),u("span",{className:"text-muted-foreground",children:[d," addons configured",d>0&&u(me,{children:[" · ",f," enabled"]})]}),u("button",{type:"button",onClick:()=>{l(c.nodeId)},disabled:a.isPending,className:"ml-auto flex items-center gap-1 px-2 py-1 rounded text-destructive hover:bg-destructive/10 disabled:opacity-50",children:[o(Ge,{className:"h-3 w-3"}),"Remove"]})]},c.nodeId)})})]})}function $G(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 DG(){const{data:e,isLoading:t}=Dn(void 0,{staleTime:1/0}),[n,r]=_(null);return ut("cluster.topology-snapshot",a=>{const i=a.data?.nodes;Array.isArray(i)&&r(i)}),{nodes:q(()=>n??e??[],[n,e]),isLoading:t&&!n}}function TG(){const[e,t]=_("diagram"),n=$G("(max-width: 767px)"),r=n&&e==="diagram"?"table":e,{nodes:s,isLoading:a}=DG(),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}=Fr(),f=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)=>u("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 u("div",{className:"flex flex-col h-full gap-4 p-4",children:[u("div",{className:"flex items-center justify-between",children:[u("div",{className:"flex items-center gap-2",children:[i>0&&u("span",{className:"text-xs px-2 py-0.5 rounded-full bg-success/10 text-success",children:[i," online"]}),l>0&&u("span",{className:"text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:[l," offline"]})]}),u("div",{className:"flex gap-0.5 p-1 rounded-lg bg-muted",children:[!n&&p("diagram","Diagram",Mn),p("table","Table",RR),p("offline-agents","Offline agents",Ml,f)]})]}),a?o("div",{className:"flex items-center justify-center flex-1 text-muted-foreground",children:"Loading cluster topology..."}):r==="diagram"?o(_G,{topology:s}):r==="table"?o("div",{className:"flex-1 overflow-auto",children:o(Vz,{nodes:s})}):o("div",{className:"flex-1 overflow-auto",children:o(PG,{onlineNodeIds:c})})]})}function tn({title:e,children:t}){return u("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 et({name:e,cssVar:t,hex:n}){const r=t?`var(${t})`:n;return u("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 LG={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 RG(){const[e,t]=_({name:"Example",count:10,enabled:!0,mode:"a",tags:["camera"],confidence:60});return u("div",{className:"p-6 space-y-6 max-w-5xl mx-auto",children:[u("div",{className:"mb-6",children:[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(tn,{title:"Typography",children:u("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(tn,{title:"Colors",children:u("div",{className:"flex flex-wrap gap-4",children:[o(et,{name:"primary",cssVar:"--color-primary"}),o(et,{name:"background",cssVar:"--color-background"}),o(et,{name:"surface",cssVar:"--color-surface"}),o(et,{name:"foreground",cssVar:"--color-foreground"}),o(et,{name:"success",cssVar:"--color-success"}),o(et,{name:"warning",cssVar:"--color-warning"}),o(et,{name:"danger",cssVar:"--color-danger"}),o(et,{name:"info",cssVar:"--color-info"}),o(et,{name:"border",cssVar:"--color-border"}),o("div",{className:"w-px"}),o(et,{name:"frigate",hex:"#3b82f6"}),o(et,{name:"scrypted",hex:"#a855f7"}),o(et,{name:"reolink",hex:"#06b6d4"}),o(et,{name:"ha",hex:"#22d3ee"}),o(et,{name:"rtsp",hex:"#78716c"})]})}),o(tn,{title:"Buttons",children:u("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(tn,{title:"Inputs",children:u("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[u("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..."})]}),u("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"})]}),u("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:"••••••••"})]}),u("div",{children:[o("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Select"}),u("select",{className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30",children:[o("option",{children:"Option A"}),o("option",{children:"Option B"}),o("option",{children:"Option C"})]})]}),u("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:u("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:u("div",{className:"flex items-center justify-between",children:[o("span",{className:"text-xs font-medium text-foreground",children:"Toggle switch"}),o(OG,{})]})}),u("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})]}),u("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(tn,{title:"Badges",children:u("div",{className:"space-y-3",children:[u("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(za,{status:n},n))})]}),u("div",{children:[o("p",{className:"text-xs text-foreground-subtle mb-2",children:"CapabilityBadges"}),o(Ra,{capabilities:["streaming","detection","recording","audio"]})]})]})}),o(tn,{title:"Cards",children:u("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[u("div",{className:"rounded-lg bg-surface p-4",children:[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."})]}),u("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`."})]}),u("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."})]}),u("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(tn,{title:"Provider Icons",children:o("div",{className:"flex flex-wrap gap-4",children:["frigate","scrypted","reolink","homeassistant","rtsp","onvif"].map(n=>o(un,{type:n,size:"lg",showLabel:!0},n))})}),u(tn,{title:"Form Builder Demo",children:[o(En,{schema:LG,values:e,onChange:t}),u("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(tn,{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 u("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 OG(){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 hh={info:{bg:"bg-blue-500/10",border:"border-blue-500/30",icon:kn},warning:{bg:"bg-orange-500/10",border:"border-orange-500/30",icon:dt},critical:{bg:"bg-red-500/10",border:"border-red-500/30",icon:Cr}};function zG({toast:e,onDismiss:t}){const n=hh[e.severity]??hh.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]),u("div",{className:`flex items-start gap-3 px-4 py-3 rounded-lg border ${n.border} ${n.bg} shadow-lg backdrop-blur-sm animate-in slide-in-from-right-5 fade-in duration-200`,children:[o(r,{className:"h-4 w-4 shrink-0 mt-0.5 text-foreground-subtle"}),u("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(Be,{className:"h-3.5 w-3.5 text-foreground-subtle"})})]})}function BG(){const[e,t]=_([]),n=U(r=>{t(s=>s.filter(a=>a.id!==r))},[]);return Lx(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(zG,{toast:r,onDismiss:n})},r.id))})}const Jl=new wh({defaultOptions:{queries:{staleTime:3e4,retry:!1,refetchOnWindowFocus:!1}}});function FG({field:e,value:t,onChange:n,disabled:r}){return o(JR,{field:e,value:t,onChange:n,disabled:r})}function jG({field:e,value:t,onChange:n,disabled:r}){return o(c6,{field:e,value:t,onChange:n,disabled:r})}const HG={"zone-editor":dT,"live-stats":pT,"pipeline-editor":FG,"model-selector":jG,"live-stream-viewer":u6,"pipeline-stats":p6,"stream-network-stats":f6,"doorbell-recent":m6,"device-info":d0};function VG({children:e}){const{user:t}=mn(),[n,r]=_(0),s=ne(t?.username??null);Y(()=>{const p=t?.username??null;p!==s.current&&(s.current=p,fr(),r(h=>h+1))},[t]);const a=q(()=>As(),[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 f=U(()=>{fr(),r(p=>p+1),Jl.invalidateQueries()},[]);return sT(f),o(Sc,{system:a,children:o(C.Provider,{client:a.trpcClient,queryClient:Jl,children:u(Jx,{children:[i?e:o(qG,{}),c!==null&&i&&u("div",{className:"fixed bottom-4 right-4 z-50 max-w-sm rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning shadow-lg",children:["Boot probe failed: ",c,". Retrying in background."]})]})})})}function qG(){return o("div",{className:"flex min-h-screen items-center justify-center bg-background",children:u("div",{className:"flex items-center gap-3 text-sm text-foreground-subtle",children:[o("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary"}),"Connecting…"]})})}function UG(){return o(Rs,{defaultMode:"dark",children:o(Nh,{client:Jl,children:o($6,{children:o(VG,{children:o(og,{children:u(Sg,{renderers:HG,children:[o(GD,{children:u(kD,{children:[o($e,{path:"/login",element:o(LO,{})}),o($e,{path:"/change-password",element:o(Ft,{children:o(OO,{})})}),o($e,{path:"/access-denied",element:o(zO,{})}),o($e,{path:"/showroom",element:o(RG,{})}),u($e,{element:o(Ft,{children:o(TO,{})}),children:[o($e,{index:!0,element:o(bt,{to:"/dashboard",replace:!0})}),o($e,{path:"/dashboard",element:o(WO,{})}),o($e,{path:"/devices",element:o(YO,{})}),o($e,{path:"/cameras",element:o(bt,{to:"/devices",replace:!0})}),o($e,{path:"/integrations",element:o(i8,{})}),o($e,{path:"/integrations/:integrationId",element:o(d8,{})}),o($e,{path:"/timeline",element:o(v8,{})}),o($e,{path:"/pipeline",element:o(t9,{})}),o($e,{path:"/devices/:deviceId",element:o(X9,{})}),o($e,{path:"/system/logs",element:o(Ft,{requireAdmin:!0,children:o(p7,{})})}),o($e,{path:"/system/addons",element:o(Ft,{requireAdmin:!0,children:o(c7,{})})}),o($e,{path:"/system/settings",element:o(Ft,{requireAdmin:!0,children:o(Ez,{})})}),o($e,{path:"/system/cluster",element:o(Ft,{requireAdmin:!0,children:o(TG,{})})}),o($e,{path:"/system/identity",element:o(Ft,{requireAdmin:!0,children:o(A7,{})})}),o($e,{path:"/system/my-access",element:o(u7,{})}),o($e,{path:"/system/network",element:o(Ft,{requireAdmin:!0,children:o(B7,{})})}),o($e,{path:"/system/data",element:o(Ft,{requireAdmin:!0,children:o(Mz,{})})}),o($e,{path:"/system/users",element:o(bt,{to:"/system/identity?tab=users",replace:!0})}),o($e,{path:"/system/api-keys",element:o(bt,{to:"/system/identity?tab=api-keys",replace:!0})}),o($e,{path:"/system/authentication",element:o(bt,{to:"/system/identity?tab=authentication",replace:!0})}),o($e,{path:"/system/remote-access",element:o(bt,{to:"/system/network?tab=remote-access",replace:!0})}),o($e,{path:"/system/turn",element:o(bt,{to:"/system/network?tab=turn",replace:!0})}),o($e,{path:"/system/storage",element:o(bt,{to:"/system/data?tab=storage",replace:!0})}),o($e,{path:"/system/backup",element:o(bt,{to:"/system/data?tab=backup",replace:!0})}),o($e,{path:"/addon/:pagePath",element:o(Ft,{requireAdmin:!0,children:o(PO,{})})})]})]})}),o(BG,{})]})})})})})})}const QG={dashboard:"Dashboard",integrations:"Integrations",metrics:"Metrics"},KG={title:"System",addons:"Addons",agents:"Agents",processes:"Processes",logs:"Logs",users:"Users",settings:"Settings",repl:"REPL",models:"Models"},GG={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"},WG={disconnected:"Server unreachable — reconnecting…",connected:"Connected"},YG={online:"Online",offline:"Offline",connecting:"Connecting",error:"Error",disabled:"Disabled",enabled:"Enabled",active:"Active",inactive:"Inactive",running:"Running",stopped:"Stopped",pending:"Pending",unknown:"Unknown"},ZG={login:"Login",logout:"Logout",username:"Username",password:"Password",signIn:"Sign In",invalidCredentials:"Invalid username or password"},XG={dark:"Dark",light:"Light",system:"System"},JG={select:"Language",en:"English",it:"Italian"},eW={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"}},tW={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"},nW={nav:QG,system:KG,common:GG,connection:WG,status:YG,auth:ZG,theme:XG,language:JG,pages:eW,integrations:tW},rW={dashboard:"Dashboard",integrations:"Integrazioni",metrics:"Metriche"},oW={title:"Sistema",addons:"Addon",agents:"Agenti",processes:"Processi",logs:"Log",users:"Utenti",settings:"Impostazioni",repl:"REPL",models:"Modelli"},sW={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"},aW={disconnected:"Server non raggiungibile — riconnessione in corso…",connected:"Connesso"},iW={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"},lW={login:"Accesso",logout:"Esci",username:"Nome utente",password:"Password",signIn:"Accedi",invalidCredentials:"Nome utente o password non validi"},cW={dark:"Scuro",light:"Chiaro",system:"Sistema"},dW={select:"Lingua",en:"Inglese",it:"Italiano"},uW={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"}},pW={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"},fW={nav:rW,system:oW,common:sW,connection:aW,status:iW,auth:lW,theme:cW,language:dW,pages:uW,integrations:pW},aw="camstack_language",hW=localStorage.getItem(aw)??"en";Ze.use(pO).init({resources:{en:{translation:nW},it:{translation:fW}},lng:hW,fallbackLng:"en",interpolation:{escapeValue:!1}});Ze.on("languageChanged",e=>{localStorage.setItem(aw,e)});window.__camstackUiLibrary=N$;window.__camstackSdk=vN;window.__camstackTypes=wN;yh(document.getElementById("root")).render(o(dN,{children:o(UG,{})}));
|