@camstack/addon-admin-ui 0.1.33 → 0.1.35

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.
Files changed (34) hide show
  1. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DJQnlBBe.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DYU-qDnu.js} +1 -1
  2. package/dist/assets/{devices-BnLu5dxg.js → devices-D4k34mru.js} +1 -1
  3. package/dist/assets/{hostInit-DQ5UjxJa.js → hostInit-CBKchP1G.js} +1 -1
  4. package/dist/assets/index-BEewR-UX.js +1 -0
  5. package/dist/assets/{index-BmzE49kT.js → index-BGZqVJZt.js} +1 -1
  6. package/dist/assets/{index-DIIqKU3D.js → index-BI3Z7SSi.js} +1 -1
  7. package/dist/assets/index-BhNfKRLZ.js +1156 -0
  8. package/dist/assets/index-BqMPfvQx.js +1 -0
  9. package/dist/assets/{index-dePEzy7t.js → index-Bwcmc2hW.js} +1 -1
  10. package/dist/assets/index-CP1R6E2R.js +88 -0
  11. package/dist/assets/index-CwjnPcOV.js +152 -0
  12. package/dist/assets/{index-CMxz0koW.js → index-D92THlot.js} +1 -1
  13. package/dist/assets/index-Dmon2mdO.js +1 -0
  14. package/dist/assets/index-KlKJOjpC.js +1 -0
  15. package/dist/assets/index-bBEaoekV.css +1 -0
  16. package/dist/assets/method-access-map-BFPyQ2-G.js +1 -0
  17. package/dist/assets/{remoteEntry-D28y34bi.js → remoteEntry-BRybuw2S.js} +1 -1
  18. package/dist/assets/{schemas-DZqswtjx.js → schemas-BEt-CulV.js} +1 -1
  19. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BXwMMqlX.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DUkp33c_.js} +2 -2
  20. package/dist/index.html +7 -7
  21. package/dist/mf-entry-bootstrap-0.js +2 -2
  22. package/dist/server/addon.js +196 -235
  23. package/dist/server/addon.js.map +1 -1
  24. package/dist/sw.js +1 -1
  25. package/package.json +1 -1
  26. package/dist/assets/index-DFRMwfPq.js +0 -1
  27. package/dist/assets/index-DRW7rVhn.js +0 -1133
  28. package/dist/assets/index-DYSrVZ4G.js +0 -1
  29. package/dist/assets/index-DeVjiPqm.js +0 -1
  30. package/dist/assets/index-DuHBxCOe.js +0 -1
  31. package/dist/assets/index-Dv0-1gwL.js +0 -80
  32. package/dist/assets/index-NNW--T4H.js +0 -80
  33. package/dist/assets/index-n9RexO7D.css +0 -1
  34. package/dist/assets/method-access-map-OoQznstl.js +0 -1
@@ -1,1133 +0,0 @@
1
- import"./virtualExposes-_ivNhQLP.js";import{d as Mr}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BXwMMqlX.js";import{c as o,a as Ah,d as u,e as me,g as wN}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-C_6K4VBY.js";import{b as Be,e as _,h as q,c as Y,f as Q,d as ve,a as Ph,j as qe,k as Ee,i as ne,l as Wn,m as va,g as wa,R as uc,n as pc,o as NN,p as kN,q as Er,r as He,s as SN,t as CN,u as MN,v as EN}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-Dl4u0xYE.js";import{a as _h,b as Oo}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-CzO_Esxm.js";import{a as $h,b as Dh}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-DNpf5SLz.js";import{_ as Lh,m as Pn,n as ke,o as Th,p as Rh,h as qn,j as IN}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-CeLhKMin.js";import{_ as Oh,c as Bh,s as zh,n as AN,B as PN,F as _N}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.mjs-DIkg6-MH.js";import{_ as Fh,a as $N}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-OcRSBqRe.js";import{c as DN,D as Un,a as it,M as LN,W as fl,S as TN,b as RN,d as Ds}from"./index-DeVjiPqm.js";import{S as hl,c as jh}from"./devices-BnLu5dxg.js";import{E as Ne,A as ON,K as BN}from"./method-access-map-OoQznstl.js";import{s as zN}from"./index-BmzE49kT.js";import{a as bu,C as FN,S as xu,s as jN}from"./index-DFRMwfPq.js";import{r as Hh}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-CSyOECfO.js";import{_ as HN}from"./preload-helper-BlTxHScW.js";import"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-xw6c6JeS.js";import"./schemas-DZqswtjx.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 Vh={frigate:"#3b82f6",scrypted:"#a855f7",reolink:"#06b6d4",homeAssistant:"#22d3ee",rtsp:"#78716c"},qh={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:Vh},Uh={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:Vh},ml={colors:{dark:qh,light:Uh},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 Qh(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]=Qh(a,s):s!==void 0&&(n[r]=s)}return n}function VN(e){return e?Qh(structuredClone(ml),e):structuredClone(ml)}function Gh(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function qN(e){return`--color-${Gh(e)}`}function yu(e){const t=[];for(const[n,r]of Object.entries(e))n!=="provider"&&t.push(` ${qN(n)}: ${r};`);return t.join(`
2
- `)}function UN(e){const t=[];for(const[n,r]of Object.entries(e))t.push(` --color-provider-${Gh(n)}: ${r};`);return t.join(`
3
- `)}function QN(e){const t=[];for(const[n,r]of Object.entries(e))t.push(` --spacing-${n}: ${r}px;`);return t.join(`
4
- `)}function GN(e){const t=[];for(const[n,r]of Object.entries(e))t.push(` --radius-${n}: ${r}px;`);return t.join(`
5
- `)}function KN(e){const t=yu(e.colors.dark),n=yu(e.colors.light),r=UN(e.colors.dark.provider),s=QN(e.spacing),a=GN(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 Kh=Be(null),ui=["dark","light","system"];function Wh(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function WN(e,t){if(typeof window>"u")return t;const n=localStorage.getItem(e);return n==="dark"||n==="light"||n==="system"?n:t}function vu(e){return e==="system"?Wh():e}function Us({children:e,defaultMode:t="system",storageKey:n="camstack-theme-mode"}){const[r,s]=_(()=>WN(n,t)),[a,i]=_(()=>vu(r)),l=q(f=>{s(f),i(vu(f)),typeof window<"u"&&localStorage.setItem(n,f)},[n]),c=q(()=>{const p=(ui.indexOf(r)+1)%ui.length;l(ui[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(Wh())};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(Kh.Provider,{value:d,children:e})}function Br(){const e=ve(Kh);if(!e)throw new Error("useThemeMode must be used within a ThemeProvider");return e}function Yh(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=Yh(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Zh(){for(var e,t,n=0,r="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=Yh(e))&&(r&&(r+=" "),r+=t);return r}const YN=(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},ZN=(e,t)=>({classGroupId:e,validator:t}),Xh=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Qs="-",wu=[],XN="arbitrary..",JN=e=>{const t=t2(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return e2(i);const l=i.split(Qs),c=l[0]===""&&l.length>1?1:0;return Jh(l,c,t)},getConflictingClassGroupIds:(i,l)=>{if(l){const c=r[i],d=n[i];return c?d?YN(d,c):c:d||wu}return n[i]||wu}}},Jh=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const s=e[t],a=n.nextPart.get(s);if(a){const d=Jh(e,t+1,a);if(d)return d}const i=n.validators;if(i===null)return;const l=t===0?e.join(Qs):e.slice(t).join(Qs),c=i.length;for(let d=0;d<c;d++){const f=i[d];if(f.validator(l))return f.classGroupId}},e2=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?XN+r:void 0})(),t2=e=>{const{theme:t,classGroups:n}=e;return n2(n,t)},n2=(e,t)=>{const n=Xh();for(const r in e){const s=e[r];fc(s,n,r,t)}return n},fc=(e,t,n,r)=>{const s=e.length;for(let a=0;a<s;a++){const i=e[a];r2(i,t,n,r)}},r2=(e,t,n,r)=>{if(typeof e=="string"){o2(e,t,n);return}if(typeof e=="function"){s2(e,t,n,r);return}a2(e,t,n,r)},o2=(e,t,n)=>{const r=e===""?t:em(t,e);r.classGroupId=n},s2=(e,t,n,r)=>{if(i2(e)){fc(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(ZN(n,e))},a2=(e,t,n,r)=>{const s=Object.entries(e),a=s.length;for(let i=0;i<a;i++){const[l,c]=s[i];fc(c,em(t,l),n,r)}},em=(e,t)=>{let n=e;const r=t.split(Qs),s=r.length;for(let a=0;a<s;a++){const i=r[a];let l=n.nextPart.get(i);l||(l=Xh(),n.nextPart.set(i,l)),n=l}return n},i2=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,l2=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)}}},gl="!",Nu=":",c2=[],ku=(e,t,n,r,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:s}),d2=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===Nu){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(gl)?(h=p.slice(0,-1),m=!0):p.startsWith(gl)&&(h=p.slice(1),m=!0);const g=d&&d>c?d-c:void 0;return ku(a,m,h,g)};if(t){const s=t+Nu,a=r;r=i=>i.startsWith(s)?a(i.slice(s.length)):ku(c2,!1,i,void 0,!0)}if(n){const s=r;r=a=>n({className:a,parseClassName:s})}return r},u2=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}},p2=e=>({cache:l2(e.cacheSize),parseClassName:d2(e),sortModifiers:u2(e),...JN(e)}),f2=/\s+/,h2=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:s,sortModifiers:a}=t,i=[],l=e.trim().split(f2);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+gl:w,N=v+y;if(i.indexOf(N)>-1)continue;i.push(N);const k=s(y,x);for(let C=0;C<k.length;++C){const E=k[C];i.push(v+E)}c=f+(c.length>0?" "+c:c)}return c},m2=(...e)=>{let t=0,n,r,s="";for(;t<e.length;)(n=e[t++])&&(r=tm(n))&&(s&&(s+=" "),s+=r);return s},tm=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=tm(e[r]))&&(n&&(n+=" "),n+=t);return n},g2=(e,...t)=>{let n,r,s,a;const i=c=>{const d=t.reduce((f,p)=>p(f),e());return n=p2(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=h2(c,n);return s(c,f),f};return a=i,(...c)=>a(m2(...c))},b2=[],Ge=e=>{const t=n=>n[e]||b2;return t.isThemeGetter=!0,t},nm=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,rm=/^\((?:(\w[\w-]*):)?(.+)\)$/i,x2=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,y2=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,v2=/\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$/,w2=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,N2=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,k2=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,xn=e=>x2.test(e),Ie=e=>!!e&&!Number.isNaN(Number(e)),yn=e=>!!e&&Number.isInteger(Number(e)),pi=e=>e.endsWith("%")&&Ie(e.slice(0,-1)),tn=e=>y2.test(e),om=()=>!0,S2=e=>v2.test(e)&&!w2.test(e),hc=()=>!1,C2=e=>N2.test(e),M2=e=>k2.test(e),E2=e=>!xe(e)&&!ye(e),I2=e=>_n(e,im,hc),xe=e=>nm.test(e),Bn=e=>_n(e,lm,S2),Su=e=>_n(e,R2,Ie),A2=e=>_n(e,dm,om),P2=e=>_n(e,cm,hc),Cu=e=>_n(e,sm,hc),_2=e=>_n(e,am,M2),os=e=>_n(e,um,C2),ye=e=>rm.test(e),Yr=e=>ar(e,lm),$2=e=>ar(e,cm),Mu=e=>ar(e,sm),D2=e=>ar(e,im),L2=e=>ar(e,am),ss=e=>ar(e,um,!0),T2=e=>ar(e,dm,!0),_n=(e,t,n)=>{const r=nm.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},ar=(e,t,n=!1)=>{const r=rm.exec(e);return r?r[1]?t(r[1]):n:!1},sm=e=>e==="position"||e==="percentage",am=e=>e==="image"||e==="url",im=e=>e==="length"||e==="size"||e==="bg-size",lm=e=>e==="length",R2=e=>e==="number",cm=e=>e==="family-name",dm=e=>e==="number"||e==="weight",um=e=>e==="shadow",O2=()=>{const e=Ge("color"),t=Ge("font"),n=Ge("text"),r=Ge("font-weight"),s=Ge("tracking"),a=Ge("leading"),i=Ge("breakpoint"),l=Ge("container"),c=Ge("spacing"),d=Ge("radius"),f=Ge("shadow"),p=Ge("inset-shadow"),h=Ge("text-shadow"),m=Ge("drop-shadow"),g=Ge("blur"),b=Ge("perspective"),x=Ge("aspect"),y=Ge("ease"),w=Ge("animate"),v=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],k=()=>[...N(),ye,xe],C=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto","contain","none"],P=()=>[ye,xe,c],I=()=>[xn,"full","auto",...P()],z=()=>[yn,"none","subgrid",ye,xe],A=()=>["auto",{span:["full",yn,ye,xe]},yn,ye,xe],O=()=>[yn,"auto",ye,xe],R=()=>["auto","min","max","fr",ye,xe],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],D=()=>["start","end","center","stretch","center-safe","end-safe"],L=()=>["auto",...P()],T=()=>[xn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...P()],B=()=>[xn,"screen","full","dvw","lvw","svw","min","max","fit",...P()],F=()=>[xn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...P()],j=()=>[e,ye,xe],H=()=>[...N(),Mu,Cu,{position:[ye,xe]}],$=()=>["no-repeat",{repeat:["","x","y","space","round"]}],V=()=>["auto","cover","contain",D2,I2,{size:[ye,xe]}],G=()=>[pi,Yr,Bn],Z=()=>["","none","full",d,ye,xe],oe=()=>["",Ie,Yr,Bn],te=()=>["solid","dashed","dotted","double"],X=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],re=()=>[Ie,pi,Mu,Cu],be=()=>["","none",g,ye,xe],J=()=>["none",Ie,ye,xe],K=()=>["none",Ie,ye,xe],ee=()=>[Ie,ye,xe],ae=()=>[xn,"full",...P()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[tn],breakpoint:[tn],color:[om],container:[tn],"drop-shadow":[tn],ease:["in","out","in-out"],font:[E2],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[tn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[tn],shadow:[tn],spacing:["px",Ie],text:[tn],"text-shadow":[tn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",xn,xe,ye,x]}],container:["container"],columns:[{columns:[Ie,xe,ye,l]}],"break-after":[{"break-after":v()}],"break-before":[{"break-before":v()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:k()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll: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:[yn,"auto",ye,xe]}],basis:[{basis:[xn,"full","auto",l,...P()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ie,xn,"auto","initial","none",xe]}],grow:[{grow:["",Ie,ye,xe]}],shrink:[{shrink:["",Ie,ye,xe]}],order:[{order:[yn,"first","last","none",ye,xe]}],"grid-cols":[{"grid-cols":z()}],"col-start-end":[{col:A()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":z()}],"row-start-end":[{row:A()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:P()}],"gap-x":[{"gap-x":P()}],"gap-y":[{"gap-y":P()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...D(),"normal"]}],"justify-self":[{"justify-self":["auto",...D()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...D(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...D(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...D(),"baseline"]}],"place-self":[{"place-self":["auto",...D()]}],p:[{p:P()}],px:[{px:P()}],py:[{py:P()}],ps:[{ps:P()}],pe:[{pe:P()}],pbs:[{pbs:P()}],pbe:[{pbe:P()}],pt:[{pt:P()}],pr:[{pr:P()}],pb:[{pb:P()}],pl:[{pl:P()}],m:[{m:L()}],mx:[{mx:L()}],my:[{my:L()}],ms:[{ms:L()}],me:[{me:L()}],mbs:[{mbs:L()}],mbe:[{mbe:L()}],mt:[{mt:L()}],mr:[{mr:L()}],mb:[{mb:L()}],ml:[{ml:L()}],"space-x":[{"space-x":P()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":P()}],"space-y-reverse":["space-y-reverse"],size:[{size:T()}],"inline-size":[{inline:["auto",...B()]}],"min-inline-size":[{"min-inline":["auto",...B()]}],"max-inline-size":[{"max-inline":["none",...B()]}],"block-size":[{block:["auto",...F()]}],"min-block-size":[{"min-block":["auto",...F()]}],"max-block-size":[{"max-block":["none",...F()]}],w:[{w:[l,"screen",...T()]}],"min-w":[{"min-w":[l,"screen","none",...T()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...T()]}],h:[{h:["screen","lh",...T()]}],"min-h":[{"min-h":["screen","lh","none",...T()]}],"max-h":[{"max-h":["screen","lh",...T()]}],"font-size":[{text:["base",n,Yr,Bn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,T2,A2]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",pi,xe]}],"font-family":[{font:[$2,P2,t]}],"font-features":[{"font-features":[xe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,ye,xe]}],"line-clamp":[{"line-clamp":[Ie,"none",ye,Su]}],leading:[{leading:[a,...P()]}],"list-image":[{"list-image":["none",ye,xe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ye,xe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:j()}],"text-color":[{text:j()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...te(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ie,"from-font","auto",ye,Bn]}],"text-decoration-color":[{decoration:j()}],"underline-offset":[{"underline-offset":[Ie,"auto",ye,xe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ye,xe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ye,xe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:H()}],"bg-repeat":[{bg:$()}],"bg-size":[{bg:V()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},yn,ye,xe],radial:["",ye,xe],conic:[yn,ye,xe]},L2,_2]}],"bg-color":[{bg:j()}],"gradient-from-pos":[{from:G()}],"gradient-via-pos":[{via:G()}],"gradient-to-pos":[{to:G()}],"gradient-from":[{from:j()}],"gradient-via":[{via:j()}],"gradient-to":[{to:j()}],rounded:[{rounded:Z()}],"rounded-s":[{"rounded-s":Z()}],"rounded-e":[{"rounded-e":Z()}],"rounded-t":[{"rounded-t":Z()}],"rounded-r":[{"rounded-r":Z()}],"rounded-b":[{"rounded-b":Z()}],"rounded-l":[{"rounded-l":Z()}],"rounded-ss":[{"rounded-ss":Z()}],"rounded-se":[{"rounded-se":Z()}],"rounded-ee":[{"rounded-ee":Z()}],"rounded-es":[{"rounded-es":Z()}],"rounded-tl":[{"rounded-tl":Z()}],"rounded-tr":[{"rounded-tr":Z()}],"rounded-br":[{"rounded-br":Z()}],"rounded-bl":[{"rounded-bl":Z()}],"border-w":[{border:oe()}],"border-w-x":[{"border-x":oe()}],"border-w-y":[{"border-y":oe()}],"border-w-s":[{"border-s":oe()}],"border-w-e":[{"border-e":oe()}],"border-w-bs":[{"border-bs":oe()}],"border-w-be":[{"border-be":oe()}],"border-w-t":[{"border-t":oe()}],"border-w-r":[{"border-r":oe()}],"border-w-b":[{"border-b":oe()}],"border-w-l":[{"border-l":oe()}],"divide-x":[{"divide-x":oe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":oe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...te(),"hidden","none"]}],"divide-style":[{divide:[...te(),"hidden","none"]}],"border-color":[{border:j()}],"border-color-x":[{"border-x":j()}],"border-color-y":[{"border-y":j()}],"border-color-s":[{"border-s":j()}],"border-color-e":[{"border-e":j()}],"border-color-bs":[{"border-bs":j()}],"border-color-be":[{"border-be":j()}],"border-color-t":[{"border-t":j()}],"border-color-r":[{"border-r":j()}],"border-color-b":[{"border-b":j()}],"border-color-l":[{"border-l":j()}],"divide-color":[{divide:j()}],"outline-style":[{outline:[...te(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ie,ye,xe]}],"outline-w":[{outline:["",Ie,Yr,Bn]}],"outline-color":[{outline:j()}],shadow:[{shadow:["","none",f,ss,os]}],"shadow-color":[{shadow:j()}],"inset-shadow":[{"inset-shadow":["none",p,ss,os]}],"inset-shadow-color":[{"inset-shadow":j()}],"ring-w":[{ring:oe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:j()}],"ring-offset-w":[{"ring-offset":[Ie,Bn]}],"ring-offset-color":[{"ring-offset":j()}],"inset-ring-w":[{"inset-ring":oe()}],"inset-ring-color":[{"inset-ring":j()}],"text-shadow":[{"text-shadow":["none",h,ss,os]}],"text-shadow-color":[{"text-shadow":j()}],opacity:[{opacity:[Ie,ye,xe]}],"mix-blend":[{"mix-blend":[...X(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":X()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ie]}],"mask-image-linear-from-pos":[{"mask-linear-from":re()}],"mask-image-linear-to-pos":[{"mask-linear-to":re()}],"mask-image-linear-from-color":[{"mask-linear-from":j()}],"mask-image-linear-to-color":[{"mask-linear-to":j()}],"mask-image-t-from-pos":[{"mask-t-from":re()}],"mask-image-t-to-pos":[{"mask-t-to":re()}],"mask-image-t-from-color":[{"mask-t-from":j()}],"mask-image-t-to-color":[{"mask-t-to":j()}],"mask-image-r-from-pos":[{"mask-r-from":re()}],"mask-image-r-to-pos":[{"mask-r-to":re()}],"mask-image-r-from-color":[{"mask-r-from":j()}],"mask-image-r-to-color":[{"mask-r-to":j()}],"mask-image-b-from-pos":[{"mask-b-from":re()}],"mask-image-b-to-pos":[{"mask-b-to":re()}],"mask-image-b-from-color":[{"mask-b-from":j()}],"mask-image-b-to-color":[{"mask-b-to":j()}],"mask-image-l-from-pos":[{"mask-l-from":re()}],"mask-image-l-to-pos":[{"mask-l-to":re()}],"mask-image-l-from-color":[{"mask-l-from":j()}],"mask-image-l-to-color":[{"mask-l-to":j()}],"mask-image-x-from-pos":[{"mask-x-from":re()}],"mask-image-x-to-pos":[{"mask-x-to":re()}],"mask-image-x-from-color":[{"mask-x-from":j()}],"mask-image-x-to-color":[{"mask-x-to":j()}],"mask-image-y-from-pos":[{"mask-y-from":re()}],"mask-image-y-to-pos":[{"mask-y-to":re()}],"mask-image-y-from-color":[{"mask-y-from":j()}],"mask-image-y-to-color":[{"mask-y-to":j()}],"mask-image-radial":[{"mask-radial":[ye,xe]}],"mask-image-radial-from-pos":[{"mask-radial-from":re()}],"mask-image-radial-to-pos":[{"mask-radial-to":re()}],"mask-image-radial-from-color":[{"mask-radial-from":j()}],"mask-image-radial-to-color":[{"mask-radial-to":j()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":N()}],"mask-image-conic-pos":[{"mask-conic":[Ie]}],"mask-image-conic-from-pos":[{"mask-conic-from":re()}],"mask-image-conic-to-pos":[{"mask-conic-to":re()}],"mask-image-conic-from-color":[{"mask-conic-from":j()}],"mask-image-conic-to-color":[{"mask-conic-to":j()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:$()}],"mask-size":[{mask:V()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ye,xe]}],filter:[{filter:["","none",ye,xe]}],blur:[{blur:be()}],brightness:[{brightness:[Ie,ye,xe]}],contrast:[{contrast:[Ie,ye,xe]}],"drop-shadow":[{"drop-shadow":["","none",m,ss,os]}],"drop-shadow-color":[{"drop-shadow":j()}],grayscale:[{grayscale:["",Ie,ye,xe]}],"hue-rotate":[{"hue-rotate":[Ie,ye,xe]}],invert:[{invert:["",Ie,ye,xe]}],saturate:[{saturate:[Ie,ye,xe]}],sepia:[{sepia:["",Ie,ye,xe]}],"backdrop-filter":[{"backdrop-filter":["","none",ye,xe]}],"backdrop-blur":[{"backdrop-blur":be()}],"backdrop-brightness":[{"backdrop-brightness":[Ie,ye,xe]}],"backdrop-contrast":[{"backdrop-contrast":[Ie,ye,xe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ie,ye,xe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ie,ye,xe]}],"backdrop-invert":[{"backdrop-invert":["",Ie,ye,xe]}],"backdrop-opacity":[{"backdrop-opacity":[Ie,ye,xe]}],"backdrop-saturate":[{"backdrop-saturate":[Ie,ye,xe]}],"backdrop-sepia":[{"backdrop-sepia":["",Ie,ye,xe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":P()}],"border-spacing-x":[{"border-spacing-x":P()}],"border-spacing-y":[{"border-spacing-y":P()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ye,xe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ie,"initial",ye,xe]}],ease:[{ease:["linear","initial",y,ye,xe]}],delay:[{delay:[Ie,ye,xe]}],animate:[{animate:["none",w,ye,xe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,ye,xe]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:J()}],"rotate-x":[{"rotate-x":J()}],"rotate-y":[{"rotate-y":J()}],"rotate-z":[{"rotate-z":J()}],scale:[{scale:K()}],"scale-x":[{"scale-x":K()}],"scale-y":[{"scale-y":K()}],"scale-z":[{"scale-z":K()}],"scale-3d":["scale-3d"],skew:[{skew:ee()}],"skew-x":[{"skew-x":ee()}],"skew-y":[{"skew-y":ee()}],transform:[{transform:[ye,xe,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ae()}],"translate-x":[{"translate-x":ae()}],"translate-y":[{"translate-y":ae()}],"translate-z":[{"translate-z":ae()}],"translate-none":["translate-none"],accent:[{accent:j()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:j()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ye,xe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mbs":[{"scroll-mbs":P()}],"scroll-mbe":[{"scroll-mbe":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pbs":[{"scroll-pbs":P()}],"scroll-pbe":[{"scroll-pbe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ye,xe]}],fill:[{fill:["none",...j()]}],"stroke-w":[{stroke:[Ie,Yr,Bn,Su]}],stroke:[{stroke:["none",...j()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},B2=g2(O2);function W(...e){return B2(Zh(e))}const z2="rounded-lg border border-border bg-surface overflow-hidden",F2="border-b border-border px-3 sm:px-4 py-1.5 sm:py-2",j2="p-2 sm:p-3 lg:p-4",pm="space-y-3 sm:space-y-4",fm="gap-2 sm:gap-3",hm="px-3 sm:px-4 py-1.5 sm:py-2",H2="grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4",V2="grid grid-cols-1 lg:grid-cols-2",q2="flex flex-col-reverse md:flex-row",U2="w-full md:w-44 lg:w-52 md:flex-shrink-0 border-b md:border-b-0 md:border-l border-border",Q2="text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider",G2="text-[11px] sm:text-xs text-foreground",Gs="text-[10px] text-foreground-subtle",K2="text-[11px] sm:text-xs font-medium text-foreground",bl="text-base sm:text-lg font-semibold leading-tight text-foreground",W2="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",Y2="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",Z2="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",X2="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",J2="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",ek="inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors",tk="border-primary/50 bg-primary/15 text-primary",nk="border-border bg-surface text-foreground-subtle hover:bg-surface-hover";function rk(e,t){for(const n of e.slots)for(const r of n.addons)if(r.id===t)return r;return null}function ok(e,t){return e.models.find(n=>n.id===t)??null}function sk(e,t){return e.models.find(n=>!!n.formats[t])??null}function ak(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 mm(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=rk(r,i);if(!c){a.push({addonId:i,outcome:"skip",modelId:null,reason:"addon not in target catalog",patch:null});continue}const d=ok(c,l.modelId),f=d!==null&&!!d.formats[n.engine.format];let p,h;if(f)p=l.modelId,h="exact";else{const g=sk(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:ak(l.settings,c)};a.push({addonId:i,outcome:h,modelId:p,patch:m})}return a}const xl={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 ir(e){return xl[e]??xl.watching}function mn(e,t){if(typeof globalThis>"u")return Be(t);const n=globalThis.__camstackSharedContexts,r=n??new Map;n||(globalThis.__camstackSharedContexts=r);const s=r.get(e);if(s)return s;const a=Be(t);return r.set(e,a),a}function Nr(e){const n=(typeof globalThis<"u"?globalThis:void 0)?.[e];return n&&typeof n=="object"?n:{}}const ik={singleton:!0,requiredVersion:!1,eager:!0},jt=e=>({version:"0.0.0",scope:"default",lib:e,shareConfig:ik}),Eu="__mf_module_cache__";function lk(){const e=globalThis,t=e[Eu];if(t&&typeof t=="object"){const r=t;return r.share??={},r.remote??={},r}const n={share:{},remote:{}};return e[Eu]=n,n}function ck(){const e=lk();e.share.react??=Ph,e.share["react-dom"]??=_h,e.share["react-dom/client"]??=$h,e.share["react/jsx-runtime"]??=Ah,e.share["@tanstack/react-query"]??=Lh,e.share["@trpc/client"]??=Oh,e.share["@trpc/react-query"]??=Fh,e.share["@camstack/ui-library"]??=Nr("__camstackUiLibrary"),e.share["@camstack/sdk"]??=Nr("__camstackSdk"),e.share["@camstack/types"]??=Nr("__camstackTypes")}function mc(){ck(),Mr.getInstance()===null&&Mr.init({name:"admin_ui_host",remotes:[],shared:{react:jt(()=>Ph),"react-dom":jt(()=>_h),"react-dom/client":jt(()=>$h),"react/jsx-runtime":jt(()=>Ah),"@tanstack/react-query":jt(()=>Lh),"@trpc/client":jt(()=>Oh),"@trpc/react-query":jt(()=>Fh),"@camstack/ui-library":jt(()=>Nr("__camstackUiLibrary")),"@camstack/sdk":jt(()=>Nr("__camstackSdk")),"@camstack/types":jt(()=>Nr("__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 gm=(...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 dk=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 uk=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 Iu=e=>{const t=uk(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 pk={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 fk=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 hk=qe(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:i,...l},c)=>Ee("svg",{ref:c,...pk,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:gm("lucide",s),...!a&&!fk(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,f])=>Ee(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)=>Ee(hk,{ref:a,iconNode:t,className:gm(`lucide-${dk(Iu(e))}`,`lucide-${e}`,r),...s}));return n.displayName=Iu(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 mk=[["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"}]],kn=le("activity",mk);/**
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 gk=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],bk=le("arrow-down",gk);/**
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 xk=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],yk=le("arrow-left",xk);/**
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 vk=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],wk=le("arrow-right",vk);/**
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"}]],gc=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 kk=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Sk=le("arrow-up",kk);/**
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 Ck=[["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"}]],Mk=le("battery-full",Ck);/**
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 Ek=[["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"}]],Ik=le("battery-low",Ek);/**
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 Ak=[["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"}]],Pk=le("battery-warning",Ak);/**
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 _k=[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],bm=le("battery",_k);/**
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 $k=[["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"}]],Dk=le("bell-ring",$k);/**
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 Lk=[["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"}]],Na=le("bell",Lk);/**
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 Tk=[["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"}]],Rk=le("bug",Tk);/**
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 Ok=[["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"}]],bc=le("camera",Ok);/**
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 Bk=[["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"}]],zk=le("cast",Bk);/**
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 Fk=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Bo=le("check",Fk);/**
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 jk=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],lr=le("chevron-down",jk);/**
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 Hk=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Vk=le("chevron-left",Hk);/**
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 qk=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],$n=le("chevron-right",qk);/**
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 Uk=[["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"}]],ka=le("circle-alert",Uk);/**
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 Qk=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Gk=le("circle-check-big",Qk);/**
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 Kk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Wk=le("circle-check",Kk);/**
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 Yk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Zk=le("circle-dot",Yk);/**
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 Xk=[["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"}]],Jk=le("circle-pause",Xk);/**
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 e5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],t5=le("circle-plus",e5);/**
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 n5=[["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"}]],xm=le("circle-question-mark",n5);/**
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 r5=[["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"}]],o5=le("circle-x",r5);/**
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 s5=[["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"}]],a5=le("copy-plus",s5);/**
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 i5=[["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"}]],Dn=le("copy",i5);/**
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 l5=[["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"}]],c5=le("cpu",l5);/**
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 d5=[["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"}]],ym=le("crosshair",d5);/**
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 u5=[["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"}]],p5=le("database",u5);/**
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 f5=[["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"}]],vm=le("door-open",f5);/**
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 h5=[["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"}]],yl=le("download",h5);/**
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 m5=[["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"}]],wm=le("ellipsis-vertical",m5);/**
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 g5=[["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"}]],Nm=le("external-link",g5);/**
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 b5=[["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"}]],km=le("eye-off",b5);/**
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 x5=[["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"}]],zo=le("eye",x5);/**
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 y5=[["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"}]],Sm=le("funnel",y5);/**
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 v5=[["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"}]],w5=le("grip-horizontal",v5);/**
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"}]],Cm=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 k5=[["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"}]],S5=le("image",k5);/**
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 C5=[["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"}]],M5=le("inbox",C5);/**
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 E5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],I5=le("info",E5);/**
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 A5=[["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"}]],P5=le("layout-grid",A5);/**
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 _5=[["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"}]],Mm=le("lightbulb",_5);/**
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 $5=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ot=le("loader-circle",$5);/**
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 D5=[["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"}]],L5=le("locate-fixed",D5);/**
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 T5=[["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"}]],Au=le("maximize-2",T5);/**
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 R5=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],O5=le("menu",R5);/**
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 B5=[["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"}]],Em=le("mic",B5);/**
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 z5=[["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"}]],Pu=le("minimize-2",z5);/**
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 F5=[["path",{d:"M5 12h14",key:"1ays0h"}]],Im=le("minus",F5);/**
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 j5=[["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"}]],xc=le("moon",j5);/**
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 H5=[["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"}]],V5=le("music",H5);/**
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 q5=[["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"}]],vl=le("network",q5);/**
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 U5=[["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"}]],Q5=le("pencil",U5);/**
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 G5=[["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"}]],wl=le("play",G5);/**
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 K5=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Fo=le("plus",K5);/**
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 W5=[["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"}]],Y5=le("plug",W5);/**
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 Z5=[["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"}]],X5=le("power-off",Z5);/**
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 J5=[["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"}]],Am=le("radar",J5);/**
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 eS=[["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"}]],tS=le("radio",eS);/**
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 nS=[["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"}]],yc=le("refresh-cw",nS);/**
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 rS=[["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"}]],Pm=le("rotate-ccw",rS);/**
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 oS=[["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"}]],_m=le("rotate-cw",oS);/**
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 sS=[["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"}]],aS=le("save",sS);/**
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 iS=[["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"}]],lS=le("scan",iS);/**
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 cS=[["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"}]],dS=le("scroll-text",cS);/**
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 uS=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],xo=le("search",uS);/**
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 pS=[["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"}]],fS=le("server",pS);/**
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 hS=[["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"}]],mS=le("shield",hS);/**
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 gS=[["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"}]],bS=le("ship",gS);/**
436
- * @license lucide-react v0.576.0 - ISC
437
- *
438
- * This source code is licensed under the ISC license.
439
- * See the LICENSE file in the root directory of this source tree.
440
- */const xS=[["path",{d:"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"}]],yS=le("sliders-horizontal",xS);/**
441
- * @license lucide-react v0.576.0 - ISC
442
- *
443
- * This source code is licensed under the ISC license.
444
- * See the LICENSE file in the root directory of this source tree.
445
- */const vS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],_u=le("square",vS);/**
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 wS=[["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",wS);/**
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 kS=[["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"}]],$m=le("sun",kS);/**
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 SS=[["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"}]],CS=le("table-2",SS);/**
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 MS=[["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"}]],$u=le("target",MS);/**
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 ES=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],IS=le("thermometer",ES);/**
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 AS=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],PS=le("toggle-left",AS);/**
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 _S=[["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",_S);/**
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 $S=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],DS=le("trending-up",$S);/**
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 LS=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],TS=le("trending-down",LS);/**
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 RS=[["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"}]],jo=le("triangle-alert",RS);/**
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 OS=[["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"}]],Dm=le("upload",OS);/**
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 BS=[["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"}]],zS=le("wifi-off",BS);/**
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 FS=[["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"}]],Lm=le("wifi",FS);/**
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 jS=[["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"}]],vc=le("wrench",jS);/**
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 HS=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ye=le("x",HS);/**
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 VS=[["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"}]],Du=le("zap",VS);/**
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 qS=[["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"}]],US=le("zoom-in",qS);/**
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 QS=[["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"}]],GS=le("zoom-out",QS),KS={frigate:bS,scrypted:mS,reolink:tS,homeAssistant:Cm,rtsp:zk},WS={online:Wk,offline:o5,degraded:ka,unknown:xm},Lu=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Tu=Zh,cr=(e,t)=>n=>{var r;if(t?.variants==null)return Tu(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=Lu(f)||Lu(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 Tu(e,i,c,n?.class,n?.className)},YS=cr("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"}}),Oe=qe(({className:e,variant:t,size:n,...r},s)=>o("button",{ref:s,className:W(YS({variant:t,size:n}),e),...r}));Oe.displayName="Button";const ZS=cr("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"}}),wc=qe(({className:e,variant:t,size:n,icon:r,...s},a)=>o("button",{ref:a,className:W(ZS({variant:t,size:n}),e),...s,children:o(r,{className:"h-4 w-4"})}));wc.displayName="IconButton";const XS=cr("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"}}),ln=qe(({className:e,variant:t,style:n,...r},s)=>o("span",{ref:s,className:W(XS({variant:t,styleVariant:n}),e),...r}));ln.displayName="Badge";const JS=cr("rounded-lg p-3",{variants:{variant:{flat:"bg-surface",bordered:"bg-surface border border-border"}},defaultVariants:{variant:"bordered"}}),Tt=qe(({className:e,variant:t,...n},r)=>o("div",{ref:r,className:W(JS({variant:t}),e),...n}));Tt.displayName="Card";function Tm({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(lr,{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 Nc=qe(({className:e,...t},n)=>o("label",{ref:n,className:W("text-[10px] uppercase tracking-wider text-foreground-muted font-medium",e),...t}));Nc.displayName="Label";const eC=cr("",{variants:{orientation:{horizontal:"h-px w-full bg-border-subtle",vertical:"w-px h-full bg-border-subtle"}},defaultVariants:{orientation:"horizontal"}}),kc=qe(({className:e,orientation:t,...n},r)=>o("div",{ref:r,role:"separator",className:W(eC({orientation:t}),e),...n}));kc.displayName="Separator";const Rm=qe(({className:e,...t},n)=>o("div",{ref:n,className:W("animate-pulse bg-surface-hover rounded-md h-4 w-full",e),...t}));Rm.displayName="Skeleton";const Ru=cr("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"}}),Ks=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(Ru({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(Ru({state:t}),e),...s}));Ks.displayName="Input";const yo=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(lr,{className:"h-3.5 w-3.5"})})]}));yo.displayName="Select";const Om=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}));Om.displayName="Checkbox";const Sc=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})]}));Sc.displayName="Switch";const Bm=Be(null);function zm(){const e=ve(Bm);if(!e)throw new Error("Dialog compound components must be used within <Dialog>");return e}function Fm({children:e,open:t,onOpenChange:n}){const[r,s]=_(!1),a=t??r,i=Wn(),l=q(c=>{n?.(c),t===void 0&&s(c)},[t,n]);return o(Bm.Provider,{value:{open:a,setOpen:l,contentId:i},children:e})}function tC({children:e,...t}){const{setOpen:n}=zm();return o("button",{type:"button",onClick:()=>n(!0),...t,children:e})}const nC=cr("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"}}),Cc=qe(({className:e,width:t,children:n,...r},s)=>{const{open:a,setOpen:i,contentId:l}=zm(),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(nC({width:t}),"w-full",e),onClick:f,onClose:()=>i(!1),...r,children:n})});Cc.displayName="DialogContent";function jm({className:e,...t}){return o("div",{className:W("flex flex-col gap-1 mb-3",e),...t})}function Hm({className:e,...t}){return o("div",{className:W("flex justify-end gap-2 mt-4",e),...t})}function Vm({className:e,...t}){return o("h2",{className:W("text-sm font-semibold text-foreground",e),...t})}function qm({className:e,...t}){return o("p",{className:W("text-xs text-foreground-muted",e),...t})}const Um=Be(null);function Mc(){const e=ve(Um);if(!e)throw new Error("Dropdown compound components must be used within <Dropdown>");return e}function Qm({children:e}){const[t,n]=_(!1),r=Wn(),s=Wn(),a=ne(null);return o(Um.Provider,{value:{open:t,setOpen:n,triggerId:r,contentId:s,triggerRef:a},children:o("div",{className:"relative inline-block",children:e})})}function Gm({children:e,...t}){const{open:n,setOpen:r,triggerId:s,contentId:a,triggerRef:i}=Mc();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 Km({className:e,children:t,align:n="start",offset:r=4,...s}){const{open:a,setOpen:i,contentId:l,triggerId:c,triggerRef:d}=Mc(),f=ne(null),[p,h]=_(null);if(va(()=>{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 Oo(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 Wm({className:e,icon:t,variant:n="default",children:r,onClick:s,...a}){const{setOpen:i}=Mc(),l=q(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 Ym=Be(null);function Zm(){const e=ve(Ym);if(!e)throw new Error("Tooltip compound components must be used within <Tooltip>");return e}function rC({children:e}){const[t,n]=_(!1),r=ne(null),s=Wn(),a=()=>{r.current=setTimeout(()=>n(!0),300)},i=()=>{r.current&&clearTimeout(r.current),n(!1)};return o(Ym.Provider,{value:{open:t,show:a,hide:i,tooltipId:s},children:o("div",{className:"relative inline-block",children:e})})}function oC({children:e,...t}){const{show:n,hide:r,tooltipId:s,open:a}=Zm();return o("div",{onMouseEnter:n,onMouseLeave:r,onFocus:n,onBlur:r,"aria-describedby":a?s:void 0,...t,children:e})}function sC({className:e,children:t,...n}){const{open:r,tooltipId:s}=Zm();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 Ou="(max-width: 767px)",Bu="(min-width: 768px) and (max-width: 1023px)";function Xm(e){return t=>{const n=window.matchMedia(e);return n.addEventListener("change",t),()=>n.removeEventListener("change",t)}}function Jm(e){return()=>window.matchMedia(e).matches}function eg(){return!1}function dr(){return wa(Xm(Ou),Jm(Ou),eg)}function tg(){return wa(Xm(Bu),Jm(Bu),eg)}function Ec({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(Ye,{className:"h-4 w-4"})})]}),o("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:r})]})]})}const ng=Be(null);function rg(){const e=ve(ng);if(!e)throw new Error("Popover compound components must be used within <Popover>");return e}function og({children:e,open:t,onOpenChange:n}){const[r,s]=_(!1),a=t??r,i=Wn(),l=Wn(),c=q(d=>{n?.(d),t===void 0&&s(d)},[t,n]);return o(ng.Provider,{value:{open:a,setOpen:c,triggerId:i,contentId:l},children:o("div",{className:"relative inline-block",children:e})})}function sg({children:e,...t}){const{open:n,setOpen:r,triggerId:s,contentId:a}=rg();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 ag({className:e,children:t,...n}){const{open:r,setOpen:s,contentId:a,triggerId:i}=rg(),l=dr(),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(Ec,{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 ig=Be(null);function lg(){const e=ve(ig);if(!e)throw new Error("Tabs compound components must be used within <Tabs>");return e}function aC({value:e,onValueChange:t,defaultValue:n="",className:r,...s}){const[a,i]=_(n),l=e??a,c=q(d=>{t?.(d),e===void 0&&i(d)},[e,t]);return o(ig.Provider,{value:{value:l,setValue:c},children:o("div",{className:r,...s})})}function iC({className:e,...t}){return o("div",{role:"tablist",className:W("flex flex-row border-b border-border-subtle",e),...t})}function lC({value:e,className:t,...n}){const{value:r,setValue:s}=lg(),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 cC({value:e,className:t,...n}){const{value:r}=lg();return e!==r?null:o("div",{role:"tabpanel",id:`tabpanel-${e}`,className:W("pt-3",t),...n})}const Ic=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}));Ic.displayName="ScrollArea";function dC({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=dr(),v=q(k=>{k.preventDefault(),b.current=!0,y.current={x:k.clientX-d.x,y:k.clientY-d.y}},[d]),N=q(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 P=E.clientX-y.current.x,I=E.clientY-y.current.y;y.current={x:E.clientX,y:E.clientY},h(z=>({w:Math.max(a,z.w+P),h:Math.max(i,z.h+I)}))}},C=()=>{b.current=!1,x.current=!1};return window.addEventListener("mousemove",k),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",C)}},[a,i]),w?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(Au,{size:12}):o(Pu,{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(Ye,{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(w5,{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(Au,{size:12}):o(Pu,{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(Ye,{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 Ac({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 Pc({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(uc.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 zu={left:"text-left",right:"text-right",center:"text-center"};function _c({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",zu[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",zu[x],y?"whitespace-nowrap":""].filter(Boolean).join(" "),children:b.render(f,p)},b.key)})},h)})})]})})}function $c({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(Ye,{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 uC={inherit:"bg-muted",on:"bg-emerald-500",off:"bg-orange-500",na:"bg-gray-300 opacity-50"};function cg({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",uC[l.state])},l.agentNodeId))})]}),e.children.map(l=>o(cg,{node:l,depth:t+1,selectedAddonId:n,onSelect:r,agentDots:s},l.addonId))]})}function dg({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(cg,{node:a,depth:0,selectedAddonId:t,onSelect:n,agentDots:r},a.addonId))})}function Sa(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 pC(e){return e?e.models.map(t=>({id:t.id,name:t.name})):[]}function Ls({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=pC(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(fi,{label:"Inherit",active:c===null,variant:"inherit",subtext:f===void 0?void 0:f?"on":"off",onClick:()=>d(null)}),o(fi,{label:"On",active:c===!0,variant:"on",onClick:()=>d(!0)}),o(fi,{label:"Off",active:c===!1,variant:"off",onClick:()=>d(!1)})]})]});return o(Tm,{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(Nl,{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(Nl,{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(Ca,{field:x,allFields:t.configSchema??[],step:e,disabled:i,onChange:s},x.key))]})})}function Nl({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 fC({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 hC(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 Ca({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=hC(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(Nl,{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(fC,{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 fi({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 ug(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 mC(e,t,n){return n?{enabled:n.enabled??t.enabled,modelId:n.modelId??t.modelId,settings:n.settings??t.settings}:t}function gC({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(Ca,{field:a,allFields:e.configSchema??[],step:ug(e,t),disabled:!1,onChange:i=>s({settings:{...i.settings}})},a.key))]})]})}function bC({addon:e,agentDefault:t,agentNodeId:n,currentPatch:r,modelsForFormat:s,onChangePatch:a}){const i=mC("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(Ca,{field:g,allFields:e.configSchema??[],step:ug(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 Ma(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(gC,{addon:n,agentDefault:r,modelsForFormat:d,onChangeAgentConfig:i}):o(bC,{addon:n,agentDefault:r,agentNodeId:s,currentPatch:a,modelsForFormat:d,onChangePatch:l})}function xC(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 Fu={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 yC({slot:e}){const t=Fu[e]??Fu.classifier;return o("span",{className:W("text-[9px] font-semibold uppercase tracking-widest leading-none",t.className),children:t.label})}const ju="inline-flex items-center rounded bg-muted px-1.5 py-px text-[9px] font-medium text-foreground-subtle";function vC({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(ju,"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(ju,"bg-emerald-500/10 text-emerald-500"),children:n},`out-${n}`))]})}function wC({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 kC({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(yC,{slot:e.slot}),u("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"font-semibold truncate",children:e.addonName}),o(vC,{inputs:e.inputClasses,outputs:e.outputClasses})]})]}),i&&o("span",{className:"pl-2 pt-0.5 shrink-0",children:o(wC,{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 Dc({tree:e,agents:t,getCellState:n,onCellClick:r,selectedCell:s,onToggleEnabled:a}){const i=Q(()=>xC(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(kC,{node:f,depth:p,agents:t,getCellState:n,onCellClick:r,selectedCell:s,toggleProps:m},f.addonId)})]})})}const pg=typeof globalThis<"u"?globalThis.__camstackTrpcReact:void 0,S=pg??$N();typeof globalThis<"u"&&!pg&&(globalThis.__camstackTrpcReact=S);const Lc=mn("camstack:system",null);function Tc({system:e,children:t}){return o(Lc.Provider,{value:e,children:t})}function De(){const e=ve(Lc);if(!e)throw new Error("useSystem(): no <SystemProvider> in tree");return e}function SC(){return ve(Lc)}function pt(e,t){const n=De(),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 kl(e){const t=ne(e);return t.current=e,t}function zr(e,t){const[n,r]=_(null),s=kl(t);return pt(e,a=>{const i=a.data,l=s.current;l&&!l(i)||r(i)}),n}function Rc(e,t,n){const[r,s]=_(()=>new Map),a=kl(t),i=kl(n);pt(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 Fr(){const{data:e,isLoading:t}=S.nodes.topology.useQuery(void 0,{staleTime:6e4}),r=zr("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 fg({selectedNodeId:e,onSelect:t,label:n="Node",hideIcon:r=!1,alwaysShow:s=!1}){const{nodes:a}=Fr();return!s&&a.length<=1?null:u("div",{className:"flex items-center gap-1.5",children:[!r&&o(fS,{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 CC={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 MC({status:e,showDot:t=!0,showLabel:n=!0,size:r="sm",className:s}){const a=CC[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 EC={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 IC({provider:e,showLabel:t=!0,className:n}){const r=EC[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 AC={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 hg({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",AC[t],r),children:e})}function PC({version:e,preRelease:t,className:n}){const r=t??/-(alpha|beta|rc|dev|canary|next)/i.test(e);return o(hg,{variant:r?"warning":"success",mono:!0,className:n,children:e})}function _C({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(Nc,{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 $C({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 Oc({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 mg=mn("camstack:confirm-dialog",null);function Je(){const e=ve(mg);if(!e)throw new Error("useConfirm must be used within ConfirmDialogProvider");return e.confirm}function gg({children:e}){const[t,n]=_(null),r=q(c=>new Promise(d=>{n({...c,resolve:d})}),[]),s=()=>{t?.resolve(!0),n(null)},a=()=>{t?.resolve(!1),n(null)},i={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600 text-white"},warning:{icon:"text-orange-400",button:"bg-orange-500 hover:bg-orange-600 text-white"},default:{icon:"text-primary",button:"bg-primary hover:bg-primary/90 text-white"}},l=t?i[t.variant??"default"]:i.default;return u(mg.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 DC({value:e,label:t,trend:n,className:r}){return u(Tt,{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(DS,{className:"h-3 w-3"}):o(TS,{className:"h-3 w-3"}),n.value,"%"]})]}),o("span",{className:"text-xs text-foreground-muted",children:t})]})}function LC({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 TC({children:e,maxHeight:t=300,className:n}){const[r,s]=_(!1),a=q(()=>{navigator.clipboard.writeText(e).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)})},[e]);return u("div",{className:W("relative group",n),children:[o(Ic,{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(wc,{icon:r?Bo:Dn,"aria-label":"Copy code",variant:"ghost",size:"sm",onClick:a})})]})}function RC({filters:e,values:t,onChange:n,className:r}){const s=dr(),[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(Ks,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:p=>l(d.key,p.target.value),leftSlot:o(xo,{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(yS,{className:"h-3.5 w-3.5"}),"Filters",c>0&&o(ln,{variant:"info",className:"ml-1 text-[10px] px-1 py-0",children:c})]}),o(Ec,{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(yo,{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(ln,{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(Ks,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:f=>l(d.key,f.target.value),leftSlot:o(xo,{className:"h-3 w-3 text-foreground-subtle"}),className:"w-48"},d.key);case"select":return o(yo,{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(ln,{variant:h?"info":"default",className:"cursor-pointer",children:f.label})},f.value)})},d.key);default:return null}})})}function Sl({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(ln,{className:"ml-auto text-[10px] px-1.5 py-0",children:r})]})}function Cl({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(Sl,{...l},l.href))})]},i))}),n&&n.length>0&&u("div",{className:"shrink-0 px-1 pb-1",children:[o(kc,{className:"mb-1"}),o("div",{className:"flex flex-col gap-0.5",onClick:r,children:n.map(a=>o(Sl,{...a},a.href))})]})]})}function OC({sidebar:e,header:t,mobileLogo:n,mobileActions:r,children:s,className:a}){const i=dr(),[l,c]=_(!1);return u("div",{className:W("flex h-screen",a),children:[!i&&o(Cl,{...e,className:W("w-44",e.className)}),i&&o(Ac,{open:l,onClose:()=>c(!1),width:"w-64",children:o(Cl,{...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(O5,{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 BC={online:"bg-success",offline:"bg-danger",warning:"bg-warning",unknown:"bg-foreground-subtle"};function zC({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",BC[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 FC({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 jC="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:jC},{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?DN(e,n):null,[e,n])}function cn(e){const t=q(r=>e?e.subscribe(()=>r()):()=>{},[e]),n=q(()=>e?.value,[e]);return wa(t,n,n)}function bg(e,t,n){const r=St(e,t),s=r?n(r.state):void 0;return cn(s)}function jr(e){const t=St(e.trpc,e.deviceId),n=t!==null?e.slice(t):void 0,r=cn(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 HC(e){return e.parentDeviceId===null?"top-level":e.role?"accessory":"adopted"}const VC={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 qC(e){const t=VC[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 UC={siren:Na,floodlight:Mm,spotlight:$m,"pir-sensor":Am,chime:V5,autotrack:ym,nightvision:xc,"privacy-mask":km,doorbell:vm},QC={camera:bc,hub:vl,nvr:vl,light:Mm,siren:Na,switch:PS,sensor:Am,thermostat:IS,button:Zk,generic:vc};function xg(e){return e.role?UC[e.role]??vc:QC[e.type.toLowerCase()]??bc}const yg={"native-snapshot":S5,"two-way-audio":Em,"pan-tilt-zoom":ym,"ptz-autotrack":L5,"doorbell-button":vm,"motion-trigger":kn,"battery-operated":bm,rebootable:_m},vg={"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"},GC={"native-snapshot":"snapshot",rebootable:"reboot","pan-tilt-zoom":"ptz","ptz-autotrack":"ptz-autotrack","two-way-audio":"intercom","motion-trigger":"motion-trigger"},wg=new Set(["camera","hub","nvr"]);function Ng(e){return!wg.has(e.type.toLowerCase())}function Hu(e){return e.role?!0:!wg.has(e.type.toLowerCase())}function kg(e){return(e.features??[]).includes("motion-trigger")}function KC(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 WC({trpc:e,accessoryChildren:t,adoptedChildren:n,onNavigate:r}){return u("div",{className:"border-t border-border-subtle/50",children:[n.length>0&&o(Vu,{trpc:e,label:"Adopted devices",rows:n,onNavigate:r}),t.length>0&&o(Vu,{trpc:e,label:"Accessories",rows:t,onNavigate:r})]})}function Vu({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(YC,{trpc:e,child:s,onNavigate:r},s.id))})]})}function YC({trpc:e,child:t,onNavigate:n}){const r=!t.disabled,s=r&&Ng(t),a=r&&kg(t),i=xg(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(XC,{trpc:e,deviceId:t.id,features:t.features}),s&&o(ZC,{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 ZC({trpc:e,deviceId:t}){const{dev:n,cap:r,slice:s,available:a}=jr({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 XC({trpc:e,deviceId:t,features:n}){const{dev:r,cap:s,slice:a,available:i}=jr({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(kn,{className:"h-2.5 w-2.5"})})}function Sg({trpc:e,device:t,flags:n}){if(!!t.disabled)return null;const s=t.type.toLowerCase(),a=n.showSwitchToggle&&Ng(t),i=kg(t),l=s==="hub"||s==="nvr",c=(t.features??[]).includes("rebootable"),d=l&&c;return u(me,{children:[i&&o(e3,{trpc:e,deviceId:t.id,features:t.features}),a&&o(JC,{trpc:e,deviceId:t.id}),d&&o(n3,{trpc:e,deviceId:t.id})]})}function JC({trpc:e,deviceId:t}){const{dev:n,cap:r,slice:s,available:a}=jr({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 e3({trpc:e,deviceId:t,features:n}){const{dev:r,cap:s,slice:a,available:i}=jr({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(kn,{className:"h-2.5 w-2.5"})})}const hi=168,t3=4;function n3({trpc:e,deviceId:t}){const{dev:n,cap:r}=jr({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-hi,v=Math.max(8,Math.min(w,window.innerWidth-hi-8)),N=y.bottom+t3;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(wm,{className:"h-3 w-3"})}),i&&Oo(o("div",{ref:a,role:"menu",style:{position:"fixed",top:i.top,left:i.left,width:hi},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(_m,{className:"h-3 w-3 shrink-0 text-foreground-subtle"}),o("span",{children:"Reboot device"})]})}),document.body)]})}const r3=Object.freeze([]);function o3(e){return e==="native"?"native":"enhanced"}function s3(e){return e.map(t=>({kind:"marker",feature:t}))}function a3(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=GC[a];if(i===void 0){s.push({kind:"marker",feature:a});continue}const l=n.get(i);l&&s.push({kind:o3(l.kind),feature:a,capName:i})}return s}function i3(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:r3}:l||a||!r?{loading:l,resolved:s3(n)}:{loading:!1,resolved:a3(n,r)}}const l3=[];function Cg({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??l3,d=a&&c.length>0,{resolved:f}=i3(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(c3,{accessoryCount:r,adoptedCount:s}),p&&o(d3,{resolved:f})]})}function c3({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 Mg=240,qu=200;function d3({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>=qu?l.bottom+4:l.top-qu-4,p=Math.max(8,Math.min(l.left,window.innerWidth-Mg-8));r({top:f,left:p})},onMouseLeave:()=>r(null),children:[e.map(i=>{const l=yg[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:vg[i.feature]??i.feature,children:o(l,{className:"h-2.5 w-2.5"})},i.feature):null}),n&&Oo(o(u3,{resolved:e,position:n}),document.body)]})}function u3({resolved:e,position:t}){return u("div",{style:{position:"fixed",top:t.top,left:t.left,width:Mg,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(p3,{entry:n},n.feature))})]})}function p3({entry:e}){const t=yg[e.feature],n=vg[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(f3,{kind:e.kind})]})}function f3({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 Eg({device:e,variant:t,flags:n,parent:r,integrationIcon:s,hasChildren:a,expanded:i,onToggleExpand:l,onNavigateToParent:c}){const d=xg(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(lr,{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:KC(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(vl,{className:"h-2.5 w-2.5 shrink-0"}),u("span",{className:"truncate",children:["Under: ",r.name]})]})]})]})}function Bc(e,t){return bg(e,t,r=>r.battery)??null}function zc(e,t){const n=St(e,t),r=ne(!1),{data:s,isLoading:a,isFetching:i,refetch:l}=Pn({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 h3(e){return e<=10?Pk:e<=30?Ik:e>=95?Mk:bm}function m3(e,t){return t!=="none"?"text-emerald-400":e<=10?"text-rose-400":e<=30?"text-amber-400":"text-foreground-subtle"}function Fc({status:e,variant:t="compact",className:n}){if(!e)return null;const r=h3(e.percentage),s=m3(e.percentage,e.charging),a=e.charging==="solar"?$m:e.charging==="dc"?Y5: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(xc,{className:"h-3 w-3 text-blue-300"}),t==="full"&&e.charging!=="none"&&o("span",{className:"text-foreground-subtle",children:e.charging})]})}function Ig({trpc:e,device:t,status:n,enabled:r,showStatusPills:s=!1}){const a=r&&t.online,i=zc(e,a?t.id:null),l=(t.features??[]).includes("battery-operated"),c=s&&l&&!t.disabled,d=Bc(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(Fc,{status:d}),r&&o(g3,{deviceName:t.name,snapshotUrl:i.src,status:n})]})}const mi=288,Uu=196,gi=8;function g3({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<Uu+gi&&h>p,g=m?f.bottom+gi:f.top-Uu-gi,b=f.right-mi,x=Math.max(8,Math.min(b,window.innerWidth-mi-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(zo,{className:"h-3.5 w-3.5"})}),s&&Oo(u("div",{style:{position:"fixed",top:s.top,left:s.left,width:mi,pointerEvents:"none"},className:"rounded-lg border border-border bg-surface shadow-lg shadow-black/30 z-[9999] overflow-hidden",children:[o("div",{className:"h-40 bg-background flex items-center justify-center",children:t&&!i?o("img",{src:t,alt:e,className:"h-full w-full object-cover"}):o("span",{className:"text-xs text-foreground-subtle",children:n==="offline"?"Offline — no snapshot":n==="disabled"?"Disabled":"No snapshot yet"})}),o("div",{className:"px-3 py-2",children:o("p",{className:"text-xs font-semibold text-foreground truncate",children:e})})]}),document.body)]})}function Ag({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 vo(e){const{trpc:t,device:n,parent:r,integrationIcon:s,onNavigate:a,className:i}=e,l=qC(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(Hu),g=h.filter(E=>!Hu(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),C=f?n.online?"online":"offline":"disabled";return d==="table"?o(x3,{trpc:t,device:n,variant:c,flags:l,parent:r??null,integrationIcon:s??null,accessoryCount:m.length,adoptedCount:g.length,hasChildren:b,expanded:w,onToggleExpand:v,onNavigate:N,displayStatus:C,isCamera:p,showSnapshot:l.showSnapshot&&p,isAccessoryRow:e.isAccessoryRow??!1,indentLevel:k,className:i}):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(Eg,{device:n,variant:c,flags:l,parent:r??null,integrationIcon:s??null,hasChildren:b,expanded:w,onToggleExpand:v,onNavigateToParent:N}),o(Cg,{trpc:t,device:n,flags:l,accessoryCount:m.length,adoptedCount:g.length,showFeatureRow:!1}),o(Ig,{trpc:t,device:n,status:C,enabled:l.showSnapshot&&p,showStatusPills:!0}),o(Sg,{trpc:t,device:n,flags:l}),o(Ag,{status:C})]}),w&&b&&o(WC,{trpc:t,accessoryChildren:m,adoptedChildren:g,onNavigate:N})]})}const b3={0:"pl-2",1:"pl-6",2:"pl-8"};function x3(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",b3[y]),children:o(Eg,{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(Cg,{trpc:t,device:n,flags:s,accessoryCount:l,adoptedCount:c,showFeatureRow:!0})}),o("td",{className:"px-2 py-2 align-middle",children:o(Ig,{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(Sg,{trpc:t,device:n,flags:s}),o(Ag,{status:m})]})})]})}function Pg(e,t){const[n,r]=_(e);return Y(()=>{const s=setTimeout(()=>r(e),t);return()=>clearTimeout(s)},[e,t]),n}const y3=new Set(["hub","nvr"]);function v3(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(y3.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 Qu=2;function w3(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-Qu),s=Math.min(t-1,e+Qu);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=w3(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(Vk,{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 k3({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(P5,{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(CS,{className:"h-3.5 w-3.5"})})]}),n&&n.length>0&&u(me,{children:[o(Gu,{children:"Type"}),o(bi,{active:r===null,onClick:()=>s(null),children:"All"}),n.map(d=>o(bi,{active:r===d,onClick:()=>s(r===d?null:d),children:S3(d)},d))]}),!c&&a&&a.length>0&&u(me,{children:[o(Gu,{children:"Integration"}),a.map(d=>o(bi,{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 Gu({children:e}){return o("span",{className:"text-[10px] font-medium uppercase tracking-wider text-foreground-subtle ml-1",children:e})}function bi({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(Ye,{className:"h-2.5 w-2.5 opacity-70"})]})}function S3(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function C3({variant:e,onClearFilters:t}){return u("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[o(M5,{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 qt(e,t){if(e==="root")return t;switch(t){case"view":return"deviceView";case"page":return"devicePage";case"type":return"deviceType";case"q":return"deviceQ";case"addon":return"deviceAddon"}}function Ku(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 M3(e,t){try{localStorage.setItem(`camstack:${e}:lastFilters`,JSON.stringify(t))}catch{}}function Wu(e,t,n){const r=new URLSearchParams(window.location.search),s=r.get(qt(e,"view")),a=s==="cards"||s==="table"?s:n.view??t,i=r.get(qt(e,"page")),l=i?parseInt(i,10):1,c=Number.isFinite(l)&&l>=1?l:1,d=r.get(qt(e,"addon"))??n.addon??null,f=r.get(qt(e,"type"))??n.type??null,p=r.get(qt(e,"q"))??n.q??"";return{view:a,page:c,addon:d,type:f,q:p}}function E3(e,t,n){const r=new URLSearchParams(window.location.search),s=(l,c)=>{c===null||c===""?r.delete(l):r.set(l,c)};s(qt(e,"view"),t.view===n?null:t.view),s(qt(e,"page"),t.page===1?null:String(t.page)),s(qt(e,"addon"),t.addon),s(qt(e,"type"),t.type),s(qt(e,"q"),t.q||null);const a=r.toString(),i=a?`${window.location.pathname}?${a}`:window.location.pathname;window.history.replaceState(null,"",i)}function I3(e){const{scope:t,defaultView:n,lsKey:r}=e,[s,a]=_(()=>{const g=Ku(r);return Wu(t,n,g)}),i=ne(s);i.current=s,Y(()=>{const g=()=>{const b=Ku(r),x=Wu(t,n,b);i.current=x,a(x)};return window.addEventListener("popstate",g),()=>window.removeEventListener("popstate",g)},[t,n,r]);const l=q(g=>{const b=g(i.current);i.current=b,a(b),E3(t,b,n),M3(r,{view:b.view,addon:b.addon,type:b.type,q:b.q})},[t,n,r]),c=q(g=>l(b=>({...b,view:g})),[l]),d=q(g=>l(b=>({...b,page:g})),[l]),f=q(g=>l(b=>({...b,addon:g,page:1})),[l]),p=q(g=>l(b=>({...b,type:g,page:1})),[l]),h=q(g=>l(b=>({...b,q:g,page:1})),[l]),m=q(()=>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 A3={cards:24,table:50};function wo(e){const{devices:t,trpc:n,defaultView:r="table",filters:s,forceAddon:a,resolveIntegrationIcon:i,resolveParent:l,onNavigate:c,pageSize:d=A3,urlScope:f="root",lsKey:p=f==="root"?"devices":"integrations:nested"}=e,h=I3({scope:f,defaultView:r,lsKey:p}),m=h.state.view,g=m==="cards"?d.cards:d.table,[b,x]=_(h.state.q),y=Pg(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(()=>v3(v),[v]),k=Q(()=>{if(h.state.q.trim()==="")return new Set;const R=h.state.q.toLowerCase().trim(),M=new Set;for(const[D,L]of N.accessoriesByParent.entries())L.some(T=>T.name.toLowerCase().includes(R)||T.stableId.toLowerCase().includes(R))&&M.add(D);return M},[N.accessoriesByParent,h.state.q]),C=N.topLevel.length,E=Math.max(1,Math.ceil(C/g)),P=Math.min(h.state.page,E),I=(P-1)*g,z=N.topLevel.slice(I,I+g);Y(()=>{P!==h.state.page&&h.setPage(P)},[P]),T3();const A=w!=null||h.state.type!==null||h.state.q!=="",O=C===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(k3,{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(xo,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle pointer-events-none"}),o("input",{type:"text",value:b,onChange:R=>x(R.target.value),placeholder:"Search by name or stableId","aria-label":"Search devices by name or stableId",className:"h-7 pl-7 pr-2.5 rounded-md border border-border bg-surface text-[11px] text-foreground placeholder:text-foreground-subtle/60 focus:outline-none focus:ring-1 focus:ring-primary/40 w-56"})]})]}),O?o(C3,{variant:A?"filtered":"nofilter",onClearFilters:A?h.clearFilters:void 0}):m==="cards"?o(P3,{rows:z,accessoriesByParent:N.accessoriesByParent,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:c??null}):o(D3,{rows:z,accessoriesByParent:N.accessoriesByParent,autoExpandedParents:k,devices:v,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:c??null}),o(N3,{currentPage:P,totalItems:C,pageSize:g,onPageChange:h.setPage}),a===void 0&&A&&C>0&&u("p",{className:"text-[11px] text-foreground-subtle",children:["Showing ",C," 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 P3({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(vo,{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 _3=new Set(["hub","nvr"]);function $3(e,t){return e.parentDeviceId===null||t===null?0:_3.has(t.toLowerCase())?1:0}function D3({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(L3,{parent:d,accessories:f,hasAccessories:p,forceExpanded:h,trpc:s,integrationIcon:a?.(d.addonId)??null,parentRowParent:m,indentLevel:$3(d,g),onNavigate:l??null},d.id)})})]})})}function L3({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(vo,{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(vo,{trpc:s,device:g,view:"table",integrationIcon:null,parent:null,isAccessoryRow:!0,showChildrenAccordion:!1,onNavigate:c??void 0},g.id))]})}function T3(){ke()}function R3({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(c5,{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 O3(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 B3(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 xi(e){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:!0,modelId:e.defaultModelId,children:[]}}function yi({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(t5,{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 jc({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?$=>x(H,$):void 0,inheritedEnabled:y[H]}:{}}),N=Q(()=>new Set(f),[f]),k=Q(()=>B3(e),[e]),[C,E]=_([]),P=s?JSON.stringify(t)!==JSON.stringify(r.find(H=>H.id===s)?.steps):!1;function I(H){const $=H.target.value||null;if($){const V=r.find(G=>G.id===$);if(V){const G=O3(V.steps,e);E([...G.warnings])}}else E([]);a($)}function z(){s&&l(s,t)}function A(){const H=window.prompt("Template name:");H?.trim()&&i(H.trim(),t)}function O(){if(!s)return;const H=r.find($=>$.id===s);H&&window.confirm(`Delete template "${H.name}"?`)&&c(s)}function R(H){n(t.map($=>$.addonId!==H.addonId?$:M(H)))}function M(H){const $=H.children.some(V=>V.enabled||V.children.some(G=>G.enabled));return{...H,enabled:H.enabled||$,children:H.children.map(V=>{const G=V.children.some(Z=>Z.enabled);return{...V,enabled:V.enabled||G}})}}function D(H,$){const V=xi($);n(t.map(G=>G.addonId!==H?G:{...G,children:[...G.children,V]}))}function L(H){const $=new Set;for(const V of H){$.add(V.addonId);for(const Z of V.children)$.add(Z.addonId);const G=L(V.children);for(const Z of G)$.add(Z)}return $}const T=L(t);function B(H){const $=k.get(H.addonId);if(!$)return[];const G=e.slots.find(X=>X.id===$.slot)?.parentSlot==null,Z=$.childSlots,oe=new Set(H.children.map(X=>X.addonId)),te=[];for(const X of e.slots)if(Z.includes(X.id))for(const re of X.addons){if(oe.has(re.id)||N.has(re.id))continue;const be=re.inputClasses.length===0;if(be&&!G)continue;(be||re.inputClasses.some(K=>H.outputClasses.includes(K)))&&te.push(re)}return te}function F(H){const $=h?{...H,children:H.children.filter(G=>G.enabled).map(G=>({...G,children:G.children.filter(Z=>Z.enabled)}))}:H,V=h?[]:B($);return u("div",{className:"space-y-1.5",children:[o(Ls,{step:$,schema:k.get($.addonId)??null,allSchemas:k,onChange:R,onDelete:d?void 0:G=>n(t.filter(Z=>Z.addonId!==G)),readOnly:d,...v($.addonId)}),($.children.length>0||V.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"}),$.children.map(G=>{const Z=B(G);return u("div",{className:"space-y-1.5",children:[o(Ls,{step:G,schema:k.get(G.addonId)??null,allSchemas:k,depth:1,onChange:oe=>{R({...$,children:$.children.map(te=>te.addonId===oe.addonId?oe:te)})},onDelete:d?void 0:oe=>{R({...$,children:$.children.filter(te=>te.addonId!==oe)})},readOnly:d,...v(G.addonId)}),(G.children.length>0||Z.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"}),G.children.map(oe=>o(Ls,{step:oe,schema:k.get(oe.addonId)??null,allSchemas:k,depth:2,onChange:te=>{R({...$,children:$.children.map(X=>X.addonId===G.addonId?{...X,children:X.children.map(re=>re.addonId===te.addonId?te:re)}:X)})},onDelete:d?void 0:te=>{R({...$,children:$.children.map(X=>X.addonId===G.addonId?{...X,children:X.children.filter(re=>re.addonId!==te)}:X)})},readOnly:d,...v(oe.addonId)},oe.addonId)),!d&&Z.map(oe=>o(yi,{addon:oe,onClick:()=>{const te=xi(oe);R({...$,children:$.children.map(X=>X.addonId===G.addonId?{...X,children:[...X.children,te]}:X)})}},oe.id))]})]},G.addonId)}),!d&&V.map(G=>o(yi,{addon:G,onClick:()=>D($.addonId,G)},G.id))]})]},$.addonId)}const j=e.slots.filter(H=>H.parentSlot===null).sort((H,$)=>H.priority-$.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))]})}),P&&o("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500 shrink-0"}),o("button",{onClick:z,disabled:!s||d,title:"Save",className: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(aS,{className:"h-4 w-4"})}),o("button",{onClick:A,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(a5,{className:"h-4 w-4"})}),o("button",{onClick:O,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"})})]})}),C.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(Ye,{className:"h-3.5 w-3.5"})})]}),C.map((H,$)=>u("div",{children:["• ",H]},$))]}),j.map(H=>{const $=t.filter(te=>te.slot===H.id&&!N.has(te.addonId)),V=h?$.filter(te=>te.enabled):$,G=h?[]:H.addons.filter(te=>!T.has(te.id)&&!N.has(te.id)),Z=new Map,oe=[];for(const te of V)te.group?(Z.has(te.group)||Z.set(te.group,[]),Z.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=>F(te)),[...Z.entries()].map(([te,X])=>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}),X.map(re=>F(re))]},te)),!d&&G.map(te=>o(yi,{addon:te,onClick:()=>{n([...t,xi(te)])}},te.id))]},H.id)})]})}const ro={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"},Yu=["#ef4444","#8b5cf6","#06b6d4","#f97316","#10b981","#6366f1","#e11d48","#0891b2","#7c3aed","#059669"],_g="#f59e42";function dt(e,t){if(t?.[e])return t[e];if(t?.[e.toLowerCase()])return t[e.toLowerCase()];if(ro[e])return ro[e];if(ro[e.toLowerCase()])return ro[e.toLowerCase()];let n=0;for(let r=0;r<e.length;r++)n=n*31+(e.codePointAt(r)??0)>>>0;return Yu[n%Yu.length]??_g}function z3({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 dt(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=H3(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(F3,{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(Zu,{detection:y,imageWidth:t,imageHeight:n,color:p(y.macroClass),showConfidence:c,borderWidth:y.debug?.mask?1:f,children:w.map(v=>o(j3,{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(Zu,{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 Zu({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:dt(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 F3({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 j3({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:dt(c.label)},children:[c.label," ",(c.score*100).toFixed(0),"%"]},`${e.id}-lbl-${d}`))]})})}function H3(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 V3({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(Xu,{detection:f,children_:c.get(f.id)??[],colors:a,hiddenKeys:r,onToggleVisibility:s},f.id)),d.map(f=>o(Xu,{detection:f,children_:[],colors:a,hiddenKeys:r,onToggleVisibility:s},f.id))]})]})}function Xu({detection:e,children_:t,colors:n,hiddenKeys:r,onToggleVisibility:s}){const a=dt(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(Q3,{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:dt(p.label,n)+"20",color:dt(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(U3,{alternateLabels:f,colors:n}),t.length>0&&o(q3,{items:t,colors:n,hiddenKeys:r,onToggleVisibility:s})]})}function q3({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=dt(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:dt(f.label,t)+"20",color:dt(f.label,t)},children:[f.label," ",u("span",{className:"opacity-60",children:[(f.score*100).toFixed(0),"%"]})]},p))})]},s.id)})})}function U3({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:dt(a,t)+"10",color:dt(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 Q3({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 G3({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 K3({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 as="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 W3({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:as,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:as,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:as,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:as,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 Y3({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 Z3({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 X3({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 $g({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(Z3,{className:"h-4 w-4"}):o(Y3,{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(X3,{className:"h-4 w-4 animate-spin"}),p?"Logging in...":"Log in"]})]})]})})}const Ml="camstack_dev_token",Dg=Be(null);function J3(){const e=ve(Dg);if(!e)throw new Error("useDevShell must be used within a DevShell");return e}function eM(){return typeof window>"u"?null:localStorage.getItem(Ml)}function tM({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 nM({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 rM({children:e,serverUrl:t,title:n,token:r,onLogout:s}){const a=Br(),i=Q(()=>{const h=t.replace(/^http/,"ws")+"/trpc",m=AN({url:h,connectionParams:()=>({token:r})});return[PN({condition:g=>g.type==="subscription",true:_N({client:m,transformer:hl}),false:zh({url:`${t}/trpc`,transformer:hl,headers:()=>({authorization:`Bearer ${r}`})})})]},[t,r]),l=Q(()=>Bh({links:i}),[i]),c=Q(()=>S.createClient({links:i}),[i]),d=Q(()=>jh({serverUrl:t,token:r}),[t,r]);Y(()=>(d.init().catch(()=>{}),()=>{d.close()}),[d]);const f=Q(()=>new Th,[]),p=Q(()=>({trpc:l,token:r,logout:s}),[l,r,s]);return o(Tc,{system:d,children:o(S.Provider,{client:c,queryClient:f,children:o(Rh,{client:f,children:o(Dg.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(tM,{className:"h-3.5 w-3.5"}):o(nM,{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 Lg({children:e,serverUrl:t="https://localhost:4443",title:n}){const[r,s]=_(eM),a=q(async(l,c)=>{const p=await Bh({links:[zh({url:`${t}/trpc`,transformer:hl})]}).auth.login.mutate({username:l,password:c});if(!p.token)throw new Error("No token returned");localStorage.setItem(Ml,p.token),s(p.token)},[t]),i=q(()=>{localStorage.removeItem(Ml),s(null)},[]);return r?o(Us,{children:o(rM,{serverUrl:t,title:n,token:r,onLogout:i,children:e})}):o(Us,{children:o($g,{onLogin:a,serverUrl:t})})}function oM(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}Dh(a).render(Ee(Lg,{serverUrl:n,title:r,children:({trpc:i,theme:l})=>Ee(e,{trpc:i,theme:{isDark:l.resolvedMode==="dark"},navigate:c=>{console.log("[dev] navigate:",c)}})}))}const Tg=mn("camstack:custom-field-renderers",{});function Rg({renderers:e,children:t}){return o(Tg.Provider,{value:e,children:t})}function Og(e){return ve(Tg)[e]??null}const Hc=mn("camstack:device-context",null);function Bg({deviceId:e,device:t,children:n}){const r={deviceId:e,device:t??null};return o(Hc.Provider,{value:r,children:n})}function gn(){return ve(Hc)?.deviceId??null}function Vc(){return ve(Hc)?.device??null}const sM=S.accessories.getStatus.useQuery,Ea=S.addonPages.listPages.useQuery,Ho=S.addons.list.useQuery,aM=S.addons.getLogs.useQuery,iM=S.addons.listPackages.useQuery,qc=S.addons.installPackage.useMutation,lM=S.addons.installFromWorkspace.useMutation,cM=S.addons.isWorkspaceAvailable.useQuery,dM=S.addons.listWorkspacePackages.useQuery,zg=S.addons.uninstallPackage.useMutation,Fg=S.addons.reloadPackages.useMutation,jg=S.addons.searchAvailable.useQuery,Uc=S.addons.listUpdates.useQuery,El=S.addons.updatePackage.useMutation,uM=S.addons.rollbackPackage.useMutation,Hg=S.addons.forceRefresh.useMutation,Vg=S.addons.restartServer.useMutation,qg=S.addons.getVersions.useQuery,Ia=S.addons.restartAddon.useMutation,Ug=S.addons.retryLoad.useMutation,Qg=S.addons.getAutoUpdateSettings.useQuery,pM=S.addons.setAutoUpdateSettings.useMutation,Gg=S.addons.getAddonAutoUpdate.useQuery,Kg=S.addons.setAddonAutoUpdate.useMutation,Wg=S.addons.applyAutoUpdateToAll.useMutation,fM=S.addons.custom.useMutation,hM=S.addons.onAddonLogs.useSubscription,Qc=S.addonSettings.getGlobalSettings.useQuery,Yg=S.addonSettings.updateGlobalSettings.useMutation,mM=S.addonSettings.getDeviceSettings.useQuery,Zg=S.addonSettings.updateDeviceSettings.useMutation,Xg=S.addonWidgets.listWidgets.useQuery,gM=S.alerts.emit.useMutation,bM=S.alerts.update.useMutation,Jg=S.alerts.list.useQuery,eb=S.alerts.getUnreadCount.useQuery,tb=S.alerts.markRead.useMutation,nb=S.alerts.markAllRead.useMutation,rb=S.alerts.dismiss.useMutation,xM=S.audioAnalysis.resolveDeviceSettings.useQuery,yM=S.audioAnalysis.getDeviceSettingsContribution.useQuery,vM=S.audioAnalysis.getDeviceLiveContribution.useQuery,wM=S.audioAnalysis.applyDeviceSettingsPatch.useMutation,NM=S.audioAnalyzer.analyseChunk.useMutation,kM=S.audioAnalyzer.classify.useQuery,SM=S.audioAnalyzer.isReady.useQuery,CM=S.audioAnalyzer.dispose.useMutation,ob=S.audioAnalyzer.reprobeAudioEngine.useMutation,MM=S.audioCodec.listSupportedCodecs.useQuery,EM=S.audioCodec.canHandle.useQuery,IM=S.audioCodec.createDecodeSession.useMutation,AM=S.audioCodec.createEncodeSession.useMutation,PM=S.audioCodec.closeSession.useMutation,_M=S.audioCodec.pushEncodedFrame.useMutation,$M=S.audioCodec.pullPcm.useQuery,DM=S.audioCodec.pushPcm.useMutation,LM=S.audioCodec.pullEncoded.useQuery,TM=S.audioCodec.flushEncode.useMutation,RM=S.audioCodec.listActiveSessions.useQuery,OM=S.audioMetrics.getCurrentSnapshot.useQuery,BM=S.audioMetrics.getHistory.useQuery,Gc=S.authentication.listProviders.useQuery,zM=S.authentication.setProviderEnabled.useMutation,Kc=S.backup.listDestinations.useQuery,sb=S.backup.trigger.useMutation,FM=S.backup.list.useQuery,ab=S.backup.listLocations.useQuery,ib=S.backup.getEntries.useQuery,lb=S.backup.restore.useMutation,cb=S.backup.delete.useMutation,Wc=S.backup.listArchives.useQuery,db=S.backup.upsertDestinationPolicy.useMutation,ub=S.backup.previewSchedule.useQuery,jM=S.battery.getStatus.useQuery,HM=S.brightness.setBrightness.useMutation,VM=S.brightness.getStatus.useQuery,qM=S.cameraCredentials.getCredentials.useQuery,UM=S.cameraCredentials.getStatus.useQuery,QM=S.cameraStreams.getCameraStreams.useQuery,GM=S.cameraStreams.getBrokerStreams.useQuery,pb=S.cameraStreams.getRtspEntries.useQuery,KM=S.decoder.supportsCodec.useQuery,WM=S.decoder.getInfo.useQuery,YM=S.decoder.createSession.useQuery,ZM=S.decoder.destroySession.useQuery,XM=S.decoder.pushPacket.useQuery,JM=S.decoder.openStream.useQuery,e4=S.decoder.pullFrames.useQuery,t4=S.decoder.updateConfig.useQuery,n4=S.decoder.getStats.useQuery,r4=S.decoder.listActiveSessions.useQuery,fb=S.decoder.reprobeHwaccel.useMutation,o4=S.detectionPipeline.getDeviceSettingsContribution.useQuery,s4=S.detectionPipeline.getDeviceLiveContribution.useQuery,a4=S.detectionPipeline.applyDeviceSettingsPatch.useMutation,hb=S.deviceDiscovery.listDiscovered.useQuery,mb=S.deviceDiscovery.refreshDiscovery.useMutation,i4=S.deviceDiscovery.adoptDevice.useMutation,l4=S.deviceDiscovery.releaseDevice.useMutation,c4=S.deviceDiscovery.getStatus.useQuery,gb=S.deviceExport.getStatus.useQuery,d4=S.deviceExport.listSupportedDeviceKinds.useQuery,u4=S.deviceExport.listExposedDevices.useQuery,p4=S.deviceExport.exposeDevice.useMutation,f4=S.deviceExport.unexposeDevice.useMutation,h4=S.deviceExport.getDeviceSettingsContribution.useQuery,m4=S.deviceExport.getDeviceLiveContribution.useQuery,g4=S.deviceExport.applyDeviceSettingsPatch.useMutation,b4=S.deviceManager.allocateDeviceId.useMutation,x4=S.deviceManager.registerDevice.useMutation,y4=S.deviceManager.removeDevice.useMutation,v4=S.deviceManager.persistConfig.useMutation,w4=S.deviceManager.loadConfig.useQuery,N4=S.deviceManager.loadRuntimeState.useQuery,k4=S.deviceManager.loadMeta.useQuery,bb=S.deviceManager.setName.useMutation,xb=S.deviceManager.setLocation.useMutation,S4=S.deviceManager.setMetadata.useMutation,yb=S.deviceManager.listLocations.useQuery,C4=S.deviceManager.addLocation.useMutation,M4=S.deviceManager.removeLocation.useMutation,E4=S.deviceManager.setDisabled.useMutation,I4=S.deviceManager.listPersistedByAddon.useQuery,Ln=S.deviceManager.listAll.useQuery,Yn=S.deviceManager.getDevice.useQuery,vb=S.deviceManager.getChildren.useQuery,A4=S.deviceManager.getStreamSources.useQuery,P4=S.deviceManager.getConfigSchema.useQuery,_4=S.deviceManager.getSettingsSchema.useQuery,$4=S.deviceManager.updateConfig.useMutation,wb=S.deviceManager.enable.useMutation,Nb=S.deviceManager.disable.useMutation,kb=S.deviceManager.remove.useMutation,D4=S.deviceManager.getStreamProfileMap.useQuery,L4=S.deviceManager.setStreamProfileMap.useMutation,T4=S.deviceManager.probeStreams.useMutation,Sb=S.deviceManager.getBindings.useQuery,R4=S.deviceManager.getAllBindings.useQuery,Cb=S.deviceManager.setWrapperActive.useMutation,O4=S.deviceManager.listWrappersForCap.useQuery,Mb=S.deviceManager.listBindableCapsForDeviceType.useQuery,B4=S.deviceManager.getDeviceSettingsAggregate.useQuery,z4=S.deviceManager.getDeviceLiveInfoAggregate.useQuery,Yc=S.deviceManager.getDeviceAggregate.useQuery,F4=S.deviceManager.updateDeviceField.useMutation,Eb=S.deviceManager.updateDeviceFieldsBatch.useMutation,Zc=S.deviceManager.discoverDevices.useMutation,Ib=S.deviceManager.adoptDevice.useMutation,Ab=S.deviceManager.getCreationSchema.useQuery,Pb=S.deviceManager.createDevice.useMutation,Xc=S.deviceManager.testCreationField.useMutation,j4=S.deviceManager.testField.useMutation,H4=S.deviceManager.getDeviceStatusAggregate.useQuery,V4=S.deviceOps.getStreamSources.useQuery,q4=S.deviceOps.getConfigEntries.useQuery,U4=S.deviceOps.setConfig.useMutation,Q4=S.deviceOps.removeDevice.useMutation,G4=S.deviceOps.getSettingsSchema.useQuery,K4=S.deviceProvider.start.useMutation,W4=S.deviceProvider.stop.useMutation,Y4=S.deviceProvider.getStatus.useQuery,Z4=S.deviceProvider.getDevices.useQuery,X4=S.deviceProvider.supportsDiscovery.useQuery,J4=S.deviceProvider.discoverDevices.useMutation,eE=S.deviceProvider.adoptDiscoveredDevice.useMutation,tE=S.deviceProvider.supportsManualCreation.useQuery,nE=S.deviceProvider.getChildCreationSchema.useQuery,rE=S.deviceProvider.createDevice.useMutation,oE=S.deviceProvider.testCreationField.useMutation,sE=S.deviceState.getSnapshot.useQuery,aE=S.deviceState.getCapSlice.useQuery,iE=S.deviceState.getAllSnapshots.useQuery,lE=S.deviceState.setCapSlice.useMutation,cE=S.deviceStatus.getStatus.useQuery,dE=S.doorbell.getStatus.useQuery,uE=S.events.getEvents.useQuery,pE=S.events.getEventThumbnail.useQuery,fE=S.events.getEventClipUrl.useQuery,hE=S.featureProbe.getStatus.useQuery,Jc=S.integrations.list.useQuery,_b=S.integrations.get.useQuery,$b=S.integrations.getByAddonId.useQuery,Db=S.integrations.create.useMutation,Lb=S.integrations.update.useMutation,Tb=S.integrations.delete.useMutation,mE=S.integrations.getSettings.useQuery,gE=S.integrations.setSettings.useMutation,Rb=S.integrations.getAvailableTypes.useQuery,Ob=S.integrations.testConnection.useMutation,Bb=S.intercom.startSession.useMutation,zb=S.intercom.handleAnswer.useMutation,Fb=S.intercom.stopSession.useMutation,bE=S.intercom.startTalkSession.useMutation,xE=S.intercom.pushTalkPcm.useMutation,yE=S.intercom.endTalkSession.useMutation,vE=S.intercom.getStatus.useQuery,jb=S.localNetwork.list.useQuery,wE=S.localNetwork.getPreferred.useQuery,Hb=S.localNetwork.getConnectionEndpoints.useQuery,Vb=S.localNetwork.getAllowedAddresses.useQuery,qb=S.localNetwork.setAllowedAddresses.useMutation,Ub=S.localNetwork.resetAllowlistToBestMatch.useMutation,NE=S.meshNetwork.getStatus.useQuery,kE=S.meshNetwork.join.useMutation,SE=S.meshNetwork.startLogin.useMutation,CE=S.meshNetwork.leave.useMutation,ME=S.meshNetwork.logout.useMutation,EE=S.meshNetwork.listPeers.useQuery,IE=S.meshNetwork.testConnection.useMutation,Qb=S.meshOrchestrator.listProviders.useQuery,AE=S.meshOrchestrator.joinProvider.useMutation,Gb=S.meshOrchestrator.leaveProvider.useMutation,Kb=S.meshOrchestrator.startLoginProvider.useMutation,Wb=S.meshOrchestrator.logoutProvider.useMutation,Yb=S.meshOrchestrator.listProviderPeers.useQuery,PE=S.metricsProvider.collectSnapshot.useQuery,_E=S.metricsProvider.getCached.useQuery,$E=S.metricsProvider.getCurrent.useQuery,DE=S.metricsProvider.getDiskSpace.useQuery,LE=S.metricsProvider.getGpuInfo.useQuery,TE=S.metricsProvider.getCpuTemperature.useQuery,RE=S.metricsProvider.getProcessStats.useQuery,OE=S.metricsProvider.listAddonInstances.useQuery,BE=S.metricsProvider.getAddonStats.useQuery,Zb=S.metricsProvider.listNodeProcesses.useQuery,Xb=S.metricsProvider.killProcess.useMutation,zE=S.motion.isDetected.useQuery,FE=S.motion.getStatus.useQuery,jE=S.motionDetection.analyze.useMutation,HE=S.motionDetection.removeCamera.useMutation,VE=S.motionDetection.reset.useMutation,qE=S.motionDetection.getDeviceSettingsContribution.useQuery,UE=S.motionDetection.getDeviceLiveContribution.useQuery,QE=S.motionDetection.applyDeviceSettingsPatch.useMutation,GE=S.motionTrigger.setMotionTrigger.useMutation,KE=S.motionTrigger.getStatus.useQuery,WE=S.mqttBroker.listBrokers.useQuery,YE=S.mqttBroker.getBrokerConfig.useQuery,ZE=S.mqttBroker.addBroker.useMutation,XE=S.mqttBroker.removeBroker.useMutation,JE=S.mqttBroker.testConnection.useMutation,eI=S.mqttBroker.startEmbeddedBroker.useMutation,tI=S.mqttBroker.stopEmbeddedBroker.useMutation,Jb=S.mqttBroker.getStatus.useQuery,nI=S.nativeObjectDetection.getStatus.useQuery,ed=S.networkQuality.getDeviceStats.useQuery,rI=S.networkQuality.getAllStats.useQuery,oI=S.networkQuality.reportClientStats.useMutation,Tn=S.nodes.topology.useQuery,sI=S.nodes.deployAddon.useMutation,ex=S.nodes.undeployAddon.useMutation,Aa=S.nodes.restartAddon.useMutation,tx=S.nodes.restartProcess.useMutation,nx=S.nodes.restartNode.useMutation,aI=S.nodes.shutdownNode.useMutation,rx=S.nodes.renameNode.useMutation,ox=S.nodes.clusterAddonStatus.useQuery,sx=S.nodes.getNodeAddons.useQuery,ax=S.nodes.setProcessLogLevel.useMutation,iI=S.nodes.executeQuery.useMutation,lI=S.notificationOutput.send.useMutation,cI=S.notificationOutput.sendTest.useMutation,dI=S.osd.setOverlay.useMutation,uI=S.osd.getStatus.useQuery,pI=S.pipelineAnalytics.getActiveTracks.useQuery,fI=S.pipelineAnalytics.getTrack.useQuery,hI=S.pipelineAnalytics.listTracks.useQuery,mI=S.pipelineAnalytics.clearTracks.useMutation,gI=S.pipelineAnalytics.getMotionEvents.useQuery,bI=S.pipelineAnalytics.getObjectEvents.useQuery,xI=S.pipelineAnalytics.getAudioEvents.useQuery,yI=S.pipelineAnalytics.getEventMedia.useQuery,vI=S.pipelineAnalytics.getTrackMedia.useQuery,wI=S.pipelineAnalytics.getDeviceSettingsContribution.useQuery,NI=S.pipelineAnalytics.getDeviceLiveContribution.useQuery,kI=S.pipelineAnalytics.applyDeviceSettingsPatch.useMutation,ix=S.pipelineExecutor.getAvailableEngines.useQuery,lx=S.pipelineExecutor.getSelectedEngine.useQuery,SI=S.pipelineExecutor.getDefaultSteps.useQuery,cx=S.pipelineExecutor.reprobeEngine.useMutation,CI=S.pipelineExecutor.getVideoPipelineSteps.useQuery,MI=S.pipelineExecutor.setVideoPipelineSteps.useMutation,Vo=S.pipelineExecutor.getSchema.useQuery,EI=S.pipelineExecutor.getGlobalSteps.useQuery,II=S.pipelineExecutor.getGlobalPipelineConfig.useQuery,AI=S.pipelineExecutor.getOrchestratorConfigSchema.useQuery,PI=S.pipelineExecutor.listTemplates.useQuery,_I=S.pipelineExecutor.saveTemplate.useMutation,$I=S.pipelineExecutor.updateTemplate.useMutation,DI=S.pipelineExecutor.deleteTemplate.useMutation,LI=S.pipelineExecutor.getCapabilities.useQuery,TI=S.pipelineExecutor.getAddonModels.useQuery,dx=S.pipelineExecutor.downloadModel.useMutation,ux=S.pipelineExecutor.deleteModel.useMutation,RI=S.pipelineExecutor.detect.useQuery,OI=S.pipelineExecutor.runPipeline.useMutation,BI=S.pipelineExecutor.runPipelineBatch.useMutation,zI=S.pipelineExecutor.cacheFrameInPool.useMutation,FI=S.pipelineExecutor.inferCached.useMutation,jI=S.pipelineExecutor.uncacheFrame.useMutation,HI=S.pipelineExecutor.getEffectiveTuning.useQuery,px=S.pipelineExecutor.listLoadedEngines.useQuery,VI=S.pipelineExecutor.spinEngine.useMutation,fx=S.pipelineExecutor.killEngine.useMutation,qI=S.pipelineExecutor.listReferenceImages.useQuery,UI=S.pipelineExecutor.getReferenceImage.useQuery,QI=S.pipelineExecutor.getReferenceAudioFiles.useQuery,GI=S.pipelineExecutor.getReferenceAudio.useQuery,KI=S.pipelineExecutor.getAudioCapabilities.useQuery,WI=S.pipelineExecutor.runAudioTest.useMutation,YI=S.pipelineExecutor.getDetectionConfigSchema.useQuery,hx=S.pipelineOrchestrator.assignPipeline.useMutation,mx=S.pipelineOrchestrator.unassignPipeline.useMutation,gx=S.pipelineOrchestrator.rebalance.useMutation,Pa=S.pipelineOrchestrator.getPipelineAssignments.useQuery,_a=S.pipelineOrchestrator.getPipelineAssignment.useQuery,bx=S.pipelineOrchestrator.getAgentLoad.useQuery,ZI=S.pipelineOrchestrator.getGlobalMetrics.useQuery,XI=S.pipelineOrchestrator.getCameraMetrics.useQuery,xx=S.pipelineOrchestrator.getCapabilityBindings.useQuery,yx=S.pipelineOrchestrator.setCapabilityBinding.useMutation,vx=S.pipelineOrchestrator.assignDecoder.useMutation,wx=S.pipelineOrchestrator.unassignDecoder.useMutation,Nx=S.pipelineOrchestrator.getDecoderAssignments.useQuery,kx=S.pipelineOrchestrator.assignAudio.useMutation,Sx=S.pipelineOrchestrator.unassignAudio.useMutation,JI=S.pipelineOrchestrator.getAudioAssignment.useQuery,Cx=S.pipelineOrchestrator.getAudioNodeLoad.useQuery,Mx=S.pipelineOrchestrator.getAudioAssignments.useQuery,eA=S.pipelineOrchestrator.getDecoderAssignment.useQuery,td=S.pipelineOrchestrator.getAgentSettings.useQuery,Hr=S.pipelineOrchestrator.listAgentSettings.useQuery,nd=S.pipelineOrchestrator.setAgentAddonDefaults.useMutation,Ex=S.pipelineOrchestrator.removeAgentSettings.useMutation,rd=S.pipelineOrchestrator.getCameraSettings.useQuery,Ix=S.pipelineOrchestrator.setCameraStepToggle.useMutation,tA=S.pipelineOrchestrator.getCameraStepOverrides.useQuery,Ax=S.pipelineOrchestrator.setCameraStepOverride.useMutation,Px=S.pipelineOrchestrator.setCameraPipelineForAgent.useMutation,_x=S.pipelineOrchestrator.resolvePipeline.useQuery,$x=S.pipelineOrchestrator.listTemplates.useQuery,nA=S.pipelineOrchestrator.saveTemplate.useMutation,Dx=S.pipelineOrchestrator.updateTemplate.useMutation,Lx=S.pipelineOrchestrator.deleteTemplate.useMutation,rA=S.pipelineOrchestrator.getDeviceSettingsContribution.useQuery,oA=S.pipelineOrchestrator.getDeviceLiveContribution.useQuery,sA=S.pipelineOrchestrator.applyDeviceSettingsPatch.useMutation,aA=S.pipelineRunner.attachCamera.useMutation,iA=S.pipelineRunner.detachCamera.useMutation,lA=S.pipelineRunner.reportMotion.useMutation,cA=S.pipelineRunner.getLocalLoad.useQuery,dA=S.pipelineRunner.getLocalMetrics.useQuery,od=S.pipelineRunner.getCameraMetrics.useQuery,uA=S.pipelineRunner.getAllCameraMetrics.useQuery,Tx=S.pipelineRunner.getLocalCameras.useQuery,pA=S.platformProbe.getCapabilities.useQuery,fA=S.platformProbe.getHardware.useQuery,hA=S.platformProbe.resolveInferenceConfig.useQuery,mA=S.platformProbe.resolveHwAccel.useQuery,gA=S.platformProbe.getHardwareEncoders.useQuery,bA=S.platformProbe.refreshHardwareEncoders.useMutation,xA=S.ptz.move.useMutation,yA=S.ptz.continuousMove.useMutation,vA=S.ptz.stop.useMutation,wA=S.ptz.getPresets.useQuery,NA=S.ptz.goToPreset.useMutation,kA=S.ptz.goHome.useMutation,SA=S.ptz.getPosition.useQuery,CA=S.ptz.getStatus.useQuery,Rx=S.ptzAutotrack.getStatus.useQuery,Ox=S.ptzAutotrack.setEnabled.useMutation,MA=S.ptzAutotrack.getSettings.useQuery,Bx=S.ptzAutotrack.setSettings.useMutation,zx=S.reboot.reboot.useMutation,EA=S.recording.getSegments.useQuery,IA=S.recording.getPlaybackUrl.useQuery,AA=S.recording.getThumbnailAt.useQuery,PA=S.recordingEngine.getStatus.useQuery,Fx=S.recordingEngine.enable.useMutation,jx=S.recordingEngine.disable.useMutation,Hx=S.recordingEngine.getConfig.useQuery,_A=S.recordingEngine.updateConfig.useMutation,$A=S.recordingEngine.getPlaylist.useQuery,DA=S.recordingEngine.getThumbnail.useQuery,Vx=S.recordingEngine.getSegments.useQuery,LA=S.recordingEngine.getAvailability.useQuery,TA=S.recordingEngine.estimateStorage.useQuery,RA=S.recordingEngine.estimateGlobalStorage.useQuery,qx=S.recordingEngine.getStorageUsage.useQuery,OA=S.recordingEngine.setPolicy.useMutation,BA=S.recordingEngine.getPolicy.useQuery,Ux=S.recordingEngine.getPolicyStatus.useQuery,Qx=S.recordingEngine.getRetentionConfig.useQuery,zA=S.recordingEngine.updateRetentionConfig.useMutation,FA=S.recordingEngine.getMotionStats.useQuery,Gx=S.remoteAccess.listProviders.useQuery,Kx=S.remoteAccess.startProvider.useMutation,Wx=S.remoteAccess.stopProvider.useMutation,jA=S.settingsStore.get.useQuery,HA=S.settingsStore.set.useMutation,VA=S.settingsStore.query.useQuery,qA=S.settingsStore.insert.useMutation,UA=S.settingsStore.update.useMutation,QA=S.settingsStore.delete.useMutation,GA=S.settingsStore.count.useQuery,KA=S.settingsStore.isEmpty.useQuery,WA=S.settingsStore.declareCollection.useMutation,YA=S.snapshot.getSnapshot.useQuery,ZA=S.snapshot.invalidateCache.useMutation,XA=S.snapshot.getStatus.useQuery,JA=S.snapshot.getDeviceSettingsContribution.useQuery,eP=S.snapshot.getDeviceLiveContribution.useQuery,tP=S.snapshot.applyDeviceSettingsPatch.useMutation,nP=S.snapshotProvider.supportsDevice.useQuery,rP=S.snapshotProvider.getSnapshot.useQuery,oP=S.storage.resolve.useQuery,sP=S.storage.write.useMutation,aP=S.storage.read.useQuery,iP=S.storage.exists.useQuery,lP=S.storage.list.useQuery,cP=S.storage.delete.useMutation,dP=S.storage.getAvailableSpace.useQuery,uP=S.storage.beginUpload.useMutation,pP=S.storage.writeChunk.useMutation,fP=S.storage.finalizeUpload.useMutation,hP=S.storage.abortUpload.useMutation,mP=S.storage.beginDownload.useMutation,gP=S.storage.readChunk.useQuery,bP=S.storage.endDownload.useMutation,Yx=S.storage.listLocations.useQuery,xP=S.storage.getDefaultLocation.useQuery,$a=S.storage.upsertLocation.useMutation,Zx=S.storage.deleteLocation.useMutation,yP=S.storage.testLocation.useQuery,sd=S.storage.listProviders.useQuery,vP=S.storage.testConfig.useQuery,wP=S.streamBroker.publishCameraStream.useMutation,NP=S.streamBroker.retractCameraStream.useMutation,kP=S.streamBroker.assignProfile.useMutation,SP=S.streamBroker.unassignProfile.useMutation,CP=S.streamBroker.listAllCameraStreams.useQuery,MP=S.streamBroker.listAllProfileSlots.useQuery,EP=S.streamBroker.getBrokerStats.useQuery,IP=S.streamBroker.listClients.useQuery,AP=S.streamBroker.killClient.useMutation,PP=S.streamBroker.restartProfile.useMutation,_P=S.streamBroker.getStreamUrl.useQuery,$P=S.streamBroker.getStreamWithCodec.useMutation,DP=S.streamBroker.releaseStreamWithCodec.useMutation,LP=S.streamBroker.getBroker.useQuery,TP=S.streamBroker.setPreBufferDuration.useMutation,RP=S.streamBroker.getPreBufferInfo.useQuery,OP=S.streamBroker.getRtspPort.useQuery,BP=S.streamBroker.getAllRtspEntries.useQuery,zP=S.streamBroker.getRtspEntry.useQuery,Xx=S.streamBroker.regenerateRtspToken.useMutation,FP=S.streamBroker.setRtspEnabled.useMutation,jP=S.streamBroker.isRtspEnabled.useQuery,HP=S.streamBroker.getDeviceSettingsContribution.useQuery,VP=S.streamBroker.getDeviceLiveContribution.useQuery,qP=S.streamBroker.applyDeviceSettingsPatch.useMutation,UP=S.switch.setState.useMutation,QP=S.switch.getStatus.useQuery,GP=S.system.info.useQuery,KP=S.system.health.useQuery,WP=S.system.featureFlags.useQuery,YP=S.system.networkAddresses.useQuery,ZP=S.system.getRetentionConfig.useQuery,XP=S.system.setRetentionConfig.useMutation,JP=S.system.forceRetentionCleanup.useMutation,Jx=S.toast.onToast.useSubscription,ey=S.turnOrchestrator.listProviders.useQuery,ty=S.turnOrchestrator.getAllServers.useQuery,ny=S.turnOrchestrator.setProviderEnabled.useMutation,e_=S.turnProvider.getTurnServers.useQuery,ad=S.userManagement.listUsers.useQuery,ry=S.userManagement.createUser.useMutation,oy=S.userManagement.updateUser.useMutation,sy=S.userManagement.deleteUser.useMutation,id=S.userManagement.resetPassword.useMutation,ay=S.userManagement.setUserScopes.useMutation,t_=S.userManagement.validateCredentials.useMutation,iy=S.userManagement.listApiKeys.useQuery,n_=S.userManagement.createApiKey.useMutation,ly=S.userManagement.revokeApiKey.useMutation,r_=S.userManagement.validateApiKey.useMutation,cy=S.userManagement.createScopedToken.useMutation,dy=S.userManagement.revokeScopedToken.useMutation,o_=S.userManagement.validateScopedToken.useQuery,uy=S.userManagement.listScopedTokens.useQuery,s_=S.userManagement.setupTotp.useMutation,a_=S.userManagement.confirmTotp.useMutation,py=S.userManagement.disableTotp.useMutation,fy=S.userManagement.getTotpStatus.useQuery,i_=S.userManagement.verifyTotp.useMutation,l_=S.webrtcSession.listStreams.useQuery,c_=S.webrtcSession.createSession.useMutation,d_=S.webrtcSession.handleOffer.useMutation,u_=S.webrtcSession.handleAnswer.useMutation,p_=S.webrtcSession.closeSession.useMutation,f_=S.webrtcSession.hasAdaptiveBitrate.useQuery,h_=S.zoneAnalytics.getCurrentSnapshot.useQuery,m_=S.zoneAnalytics.getZoneHistory.useQuery,g_=S.zoneAnalytics.getCameraHistory.useQuery,b_=S.zoneAnalytics.getUnzonedHistory.useQuery,x_=S.zoneRules.listRules.useQuery,y_=S.zoneRules.setRules.useMutation,v_=S.zones.listZones.useQuery,w_=S.zones.addZone.useMutation,N_=S.zones.removeZone.useMutation,k_=S.zones.updateZone.useMutation,hy=mn("camstack:widget-registry",null),Ws=new Map,is=new Map,Ju=new Set;function S_(e){if(!e||typeof e!="object")return!1;const t=e.default;return t!==null&&typeof t=="object"}function C_(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 M_(e,t){const n=Ws.get(e);if(n)return n;const r=is.get(e);if(r)return r;Ju.has(e)||(mc(),Mr.registerRemotes([{name:e,entry:t,type:"module"}],{force:!1}),Ju.add(e));const s=Mr.loadRemote(`${e}/widgets`).then(a=>{if(!S_(a)){const l=C_(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 Ws.set(e,i),is.delete(e),i}).catch(a=>{throw is.delete(e),a});return is.set(e,s),s}const E_=3e4,I_=2e3;function my({children:e}){const t=ke(),n=ne(Date.now()),{data:r}=Xg(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:l=>{const c=l.state.data;return c&&c.length>0||Date.now()-n.current>=E_?!1:I_}});pt("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),Ws.has(d.remoteName)))continue;const f=d.bundleUrl;M_(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=Ws.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(hy.Provider,{value:i,children:e})}function gy(e){return Da().resolve(e)}function by(e){return Da().metadata(e)}function xy(){return Da().listAll()}function Da(){const e=yy();if(!e)throw new Error("useWidgetRegistry(): no <WidgetRegistryProvider> in tree");return e}function yy(){return A_(hy)}function A_(e){return ve(e)}function lt(e){const{widgetId:t,host:n="device-tab",config:r,deviceId:s,integrationId:a,instanceId:i,size:l,columns:c,rows:d}=e,f=gy(t),p=by(t),h=Q(()=>i??t,[i,t]);if(f===void 0&&p===void 0)return o(ls,{widgetId:t,reason:"unknown"});if(f===void 0)return o(ls,{widgetId:t,reason:"missing-export"});if(f===null)return o(P_,{});if(p){if(p.requires.deviceContext&&s===void 0)return o(ls,{widgetId:t,reason:"missing-device-context"});if(p.requires.integrationContext&&a===void 0)return o(ls,{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 P_(){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 ls({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 ur="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",La="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=Bt(e,a),c=Bt(t,a);return u("div",{className:i,children:[l!==void 0&&l!==""&&u("label",{className:La,children:[l,n&&o("span",{className:"text-danger ml-0.5",children:"*"})]}),s,c&&o("p",{className:__,children:c})]})}function $_({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:ur,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 D_({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:ur,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 L_({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:Bt(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:La+" mb-0",children:[Bt(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:ur,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 R_({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 O_({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:ur+(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(km,{className:"h-3.5 w-3.5"}):o(zo,{className:"h-3.5 w-3.5"})})]})})}function B_({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:ur+" 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(Im,{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,C=N-e.min,E=e.min+Math.round(C/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(Fo,{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 F_({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const a=Array.isArray(t)?t:[],[i,l]=_(""),c=ne(null),d=q(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(Ye,{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 vy({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const{nodes:a}=Fr(),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 wy({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const{nodes:a}=Fr(),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 j_({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:ur+" 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 H_({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=q(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(Ot,{className:"h-3 w-3 animate-spin"}):h==="ok"?o(Gk,{className:"h-3 w-3"}):h==="error"?o(ka,{className:"h-3 w-3"}):o(Lm,{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:ur+" 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 V_({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:Bt(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(pr,{field:f,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a},f.key))})]})})}function q_({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:La,children:Bt(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:Bt(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(pr,{field:h,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,onAction:i},g)})},p.id))]})]})}function U_({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 ep={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 Q_(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 G_({field:e}){const t=e.variant??"info",n=ep[t]??ep.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:Q_(e.content)}}):o("p",{className:"text-xs text-foreground-subtle leading-relaxed whitespace-pre-line",children:e.content})]})})}const tp={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 W_(e){return!Number.isFinite(e)||e<=0?"—":new Date(e).toLocaleTimeString()}function Y_({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=tp[n]??tp.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:W_(t)}):o("span",{children:String(t)})}function Z_({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(Y_,{kind:a.kind,value:r[a.key]})},a.key))},s))})]})})]})}function X_({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:Bt(e.label,s)}),e.description&&o("p",{className:"text-[11px] text-foreground-subtle",children:Bt(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(Im,{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(pr,{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(Fo,{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 J_({field:e,disabled:t,onAction:n}){const[r,s]=_(!1),a=Je(),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 Ny(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 e$({field:e,value:t,values:n,onChange:r,disabled:s,onAction:a}){const[i,l]=_(!1),[c,d]=_(null),[f,p]=_(null),h=Ny(e,n),m=Object.keys(e.paramsFromForm??{}).some(w=>h[w]===void 0),g=(e.refreshOn??Object.values(e.paramsFromForm??{})).map(w=>`${w}=${JSON.stringify(n[w])}`).join("|");Y(()=>{if(!a||m){p(null),d(null);return}let w=!1;return l(!0),d(null),a(e.action,e.key,h).then(v=>{if(w)return;const N=v;let k=[];if(Array.isArray(N))k=N;else if(N&&typeof N=="object")for(const C of Object.keys(N)){const E=N[C];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(Ot,{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],C=v[x],E=y?v[y]:void 0,P=typeof k=="string"&&k!==""?k:`row-${N}`;return u("option",{value:typeof k=="string"?k:String(k??""),children:[typeof C=="string"?C:String(C??P),E!==void 0?` (${String(E)})`:""]},P)})]})})()})}function t$({field:e,values:t,disabled:n,onAction:r}){const[s,a]=_(!1),[i,l]=_(null),c=Je(),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=Ny(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 n$({field:e}){const t=gn();return o(Ue,{label:e.label,description:e.description,required:e.required,span:e.span,children:o(lt,{widgetId:e.widgetId,host:"device-tab",config:e.widgetConfig,deviceId:t??void 0,instanceId:e.key})})}function r$(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 o$({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=r$(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(a$,{action:m,fieldKey:s,value:i,onAction:n},m.action))})]})})}function s$({name:e}){const t="h-3.5 w-3.5";switch(e){case"copy":return o(Dn,{className:t});case"refresh-cw":return o(yc,{className:t});case"external-link":return o(Nm,{className:t});case"trash-2":return o(Kt,{className:t});case"download":return o(yl,{className:t});case"upload":return o(Dm,{className:t});default:return o(vc,{className:t})}}function a$({action:e,fieldKey:t,value:n,onAction:r}){const s=Je(),[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(s$,{name:e.icon})})}function i$(e){return"multiple"in e&&e.multiple!=null}function l$({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,C)=>{const E=[...g];E[k]=C,x(E)},w=()=>{g.length>=p||x([...g,b])},v=k=>{g.length<=f||x(g.filter((C,E)=>E!==k))},N=()=>{const{multiple:k,...C}=e;return{...C,...{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,C)=>{const E=d.itemLabel?.replace("${n}",String(C+1));return u("div",{className:"space-y-1",children:[E&&o("div",{className:La,children:E}),u("div",{className:"flex items-center gap-2",children:[o("div",{className:"flex-1 min-w-0",children:o(pr,{field:N(),values:{...t,[e.key]:k},onChange:(P,I)=>y(C,I),disabled:r,translationFn:s,onTestField:a,onAction:c,allFields:l})}),g.length>f&&o("button",{type:"button",onClick:()=>v(C),disabled:r,title:"Remove",className:"flex-shrink-0 inline-flex items-center justify-center rounded-md border border-border p-1.5 text-foreground-subtle hover:text-danger hover:border-danger/50 transition-colors disabled:opacity-40",children:o(Kt,{className:"h-3.5 w-3.5"})})]})]},C)}),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(Fo,{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 ld(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 pr({field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c}){if(i$(e))return o(l$,{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(o$,{field:e,values:t,onAction:c,translationFn:s});if(!ld(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=Og(e.type);switch(e.type){case"text":return o($_,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"number":return o(D_,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"boolean":return o(L_,{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(R_,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"password":return o(O_,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"textarea":return o(B_,{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(F_,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"color":return o(j_,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"node-select":return o(vy,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"node-multiselect":return o(wy,{field:e,value:f,onChange:p,disabled:r,translationFn:s});case"probe":return o(H_,{field:e,value:f,onChange:p,disabled:r,translationFn:s,onTestField:a,onAction:c,externalProbe:i});case"group":return o(V_,{field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a});case"sub-tabs":return o(q_,{field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,onAction:c});case"separator":return o(U_,{});case"info":return o(G_,{field:e});case"object-array":return o(Z_,{field:e});case"editable-array":return o(X_,{field:e,value:f,onChange:p,disabled:r,translationFn:s,onTestField:a,onAction:c});case"button":return o(J_,{field:e,disabled:r,onAction:c});case"addon-action-select":return o(e$,{field:e,value:f,values:t,onChange:p,disabled:r,onAction:c});case"addon-action-button":return o(t$,{field:e,values:t,disabled:r,onAction:c});case"widget":return o(n$,{field:e});default:return h?o(h,{field:e,value:f,onChange:p,disabled:r}):null}}function c$(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Bt(e,t){if(e!==void 0)return t&&c$(e)?t(e):e}function d$({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:Bt(e.title,s)}),e.description&&o("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:Bt(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(pr,{field:h,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i?.[h.key]},h.key))})]})}function ky({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(d$,{section:d,values:t,onChange:c,disabled:r,translationFn:s,onTestField:a,probeResults:i},d.id))})}const u$=({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 np(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 p$(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 f$({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),[C,E]=_({}),[P,I]=_(null);Y(()=>{I(null),E({})},[e,t,n,i,p]);const z=JSON.stringify(C);Y(()=>{let L=!1;b(!0),y(null);const T=p==="override"&&Object.keys(C).length>0?C:void 0;return e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n,...T?{overlay:T}:{}}).then(B=>{L||(m(B),T||I(np(B)),b(!1))}).catch(B=>{L||(y(B instanceof Error?B.message:String(B)),b(!1))}),()=>{L=!0}},[e,t,n,i,p,z]);const A=Q(()=>np(h),[h]),O=Q(()=>h?p$(h):null,[h]),R=async L=>{if(p==="override"){const B=P??A,F={};for(const H of Object.keys(L))L[H]!==B[H]&&(F[H]=L[H]);const j={...B,...F};E(F),f?.(F,j);return}const T={};for(const B of Object.keys(L))L[B]!==A[B]&&(T[B]=L[B]);if(Object.keys(T).length!==0){v(!0);try{await e.addonSettings.updateGlobalSettings.mutate({addonId:t,nodeId:n,patch:T});const B=await e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n});m(B),a?.()}catch(B){y(B instanceof Error?B.message:String(B))}finally{v(!1)}}};if(g)return 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||!O)return u("div",{className:"text-xs text-foreground-subtle",children:[r??t," not available on ",n,"."]});const M=p==="override"?{...A,...C}:A,D=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(ky,{schema:O,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(L=>!L),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover text-left","aria-expanded":N,children:[o(u$,{open:N}),o("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide flex-1",children:r??t}),o("span",{className:"text-[10px] text-foreground-subtle",children:N?"hide":"edit"})]}),N?o("div",{className:"border-t border-border px-4 py-3",children:D}):null]}):r?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:D})]}):o("div",{children:D})}function Sy({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(h$,{phase:r}),d&&o(m$,{raw:t}),c&&o(g$,{motion:e}),f&&o(b$,{detections:n.detections,frameWidth:n.frameWidth,frameHeight:n.frameHeight})]})}function h$({phase:e}){const t=ir(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 m$({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 g$({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 b$({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=dt(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 x$(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 y$=3e3,v$=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),[C,E]=_("idle"),[P,I]=_(""),[z,A]=_(s),[O,R]=_(!1),[M,D]=_(!1),L=ne(null),T=ne(!1);(p||f)&&(T.current=!0);const B=T.current,F=q(K=>{E(K),l?.(K)},[l]),j=q(()=>{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 K of y.current)h(K).catch(()=>{});y.current.clear()}g.current&&(g.current.srcObject=null)},[h]),H=q(async()=>{if(!k.current||!f||!p)return;j(),F("connecting");const K=new AbortController;w.current=K;try{const ae={...x$(b.current),...m},{sessionId:fe,sdpOffer:ge}=await f(ae);if(y.current.add(fe),!k.current||K.signal.aborted){h?.(fe).catch(()=>{}),y.current.delete(fe);return}const U=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});x.current=U;const ie=new MediaStream;U.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(()=>{}))},U.oniceconnectionstatechange=()=>{if(!k.current)return;const pe=U.iceConnectionState;console.debug("[WebRTC] ICE state:",pe),pe==="connected"||pe==="completed"?(N.current=0,F("playing"),g.current?.paused&&(console.debug("[WebRTC] video was paused at ICE connected — calling play()"),g.current.play().catch(()=>{}))):(pe==="failed"||pe==="disconnected"||pe==="closed")&&(F("disconnected"),Z())},U.onicecandidateerror=pe=>{console.debug("[WebRTC] ICE candidate error:",pe)},console.debug("[WebRTC] Setting remote description (server offer)..."),await U.setRemoteDescription({type:"offer",sdp:ge});const ue=await U.createAnswer();if(await U.setLocalDescription(ue),console.debug("[WebRTC] Local description set, waiting for ICE gathering..."),await rp(U),!k.current)return;const de=(U.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,U.localDescription?.sdp??""),console.debug("[WebRTC] Answer sent successfully");const ce=U,Ce=()=>{const pe=ce.connectionState;if(pe==="closed"||pe==="failed")return;const _e=g.current;_e&&_e.readyState===0&&console.log(`[WebRTC] no video data yet (ice=${ce.iceConnectionState})`)};setTimeout(Ce,3e3),setTimeout(Ce,8e3)}catch(ee){if(!k.current)return;const ae=ee instanceof Error?ee.message:String(ee);I(ae),F("error"),c?.(ae),Z()}},[e,t,f,p,j,F,c,m]),$=q(async()=>{if(k.current){j(),F("connecting");try{const K=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});x.current=K,K.addTransceiver("video",{direction:"recvonly"}),K.addTransceiver("audio",{direction:"recvonly"});const ee=new MediaStream;K.ontrack=ie=>{ee.addTrack(ie.track),g.current&&(g.current.srcObject=ee,g.current.play().catch(()=>{}))},K.oniceconnectionstatechange=()=>{if(!k.current)return;const ie=K.iceConnectionState;ie==="connected"||ie==="completed"?(N.current=0,F("playing"),g.current?.paused&&g.current.play().catch(()=>{})):(ie==="failed"||ie==="disconnected"||ie==="closed")&&(F("disconnected"),Z())};const ae=await K.createOffer();if(await K.setLocalDescription(ae),await rp(K),!k.current)return;const fe=`${e}/api/webrtc?src=${encodeURIComponent(t)}`,ge=await fetch(fe,{method:"POST",headers:{"Content-Type":"application/sdp"},body:K.localDescription?.sdp??""});if(!ge.ok)throw new Error(`WHEP ${ge.status}: ${ge.statusText}`);const U=await ge.text();await K.setRemoteDescription({type:"answer",sdp:U})}catch(K){if(!k.current)return;const ee=K instanceof Error?K.message:String(K);I(ee),F("error"),c?.(ee),Z()}}},[e,t,j,F,c]),V=B?H:$,G=ne(()=>{});G.current=V;const Z=q(()=>{k.current&&(N.current>=v$||(N.current+=1,v.current=setTimeout(()=>{k.current&&G.current()},y$)))},[]);Y(()=>(k.current=!0,N.current=0,r&&V(),()=>{k.current=!1,j()}),[e,t]);const oe=ne(!1);Y(()=>{!r||!B||!f||!p||oe.current||x.current||(oe.current=!0,V())},[r,B,f,p,V]);const te=()=>{N.current=0,V()},X=()=>{g.current&&(g.current.muted=!g.current.muted,A(g.current.muted))},re=async()=>{if(b.current)try{document.fullscreenElement?await document.exitFullscreen():await b.current.requestFullscreen()}catch(K){console.warn(`Fullscreen toggle failed: ${K instanceof Error?K.message:K}`)}},be=()=>{if(!g.current)return;const K=document.createElement("canvas");K.width=g.current.videoWidth||1280,K.height=g.current.videoHeight||720;const ee=K.getContext("2d");if(!ee)return;ee.drawImage(g.current,0,0);const ae=document.createElement("a");ae.download=`${t.replace(/[/:]/g,"-")}-${Date.now()}.jpg`,ae.href=K.toDataURL("image/jpeg",.92),ae.click()};Y(()=>{const K=()=>R(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",K),()=>document.removeEventListener("fullscreenchange",K)},[]);const J=()=>{D(!0),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>D(!1),3e3)};return u("div",{ref:b,className:`relative bg-black overflow-hidden group ${i}`,onMouseMove:J,onMouseEnter:J,children:[o("video",{ref:g,autoPlay:r,muted:z,playsInline:!0,className:"w-full h-full object-contain"}),n&&C==="playing"&&o("div",{className:"absolute top-2 left-2 px-2 py-0.5 rounded bg-black/60 text-[10px] text-white font-medium",children:n}),d,C==="connecting"&&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…"})]}),(C==="error"||C==="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:C==="error"?P||"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&&C==="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(vi,{onClick:X,title:z?"Unmute":"Mute",children:z?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(vi,{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(vi,{onClick:re,title:O?"Exit fullscreen":"Fullscreen",children:O?o("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:o("path",{d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):o("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:o("path",{d:"M8 3H5a2 2 0 00-2 2v3m18 0V5a2 2 0 00-2-2h-3m0 18h3a2 2 0 002-2v-3M3 16v3a2 2 0 002 2h3"})})})]})]})]})}function vi({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 rp(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 cd=mn("camstack:player-overlays-state",null),dd=mn("camstack:player-overlays-actions",null);function My({children:e}){const[t,n]=_(()=>new Map),[r,s]=_(()=>new Map),a=q(p=>{n(h=>{const m=new Map(h);return m.set(p.id,p),m})},[]),i=q(p=>{n(h=>{if(!h.has(p))return h;const m=new Map(h);return m.delete(p),m})},[]),l=q(p=>{s(h=>{const m=new Map(h);return m.set(p.id,p),m})},[]),c=q(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(cd.Provider,{value:d,children:o(dd.Provider,{value:f,children:e})})}function Ey(){const e=ve(cd);return Q(()=>e?[...e.layers.values()].sort((t,n)=>t.order-n.order):[],[e])}function Iy(){const e=ve(cd);return Q(()=>e?[...e.buttons.values()].sort((t,n)=>t.order-n.order):[],[e])}function w$(e){const t=ve(dd);Y(()=>{if(!(!t||!e))return t.setLayer(e),()=>t.removeLayer(e.id)},[t,e])}function N$(e){const t=ve(dd);Y(()=>{if(!(!t||!e))return t.setButton(e),()=>t.removeButton(e.id)},[t,e])}function k$(e){return e==="streaming"?"bg-emerald-500":e==="connecting"?"bg-amber-500":e==="error"?"bg-rose-500":"bg-zinc-500"}function S$(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 Il({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 C$({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 M$({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 E$({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 wi({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 Ay({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 I$({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 ud({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:C=!1,ptzShown:E=!1,ptzOverlay:P,onPtzToggle:I,intercomAvailable:z=!1,intercomShown:A=!1,onIntercomToggle:O,chromeless:R=!1,className:M}){const D=Iy(),[L,T]=_(g),[B,F]=_(p),[j,H]=_(h),[$,V]=_(null),[G,Z]=_(!1),oe=ne(null);Y(()=>{if(!G)return;function ce(Ce){oe.current&&!oe.current.contains(Ce.target)&&Z(!1)}return document.addEventListener("mousedown",ce),()=>document.removeEventListener("mousedown",ce)},[G]);const te=a??$??s?.[0]?.id??"",X=s?.find(ce=>ce.id===te)??s?.[0],re=X?.inputFps!=null?{status:X.status??"unknown",inputFps:X.inputFps,bitrateKbps:X.bitrateKbps??0}:null,be=ce=>{V(ce),i?.(ce),L&&b&&(T(!1),setTimeout(()=>T(!0),50))},J=Q(()=>{const ce=X?.target;if(ce)return Ce=>t(ce,Ce)},[t,X]),K=s,ee=()=>T(!0),ae=()=>T(!1),fe=d?.phase??c,ge=fe==="active",U=!!f,ie=U&&(B||j),ue=C&&E&&!!P,de=b?L:!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 ${k$((m??re).status)}`}),l&&o("span",{className:"text-xs font-medium text-foreground",children:l}),K&&K.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:K.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:[z&&u("button",{"data-testid":"stream-intercom-toggle","data-intercom-shown":A?"true":"false",onClick:O,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${A?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:A?"Close intercom":"Open intercom",children:[o(M$,{className:"h-3 w-3"}),o("span",{className:"hidden xl:inline",children:"Intercom"})]}),D.map(ce=>{const pe=ce.tone==="primary"?"bg-primary text-primary-foreground":"bg-primary/15 text-primary";return 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:ee,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${de?"bg-danger/10 text-danger hover:bg-danger/20":"bg-primary/10 text-primary hover:bg-primary/20"}`,title:de?"Stop stream":"Start stream",children:[de?o(C$,{className:"h-3 w-3"}):o(Il,{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(Ay,{className:`h-3 w-3 ${y?"animate-spin":""}`}),o("span",{className:"hidden xl:inline",children:"Snapshot"})]}),(U||C||d||fe||m||re&&re.inputFps>0)&&u("div",{ref:oe,className:"relative",children:[o("button",{onClick:()=>Z(ce=>!ce),title:"More controls",className:"inline-flex items-center justify-center rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:o(E$,{className:"h-3.5 w-3.5"})}),G&&u("div",{className:"absolute right-0 top-full mt-1 z-30 min-w-[200px] rounded-lg border border-border bg-surface shadow-xl py-1.5",children:[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:S$(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||U&&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"]})]})]}),U&&u(me,{children:[o(wi,{label:"Show detections",active:B,onClick:()=>F(ce=>!ce)}),o(wi,{label:"Show motion",active:j,onClick:()=>H(ce=>!ce)})]}),C&&o(wi,{label:"PTZ controls",active:E,onClick:()=>{I?.(),Z(!1)}})]})]})]})]}),de?o("div",{className:"aspect-video relative",children:o(Cy,{serverUrl:e,streamKey:te,autoPlay:!0,className:"w-full h-full",createSession:J,sendAnswer:n,closeSession:r,overlay:ie||k||ue?u(me,{children:[ie&&o(Sy,{detections:f,showPhaseIndicator:!1,showMotionZones:j,showMotionRaw:j,showDetections:B}),k,ue&&P]}):void 0},te)}):o(A$,{src:x??null,isLoading:y,onPlay:ee,onRetry:w,extraOverlay:k||ue?u(me,{children:[k,ue&&P]}):null,suppressPlayHover:!!k||ue}),N]})}function A$({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(Il,{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(I$,{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(Ay,{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(Il,{className:"h-3 w-3"}),"Play Live"]})]})]})})}const op={value:"auto",label:"Auto (best available)"};function P$(e){return e.charAt(0).toUpperCase()+e.slice(1)}function _$({deviceId:e,value:t,onChange:n,disabled:r,label:s,className:a}){const i=Wn(),l=pb({deviceId:e},{refetchOnWindowFocus:!1}),[c,d]=_([op]);Y(()=>{if(!l.data)return;const h=`${e}/`,m=[op];for(const g of l.data){if(!g.enabled)continue;const b=g.brokerId.startsWith(h)?g.brokerId.slice(h.length):g.brokerId;m.push({value:b,label:P$(b)})}d(m)},[l.data,e]);const f=s??"Preferred stream",p=l.isLoading?"Loading available streams…":l.isError?"Could not load streams — only Auto available.":c.length===1?"No enabled streams found — only Auto available.":null;return u("div",{className:a,children:[o("label",{id:i,className:"text-xs font-medium text-foreground-muted block mb-1",children:f}),o(yo,{"aria-labelledby":i,options:c,value:t,disabled:r,onChange:h=>n(h.target.value)}),p!==null&&o("p",{className:"text-foreground-subtle text-[10px] mt-1",children:p})]})}function $$({samples:e,sampleRate:t=16e3,height:n=96,className:r="",color:s="#3b82f6",bgColor:a="transparent"}){const i=ne(null),l=ne(null),c=q(()=>{const p=i.current,h=l.current;if(!p||!h||!e||e.length===0)return;const m=h.clientWidth;if(m===0)return;const g=window.devicePixelRatio||1;p.width=m*g,p.height=n*g,p.style.width=`${m}px`,p.style.height=`${n}px`;const b=p.getContext("2d");if(!b)return;b.scale(g,g),a!=="transparent"?(b.fillStyle=a,b.fillRect(0,0,m,n)):b.clearRect(0,0,m,n);const x=e.length/m,y=n/2;b.fillStyle=s,b.globalAlpha=.7;for(let w=0;w<m;w++){const v=Math.floor(w*x),N=Math.min(Math.floor((w+1)*x),e.length);let k=0,C=0;for(let z=v;z<N;z++){const A=e[z];A<k&&(k=A),A>C&&(C=A)}const E=y-C*y,P=y-k*y,I=Math.max(1,P-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 D$({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=q(()=>{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,C=N-k,E=p.filter(A=>A.timestamp>=C);if(E.length===0)return;const P=Math.max(1,Math.floor(y/(t*2))),I=Math.abs(c);for(const A of E){const O=A.timestamp-C,R=Math.floor(O/k*y),D=(Math.max(c,Math.min(0,A.dbfs))-c)/I,L=Math.max(1,D*r),T=A.dbfs>=l;v.fillStyle=T?i:a,v.globalAlpha=.8,v.fillRect(R,r-L,P,L)}v.globalAlpha=1;const z=r-(l-c)/I*r;v.strokeStyle=i,v.globalAlpha=.25,v.lineWidth=1,v.setLineDash([4,4]),v.beginPath(),v.moveTo(0,z),v.lineTo(y,z),v.stroke(),v.setLineDash([]),v.globalAlpha=1},[p,t,r,a,i,l,c]);Y(()=>{m()},[m]),Y(()=>{const b=new ResizeObserver(()=>m()),x=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 L$(e){return e>=.8?"bg-emerald-500":e>=.5?"bg-amber-500":e>=.3?"bg-orange-500":"bg-zinc-500"}function T$(e){return e>=.8?"text-emerald-400":e>=.5?"text-amber-400":e>=.3?"text-orange-400":"text-zinc-400"}function R$({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 ${L$(l.score)}`,style:{width:`${d}%`}})}),u("span",{className:`text-xs font-mono font-semibold w-14 text-right ${T$(l.score)}`,children:[(l.score*100).toFixed(1),"%"]})]},`${l.className}-${c}`)})})]})}function O$({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 B$={Activity:kn,Eye:zo,AlertTriangle:jo,PauseCircle:Jk,PowerOff:X5};function pd({phase:e,...t}){const n=ir(e),r=B$[n.icon];return o(r,{...t})}function Qn(e){const[t,n]=_([]),r=q(a=>{n(i=>{const l=[...i,a];return l.length>e?l.slice(-e):l})},[e]),s=q(()=>{n([])},[]);return Q(()=>({entries:t,append:r,reset:s}),[t,r,s])}function sp(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}const ap={error:{icon:ka,color:"text-red-400"},warn:{icon:jo,color:"text-amber-400"},info:{icon:I5,color:"text-blue-400"},debug:{icon:Rk,color:"text-gray-500"}},ip={debug:0,info:1,warn:2,error:3},z$=["all","debug","info","warn","error"],F$=500;function j$(e,t){return t?(ip[e]??0)>=(ip[t]??0):!0}function Xt({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),C=r,E=s,P=Q(()=>{const U={};return v&&(U.agentId=v),N&&(U.addonId=N),k!==void 0&&Number.isFinite(k)&&(U.deviceId=k),C&&(U.integrationId=C),E&&(U.requestId=E),Object.keys(U).length>0?U:void 0},[v,N,k,C,E]),I=Qn(F$),z=f??I,A=z.entries,[O,R]=_(0),[M,D]=_(!1),[L,T]=_(!1),[B,F]=_(new Set),[j,H]=_(""),$=ne(null),V=`${v??""}:${N??""}:${String(k??"")}:${C??""}:${E??""}`,G=ne(V);Y(()=>{G.current!==V&&(G.current=V,z.reset(),R(0),F(new Set))},[V,z]);const{data:Z,isLoading:oe}=S.logs.query.useQuery({...P?{tags:P}:{},limit:d},{staleTime:3e4});S.logs.subscribe.useSubscription({...P?{tags:P}:{}},{onData:U=>{z.append(U)}});const te=ne(A.length);Y(()=>{const U=$.current;if(!U){te.current=A.length;return}const ie=te.current;if(te.current=A.length,!(A.length<=ie)){if(M&&U.scrollTop<=8)U.scrollTo({top:0});else if(!M&&U.scrollTop>0){const ue=U.querySelector("tbody tr"),de=ue instanceof HTMLElement?ue.offsetHeight:24;U.scrollTop+=de*(A.length-ie)}}},[A.length,M]);const X=Q(()=>{const U=(Z??[]).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[...A].reverse()){const _e=`${pe.timestamp}|${pe.level}|${pe.scope??""}|${pe.message}`;ie.has(_e)||(ie.add(_e),ue.push(pe))}for(const pe of U){const _e=`${pe.timestamp}|${pe.level}|${pe.scope??""}|${pe.message}`;ie.has(_e)||(ie.add(_e),ue.push(pe))}const ce=(O>0?ue.filter(pe=>new Date(pe.timestamp).getTime()>O):ue).filter(pe=>j$(pe.level,y)),Ce=j.trim().toLowerCase();return Ce?ce.filter(pe=>{if(pe.message.toLowerCase().includes(Ce)||pe.scope&&pe.scope.toLowerCase().includes(Ce))return!0;if(pe.tags){for(const _e of Object.values(pe.tags))if(_e!==void 0&&String(_e).toLowerCase().includes(Ce))return!0}if(pe.meta){for(const _e of Object.values(pe.meta))if(_e!=null&&sp(_e).toLowerCase().includes(Ce))return!0}return!1}):ce},[Z,A,y,O,j]),re=q(()=>{const U=X.map(ie=>{const ue=new Date(ie.timestamp).toLocaleTimeString(),de=ie.tags?" "+Object.entries(ie.tags).filter(([,ce])=>ce).map(([ce,Ce])=>`${ce}=${Ce}`).join(" "):"";return`${ue} [${ie.level.toUpperCase()}]${ie.scope?` [${ie.scope}]`:""}${de} ${ie.message}`});navigator.clipboard.writeText(U.join(`
537
- `)).then(()=>{T(!0),setTimeout(()=>T(!1),1500)})},[X]),be=S.logs.clear.useMutation(),J=q(()=>{R(Date.now()),z.reset(),be.mutate({...P?{tags:P}:{}})},[z,be,P]),K=q(U=>{F(ie=>{const ue=new Set(ie);return ue.has(U)?ue.delete(U):ue.add(U),ue})},[]),[ee,ae]=_(null),fe=q((U,ie)=>{const ue=new Date(U.timestamp).toISOString(),de=U.tags?" "+Object.entries(U.tags).filter(([,pe])=>pe).map(([pe,_e])=>`${pe}=${_e}`).join(" "):"",ce=U.meta&&Object.keys(U.meta).length>0?` meta=${JSON.stringify(U.meta)}`:"",Ce=`${ue} [${U.level.toUpperCase()}]${U.scope?` [${U.scope}]`:""}${de} ${U.message}${ce}`;navigator.clipboard.writeText(Ce).then(()=>{ae(ie),setTimeout(()=>ae(pe=>pe===ie?null:pe),1200)})},[]),ge=q(U=>`${U.timestamp}|${U.level}|${U.scope??""}|${U.message}`,[]);return u("div",{className:W("h-full min-h-0 flex flex-col",h),onClick:U=>U.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(Ni,{label:"agent",value:v}),N&&o(Ni,{label:"addon",value:N}),k!==void 0&&o(Ni,{label:"device",value:`#${k}`}),o("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:z$.map(U=>u("button",{type:"button",onClick:()=>w(U==="all"?void 0:U),className:W("px-1.5 py-0.5 capitalize transition-colors",U==="all"&&!y||y===U?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover",U!=="all"&&"border-l border-border"),children:[U,U!=="all"?"+":""]},U))}),o(ki,{icon:gc,label:M?"Auto":"Paused",active:!M,onClick:()=>{D(U=>!U),!M&&$.current&&$.current.scrollTo({top:0,behavior:"smooth"})}}),o(ki,{icon:Dn,label:L?"Copied!":"Copy",onClick:re,disabled:X.length===0}),o(ki,{icon:Kt,label:"Clear",onClick:J}),u("div",{className:"relative",children:[o("input",{type:"text",value:j,onChange:U=>H(U.target.value),placeholder:"Search…",className:"w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"}),j&&o("button",{type:"button",onClick:()=>H(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:o(Ye,{className:"h-2.5 w-2.5"})})]}),A.length>0&&u("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",A.length," live"]})]}),p&&o("button",{type:"button",onClick:p,className:"text-foreground-subtle hover:text-foreground",children:o(Ye,{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:U=>g(U.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:U=>x(U.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:$,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(Ot,{className:"h-3.5 w-3.5 animate-spin"}),"Loading logs..."]}),!oe&&X.length===0&&o("div",{className:"py-4 text-center text-foreground-subtle",children:"No logs found"}),X.length>0&&o("table",{className:"w-full",children:o("tbody",{children:X.map(U=>{const ie=ap[U.level]??ap.info,ue=ie.icon,de=ge(U),ce=B.has(de),Ce=U.tags&&Object.keys(U.tags).length>0,pe=U.meta&&Object.keys(U.meta).length>0,_e=Ce||pe;return u("tr",{className:W("hover:bg-surface-hover/30 border-b border-border/30",_e&&"cursor-pointer"),onClick:_e?()=>K(de):void 0,children:[o("td",{className:"px-2 py-1 text-foreground-subtle whitespace-nowrap align-top w-[70px]",children:new Date(U.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:U.scope,children:U.scope?.replace(/^addon:/,"")??""}),o("td",{className:"px-2 py-1 text-foreground break-all",children:u("div",{className:"flex items-start gap-1",children:[_e&&(ce?o(lr,{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:[U.message,ce&&_e&&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(U.meta).filter(([,Ae])=>Ae!==void 0&&Ae!=="").map(([Ae,We])=>u("div",{children:[o("span",{className:"text-amber-400/80 font-medium",children:Ae}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground break-all",children:sp(We)})]},`m-${Ae}`)),Ce&&Object.entries(U.tags).filter(([,Ae])=>Ae!==void 0).map(([Ae,We])=>u("div",{children:[o("span",{className:"text-primary/70 font-medium",children:Ae}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground",children:We})]},`t-${Ae}`))]})]})]})}),o("td",{className:"px-1 py-1 align-top w-5",children:o(H$,{copied:ee===de,onCopy:()=>fe(U,de)})})]},de)})})})]})]})}function Py({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(Xt,{maxHeight:"max-h-48",...n})})}function Ni({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 H$({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(Bo,{className:"h-3 w-3"}):o(Dn,{className:"h-3 w-3"})})}function ki({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 V$(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 q$={[Ne.AddonStarted]:{icon:wl,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Started"},[Ne.AddonInstalled]:{icon:yl,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Installed"},[Ne.AddonRestarted]:{icon:yc,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Restarted"},[Ne.AddonUpdated]:{icon:Dm,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Updated"},[Ne.AddonStopped]:{icon:_u,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:ka,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Crashed"},[Ne.AddonError]:{icon:jo,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Error"},[Ne.DetectionPhaseTransition]:{icon:kn,color:"bg-violet-500/15 text-violet-400 border-violet-500/30",label:"Phase"},[Ne.DetectionResult]:{icon:lS,color:"bg-purple-500/15 text-purple-400 border-purple-500/30",label:"Detection"},[Ne.DetectionEvent]:{icon:zo,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Event"},[Ne.DetectionCameraNative]:{icon:$u,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Camera AI"},[Ne.ProviderMotion]:{icon:Du,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[Ne.MotionOnMotionChanged]:{icon:Du,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[Ne.MotionAnalysis]:{icon:kn,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion analysis"},[Ne.MotionZonesRaw]:{icon:kn,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion zones"},[Ne.ProviderDetection]:{icon:$u,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Provider Det"},[Ne.PipelineAudioInferenceResult]:{icon:Em,color:"bg-pink-500/15 text-pink-400 border-pink-500/30",label:"Audio"},[Ne.AgentOnline]:{icon:wl,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Agent Online"},[Ne.AgentOffline]:{icon:_u,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Agent Offline"},[Ne.DeviceRegistered]:{icon:yl,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:kn,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"State"}};function Al(e,t){const n=q$[e]??{icon:wl,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 xr=Object.freeze([...new Set(Object.values(Ne))].sort()),U$=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]),Q$=new Set(U$),G$=Object.freeze(xr.filter(e=>!Q$.has(e)));function Ts(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 K$(e){const t=e.category;return t===Ne.DetectionResult||t===Ne.PipelineAudioInferenceResult?Ts(t,e.data)!==null:!0}const W$=300;function fr({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??G$,[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=Qn(W$),v=f??w,N=v.entries,[k,C]=_(!0),[E,P]=_(new Set),[I,z]=_(""),[A,O]=_(!1),[R,M]=_(""),[D,L]=_(0),T=ne(null),B=ne(null),F=`${e??""}:${t??""}:${String(n??"")}:${a??""}`,j=ne(F);Y(()=>{j.current!==F&&(j.current=F,v.reset(),P(new Set),L(0))},[F,v]),Y(()=>{if(!A)return;const he=Pe=>{const Te=B.current;Te&&Pe.target instanceof Node&&!Te.contains(Pe.target)&&O(!1)};return document.addEventListener("mousedown",he),()=>{document.removeEventListener("mousedown",he)}},[A]);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]),$=Q(()=>[...b].sort(),[b]),V=Q(()=>$.join(","),[$]),G=Q(()=>{const he={...H,limit:l};return $.length>0&&$.length<xr.length&&(he.category=$),he},[H,l,V,$]),{data:Z,isLoading:oe}=S.systemEvents.getRecent.useQuery(G,{staleTime:3e4}),te=ne(b);Y(()=>{te.current=b},[b]);const X=H;S.systemEvents.subscribe.useSubscription(X,{onData:he=>{const Pe=he;Pe?.id&&V$(Pe,e,t,n)&&te.current.has(Pe.category)&&v.append(Pe)}});const re=ne(N.length);Y(()=>{const he=T.current;if(!he){re.current=N.length;return}const Pe=re.current;if(re.current=N.length,!(N.length<=Pe)){if(k&&he.scrollTop<=8)he.scrollTo({top:0});else if(!k&&he.scrollTop>0){const Te=he.firstElementChild?.firstElementChild,Re=Te instanceof HTMLElement?Te.offsetHeight:28;he.scrollTop+=Re*(N.length-Pe)}}},[N.length,k]);const be=Q(()=>{const he=new Map;for(const Re of Z??[])he.set(Re.id,Re);for(const Re of N)he.set(Re.id,Re);let Pe=[...he.values()].filter(Re=>b.has(Re.category)).filter(K$);D>0&&(Pe=Pe.filter(Re=>new Date(Re.timestamp).getTime()>D));const Te=I.trim().toLowerCase();return Te&&(Pe=Pe.filter(Re=>{if(Re.category.toLowerCase().includes(Te)||Al(Re.category,Re.data).label.toLowerCase().includes(Te))return!0;const On=Ts(Re.category,Re.data);if(On&&On.toLowerCase().includes(Te))return!0;try{if(new Date(Re.timestamp).toLocaleTimeString().toLowerCase().includes(Te))return!0}catch{}try{if(JSON.stringify(Re.data).toLowerCase().includes(Te)||JSON.stringify(Re.source).toLowerCase().includes(Te))return!0}catch{}return!1})),Pe.sort((Re,Rn)=>new Date(Rn.timestamp).getTime()-new Date(Re.timestamp).getTime())},[Z,N,b,I,D]),J=q(he=>{P(Pe=>{const Te=new Set(Pe);return Te.has(he)?Te.delete(he):Te.add(he),Te})},[]),K=q(he=>{x(Pe=>{const Te=new Set(Pe);return Te.has(he)?Te.delete(he):Te.add(he),Te})},[]),ee=q(()=>{x(new Set(m)),z(""),L(0)},[m]),ae=q(()=>{L(Date.now()),v.reset()},[v]),[fe,ge]=_(!1),[U,ie]=_(null),ue=q(he=>{const Pe=new Date(he.timestamp).toISOString(),Te=Ts(he.category,he.data)??"",Re=Te?` ${Te}`:"";return`${Pe} [${he.category}]${Re} data=${JSON.stringify(he.data)}`},[]),de=q(()=>{const he=be.map(ue);navigator.clipboard.writeText(he.join(`
538
- `)).then(()=>{ge(!0),setTimeout(()=>ge(!1),1500)})},[be,ue]),ce=q(he=>{navigator.clipboard.writeText(ue(he)).then(()=>{ie(he.id),setTimeout(()=>ie(Pe=>Pe===he.id?null:Pe),1200)})},[ue]),Ce=q(()=>{x(new Set(xr))},[]),pe=q(()=>{x(new Set)},[]),_e=Q(()=>{const he=R.trim().toLowerCase();return he?xr.filter(Pe=>Pe.toLowerCase().includes(he)):xr},[R]),Ae=xr.length,We=b.size,st=We===Ae,mr=st?"All":`${We}/${Ae}`;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(cs,{label:"agent",value:e}),t&&o(cs,{label:"addon",value:t}),n!==void 0&&o(cs,{label:"device",value:`#${n}`}),a&&o(cs,{label:"category",value:a}),u("button",{type:"button",onClick:()=>{C(he=>!he),!k&&T.current&&T.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(gc,{className:"h-2.5 w-2.5"}),k?"Auto":"Paused"]}),c&&u("div",{className:"relative",ref:B,children:[u("button",{type:"button",onClick:()=>O(he=>!he),className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",st?"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(Sm,{className:"h-2.5 w-2.5"}),"Filter (",mr,")"]}),A&&o(Y$,{search:R,onSearchChange:M,categories:_e,active:b,onToggle:K,onSelectAll:Ce,onSelectNone:pe,onResetDefaults:ee})]}),u("button",{type:"button",onClick:ee,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Reset filters to defaults",children:[o(Pm,{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(Dn,{className:"h-2.5 w-2.5"}),fe?"Copied!":"Copy"]}),u("div",{className:"relative",children:[o("input",{type:"text",value:I,onChange:he=>z(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:()=>z(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:o(Ye,{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(Ye,{className:"h-3.5 w-3.5"})})]}),u("div",{ref:T,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(Ot,{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 Pe=Al(he.category,he.data),Te=Pe.icon,Re=Ts(he.category,he.data),Rn=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:()=>J(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(X$,{copied:U===he.id,onCopy:()=>ce(he)}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5",children:[Rn?o(lr,{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",Pe.color),children:[o(Te,{className:"h-2.5 w-2.5"}),Pe.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}),Rn&&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(([On,Wr])=>u("div",{children:[o("span",{className:"text-primary/70",children:On}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground break-all",children:typeof Wr=="object"?JSON.stringify(Wr):String(Wr)})]},On))]})]})]},he.id)})})]})]})}function Y$({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(xo,{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(Ye,{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=Al(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 Z$({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(fr,{maxHeight:"max-h-48",...n})})}function cs({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 X$({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(Bo,{className:"h-3 w-3"}):o(Dn,{className:"h-3 w-3"})})}function _y({deviceId:e,className:t="",onOpenChild:n}){const r=S.useUtils(),s=S.deviceDiscovery.listDiscovered.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),a=S.deviceDiscovery.getStatus.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),i=S.deviceDiscovery.refreshDiscovery.useMutation({onSuccess:()=>{r.deviceDiscovery.listDiscovered.invalidate({deviceId:e}),r.deviceDiscovery.getStatus.invalidate({deviceId:e})}}),l=S.deviceDiscovery.adoptDevice.useMutation({onSuccess:()=>{r.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),c=S.deviceDiscovery.releaseDevice.useMutation({onSuccess:()=>{r.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),[d,f]=_(null),{available:p,adopted:h}=Q(()=>{const v=s.data??[],N=C=>typeof C.metadata.rtspChannel=="number"?C.metadata.rtspChannel:Number.POSITIVE_INFINITY,k=(C,E)=>{const P=N(C),I=N(E);return P!==I?P-I:C.name.localeCompare(E.name)};return{available:v.filter(C=>!C.alreadyAdopted).sort(k),adopted:v.filter(C=>C.alreadyAdopted).sort(k)}},[s.data]),m=a.data,g=m?.lastError??null,b=m?.lastDiscoveryAt??null;async function x(){await i.mutateAsync({deviceId:e}).catch(()=>{})}async function y(v){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(Ot,{className:"h-3.5 w-3.5 animate-spin"}):o(yc,{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(jo,{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(Ot,{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(lp,{title:"Available to add",count:p.length,tone:"primary",children:p.map(v=>o(cp,{child:v,busy:d===v.childNativeId,onAdopt:y,onRelease:w,onOpenChild:n},v.childNativeId))}):null,h.length>0?o(lp,{title:"Already adopted",count:h.length,tone:"muted",children:h.map(v=>o(cp,{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 lp({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 cp({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(J$,{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(Nm,{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(Ot,{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(Ot,{className:"h-3.5 w-3.5 animate-spin"}):o(Fo,{className:"h-3.5 w-3.5"}),"Add"]})]})}function J$({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(Lm,{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(xc,{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(zS,{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(xm,{className:"h-2.5 w-2.5"})," unknown"]})}}function eD(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 Si(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 tD=300,nD=Object.freeze([...new Set(ON.filter(e=>e.scope==="device").map(e=>e.name))].sort());function fd({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]=_(""),C=ne(null),E=Qn(tD),P=s??E,I=P.entries,z=ne(null),A=ne(e);Y(()=>{A.current!==e&&(A.current=e,P.reset(),b(new Set),y(0))},[e,P]);const O=Q(()=>({deviceId:e,category:Ne.DeviceStateChanged,limit:r}),[e,r]),{data:R,isLoading:M}=S.systemEvents.getRecent.useQuery(O,{staleTime:3e4}),D=ne(c);Y(()=>{D.current=c},[c]),S.systemEvents.subscribe.useSubscription({deviceId:e,category:Ne.DeviceStateChanged},{onData:U=>{if(!eD(U,e))return;const ie=Si(U);if(!ie)return;const ue=D.current;ue.size>0&&!ue.has(ie.capName)||P.append(ie)}});const L=ne(I.length);Y(()=>{const U=z.current;if(!U){L.current=I.length;return}const ie=L.current;if(L.current=I.length,!(I.length<=ie)){if(h&&U.scrollTop<=8)U.scrollTo({top:0});else if(!h&&U.scrollTop>0){const ue=U.firstElementChild?.firstElementChild,de=ue instanceof HTMLElement?ue.offsetHeight:28,ce=I.length-ie;U.scrollTop+=de*ce}}},[I.length,h]);const T=Q(()=>{const U=new Map;for(const de of R??[]){const ce=Si(de);ce&&U.set(ce.id,ce)}for(const de of I)U.set(de.id,de);let ie=[...U.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(([Ce,pe])=>`${Ce}=${Ci(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]),B=Q(()=>{const U=new Set(nD);for(const ie of R??[]){const ue=Si(ie);ue&&U.add(ue.capName)}for(const ie of I)U.add(ie.capName);return[...U].sort()},[R,I]),F=q(U=>{b(ie=>{const ue=new Set(ie);return ue.has(U)?ue.delete(U):ue.add(U),ue})},[]),j=q(U=>{d(ie=>{const ue=new Set(ie);return ue.has(U)?ue.delete(U):ue.add(U),ue})},[]),H=q(()=>{d(new Set(t??[])),p("")},[t]),$=q(()=>{y(Date.now()),P.reset()},[P]),[V,G]=_(!1),[Z,oe]=_(null),te=q(U=>`${new Date(U.timestamp).toISOString()} [${U.capName}] slice=${JSON.stringify(U.slice)}`,[]),X=q(()=>{const U=T.map(te);navigator.clipboard.writeText(U.join(`
539
- `)).then(()=>{G(!0),setTimeout(()=>G(!1),1500)})},[T,te]),re=q(U=>{navigator.clipboard.writeText(te(U)).then(()=>{oe(U.id),setTimeout(()=>oe(ie=>ie===U.id?null:ie),1200)})},[te]),be=q(()=>{d(new Set(B))},[B]),J=q(()=>{d(new Set)},[]),K=Q(()=>{const U=N.trim().toLowerCase();return U?B.filter(ie=>ie.toLowerCase().includes(U)):B},[N,B]),ee=B.length,ae=c.size,fe=ae===0||ae===ee,ge=fe?"All":`${ae}/${ee}`;return Y(()=>{if(!w)return;const U=ie=>{const ue=C.current;ue&&!ue.contains(ie.target)&&v(!1)};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[w]),u("div",{className:W("h-full min-h-0 flex flex-col",i),onClick:U=>U.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(rD,{label:"device",value:`#${e}`}),u("button",{type:"button",onClick:()=>{m(U=>!U),!h&&z.current&&z.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(gc,{className:"h-2.5 w-2.5"}),h?"Auto":"Paused"]}),u("div",{className:"relative",ref:C,children:[u("button",{type:"button",onClick:()=>v(U=>!U),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(Sm,{className:"h-2.5 w-2.5"}),"Filter (",ge,")"]}),w&&o(oD,{search:N,onSearchChange:k,caps:K,active:c,onToggle:j,onSelectAll:be,onSelectNone:J,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(Pm,{className:"h-2.5 w-2.5"}),"Reset"]}),u("button",{type:"button",onClick:$,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Clear visible entries",children:[o(Kt,{className:"h-2.5 w-2.5"}),"Clear"]}),u("button",{type:"button",onClick:X,disabled:T.length===0,className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",V?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",T.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible state changes",children:[o(Dn,{className:"h-2.5 w-2.5"}),V?"Copied!":"Copy"]}),u("div",{className:"relative",children:[o("input",{type:"text",value:f,onChange:U=>p(U.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(Ye,{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(Ye,{className:"h-3.5 w-3.5"})})]}),u("div",{ref:z,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(Ot,{className:"h-3.5 w-3.5 animate-spin"}),"Loading state changes..."]}),!M&&T.length===0&&o("div",{className:"py-4 text-center text-foreground-subtle",children:"No state changes"}),T.length>0&&o("div",{className:"divide-y divide-border/30",children:T.map(U=>{const ie=g.has(U.id),ue=Object.entries(U.slice),de=ue.slice(0,3).map(([ce,Ce])=>`${ce}=${Ci(Ce)}`).join(" · ");return u("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>F(U.id),children:[o("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(U.timestamp).toLocaleTimeString()}),o(sD,{copied:Z===U.id,onCopy:()=>re(U)}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5",children:[ie?o(lr,{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:U.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,Ce])=>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:Ci(Ce)})]},ce))})]})]},U.id)})})]})]})}function Ci(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 rD({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 oD({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(xo,{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(Ye,{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 sD({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(Bo,{className:"h-3 w-3"}):o(Dn,{className:"h-3 w-3"})})}const Mi=500,aD=[{id:"logs",label:"Logs",icon:dS},{id:"events",label:"Events",icon:Na},{id:"state",label:"State",icon:p5}];function iD({deviceId:e,defaultEventCategories:t,defaultStateCaps:n,initialTab:r="events",className:s,maxHeight:a="max-h-96"}){const[i,l]=_(r),c=Qn(Mi),d=Qn(Mi),f=Qn(Mi),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:aD.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(Xt,{deviceId:e,maxHeight:a,showFilters:!1,liveBuffer:c}),i==="events"&&o(fr,{deviceId:e,defaultCategories:t,maxHeight:a,showCategoryFilter:!0,liveBuffer:d}),i==="state"&&o(fd,{deviceId:e,defaultCaps:n,maxHeight:a,liveBuffer:f})]})]})}function $y({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(Oe,{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(Fm,{open:h,onOpenChange:v=>!g&&m(v),children:u(Cc,{children:[u(jm,{children:[u(Vm,{className:"flex items-center gap-2",children:[o(jo,{className:"h-4 w-4 text-amber-400"}),n]}),typeof r=="string"?o(qm,{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(Hm,{children:[o(Oe,{type:"button",variant:"ghost",size:l,disabled:g,onClick:()=>m(!1),children:"Cancel"}),u(Oe,{type:"button",variant:i,size:l,disabled:g,onClick:()=>{w()},children:[g&&o(Ot,{className:"h-3.5 w-3.5 animate-spin"}),s??e]})]})]})})]})}function ds({direction:e,icon:t,disabled:n,className:r,variant:s,onMove:a,onStart:i,onStop:l}){const[c,d]=_(null),[f,p]=_(!1),h=q(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=q(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=q(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 hd({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",C=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",P=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(ds,{direction:"up",icon:Sk,variant:t,onMove:i,onStart:l,onStop:c}),o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),o(ds,{direction:"left",icon:yk,variant:t,onMove:i,onStart:l,onStop:c}),o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),o(ds,{direction:"right",icon:wk,variant:t,onMove:i,onStart:l,onStop:c}),o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),o(ds,{direction:"down",icon:bk,variant:t,onMove:i,onStart:l,onStop:c}),o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"})]}),(r||s)&&o("div",{className:P}),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(US,{className:C})}),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(GS,{className:C})})]}),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(Cm,{className:C})})]}),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(lr,{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 lD(e,t){const n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function cD({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=q(async k=>{i(!0),f(null),c(!1);try{const C=await e.snapshot.getSnapshot.query({deviceId:t,force:!0});if(!C)throw new Error("No snapshot available");const E=`data:${C.contentType};base64,${C.base64}`;if(k==="copy")try{await navigator.clipboard.writeText(E)}catch{throw new Error("Clipboard unavailable")}else{const P=C.contentType.includes("png")?"png":"jpg",I=new Date().toISOString().replace(/[:.]/g,"-");lD(`${p}-${I}.${P}`,E)}c(!0),setTimeout(()=>c(!1),1500)}catch(C){f(C instanceof Error?C.message:String(C))}finally{i(!1)}},[e,t,p]),m=r==="md"?"h-9 px-3 text-sm gap-2":"h-7 px-2.5 text-[11px] gap-1.5",[g,b]=_(null),[x,y]=_(!1),w=()=>{y(!1);const k=setTimeout(()=>{y(!0),h("copy")},600);b(k)},v=()=>{g&&(clearTimeout(g),b(null)),x||h("download")},N=()=>{g&&(clearTimeout(g),b(null))};return 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(Ot,{className:"h-3.5 w-3.5 animate-spin"}):l?o(Bo,{className:"h-3.5 w-3.5 text-success"}):o(bc,{className:"h-3.5 w-3.5"}),"Snapshot"]})}function dD(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 md({history:e,limit:t=5,latestIsFresh:n,className:r}){if(e.length===0)return null;const s=n?Dk:Na,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:dD(i.timestamp)}),o("span",{className:"text-foreground-subtle font-mono text-[10px]",children:new Date(i.timestamp).toLocaleTimeString()})]},`${i.deviceId}-${i.timestamp}`))})]})}function Dy({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(og,{open:s,onOpenChange:a,children:[o(sg,{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(wm,{className:"h-4 w-4"})}),u(ag,{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 uD=[{value:"view",label:"View",icon:zo,hint:"Read-only — queries + subscriptions"},{value:"create",label:"Create",icon:Q5,hint:"Mutations that create or update"},{value:"delete",label:"Delete",icon:Kt,hint:"Destructive ops (delete/revoke/reset/…)"}],pD=["device","system"];function fD(){return{type:"capability",target:"",access:["view"]}}function hD(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 mD(e,t,n,r){let s;switch(e){case"addon":s=n;break;case"capability":s=r;break;case"category":s=pD.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 gD(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 gd({value:e,onChange:t,clampToParent:n,emptyHint:r}){const{data:s}=Ho(),{data:a}=Ln({}),i=Q(()=>(s??[]).map(g=>({value:g.manifest.id,label:g.manifest.id})).sort((g,b)=>g.label.localeCompare(b.label)),[s]),l=Q(()=>[...BN].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:hD(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,fD()])};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=gD(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(bD,{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," —"]}),mD(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:uD.map(({value:y,label:w,icon:v,hint:N})=>{const k=g.access.includes(y),C=n!=null&&!x.includes(y)&&!k;return u("label",{title:C?`${N} — not granted by your scope`:N,className:`inline-flex items-center gap-1 rounded px-1.5 py-1 text-[10px] cursor-pointer transition-colors ${k?"bg-primary/15 text-primary font-medium":"text-foreground-subtle hover:bg-foreground-subtle/10"} ${C?"opacity-40 cursor-not-allowed":""}`,children:[o("input",{type:"checkbox",checked:k,disabled:C,onChange:E=>{const P=new Set(g.access);E.target.checked?P.add(y):P.delete(y),p(b,{access:[...P]})},className:"sr-only"}),o(v,{className:"h-3 w-3"}),w]},y)})}),o("button",{type:"button",onClick:()=>h(b),className:"rounded p-1 text-foreground-subtle hover:bg-danger/10 hover:text-danger transition-colors",title:"Remove scope",children:o(Ye,{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(Fo,{className:"h-3 w-3"}),"Add scope"]})]})}function bD({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(Ye,{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 bd(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 Ly=mn("camstack:zone-editing",null);function Ty({children:e}){const[t,n]=_(!1),[r,s]=_(null),[a,i]=_(null),[l,c]=_(null),d=q(w=>{n(w),w||(s(null),i(null),c(null))},[]),f=q(w=>{s(w)},[]),p=q(w=>{i(w)},[]),h=q(w=>{n(!0),i(null),s(w),c(null)},[]),m=q(()=>{n(!1),s(null),i(null),c(null)},[]),g=q(w=>{i(w.id),c(w)},[]),b=q(w=>{c(v=>v===null?v:{...v,...w})},[]),x=q(()=>{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(Ly.Provider,{value:y,children:e})}function xD(){return ve(Ly)}const dp=500,yD=800;function us(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 ps(e,t){return e?.id===t}function Ry(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=us(e,"detection.motion-analysis",g=>{const b=g;if(!ps(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),dp))});return()=>{m?.unsubscribe(),f.current&&clearTimeout(f.current)}},[e,t]),Y(()=>{if(t===null)return;const m=us(e,"detection.motion-zones-raw",g=>{const b=g;if(!ps(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),dp))});return()=>{m?.unsubscribe(),p.current&&clearTimeout(p.current)}},[e,t]),Y(()=>{if(t===null)return;const m=us(e,"detection.result",g=>{const b=g;if(!ps(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),yD))});return()=>{m?.unsubscribe(),h.current&&clearTimeout(h.current)}},[e,t]),Y(()=>{if(t===null)return;const m=us(e,"detection.phase-transition",g=>{const b=g;ps(b?.source,t)&&b.data?.to&&d(b.data.to)});return()=>{m?.unsubscribe()}},[e,t]),{motion:n,motionRaw:s,detection:i,phase:c}}function xd(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]),pt("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=q(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=q(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=q(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 up={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 yd(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=q(async()=>{if(!(!a||!l))try{const C=await l.getPresets({});d(C)}catch(C){const E=C instanceof Error?C.message:String(C);if(E.includes("provider not available")||E.includes("no 'ptz' binding"))return;m(E)}},[l,a]);Y(()=>{g()},[g]);const b=q(async C=>{if(!(!a||!l)){m(null),p(!0);try{return await C()}catch(E){m(E instanceof Error?E.message:String(E));return}finally{p(!1)}}},[a,l]),x=q(async(C,E)=>{if(!l)return;const P=up[C],I=E??r;await b(async()=>{await l.move({pan:P.pan,tilt:P.tilt,speed:I}),await new Promise(z=>setTimeout(z,s)),await l.stop({})})},[l,r,s,b]),y=q(async(C,E)=>{if(!l)return;const P=up[C],I=E??r;await b(()=>l.continuousMove({pan:P.pan,tilt:P.tilt,speed:I}))},[l,r,b]),w=q(async()=>{l&&await b(()=>l.stop({}))},[l,b]),v=q(async(C,E)=>{if(!l)return;const P=C==="in"?1:-1,I=E??r;await b(async()=>{await l.move({zoom:P,speed:I}),await new Promise(z=>setTimeout(z,s)),await l.stop({})})},[l,r,s,b]),N=q(async()=>{l&&await b(()=>l.goHome({}))},[l,b]),k=q(async C=>{l&&await b(()=>l.goToPreset({presetId:C}))},[l,b]);return{move:x,startContinuous:y,stopContinuous:w,zoom:v,goHome:N,goToPreset:k,presets:c,refreshPresets:g,busy:f,error:h}}function vd(e){const t=e?.deviceId??null,n=e?.historyLimit??20,r=zr("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 vD(e){const t=De(),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 wD(e){const t=De(),[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 ND(e,t,n){const r=De();return Pn({queryKey:e,queryFn:()=>t(r)(),...n})}function kD(e,t){const n=De();return qn({mutationFn:r=>e(n)(r),...t})}function SD(e,t){const n=De(),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 CD=Object.freeze(Object.defineProperty({__proto__:null,AddonGlobalSettingsForm:f$,AgentStepEditor:Ma,AppShell:OC,AudioClassificationList:R$,AudioLevelWaveform:D$,AudioWaveform:$$,BTN_COMPACT:W2,BTN_COMPACT_DANGER:Z2,BTN_COMPACT_PRIMARY:Y2,BTN_COMPACT_WARNING:X2,Badge:ln,BatteryBadge:Fc,BottomSheet:Ec,Breadcrumb:Pc,Button:Oe,CHIP_ACTIVE:tk,CHIP_BASE:ek,CHIP_INACTIVE:nk,CLASS_COLORS:ro,CameraStreamPlayer:Cy,Card:Tt,Checkbox:Om,CodeBlock:TC,CollapsibleCard:Tm,ConfigFormBuilder:ky,ConfigFormField:pr,ConfigSchemaField:Ca,ConfirmActionButton:$y,ConfirmDialogProvider:gg,CustomFieldRenderersProvider:Rg,DEFAULT_COLOR:_g,DataTable:_c,DetectionCanvas:z3,DetectionOverlay:Sy,DetectionResultTree:V3,DevShell:Lg,DeviceActivityPanel:iD,DeviceCard:zC,DeviceContextProvider:Bg,DeviceGrid:FC,DeviceItem:vo,DeviceList:wo,Dialog:Fm,DialogContent:Cc,DialogDescription:qm,DialogFooter:Hm,DialogHeader:jm,DialogTitle:Vm,DialogTrigger:tC,DiscoveryPanel:_y,DoorbellRecentPanel:md,Dropdown:Qm,DropdownContent:Km,DropdownItem:Wm,DropdownTrigger:Gm,EmptyState:Oc,EventStream:fr,FilterBar:RC,FloatingEventStream:Z$,FloatingLogStream:Py,FloatingPanel:dC,FormField:_C,GRID_GAP:fm,GRID_PAIRED:V2,GRID_QUICK_STATS:H2,INPUT_COMPACT:J2,IconButton:wc,ImageSelector:K3,InferenceConfigSelector:W3,Input:Ks,KebabMenu:Dy,KeyValueList:LC,LIST_ROW:hm,Label:Nc,LogStream:Xt,LoginForm:$g,MobileDrawer:Ac,NodeMultiSelectField:wy,NodePicker:fg,NodeSelectField:vy,PHASE_CONFIG:xl,PTZOverlay:hd,PageHeader:$C,PhaseIcon:pd,PipelineBuilder:jc,PipelineRuntimeSelector:R3,PipelineStep:Ls,PipelineTreeMatrix:Dc,PlayerOverlaysProvider:My,Popover:og,PopoverContent:ag,PopoverTrigger:sg,ProviderBadge:IC,ResponseLog:O$,SECTION_BODY:j2,SECTION_CARD:z2,SECTION_HEADER:F2,SPLIT_PANEL_OUTER:q2,SPLIT_PANEL_SIDE:U2,STACK_GAP:pm,ScopePicker:gd,ScrollArea:Ic,Select:yo,SemanticBadge:hg,Separator:kc,Sidebar:Cl,SidebarItem:Sl,Skeleton:Rm,SlideOverPanel:$c,SnapshotButton:cD,StatCard:DC,StateValuesStream:fd,StatusBadge:MC,StepTimings:G3,StepTreeMaster:dg,StreamBrokerSelector:_$,StreamPanel:ud,Switch:Sc,SystemProvider:Tc,TEXT_FIELD_LABEL:G2,TEXT_HINT:Gs,TEXT_METRIC:bl,TEXT_SECTION_LABEL:Q2,TEXT_VALUE:K2,Tabs:aC,TabsContent:cC,TabsList:iC,TabsTrigger:lC,ThemeProvider:Us,Tooltip:rC,TooltipContent:sC,TooltipTrigger:oC,VersionBadge:PC,WidgetRegistryProvider:my,WidgetSlot:lt,ZoneEditingProvider:Ty,buildStepTreeFromSchema:Sa,cn:W,createSharedContext:mn,createTheme:VN,darkColors:qh,defaultTheme:ml,deriveDeviceKind:HC,ensureMfHostInit:mc,getClassColor:dt,getPhaseVisual:ir,isFieldVisible:ld,lightColors:Uh,mirror:mm,mountAddonPage:oM,providerIcons:KS,statusIcons:WS,themeToCss:KN,trpc:S,useAccessoriesGetStatus:sM,useAddonPagesListPages:Ea,useAddonSettingsGetDeviceSettings:mM,useAddonSettingsGetGlobalSettings:Qc,useAddonSettingsUpdateDeviceSettings:Zg,useAddonSettingsUpdateGlobalSettings:Yg,useAddonWidgetsListWidgets:Xg,useAddonsApplyAutoUpdateToAll:Wg,useAddonsCustom:fM,useAddonsForceRefresh:Hg,useAddonsGetAddonAutoUpdate:Gg,useAddonsGetAutoUpdateSettings:Qg,useAddonsGetLogs:aM,useAddonsGetVersions:qg,useAddonsInstallFromWorkspace:lM,useAddonsInstallPackage:qc,useAddonsIsWorkspaceAvailable:cM,useAddonsList:Ho,useAddonsListPackages:iM,useAddonsListUpdates:Uc,useAddonsListWorkspacePackages:dM,useAddonsOnAddonLogs:hM,useAddonsReloadPackages:Fg,useAddonsRestartAddon:Ia,useAddonsRestartServer:Vg,useAddonsRetryLoad:Ug,useAddonsRollbackPackage:uM,useAddonsSearchAvailable:jg,useAddonsSetAddonAutoUpdate:Kg,useAddonsSetAutoUpdateSettings:pM,useAddonsUninstallPackage:zg,useAddonsUpdatePackage:El,useAlertsDismiss:rb,useAlertsEmit:gM,useAlertsGetUnreadCount:eb,useAlertsList:Jg,useAlertsMarkAllRead:nb,useAlertsMarkRead:tb,useAlertsUpdate:bM,useAllWidgets:xy,useAudioAnalysisApplyDeviceSettingsPatch:wM,useAudioAnalysisGetDeviceLiveContribution:vM,useAudioAnalysisGetDeviceSettingsContribution:yM,useAudioAnalysisResolveDeviceSettings:xM,useAudioAnalyzerAnalyseChunk:NM,useAudioAnalyzerClassify:kM,useAudioAnalyzerDispose:CM,useAudioAnalyzerIsReady:SM,useAudioAnalyzerReprobeAudioEngine:ob,useAudioCodecCanHandle:EM,useAudioCodecCloseSession:PM,useAudioCodecCreateDecodeSession:IM,useAudioCodecCreateEncodeSession:AM,useAudioCodecFlushEncode:TM,useAudioCodecListActiveSessions:RM,useAudioCodecListSupportedCodecs:MM,useAudioCodecPullEncoded:LM,useAudioCodecPullPcm:$M,useAudioCodecPushEncodedFrame:_M,useAudioCodecPushPcm:DM,useAudioMetricsGetCurrentSnapshot:OM,useAudioMetricsGetHistory:BM,useAuthenticationListProviders:Gc,useAuthenticationSetProviderEnabled:zM,useBackupDelete:cb,useBackupGetEntries:ib,useBackupList:FM,useBackupListArchives:Wc,useBackupListDestinations:Kc,useBackupListLocations:ab,useBackupPreviewSchedule:ub,useBackupRestore:lb,useBackupTrigger:sb,useBackupUpsertDestinationPolicy:db,useBatteryGetStatus:jM,useBrightnessGetStatus:VM,useBrightnessSetBrightness:HM,useCameraCredentialsGetCredentials:qM,useCameraCredentialsGetStatus:UM,useCameraStreamsGetBrokerStreams:GM,useCameraStreamsGetCameraStreams:QM,useCameraStreamsGetRtspEntries:pb,useClusterNodes:Fr,useConfirm:Je,useCustomFieldRenderer:Og,useDebouncedString:Pg,useDecoderCreateSession:YM,useDecoderDestroySession:ZM,useDecoderGetInfo:WM,useDecoderGetStats:n4,useDecoderListActiveSessions:r4,useDecoderOpenStream:JM,useDecoderPullFrames:e4,useDecoderPushPacket:XM,useDecoderReprobeHwaccel:fb,useDecoderSupportsCodec:KM,useDecoderUpdateConfig:t4,useDetectionPipelineApplyDeviceSettingsPatch:a4,useDetectionPipelineGetDeviceLiveContribution:s4,useDetectionPipelineGetDeviceSettingsContribution:o4,useDevShell:J3,useDevice:wD,useDeviceBattery:Bc,useDeviceCapability:jr,useDeviceDetections:Ry,useDeviceDiscoveryAdoptDevice:i4,useDeviceDiscoveryGetStatus:c4,useDeviceDiscoveryListDiscovered:hb,useDeviceDiscoveryRefreshDiscovery:mb,useDeviceDiscoveryReleaseDevice:l4,useDeviceExportApplyDeviceSettingsPatch:g4,useDeviceExportExposeDevice:p4,useDeviceExportGetDeviceLiveContribution:m4,useDeviceExportGetDeviceSettingsContribution:h4,useDeviceExportGetStatus:gb,useDeviceExportListExposedDevices:u4,useDeviceExportListSupportedDeviceKinds:d4,useDeviceExportUnexposeDevice:f4,useDeviceId:gn,useDeviceManagerAddLocation:C4,useDeviceManagerAdoptDevice:Ib,useDeviceManagerAllocateDeviceId:b4,useDeviceManagerCreateDevice:Pb,useDeviceManagerDisable:Nb,useDeviceManagerDiscoverDevices:Zc,useDeviceManagerEnable:wb,useDeviceManagerGetAllBindings:R4,useDeviceManagerGetBindings:Sb,useDeviceManagerGetChildren:vb,useDeviceManagerGetConfigSchema:P4,useDeviceManagerGetCreationSchema:Ab,useDeviceManagerGetDevice:Yn,useDeviceManagerGetDeviceAggregate:Yc,useDeviceManagerGetDeviceLiveInfoAggregate:z4,useDeviceManagerGetDeviceSettingsAggregate:B4,useDeviceManagerGetDeviceStatusAggregate:H4,useDeviceManagerGetSettingsSchema:_4,useDeviceManagerGetStreamProfileMap:D4,useDeviceManagerGetStreamSources:A4,useDeviceManagerListAll:Ln,useDeviceManagerListBindableCapsForDeviceType:Mb,useDeviceManagerListLocations:yb,useDeviceManagerListPersistedByAddon:I4,useDeviceManagerListWrappersForCap:O4,useDeviceManagerLoadConfig:w4,useDeviceManagerLoadMeta:k4,useDeviceManagerLoadRuntimeState:N4,useDeviceManagerPersistConfig:v4,useDeviceManagerProbeStreams:T4,useDeviceManagerRegisterDevice:x4,useDeviceManagerRemove:kb,useDeviceManagerRemoveDevice:y4,useDeviceManagerRemoveLocation:M4,useDeviceManagerSetDisabled:E4,useDeviceManagerSetLocation:xb,useDeviceManagerSetMetadata:S4,useDeviceManagerSetName:bb,useDeviceManagerSetStreamProfileMap:L4,useDeviceManagerSetWrapperActive:Cb,useDeviceManagerTestCreationField:Xc,useDeviceManagerTestField:j4,useDeviceManagerUpdateConfig:$4,useDeviceManagerUpdateDeviceField:F4,useDeviceManagerUpdateDeviceFieldsBatch:Eb,useDeviceOpsGetConfigEntries:q4,useDeviceOpsGetSettingsSchema:G4,useDeviceOpsGetStreamSources:V4,useDeviceOpsRemoveDevice:Q4,useDeviceOpsSetConfig:U4,useDeviceProviderAdoptDiscoveredDevice:eE,useDeviceProviderCreateDevice:rE,useDeviceProviderDiscoverDevices:J4,useDeviceProviderGetChildCreationSchema:nE,useDeviceProviderGetDevices:Z4,useDeviceProviderGetStatus:Y4,useDeviceProviderStart:K4,useDeviceProviderStop:W4,useDeviceProviderSupportsDiscovery:X4,useDeviceProviderSupportsManualCreation:tE,useDeviceProviderTestCreationField:oE,useDeviceProxy:St,useDeviceSnapshot:Vc,useDeviceSnapshotImage:zc,useDeviceState:bg,useDeviceStateGetAllSnapshots:iE,useDeviceStateGetCapSlice:aE,useDeviceStateGetSnapshot:sE,useDeviceStateSetCapSlice:lE,useDeviceStateSlice:cn,useDeviceStatusGetStatus:cE,useDeviceWebrtc:xd,useDevices:vD,useDoorbellEvents:vd,useDoorbellGetStatus:dE,useEventInvalidation:SD,useEventStreamLatest:zr,useEventStreamMap:Rc,useEventsGetEventClipUrl:fE,useEventsGetEventThumbnail:pE,useEventsGetEvents:uE,useFeatureProbeGetStatus:hE,useIntegrationsCreate:Db,useIntegrationsDelete:Tb,useIntegrationsGet:_b,useIntegrationsGetAvailableTypes:Rb,useIntegrationsGetByAddonId:$b,useIntegrationsGetSettings:mE,useIntegrationsList:Jc,useIntegrationsSetSettings:gE,useIntegrationsTestConnection:Ob,useIntegrationsUpdate:Lb,useIntercomEndTalkSession:yE,useIntercomGetStatus:vE,useIntercomHandleAnswer:zb,useIntercomPushTalkPcm:xE,useIntercomStartSession:Bb,useIntercomStartTalkSession:bE,useIntercomStopSession:Fb,useIsMidWidth:tg,useIsMobile:dr,useLiveBuffer:Qn,useLiveEvent:pt,useLocalNetworkGetAllowedAddresses:Vb,useLocalNetworkGetConnectionEndpoints:Hb,useLocalNetworkGetPreferred:wE,useLocalNetworkList:jb,useLocalNetworkResetAllowlistToBestMatch:Ub,useLocalNetworkSetAllowedAddresses:qb,useMeshNetworkGetStatus:NE,useMeshNetworkJoin:kE,useMeshNetworkLeave:CE,useMeshNetworkListPeers:EE,useMeshNetworkLogout:ME,useMeshNetworkStartLogin:SE,useMeshNetworkTestConnection:IE,useMeshOrchestratorJoinProvider:AE,useMeshOrchestratorLeaveProvider:Gb,useMeshOrchestratorListProviderPeers:Yb,useMeshOrchestratorListProviders:Qb,useMeshOrchestratorLogoutProvider:Wb,useMeshOrchestratorStartLoginProvider:Kb,useMetricsProviderCollectSnapshot:PE,useMetricsProviderGetAddonStats:BE,useMetricsProviderGetCached:_E,useMetricsProviderGetCpuTemperature:TE,useMetricsProviderGetCurrent:$E,useMetricsProviderGetDiskSpace:DE,useMetricsProviderGetGpuInfo:LE,useMetricsProviderGetProcessStats:RE,useMetricsProviderKillProcess:Xb,useMetricsProviderListAddonInstances:OE,useMetricsProviderListNodeProcesses:Zb,useMotionDetectionAnalyze:jE,useMotionDetectionApplyDeviceSettingsPatch:QE,useMotionDetectionGetDeviceLiveContribution:UE,useMotionDetectionGetDeviceSettingsContribution:qE,useMotionDetectionRemoveCamera:HE,useMotionDetectionReset:VE,useMotionGetStatus:FE,useMotionIsDetected:zE,useMotionTriggerGetStatus:KE,useMotionTriggerSetMotionTrigger:GE,useMqttBrokerAddBroker:ZE,useMqttBrokerGetBrokerConfig:YE,useMqttBrokerGetStatus:Jb,useMqttBrokerListBrokers:WE,useMqttBrokerRemoveBroker:XE,useMqttBrokerStartEmbeddedBroker:eI,useMqttBrokerStopEmbeddedBroker:tI,useMqttBrokerTestConnection:JE,useNativeObjectDetectionGetStatus:nI,useNetworkQualityGetAllStats:rI,useNetworkQualityGetDeviceStats:ed,useNetworkQualityReportClientStats:oI,useNodesClusterAddonStatus:ox,useNodesDeployAddon:sI,useNodesExecuteQuery:iI,useNodesGetNodeAddons:sx,useNodesRenameNode:rx,useNodesRestartAddon:Aa,useNodesRestartNode:nx,useNodesRestartProcess:tx,useNodesSetProcessLogLevel:ax,useNodesShutdownNode:aI,useNodesTopology:Tn,useNodesUndeployAddon:ex,useNotificationOutputSend:lI,useNotificationOutputSendTest:cI,useOptionalSystem:SC,useOptionalWidgetRegistry:yy,useOsdGetStatus:uI,useOsdSetOverlay:dI,usePTZ:yd,usePipelineAnalyticsApplyDeviceSettingsPatch:kI,usePipelineAnalyticsClearTracks:mI,usePipelineAnalyticsGetActiveTracks:pI,usePipelineAnalyticsGetAudioEvents:xI,usePipelineAnalyticsGetDeviceLiveContribution:NI,usePipelineAnalyticsGetDeviceSettingsContribution:wI,usePipelineAnalyticsGetEventMedia:yI,usePipelineAnalyticsGetMotionEvents:gI,usePipelineAnalyticsGetObjectEvents:bI,usePipelineAnalyticsGetTrack:fI,usePipelineAnalyticsGetTrackMedia:vI,usePipelineAnalyticsListTracks:hI,usePipelineExecutorCacheFrameInPool:zI,usePipelineExecutorDeleteModel:ux,usePipelineExecutorDeleteTemplate:DI,usePipelineExecutorDetect:RI,usePipelineExecutorDownloadModel:dx,usePipelineExecutorGetAddonModels:TI,usePipelineExecutorGetAudioCapabilities:KI,usePipelineExecutorGetAvailableEngines:ix,usePipelineExecutorGetCapabilities:LI,usePipelineExecutorGetDefaultSteps:SI,usePipelineExecutorGetDetectionConfigSchema:YI,usePipelineExecutorGetEffectiveTuning:HI,usePipelineExecutorGetGlobalPipelineConfig:II,usePipelineExecutorGetGlobalSteps:EI,usePipelineExecutorGetOrchestratorConfigSchema:AI,usePipelineExecutorGetReferenceAudio:GI,usePipelineExecutorGetReferenceAudioFiles:QI,usePipelineExecutorGetReferenceImage:UI,usePipelineExecutorGetSchema:Vo,usePipelineExecutorGetSelectedEngine:lx,usePipelineExecutorGetVideoPipelineSteps:CI,usePipelineExecutorInferCached:FI,usePipelineExecutorKillEngine:fx,usePipelineExecutorListLoadedEngines:px,usePipelineExecutorListReferenceImages:qI,usePipelineExecutorListTemplates:PI,usePipelineExecutorReprobeEngine:cx,usePipelineExecutorRunAudioTest:WI,usePipelineExecutorRunPipeline:OI,usePipelineExecutorRunPipelineBatch:BI,usePipelineExecutorSaveTemplate:_I,usePipelineExecutorSetVideoPipelineSteps:MI,usePipelineExecutorSpinEngine:VI,usePipelineExecutorUncacheFrame:jI,usePipelineExecutorUpdateTemplate:$I,usePipelineOrchestratorApplyDeviceSettingsPatch:sA,usePipelineOrchestratorAssignAudio:kx,usePipelineOrchestratorAssignDecoder:vx,usePipelineOrchestratorAssignPipeline:hx,usePipelineOrchestratorDeleteTemplate:Lx,usePipelineOrchestratorGetAgentLoad:bx,usePipelineOrchestratorGetAgentSettings:td,usePipelineOrchestratorGetAudioAssignment:JI,usePipelineOrchestratorGetAudioAssignments:Mx,usePipelineOrchestratorGetAudioNodeLoad:Cx,usePipelineOrchestratorGetCameraMetrics:XI,usePipelineOrchestratorGetCameraSettings:rd,usePipelineOrchestratorGetCameraStepOverrides:tA,usePipelineOrchestratorGetCapabilityBindings:xx,usePipelineOrchestratorGetDecoderAssignment:eA,usePipelineOrchestratorGetDecoderAssignments:Nx,usePipelineOrchestratorGetDeviceLiveContribution:oA,usePipelineOrchestratorGetDeviceSettingsContribution:rA,usePipelineOrchestratorGetGlobalMetrics:ZI,usePipelineOrchestratorGetPipelineAssignment:_a,usePipelineOrchestratorGetPipelineAssignments:Pa,usePipelineOrchestratorListAgentSettings:Hr,usePipelineOrchestratorListTemplates:$x,usePipelineOrchestratorRebalance:gx,usePipelineOrchestratorRemoveAgentSettings:Ex,usePipelineOrchestratorResolvePipeline:_x,usePipelineOrchestratorSaveTemplate:nA,usePipelineOrchestratorSetAgentAddonDefaults:nd,usePipelineOrchestratorSetCameraPipelineForAgent:Px,usePipelineOrchestratorSetCameraStepOverride:Ax,usePipelineOrchestratorSetCameraStepToggle:Ix,usePipelineOrchestratorSetCapabilityBinding:yx,usePipelineOrchestratorUnassignAudio:Sx,usePipelineOrchestratorUnassignDecoder:wx,usePipelineOrchestratorUnassignPipeline:mx,usePipelineOrchestratorUpdateTemplate:Dx,usePipelineRunnerAttachCamera:aA,usePipelineRunnerDetachCamera:iA,usePipelineRunnerGetAllCameraMetrics:uA,usePipelineRunnerGetCameraMetrics:od,usePipelineRunnerGetLocalCameras:Tx,usePipelineRunnerGetLocalLoad:cA,usePipelineRunnerGetLocalMetrics:dA,usePipelineRunnerReportMotion:lA,usePlatformProbeGetCapabilities:pA,usePlatformProbeGetHardware:fA,usePlatformProbeGetHardwareEncoders:gA,usePlatformProbeRefreshHardwareEncoders:bA,usePlatformProbeResolveHwAccel:mA,usePlatformProbeResolveInferenceConfig:hA,usePlayerOverlayLayer:w$,usePlayerOverlayLayers:Ey,usePlayerToolbarButton:N$,usePlayerToolbarButtons:Iy,usePtzAutotrackGetSettings:MA,usePtzAutotrackGetStatus:Rx,usePtzAutotrackSetEnabled:Ox,usePtzAutotrackSetSettings:Bx,usePtzContinuousMove:yA,usePtzGetPosition:SA,usePtzGetPresets:wA,usePtzGetStatus:CA,usePtzGoHome:kA,usePtzGoToPreset:NA,usePtzMove:xA,usePtzStop:vA,useRebootReboot:zx,useRecordingEngineDisable:jx,useRecordingEngineEnable:Fx,useRecordingEngineEstimateGlobalStorage:RA,useRecordingEngineEstimateStorage:TA,useRecordingEngineGetAvailability:LA,useRecordingEngineGetConfig:Hx,useRecordingEngineGetMotionStats:FA,useRecordingEngineGetPlaylist:$A,useRecordingEngineGetPolicy:BA,useRecordingEngineGetPolicyStatus:Ux,useRecordingEngineGetRetentionConfig:Qx,useRecordingEngineGetSegments:Vx,useRecordingEngineGetStatus:PA,useRecordingEngineGetStorageUsage:qx,useRecordingEngineGetThumbnail:DA,useRecordingEngineSetPolicy:OA,useRecordingEngineUpdateConfig:_A,useRecordingEngineUpdateRetentionConfig:zA,useRecordingGetPlaybackUrl:IA,useRecordingGetSegments:EA,useRecordingGetThumbnailAt:AA,useRemoteAccessListProviders:Gx,useRemoteAccessStartProvider:Kx,useRemoteAccessStopProvider:Wx,useSettingsStoreCount:GA,useSettingsStoreDeclareCollection:WA,useSettingsStoreDelete:QA,useSettingsStoreGet:jA,useSettingsStoreInsert:qA,useSettingsStoreIsEmpty:KA,useSettingsStoreQuery:VA,useSettingsStoreSet:HA,useSettingsStoreUpdate:UA,useSnapshotApplyDeviceSettingsPatch:tP,useSnapshotGetDeviceLiveContribution:eP,useSnapshotGetDeviceSettingsContribution:JA,useSnapshotGetSnapshot:YA,useSnapshotGetStatus:XA,useSnapshotInvalidateCache:ZA,useSnapshotProviderGetSnapshot:rP,useSnapshotProviderSupportsDevice:nP,useStorageAbortUpload:hP,useStorageBeginDownload:mP,useStorageBeginUpload:uP,useStorageDelete:cP,useStorageDeleteLocation:Zx,useStorageEndDownload:bP,useStorageExists:iP,useStorageFinalizeUpload:fP,useStorageGetAvailableSpace:dP,useStorageGetDefaultLocation:xP,useStorageList:lP,useStorageListLocations:Yx,useStorageListProviders:sd,useStorageRead:aP,useStorageReadChunk:gP,useStorageResolve:oP,useStorageTestConfig:vP,useStorageTestLocation:yP,useStorageUpsertLocation:$a,useStorageWrite:sP,useStorageWriteChunk:pP,useStreamBrokerApplyDeviceSettingsPatch:qP,useStreamBrokerAssignProfile:kP,useStreamBrokerGetAllRtspEntries:BP,useStreamBrokerGetBroker:LP,useStreamBrokerGetBrokerStats:EP,useStreamBrokerGetDeviceLiveContribution:VP,useStreamBrokerGetDeviceSettingsContribution:HP,useStreamBrokerGetPreBufferInfo:RP,useStreamBrokerGetRtspEntry:zP,useStreamBrokerGetRtspPort:OP,useStreamBrokerGetStreamUrl:_P,useStreamBrokerGetStreamWithCodec:$P,useStreamBrokerIsRtspEnabled:jP,useStreamBrokerKillClient:AP,useStreamBrokerListAllCameraStreams:CP,useStreamBrokerListAllProfileSlots:MP,useStreamBrokerListClients:IP,useStreamBrokerPublishCameraStream:wP,useStreamBrokerRegenerateRtspToken:Xx,useStreamBrokerReleaseStreamWithCodec:DP,useStreamBrokerRestartProfile:PP,useStreamBrokerRetractCameraStream:NP,useStreamBrokerSetPreBufferDuration:TP,useStreamBrokerSetRtspEnabled:FP,useStreamBrokerUnassignProfile:SP,useSwitchGetStatus:QP,useSwitchSetState:UP,useSystem:De,useSystemFeatureFlags:WP,useSystemForceRetentionCleanup:JP,useSystemGetRetentionConfig:ZP,useSystemHealth:KP,useSystemInfo:GP,useSystemMutation:kD,useSystemNetworkAddresses:YP,useSystemQuery:ND,useSystemSetRetentionConfig:XP,useThemeMode:Br,useToastOnToast:Jx,useTurnOrchestratorGetAllServers:ty,useTurnOrchestratorListProviders:ey,useTurnOrchestratorSetProviderEnabled:ny,useTurnProviderGetTurnServers:e_,useUserManagementConfirmTotp:a_,useUserManagementCreateApiKey:n_,useUserManagementCreateScopedToken:cy,useUserManagementCreateUser:ry,useUserManagementDeleteUser:sy,useUserManagementDisableTotp:py,useUserManagementGetTotpStatus:fy,useUserManagementListApiKeys:iy,useUserManagementListScopedTokens:uy,useUserManagementListUsers:ad,useUserManagementResetPassword:id,useUserManagementRevokeApiKey:ly,useUserManagementRevokeScopedToken:dy,useUserManagementSetUserScopes:ay,useUserManagementSetupTotp:s_,useUserManagementUpdateUser:oy,useUserManagementValidateApiKey:r_,useUserManagementValidateCredentials:t_,useUserManagementValidateScopedToken:o_,useUserManagementVerifyTotp:i_,useWebrtcSessionCloseSession:p_,useWebrtcSessionCreateSession:c_,useWebrtcSessionHandleAnswer:u_,useWebrtcSessionHandleOffer:d_,useWebrtcSessionHasAdaptiveBitrate:f_,useWebrtcSessionListStreams:l_,useWidget:gy,useWidgetMetadata:by,useWidgetRegistry:Da,useZoneAnalyticsGetCameraHistory:g_,useZoneAnalyticsGetCurrentSnapshot:h_,useZoneAnalyticsGetUnzonedHistory:b_,useZoneAnalyticsGetZoneHistory:m_,useZoneEditing:xD,useZoneRulesListRules:x_,useZoneRulesSetRules:y_,useZonesAddZone:w_,useZonesListZones:v_,useZonesRemoveZone:N_,useZonesUpdateZone:k_,validateScopes:bd},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 pp="popstate";function fp(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function MD(e={}){function t(r,s){let a=s.state?.masked,{pathname:i,search:l,hash:c}=a||r.location;return Pl("",{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:No(s)}return ID(t,n,null,e)}function Fe(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function wt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function ED(){return Math.random().toString(36).substring(2,10)}function hp(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 Pl(e,t,n=null,r,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Vr(t):t,state:n,key:t&&t.key||r||ED(),mask:s}}function No({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 Vr(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 ID(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=fp(x)?x:Pl(b.location,x,y);d=f()+1;let v=hp(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=fp(x)?x:Pl(b.location,x,y);d=f();let v=hp(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 AD(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(pp,p),c=x,()=>{s.removeEventListener(pp,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 AD(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Fe(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:No(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Oy(e,t,n="/"){return PD(e,t,n,!1)}function PD(e,t,n,r,s){let a=typeof t=="string"?Vr(t):t,i=dn(a.pathname||"/",n);if(i==null)return null;let l=_D(e),c=null,d=VD(i);for(let f=0;c==null&&f<l.length;++f)c=jD(l[f],d,r);return c}function _D(e){let t=By(e);return $D(t),t}function By(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;Fe(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=Rt([r,f.relativePath]),h=n.concat(f);i.children&&i.children.length>0&&(Fe(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${p}".`),By(i.children,t,h,p,c)),!(i.path==null&&!i.index)&&t.push({path:p,score:zD(p,i.index),routesMeta:h})};return e.forEach((i,l)=>{if(i.path===""||!i.path?.includes("?"))a(i,l);else for(let c of zy(i.path))a(i,l,!0,c)}),t}function zy(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=zy(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 $D(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:FD(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var DD=/^:[\w-]+$/,LD=3,TD=2,RD=1,OD=10,BD=-2,mp=e=>e==="*";function zD(e,t){let n=e.split("/"),r=n.length;return n.some(mp)&&(r+=BD),t&&(r+=TD),n.filter(s=>!mp(s)).reduce((s,a)=>s+(DD.test(a)?LD:a===""?RD:OD),r)}function FD(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 jD(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=Ys({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},f),h=c.route;if(!p&&d&&n&&!r[r.length-1].route.index&&(p=Ys({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!p)return null;Object.assign(s,p.params),i.push({params:s,pathname:Rt([a,p.pathname]),pathnameBase:GD(Rt([a,p.pathnameBase])),route:h}),p.pathnameBase!=="/"&&(a=Rt([a,p.pathnameBase]))}return i}function Ys(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=HD(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 HD(e,t=!1,n=!0){wt(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 VD(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return wt(!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 dn(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 qD=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function UD(e,t="/"){let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?Vr(e):e,a;return n?(n=Fy(n),n.startsWith("/")?a=gp(n.substring(1),"/"):a=gp(n,t)):a=t,{pathname:a,search:KD(r),hash:WD(s)}}function gp(e,t){let n=Zs(t).split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function Ei(e,t,n,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 QD(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function wd(e){let t=QD(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Ta(e,t,n,r=!1){let s;typeof e=="string"?s=Vr(e):(s={...e},Fe(!s.pathname||!s.pathname.includes("?"),Ei("?","pathname","search",s)),Fe(!s.pathname||!s.pathname.includes("#"),Ei("#","pathname","hash",s)),Fe(!s.search||!s.search.includes("#"),Ei("#","search","hash",s)));let a=e===""||s.pathname==="",i=a?"/":s.pathname,l;if(i==null)l=n;else{let p=t.length-1;if(!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=UD(s,l),d=i&&i!=="/"&&i.endsWith("/"),f=(a||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var Fy=e=>e.replace(/\/\/+/g,"/"),Rt=e=>Fy(e.join("/")),Zs=e=>e.replace(/\/+$/,""),GD=e=>Zs(e).replace(/^\/*/,"/"),KD=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,WD=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,YD=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 ZD(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function XD(e){let t=e.map(n=>n.route.path).filter(Boolean);return Rt(t)||"/"}var jy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Hy(e,t){let n=e;if(typeof n!="string"||!qD.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,s=!1;if(jy)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=dn(i.pathname,t);i.origin===a.origin&&l!=null?n=l+i.search+i.hash:s=!0}catch{wt(!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 Vy=["POST","PUT","PATCH","DELETE"];new Set(Vy);var JD=["GET",...Vy];new Set(JD);var qr=Be(null);qr.displayName="DataRouter";var Ra=Be(null);Ra.displayName="DataRouterState";var qy=Be(!1);function eL(){return ve(qy)}var Uy=Be({isTransitioning:!1});Uy.displayName="ViewTransition";var tL=Be(new Map);tL.displayName="Fetchers";var nL=Be(null);nL.displayName="Await";var gt=Be(null);gt.displayName="Navigation";var qo=Be(null);qo.displayName="Location";var Ct=Be({outlet:null,matches:[],isDataRoute:!1});Ct.displayName="Route";var Nd=Be(null);Nd.displayName="RouteError";var Qy="REACT_ROUTER_ERROR",rL="REDIRECT",oL="ROUTE_ERROR_RESPONSE";function sL(e){if(e.startsWith(`${Qy}:${rL}:{`))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 aL(e){if(e.startsWith(`${Qy}:${oL}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new YD(t.status,t.statusText,t.data)}catch{}}function iL(e,{relative:t}={}){Fe(Ur(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=ve(gt),{hash:s,pathname:a,search:i}=Uo(e,{relative:t}),l=a;return n!=="/"&&(l=a==="/"?n:Rt([n,a])),r.createHref({pathname:l,search:i,hash:s})}function Ur(){return ve(qo)!=null}function bt(){return Fe(Ur(),"useLocation() may be used only in the context of a <Router> component."),ve(qo).location}var Gy="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Ky(e){ve(gt).static||va(e)}function et(){let{isDataRoute:e}=ve(Ct);return e?NL():lL()}function lL(){Fe(Ur(),"useNavigate() may be used only in the context of a <Router> component.");let e=ve(qr),{basename:t,navigator:n}=ve(gt),{matches:r}=ve(Ct),{pathname:s}=bt(),a=JSON.stringify(wd(r)),i=ne(!1);return Ky(()=>{i.current=!0}),q((c,d={})=>{if(wt(i.current,Gy),!i.current)return;if(typeof c=="number"){n.go(c);return}let f=Ta(c,JSON.parse(a),s,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Rt([t,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,a,s,e])}var cL=Be(null);function dL(e){let t=ve(Ct).outlet;return Q(()=>t&&Ee(cL.Provider,{value:e},t),[t,e])}function kd(){let{matches:e}=ve(Ct);return e[e.length-1]?.params??{}}function Uo(e,{relative:t}={}){let{matches:n}=ve(Ct),{pathname:r}=bt(),s=JSON.stringify(wd(n));return Q(()=>Ta(e,JSON.parse(s),r,t==="path"),[e,s,r,t])}function uL(e,t){return Wy(e,t)}function Wy(e,t,n){Fe(Ur(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=ve(gt),{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||"";Zy(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=bt(),p;if(t){let x=typeof t=="string"?Vr(t):t;Fe(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})):Oy(e,{pathname:m});wt(d||g!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),wt(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=gL(g&&g.map(x=>Object.assign({},x,{params:Object.assign({},i,x.params),pathname:Rt([c,r.encodeLocation?r.encodeLocation(x.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?c:Rt([c,r.encodeLocation?r.encodeLocation(x.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathnameBase])})),s,n);return t&&b?Ee(qo.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...p},navigationType:"POP"}},b):b}function pL(){let e=wL(),t=ZD(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=Ee(Er,null,Ee("p",null,"💿 Hey developer 👋"),Ee("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",Ee("code",{style:a},"ErrorBoundary")," or"," ",Ee("code",{style:a},"errorElement")," prop on your route.")),Ee(Er,null,Ee("h2",null,"Unexpected Application Error!"),Ee("h3",{style:{fontStyle:"italic"}},t),n?Ee("pre",{style:s},n):null,i)}var fL=Ee(pL,null),Yy=class extends SN{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=aL(e.digest);n&&(e=n)}let t=e!==void 0?Ee(Ct.Provider,{value:this.props.routeContext},Ee(Nd.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?Ee(hL,{error:e},t):t}};Yy.contextType=qy;var Ii=new WeakMap;function hL({children:e,error:t}){let{basename:n}=ve(gt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=sL(t.digest);if(r){let s=Ii.get(t);if(s)throw s;let a=Hy(r.location,n);if(jy&&!Ii.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 Ii.set(t,i),i}return Ee("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function mL({routeContext:e,match:t,children:n}){let r=ve(qr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),Ee(Ct.Provider,{value:e},n)}function gL(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);Fe(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:XD(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||fL,i&&(l<0&&h===0?(Zy("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,x=null):l===h&&(g=!0,x=p.route.hydrateFallbackElement||null)));let y=t.concat(s.slice(0,h+1)),w=()=>{let v;return m?v=b:g?v=x:p.route.Component?v=Ee(p.route.Component,null):p.route.element?v=p.route.element:v=f,Ee(mL,{match:p,routeContext:{outlet:f,matches:y,isDataRoute:r!=null},children:v})};return r&&(p.route.ErrorBoundary||p.route.errorElement||h===0)?Ee(Yy,{location:r.location,revalidation:r.revalidation,component:b,error:m,children:w(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:d}):w()},null)}function Sd(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function bL(e){let t=ve(qr);return Fe(t,Sd(e)),t}function xL(e){let t=ve(Ra);return Fe(t,Sd(e)),t}function yL(e){let t=ve(Ct);return Fe(t,Sd(e)),t}function Cd(e){let t=yL(e),n=t.matches[t.matches.length-1];return Fe(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function vL(){return Cd("useRouteId")}function wL(){let e=ve(Nd),t=xL("useRouteError"),n=Cd("useRouteError");return e!==void 0?e:t.errors?.[n]}function NL(){let{router:e}=bL("useNavigate"),t=Cd("useNavigate"),n=ne(!1);return Ky(()=>{n.current=!0}),q(async(s,a={})=>{wt(n.current,Gy),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:t,...a}))},[e,t])}var bp={};function Zy(e,t,n){!t&&!bp[e]&&(bp[e]=!0,wt(!1,n))}He(kL);function kL({routes:e,manifest:t,future:n,state:r,isStatic:s,onError:a}){return Wy(e,void 0,{manifest:t,state:r,isStatic:s,onError:a})}function xt({to:e,replace:t,state:n,relative:r}){Fe(Ur(),"<Navigate> may be used only in the context of a <Router> component.");let{static:s}=ve(gt);wt(!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}=bt(),l=et(),c=Ta(e,wd(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 SL(e){return dL(e.context)}function Le(e){Fe(!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 CL({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:s,static:a=!1,useTransitions:i}){Fe(!Ur(),"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=Vr(n));let{pathname:d="/",search:f="",hash:p="",state:h=null,key:m="default",mask:g}=n,b=Q(()=>{let x=dn(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 wt(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:Ee(gt.Provider,{value:c},Ee(qo.Provider,{children:t,value:b}))}function ML({children:e,location:t}){return uL(_l(e),t)}function _l(e,t=[]){let n=[];return NN.forEach(e,(r,s)=>{if(!kN(r))return;let a=[...t,s];if(r.type===Er){n.push.apply(n,_l(r.props.children,a));return}Fe(r.type===Le,`[${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>`),Fe(!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=_l(r.props.children,a)),n.push(i)}),n}var Rs="get",Os="application/x-www-form-urlencoded";function Oa(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function EL(e){return Oa(e)&&e.tagName.toLowerCase()==="button"}function IL(e){return Oa(e)&&e.tagName.toLowerCase()==="form"}function AL(e){return Oa(e)&&e.tagName.toLowerCase()==="input"}function PL(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function _L(e,t){return e.button===0&&(!t||t==="_self")&&!PL(e)}function $l(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 $L(e,t){let n=$l(e);return t&&t.forEach((r,s)=>{n.has(s)||t.getAll(s).forEach(a=>{n.append(s,a)})}),n}var fs=null;function DL(){if(fs===null)try{new FormData(document.createElement("form"),0),fs=!1}catch{fs=!0}return fs}var LL=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ai(e){return e!=null&&!LL.has(e)?(wt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Os}"`),null):e}function TL(e,t){let n,r,s,a,i;if(IL(e)){let l=e.getAttribute("action");r=l?dn(l,t):null,n=e.getAttribute("method")||Rs,s=Ai(e.getAttribute("enctype"))||Os,a=new FormData(e)}else if(EL(e)||AL(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?dn(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||Rs,s=Ai(e.getAttribute("formenctype"))||Ai(l.getAttribute("enctype"))||Os,a=new FormData(l,e),!DL()){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(Oa(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Rs,r=null,s=Os,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 Xy(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&&dn(s.pathname,t)==="/"?s.pathname=`${Zs(t)}/_root.${r}`:s.pathname=`${Zs(s.pathname)}.${r}`,s}async function RL(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 OL(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 BL(e,t,n){let r=await Promise.all(e.map(async s=>{let a=t.routes[s.route.id];if(a){let i=await RL(a,n);return i.links?i.links():[]}return[]}));return HL(r.flat(1).filter(OL).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function xp(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 zL(e,t,{includeHydrateFallback:n}={}){return FL(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 FL(e){return[...new Set(e)]}function jL(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function HL(e,t){let n=new Set;return new Set(t),e.reduce((r,s)=>{let a=JSON.stringify(jL(s));return n.has(a)||(n.add(a),r.push({key:a,link:s})),r},[])}function Ed(){let e=ve(qr);return Md(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function VL(){let e=ve(Ra);return Md(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Id=Be(void 0);Id.displayName="FrameworkContext";function Ad(){let e=ve(Id);return Md(e,"You must render this element inside a <HydratedRouter> element"),e}function qL(e,t){let n=ve(Id),[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:Zr(l,m),onBlur:Zr(c,g),onMouseEnter:Zr(d,m),onMouseLeave:Zr(f,g),onTouchStart:Zr(p,m)}]:[!1,h,{}]}function Zr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function UL({page:e,...t}){let n=eL(),{router:r}=Ed(),s=Q(()=>Oy(r.routes,e,r.basename),[r.routes,e,r.basename]);return s?n?Ee(GL,{page:e,matches:s,...t}):Ee(KL,{page:e,matches:s,...t}):null}function QL(e){let{manifest:t,routeModules:n}=Ad(),[r,s]=_([]);return Y(()=>{let a=!1;return BL(e,t,n).then(i=>{a||s(i)}),()=>{a=!0}},[e,t,n]),r}function GL({page:e,matches:t,...n}){let r=bt(),{future:s}=Ad(),{basename:a}=Ed(),i=Q(()=>{if(e===r.pathname+r.search+r.hash)return[];let l=Xy(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 Ee(Er,null,i.map(l=>Ee("link",{key:l,rel:"prefetch",as:"fetch",href:l,...n})))}function KL({page:e,matches:t,...n}){let r=bt(),{future:s,manifest:a,routeModules:i}=Ad(),{basename:l}=Ed(),{loaderData:c,matches:d}=VL(),f=Q(()=>xp(e,t,d,a,r,"data"),[e,t,d,a,r]),p=Q(()=>xp(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=Xy(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(()=>zL(p,a),[p,a]),g=QL(p);return Ee(Er,null,h.map(b=>Ee("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),m.map(b=>Ee("link",{key:b,rel:"modulepreload",href:b,...n})),g.map(({key:b,link:x})=>Ee("link",{key:b,nonce:n.nonce,...x,crossOrigin:x.crossOrigin??n.crossOrigin})))}function WL(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var YL=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{YL&&(window.__reactRouterVersion="7.15.0")}catch{}function ZL({basename:e,children:t,useTransitions:n,window:r}){let s=ne();s.current==null&&(s.current=MD({window:r,v5Compat:!0}));let a=s.current,[i,l]=_({action:a.action,location:a.location}),c=q(d=>{n===!1?l(d):pc(()=>l(d))},[n]);return va(()=>a.listen(c),[a,c]),Ee(CL,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a,useTransitions:n})}var Jy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Zn=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(gt),v=typeof f=="string"&&Jy.test(f),N=Hy(f,x);f=N.to;let k=iL(f,{relative:s}),C=bt(),E=null;if(l){let D=Ta(l,[],C.mask?C.mask.pathname:"/",!0);x!=="/"&&(D.pathname=D.pathname==="/"?x:Rt([x,D.pathname])),E=y.createHref(D)}let[P,I,z]=qL(r,g),A=tT(f,{replace:i,mask:l,state:c,target:d,preventScrollReset:p,relative:s,viewTransition:h,defaultShouldRevalidate:m,useTransitions:w});function O(D){t&&t(D),D.defaultPrevented||A(D)}let R=!(N.isExternal||a),M=Ee("a",{...g,...z,href:(R?E:void 0)||N.absoluteURL||k,onClick:R?O:t,ref:WL(b,I),target:d,"data-discover":!v&&n==="render"?"true":void 0});return P&&!v?Ee(Er,null,M,Ee(UL,{page:k})):M});Zn.displayName="Link";var XL=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=Uo(i,{relative:d.relative}),h=bt(),m=ve(Ra),{navigator:g,basename:b}=ve(gt),x=m!=null&&aT(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=dn(v,b)||v);const N=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let k=w===y||!s&&w.startsWith(y)&&w.charAt(N)==="/",C=v!=null&&(v===y||!s&&v.startsWith(y)&&v.charAt(y.length)==="/"),E={isActive:k,isPending:C,isTransitioning:x},P=k?t:void 0,I;typeof r=="function"?I=r(E):I=[r,k?"active":null,C?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let z=typeof a=="function"?a(E):a;return Ee(Zn,{...d,"aria-current":P,className:I,ref:f,style:z,to:i,viewTransition:l},typeof c=="function"?c(E):c)});XL.displayName="NavLink";var JL=qe(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:s,state:a,method:i=Rs,action:l,onSubmit:c,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:h,...m},g)=>{let{useTransitions:b}=ve(gt),x=oT(),y=sT(l,{relative:d}),w=i.toLowerCase()==="get"?"get":"post",v=typeof l=="string"&&Jy.test(l);return Ee("form",{ref:g,method:w,action:y,onSubmit:r?c:k=>{if(c&&c(k),k.defaultPrevented)return;k.preventDefault();let C=k.nativeEvent.submitter,E=C?.getAttribute("formmethod")||i,P=()=>x(C||k.currentTarget,{fetcherKey:t,method:E,navigate:n,replace:s,state:a,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:h});b&&n!==!1?pc(()=>P()):P()},...m,"data-discover":!v&&e==="render"?"true":void 0})});JL.displayName="Form";function eT(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function e0(e){let t=ve(qr);return Fe(t,eT(e)),t}function tT(e,{target:t,replace:n,mask:r,state:s,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:c,useTransitions:d}={}){let f=et(),p=bt(),h=Uo(e,{relative:i});return q(m=>{if(_L(m,t)){m.preventDefault();let g=n!==void 0?n:No(p)===No(h),b=()=>f(e,{replace:g,mask:r,state:s,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:c});d?pc(()=>b()):b()}},[p,f,h,n,r,s,t,e,a,i,l,c,d])}function Ba(e){wt(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($l(e)),n=ne(!1),r=bt(),s=Q(()=>$L(r.search,n.current?null:t.current),[r.search]),a=et(),i=q((l,c)=>{const d=$l(typeof l=="function"?l(new URLSearchParams(s)):l);n.current=!0,a("?"+d,c)},[a,s]);return[s,i]}var nT=0,rT=()=>`__${String(++nT)}__`;function oT(){let{router:e}=e0("useSubmit"),{basename:t}=ve(gt),n=vL(),r=e.fetch,s=e.navigate;return q(async(a,i={})=>{let{action:l,method:c,encType:d,formData:f,body:p}=TL(a,t);if(i.navigate===!1){let h=i.fetcherKey||rT();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 sT(e,{relative:t}={}){let{basename:n}=ve(gt),r=ve(Ct);Fe(r,"useFormAction must be used inside a RouteContext");let[s]=r.matches.slice(-1),a={...Uo(e||".",{relative:t})},i=bt();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:Rt([n,a.pathname])),No(a)}function aT(e,{relative:t}={}){let n=ve(Uy);Fe(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=e0("useViewTransitionState"),s=Uo(e,{relative:t});if(!n.isTransitioning)return!1;let a=dn(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=dn(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Ys(s.pathname,i)!=null||Ys(s.pathname,a)!=null}const iT=3e4;function lT(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>=iT&&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 Dl="disconnected";const Ll=new Set;function cT(){for(const e of Ll)e()}function dT(e){Dl!==e&&(Dl=e,cT())}function uT(e){return Ll.add(e),()=>{Ll.delete(e)}}function yp(){return Dl}function pT(){return wa(uT,yp,yp)}let lo=null;function Bs(){if(!lo){const e=window.location.origin,t=localStorage.getItem("camstack_admin_token")??void 0;lo=jh({serverUrl:e,token:t,onConnectionChange:n=>dT(n)})}return lo}function yr(){lo?.close(),lo=null}function fT(e){const t=gn();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(lt,{widgetId:"pipeline-orchestrator/zone-editor",host:"device-tab",deviceId:t})}function hT({deviceId:e}){return u("div",{className:pm,children:[u("div",{className:`grid ${fm}`,style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 340px), 1fr))"},children:[o(lt,{widgetId:"pipeline-analytics/live-occupancy-panel",host:"device-tab",deviceId:e}),o(lt,{widgetId:"pipeline-analytics/audio-metrics-panel",host:"device-tab",deviceId:e})]}),o(lt,{widgetId:"pipeline-analytics/audio-history-chart",host:"device-tab",deviceId:e}),o(lt,{widgetId:"pipeline-analytics/occupancy-history-chart",host:"device-tab",deviceId:e}),o(lt,{widgetId:"pipeline-analytics/motion-history-chart",host:"device-tab",deviceId:e}),o(lt,{widgetId:"pipeline-analytics/detection-history-chart",host:"device-tab",deviceId:e})]})}function mT(e){const t=gn();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(hT,{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 gT=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),bT=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),vp=e=>{const t=bT(e);return t.charAt(0).toUpperCase()+t.slice(1)},t0=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),xT=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 yT={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 vT=qe(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:i,...l},c)=>Ee("svg",{ref:c,...yT,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:t0("lucide",s),...!a&&!xT(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,f])=>Ee(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)=>Ee(vT,{ref:a,iconNode:t,className:t0(`lucide-${gT(vp(e))}`,`lucide-${e}`,r),...s}));return n.displayName=vp(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 wT=[["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"}]],Qo=se("activity",wT);/**
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 NT=[["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"}]],n0=se("archive",NT);/**
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 kT=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Pd=se("arrow-left",kT);/**
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 ST=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],CT=se("arrow-right",ST);/**
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 MT=[["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"}]],ET=se("battery-full",MT);/**
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 IT=[["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"}]],Go=se("bell",IT);/**
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 AT=[["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"}]],PT=se("book-open",AT);/**
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 _T=[["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"}]],$T=se("bot",_T);/**
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 DT=[["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"}]],za=se("box",DT);/**
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 LT=[["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"}]],Ko=se("boxes",LT);/**
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 TT=[["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"}]],RT=se("calendar-clock",TT);/**
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 OT=[["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"}]],r0=se("calendar",OT);/**
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 BT=[["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"}]],Ir=se("camera",BT);/**
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 zT=[["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"}]],o0=se("cctv",zT);/**
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 FT=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],jT=se("check-check",FT);/**
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 HT=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Mt=se("check",HT);/**
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 VT=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Nt=se("chevron-down",VT);/**
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 qT=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],_d=se("chevron-left",qT);/**
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 UT=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Et=se("chevron-right",UT);/**
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 QT=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],GT=se("chevron-up",QT);/**
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 KT=[["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"}]],Xn=se("circle-alert",KT);/**
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 WT=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],co=se("circle-check-big",WT);/**
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 YT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],s0=se("circle-check",YT);/**
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 ZT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],a0=se("circle-dot",ZT);/**
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 XT=[["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"}]],JT=se("circle-help",XT);/**
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 eR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],tR=se("clock",eR);/**
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 nR=[["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"}]],Xs=se("copy",nR);/**
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 rR=[["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"}]],ft=se("cpu",rR);/**
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 oR=[["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"}]],sR=se("crosshair",oR);/**
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 aR=[["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"}]],i0=se("database",aR);/**
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 iR=[["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"}]],Mn=se("download",iR);/**
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 lR=[["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"}]],cR=se("ellipsis-vertical",lR);/**
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 dR=[["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"}]],$d=se("external-link",dR);/**
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 uR=[["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"}]],l0=se("eye-off",uR);/**
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 pR=[["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"}]],Wo=se("eye",pR);/**
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 fR=[["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"}]],uo=se("film",fR);/**
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 hR=[["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"}]],mR=se("flame",hR);/**
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 gR=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],c0=se("gauge",gR);/**
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 bR=[["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"}]],Tl=se("ghost",bR);/**
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 xR=[["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"}]],yR=se("git-branch",xR);/**
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 vR=[["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"}]],Wt=se("globe",vR);/**
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 wR=[["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"}]],Js=se("hard-drive",wR);/**
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 NR=[["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"}]],kR=se("house",NR);/**
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 SR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Jn=se("info",SR);/**
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 CR=[["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"}]],d0=se("key-round",CR);/**
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 MR=[["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"}]],u0=se("key-square",MR);/**
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 ER=[["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"}]],IR=se("key",ER);/**
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 AR=[["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"}]],PR=se("layers",AR);/**
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 _R=[["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"}]],p0=se("layout-dashboard",_R);/**
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 $R=[["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"}]],DR=se("lightbulb",$R);/**
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 LR=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Se=se("loader-circle",LR);/**
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 TR=[["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"}]],Dd=se("lock",TR);/**
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 RR=[["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"}]],OR=se("log-in",RR);/**
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 BR=[["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"}]],Ld=se("log-out",BR);/**
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 zR=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],FR=se("mail",zR);/**
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 jR=[["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"}]],HR=se("map-pin",jR);/**
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 VR=[["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"}]],Td=se("memory-stick",VR);/**
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 qR=[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]],UR=se("menu",qR);/**
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 QR=[["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"}]],Rl=se("mic",QR);/**
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 GR=[["path",{d:"M5 12h14",key:"1ays0h"}]],KR=se("minus",GR);/**
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 WR=[["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"}]],YR=se("monitor",WR);/**
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 ZR=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],f0=se("moon",ZR);/**
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 XR=[["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"}]],JR=se("move",XR);/**
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 e6=[["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"}]],En=se("network",e6);/**
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 t6=[["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"}]],n6=se("octagon-alert",t6);/**
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 r6=[["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"}]],h0=se("package",r6);/**
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 o6=[["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",o6);/**
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 s6=[["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"}]],m0=se("pin",s6);/**
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 a6=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],Fa=se("play",a6);/**
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 i6=[["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"}]],ko=se("plug",i6);/**
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 l6=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ot=se("plus",l6);/**
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 c6=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],g0=se("power",c6);/**
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 d6=[["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"}]],So=se("puzzle",d6);/**
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 u6=[["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"}]],p6=se("radar",u6);/**
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 f6=[["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"}]],ja=se("radio",f6);/**
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 h6=[["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"}]],ht=se("refresh-cw",h6);/**
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 m6=[["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"}]],b0=se("rotate-ccw",m6);/**
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 g6=[["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"}]],yt=se("rotate-cw",g6);/**
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 b6=[["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"}]],x6=se("save",b6);/**
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 y6=[["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"}]],rt=se("scroll-text",y6);/**
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 v6=[["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"}]],w6=se("search-x",v6);/**
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 N6=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],x0=se("search",N6);/**
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 k6=[["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"}]],un=se("server",k6);/**
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 S6=[["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"}]],Yt=se("settings",S6);/**
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 C6=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],M6=se("share-2",C6);/**
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 E6=[["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"}]],pn=se("shield-check",E6);/**
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 I6=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]],wp=se("shield-off",I6);/**
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 A6=[["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"}]],P6=se("shield-x",A6);/**
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 _6=[["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"}]],$6=se("shield",_6);/**
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 D6=[["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"}]],hs=se("skull",D6);/**
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 L6=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Sn=se("smartphone",L6);/**
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 T6=[["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"}]],R6=se("sparkles",T6);/**
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 O6=[["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"}]],y0=se("square-check-big",O6);/**
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 B6=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Yo=se("square",B6);/**
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 z6=[["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"}]],Pi=se("star",z6);/**
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 F6=[["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"}]],j6=se("sun",F6);/**
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 H6=[["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"}]],V6=se("table-2",H6);/**
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 q6=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],v0=se("terminal",q6);/**
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 U6=[["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"}]],Ke=se("trash-2",U6);/**
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 Q6=[["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"}]],ut=se("triangle-alert",Q6);/**
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 G6=[["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"}]],Ha=se("upload",G6);/**
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 K6=[["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"}]],W6=se("users",K6);/**
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 Y6=[["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"}]],w0=se("video",Y6);/**
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 Z6=[["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"}]],N0=se("wifi-off",Z6);/**
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 X6=[["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"}]],er=se("wifi",X6);/**
1096
- * @license lucide-react v0.511.0 - ISC
1097
- *
1098
- * This source code is licensed under the ISC license.
1099
- * See the LICENSE file in the root directory of this source tree.
1100
- */const J6=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ze=se("x",J6);/**
1101
- * @license lucide-react v0.511.0 - ISC
1102
- *
1103
- * This source code is licensed under the ISC license.
1104
- * See the LICENSE file in the root directory of this source tree.
1105
- */const eO=[["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"}]],tO=se("wrench",eO);/**
1106
- * @license lucide-react v0.511.0 - ISC
1107
- *
1108
- * This source code is licensed under the ISC license.
1109
- * See the LICENSE file in the root directory of this source tree.
1110
- */const nO=[["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"}]],Rd=se("zap",nO);function rO(e){const t=De();return Pn({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 oO(e){return typeof e=="string"&&e.length>0&&e!=="undefined"&&e!=="null"}function sO(e={}){const t=ke(),n=Hr(void 0,{staleTime:1e4,enabled:e.enabled??!0}),r=Q(()=>(n.data??[]).filter(i=>oO(i.nodeId)),[n.data]),s=q(()=>{t.invalidateQueries({queryKey:["pipelineOrchestrator","listAgentSettings"]})},[t]);return{agents:r,isLoading:n.isLoading,isError:n.isError,error:n.error,refetch:()=>{n.refetch()},invalidate:s}}function aO({field:e,disabled:t}){const n=ke(),r=e.deviceId,s=rO(e.catalogResolver),a=td({agentNodeId:e.nodeId}),i=rd({deviceId:r}),c=Ix({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),d=s.data,f=a.data??null,p=i.data??null,h=Q(()=>d?lO(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(jc,{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(iO,{deviceId:r,currentAgentNodeId:e.nodeId,catalog:d,pipelineByAgent:p?.pipelineByAgent??{},disabled:t===!0})]})}function iO({deviceId:e,currentAgentNodeId:t,catalog:n,pipelineByAgent:r,disabled:s}){const a=ke(),[i,l]=_(!1),[c,d]=_(t),{agents:f}=sO({enabled:i}),p=_x({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?cO(g.steps,n):[],[g,n]),y=w=>{const v=g?.audio??null;m.mutate({deviceId:e,agentNodeId:c,pipeline:{steps:dO(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(Nt,{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(Ke,{className:"h-3 w-3"}),"Remove override"]})]}),g?o(jc,{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 lO(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 cO(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 dO(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 uO({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 pO(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 fO(e){return`${e.inputSize.width}x${e.inputSize.height}`}function hO(e){return e.formats?Object.keys(e.formats).filter(t=>e.formats[t]!==void 0):[]}function mO({entry:e,selected:t,onSelect:n,disabled:r}){const s=pO(e),a=fO(e),i=hO(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(ft,{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 gO({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(uO,{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(mO,{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(Jn,{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(Jn,{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($d,{className:"h-3 w-3"})]})]})]})}function k0(e){const t=De();return Ry(t.trpcClient,e)}function bO({deviceId:e,deviceName:t,hasPTZ:n=!1,className:r}){const s=De(),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}=Pn({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}=xd(s.trpcClient,i?e:null),C=k0(i?e:null),E=yd(s.trpcClient,i?e:0,{enabled:d}),P=h?`data:${h.contentType};base64,${h.base64}`:null;return o(ud,{serverUrl:a,createSession:v,sendAnswer:N,closeSession:k,streams:y,pipelineMetrics:w,deviceName:t,phase:C.phase,detections:C,defaultShowDetections:!1,defaultShowMotion:!1,autoPlay:!1,showPlayStop:!0,snapshotSrc:P,snapshotLoading:m||g,onRefreshSnapshot:x,ptzAvailable:i&&n,ptzShown:d,onPtzToggle:()=>c(I=>!I),ptzOverlay:d?o(hd,{controls:E}):void 0,className:r})}function xO(){const e=gn(),t=Vc();if(e===null)return null;const n=typeof t?.name=="string"?t.name:"",s=(t?.features??[]).includes(Un.PanTiltZoom);return o(bO,{deviceId:e,deviceName:n,hasPTZ:s})}function vt(e,t){const n=De(),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 ms({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:`${Gs} uppercase tracking-wider whitespace-nowrap overflow-hidden text-ellipsis min-w-0`,children:t})]}),o("p",{className:`${s?`${bl.replace("text-foreground","")} ${s}`:bl} whitespace-nowrap overflow-hidden text-ellipsis`,children:n}),r&&o("p",{className:`${Gs} mt-0.5 truncate`,children:r})]})}function gs({label:e,value:t,warning:n}){return u("div",{className:"min-w-0",children:[o("p",{className:`${Gs} truncate`,children:e}),o("p",{className:`text-[11px] font-medium truncate ${n?"text-warning":"text-foreground"}`,children:t})]})}function sn({label:e,value:t}){return u("div",{className:`${hm} 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 yO(){const e=gn();vt(["pipelineOrchestrator","getPipelineAssignment"],["pipeline.camera-assigned","pipeline.camera-unassigned","pipeline.camera-updated"]),vt(["pipelineRunner","getCameraMetrics"],["pipeline.camera-metrics-snapshot"]);const{data:t}=_a({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}=od({deviceId:e??0,...s?{nodeId:s}:{}},{enabled:e!==null,staleTime:2e3,retry:!1}),i=De(),l=St(i.trpcClient,e),{data:c}=Pn({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=ir(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(ms,{icon:Qo,label:"Phase",value:x.label,color:x.textColor,subtext:f??void 0}),o(ms,{icon:c0,label:"Detection FPS",value:`${p.toFixed(1)}`,subtext:h>0?`target: ${h}`:void 0}),o(ms,{icon:ft,label:"Inference",value:`${m.toFixed(1)} ms`,subtext:g>0?`queue: ${g}`:void 0}),o(ms,{icon:Wo,label:"Active Tracks",value:String(y),subtext:b>0?`dropped: ${b}`:void 0})]})}function _i(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function vO(){const e=gn(),{data:t}=ed({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(er,{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(gs,{label:"Nominal",value:_i(a.nominalBitrateKbps??0)}),o(gs,{label:"Observed",value:_i(a.observedBitrateKbps??0)}),o(gs,{label:"Peak",value:_i(a.peakBitrateKbps??0)}),o(gs,{label:"Packet Loss",value:`${(a.packetLossPercent??0).toFixed(2)}%`,warning:(a.packetLossPercent??0)>1})]})]},s))})]})}const wO=3e4;function NO({field:e}){const t=gn(),n=e.type==="doorbell-recent"&&typeof e.historyLimit=="number"?e.historyLimit:10,r=vd({deviceId:t??void 0,historyLimit:n});if(t===null)return null;const s=r.latest?Date.now()-r.latest.timestamp<wO:!1;return o(md,{history:r.history,latestIsFresh:s})}const kO={streaming:{icon:w0,label:"Streaming"},detection:{icon:Wo,label:"Detection"},recording:{icon:a0,label:"Recording"},audio:{icon:Rl,label:"Audio"},snapshot:{icon:Ir,label:"Snapshot"},motion:{icon:Rd,label:"Motion"},ptz:{icon:Yt,label:"PTZ"},webrtc:{icon:ja,label:"WebRTC"},onvif:{icon:$6,label:"ONVIF"},analytics:{icon:ft,label:"Analytics"},"battery-operated":{icon:ET,label:"Battery"},"native-snapshot":{icon:Ir,label:"Native Snapshot"},"pan-tilt-zoom":{icon:Yt,label:"PTZ"},"two-way-audio":{icon:Rl,label:"Two-way Audio"},"doorbell-button":{icon:Go,label:"Doorbell"},rebootable:{icon:ht,label:"Rebootable"}},SO=za;function Va({capabilities:e,showLabels:t=!1}){return o("div",{className:"flex items-center gap-1 flex-wrap",children:e.map(n=>{const r=kO[n],s=r?.icon??SO,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 CO={frigate:{icon:o0,color:"#3b82f6",label:"Frigate"},scrypted:{icon:un,color:"#a855f7",label:"Scrypted"},reolink:{icon:ja,color:"#06b6d4",label:"Reolink"},homeassistant:{icon:kR,color:"#22d3ee",label:"Home Assistant"},rtsp:{icon:er,color:"#78716c",label:"RTSP"},onvif:{icon:er,color:"#78716c",label:"ONVIF"}},Np={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6"},MO={sm:"h-7 w-7",md:"h-8 w-8",lg:"h-10 w-10"};function S0(e){const t=e.toLowerCase();return t.startsWith("provider-")?t.slice(9):t}function EO(e){const t=S0(e);return CO[t]??{icon:o0,color:"#78716c",label:e}}function IO(e){const t=S0(e);return`/api/addon-assets/${e.toLowerCase().startsWith("provider-")?e:`provider-${t}`}/assets/icon.svg`}function fn({type:e,size:t="md",showLabel:n}){const r=EO(e),s=r.icon,[a,i]=_(!1),l=IO(e);return u("div",{className:"flex items-center gap-2",children:[o("div",{className:`flex items-center justify-center rounded-lg ${MO[t]}`,style:{backgroundColor:`${r.color}15`},children:a?o(s,{className:Np[t],style:{color:r.color}}):o("img",{src:l,alt:r.label,className:Np[t],onError:()=>i(!0)})}),n&&o("span",{className:"text-xs font-medium text-foreground-subtle",children:r.label})]})}function AO({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=bb({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(sn,{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(ze,{className:"h-3 w-3"})})]})}):o(sn,{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 PO({deviceId:e,initialLocation:t}){const n=ke(),[r,s]=_(!1),[a,i]=_(t??""),[l,c]=_(!1),d=ne(null),{data:f}=yb(void 0,{staleTime:3e4,enabled:r}),p=f??[];Y(()=>{r||i(t??"")},[t,r]),Y(()=>{r&&d.current?.focus()},[r]);const h=xb({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(sn,{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(ze,{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(HR,{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(sn,{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 kp=["manufacturer","model","hardware","firmware","serialNumber","uid","mac","itemNo"];function _O(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}function $O(e){return e==null?"—":typeof e=="string"||typeof e=="number"||typeof e=="boolean"?String(e):JSON.stringify(e)}function C0(){const e=gn(),t=Vc(),{data:n}=Yn({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(Sp,{active:s==="identity",onClick:()=>a("identity"),label:"Identity"}),o(Sp,{active:s==="hardware",onClick:()=>a("hardware"),label:"Hardware"})]})]}),(!m||s==="identity")&&u("div",{className:"divide-y divide-border",children:[o(sn,{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(AO,{deviceId:e,initialName:l}),o(PO,{deviceId:e,initialLocation:p}),o(sn,{label:"Type",value:c}),o(sn,{label:"Provider",value:o(fn,{type:d,size:"sm",showLabel:!0})}),o(sn,{label:"Capabilities",value:f.length>0?o(Va,{capabilities:f,showLabels:!0}):o("span",{className:"text-[11px] text-foreground-subtle",children:"None"})})]}),m&&s==="hardware"&&o(DO,{metadata:h})]})}function Sp({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 DO({metadata:e}){const t=kp.filter(s=>s in e),n=Object.keys(e).filter(s=>!kp.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(sn,{label:_O(s),value:o("span",{className:"font-mono text-[11px] text-foreground break-all",children:$O(e[s])})},s))})]})}function zs(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:RO(n.scopes)}}catch{return null}}const LO=new Set(["view","create","delete"]),TO=new Set(["category","capability","addon","device"]);function RO(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"||!TO.has(s)||!Array.isArray(a))continue;const i=a.filter(c=>typeof c=="string"&&LO.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 OO(e){const t=zs(e);return t?t.exp*1e3<Date.now():!0}const BO="changeme",M0=Be(null);function zO({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(OO(p)){localStorage.removeItem("camstack_admin_token"),s(!1);return}const h=zs(p);if(!h){localStorage.removeItem("camstack_admin_token"),s(!1);return}Bs().trpcClient.system.info.query().then(()=>n(h)).catch(b=>{const x=b?.data?.code;x==="UNAUTHORIZED"||x==="FORBIDDEN"?(localStorage.removeItem("camstack_admin_token"),yr()):n(h)}).finally(()=>s(!1))},[]);const l=q(async(p,h)=>{const g=await Bs().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),yr(),n(zs(b)),i(h===BO),{kind:"ok"}},[]),c=q(async(p,h)=>{const b=(await Bs().loginVerifyTotp(p,h)).token;localStorage.setItem("camstack_admin_token",b),yr(),n(zs(b)),i(!1)},[]),d=q(()=>{localStorage.removeItem("camstack_admin_token"),yr(),n(null),i(!1)},[]),f=q(()=>{i(!1)},[]);return o(M0.Provider,{value:{user:t,loading:r,mustChangePassword:a,login:l,verifyTotp:c,logout:d,clearMustChangePassword:f},children:e})}function Jt(){const e=ve(M0);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}function At({children:e,requireAdmin:t}){const{user:n,loading:r,mustChangePassword:s}=Jt(),a=bt();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(xt,{to:"/change-password",replace:!0}):t&&!n.isAdmin?o(xt,{to:"/access-denied",replace:!0}):o(me,{children:e}):o(xt,{to:"/login",replace:!0})}var $i={};const Me=e=>typeof e=="string",Xr=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},Cp=e=>e==null?"":""+e,FO=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},jO=/###/g,Mp=e=>e&&e.indexOf("###")>-1?e.replace(jO,"."):e,Ep=e=>!e||Me(e),po=(e,t,n)=>{const r=Me(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(Ep(e))return{};const a=Mp(r[s]);!e[a]&&n&&(e[a]=new n),Object.prototype.hasOwnProperty.call(e,a)?e=e[a]:e={},++s}return Ep(e)?{}:{obj:e,k:Mp(r[s])}},Ip=(e,t,n)=>{const{obj:r,k:s}=po(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=po(e,i,Object);for(;l.obj===void 0&&i.length;)a=`${i[i.length-1]}.${a}`,i=i.slice(0,i.length-1),l=po(e,i,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},HO=(e,t,n,r)=>{const{obj:s,k:a}=po(e,t,Object);s[a]=s[a]||[],s[a].push(n)},ea=(e,t)=>{const{obj:n,k:r}=po(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},VO=(e,t,n)=>{const r=ea(e,n);return r!==void 0?r:ea(t,n)},E0=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?Me(e[r])||e[r]instanceof String||Me(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):E0(e[r],t[r],n):e[r]=t[r]);return e},zn=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var qO={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const UO=e=>Me(e)?e.replace(/[&<>"'\/]/g,t=>qO[t]):e;class QO{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 GO=[" ",",","?","!",";"],KO=new QO(20),WO=(e,t,n)=>{t=t||"",n=n||"";const r=GO.filter(i=>t.indexOf(i)<0&&n.indexOf(i)<0);if(r.length===0)return!0;const s=KO.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},Ol=(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},Co=e=>e?.replace(/_/g,"-"),YO={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 ta{constructor(t,n={}){this.init(t,n)}init(t,n={}){this.prefix=n.prefix||"i18next:",this.logger=t||YO,this.options=n,this.debug=n.debug}log(...t){return this.forward(t,"log","",!0)}warn(...t){return this.forward(t,"warn","",!0)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,r,s){return s&&!this.debug?null:(Me(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new ta(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new ta(this.logger,t)}}var Ut=new ta;class qa{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 Ap extends qa{constructor(t,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,r,s={}){const a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,i=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;t.indexOf(".")>-1?l=t.split("."):(l=[t,n],r&&(Array.isArray(r)?l.push(...r):Me(r)&&a?l.push(...r.split(a)):l.push(r)));const c=ea(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!i||!Me(r)?c:Ol(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),Ip(this.data,l,s),a.silent||this.emit("added",t,n,r,s)}addResources(t,n,r,s={silent:!1}){for(const a in r)(Me(r[a])||Array.isArray(r[a]))&&this.addResource(t,n,a,r[a],{silent:!0});s.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,s,a,i={silent:!1,skipCopy:!1}){let l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),s=r,r=n,n=l[1]),this.addNamespaces(n);let c=ea(this.data,l)||{};i.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?E0(c,r,a):c={...c,...r},Ip(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 I0={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 A0=Symbol("i18next/PATH_KEY");function ZO(){const e=[],t=Object.create(null);let n;return t.get=(r,s)=>(n?.revoke?.(),s===A0?e:(e.push(s),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function kr(e,t){const{[A0]:n}=e(ZO()),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 Pp={},Di=e=>!Me(e)&&typeof e!="boolean"&&typeof e!="number";class na extends qa{constructor(t,n={}){super(),FO(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Ut.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=Di(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&&!WO(t,r,s);if(i&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:Me(a)?[a]:a};const d=t.split(r);(r!==s||r===s&&this.options.ns.indexOf(d[0])>-1)&&(a=d.shift()),t=d.join(s)}return{key:t,namespaces:Me(a)?[a]:a}}translate(t,n,r){let s=typeof n=="object"?{...n}:n;if(typeof s!="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),typeof s=="object"&&(s={...s}),s||(s={}),t==null)return"";typeof t=="function"&&(t=kr(t,{...this.options,...s})),Array.isArray(t)||(t=[String(t)]),t=t.map(R=>typeof R=="function"?kr(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&&!Me(s.count),k=na.hasDefaultValue(s),C=N?this.pluralResolver.getSuffix(p,s.count,s):"",E=s.ordinal&&N?this.pluralResolver.getSuffix(p,s.count,{ordinal:!1}):"",P=N&&!s.ordinal&&s.count===0,I=P&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${C}`]||s[`defaultValue${E}`]||s.defaultValue;let z=g;v&&!g&&k&&(z=I);const A=Di(z),O=Object.prototype.toString.apply(z);if(v&&z&&A&&y.indexOf(O)<0&&!(Me(w)&&Array.isArray(z))){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const R=this.options.returnedObjectHandler?this.options.returnedObjectHandler(b,z,{...s,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(m.res=R,m.usedParams=this.getUsedParamsDetails(s),m):R}if(i){const R=Array.isArray(z),M=R?[]:{},D=R?x:b;for(const L in z)if(Object.prototype.hasOwnProperty.call(z,L)){const T=`${D}${i}${L}`;k&&!g?M[L]=this.translate(T,{...s,defaultValue:Di(I)?I[L]:void 0,joinArrays:!1,ns:c}):M[L]=this.translate(T,{...s,joinArrays:!1,ns:c}),M[L]===T&&(M[L]=z[L])}g=M}}else if(v&&Me(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 L=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&M?void 0:g,T=k&&I!==g&&this.options.updateMissing;if(M||R||T){if(this.logger.log(T?"updateKey":"missingKey",p,d,l,T?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 B=[];const F=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&F&&F[0])for(let H=0;H<F.length;H++)B.push(F[H]);else this.options.saveMissingTo==="all"?B=this.languageUtils.toResolveHierarchy(s.lng||this.language):B.push(s.lng||this.language);const j=(H,$,V)=>{const G=k&&V!==g?V:L;this.options.missingKeyHandler?this.options.missingKeyHandler(H,d,$,G,T,s):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(H,d,$,G,T,s),this.emit("missingKey",H,d,$,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?B.forEach(H=>{const $=this.pluralResolver.getSuffixes(H,s);P&&s[`defaultValue${this.options.pluralSeparator}zero`]&&$.indexOf(`${this.options.pluralSeparator}zero`)<0&&$.push(`${this.options.pluralSeparator}zero`),$.forEach(V=>{j([H],l+V,s[`defaultValue${V}`]||I)})}):j(B,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=Me(t)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let d;if(c){const p=t.match(this.interpolator.nestingRegexp);d=p&&p.length}let f=r.replace&&!Me(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=Me(i)?[i]:i;return t!=null&&l?.length&&r.applyPostProcessor!==!1&&(t=I0.handle(l,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t,n={}){let r,s,a,i,l;return Me(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(c=>typeof c=="function"?kr(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&&!Me(n.count),m=h&&!n.ordinal&&n.count===0,g=n.context!==void 0&&(Me(n.context)||typeof n.context=="number")&&n.context!=="",b=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);p.forEach(x=>{this.isValidLookup(r)||(l=x,!Pp[`${b[0]}-${x}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(Pp[`${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`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(h&&(n.ordinal&&N.indexOf(C)===0&&w.push(f+N.replace(C,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(C)===0&&w.push(E+N.replace(C,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&&!Me(t.replace);let s=r?t.replace:t;if(r&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!r){s={...s};for(const a of n)delete s[a]}return s}static hasDefaultValue(t){const n="defaultValue";for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&n===r.substring(0,n.length)&&t[r]!==void 0)return!0;return!1}}class _p{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ut.create("languageUtils")}getScriptPartFromCode(t){if(t=Co(t),!t||t.indexOf("-")<0)return null;const n=t.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(t){if(t=Co(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(Me(t)&&t.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(t)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let n;return t.forEach(r=>{if(n)return;const s=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(s))&&(n=s)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const s=this.getScriptPartFromCode(r);if(this.isSupportedCode(s))return n=s;const a=this.getLanguagePartFromCode(r);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(i=>{if(i===a)return i;if(!(i.indexOf("-")<0&&a.indexOf("-")<0)&&(i.indexOf("-")>0&&a.indexOf("-")<0&&i.substring(0,i.indexOf("-"))===a||i.indexOf(a)===0&&a.length>1))return i})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),Me(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}toResolveHierarchy(t,n){const r=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],t),s=[],a=i=>{i&&(this.isSupportedCode(i)?s.push(i):this.logger.warn(`rejecting language code not found in supportedLngs: ${i}`))};return Me(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(t))):Me(t)&&a(this.formatLanguageCode(t)),r.forEach(i=>{s.indexOf(i)<0&&a(this.formatLanguageCode(i))}),s}}const $p={zero:0,one:1,two:2,few:3,many:4,other:5},Dp={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class XO{constructor(t,n={}){this.languageUtils=t,this.options=n,this.logger=Ut.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,n={}){const r=Co(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!"),Dp;if(!t.match(/-|_/))return Dp;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)=>$p[s]-$p[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 Lp=(e,t,n,r=".",s=!0)=>{let a=VO(e,t,n);return!a&&s&&Me(n)&&(a=Ol(e,n,r),a===void 0&&(a=Ol(t,n,r))),a},Li=e=>e.replace(/\$/g,"$$$$");class Tp{constructor(t={}){this.logger=Ut.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:UO,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=a?zn(a):i||"{{",this.suffix=l?zn(l):c||"}}",this.formatSeparator=d||",",this.unescapePrefix=f?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=h?zn(h):m||zn("$t("),this.nestingSuffix=g?zn(g):b||zn(")"),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=Lp(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(Lp(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=>Li(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?Li(this.escape(m)):Li(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=Me(x)?x:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))i="";else if(p){i=a[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`),i="";else!Me(i)&&!this.useRawValueToEscape&&(i=Cp(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(`${zn(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&&!Me(i.replace)?i.replace:i,i.applyPostProcessor=!1,delete i.defaultValue;const d=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(d!==-1&&(c=s[1].slice(d).split(this.formatSeparator).map(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&&!Me(a))return a;Me(a)||(a=Cp(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 JO=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}},Rp=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(Co(r),s),t[i]=l),l(n)}},e8=e=>(t,n,r)=>e(Co(n),r)(t);class t8{constructor(t={}){this.logger=Ut.create("formatter"),this.options=t,this.init(t)}init(t,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?Rp:e8;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()]=Rp(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}=JO(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 n8=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class r8 extends qa{constructor(t,n,r,s={}){super(),this.backend=t,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=s,this.logger=Ut.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=>{HO(c.loaded,[a],i),n8(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();Me(t)&&(t=this.languageUtils.toResolveHierarchy(t)),Me(n)&&(n=[n]);const a=this.queueLoad(t,n,r,s);if(!a.toLoad.length)return a.pending.length||s(),null;a.toLoad.forEach(i=>{this.loadOne(i)})}load(t,n,r){this.prepareLoading(t,n,{},r)}reload(t,n,r){this.prepareLoading(t,n,{reload:!0},r)}loadOne(t,n=""){const r=t.split("|"),s=r[0],a=r[1];this.read(s,a,"read",void 0,void 0,(i,l)=>{i&&this.logger.warn(`${n}loading namespace ${a} for language ${s} failed`,i),!i&&l&&this.logger.log(`${n}loaded namespace ${a} for language ${s}`,l),this.loaded(t,i,l)})}saveMissing(t,n,r,s,a,i={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...i,isUpdate:a},d=this.backend.create.bind(this.backend);if(d.length<6)try{let 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 Ti=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),Me(e[1])&&(t.defaultValue=e[1]),Me(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(r=>{t[r]=n[r]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),Op=e=>(Me(e.ns)&&(e.ns=[e.ns]),Me(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),Me(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),typeof e.initImmediate=="boolean"&&(e.initAsync=e.initImmediate),e),bs=()=>{},o8=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})},P0="__i18next_supportNoticeShown",s8=()=>!!(typeof globalThis<"u"&&globalThis[P0]||typeof process<"u"&&$i&&$i.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&$i),a8=()=>{typeof globalThis<"u"&&(globalThis[P0]=!0)},i8=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 fo extends qa{constructor(t={},n){if(super(),this.options=Op(t),this.services={},this.logger=Ut,this.modules={external:[]},o8(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(t={},n){this.isInitializing=!0,typeof t=="function"&&(n=t,t={}),t.defaultNS==null&&t.ns&&(Me(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const r=Ti();this.options={...r,...this.options,...Op(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&&!i8(this)&&!s8()&&(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 💙"),a8());const s=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Ut.init(s(this.modules.logger),this.options):Ut.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=t8;const f=new _p(this.options);this.store=new Ap(this.options.resources,this.options);const p=this.services;p.logger=Ut,p.resourceStore=this.store,p.languageUtils=f,p.pluralResolver=new XO(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 Tp(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new r8(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 na(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=bs),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=Xr(),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=bs){let r=n;const s=Me(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(s?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const a=[],i=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(d=>{d!=="cimode"&&a.indexOf(d)<0&&a.push(d)})};s?i(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>i(c)),this.options.preload?.forEach?.(l=>i(l)),this.services.backendConnector.load(a,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(t,n,r){const s=Xr();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=bs),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"&&I0.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=Xr();this.emit("languageChanging",t);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},a=(l,c)=>{c?this.isLanguageChangingTo===t&&(s(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...d)=>this.t(...d)),n&&n(l,(...d)=>this.t(...d))},i=l=>{!t&&!l&&this.services.languageDetector&&(l=[]);const c=Me(l)?l:l&&l[0],d=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(Me(l)?[l]:l);d&&(this.language||s(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector?.cacheUserLanguage?.(d)),this.loadResources(d,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=kr(c.keyPrefix,d));const f=this.options.keySeparator||".";let p;return c.keyPrefix&&Array.isArray(a)?p=a.map(h=>(typeof h=="function"&&(h=kr(h,d)),`${c.keyPrefix}${f}${h}`)):(typeof a=="function"&&(a=kr(a,d)),p=c.keyPrefix?`${c.keyPrefix}${f}${a}`:a),this.t(p,c)};return Me(t)?s.lng=t:s.lngs=t,s.ns=n,s.keyPrefix=r,s}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const i=(l,c)=>{const d=this.services.backendConnector.state[`${l}|${c}`];return d===-1||d===0||d===2};if(n.precheck){const l=n.precheck(this,i);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(r,t)&&(!s||i(a,t)))}loadNamespaces(t,n){const r=Xr();return this.options.ns?(Me(t)&&(t=[t]),t.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{r.resolve(),n&&n(s)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=Xr();Me(t)&&(t=[t]);const s=this.options.preload||[],a=t.filter(i=>s.indexOf(i)<0&&this.services.languageUtils.isSupportedCode(i));return a.length?(this.options.preload=s.concat(a),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return"rtl";try{const s=new Intl.Locale(t);if(s&&s.getTextInfo){const a=s.getTextInfo();if(a&&a.direction)return a.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new _p(Ti());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 fo(t,n);return r.createInstance=fo.createInstance,r}cloneInstance(t={},n=bs){const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},a=new fo(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 Ap(l,s),a.services.resourceStore=a.store}if(t.interpolation){const c={...Ti().interpolation,...this.options.interpolation,...t.interpolation},d={...s,interpolation:c};a.services.interpolator=new Tp(d)}return a.translator=new na(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=fo.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 l8=(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);tr(s[0])&&(s[0]=`react-i18next:: ${s[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...s):console?.warn&&console.warn(...s)},Bp={},Bl=(e,t,n,r)=>{tr(n)&&Bp[n]||(tr(n)&&(Bp[n]=new Date),l8(e,t,n,r))},_0=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}},zl=(e,t,n)=>{e.loadNamespaces(t,_0(e,n))},zp=(e,t,n,r)=>{if(tr(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return zl(e,n,r);n.forEach(s=>{e.options.ns.indexOf(s)<0&&e.options.ns.push(s)}),e.loadLanguages(t,_0(e,r))},c8=(e,t,n={})=>!t.languages||!t.languages.length?(Bl(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}}),tr=e=>typeof e=="string",d8=e=>typeof e=="object"&&e!==null,u8=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,p8={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},f8=e=>p8[e],h8=e=>e.replace(u8,f8);let Fl={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:h8,transDefaultProps:void 0};const m8=(e={})=>{Fl={...Fl,...e}},g8=()=>Fl;let $0;const b8=e=>{$0=e},x8=()=>$0,y8={type:"3rdParty",init(e){m8(e.options.react),b8(e)}},v8=Be();class w8{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var D0={exports:{}},L0={};/**
1111
- * @license React
1112
- * use-sync-external-store-shim.production.js
1113
- *
1114
- * Copyright (c) Meta Platforms, Inc. and affiliates.
1115
- *
1116
- * This source code is licensed under the MIT license found in the
1117
- * LICENSE file in the root directory of this source tree.
1118
- */var Ar=Hh;function N8(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var k8=typeof Object.is=="function"?Object.is:N8,S8=Ar.useState,C8=Ar.useEffect,M8=Ar.useLayoutEffect,E8=Ar.useDebugValue;function I8(e,t){var n=t(),r=S8({inst:{value:n,getSnapshot:t}}),s=r[0].inst,a=r[1];return M8(function(){s.value=n,s.getSnapshot=t,Ri(s)&&a({inst:s})},[e,n,t]),C8(function(){return Ri(s)&&a({inst:s}),e(function(){Ri(s)&&a({inst:s})})},[e]),E8(n),n}function Ri(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!k8(e,n)}catch{return!0}}function A8(e,t){return t()}var P8=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?A8:I8;L0.useSyncExternalStore=Ar.useSyncExternalStore!==void 0?Ar.useSyncExternalStore:P8;D0.exports=L0;var T0=D0.exports;const _8=(e,t)=>{if(tr(t))return t;if(d8(t)&&tr(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},$8={t:_8,ready:!1},D8=()=>()=>{},zt=(e,t={})=>{const{i18n:n}=t,{i18n:r,defaultNS:s}=ve(v8)||{},a=n||r||x8();a&&!a.reportNamespaces&&(a.reportNamespaces=new w8),a||Bl(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const i=Q(()=>({...g8(),...a?.options?.react,...t}),[a,t]),{useSuspense:l,keyPrefix:c}=i,d=s||a?.options?.defaultNS,f=tr(d)?[d]:d||["translation"],p=Q(()=>f,f);a?.reportNamespaces?.addUsedNamespaces?.(p);const h=ne(0),m=q(I=>{if(!a)return D8;const{bindI18n:z,bindI18nStore:A}=i,O=()=>{h.current+=1,I()};return z&&a.on(z,O),A&&a.store.on(A,O),()=>{z&&z.split(" ").forEach(R=>a.off(R,O)),A&&A.split(" ").forEach(R=>a.store.off(R,O))}},[a,i]),g=ne(),b=q(()=>{if(!a)return $8;const I=!!(a.isInitialized||a.initializedStoreOnce)&&p.every(D=>c8(D,a,i)),z=t.lng||a.language,A=h.current,O=g.current;if(O&&O.ready===I&&O.lng===z&&O.keyPrefix===c&&O.revision===A)return O;const M={t:a.getFixedT(z,i.nsMode==="fallback"?p:p[0],c),ready:I,lng:z,keyPrefix:c,revision:A};return g.current=M,M},[a,p,c,i,t.lng]),[x,y]=_(0),{t:w,ready:v}=T0.useSyncExternalStore(m,b,b);Y(()=>{if(a&&!v&&!l){const I=()=>y(z=>z+1);t.lng?zp(a,t.lng,p,I):zl(a,p,I)}},[a,t.lng,p,v,l,x]);const N=a||{},k=ne(null),C=ne(),E=I=>{const z=Object.getOwnPropertyDescriptors(I);z.__original&&delete z.__original;const A=Object.create(Object.getPrototypeOf(I),z);if(!Object.prototype.hasOwnProperty.call(A,"__original"))try{Object.defineProperty(A,"__original",{value:I,writable:!1,enumerable:!1,configurable:!1})}catch{}return A},P=Q(()=>{const I=N,z=I?.language;let A=I;I&&(k.current&&k.current.__original===I?C.current!==z?(A=E(I),k.current=A,C.current=z):A=k.current:(A=E(I),k.current=A,C.current=z));const O=!v&&!l?(...M)=>(Bl(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=[O,A,v];return R.t=O,R.i18n=A,R.ready=v,R},[w,N,v,N.resolvedLanguage,N.language,N.languages]);if(a&&l&&!v)throw new Promise(I=>{const z=()=>I();t.lng?zp(a,t.lng,p,z):zl(a,p,z)});return P},Fp={info:Jn,success:s0,warning:ut,error:Xn},L8={info:"text-blue-400",success:"text-green-400",warning:"text-amber-400",error:"text-red-400"},jp={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 T8(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 Hp({alert:e,onMarkRead:t,onDismiss:n}){const r=e.severity in Fp?e.severity:"info",s=e.status in jp?e.status:"active",a=Fp[r],i=L8[r],l=jp[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:T8(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(ze,{className:"h-3 w-3 text-foreground-subtle"})})]})]})}function Vp({variant:e="icon",compact:t=!1}={}){const[n,r]=_(!1),[s,a]=_(!1),i=ne(null),l=ne(null),c=ke(),{data:d=0}=eb(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=tb({onSuccess:g}),x=nb({onSuccess:g}),y=rb({onSuccess:g});pt("alert.created",()=>{c.invalidateQueries({queryKey:[["alerts"]]})}),pt("alert.updated",()=>{c.invalidateQueries({queryKey:[["alerts"]]})}),Y(()=>{if(!n)return;const I=z=>{const A=z.target;i.current&&!i.current.contains(A)&&l.current&&!l.current.contains(A)&&r(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[n]);const w=q(I=>{b.mutate({alertId:I})},[b]),v=q(I=>{I&&y.mutate({alertId:I})},[y]),N=q(()=>{x.mutate(void 0),r(!1)},[x]),k=h.filter(I=>I.status==="in-progress"),C=h.filter(I=>I.status!=="in-progress"),[E,P]=_({});return Y(()=>{if(n&&l.current){const I=l.current.getBoundingClientRect();P({position:"fixed",left:I.left,bottom:window.innerHeight-I.top+4,zIndex:9999})}},[n]),u("div",{children:[e==="sidebar"?u("button",{ref:l,type:"button",onClick:()=>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(rt,{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(rt,{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&&Oo(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(jT,{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(Se,{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(rt,{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(Hp,{alert:I,onMarkRead:w,onDismiss:v},I.id))]}),C.map(I=>o(Hp,{alert:I,onMarkRead:w,onDismiss:v},I.id))]})]}),document.body)]})}function R0(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 qp=new Map,xs=new Map,Up=new Set;function R8(e){return!e||typeof e!="object"?!1:typeof e.default=="function"}async function O8(e,t){const n=qp.get(e);if(n)return n;const r=xs.get(e);if(r)return r;Up.has(e)||(mc(),Mr.registerRemotes([{name:e,entry:t,type:"module"}],{force:!1}),Up.add(e));const s=Mr.loadRemote(`${e}/page`).then(a=>{if(!R8(a))throw new Error(`Addon page remote ${e} (${t}) does not expose a default React component on './page'`);return qp.set(e,a.default),xs.delete(e),a.default}).catch(a=>{throw xs.delete(e),a});return xs.set(e,s),s}function B8(){const{pagePath:e}=kd(),t=De(),{data:n}=Ea(void 0,{staleTime:6e4}),r=Q(()=>n?R0(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 O8(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 z8={dark:f0,light:j6,system:YR},F8={gauge:c0,puzzle:So,bot:$T,cpu:ft,terminal:v0,box:za,wrench:tO,activity:Qo,plug:ko};function j8(){const e=bt(),t=et(),{user:n,logout:r}=Jt(),s=Br(),{t:a}=zt(),i=dr(),l=tg(),c=pT(),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 $=window.localStorage.getItem("camstack:sidebar-collapsed-groups");if(!$)return new Set;const V=JSON.parse($);return Array.isArray(V)?new Set(V.filter(G=>typeof G=="string")):new Set}catch{return new Set}});Y(()=>{typeof window>"u"||window.localStorage.setItem("camstack:sidebar-collapsed-groups",JSON.stringify([...b]))},[b]),Y(()=>{l&&window.localStorage.getItem("camstack:sidebar-collapsed")===null&&g(!0)},[l]);const{data:y=[]}=Uc(void 0,{staleTime:3e4,refetchInterval:3e4}),w=y.length,v=ke(),N=ne(Date.now()),k=3e4,C=2e3,{data:E}=Ea(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:$=>{const V=$.state.data;return V&&V.length>0||Date.now()-N.current>=k?!1:C}}),P=Q(()=>E&&n?.isAdmin?R0(E):[],[E,n?.isAdmin]);pt("addon.page-ready",()=>{v.invalidateQueries({queryKey:[["addonPages","listPages"]]})});const I=()=>{r(),t("/login")},z=$=>!!(e.pathname===$||e.pathname.startsWith($+"/")),O=["/pipeline","/timeline"].some($=>e.pathname===$||e.pathname.startsWith($+"/")),R=n?.isAdmin===!0,M=[{label:a("nav.devices","Devices"),icon:Ir,path:"/devices"},{label:a("nav.integrations"),icon:ko,path:"/integrations"},{label:a("nav.timeline","Timeline"),icon:tR,path:"/timeline"},{label:a("nav.pipeline","Pipeline"),icon:yR,path:"/pipeline"}].filter(Boolean),L=[{label:a("system.identity","Identity & Access"),icon:Dd,path:"/system/identity",adminOnly:!0},{label:a("system.network","Network"),icon:Wt,path:"/system/network",adminOnly:!0},{label:a("system.integrations","Integrations"),icon:ko,path:"/system/integrations",adminOnly:!0},{label:a("system.data","Data"),icon:i0,path:"/system/data",adminOnly:!0},{label:a("system.cluster","Cluster"),icon:En,path:"/system/cluster",adminOnly:!0},{label:a("system.addons"),icon:So,path:"/system/addons",adminOnly:!0},{label:a("system.addonSettings","Addon Settings"),icon:Yt,path:"/system/settings",adminOnly:!0},{label:a("system.logs","Logs"),icon:rt,path:"/system/logs",adminOnly:!0}].filter($=>!$.adminOnly||R),T=s?.mode??"system",B={dark:a("theme.dark"),light:a("theme.light"),system:a("theme.system")},F=m&&!i,j=($,V="md")=>`flex w-full items-center gap-2.5 rounded-md ${F?"justify-center px-0 py-2":"px-2.5 py-1.5"} ${V==="lg"?"text-[13px] font-medium":"text-[12px]"} transition-all ${$?V==="lg"?"bg-primary/12 text-primary shadow-sm shadow-primary/5":"bg-primary/12 text-primary":"text-foreground-subtle hover:bg-surface-hover hover:text-foreground"}`,H=u(me,{children:[u("div",{className:`flex h-14 items-center border-b border-border ${F?"justify-center px-1":"pl-3 pr-4 gap-2"}`,children:[!F&&o("img",{src:s?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack Admin",className:"h-9 flex-1 min-w-0"}),!i&&o("button",{onClick:()=>g($=>!$),className:`p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle transition-colors flex-shrink-0 ${F?"":"mr-2"}`,"aria-label":m?"Expand sidebar":"Collapse sidebar",title:m?"Expand sidebar":"Collapse sidebar",children:m?o(Et,{className:"h-4 w-4"}):o(_d,{className:"h-4 w-4"})})]}),u("nav",{className:`flex-1 overflow-y-auto py-3 ${F?"px-1.5":"px-2"} space-y-0.5`,children:[(()=>{const $=z("/dashboard");return u("button",{"data-testid":"nav-dashboard",onClick:()=>{t("/dashboard"),h(!1)},className:j($,"lg"),title:F?a("nav.dashboard"):void 0,children:[o(p0,{className:`h-4 w-4 shrink-0 ${$?"text-primary":""}`}),!F&&a("nav.dashboard")]})})(),!F&&o("div",{className:"pt-4 pb-1.5 px-2.5",children:o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("nav.camerasSection","Cameras")})}),F&&o("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),M.map($=>{const V=$.icon,G=z($.path),Z=`nav-${$.path.replace(/^\//,"").replace(/\//g,"-")}`;return u("button",{"data-testid":Z,onClick:()=>{t($.path),h(!1)},className:j(G),title:F?$.label:void 0,children:[o(V,{className:`h-3.5 w-3.5 shrink-0 ${G?"text-primary":""}`}),!F&&$.label]},$.path)}),!F&&o("div",{className:"pt-4 pb-1.5 px-2.5",children:o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("system.title")})}),F&&o("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),L.map($=>{const V=$.icon,G=z($.path),Z=$.path==="/system/addons",oe=`nav-${$.path.replace(/^\//,"").replace(/\//g,"-")}`;return u("button",{"data-testid":oe,onClick:()=>{t($.path),h(!1)},className:j(G),title:F?$.label:void 0,children:[o(V,{className:`h-3.5 w-3.5 shrink-0 ${G?"text-primary":""}`}),!F&&u(me,{children:[o("span",{className:"flex-1 text-left",children:$.label}),Z&&w>0&&o("span",{className:"ml-auto rounded-full bg-primary px-1.5 py-0.5 text-[9px] font-bold text-primary-foreground leading-none",children:w})]}),F&&Z&&w>0&&o("span",{className:"absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary"})]},$.path)}),P&&P.length>0&&!F&&o("div",{className:"pt-4 pb-1.5 px-2.5",children:o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("nav.addonPages","Addon Pages")})}),F&&P&&P.length>0&&o("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),P?.map($=>{const V=z($.path),G=F8[$.icon]??So;return u("button",{onClick:()=>{t($.path),h(!1)},className:j(V),title:F?$.label:void 0,children:[o(G,{className:`h-3.5 w-3.5 shrink-0 ${V?"text-primary":""}`}),!F&&$.label]},$.id)})]}),u("div",{className:`border-t border-border ${F?"p-1.5":"p-2"} space-y-0.5`,children:[u("button",{onClick:()=>s?.toggleMode(),className:j(!1),title:F?B[T]:void 0,children:[(()=>{const $=z8[T];return o($,{className:"h-3.5 w-3.5 shrink-0"})})(),!F&&o("span",{children:B[T]})]}),o(Vp,{variant:"sidebar",compact:F}),u("button",{type:"button",onClick:()=>t("/system/my-access"),className:j(z("/system/my-access")),title:F?a("system.myAccess","My access"):void 0,children:[o(pn,{className:"h-3.5 w-3.5 shrink-0"}),!F&&o("span",{className:"truncate",children:a("system.myAccess","My access")})]}),u("button",{onClick:I,className:j(!1).replace("hover:text-foreground","hover:text-danger"),title:F?n?.username??"Logout":void 0,children:[o(Ld,{className:"h-3.5 w-3.5 shrink-0"}),!F&&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 ${F?"w-12":"w-48"}`,children:H}),i&&o(Ac,{open:p,onClose:()=>h(!1),width:"w-64",children:H}),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(N0,{className:"h-3.5 w-3.5"}),o("span",{children:f?a("connection.reconnecting","Reconnecting…"):a("connection.disconnected","Server unreachable — reconnecting…")}),o(Se,{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(UR,{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(Vp,{})]}),u("main",{className:`relative flex-1 min-h-0 bg-background ${O?"overflow-hidden":"overflow-auto"}`,children:[d&&o("div",{className:"absolute inset-0 z-40 bg-background/60 backdrop-blur-[2px]"}),o(SL,{})]})]})]})}function H8(){const{login:e,verifyTotp:t}=Jt(),n=Br(),r=et(),[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 P=await e(s,i);if(P.kind==="totp-required"){y(P.challengeToken),b("totp");return}r(i==="changeme"?"/change-password":"/dashboard",{replace:!0})}catch(P){p(P instanceof Error?P.message:"Login failed")}finally{m(!1)}},k=async E=>{E.preventDefault(),p(""),m(!0);try{await t(x,w.trim()),r("/dashboard",{replace:!0})}catch(P){p(P instanceof Error?P.message:"TOTP verification failed"),v("")}finally{m(!1)}},C=()=>{b("credentials"),y(""),v(""),p("")};return o("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children: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(l0,{className:"h-4 w-4"}):o(Wo,{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(Sn,{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:C,className:"w-full flex items-center justify-center gap-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors",children:[o(Pd,{className:"h-3 w-3"}),"Back to username + password"]})]}),g==="credentials"&&o(V8,{}),o("p",{className:"mt-6 text-center text-[10px] text-foreground-subtle/50",children:"CamStack v0.1.0"})]})})}function V8(){const t=(Gc().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(pn,{className:"h-4 w-4 text-primary"}),n.displayName]},s)})})]})}const Qp=8;function q8(){const{user:e,mustChangePassword:t,clearMustChangePassword:n,logout:r}=Jt(),s=Br(),a=et(),[i,l]=_(""),[c,d]=_(""),[f,p]=_(!1),[h,m]=_(""),g=id({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<Qp){m(`Password must be at least ${Qp} 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(l0,{className:"h-4 w-4"}):o(Wo,{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 U8(){const e=et();return u("div",{className:"flex flex-col items-center justify-center text-foreground py-16 px-4",children:[o("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-danger/10 mb-4",children:o(P6,{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 O0="camstack:dashboard-layout",Oi={version:1,widgets:[]};function Q8(){try{const e=localStorage.getItem(O0);if(!e)return Oi;const t=JSON.parse(e);return t&&t.version===1&&Array.isArray(t.widgets)?{version:1,widgets:t.widgets}:Oi}catch{return Oi}}function G8(e){try{localStorage.setItem(O0,JSON.stringify(e))}catch{}}function K8(){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 W8(){const[e,t]=_(Q8),[n,r]=_(!1),s=xy(),a=Q(()=>s.filter(d=>d.hosts.includes("dashboard")),[s]),i=q(d=>{t(d),G8(d)},[]),l=q(d=>{i({version:1,widgets:[...e.widgets,d]})},[e,i]),c=q(d=>{i({version:1,widgets:e.widgets.filter(f=>f.instanceId!==d)})},[e,i]);return u("div",{className:"p-4",children:[u("div",{className:"flex items-center justify-between mb-4",children:[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(ot,{className:"h-3.5 w-3.5"}),"Add widget"]})]}),e.widgets.length===0?o(Y8,{onAdd:()=>r(!0)}):o("div",{className:"grid grid-cols-12 gap-3 auto-rows-[minmax(80px,_auto)]",children:e.widgets.map(d=>o(Z8,{entry:d,onRemove:()=>c(d.instanceId)},d.instanceId))}),n&&o(J8,{widgets:a,onClose:()=>r(!1),onAdd:d=>{l(d),r(!1)}})]})}function Y8({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(p0,{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(ot,{className:"h-3.5 w-3.5"}),"Add your first widget"]})]})}function Z8({entry:e,onRemove:t}){const n=X8(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(ze,{className:"h-3 w-3"})}),o("div",{className:"flex-1 min-h-0 overflow-auto p-2",children:o(lt,{widgetId:e.widgetId,host:"dashboard",instanceId:e.instanceId,config:e.config,deviceId:e.deviceId,size:e.size,columns:e.columns,rows:e.rows})})]})}function X8(e){return!Number.isFinite(e)||e<1?6:Math.min(12,Math.floor(e))}function J8({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(ze,{className:"h-4 w-4"})})]}),r===null?o(e9,{widgets:e,onSelect:s}):o(t9,{widget:r,onCancel:()=>s(null),onAdd:n})]})})}function e9({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 t9({widget:e,onCancel:t,onAdd:n}){const[r,s]=_(e.defaultSize),[a,i]=_(e.defaultColumns),[l,c]=_(e.defaultRows),[d,f]=_(null),{data:p}=Ln({},{enabled:e.requires.deviceContext,staleTime:3e4}),h=!e.requires.deviceContext||d!==null&&d>0,m=()=>{if(!h)return;const g={instanceId:K8(),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(Gp,{label:"Columns (1-12)",value:a,min:1,max:12,onChange:i}),o(Gp,{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 Gp({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 n9(){return o(W8,{})}function Xe({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 Kp=["camera","hub","nvr","light","siren","switch","sensor","thermostat","button","generic"];function r9(){const{t:e}=zt(),t=et(),n=De();vt(["deviceManager"],["device.registered","device.unregistered","device.online","device.offline","device.disabled","device.enabled"]),vt(["integrations"],["integration.enabled","integration.disabled","integration.deleted","provider.started","provider.stopped","addon.installed","addon.uninstalled","addon.started","addon.stopped"]);const{data:r}=Ln({},{staleTime:3e4}),{data:s}=Jc(void 0,{staleTime:3e4}),a=Q(()=>r??[],[r]),{activeDevices:i,orphanDevices:l}=Q(()=>{const m=new Set((s??[]).map(k=>k.addonId)),g=k=>typeof k.addonId=="string"&&k.addonId.length>0&&!m.has(k.addonId),b=new Set;for(const k of a)g(k)&&b.add(k.id);const x=new Set(b),y=new Map;for(const k of a)y.set(k.id,k);const w=(k,C=0)=>{if(C>32)return!1;if(b.has(k.id))return!0;if(k.parentDeviceId==null)return!1;const E=y.get(k.parentDeviceId);return E?w(E,C+1):!1};for(const k of a)w(k)&&x.add(k.id);const v=[],N=[];for(const k of a)x.has(k.id)?N.push(k):v.push(k);return{activeDevices:v,orphanDevices:N}},[a,s]),c=Q(()=>{const m=new Map;for(const g of a)m.set(g.id,{id:g.id,name:g.name??g.stableId??`#${String(g.id)}`});return m},[a]),d=q(m=>c.get(m)??null,[c]),f=Q(()=>(s??[]).map(m=>({id:m.addonId,name:m.name??m.addonId,icon:o(fn,{type:m.addonId,size:"sm"})})),[s]),p=q(m=>o(fn,{type:m,size:"sm"}),[]),h=q(m=>t(`/devices/${String(m)}`),[t]);return u(Xe,{icon:Ir,title:e("nav.devices","Devices"),children:[o(wo,{devices:i,trpc:n.trpcClient,filters:{types:Kp,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(ut,{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(wo,{devices:l,trpc:n.trpcClient,filters:{types:Kp,addons:f},urlScope:"nested",lsKey:"devices:orphan",resolveIntegrationIcon:p,resolveParent:d,onNavigate:h})]})]})]})}function o9({onSelect:e,onClose:t,pendingAddonId:n=null}){const{t:r}=zt(),s=et(),{data:a,isLoading:i}=Rb();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(Se,{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(Yt,{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 s9(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Wp(e,t){if(e!==void 0)return t&&s9(e)?t(e):e}function a9({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+(ld(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:Wp(e.title,s)}),e.description&&o("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:Wp(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(pr,{field:b,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i?.[b.key],allFields:e.fields,onAction:l},b.key))})]})}function In({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(a9,{section:f,values:t,onChange:d,disabled:r,translationFn:s,onTestField:a,probeResults:i,onAction:c},`${f.id}-${p}`))})}function i9({addonId:e,configSchema:t,onSave:n,onBack:r}){const{t:s}=zt(),[a,i]=_(""),[l,c]=_({}),[d,f]=_(null),p=Ob({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(In,{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 l9({providerId:e,onImport:t,onSkip:n}){const{t:r}=zt(),[s,a]=_(new Set),i=Zc(),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(Ir,{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 c9(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 d9({open:e,onClose:t}){const{t:n}=zt(),r=et(),s=ke(),[a,i]=_("picker"),[l,c]=_(null),[d,f]=_(null),[p,h]=_("manual"),{data:m}=Qc({addonId:l??"",nodeId:"hub"},{enabled:l!=null}),g=Q(()=>m?c9(m):null,[m]),b=Db({onSuccess:()=>s.invalidateQueries({queryKey:[["integrations"]]})}),x=Zc(),y=x.data;Y(()=>{a!=="discovery"||!d||!l||x.isPending||x.data||x.mutate({addonId:l})},[a,d,l,x]);const w=Ib({onSuccess:()=>s.invalidateQueries({queryKey:[["deviceManager"]]})});async function v(R,M,D,L){if(!b.isPending){if(c(R),h(D),M==="unique"){try{const T=await b.mutateAsync({addonId:R,name:L,settings:{}});t(),E(),r(`/integrations/${T.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"):C(M.id)}catch{}}async function k(R){if(l){for(const M of R){const D=y?.find(L=>L.stableId===M);D&&await w.mutateAsync({addonId:l,candidate:D})}C()}}function C(R){const M=R??d??l;t(),E(),M&&r(`/integrations/${M}`)}function E(){i("picker"),c(null),f(null),h("manual")}function P(){t(),E()}if(!e)return null;const I={picker:n("integrations.newIntegration"),config:n("integrations.configureIntegration"),discovery:n("integrations.importDevices")},z=b.isPending,A=z?l:null,O=b.error;return u("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[o("div",{className:"absolute inset-0 bg-black/60",onClick:z?void 0:P}),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:P,disabled:z,className:"rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:o(ze,{className:"h-4 w-4"})})]}),u("div",{className:"relative px-5 py-4",children:[O&&!z&&o("div",{className:"mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:O instanceof Error?O.message:String(O)}),a==="picker"&&o(o9,{onSelect:v,onClose:P,pendingAddonId:A}),a==="config"&&l&&o(i9,{addonId:l,configSchema:g??null,onSave:N,onBack:()=>i("picker")}),a==="discovery"&&d&&o(l9,{providerId:d,onImport:k,onSkip:C}),z&&u("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background/85 backdrop-blur-sm",children:[o(Se,{className:"h-6 w-6 animate-spin text-primary"}),o("p",{className:"text-xs font-medium text-foreground",children:n("integrations.creating",{defaultValue:"Creating integration…"})}),o("p",{className:"text-[10px] text-foreground-subtle",children:n("integrations.creatingHint",{defaultValue:"Waiting for the addon to restart and register"})})]})]})]})]})}const Yp={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 Ua({status:e}){const t=Yp[e]??Yp.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 Bi="px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle";function u9({integrations:e,expandedAddonId:t,onToggleExpand:n,onOpenSettings:r,renderExpanded:s}){const a=q(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(Bi,"w-[60%]"),children:"Integration"}),o("th",{className:W(Bi,"w-[15%]"),children:"Devices"}),o("th",{className:W(Bi,"w-[25%]"),children:"Status"})]})}),o("tbody",{children:e.map(i=>{const l=t===i.addonId;return o(p9,{integration:i,isExpanded:l,onClick:a,onOpenSettings:r,renderExpanded:s},i.id)})})]})})}function p9({integration:e,isExpanded:t,onClick:n,onOpenSettings:r,renderExpanded:s}){const a=q(c=>{c.stopPropagation(),r(e.id)},[e.id,r]),i=q(()=>{n(e.addonId)},[e.addonId,n]),l=q(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(Nt,{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(fn,{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(Ua,{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(Yt,{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 f9(e){if(!e.enabled)return"disabled";switch(e.processState){case"running":return"running";case"stopped":case"crashed":case"unknown":default:return"stopped"}}const ys="expand";function h9(){const{t:e}=zt(),t=et(),n=De(),[r]=Ba(),[s,a]=_(!1),i=q(()=>a(!0),[]),l=q(()=>a(!1),[]);vt(["integrations"],["integration.enabled","integration.disabled","integration.deleted","provider.started","provider.stopped","addon.installed","addon.uninstalled","addon.started","addon.stopped","addon.updated"]),vt(["deviceManager"],["device.registered","device.unregistered","device.online","device.offline","device.disabled","device.enabled"]);const{data:c,isLoading:d,refetch:f}=Jc(void 0,{staleTime:3e4}),{data:p,isLoading:h,refetch:m}=Ln({},{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 L=M.addonId??"";L&&R.set(L,(R.get(L)??0)+1)}return R},[g]),w=Q(()=>b.map(R=>({id:R.id,addonId:R.addonId,name:R.name,enabled:R.enabled,status:f9(R),deviceCount:y.get(R.addonId)??0})),[b,y]),v=r.get(ys),N=q(R=>{const M=new URLSearchParams(window.location.search);M.get(ys)===R?M.delete(ys):M.set(ys,R);const L=M.toString(),T=`${window.location.pathname}${L?`?${L}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",T),window.dispatchEvent(new PopStateEvent("popstate"))},[]),k=q(R=>t(`/integrations/${R}`),[t]),C=q(R=>x.get(R)??null,[x]),E=q(R=>o(fn,{type:R,size:"sm"}),[]),P=q(R=>t(`/devices/${String(R)}`),[t]),I=q(R=>o(wo,{devices:g,trpc:n.trpcClient,forceAddon:R,urlScope:"nested",lsKey:`integrations:nested:${R}`,resolveIntegrationIcon:E,resolveParent:C,onNavigate:P}),[g,n.trpcClient,E,C,P]),z=q(()=>{f(),m()},[f,m]),A=d||h,O=b.length>0;return u(Xe,{icon:ko,title:e("nav.integrations","Integrations"),actions:u(me,{children:[o("button",{onClick:z,disabled:A,className:"flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",title:"Refresh",children:o(ht,{className:W("h-3.5 w-3.5",A&&"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(ot,{className:"h-3.5 w-3.5"}),"New Integration"]})]}),children:[A&&o("div",{className:"space-y-2",children:[1,2,3].map(R=>o("div",{className:"h-12 rounded-lg border border-border bg-surface animate-pulse"},R))}),!A&&!O&&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.'})]}),!A&&O&&o(u9,{integrations:w,expandedAddonId:v,onToggleExpand:N,onOpenSettings:k,renderExpanded:I}),o(d9,{open:s,onClose:l})]})}function B0(e){const t=[];for(const n of e)n.type==="probe"&&t.push(n.key),n.type==="group"&&"fields"in n&&t.push(...B0(n.fields));return t}function m9(e,t,n){const[r,s]=_("idle"),[a,i]=_({}),l=Q(()=>{const p=[];for(const h of e.sections)p.push(...B0(h.fields));return p},[e]),c=l.length>0&&n!==void 0,d=q(p=>{i(h=>{if(!h[p])return h;const m={...h};return delete m[p],m})},[]),f=q(async()=>{if(!n)return;const p=l.filter(b=>{const x=t[b];return x!=null&&String(x).trim()!==""});if(p.length===0)return;s("testing");const 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 z0(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(...z0(n.fields));return t}function zi(e){return e==null?!0:typeof e=="string"?e.trim()==="":!1}function jl(e,t={}){for(const n of e){if(n.type==="group"&&"fields"in n){jl(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 g9({open:e,integrationId:t,addonId:n,onClose:r}){const{t:s}=zt(),a=ke(),[i,l]=_({}),[c,d]=_(!1),[f,p]=_(null),[h,m]=_(Zp),g=Ab({addonId:n,type:it.Camera},{enabled:e}),b=g.data??null;Y(()=>{if(e){const M=b?jl(b.sections.flatMap(D=>D.fields)):{};l(M),m(Zp()),d(!1),p(null)}},[e,t,b]);const x=Q(()=>({...i,_probeRequestId:h}),[i,h]),y=Pb({onSuccess:()=>{a.invalidateQueries({queryKey:[["deviceManager"]]})}}),w=Xc(),v=q(async(M,D)=>{d(!0);const L=await w.mutateAsync({addonId:n,type:it.Camera,key:M,value:D,formValues:x});return L.status==="ok"&&L.suggestedValues&&l(T=>{let B=!1;const F={...T};for(const[j,H]of Object.entries(L.suggestedValues??{}))zi(T[j])&&!zi(H)&&(F[j]=H,B=!0);return B?F:T}),L},[w,n,x]),{testAllStatus:N,hasProbeFields:k,probeResults:C,handleTestAll:E,clearProbeResult:P}=m9(b??{sections:[]},i,v);async function I(M){p(null);try{if(await y.mutateAsync({addonId:n,type:it.Camera,config:i}),M){const D=b?jl(b.sections.flatMap(L=>L.fields)):{};l(D)}else r()}catch(D){p(D instanceof Error?D.message:String(D))}}if(!e)return null;const A=z0((b?.sections??[]).flatMap(M=>M.fields)).filter(M=>zi(i[M])),O=A.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(ze,{className:"h-4 w-4"})})]}),o("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-3",children:g.isLoading?o("div",{className:"flex items-center justify-center py-8",children:o(Se,{className:"h-5 w-5 animate-spin text-primary"})}):R?u("div",{className:"flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3",children:[o(ut,{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(In,{schema:b,values:i,onChange:l,onTestField:v,probeResults:C,onClearProbe:P})}),!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(rt,{className:"h-3.5 w-3.5"}),"Test logs",o("span",{className:"font-mono text-[9px] opacity-60",children:h.slice(0,14)})]}),o(Nt,{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(Xt,{addonId:n,requestId:h,limit:50,maxHeight:"max-h-64",showFilters:!1,showScope:!1,className:"border-0 rounded-none"})})]}),!R&&!g.isLoading&&(f||A.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(ut,{className:"h-3.5 w-3.5 text-destructive mt-0.5 shrink-0"}),o("p",{className:"text-[11px] text-destructive",children:f||`Required: ${A.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(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(er,{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||!O||y.isPending,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:s("integrations.saveAndNew")}),o("button",{onClick:()=>I(!1),disabled:R||!O||y.isPending,className:"rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:y.isPending?s("integrations.saving"):s("integrations.save")})]})]})]})]})}function b9(){const{t:e}=zt(),{integrationId:t}=kd(),n=ke(),r=et(),s=De(),[a,i]=_(!1),[l,c]=_(!1),[d,f]=_(!1),[p,h]=_(!1),{data:m,isLoading:g}=_b({id:t??""},{enabled:!!t}),{data:b}=Qc({addonId:m?.addonId??"",nodeId:"hub"},{enabled:!!m?.addonId}),x=b!=null&&Array.isArray(b.sections)&&b.sections.some(O=>O.fields.length>0),{data:y}=Ln({},{refetchInterval:5e3}),w=[["integrations","get"],{input:{id:t??""},type:"query"}],v=Lb({onMutate:async O=>{await n.cancelQueries({queryKey:w});const R=n.getQueryData(w);return R!=null&&n.setQueryData(w,{...R,enabled:O.enabled}),{previous:R}},onError:(O,R,M)=>{const D=M;D?.previous!=null&&n.setQueryData(w,D.previous)},onSettled:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),N=Tb({onSuccess:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]}),f(!1),r("/integrations")}}),k=Ia({onSuccess:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),C=Q(()=>y??[],[y]),E=Q(()=>{const O=new Map;for(const R of C)O.set(R.id,{id:R.id,name:R.name??R.stableId??`#${String(R.id)}`});return O},[C]),P=q(O=>E.get(O)??null,[E]),I=q(O=>o(fn,{type:O,size:"sm"}),[]),z=q(O=>r(`/devices/${String(O)}`),[r]),A=Q(()=>{const O=m?.addonId;if(!O)return 0;let R=0;for(const M of C)M.addonId!==O||M.parentDeviceId!==null&&M.parentDeviceId!==void 0&&M.role||(R+=1);return R},[C,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(Pc,{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:O=>{O.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," · ",A," ",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(Sc,{checked:m.enabled,onCheckedChange:O=>v.mutate({id:t,enabled:O}),disabled:v.isPending,"aria-label":m.enabled?"Disable integration":"Enable integration"}),o("span",{className:`text-[11px] font-medium ${m.enabled?"text-success":"text-foreground-subtle"}`,children:m.enabled?"Enabled":"Disabled"}),v.isPending&&o(Se,{className:"h-3 w-3 animate-spin text-foreground-subtle"})]}),x&&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(Yt,{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(rt,{className:"h-3 w-3"}),e("integrations.logs",{defaultValue:"Logs"})]}),o($y,{label:"Restart",icon:ht,title:`Restart "${m.name}"?`,description:`Restarting the addon will briefly disconnect every device backed by it (${A} active). Streams will reconnect automatically.`,confirmLabel:"Restart",triggerVariant:"outline",confirmVariant:"danger",disabled:k.isPending,action:()=>k.mutateAsync({addonId:m.addonId})}),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(Ke,{className:"h-3 w-3"}),e("integrations.delete",{defaultValue:"Delete"})]})]})]}),o(wo,{devices:C,trpc:s.trpcClient,defaultView:"cards",forceAddon:m.addonId,urlScope:"root",lsKey:`integration-detail:${m.addonId}`,resolveIntegrationIcon:I,resolveParent:P,onNavigate:z}),o("button",{onClick:()=>i(!0),className:"fixed bottom-6 right-6 flex h-12 w-12 items-center justify-center rounded-full bg-primary shadow-lg shadow-primary/30 hover:shadow-primary/40 transition-shadow",title:e("integrations.addDevice"),children:o(ot,{className:"h-5 w-5 text-primary-foreground"})}),a&&t&&o(g9,{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:O=>O.stopPropagation(),children:[o("h2",{className:"text-sm font-semibold text-foreground mb-2",children:e("integrations.providerConfig")}),o("p",{className:"text-[11px] text-foreground-subtle",children:e("integrations.configComingSoon")}),o("button",{onClick:()=>c(!1),className:"mt-4 w-full rounded-lg bg-primary px-3 py-1.5 text-[11px] text-primary-foreground hover:bg-primary/90 transition-colors",children:"Close"})]})}),p&&o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6",onClick:()=>h(!1),children:u("div",{className:"flex flex-col rounded-xl border border-border bg-surface shadow-xl w-full max-w-5xl h-[80vh]",onClick:O=>O.stopPropagation(),children:[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(rt,{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(ze,{className:"h-4 w-4"})})]}),o("div",{className:"flex-1 min-h-0 overflow-hidden",children:o(Xt,{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:O=>O.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(ut,{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:A})})]})]}),N.error&&o("div",{className:"rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger",children:N.error instanceof Error?N.error.message:String(N.error)}),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(Se,{className:"h-3 w-3 animate-spin"}),e("integrations.deleting",{defaultValue:"Deleting…"})]}):u(me,{children:[o(Ke,{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(w6,{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(Pd,{className:"h-3 w-3"}),e("integrations.backToList",{defaultValue:"Back to integrations"})]})]})}function x9({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 Fi=36e5;function y9(e){return String(e).padStart(2,"0")}function v9(e){const t=new Date(e);return`${y9(t.getHours())}:00`}function w9({startMs:e,endMs:t,segments:n,events:r,playheadMs:s,onSeek:a}){const i=ne(null),l=t-e,c=q(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/Fi),h=Math.ceil(t/Fi);for(let m=p;m<=h;m++){const g=m*Fi;g<e||g>t||f.push({percent:c(g),label:v9(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(x9,{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 Xp={person:"#f59e0b",vehicle:"#3b82f6",car:"#3b82f6",face:"#a855f7",plate:"#ec4899",animal:"#10b981",motion:"#ef4444",unknown:"#6b7280"};function Hl(e){return Xp[e.toLowerCase()]??Xp.unknown}function N9(e){const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function k9(e){return new Date(e).toISOString().slice(0,10)}function S9(e){return new Date(e+"T00:00:00").getTime()}function C9(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 M9(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:Hl(t[r%t.length])})).sort((n,r)=>n.timestampMs-r.timestampMs)}function E9(){const{t:e}=zt(),t=N9(new Date),[n,r]=_(t),[s,a]=_(null),[i,l]=_(t+12*36e5),c=n,d=n+24*36e5,{data:f,isLoading:p}=Ln({},{staleTime:3e4}),h=f??[],m=Q(()=>h.filter(N=>{const k=N.type.toLowerCase();return k==="camera"||k.includes("camera")||N.features.some(C=>C.toLowerCase().includes("video")||C.toLowerCase().includes("stream"))}).map(N=>({id:N.id,name:N.name??N.stableId})),[h]),g=s??m[0]?.id??null,{data:b}=Pn({queryKey:["events",g,c],queryFn:()=>Promise.resolve(null),enabled:!!g,staleTime:6e4}),x=Q(()=>{const v=Array.isArray(b)?b:(()=>{const k=bu(b)?.events;return Array.isArray(k)?k:[]})();return v.length===0?g?M9(c):[]:v.flatMap((N,k)=>{const C=bu(N);if(!C)return[];const E=String(C.class??C.type??C.label??"unknown").toLowerCase(),P=typeof C.timestamp=="number"?C.timestamp:c;return[{id:String(C.id??k),timestampMs:P,label:E,color:Hl(E)}]})},[b,g,c]),y=Q(()=>g?C9(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(_d,{className:"h-4 w-4"})}),u("div",{className:"relative flex items-center",children:[o(r0,{className:"absolute left-2 h-3.5 w-3.5 text-foreground-subtle pointer-events-none"}),o("input",{type:"date",value:k9(n),onChange:v=>{if(v.target.value){const N=S9(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(uo,{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:Hl(v)}}),o("span",{className:"text-[10px] text-foreground-subtle capitalize",children:v})]},v))]}),g?o(w9,{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 I9({selectedNodeId:e,onSelect:t,refreshToken:n}){const{data:r}=Tn(void 0,{staleTime:3e4}),{data:s}=Pa(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(ho),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===ho?"bg-primary/10 text-primary":"text-foreground hover:bg-surface-hover"}`,children:[o(Wt,{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?un:ft;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(w0,{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 A9({nodeId:e,refreshToken:t}){const{data:n}=Tn(void 0,{staleTime:3e4}),r=n?.find(i=>i.id===e),a=zr("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 F0({refreshToken:e,nodeId:t}){const[n,r]=_(new Map),{nodes:s}=Fr();pt("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}=Cx(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(Ht,{label:"FPS",value:p?p.totalFps.toFixed(1):"—"}),o(Ht,{label:"Cameras",value:p?`${p.activeCameras}/${p.attachedCameras}`:"—"}),o(Ht,{label:"Avg infer ms",value:p&&p.attachedCameras>0?(p.totalInferenceWeighted/p.attachedCameras).toFixed(0):"—"}),o(Ht,{label:"Queue",value:p?String(p.queueDepth):"—"}),o(Ht,{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(Ht,{label:"Total agents",value:`${d.onlineAgents}/${d.totalAgents}`}),o(Ht,{label:"Cameras",value:`${d.activeCameras}/${d.attachedCameras}`}),o(Ht,{label:"Total FPS",value:d.totalFps.toFixed(1)}),o(Ht,{label:"Avg inference ms",value:d.avgInferenceTimeMs.toFixed(0)}),o(Ht,{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 Ht({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 j0(e){return Ln({addonId:e})}function P9(e){return Yn({deviceId:e},{enabled:Number.isFinite(e)})}const _9=3e4,$9=2e3;function H0(e){const t=ne(0);return t.current===0&&(t.current=Date.now()),vb({parentDeviceId:e},{enabled:Number.isFinite(e),staleTime:0,refetchOnMount:"always",refetchInterval:n=>{const r=n.state.data;return r&&r.length>0||Date.now()-t.current>=_9?!1:$9}})}const ji={active:!1,pinned:!1,nodeId:null,reason:""},Hi=["pipeline.camera-assigned","pipeline.camera-unassigned","pipeline.camera-updated","agent.online","agent.offline"],D9={pipeline:ft,decoder:uo,audio:Rl},Jp={pipeline:"Pipeline",decoder:"Decoder",audio:"Audio"};function V0({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);vt(["pipelineOrchestrator","getPipelineAssignments"],Hi),vt(["pipelineOrchestrator","getDecoderAssignments"],Hi),vt(["pipelineOrchestrator","getAudioAssignments"],Hi);const{data:f}=Pa(void 0,{staleTime:3e4}),{data:p}=Nx(void 0,{staleTime:3e4}),{data:h}=Mx(void 0,{staleTime:3e4}),{nodes:m}=Fr(),{data:g}=j0();pt("pipeline.camera-metrics-snapshot",A=>{const O=A.data;typeof O.deviceId=="number"&&d(R=>{const M=new Map(R);return M.set(O.deviceId,O),M})}),Y(()=>{if(c.size===0)return;const A=setInterval(()=>{d(O=>{const R=Date.now()-1e4;let M=!1;const D=new Map(O);for(const[L,T]of O)T.timestamp<R&&(D.delete(L),M=!0);return M?D:O})},5e3);return()=>clearInterval(A)},[c.size]);const b=Q(()=>{const A=new Map;for(const O of g??[])A.set(O.id,O.name);return A},[g]),x=Q(()=>{const A=new Map,O=M=>{const D=A.get(M);if(D)return D;const L={deviceId:M,deviceName:b.get(M)??`Device ${M}`,pipeline:ji,decoder:ji,audio:ji};return A.set(M,L),L};for(const M of f??[]){const D=O(M.deviceId);A.set(M.deviceId,{...D,pipeline:{active:e==="cluster"?!0:M.agentNodeId===t,pinned:M.pinned,nodeId:M.agentNodeId,reason:M.reason??""}})}for(const M of p??[]){const D=O(M.deviceId);A.set(M.deviceId,{...D,decoder:{active:e==="cluster"?!0:M.decoderNodeId===t,pinned:M.pinned,nodeId:M.decoderNodeId,reason:M.reason??""}})}for(const M of h??[]){const D=O(M.deviceId);A.set(M.deviceId,{...D,audio:{active:e==="cluster"?!0:M.nodeId===t,pinned:M.pinned,nodeId:M.nodeId,reason:"capacity"}})}let R=[...A.values()];return e==="agent"&&(R=R.filter(M=>M.pipeline.active||M.decoder.active||M.audio.active)),R.sort((M,D)=>M.deviceId-D.deviceId),R},[f,p,h,b,e,t]),y=Q(()=>(m??[]).filter(A=>A.isOnline).map(A=>({id:A.id,name:A.name})),[m]),w=()=>{r.invalidateQueries({queryKey:[["pipelineOrchestrator","getPipelineAssignments"]]}),r.invalidateQueries({queryKey:[["pipelineOrchestrator","getDecoderAssignments"]]}),r.invalidateQueries({queryKey:[["pipelineOrchestrator","getAudioAssignments"]]})},v=hx({onSuccess:w}),N=mx({onSuccess:w}),k=vx({onSuccess:w}),C=wx({onSuccess:w}),E=kx({onSuccess:w}),P=Sx({onSuccess:w}),I=(A,O,R)=>{O==="pipeline"?v.mutate({deviceId:A,agentNodeId:R}):O==="decoder"?k.mutate({deviceId:A,nodeId:R}):E.mutate({deviceId:A,nodeId:R}),a(null)},z=(A,O)=>{O==="pipeline"?N.mutate({deviceId:A}):O==="decoder"?C.mutate({deviceId:A}):P.mutate({deviceId:A}),a(null)};return o("div",{className:"rounded-lg border border-border overflow-x-auto",children: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(A=>{const O=c.get(A.deviceId),R=i===A.deviceId;return u(uc.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:A.deviceId),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle","aria-label":R?"Collapse broker details":"Expand broker details",children:R?o(Nt,{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:A.deviceName}),u("div",{className:"text-[10px] text-foreground-subtle leading-tight",children:["#",A.deviceId]})]}),o(Vi,{role:"pipeline",state:A.pipeline,mode:e,deviceId:A.deviceId,onlineNodes:y,isMenuOpen:s?.deviceId===A.deviceId&&s.role==="pipeline",onToggleMenu:()=>a(s?.deviceId===A.deviceId&&s.role==="pipeline"?null:{deviceId:A.deviceId,role:"pipeline"}),onCloseMenu:()=>a(null),onMove:M=>I(A.deviceId,"pipeline",M),onUnpin:()=>z(A.deviceId,"pipeline")}),o(Vi,{role:"decoder",state:A.decoder,mode:e,deviceId:A.deviceId,onlineNodes:y,isMenuOpen:s?.deviceId===A.deviceId&&s.role==="decoder",onToggleMenu:()=>a(s?.deviceId===A.deviceId&&s.role==="decoder"?null:{deviceId:A.deviceId,role:"decoder"}),onCloseMenu:()=>a(null),onMove:M=>I(A.deviceId,"decoder",M),onUnpin:()=>z(A.deviceId,"decoder")}),o(Vi,{role:"audio",state:A.audio,mode:e,deviceId:A.deviceId,onlineNodes:y,isMenuOpen:s?.deviceId===A.deviceId&&s.role==="audio",onToggleMenu:()=>a(s?.deviceId===A.deviceId&&s.role==="audio"?null:{deviceId:A.deviceId,role:"audio"}),onCloseMenu:()=>a(null),onMove:M=>I(A.deviceId,"audio",M),onUnpin:()=>z(A.deviceId,"audio")}),o("td",{className:"px-3 py-2 align-middle",children:o(R9,{snap:O})})]}),R&&!n&&u("tr",{className:"bg-surface/50",children:[o("td",{}),o("td",{colSpan:5,className:"px-3 py-2",children:o(lt,{widgetId:"stream-broker/stream-broker-panel",host:"device-tab",deviceId:A.deviceId,instanceId:`pipeline-row/${A.deviceId}`,config:{variant:"compact",title:"Stream brokers & clients"}})})]})]},A.deviceId)}),x.length===0&&o("tr",{children:o("td",{colSpan:n?5:6,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:e==="agent"?"No cameras assigned to this node":"No cameras currently assigned"})})]})]})})}function Vi({role:e,state:t,mode:n,onlineNodes:r,isMenuOpen:s,onToggleMenu:a,onCloseMenu:i,onMove:l,onUnpin:c}){const d=D9[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(L9,{state:t,Icon:d}):o(T9,{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":`${Jp[e]} actions`,children:o(cR,{className:"h-3 w-3 text-foreground-subtle"})})})]}),s&&h&&o(O9,{title:Jp[e],targets:f,pinned:t.pinned,onMove:l,onUnpin:c,onClose:i})]})}function L9({state:e,Icon:t}){const n=e.active?y0:Yo;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(m0,{className:"h-2.5 w-2.5 text-amber-400"})]})}function T9({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(m0,{className:"h-2.5 w-2.5"})," manual"]}):u("span",{className:"text-foreground-subtle truncate",children:["auto · ",e.reason||"capacity"]})})]})]})}function R9({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=ir(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(pd,{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 O9({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 B9({nodeId:e,refreshToken:t}){return u("div",{className:"space-y-6",children:[o(F0,{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(V0,{mode:"agent",nodeId:e,compact:!0})]})}function z9(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 F9({nodeId:e,refreshToken:t}){const n=ke(),r=fx({onSettled:()=>{n.invalidateQueries({queryKey:["pipelineExecutor","listLoadedEngines"]})}}),{data:s}=px({nodeId:e},{staleTime:5e3}),i=zr("pipeline.engine-metrics-snapshot",h=>h.nodeId===e)?.engines??s??null,l=i===null;vt(["pipelineRunner","getLocalCameras"],["pipeline.camera-assigned","pipeline.camera-unassigned"]);const{data:c}=Tx({nodeId:e},{staleTime:3e4}),{values:d}=Rc("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(mR,{className:"h-3 w-3"}):o(ft,{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(Rd,{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:z9(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(Ke,{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 q0(e){return kt(e*1024*1024)}const j9=new Set(LN);function ef(e){return j9.has(e)}function qi(e,t,n){return`${e}/${t}/${n}`}function Vl(e){return{coreml:"CoreML",openvino:"OpenVINO",onnx:"ONNX"}[e.format]??e.format.toUpperCase()}function tf(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 Fn(e){return e.format}function H9(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 V9({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:q0(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(Xn,{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(Se,{className:"h-3 w-3 animate-spin"}):o(Ke,{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(Se,{className:"h-3 w-3 animate-spin"}):o(Mn,{className:"h-3 w-3"}),r?"Downloading...":"Download"]})]}):null}function q9({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(ft,{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:Vl(n)}),Fn(n)===Fn(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:tf(n)})]}),o(Nt,{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=Fn(i)===Fn(n),c=Fn(i)===Fn(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(ft,{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:Vl(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:tf(i)})]}),l&&o(s0,{className:"h-4 w-4 text-primary shrink-0"})]},Fn(i))})})]})}function U9({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=[]}=ix({nodeId:r},{staleTime:6e4}),x=g.filter((B,F,j)=>j.findIndex(H=>H.format===B.format)===F),{data:y}=lx({nodeId:r},{staleTime:3e4}),w=y,{data:v,isLoading:N}=Vo({nodeId:r},{staleTime:1e4}),k=dx(),C=ux();pt("model.download.progress",B=>{const F=B.data,j=typeof F.modelId=="string"?F.modelId:void 0,H=typeof F.progress=="number"?F.progress:void 0,$=typeof F.totalMB=="number"?F.totalMB:0;j===void 0||H===void 0||(d(V=>{const G=new Map(V);return H===100||H===-1?G.delete(j):G.set(j,{modelId:j,progress:H,totalMB:$}),G}),H===100&&n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]}))});const E=w??{runtime:"node",backend:"cpu",format:"onnx"},P=x.find(B=>B.format===s)??E,I=P.format,z=v?.slots??[],A=z.map(B=>({...B,addons:B.addons.map(F=>({...F,models:F.models.filter(j=>j.formats[I]!==void 0)})).filter(F=>F.models.length>0)})).filter(B=>B.addons.length>0),O=H9(A,I),R=q(async(B,F,j)=>{if(!ef(j))return;const H=qi(B,F,j);l($=>new Set([...$,H])),p($=>{const V=new Map($);return V.delete(H),V});try{await k.mutateAsync({addonId:B,modelId:F,format:j,nodeId:r}),n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]})}catch($){p(V=>new Map([...V,[H,$ instanceof Error?$.message:"Download failed"]]))}finally{l($=>{const V=new Set($);return V.delete(H),V})}},[k,n,r]),M=q(async(B,F,j)=>{if(!ef(j))return;const H=qi(B,F,j);l($=>new Set([...$,H])),p($=>{const V=new Map($);return V.delete(H),V});try{await C.mutateAsync({addonId:B,modelId:F,format:j,nodeId:r}),n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]})}catch($){p(V=>new Map([...V,[H,$ instanceof Error?$.message:"Delete failed"]]))}finally{l($=>{const V=new Set($);return V.delete(H),V})}},[C,n,r]),D=q(B=>{a(B.format)},[]),L=h.trim()?A.map(B=>({...B,addons:B.addons.map(F=>({...F,models:F.models.filter(j=>j.name.toLowerCase().includes(h.toLowerCase())||j.id.toLowerCase().includes(h.toLowerCase())||F.name.toLowerCase().includes(h.toLowerCase()))})).filter(F=>F.models.length>0)})).filter(B=>B.addons.length>0):A,T=u(me,{children:[N&&o("div",{className:"flex items-center justify-center py-16",children:o(Se,{className:"h-5 w-5 animate-spin text-foreground-subtle"})}),!N&&z.length===0&&u("div",{className:"flex flex-col items-center justify-center py-16 text-foreground-subtle",children:[o(Js,{className:"h-8 w-8 mb-3 opacity-30"}),o("span",{className:"text-sm",children:"No pipeline steps available"}),o("span",{className:"text-xs mt-1",children:"Configure the detection pipeline to see available models."})]}),!N&&z.length>0&&u(me,{children:[o(q9,{engines:x,activeEngine:E,viewEngine:P,onSelect:D}),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:O.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:O.downloaded}),o("span",{className:"ml-1",children:"downloaded"})]}),o("span",{className:"text-border",children:"|"}),u("span",{className:"tabular-nums",children:[q0(O.downloadedSizeMB),o("span",{className:"ml-1",children:"on disk"})]})]}),O.total>5&&u("div",{className:"relative",children:[o(x0,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle"}),o("input",{type:"text",value:h,onChange:B=>m(B.target.value),placeholder:"Search models...",className:"w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-border bg-surface text-foreground placeholder:text-foreground-subtle/50 focus:outline-none focus:ring-1 focus:ring-primary"})]}),L.map(B=>{const F=B.addons.reduce((H,$)=>H+$.models.length,0),j=B.addons.reduce((H,$)=>H+$.models.filter(V=>V.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:B.label}),o("div",{className:"flex-1 h-px bg-border"}),u("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[j,"/",F]})]}),o("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:B.addons.map(H=>H.models.map($=>{const V=qi(H.id,$.id,I);return o(V9,{addonId:H.id,model:$,format:I,isActive:i.has(V),progress:c.get($.id),errorMsg:f.get(V),onDownload:()=>R(H.id,$.id,I),onDelete:()=>M(H.id,$.id,I)},`${H.id}/${$.id}`)}))})]},B.id)}),L.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 ",Vl(P)," format"]})})]})]});return e?o("div",{className:"space-y-4",children:T}):o(Xe,{children:T})}function Q9({nodeId:e,refreshToken:t}){return o(U9,{embedded:!0,nodeId:e})}function U0({nodeId:e,title:t}){const{data:n}=j0(),{data:r}=Pa(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);pt("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=ir(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(pd,{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 Ui(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 G9({nodeId:e,refreshToken:t}){const n=ke(),[r,s]=_(null),[a,i]=_(null),l=Vo({nodeId:e},{refetchOnMount:"always"}),c=td({agentNodeId:e},{refetchOnMount:"always"}),d=nd({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?Sa(f):[],[f]),g=Q(()=>[{agentNodeId:e,engineLabel:h}],[e,h]),b=(C,E)=>{const P=p?.addonDefaults[C];return Ui(f,C)?.models.some(A=>!!A.formats[h])?P?P.enabled?{kind:"enabled",modelId:P.modelId}:{kind:"disabled"}:{kind:"na"}:{kind:"na"}},x=r&&f?Ui(f,r.addonId):null,y=C=>{const E=p?.addonDefaults[C]??null;s({addonId:C,agentNodeId:e}),i(E)},w=(C,E)=>{if(!p)return;const P=p.addonDefaults[C],I=Ui(f,C);if(!P&&!I)return;const z={enabled:E,modelId:P?.modelId??I?.defaultModelId??"",settings:P?.settings??{}};d.mutate({agentNodeId:e,defaults:{...p.addonDefaults,[C]:z}})},v=()=>{s(null),i(null)},N=()=>{!a||!r||!p||d.mutate({agentNodeId:e,defaults:{...p.addonDefaults,[r.addonId]:a}},{onSuccess:v})};if(l.isLoading||c.isLoading)return o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading pipeline…"});if(l.error)return 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(U0,{nodeId:e}),o("div",{className:k?"pr-[360px]":"",children:m.length>0?o(Dc,{tree:m,agents:g,getCellState:b,onCellClick:y,selectedCell:r,onToggleEnabled:w}):o("div",{className:"text-xs text-foreground-subtle",children:"Catalog empty."})}),o($c,{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(Ma,{mode:"agent",addon:x,agentDefault:a,agentNodeId:r.agentNodeId,engineFormat:h,onChangeAgentConfig:C=>i(C)})})]})}function Q0({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 G0({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 K9(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 K0({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=q(()=>{l(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>l(!1),2e3)},[]),m=q(y=>{h();const w={},v={},N={...t,...s};for(const[k,C]of Object.entries(y))N[k]!==C&&(K9(d,k)?w[k]=C:v[k]=C);Object.keys(w).length>0&&n(w),a(k=>{const C={...k};for(const E of Object.keys(w))delete C[E];for(const[E,P]of Object.entries(v))C[E]=P;return C})},[h,t,s,d,n]),g=q(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=q(y=>{a(w=>{const v={...w};for(const N of y)delete v[N];return v})},[]),x=q(()=>{a({})},[]);return{values:p,pendingKeys:Object.keys(s),hasPendingEdits:f,editingPaused:i,handleChange:m,handleSave:g,handleDiscard:b,resetAll:x}}const W9=qe(function({addonId:t,schema:n,serverValues:r,onImmediateSave:s,onStateChange:a,onAction:i,disabled:l},c){const d=K0({schema:n,serverValues:r,onImmediateSave:q(b=>s(t,b),[t,s]),onDeferredSave:q(()=>{},[])});CN(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(In,{schema:n,values:d.values,onChange:d.handleChange,disabled:l,onAction:g})});function W0(e,t){if(e.type==="separator"||e.type==="info"||e.type==="button")return e;if(e.type==="group"){const a=e.fields.map(i=>W0(i,t));return{...e,fields:a}}const n=e;t[e.key]=n.value;const{value:r,...s}=n;return s}function Y9(e,t){return{...e,fields:e.fields.map(n=>W0(n,t))}}function Z9(e){const t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(r=>Y9(r,t))},values:t}}function Gr({nodeId:e,addonIds:t,level:n,deviceId:r,sectionIds:s,sectionTab:a,extraTabs:i,title:l,description:c}){const d=ke(),f=De().trpcClient,p=Yg(),h=Zg(),m=cx(),g=fb(),b=ob(),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=IN({queries:t.map(J=>({queryKey:[["addonSettings",n==="global"?"getGlobalSettings":"getDeviceSettings"],{addonId:J,nodeId:v,deviceId:r??null}],queryFn:async()=>{if(n==="global"){const ee=await f.addonSettings.getGlobalSettings.query({addonId:J,nodeId:v});return{addonId:J,result:ee}}const K=await f.addonSettings.getDeviceSettings.query({addonId:J,deviceId:r,nodeId:v});return{addonId:J,result:K}},staleTime:3e4}))}),k=N.some(J=>J.isLoading),C=N.map(J=>{if(!J.data)return"-";if(J.data.result===null)return`${J.data.addonId}:n`;const K=[];for(const ee of J.data.result.sections){K.push(`s:${ee.id}:${ee.tab??"general"}`);for(const ae of ee.fields){if(!("key"in ae))continue;const fe="options"in ae&&Array.isArray(ae.options)?ae.options.map(ie=>ie.value).join(","):"",ge=ae.value,U=ge===void 0?"":typeof ge=="string"?ge:JSON.stringify(ge);K.push(`f:${ae.key}:${fe}:${U}`)}}return`${J.data.addonId}:${K.join("|")}`}).join("||"),E=Q(()=>{const J=new Set;for(const K of N){const ee=K.data?.result?.sections;if(ee)for(const ae of ee)J.add(ae.tab??"general")}return[...J]},[C+"::"+N.map(J=>(J.data?.result?.sections??[]).map(K=>K.tab??"general").join(",")).join("::")]),P=Q(()=>new Map((i??[]).map(J=>[J.id,J])),[i]),I=Q(()=>{if(!x)return[];const J=[...new Set([...E,...(i??[]).map(ee=>ee.id)])],K=ee=>{const ae=P.get(ee);if(ae?.order!==void 0)return ae.order;const fe=fl[ee];return fe?fe.order:50};return J.sort((ee,ae)=>{const fe=K(ee),ge=K(ae);return fe!==ge?fe-ge:ee.localeCompare(ae)})},[x,E,i,P]),z=Q(()=>{const J=new Map;for(const K of E){const ee=fl[K];J.set(K,ee?.label??K.charAt(0).toUpperCase()+K.slice(1))}for(const K of i??[])J.set(K.id,K.label);return J},[E,i]),A=x?y&&I.includes(y)?y:I[0]??null:null,O=A!==null&&P.has(A),R=x?A&&!O?A:void 0:a,{data:M}=Ho(void 0,{staleTime:6e4}),D=Q(()=>{const J=new Map;for(const K of M??[]){const ee=K.manifest?.id;if(!ee)continue;const ae=K.manifest?.name??K.manifest?.packageDisplayName??ee;J.set(ee,ae)}return J},[M]),L=Q(()=>{const J=s?new Set(s):null,K=[];for(const ee of N){if(!ee.data||ee.data.result===null)continue;const{schema:ae,values:fe}=Z9(ee.data.result),ge=ae.sections.filter(ue=>J?J.has(ue.id):!0);if(ge.length===0)continue;const U={...ee.data.result,sections:ee.data.result.sections.filter(ue=>J?J.has(ue.id):!0)},ie={...ae,sections:ge};K.push({addonId:ee.data.addonId,schemaWithValues:U,schema:ie,serverValues:fe})}return K},[C,s]),[T,B]=_(new Map),F=q(J=>{B(K=>{const ee=new Map(K);return ee.set(J.addonId,J),ee})},[]),j=ne(new Map),H=q(J=>K=>{K?j.current.set(J,K):j.current.delete(J)},[]),$=q(async(J,K)=>{n==="global"?await p.mutateAsync({addonId:J,nodeId:v,patch:K}):await h.mutateAsync({addonId:J,deviceId:r,nodeId:v,patch:K}),d.invalidateQueries({queryKey:[["addonSettings"]]})},[p,h,v,n,r,d]),V=q(async(J,K,ee,ae)=>{const fe=v;try{switch(K){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:J,action:K,input:ae});return d.invalidateQueries({queryKey:[["addonSettings"]]}),ge}}}catch(ge){throw console.error("[NodeAddonsSettingsPanel] action failed",{addonId:J,action:K,err:ge}),ge}},[m,g,b,v,d,f]),G=q((J,K)=>{$(J,K)},[$]),Z=qn({mutationFn:async()=>{const J=[];for(const ee of L){const ae=T.get(ee.addonId);!ae||ae.pendingKeys.length===0||J.push({addonId:ee.addonId,patch:ae.pendingValues})}return J.length===0?{saved:[]}:{saved:await Promise.all(J.map(async({addonId:ee,patch:ae})=>(n==="global"?await p.mutateAsync({addonId:ee,nodeId:v,patch:ae}):await h.mutateAsync({addonId:ee,deviceId:r,nodeId:v,patch:ae}),ee)))}},onSuccess:({saved:J})=>{for(const K of J)j.current.get(K)?.discard();d.invalidateQueries({queryKey:[["addonSettings"]]})}}),oe=q(()=>{for(const J of j.current.values())J.discard()},[]),te=Q(()=>{let J=0;for(const K of L){const ee=T.get(K.addonId);ee&&(J+=ee.pendingKeys.length)}return J},[L,T]),X=Q(()=>{const J=new Map;for(const K of L){const ee=T.get(K.addonId);if(!ee||ee.pendingKeys.length===0)continue;const ae=new Set(ee.pendingKeys);for(const fe of K.schema.sections){const ge=fe.tab??"general";for(const U of fe.fields)"key"in U&&ae.has(U.key)&&J.set(ge,(J.get(ge)??0)+1)}}return J},[L,T]);if(k)return o("div",{className:"h-24 rounded-lg border border-border bg-surface animate-pulse"});const re=A&&O?P.get(A):void 0;if(!x&&L.length===0)return 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=Z.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(G0,{tabs:I.map(J=>({id:J,label:z.get(J)??J})),activeId:A,onChange:w,pendingByTab:X}),Z.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(Z.error?.message??Z.error)]}),re?re.content:(()=>{const J=R?L.reduce((ae,fe)=>ae+fe.schemaWithValues.sections.filter(ge=>(ge.tab??"general")===R).length,0):0,K=R!==null&&J<=1,ee=L.map(ae=>({...ae,renderedWithValues:{...ae.schemaWithValues,sections:ae.schemaWithValues.sections.filter(fe=>R?(fe.tab??"general")===R:!0).map(fe=>K?{...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},U=ge(ae.renderedWithValues.sections),ie=ge(fe.renderedWithValues.sections);return U!==ie?U-ie:0});return ee.length===0?o("div",{className:"text-[11px] text-foreground-subtle italic",children:"Nothing to configure here for this node."}):o(X9,{entries:ee,paneStates:T,displayNames:D,disabled:be,setPaneRef:H,onPaneStateChange:F,onImmediateSave:G,onAction:V,inline:x||!!a})})(),!k&&o(Q0,{pendingCount:te,onSave:()=>Z.mutate(),onDiscard:oe,saving:be})]})}function X9({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(W9,{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 J9=["detection-pipeline","decoder-nodeav","audio-analyzer","pipeline-runner"];function e7({nodeId:e,refreshToken:t}){return u("div",{className:"flex flex-col h-full",children:[o(A9,{nodeId:e,refreshToken:t}),o("div",{className:"flex-1 min-h-0 overflow-y-auto p-6",children:o(Gr,{nodeId:e,addonIds:J9,level:"global",extraTabs:[{id:"assignments",label:"Assignments",order:-10,content:o(B9,{nodeId:e,refreshToken:t})},{id:"tree",label:"Pipeline",order:39,content:o(G9,{nodeId:e,refreshToken:t})},{id:"engines",label:"Warm instances",order:180,content:o(F9,{nodeId:e,refreshToken:t})},{id:"models",label:"Models",order:200,content:o(Q9,{nodeId:e,refreshToken:t})}]})})]})}function t7({refreshToken:e}){const t=ke(),n=gx({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(F0,{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(Rd,{className:"h-3.5 w-3.5"}),n.isPending?"Rebalancing…":"Rebalance pipelines"]})]}),o(V0,{mode:"cluster"})]})}const n7=["pipeline-orchestrator"];function r7({refreshToken:e}){return o("div",{className:"space-y-4 max-w-3xl",children:o(Gr,{nodeId:"hub",addonIds:n7,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 o7({refreshToken:e}){const t=ke(),{data:n,isLoading:r}=$x(),[s,a]=_(null),[i,l]=_(""),[c,d]=_(""),f=()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","listTemplates"]]})},p=Dx({onSuccess:()=>{a(null),f()}}),h=Lx({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(ot,{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(ze,{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(Ke,{className:"h-3 w-3"})})]})})]})},y.id)})})]})})}function nf(e,t){if(!e)return null;for(const n of e.slots)for(const r of n.addons)if(r.id===t)return r;return null}function s7({nodeId:e,refreshToken:t}){const n=ke(),r=De().trpcClient,[s,a]=_(null),[i,l]=_(null),c=Hr(void 0,{refetchOnMount:"always"});vt(["nodes","topology"],["agent.online","agent.offline","agent.unregistered","addon.installed","addon.uninstalled","addon.updated"]);const d=Tn(void 0,{staleTime:3e4,refetchOnMount:"always"}),f=Q(()=>{const I=new Set;for(const z of d.data??[])z.isOnline&&I.add(z.id);return I},[d.data]),p=Vo({nodeId:e},{refetchOnMount:"always"}),h=Q(()=>(c.data??[]).filter(I=>f.has(I.nodeId)).map(I=>I.nodeId),[c.data,f]),m=Pn({enabled:h.length>0,queryKey:[["pipelineExecutor","getSchema"],"schema-by-agent",h.join(","),t],queryFn:async()=>{const I={};for(const z of h)try{const A=await r.pipelineExecutor.getSchema.query({nodeId:z});I[z]=A.selectedEngine.format}catch{I[z]="coreml"}return I}}),g=nd({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator"]]}),n.invalidateQueries({queryKey:[["pipelineExecutor"]]}),n.invalidateQueries({queryKey:[["addonSettings"]]})}}),b=Q(()=>p.data?Sa(p.data):[],[p.data]),x=Q(()=>{const I=c.data??[],z=f;return(z.size===0?[]:I.filter(O=>z.has(O.nodeId))).map(O=>{const R=m.data?.[O.nodeId];return{agentNodeId:O.nodeId,engineLabel:R??"(engine unknown)"}})},[c.data,m.data,f]),y=(I,z)=>{const O=c.data?.find(L=>L.nodeId===z)?.settings.addonDefaults[I],R=m.data?.[z];return nf(p.data??null,I)?.models.some(L=>R!==void 0&&!!L.formats[R])?O?O.enabled?{kind:"enabled",modelId:O.modelId}:{kind:"disabled"}:{kind:"na"}:{kind:"na"}},w=s?c.data?.find(I=>I.nodeId===s.agentNodeId)??null:null,v=s&&p.data?nf(p.data,s.addonId):null,N=s?m.data?.[s.agentNodeId]??"coreml":"coreml",k=()=>{a(null),l(null)},C=(I,z)=>{const O=c.data?.find(R=>R.nodeId===z)?.settings.addonDefaults[I]??null;a({addonId:I,agentNodeId:z}),l(O)},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 P=s!==null&&v!==null&&i!==null;return u("div",{className:"relative h-full w-full space-y-3",children:[o(U0,{title:"Cluster cameras"}),o("div",{className:P?"pr-[360px]":"",children:b.length>0&&x.length>0?o(Dc,{tree:b,agents:x,getCellState:y,onCellClick:C,selectedCell:s}):o("div",{className:"text-xs text-foreground-subtle",children:"No agents or catalog empty."})}),o($c,{open:P,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(Ma,{mode:"agent",addon:v,agentDefault:i,agentNodeId:s.agentNodeId,engineFormat:N,onChangeAgentConfig:I=>l(I)})})]})}const a7=[{id:"assignments",label:"Assignments"},{id:"pipeline",label:"Pipeline"},{id:"settings",label:"Settings"},{id:"templates",label:"Templates"}];function i7({refreshToken:e}){const[t,n]=_("assignments"),{data:r}=Tn(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:a7.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(t7,{refreshToken:e}),t==="pipeline"&&(s?o(s7,{nodeId:s,refreshToken:e}):o("div",{className:"text-xs text-foreground-subtle",children:"No online node available — schema unreachable."})),t==="settings"&&o(r7,{refreshToken:e}),t==="templates"&&o(o7,{refreshToken:e})]})]})}const ho="__cluster__";function l7(){const[e,t]=Ba(),n=e.get("node")??ho,[r,s]=_(0);return Y(()=>{e.get("node")||t({node:ho},{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(ht,{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(I9,{selectedNodeId:n,onSelect:i=>{t({node:i},{replace:!0})},refreshToken:r})}),o("section",{className:"flex-1 min-h-0 overflow-hidden",children:n===ho?o(i7,{refreshToken:r}):o(e7,{nodeId:n,refreshToken:r})})]})]})}const c7="device-export",Qi="export",d7="Export";function ql(e){return e.type==="separator"||e.type==="info"||e.type==="object-array"||e.type==="widget"||e.type==="addon-action-button"?!1:e.type==="group"?e.fields.some(ql):e.type==="sub-tabs"?e.tabs.some(t=>t.fields.some(ql)):e.writerCapName===c7}function Mo(e){return e.fields.some(ql)}function u7(e){const[t,n]=_("idle"),[r,s]=_(null),a=ne(null),i=ne(null),l=ne(null),c=ne(!0),d=Bb(),f=zb(),p=Fb(),h=q(()=>{if(a.current){try{a.current.close()}catch{}a.current=null}if(i.current){for(const b of i.current.getTracks())try{b.stop()}catch{}i.current=null}l.current=null},[]),m=q(async()=>{if(t==="idle")return;n("stopping");const b=l.current;if(b&&e!==null)try{await Promise.race([p.mutateAsync({deviceId:e,sessionId:b}),new Promise((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=q(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 p7=0;function at(){return++p7}function Gi(e){switch(e.type){case"system":return"system";case"device":return`#${e.deviceId}`;case"provider":return e.providerId;case"addon":return e.addonId}}function f7(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 h7(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 m7(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 g7({scope:e,greeting:t,className:n}){const r=De(),[s,a]=_(()=>{const v=[];return t&&v.push({id:at(),kind:"info",text:t}),v.push({id:at(),kind:"info",text:`scope: ${Gi(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=q(()=>{h.current?.focus()},[]),b=qn({mutationFn:v=>r.trpcClient.repl.execute.mutate({code:v,scope:e}),onSuccess:v=>{const N=v??{},k=typeof N.output=="string"?N.output:v==null?"undefined":typeof v=="string"?v:JSON.stringify(v,null,2),C=N.type==="error";a(E=>[...E,{id:at(),kind:C?"error":"result",text:k}])},onError:v=>{const N=v instanceof Error?v.message:String(v);a(k=>[...k,{id:at(),kind:"error",text:N}])}});function x(v){const N=v.trim();if(N){if(N==="clear"){a([{id:at(),kind:"info",text:`scope: ${Gi(e)}`}]),l("");return}if(N==="help"){a(k=>[...k,{id:at(),kind:"input",text:`> ${N}`},...f7(e).map(C=>({id:at(),kind:"info",text:C}))]),l("");return}if(N==="context"){a(k=>[...k,{id:at(),kind:"input",text:`> ${N}`},...m7(e).map(C=>({id:at(),kind:"info",text:C}))]),l("");return}if(N==="examples"){a(k=>[...k,{id:at(),kind:"input",text:`> ${N}`},...h7(e).map(C=>({id:at(),kind:"info",text:C}))]),l("");return}d(k=>[...k,N]),p(-1),a(k=>[...k,{id:at(),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:at(),kind:"info",text:`scope: ${Gi(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 b7(e){const t=ke(),n=e!==null&&Number.isFinite(e),r=Rx({deviceId:e??0},{enabled:n,refetchInterval:5e3,retry:1}),s=Ox({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),a=Bx({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),i=q(async d=>{e!==null&&await s.mutateAsync({deviceId:e,enabled:d})},[e,s]),l=q(async d=>{e!==null&&await a.mutateAsync({deviceId:e,settings:d})},[e,a]),c=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 x7({deviceId:e}){const{status:t,isLoading:n,isPending:r,error:s,setEnabled:a,setSettings:i}=b7(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(Se,{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(sR,{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(Xn,{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 y7({deviceId:e,intercomAvailable:t=!1}){const n=De(),r=typeof window<"u"?window.location.origin:"",s=Number.isFinite(e),a=k0(s?e:null),{streams:i,pipelineMetrics:l,createSession:c,sendAnswer:d,closeSession:f}=xd(n.trpcClient,s?e:null),p=zc(n.trpcClient,s?e:null),h=u7(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=Ey(),y=x.length>0?o(me,{children:x.map(w=>o("div",{className:"absolute inset-0",children:w.node},w.id))}):null;return o(ud,{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 v7({deviceId:e}){return Number.isFinite(e)?o("div",{className:"flex flex-col h-full",children:o(Xt,{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 w7({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(`
1119
- `);return o(g7,{scope:{type:"device",deviceId:e},greeting:t,className:"h-full border-0 rounded-none"})}function N7({deviceId:e}){const t=De(),n=Number.isFinite(e),r=yd(t.trpcClient,n?e:0,{enabled:n}),{data:s}=P9(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(Un.PtzAutotrack);return u("div",{className:"flex flex-col h-full overflow-y-auto",children:[o(hd,{controls:r,mode:"panel"}),a&&o(x7,{deviceId:e})]})}function k7({deviceId:e}){return Number.isFinite(e)?o("div",{className:"flex flex-col h-full overflow-y-auto",children:o(fr,{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 S7({deviceId:e}){return Number.isFinite(e)?o("div",{className:"flex flex-col h-full overflow-y-auto",children:o(fd,{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 C7({parentDeviceId:e}){const{t}=zt(),n=et(),r=De(),{data:s,isLoading:a,isError:i}=H0(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(vo,{trpc:r.trpcClient,device:p,variant:"minimal",onNavigate:h=>n(`/devices/${String(h)}`)},p.id))})]})}function Ki(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function M7({device:e}){const t=et(),n=typeof e.id=="number"?e.id:null,r=String(e.type??""),s=r===it.Camera,a=r===it.Hub,i=e.features??[],{data:l}=ed({deviceId:n??0},{enabled:n!==null&&s,refetchInterval:5e3}),c=l?.streams??{},d=Object.entries(c),f=i.includes(Un.DoorbellButton),p=vd(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(_y,{deviceId:n,onOpenChild:m=>t(`/devices/${m}`)}),s&&n!==null&&o(lt,{widgetId:"pipeline-orchestrator/pipeline-quick-stats",host:"device-tab",deviceId:n}),f&&o(md,{history:p.history,latestIsFresh:h}),s&&n!==null&&o(lt,{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(er,{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(vs,{label:"Nominal",value:Ki(g.nominalBitrateKbps??0)}),o(vs,{label:"Observed",value:Ki(g.observedBitrateKbps??0)}),o(vs,{label:"Peak",value:Ki(g.peakBitrateKbps??0)}),o(vs,{label:"Packet Loss",value:`${(g.packetLossPercent??0).toFixed(2)}%`,warning:(g.packetLossPercent??0)>1})]})]},m))})]}),o(C0,{})]})}function vs({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 E7({schema:e,values:t,pendingKeys:n,onChange:r,onAction:s,onSave:a,onDiscard:i,disabled:l}){const c=e.tabs??[],d=Q(()=>{const k=new Map;for(const C of e.sections){const E=C.tab??"general",P=k.get(E)??[];P.push(C),k.set(E,P)}return k},[e.sections]),f=new Set(c.map(k=>k.id)),p=[...c,...[...d.keys()].filter(k=>!f.has(k)).map(k=>({id:k,label:k,icon:"wrench",order:100}))],h=p[0]?.id??"general",[m,g]=_(h),b=d.get(m)??[],y={sections:b.length<=1?b.length===1?[{...b[0],title:""}]:b:b.every(C=>!C.title)?[{...b[0],title:"",fields:b.flatMap(C=>C.fields)}]:b},w=o(Q0,{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(In,{schema:e,values:t,onChange:r,onAction:s,disabled:l}),w]});const v=new Map,N=new Map;for(const[k,C]of d){v.set(k,C.length);const E=new Set,P=z=>{for(const A of z)if("key"in A&&typeof A.key=="string"&&E.add(A.key),A.type==="group")P(A.fields);else if(A.type==="sub-tabs")for(const O of A.tabs)P(O.fields)};for(const z of C)P(z.fields);const I=n.filter(z=>E.has(z)).length;I>0&&N.set(k,I)}return u("div",{className:"flex flex-col gap-3",children:[o(G0,{tabs:p.map(k=>({id:k.id,label:k.label})),activeId:m,onChange:g,countByTab:v,pendingByTab:N}),o(In,{schema:y,values:t,onChange:r,onAction:s,disabled:l}),w]})}function I7(e,t){return t&&t==="admin"?e:!0}function A7(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):Mo(r)&&Mo(s)?r.id.localeCompare(s.id):(r.order??0)-(s.order??0)})};return e.tabs?{...n,tabs:e.tabs}:n}function Y0(e){return e.type==="separator"||e.type==="info"||e.type==="button"||e.type==="widget"||e.type==="addon-action-button"}function Z0(e){return e.key}function P7(e){if(!Y0(e))return e.value}function X0(e){return Y0(e)?null:e}function ra(e,t){for(const n of e)if(t(n),n.type==="group")ra(n.fields,t);else if(n.type==="sub-tabs")for(const r of n.tabs)ra(r.fields,t)}function _7(e){if(!e)return{};const t={};for(const n of e.sections)ra(n.fields,r=>{const s=Z0(r);s!==null&&(t[s]=P7(r))});return t}function rf(e,t){if(!e)return null;let n=null;for(const r of e.sections)if(ra(r.fields,s=>{if(n!==null||Z0(s)!==t)return;const a=X0(s);a&&a.writerCapName&&a.writerAddonId&&(n={capName:a.writerCapName,addonId:a.writerAddonId})}),n!==null)break;return n}function $7(e){return{...e,fields:e.fields.map(J0)}}function J0(e){return e.type==="separator"||e.type==="info"||e.type==="button"||e.type==="object-array"?e:{...e,readonlyField:!0}}function D7(e,t){return e&&{...e,sections:e.sections.map(n=>({...n,fields:n.fields.map(r=>{const s=X0(r);return s?I7(t,s.minRole)?r:J0(r):r})}))}}function Ul({deviceId:e,sectionFilter:t}){const n=ke(),{user:r}=Jt(),s=r?.isAdmin===!0,a=ne(!1),{data:i,isLoading:l}=Yc({deviceId:e},{refetchInterval:()=>a.current?!1:2500,staleTime:6e4,enabled:Number.isFinite(e)}),{data:c}=Yn({deviceId:e},{staleTime:6e4,enabled:Number.isFinite(e)}),d=i?.settings??null,f=i?.live??null,p=Q(()=>{if(!d&&!f)return null;const O=d?.sections??[],R=(f?.sections??[]).map($7),M=[...O,...R],D=t?M.filter(t):M.filter(F=>F.location!=="top-tab"&&!Mo(F));if(D.length===0)return null;const L=new Set;for(const F of D)L.add(F.tab??"general");const B=[...d?.tabs??[],...(f?.tabs??[]).filter(F=>!(d?.tabs??[]).some(j=>j.id===F.id))].filter(F=>L.has(F.id));return B.length>0?{tabs:B,sections:D}:{sections:D}},[d,f,t]),h=Q(()=>A7(p),[p]),m=Q(()=>D7(h,s),[h,s]),g=Q(()=>_7(m),[m]),b=Xx(),x=Xc(),y=Eb({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]})}}),w={isPending:y.isPending,mutate:O=>{y.mutate({deviceId:e,changes:[...O]})}},v=q(O=>{const R=Object.entries(O).map(([M,D])=>{const L=rf(m,M);return L?{writerCapName:L.capName,writerAddonId:L.addonId,key:M,value:D}:null}).filter(M=>M!==null);R.length>0&&w.mutate(R)},[m,w]),N=q(O=>{const R=Object.entries(O).map(([M,D])=>{const L=rf(m,M);return L?{writerCapName:L.capName,writerAddonId:L.addonId,key:M,value:D}:null}).filter(M=>M!==null);R.length>0&&w.mutate(R)},[m,w]),k=K0({schema:m,serverValues:g,onImmediateSave:v,onDeferredSave:N}),{values:C,pendingKeys:E,handleChange:P,handleSave:I,handleDiscard:z}=k;if(a.current=k.editingPaused,l)return u("div",{className:"flex items-center justify-center py-12 text-foreground-subtle",children:[o(Se,{className:"h-4 w-4 animate-spin mr-2"}),o("span",{className:"text-xs",children:"Loading device aggregate…"})]});if(!m||m.sections.length===0)return o("div",{className:"text-xs text-foreground-subtle italic py-4 text-center",children:"No aggregate contributions for this device."});async function A(O,R,M){if(O==="regenerate-rtsp-token"){const D=["rtspUrl:","regenerateToken:"].find(B=>R.startsWith(B));if(!D)throw new Error(`regenerate-rtsp-token: unrecognised key "${R}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);const L=R.slice(D.length);if(!L)throw new Error(`regenerate-rtsp-token: key "${R}" has no streamId after prefix`);const T=`${e}/${L}`;await b.mutateAsync({brokerId:T}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]});return}if(O==="test-probe"){if(!c)return{status:"error",error:"Device metadata not loaded yet"};try{return await x.mutateAsync({addonId:c.addonId,type:c.type,key:R,value:M})}catch(D){return{status:"error",error:D instanceof Error?D.message:String(D)}}}if(O==="refresh-driver-data"){await y.mutateAsync({deviceId:e,changes:[{writerCapName:"device-manager",writerAddonId:"device-manager",key:R,value:Date.now()}]});return}throw new Error(`[device-aggregate] unknown action "${O}"`)}return o(E7,{schema:m,values:C,pendingKeys:E,onChange:P,onAction:A,onSave:I,onDiscard:z,disabled:w.isPending})}function L7({deviceId:e}){return o(Ul,{deviceId:e})}const ev=6e4,Ql=60*ev,of=24*Ql;function Qa(e){if(e==null||e<=0)return"—";const t=Date.now()-e;return t<0||t<3e4?"just now":t<Ql?`${String(Math.floor(t/ev))}m ago`:t<of?`${String(Math.floor(t/Ql))}h ago`:`${String(Math.floor(t/of))}d ago`}function T7(e,t=new Date){const n=new Date(e);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()}function tv({dev:e,busy:t,setBusy:n}){const r=e?.motionTrigger,s=cn(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(Qo,{className:"h-3 w-3"}),o("span",{children:a?l?"Disabling…":"Enabling…":c?l?"On motion: on":"On motion: off":"On motion: …"})]})}function nv({deviceId:e,deviceName:t,useSiren:n=!1}){const r=De(),s=St(r.trpcClient,e),a=cn(s?.state.switch),[i,l]=_(!1),c=a?.on??!1,d=a?.lastChangedAt??null,f=a!==void 0,p=n?Go:g0,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(tv,{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 ${Qa(d)}`:"Awaiting state…"})]})]})}function R7({deviceId:e,deviceName:t}){const n=De(),r=St(n.trpcClient,e),s=cn(r?.state.switch),a=cn(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(DR,{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(tv,{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 ${Qa(l)}`:"Awaiting state…"})]})]})}function O7({deviceId:e}){const t=De(),n=St(t.trpcClient,e),r=cn(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(p6,{className:"h-10 w-10"}):o(Qo,{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 ${Qa(a)}`:"Awaiting state…"})]})]})}function B7({deviceId:e}){const t=De(),n=St(t.trpcClient,e),r=cn(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),T7(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(Go,{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 ${Qa(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 z7({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(fn,{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(Ua,{status:r?"online":"offline"}),s.length>0&&o(Va,{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 F7({deviceId:e}){const t=ke(),n=hb({deviceId:e},{refetchInterval:1e4,retry:!1}),r=mb({onSuccess:()=>{t.invalidateQueries({queryKey:[["deviceDiscovery","listDiscovered"]]}),t.invalidateQueries({queryKey:[["deviceDiscovery","getStatus"]]})}}),s=Q(()=>j7(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(Wi,{label:"Discovered",value:s.total,icon:o(En,{className:"h-3.5 w-3.5"})}),o(Wi,{label:"Adopted",value:s.adopted,accent:"success"}),o(Wi,{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(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(ht,{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(ws,{icon:o(er,{className:"h-3 w-3 text-emerald-500"}),label:`${s.online} online`}),o(ws,{icon:o(f0,{className:"h-3 w-3 text-amber-500"}),label:`${s.sleeping} sleeping`}),o(ws,{icon:o(N0,{className:"h-3 w-3 text-destructive"}),label:`${s.offline} offline`}),s.unknown>0?o(ws,{icon:o(JT,{className:"h-3 w-3 text-foreground-subtle"}),label:`${s.unknown} unknown`}):null]})]})}function j7(e){const t={total:e.length,adopted:0,available:0,online:0,sleeping:0,offline:0,unknown:0};for(const n of e)n.alreadyAdopted?t.adopted+=1:t.available+=1,t[n.status]+=1;return t}function Wi({label:e,value:t,icon:n,accent: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 ws({icon:e,label:t}){return u("span",{className:"inline-flex items-center gap-1",children:[e,o("span",{children:t})]})}const H7=e=>o(nv,{...e,useSiren:!0}),V7={[it.Switch]:nv,[it.Siren]:H7,[it.Light]:R7,[it.Sensor]:O7,[it.Button]:B7,[it.Hub]:F7};function q7(e){const t=V7[e.deviceType]??z7;return o(t,{...e})}function Od(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 oa(e){return new Date(e).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function sa(e){return e.toISOString().slice(0,10)}function U7(e,t){return sa(e)===sa(t)}function oo(e){const t=new Date(e);return t.setHours(0,0,0,0),t}function Q7(e){const t=new Date(e);return t.setHours(23,59,59,999),t}function Pt({className:e=""}){return o("div",{className:`animate-pulse rounded bg-foreground-subtle/10 ${e}`})}function jn(){return u("div",{className:"flex items-center gap-3 px-4 py-3",children:[o(Pt,{className:"h-4 w-4"}),o(Pt,{className:"h-3 w-24"}),o(Pt,{className:"h-3 w-16 ml-auto"})]})}function Jr({children:e,actions:t}){return u("div",{className:"border-b border-border px-4 py-2.5 flex items-center justify-between",children:[o("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:e}),t]})}function sf({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 G7({segments:e,selectedDate:t}){const n=oo(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:`${oa(a.startTime)} - ${oa(a.endTime)} (${Od(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 K7({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(y0,{className:"h-4 w-4 text-primary"}):o(Yo,{className:"h-4 w-4"})}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-xs font-mono text-foreground",children:[oa(e.startTime)," - ",oa(e.endTime)]}),u("p",{className:"text-[10px] text-foreground-subtle",children:[Od(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(Fa,{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(Mn,{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(Ke,{className:"h-3.5 w-3.5"})})]})]})}function W7({deviceId:e}){const t=ke(),[n,r]=_(()=>oo(new Date)),[s,a]=_(new Set),i=Ux({deviceId:e},{refetchInterval:5e3}),l=Hx({deviceId:e}),c=l.data?.streams[0]?.streamId??"stream0",d=Vx({deviceId:e,streamId:c,startTime:oo(n).getTime(),endTime:Q7(n).getTime()}),f=qx({deviceId:e,streamId:c},{refetchInterval:3e4}),p=Qx({deviceId:e,dataCategory:"recording:main"}),h=q(()=>{t.invalidateQueries({queryKey:["recordingEngine","getPolicyStatus"]}),t.invalidateQueries({queryKey:["recordingEngine","getSegments"]}),t.invalidateQueries({queryKey:["recordingEngine","getStorageUsage"]})},[t]),m=Fx({onSuccess:h}),g={isPending:m.isPending,error:m.error,mutate:()=>{const L=l.data,T=L?{mode:L.mode,streams:L.streams,enabled:!0,preBufferSec:L.preBufferSec,postBufferSec:L.postBufferSec,scheduleRules:L.scheduleRules}:{mode:"continuous",streams:[{streamId:c,mode:"always"}],enabled:!0,preBufferSec:10,postBufferSec:5};m.mutate({deviceId:e,policy:T})}},b=jx({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,C=g.isPending||b.isPending,E=U7(n,new Date),P=Q(()=>[...w].sort((L,T)=>new Date(T.startTime).getTime()-new Date(L.startTime).getTime()),[w]),I=Q(()=>w.reduce((L,T)=>L+(T.duration??0),0),[w]),z=Q(()=>w.reduce((L,T)=>L+(T.sizeBytes??0),0),[w]);function A(){k?b.mutate({deviceId:e}):g.mutate()}function O(){r(L=>{const T=new Date(L);return T.setDate(T.getDate()-1),oo(T)}),a(new Set)}function R(){E||(r(L=>{const T=new Date(L);return T.setDate(T.getDate()+1),oo(T)}),a(new Set))}function M(L){a(T=>{const B=new Set(T);return B.has(L)?B.delete(L):B.add(L),B})}function D(){s.size===P.length?a(new Set):a(new Set(P.map(L=>L.id)))}return i.isLoading&&l.isLoading?u("div",{className:"space-y-4",children:[u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(Jr,{children:"Recording Status"}),u("div",{className:"px-4 py-4 space-y-3",children:[o(Pt,{className:"h-10 w-full"}),o(Pt,{className:"h-4 w-48"})]})]}),u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(Jr,{children:"Segments"}),u("div",{className:"divide-y divide-border",children:[o(jn,{}),o(jn,{}),o(jn,{})]})]})]}):u("div",{className:"space-y-4",children:[u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(Jr,{children:"Recording Status"}),u("div",{className:"px-4 py-4 flex items-center justify-between gap-4",children:[u("div",{className:"flex items-center gap-3 min-w-0",children:[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(a0,{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:A,disabled:C,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors flex-shrink-0 disabled:opacity-50 ${k?"bg-danger/10 text-danger hover:bg-danger/20":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:k?u(me,{children:[o(Yo,{className:"h-3.5 w-3.5"}),C?"Stopping...":"Stop Recording"]}):u(me,{children:[o(Fa,{className:"h-3.5 w-3.5"}),C?"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(uo,{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(Jr,{children:u("span",{className:"flex items-center gap-1.5",children:[o(Yt,{className:"h-3.5 w-3.5"}),"Settings"]})}),l.isLoading?u("div",{className:"px-4 py-3 space-y-2",children:[o(Pt,{className:"h-3 w-32"}),o(Pt,{className:"h-3 w-40"}),o(Pt,{className:"h-3 w-28"})]}):u("div",{className:"divide-y divide-border",children:[o(eo,{label:"Stream",value:c}),o(eo,{label:"Pre-buffer",value:y?`${y.preBufferSec}s`:"N/A"}),o(eo,{label:"Mode",value:y?.mode??"continuous"}),o(eo,{label:"Retention",value:N?.retentionDays!=null?`${N.retentionDays} days`:"N/A"}),N?.retentionGb!=null&&o(eo,{label:"Max Storage",value:`${N.retentionGb} GB`})]})]}),u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(Jr,{children:u("span",{className:"flex items-center gap-1.5",children:[o(Js,{className:"h-3.5 w-3.5"}),"Storage"]})}),f.isLoading?u("div",{className:"px-4 py-3 space-y-2",children:[o(Pt,{className:"h-3 w-28"}),o(Pt,{className:"h-3 w-36"}),o(Pt,{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(ut,{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(sf,{icon:Js,label:"Total",value:v?.totalBytes!=null?kt(v.totalBytes):"N/A"}),o(sf,{icon:uo,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:O,className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:o(_d,{className:"h-4 w-4"})}),u("div",{className:"flex items-center gap-1.5 text-xs text-foreground font-medium",children:[o(r0,{className:"h-3.5 w-3.5 text-foreground-subtle"}),E?"Today":sa(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(G7,{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:[Od(I)," recorded"]}),z>0&&o("span",{children:kt(z)})]})]}),P.length>0&&u("div",{className:"border-b border-border px-4 py-2 flex items-center justify-between",children:[o("button",{onClick:D,className:"text-[11px] text-foreground-subtle hover:text-foreground transition-colors",children:s.size===P.length?"Deselect All":"Select All"}),s.size>0&&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(Mn,{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(Ke,{className:"h-3 w-3"}),"Delete"]})]})]}),d.isLoading?u("div",{className:"divide-y divide-border",children:[o(jn,{}),o(jn,{}),o(jn,{}),o(jn,{})]}):P.length===0?u("div",{className:"flex flex-col items-center justify-center py-12 text-foreground-subtle",children:[o(uo,{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 ${sa(n)}`})]}):o("div",{className:"max-h-[400px] overflow-y-auto",children:P.map(L=>o(K7,{segment:L,selected:s.has(L.id),onToggle:()=>M(L.id),onPlay:()=>{},onDownload:()=>{},onDelete:()=>{}},L.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(ut,{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(ut,{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 eo({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 Y7({deviceId:e}){const t=ke(),n=Number.isFinite(e),{data:r}=Yn({deviceId:e},{enabled:n}),s=typeof r?.type=="string"?r.type:"camera";vt(["deviceManager","getBindings"],["capability.binding-changed"]);const{data:a,isLoading:i,isError:l,error:c}=Sb({deviceId:e},{staleTime:3e4,enabled:n}),{data:d}=Mb({deviceType:s},{staleTime:3e4,enabled:!!s}),f=Cb({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(Ko,{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(Z7,{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(X7,{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(J7,{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 Z7({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(un,{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(PR,{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(KR,{className:"h-3 w-3"}),"unbound"]})}function X7({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 J7({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(b0,{className:"h-3 w-3"}),s]},s)})})}function eB(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 tB(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 nB({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 rB({deviceId:e,refreshToken:t}){const n=ke(),[r,s]=_(null),[a,i]=_(null),[l,c]=_(null),[d,f]=_(null),p=rd({deviceId:e}),h=Hr(),m=_a({deviceId:e}),g=bx(),b=Q(()=>{const D=m.data?.agentNodeId;if(D)return D;const L=g.data?.find(T=>T.online)?.nodeId;return L||"hub"},[m.data?.agentNodeId,g.data]),x=a??b,y=Vo({nodeId:x??""},{enabled:!!x}),w=Ax({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),c(null)}}),v=Q(()=>y.data?Sa(y.data):[],[y.data]),N=Q(()=>{const D=p.data??null,L={};for(const T of h.data??[])for(const B of Object.keys(T.settings.addonDefaults)){const F=L[B]??[];F.push({agentNodeId:T.nodeId,state:tB(D,T.nodeId,B)}),L[B]=F}return L},[p.data,h.data]),k=r?eB(y.data??null,r):null,C=x?h.data?.find(D=>D.nodeId===x)??null:null,E=r&&C?C.settings.addonDefaults[r]??null:null,P=r&&x?p.data?.stepOverridesByAgent?.[x]?.[r]??null:null,I=y.data?.selectedEngine.format??"coreml",z=D=>{i(D),c(null),f(null)},A=D=>{s(D),c(null),f(null)},O=D=>{if(!x||!r||!y.data||!h.data)return;const L=h.data.find(F=>F.nodeId===D),T=h.data.find(F=>F.nodeId===x);if(!L||!T)return;const[B]=mm({source:{nodeId:L.nodeId,engine:{format:I},defaults:L.settings.addonDefaults},target:{nodeId:T.nodeId,engine:{format:I},defaults:T.settings.addonDefaults},catalog:y.data,addonIds:[r]});if(!B){f("no mirror result");return}if(B.outcome==="skip"){f(`skipped: ${B.reason??"no candidate"}`);return}c(B.patch),f(`${B.outcome} from ${D}`)},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(dg,{tree:v,selectedAddonId:r,onSelect:A,agentDots:N})}),o("section",{className:"flex-1 min-w-0 p-4 overflow-y-auto",children:!r||!k?o("div",{className:"text-sm text-foreground-subtle",children:"Select a step on the left to configure it for this camera."}):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(D=>o("button",{type:"button",onClick:()=>z(D.nodeId),className:`px-3 py-1 text-xs ${x===D.nodeId?"bg-primary text-primary-foreground":"bg-surface hover:bg-muted"}`,children:D.nodeId},D.nodeId))})]}),o(nB,{agents:(h.data??[]).map(D=>D.nodeId),currentAgent:x,onPick:O}),d&&o("div",{className:"text-[10px] text-foreground-subtle",children:d})]}),E&&o(Ma,{mode:"device",addon:k,agentDefault:E,agentNodeId:x??"",currentPatch:l??P,engineFormat:I,onChangePatch:c}),u("div",{className:"flex items-center justify-between gap-2 pt-4 border-t border-border",children:[o("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted text-foreground-subtle",disabled:!P||w.isPending,onClick: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 oB=[{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 sB(e){const t=e===it.Camera;return oB.filter(n=>t||!n.cameraOnly).map(({id:n,label:r})=>({id:n,label:r}))}const aB=[{id:"logs",icon:rt,label:"Logs"},{id:"repl",icon:v0,label:"REPL"},{id:"events",icon:Go,label:"Events"},{id:"state",icon:i0,label:"State"},{id:"ptz",icon:JR,label:"PTZ",featureGate:Un.PanTiltZoom}];function iB(){const e=kd(),t=Number(e.deviceId),n=Number.isFinite(t),r=et(),s=ke(),a=Je(),i=De(),[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,Ce=de.currentTarget.previousElementSibling?.getBoundingClientRect().width??h??0,pe=280,_e=Math.max(pe+50,Math.floor(window.innerWidth*.7)),Ae=st=>{const mr=Math.max(pe,Math.min(_e,Ce+(st.clientX-ce)));m(mr)},We=()=>{document.removeEventListener("mousemove",Ae),document.removeEventListener("mouseup",We);const st=g.current;if(st!==null)try{window.localStorage.setItem(p,String(Math.round(st)))}catch{}document.body.style.userSelect="",document.body.style.cursor=""};document.body.style.userSelect="none",document.body.style.cursor="col-resize",document.addEventListener("mousemove",Ae),document.addEventListener("mouseup",We)}const{data:x,isLoading:y,isError:w}=Yn({deviceId:t},{enabled:n,refetchInterval:5e3,retry:1}),{data:v}=Yc({deviceId:t},{enabled:n,staleTime:3e4}),N=Q(()=>{const de=v?.settings?.sections??[],ce=v?.live?.sections??[],Ce=[...de,...ce],pe=new Set;for(const Ae of Ce)Ae.location==="top-tab"&&Ae.tab&&pe.add(Ae.tab);return Ce.some(Mo)&&pe.add(Qi),[...pe].map(Ae=>{if(Ae===Qi)return{id:Ae,label:d7,isAddonContrib:!0};const We=fl[Ae];return{id:Ae,label:We?.label??Ae,isAddonContrib:!0}})},[v]),k=x,C=String(k?.name??e.deviceId??"Device"),E=k?.online===!0,P=E?"online":"offline",I=String(k?.addonId??"rtsp"),z=k?.features??[],A=k?.type,O=A===it.Camera,R=typeof k?.parentDeviceId=="number"?k.parentDeviceId:null,{data:M}=Yn({deviceId:R??0},{enabled:R!==null,staleTime:3e4}),D=dr(),L=Q(()=>[...sB(A),...N],[A,N]),{data:T}=H0(n?t:0),B=(T??[]).length>0,F=Q(()=>aB.filter(({featureGate:de})=>!de||z.includes(de)),[z]),{data:j}=$b({addonId:I},{enabled:!!I&&I!=="rtsp"}),H=kb({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]}),r(j?.id?`/integrations/${j.id}`:"/integrations")}}),$=wb({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),V=Nb({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),G=zx(),Z=Ia({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),oe=z.includes(Un.Rebootable),te=z.includes(Un.BatteryOperated),X=Bc(i.trpcClient,te&&n?t:null),[re,be]=_(!1),J=St(i.trpcClient,n?t:null),K=async()=>{if(!(re||!J)){be(!0);try{await J.snapshot?.invalidateCache({});const de=await J.snapshot?.getSnapshot({});if(!de)return;const ce=`data:${de.contentType};base64,${de.base64}`,Ce=de.contentType.includes("png")?"png":"jpg",pe=C.replace(/[^a-zA-Z0-9_.-]+/g,"_"),_e=new Date().toISOString().replace(/[:.]/g,"-"),Ae=document.createElement("a");Ae.href=ce,Ae.download=`${pe}-${_e}.${Ce}`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae)}finally{be(!1)}}},ee=$.isPending||V.isPending,{data:ae}=_a({deviceId:t},{enabled:n,refetchInterval:1e4}),fe=ae?.agentNodeId??null,U=typeof fe=="string"&&fe.length>0&&!fe.startsWith("addon:")?fe:void 0,{data:ie}=od({deviceId:t,...U?{nodeId:U}:{}},{enabled:n,refetchInterval:3e3,retry:!1});function ue(){if(!n)return null;switch(l){case"overview":return o(M7,{device:k??{}});case"config":return o(L7,{deviceId:t});case"pipeline":return o(rB,{deviceId:t,refreshToken:0});case"bindings":return o(Y7,{deviceId:t});case"recording":return o(W7,{deviceId:t});default:{const de=l;return N.some(Ce=>Ce.id===de)?de===Qi?o(Ul,{deviceId:t,sectionFilter:Mo}):o(Ul,{deviceId:t,sectionFilter:Ce=>Ce.location==="top-tab"&&Ce.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(Pc,{items:[{label:"Integrations",onClick:()=>r("/integrations")},{label:j?.name??I,onClick:()=>j?.id&&r(`/integrations/${j.id}`)},{label:C}]})}),u("div",{className:"flex items-center gap-2 sm:gap-3",children:[o(fn,{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:C}),o(Ua,{status:P}),te&&o(Fc,{status:X,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:z.length>0&&o(Va,{capabilities:z})})]}),ie&&o("div",{className:"hidden lg:flex",children:o(lB,{metrics:ie})}),u("div",{className:"flex items-center gap-1 shrink-0",children:[u("button",{onClick:async()=>{await a({title:`Disable "${C}"?`,message:"The device will stop processing streams and events. You can re-enable it later.",confirmLabel:"Disable",variant:"danger"})&&V.mutate({deviceId:t})},disabled:ee,title:"Disable device",className:"inline-flex items-center gap-1.5 rounded-lg px-2 sm:px-2.5 py-1.5 text-[11px] font-medium border transition-colors disabled:opacity-50 border-success/30 text-success hover:bg-success/10",children:[o(g0,{className:"h-3.5 w-3.5"}),o("span",{className:"hidden sm:inline",children:ee?"Updating…":"Enabled"})]}),o("div",{className:"hidden sm:block h-5 w-px bg-border mx-1"}),o(Dy,{triggerClassName:"ml-1",items:[{id:"snapshot",label:"Take snapshot",description:"Fetch a fresh frame and download it.",icon:Ir,disabled:re,onClick:()=>{K()}},{id:"reboot",label:"Reboot device",description:"Camera goes offline for ~30 seconds.",icon:yt,hidden:!oe,disabled:G.isPending,danger:!0,onClick:async()=>{await a({title:`Reboot "${C}"?`,message:"The camera will go offline for around 30 seconds while the firmware reboots.",confirmLabel:"Reboot",variant:"danger"})&&G.mutate({deviceId:t})}},{id:"restart-addon",label:"Restart addon",description:`Bounces every device served by ${j?.name??I}.`,icon:ht,disabled:Z.isPending,danger:!0,onClick:async()=>{await a({title:`Restart "${j?.name??I}"?`,message:`Restarting the addon will briefly disconnect every device served by it (not just "${C}"). Streams will reconnect automatically.`,confirmLabel:"Restart",variant:"danger"})&&Z.mutate({addonId:I})}},{id:"delete",label:"Delete device",description:"Remove the device and all its settings.",icon:Ke,separatorBefore:!0,disabled:H.isPending,danger:!0,onClick:async()=>{await a({title:`Delete "${C}"?`,message:"This will remove the device and all its settings. This action cannot be undone.",confirmLabel:"Delete",variant:"danger"})&&H.mutate({deviceId:t})}}]})]})]})]}),o(Bg,{deviceId:t,device:k??void 0,children:o(My,{children:o(Ty,{children:u("main",{className:D?"flex-1 overflow-y-auto flex flex-col":"flex-1 min-h-0 overflow-hidden flex flex-row",children:[u("div",{className:D?"flex flex-col bg-surface":`${h===null?"w-1/2 lg:w-1/3":""} flex-shrink-0 flex flex-col bg-surface min-h-0 overflow-hidden`,style:!D&&h!==null?{width:`${String(h)}px`}:void 0,children:[o("div",{className:`flex-shrink-0 border-b border-border-subtle ${O?"aspect-video bg-black":"bg-surface"}`,children:O?o(y7,{deviceId:t,intercomAvailable:z.includes(Un.TwoWayAudio)}):o(q7,{deviceId:t,deviceName:C,deviceType:A??"unknown",provider:I,isOnline:E,features:z})}),u("div",{className:D?"flex flex-col border-b border-border":"flex-1 min-h-0 flex flex-col overflow-hidden",children:[o("div",{className:"flex-shrink-0 border-b border-border-subtle px-2 py-1.5",children:o("div",{className:"flex gap-1 overflow-x-auto -mx-1 px-1 pb-0.5",children:F.map(({id:de,label:ce,icon:Ce})=>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(Ce,{className:"h-3 w-3"}),ce]},de))})}),u("div",{className:D?"h-72 overflow-hidden":"flex-1 min-h-0 overflow-hidden",children:[d==="logs"&&o(v7,{deviceId:t}),d==="repl"&&o(w7,{deviceId:t}),d==="events"&&o(k7,{deviceId:t}),d==="state"&&o(S7,{deviceId:t}),d==="ptz"&&o(N7,{deviceId:t})]})]})]}),!D&&o("div",{role:"separator","aria-orientation":"vertical",title:"Drag to resize",onMouseDown:b,className:"flex-shrink-0 w-1 cursor-col-resize bg-border hover:bg-primary/40 transition-colors group relative z-10",children:o("span",{className:"absolute inset-y-0 -left-1 -right-1"})}),u("div",{className:D?"flex flex-col":"flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden",children:[o("div",{className:"flex-shrink-0 border-b border-border bg-surface px-4",children:o("div",{className:"flex flex-wrap items-center gap-0",children:L.map(de=>{const ce=l===de.id;return 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:D?"p-3 flex flex-col gap-3":"flex-1 min-h-0 overflow-y-auto p-4 flex flex-col gap-3",children:[l==="overview"&&B&&o(C7,{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 lB({metrics:e}){const t=e.phase??"idle",n=ir(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(Qo,{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(ft,{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 cB({packageName:e,currentVersion:t,installSource:n,onInstall:r,onClose:s}){const a=n==="upload"||n==="local",{data:i,isLoading:l}=qg({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(ze,{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(Ha,{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(Se,{className:"h-3.5 w-3.5 animate-spin"}),"Loading versions..."]}),i&&o("div",{className:"max-h-64 overflow-auto divide-y divide-border",children:i.map(c=>{const d=c.version===t,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(Mn,{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 dB({isBundle:e,installSource:t,addonId:n,iconPath:r,color:s}){const[a,i]=_(!1),l=s?{backgroundColor:`${s.startsWith("#")?s:`#${s}`}26`}:void 0,c=e?"bg-indigo-500/20 text-indigo-700 dark:text-indigo-300":"bg-purple-500/20 text-purple-700 dark:text-purple-300",d=n&&r?`/api/addon-assets/${n}/${r}`:null,f=!!d&&!a;return u("div",{className:"relative flex-shrink-0",children:[o("div",{className:`h-9 w-9 rounded-lg flex items-center justify-center ${l?"":c}`,style:l,children:f?o("img",{src:d,alt:n,className:"h-5 w-5",onError:()=>i(!0)}):e?o(h0,{className:"h-4 w-4"}):o(So,{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(Ha,{className:"h-2.5 w-2.5 text-white"})})]})}function uB({addonId:e}){const t=ke(),{data:n="inherit"}=Gg({addonId:e},{staleTime:3e4}),r=Kg({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 Gl({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=Je(),{manifest:C}=e,E=e.installedOn??[],P=!l&&!C.protected&&C.removable!==!1,I=!!l,z=l?.displayName??C.name,A=l?.packageName??C.packageName,O=l?.version??C.packageVersion??C.version,R=l?.installSource??e.installSource,M=l?l.bundle?.description??l.addons[0]?.manifest.description:C.description;!l&&(C.components&&C.components.length>0||t.length>=2);const D=zg({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["addonPages"]]}),N.invalidateQueries({queryKey:[["capabilities"]]})}}),L=Ia({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]})}}),T=qc({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["addonPages"]]}),N.invalidateQueries({queryKey:[["capabilities"]]}),N.invalidateQueries({queryKey:[["integrations"]]})}}),B=Ug({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["alerts"]]})}}),F=e.health,j=F?.phase==="failed"&&!F.inGracePeriod,H=j&&F?.nextRetryAt&&!F.retrying;return u("div",{className:`rounded-lg border bg-surface overflow-hidden ${j?"border-red-500/50":"border-border"}`,children:[j&&F&&u("div",{className:"bg-danger/10 border-b border-danger/30 px-4 py-2.5 flex items-start gap-2.5",children:[o(n6,{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 #",F.retryCount,")"]}),o("div",{className:"text-[11px] text-foreground mt-0.5 break-words font-mono",children:F.lastError?.message??"Unknown error"}),H&&F.nextRetryAt&&u("div",{className:"text-[10px] text-foreground-subtle mt-1",children:["Auto-retry at ",new Date(F.nextRetryAt).toLocaleTimeString()]})]}),u("button",{type:"button",disabled:B.isPending||F.retrying,onClick:$=>{$.stopPropagation(),B.mutate({packageName:A})},className:"inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0",title:"Reset retry counter and force immediate reload",children:[o(ht,{className:`h-3 w-3 ${B.isPending||F.retrying?"animate-spin":""}`}),"Retry now"]})]}),u("div",{className:"flex items-start gap-3 px-4 py-3",children:[o(dB,{isBundle:I||!!C.components&&C.components.length>1,installSource:R,addonId:I?l.addons[0]?.manifest.id:C.id,iconPath:I?l.bundle?.icon??l.addons[0]?.manifest.icon:C.icon,color:I?l.addons[0]?.manifest.color:C.color}),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:z}),u("span",{className:"text-[10px] text-foreground-subtle font-mono shrink-0",children:["(",A,")"]}),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(h0,{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(Se,{className:"h-3 w-3 animate-spin"}),"Updating to ",s,"…"]}):s&&a?u("button",{type:"button",onClick:$=>{$.stopPropagation(),a()},className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-semibold border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors animate-pulse",title:`Update to ${s}`,children:[o(Mn,{className:"h-3 w-3"}),s]}):null,u("button",{type:"button",onClick:$=>{$.stopPropagation(),m(V=>!V)},className:["inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-bold font-mono border transition-colors",R==="local"?"border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20":s?"border-amber-500/30 bg-amber-500/10 text-amber-400 hover:bg-amber-500/20":"border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20"].join(" "),title:s?`Current ${O} — newer ${s} available`:"View all versions",children:[O,o(Nt,{className:"h-3 w-3 opacity-50"})]}),h&&o(cB,{packageName:A,currentVersion:O,...R?{installSource:R}:{},onInstall:$=>{m(!1),T.mutate({packageName:A,version:$})},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:$=>{$.stopPropagation(),L.mutate({addonId:C.id})},disabled:L.isPending,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors",children:[o(ht,{className:`h-3 w-3 ${L.isPending?"animate-spin":""}`}),"Restart"]}),u("button",{type:"button",onClick:$=>{$.stopPropagation(),b(V=>!V)},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(rt,{className:"h-3 w-3"}),"Logs"]}),!I&&u("button",{type:"button",onClick:$=>{$.stopPropagation(),y(!0)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${x?"border-primary/30 bg-primary/10 text-primary":"border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10"}`,children:[o(Yt,{className:"h-3 w-3"}),"Settings"]}),o("div",{className:"flex-1"}),P&&u("button",{type:"button",onClick:async $=>{$.stopPropagation(),await k({title:`Uninstall ${C.name}?`,message:"This will remove the addon package and all its data. This action cannot be undone.",confirmLabel:"Uninstall",variant:"danger"})&&D.mutate({packageName:C.packageName})},disabled:D.isPending,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-red-400 hover:border-red-500/30 hover:bg-red-500/10 disabled:opacity-50 transition-colors",children:[o(Ke,{className:"h-3 w-3"}),D.isPending?"Removing...":"Uninstall"]})]}),n&&n.nodes.length>1&&!I&&u("div",{className:"border-t border-border px-4 py-2 bg-muted/10",children:[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($=>u("div",{className:"flex items-center gap-2 text-[10px]",children:[o("div",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${$.status==="offline"?"bg-muted-foreground/30":$.synced?"bg-success":"bg-amber-500"}`}),o("span",{className:"font-medium text-foreground min-w-[60px]",children:$.name}),o("span",{className:"font-mono text-foreground-subtle",children:$.version}),!$.synced&&$.status!=="offline"&&o("span",{className:"text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"outdated"}),$.status==="offline"&&o("span",{className:"text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground",children:"offline"}),$.synced&&$.status!=="offline"&&o("span",{className:"text-[9px] text-success",children:"synced"})]},$.nodeId))})]}),g&&!I&&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:$=>{$.stopPropagation(),b(!1)},className:"text-foreground-subtle hover:text-foreground",children:o(ze,{className:"h-3.5 w-3.5"})})]}),w==="logs"&&o(Xt,{addonId:C.id,maxHeight:"max-h-64",showFilters:!1}),w==="events"&&o(fr,{addonId:C.id,category:"addon.*",maxHeight:"max-h-64"})]}),I&&u(me,{children:[o("button",{type:"button",onClick:()=>d($=>!$),className:"w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors",children:c?o(GT,{className:"h-3.5 w-3.5 text-foreground-subtle"}):o(Nt,{className:"h-3.5 w-3.5 text-foreground-subtle"})}),c&&o("div",{className:"border-t border-border px-3 py-2 space-y-2",children:l.addons.map($=>o(Gl,{addon:$,agents:t,hideVersion:!0},$.manifest.id))})]}),x&&!I&&o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",onClick:()=>y(!1),children: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:$=>$.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(Yt,{className:"h-4 w-4 text-primary"}),u("h2",{className:"text-sm font-semibold text-foreground",children:[z," Settings"]})]}),o("button",{onClick:()=>y(!1),className:"text-foreground-subtle hover:text-foreground transition-colors p-1 rounded",children:o(ze,{className:"h-4 w-4"})})]}),u("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[o(Gr,{nodeId:"hub",addonIds:[C.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(uB,{addonId:C.id})]}),C.components&&C.components.length>0&&u("div",{children:[u("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Components (",C.components.length,")"]}),o("div",{className:"flex flex-wrap gap-1",children:C.components.map($=>o("span",{className:"text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono",children:$},$))})]}),t.length>=2&&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($=>o("span",{className:"rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle",children:$},$)),u("div",{className:"relative",children:[u("button",{type:"button",onClick:$=>{$.stopPropagation(),p(V=>!V)},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(ot,{className:"h-3 w-3"}),"Add agent"]}),f&&u("div",{className:"absolute left-0 top-full mt-1 z-10 min-w-[160px] rounded-md border border-border bg-surface shadow-lg overflow-hidden",children:[t.filter($=>!$.isHub&&!E.includes($.name)).map($=>o("button",{type:"button",onClick:V=>{V.stopPropagation(),p(!1)},className:"w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors",children:$.name},$.id)),t.filter($=>!$.isHub&&!E.includes($.name)).length===0&&o("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle",children:"No available agents"})]})]})]})]})]}),o("div",{className:"flex items-center justify-end px-5 py-3 border-t border-border flex-shrink-0",children:o("button",{type:"button",onClick:()=>y(!1),className:"rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:"Close"})})]})})]})}const pB=".tgz,.tar.gz,.zip";function fB({onUploadSuccess:e}){const[t,n]=_(!1),r=ne(null),s=q(async i=>{n(!0);const l=new FormData;l.append("file",i);const c=localStorage.getItem("camstack_admin_token")??"";try{(await(await fetch("/api/addons/upload",{method:"POST",headers:{Authorization:`Bearer ${c}`},body:l})).json()).success&&e()}finally{n(!1)}},[e]),a=q(i=>{const l=i.target.files?.[0];l&&s(l),i.target.value=""},[s]);return u(me,{children:[o("input",{ref:r,type:"file",accept:pB,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(Se,{className:"w-3.5 h-3.5 animate-spin"}):o(Ha,{className:"w-3.5 h-3.5"}),t?"Uploading...":"Upload"]})]})}function hB(e,t){const n=e??"hub-only";return n==="any-node"?!0:n==="hub-only"?t:!t}function mB(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 gB(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 nn(e){return"bundle"in e}function bB({addons:e,clusterStatus:t,selectedNode:n,onRefresh:r,isRefreshing:s}){const a=ke(),[i,l]=_(""),c=MN(i),[d,f]=_(!1),p=ne(null);Y(()=>{if(!d)return;const $=V=>{p.current&&!p.current.contains(V.target)&&f(!1)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[d]);const{data:h}=Uc(void 0,{staleTime:5*6e4}),m=Q(()=>{const $=new Map;for(const V of h??[])$.set(V.name,V.latestVersion);return $},[h]),[g,b]=_(null),[x,y]=_(null),w=El({onMutate:$=>{b($.name),y(null)},onSuccess:($,V)=>{b(null);const G=$;if(G&&G.success===!1){y({name:V.name,message:G.error??"Update failed (no error message returned by server)"});return}a.invalidateQueries({queryKey:[["addons"]]}),a.invalidateQueries({queryKey:[["addons","listUpdates"]]})},onError:($,V)=>{b(null),y({name:V.name,message:$ instanceof Error?$.message:String($)})}}),{data:v}=Qg(void 0,{staleTime:3e4}),N=Wg({onSuccess:()=>{a.invalidateQueries({queryKey:[["addons","getAutoUpdateSettings"]]})}}),{data:k,isFetching:C}=jg({query:c||void 0},{enabled:d,staleTime:6e4}),E=El(),P=async()=>{const $=h??[];for(const V of $)await E.mutateAsync({name:V.name,version:V.latestVersion});a.invalidateQueries({queryKey:[["addons"]]})},I=qc({onSuccess:()=>{a.invalidateQueries({queryKey:[["addons"]]}),a.invalidateQueries({queryKey:[["addonPages"]]}),a.invalidateQueries({queryKey:[["capabilities"]]}),a.invalidateQueries({queryKey:[["integrations"]]})}}),[z,A]=_("type"),[O,R]=_(()=>typeof window>"u"?"grouped":window.localStorage.getItem("camstack.addons.viewMode")==="flat"?"flat":"grouped"),M=$=>{R($),typeof window<"u"&&window.localStorage.setItem("camstack.addons.viewMode",$)},[D,L]=Ba(),T=D.get("capability"),B=Q(()=>{let $=n.isHub?e:e.filter(V=>{const G=V.manifest.execution;return hB(G?.placement,n.isHub)});return T&&($=$.filter(V=>(V.manifest.capabilities??[]).some(Z=>(typeof Z=="string"?Z:Z.name)===T))),$},[e,n.isHub,T]),F=()=>{const $=new URLSearchParams(D);$.delete("capability"),L($,{replace:!0})},j=O==="flat"?B:gB(B),H=Q(()=>{const $=[...j];switch(z){case"type":$.sort((V,G)=>{const Z=nn(V)?0:1,oe=nn(G)?0:1;if(Z!==oe)return Z-oe;const te=nn(V)?V.bundle.displayName:V.manifest.name,X=nn(G)?G.bundle.displayName:G.manifest.name;return te.localeCompare(X)});break;case"name":$.sort((V,G)=>{const Z=nn(V)?V.bundle.displayName:V.manifest.name,oe=nn(G)?G.bundle.displayName:G.manifest.name;return Z.localeCompare(oe)});break;case"source":$.sort((V,G)=>{const Z=nn(V)?V.bundle.installSource??"":V.installSource??"",oe=nn(G)?G.bundle.installSource??"":G.installSource??"";return Z.localeCompare(oe)});break}return $},[j,z]);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:z,onChange:$=>A($.target.value),className:"rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] text-foreground focus:outline-none focus:border-primary/50",children:[o("option",{value:"type",children:"Bundles first"}),o("option",{value:"name",children:"Name"}),o("option",{value:"source",children:"Install source"})]})]}),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($=>o("button",{type:"button",onClick:()=>M($),className:`px-2.5 py-1.5 transition-colors capitalize ${O===$?"bg-primary/10 text-primary":"bg-transparent text-foreground-subtle hover:bg-surface-hover"}`,title:$==="grouped"?"Group multi-addon packages into a bundle card":"Show every addon as its own card",children:$},$))})]}),u("div",{className:"flex items-center gap-1.5",children:[o(ht,{className:"h-3 w-3 text-foreground-subtle"}),o("span",{className:"text-[10px] text-foreground-subtle",children:"Auto-Update:"}),o("div",{className:"flex rounded-md border border-border overflow-hidden text-[10px] font-medium",children:["off","latest","beta"].map($=>o("button",{type:"button",onClick:()=>N.mutate({channel:$}),disabled:N.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${v?.channel===$?$==="off"?"bg-gray-700 text-gray-200":$==="latest"?"bg-blue-500/20 text-blue-400":"bg-amber-500/20 text-amber-400":"bg-transparent text-foreground-subtle hover:bg-surface-hover"} ${$!=="off"?"border-l border-border":""}`,children:$},$))})]}),(h?.length??0)>0&&u("button",{type:"button",onClick:()=>void P(),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(Mn,{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(ht,{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(x0,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle"}),o("input",{type:"text",value:i,onChange:$=>{l($.target.value),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"}),C&&o(Se,{className:"absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin"}),d&&k&&k.length>0&&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($=>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:$.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:$.name}),u("span",{className:"text-[10px] text-foreground-subtle",children:["v",$.version]})]}),$.description&&o("div",{className:"text-[10px] text-foreground-subtle truncate",children:$.description})]}),$.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"}),$.installedVersion??"Installed"]}):u("button",{type:"button",onClick:()=>I.mutate({packageName:$.name}),disabled:I.isPending,className:"inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0",children:[I.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(Mn,{className:"h-3 w-3"}),"Install"]})]},$.name))})]})]}),o(fB,{onUploadSuccess:()=>{a.invalidateQueries({queryKey:[["addons"]]}),r()}})]}),T&&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:T}),o("button",{type:"button",onClick:F,className:"ml-auto text-xs text-foreground-subtle hover:text-foreground underline",children:"Clear"})]}),B.length===0&&o("div",{className:"text-xs text-foreground-subtle",children:e.length===0?"No addons installed":T?`No installed addons declare the "${T}" capability. Browse the npm catalog above to find a compatible addon.`:`No addons compatible with ${n.name} (placement filter active)`}),o("div",{className:"space-y-2",children:H.map($=>{if(nn($)){const Z=$.bundle.packageName,oe=m.get(Z);return o(Gl,{addon:$.representative,clusterStatus:t?.[$.representative.manifest.id],bundle:$.bundle,availableUpdate:oe,isUpdating:g===Z,onUpdate:oe?()=>w.mutate({name:Z,version:oe}):void 0},Z)}const V=$.manifest.packageName,G=m.get(V);return o(Gl,{addon:$,clusterStatus:t?.[$.manifest.id],availableUpdate:G,isUpdating:g===V,onUpdate:G?()=>w.mutate({name:$.manifest.packageName,version:G}):void 0},$.manifest.id)})})]})}function xB(){const e=ke(),{data:t,isLoading:n,isError:r}=Ho(),{data:s}=ox(void 0,{staleTime:15e3}),{data:a}=Tn(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=Hg(),p=Fg(),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(mB).filter(x=>x!==null);return u(Xe,{children:[u("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[o(fg,{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(ht,{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(bB,{addons:b,clusterStatus:s,selectedNode:d,onRefresh:()=>void m(),isRefreshing:h})]})}function yB({value:e,size:t=192}){const[n,r]=_(null),[s,a]=_(null);if(Y(()=>{let d=!1;return HN(()=>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]})}const vB={view:{icon:Wo,cls:"bg-foreground-subtle/15 text-foreground-subtle"},create:{icon:Qr,cls:"bg-primary/15 text-primary"},delete:{icon:Ke,cls:"bg-danger/15 text-danger"}};function wB(){const{user:e,logout:t}=Jt();if(!e)return o(Xe,{children:o("div",{className:"text-xs text-foreground-subtle",children:"Not signed in."})});const n=e.isAdmin,r=e.scopes??[];return u(Xe,{children:[u("div",{className:"rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3",children:[o("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base",children:e.username.slice(0,1).toUpperCase()}),u("div",{className:"flex-1 min-w-0",children:[o("div",{className:"text-sm font-semibold text-foreground truncate",children:e.username}),u("div",{className:"text-[11px] text-foreground-subtle",children:[n?"Administrator":"User"," · session id ",u("span",{className:"font-mono",children:[e.id.slice(0,8),"…"]})]})]})]}),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(Jn,{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."})]})]}),o(NB,{}),o(kB,{username:e.username}),r.length>0&&u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"px-4 py-2 border-b border-border",children:[o("div",{className:"text-xs font-semibold text-foreground",children:"Granted scopes"}),o("div",{className:"text-[10px] text-foreground-subtle",children:"Baked into your session token at login; sign out + back in to refresh after changes."})]}),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}=vB[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))})]}),o("div",{className:"flex justify-end",children: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",children:[o(Ld,{className:"h-3 w-3"}),"Sign out"]})})]})}function NB(){const e=De(),[t,n]=_(""),[r,s]=_(""),[a,i]=_(""),[l,c]=_(null),d=qn({mutationFn:m=>e.changeOwnPassword(m),onSuccess:()=>{c({kind:"success",msg:"Password updated."}),n(""),s(""),i("")},onError:m=>{c({kind:"error",msg:m instanceof Error?m.message:"Update failed"})}}),f=r.length>0&&a.length>0&&r!==a,p=r.length>0&&r.length<8,h=t.length>=1&&r.length>=8&&r===a;return u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"px-4 py-2.5 border-b border-border flex items-center gap-2",children:[o(d0,{className:"h-3.5 w-3.5 text-foreground-subtle"}),o("div",{className:"text-xs font-semibold text-foreground",children:"Change password"})]}),u("div",{className:"p-4 space-y-3",children:[o(Yi,{label:"Current password",value:t,onChange:n,autoComplete:"current-password"}),o(Yi,{label:"New password",value:r,onChange:s,autoComplete:"new-password",hint:"At least 8 characters."}),o(Yi,{label:"Confirm new password",value:a,onChange:i,autoComplete:"new-password"}),(f||p)&&o("div",{className:"text-[11px] text-danger",children:f?"Passwords do not match.":"New password must be at least 8 characters."}),l&&u("div",{className:`text-[11px] flex items-center gap-1 ${l.kind==="success"?"text-emerald-500":"text-danger"}`,children:[l.kind==="success"?o(co,{className:"h-3 w-3"}):o(Xn,{className:"h-3 w-3"}),l.msg]}),o("div",{className:"flex justify-end",children:u("button",{onClick:()=>{c(null),d.mutate({currentPassword:t,newPassword:r})},disabled:!h||d.isPending,className:"inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[d.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(Dd,{className:"h-3 w-3"}),"Update password"]})})]})]})}function Yi({label:e,value:t,onChange:n,autoComplete:r,hint:s}){return u("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:e}),o("input",{type:"password",value:t,onChange:a=>n(a.target.value),autoComplete:r,className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary"}),s&&o("div",{className:"text-[10px] text-foreground-subtle",children:s})]})}function kB({username:e}){const t=De(),n=Pn({queryKey:["auth","getOwnTotpStatus"],queryFn:()=>t.getOwnTotpStatus()}),r=n.data,[s,a]=_(null),[i,l]=_(""),[c,d]=_(null),[f,p]=_(!1),h=qn({mutationFn:()=>t.setupOwnTotp(),onSuccess:y=>{a({secret:y.secret,otpauthUrl:y.otpauthUrl}),l(""),d(null)},onError:y=>d(y instanceof Error?y.message:"Setup failed")}),m=qn({mutationFn:y=>t.confirmOwnTotp(y),onSuccess:()=>{a(null),l(""),d(null),n.refetch()},onError:y=>d(y instanceof Error?y.message:"Confirmation failed — code did not match")}),g=qn({mutationFn:()=>t.disableOwnTotp(),onSuccess:()=>{d(null),n.refetch()},onError:y=>d(y instanceof Error?y.message:"Disable failed")});Y(()=>{if(!f)return;const y=setTimeout(()=>p(!1),1500);return()=>clearTimeout(y)},[f]);const b=Q(()=>n.isLoading?"loading":s?"setup_in_progress":r?.enabled?"enrolled":"not_enrolled",[n.isLoading,r?.enabled,s]),x=()=>{s&&navigator.clipboard.writeText(s.secret).then(()=>p(!0))};return u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"px-4 py-2.5 border-b border-border flex items-center gap-2",children:[o(Sn,{className:"h-3.5 w-3.5 text-foreground-subtle"}),o("div",{className:"text-xs font-semibold text-foreground",children:"Two-factor authentication"})]}),u("div",{className:"p-4 space-y-3",children:[b==="loading"&&u("div",{className:"flex items-center gap-2 text-xs text-foreground-subtle",children:[o(Se,{className:"h-3.5 w-3.5 animate-spin"}),"Checking status…"]}),b==="not_enrolled"&&u(me,{children:[o("div",{className:"text-xs text-foreground-subtle",children:"2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login."}),o("div",{className:"flex justify-end",children:u("button",{onClick:()=>{d(null),h.mutate()},disabled:h.isPending,className:"inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[h.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(Sn,{className:"h-3 w-3"}),"Enable 2FA"]})})]}),b==="setup_in_progress"&&s&&u(me,{children:[u("div",{className:"text-[11px] text-foreground-subtle",children:["Scan the QR code (or enter the secret manually) into your authenticator app for ",o("span",{className:"font-mono",children:e}),", then enter the 6-digit code below to confirm."]}),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(yB,{value:s.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:s.secret}),u("button",{onClick:x,className:"inline-flex items-center gap-1 text-[10px] text-foreground-subtle hover:text-foreground",children:[f?o(co,{className:"h-3 w-3 text-emerald-500"}):o(Xs,{className:"h-3 w-3"}),f?"Copied":"Copy"]})]})]})]}),u("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"6-digit code"}),o("input",{type:"text",inputMode:"numeric",autoComplete:"one-time-code",placeholder:"123456",value:i,onChange:y=>l(y.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary"})]}),c&&u("div",{className:"text-[11px] text-danger flex items-center gap-1",children:[o(Xn,{className:"h-3 w-3"}),c]}),u("div",{className:"flex justify-end gap-2",children:[o("button",{onClick:()=>{a(null),d(null),l("")},className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),u("button",{onClick:()=>{d(null),m.mutate({code:i})},disabled:m.isPending||i.length!==6,className:"inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[m.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(co,{className:"h-3 w-3"}),"Confirm"]})]})]}),b==="enrolled"&&r&&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(co,{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:"2FA is active"}),u("div",{className:"text-foreground-subtle",children:["Enrolled on ",r.confirmedAt?new Date(r.confirmedAt).toLocaleString():"—"]})]})]}),c&&u("div",{className:"text-[11px] text-danger flex items-center gap-1",children:[o(Xn,{className:"h-3 w-3"}),c]}),o("div",{className:"flex justify-end",children:u("button",{onClick:()=>{d(null),g.mutate()},disabled:g.isPending,className:"rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1",children:[g.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(Sn,{className:"h-3 w-3"}),"Disable 2FA"]})})]})]})]})}function SB(){return o(Xe,{children:o("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:o(Xt,{limit:500,maxHeight:"max-h-[calc(100vh-250px)]",showScope:!0,showFilters:!0})})})}function Bd({tabs:e,defaultTab:t}){const[n,r]=Ba(),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 CB({userId:e,username:t,onClose:n}){const r=ke(),s=Je(),a=fy({userId:e}),i=a.data,l=()=>r.invalidateQueries({queryKey:[["userManagement","getTotpStatus"]]}),c=py({onSuccess:()=>{l(),n()}}),d=a.isLoading?"loading":i?.enabled?"enrolled":"not_enrolled",f=async()=>{await s({title:"Remove 2FA",message:`Remove two-factor authentication for "${t}"? They'll be able to log in with just their password until they re-enroll from their own profile page.`,confirmLabel:"Remove",variant:"danger"})&&c.mutate({userId:e})};return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm p-4",children: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(Sn,{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(ze,{className:"h-4 w-4"})})]}),u("div",{className:"p-4 space-y-4",children:[d==="loading"&&u("div",{className:"flex items-center gap-2 text-xs text-foreground-subtle",children:[o(Se,{className:"h-3.5 w-3.5 animate-spin"}),"Checking status…"]}),d==="not_enrolled"&&u("div",{className:"rounded-md border border-border bg-surface-hover/30 px-3 py-2.5 flex items-start gap-2.5 text-xs text-foreground-subtle",children:[o(Jn,{className:"h-4 w-4 mt-0.5 shrink-0"}),u("div",{children:[o("div",{className:"font-medium text-foreground",children:"2FA not enrolled"}),o("p",{className:"mt-0.5",children:"Only the user themselves can enable 2FA, from their own profile page."})]})]}),d==="enrolled"&&i&&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(co,{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:"2FA 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:"Removing here clears the server-side secret. Use this only when the user has lost access — they'll have to re-enroll from their profile page afterwards."}),u("div",{className:"flex justify-end gap-2",children:[o(Oe,{onClick:n,variant:"secondary",children:"Close"}),u("button",{onClick:f,disabled:c.isPending,className:"rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1",children:[c.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(ze,{className:"h-3 w-3"}),"Remove 2FA"]})]})]})]})]})})}function MB(){const e=ke(),{user:t}=Jt(),[n,r]=_(!1),[s,a]=_(""),[i,l]=_(""),[c,d]=_(!1),[f,p]=_(null),{data:h,isLoading:m,isError:g}=ad(),b=Je(),x=()=>e.invalidateQueries({queryKey:[["userManagement","listUsers"]]}),y=ry({onSuccess:()=>{x(),r(!1),a(""),l(""),d(!1),p(null)},onError:D=>{p(D instanceof Error?D.message:"Failed to create user")}}),w=sy({onSuccess:x}),v=oy({onSuccess:x}),N=id({onSuccess:x}),k=ay({onSuccess:()=>{x(),E(null)}}),[C,E]=_(null),[P,I]=_(null),z=h??[];async function A(D){await b({title:"Delete user",message:`Permanently delete user "${D.username}"? This cannot be undone — any active sessions will be revoked on next request.`,confirmLabel:"Delete",variant:"danger"})&&w.mutate({id:D.id})}async function O(D){const L=window.prompt(`New password for "${D.username}":`);if(!L)return;if(L.length<8){window.alert("Password must be at least 8 characters.");return}await b({title:"Reset password",message:`Reset the password for "${D.username}"? They will need to use the new password on their next login.`,confirmLabel:"Reset"})&&N.mutate({id:D.id,newPassword:L})}function R(D,L){L!==D.isAdmin&&v.mutate({id:D.id,isAdmin:L})}function M(D){return D?new Date(typeof D=="number"?D:String(D)).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}):"—"}return u(Xe,{children:[o("div",{className:"flex items-center justify-end",children:u("button",{onClick:()=>r(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm hover:bg-primary/90",children:[o(ot,{className:"h-3.5 w-3.5"}),"Create User"]})}),n&&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:()=>r(!1),className:"text-foreground-subtle hover:text-foreground",children:o(ze,{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:s,onChange:D=>a(D.target.value),placeholder:"john",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),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:i,onChange:D=>l(D.target.value),placeholder:"••••••••",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),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:c,onChange:D=>d(D.target.checked),className:"rounded border-border focus:ring-primary"}),o("span",{className:"text-foreground-subtle",children:"Unrestricted access"})]})]})]}),f&&o("p",{className:"text-[10px] text-danger",children:f}),u("div",{className:"flex justify-end gap-2",children:[o("button",{onClick:()=>r(!1),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),o("button",{onClick:()=>y.mutate({username:s,password:i,isAdmin:c}),disabled:y.isPending||!s||!i,className:"rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:y.isPending?"Creating...":"Create"})]})]}),m&&o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading..."}),g&&o("div",{className:"text-xs text-danger",children:"Failed to load"}),!m&&!g&&z.length===0&&o("div",{className:"text-xs text-foreground-subtle",children:"No data"}),(()=>{const D=T=>w.isPending&&w.variables?.id===T.id||v.isPending&&v.variables?.id===T.id||N.isPending&&N.variables?.id===T.id;return o(_c,{columns:[{key:"username",header:"Username",render:T=>T.username},{key:"isAdmin",header:"Admin",render:T=>u("label",{className:"inline-flex items-center gap-1.5 text-xs cursor-pointer",children:[o("input",{type:"checkbox",checked:T.isAdmin,onChange:B=>R(T,B.target.checked),disabled:D(T),className:"rounded border-border focus:ring-primary disabled:opacity-50"}),o("span",{className:T.isAdmin?"text-primary font-medium":"text-foreground-subtle",children:T.isAdmin?"Admin":"Regular"})]})},{key:"scopes",header:"Scopes",render:T=>{if(T.isAdmin)return o("span",{className:"text-[10px] text-foreground-subtle italic",children:"unscoped"});const B=T.scopes??[];return u("button",{onClick:()=>E(T),className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground",title:"Edit scope grants",children:[o(pn,{className:"h-3 w-3"}),B.length===0?"no access":`${B.length} grant${B.length===1?"":"s"}`]})}},{key:"createdAt",header:"Created",render:T=>o("span",{className:"text-foreground-subtle",children:M(T.createdAt)})},{key:"actions",header:"Actions",align:"right",render:T=>{const B=D(T),F=T.id!==t?.id&&T.totpEnabled;return u("div",{className:"flex items-center justify-end gap-1",children:[F&&u("button",{onClick:()=>I(T),disabled:B,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground disabled:opacity-50",title:"Remove two-factor authentication",children:[o(Sn,{className:"h-3 w-3"}),"Remove 2FA"]}),u("button",{onClick:()=>O(T),disabled:B,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground disabled:opacity-50",title:"Reset password",children:[o(IR,{className:"h-3 w-3"}),"Reset password"]}),u("button",{onClick:()=>A(T),disabled:B,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50",title:"Delete user",children:[B?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ke,{className:"h-3 w-3"}),"Delete"]})]})}}],rows:z,rowKey:T=>T.id,minWidthPx:560})})(),P&&o(CB,{userId:P.id,username:P.username,onClose:()=>I(null)}),C&&o(EB,{user:C,onClose:()=>E(null),onSubmit:D=>k.mutate({userId:C.id,scopes:D}),submitting:k.isPending})]})}function EB(e){const{user:t}=Jt(),n=t?.isAdmin===!0;return o(IB,{...e,callerScopes:n?null:t?.scopes??[]})}function IB({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=bd(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(ze,{className:"h-4 w-4"})})]}),u("div",{className:"px-4 py-4",children:[o(gd,{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(Se,{className:"h-3 w-3 animate-spin"}):"Save scopes"})]})]})})}const AB="bg-primary/10 text-primary",PB="bg-foreground-subtle/10 text-foreground-subtle";function mo(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString()}function _B(e){return e?e==="*"?"*":e.join(", "):""}function $B(){const e=ke(),t=Je(),{data:n,isLoading:r}=iy(),{data:s}=ad(),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=ly({onSuccess:l}),g=cy({onSuccess:({token:w,record:v})=>{c(),f(!1),h({token:w,label:v.name})}}),b=dy({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(Xe,{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(pn,{className:"h-3.5 w-3.5"}),"New token"]})]}),u(af,{title:"Scoped tokens",subtitle:"Grouped per user",children:[i.length===0&&o(LB,{text:"No users yet — scoped tokens are issued on behalf of an existing user."}),i.map(w=>o(TB,{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(af,{title:"Legacy API keys",subtitle:`${a.length} pre-existing — revoke only`,children:o(rv,{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?AB:PB}`,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:_B(w.allowedProviders)||"all"}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:mo(w.createdAt)}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:mo(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(Se,{className:"h-3 w-3 animate-spin"}):o(Ke,{className:"h-3 w-3"}),"Revoke"]})})]},w.id)})})}),r&&o(DB,{}),d&&o(RB,{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(OB,{token:p.token,label:p.label,onClose:()=>h(null)})]})}function af({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 DB(){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 LB({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 rv({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 TB({userId:e,username:t,onRevoke:n,revokePending:r,revokeId:s}){const{data:a,isLoading:i}=uy({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(rv,{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:mo(c.expiresAt)}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:mo(c.lastUsedAt)}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:mo(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(Se,{className:"h-3 w-3 animate-spin"}):o(Ke,{className:"h-3 w-3"}),"Revoke"]})})]},c.id)})})]})}function RB({users:e,onClose:t,onSubmit:n,submitting:r}){const{user:s}=Jt(),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=bd(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(ov,{title:"Create scoped token",onClose:t,children:[u("div",{className:"space-y-3",children:[o(Ns,{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(Ns,{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(Ns,{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(gd,{value:p,onChange:h,clampToParent:i}),b&&o("p",{className:"mt-1 text-[10px] text-danger",children:b})]}),o(Ns,{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(sv,{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(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(pn,{className:"h-3.5 w-3.5"}),"Issue token"]})]})]})}function OB({token:e,label:t,onClose:n}){const[r,s]=_(!1),a=async()=>{try{await navigator.clipboard.writeText(e),s(!0)}catch{}};return u(ov,{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(sv,{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(Xs,{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 ov({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(ze,{className:"h-4 w-4"})})]}),o("div",{className:"p-4",children:n})]})})}function sv({children:e}){return o("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:e})}function Ns({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 BB({addonId:e,fallback:t,tileClassName:n,iconPath:r="assets/icon.svg"}){const[s,a]=_(!1),i=`/api/addon-assets/${e}/${r}`;return o("div",{className:`h-10 w-10 rounded-lg flex items-center justify-center shrink-0 ${n}`,children:s?o(t,{className:"h-5 w-5"}):o("img",{src:i,alt:e,className:"h-6 w-6",onError:()=>a(!0)})})}function Ga(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(C=>C.addonId===w)||v(l[0]?.addonId??null))},[l,w]);const N=C=>v(E=>E===C?null:C),k=a?`/system/addons?capability=${encodeURIComponent(a)}`:null;return o(Xe,{icon:x?r:void 0,title:x?t:void 0,subtitle:x?n:void 0,actions:x&&k?o(Zn,{to:k,children:u(Oe,{variant:"primary",size:"sm",children:[o(ot,{className:"h-3.5 w-3.5 mr-1"}),i]})}):void 0,children:c?o(Tt,{children:o("div",{className:"p-6 text-sm text-foreground-subtle",children:"Loading…"})}):l.length===0?o(Tt,{children:o(Oc,{title:d,description:f??(k?`Install an addon that declares the "${a}" capability to get started.`:void 0),action:x&&k?o(Zn,{to:k,children:u(Oe,{variant:"primary",size:"sm",children:[o(ot,{className:"h-3.5 w-3.5 mr-1"}),i]})}):void 0})}):u("div",{className:"flex flex-col gap-4",children:[l.map(C=>{const E=!y||w===C.addonId,P=p?.(C)??"bg-primary/15 text-primary";return u(Tt,{children:[u("div",{className:`flex items-center gap-3 p-4 ${E?"border-b border-border":""}`,children:[y&&o("button",{type:"button",onClick:()=>N(C.addonId),"aria-label":E?"Collapse":"Expand",className:"shrink-0 p-1 rounded hover:bg-foreground-subtle/10 transition-colors",children:o(Nt,{className:`h-4 w-4 text-foreground-subtle transition-transform ${E?"rotate-180":""}`})}),u("button",{type:"button",onClick:()=>y&&N(C.addonId),className:`flex items-center gap-4 flex-1 min-w-0 text-left ${y?"hover:opacity-80 transition-opacity":""}`,disabled:!y,children:[o(BB,{addonId:C.addonId,fallback:s,tileClassName:P}),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:C.displayName}),h?.(C)]}),u("div",{className:"text-xs text-foreground-subtle mt-1 font-mono",children:["@camstack/addon-",C.addonId]})]})]}),m&&o("div",{className:"flex items-center gap-1 shrink-0",children:m(C)})]}),E&&g?.(C)]},C.addonId)}),b]})})}function Ka({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(Gr,{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(lf,{kind:"logs",active:i==="logs",onClick:()=>l("logs")}),o(lf,{kind:"events",active:i==="events",onClick:()=>l("events")})]})]}),i==="logs"?o(Xt,{addonId:e,maxHeight:r,showFilters:!1}):o(fr,{addonId:e,category:"addon.*",maxHeight:r})]})]})}function lf({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"?rt:Go,{className:"h-3 w-3"}),e==="logs"?"Logs":"Events"]})}function zB(e){const t=e.kind??"";return t==="local"||e.addonId==="local-auth"?{headline:"Username + password (local).",icon:u0,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:Wt,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:Wt,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:Sn,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:Sn,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:pn,bullets:["Generic authentication provider. No additional hints registered."]}}function FB(){const e=Gc(),t=e.data??[];return o(Ga,{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:pn,itemIcon:pn,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(u0,{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(Wt,{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(ut,{className:"inline h-2.5 w-2.5 mr-0.5"}),n.status]})]}),renderExpandedBody:n=>{const r=zB(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(PT,{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(Jn,{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(Ka,{addonId:n.addonId,maxHeight:"max-h-64"})})]})}})}function jB(){return o("div",{className:"flex flex-col p-4",children:o(Bd,{tabs:[{id:"users",label:"Users",icon:W6,content:o(MB,{})},{id:"api-keys",label:"Tokens",icon:d0,content:o($B,{})},{id:"authentication",label:"Authentication",icon:pn,content:o(FB,{})}]})})}function av(){const e=ke(),t=Gx(void 0,{refetchInterval:5e3}),n=t.data??[],[r,s]=_(null),[a,i]=_({}),l=(p,h)=>{e.invalidateQueries({queryKey:[["remoteAccess"]]}),s(null),i(m=>{if(!(h.addonId in m))return m;const g={...m};return delete g[h.addonId],g})},c=(p,h)=>{s(null);const m=p instanceof Error?p.message:String(p);i(g=>({...g,[h.addonId]:m}))},d=Kx({onSuccess:l,onError:c}),f=Wx({onSuccess:l,onError:c});return o(Ga,{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:Wt,itemIcon:Wt,capability:"network-access",installButtonLabel:"Add tunnel",items:n,isLoading:t.isLoading,emptyTitle:"No remote-access providers installed",emptyDescription:"Install a tunnel addon (e.g. @camstack/addon-cloudflare-tunnel) to expose this hub publicly.",itemIconColor:p=>p.connected?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle",renderStatusBadges:p=>u(me,{children:[o("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${p.connected?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:p.connected?"Connected":"Disconnected"}),p.endpoint&&u("a",{href:p.endpoint.url,target:"_blank",rel:"noopener noreferrer",onClick:h=>h.stopPropagation(),className:"text-[10px] text-emerald-700 dark:text-emerald-300 hover:underline flex items-center gap-1",children:[o($d,{className:"h-3 w-3"}),p.endpoint.url]}),p.error&&o("span",{className:"text-[10px] text-danger",children:p.error}),a[p.addonId]&&o("span",{className:"text-[10px] text-danger truncate max-w-md",title:a[p.addonId],children:a[p.addonId]})]}),renderActionButtons:p=>{const h=r===p.addonId;return p.connected?u(Oe,{size:"sm",variant:"secondary",disabled:h,onClick:()=>{s(p.addonId),f.mutate({addonId:p.addonId})},children:[h?o(Se,{className:"h-3 w-3 animate-spin"}):o(Yo,{className:"h-3 w-3"}),"Stop"]}):u(Oe,{size:"sm",variant:"primary",disabled:h,onClick:()=>{s(p.addonId),d.mutate({addonId:p.addonId})},children:[h?o(Se,{className:"h-3 w-3 animate-spin"}):o(Fa,{className:"h-3 w-3"}),"Start"]})},renderExpandedBody:p=>o("div",{className:"p-4",children:o(Ka,{addonId:p.addonId,maxHeight:"max-h-72"})})})}function HB(){const e=ke(),t=ey(void 0,{refetchInterval:3e4}),n=ty(),r=t.data??[],s=n.data??[],[a,i]=_(null),l=ny({onSuccess:()=>{e.invalidateQueries({queryKey:[["turnOrchestrator"]]}),i(null)},onError:()=>i(null)});return o(Ga,{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:En,itemIcon:En,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(Oe,{size:"sm",variant:"secondary",disabled:d,onClick:()=>{i(c.addonId),l.mutate({addonId:c.addonId,enabled:!1})},children:[d?o(Se,{className:"h-3 w-3 animate-spin"}):o(Yo,{className:"h-3 w-3"}),"Disable"]}):u(Oe,{size:"sm",variant:"primary",disabled:d,onClick:()=>{i(c.addonId),l.mutate({addonId:c.addonId,enabled:!0})},children:[d?o(Se,{className:"h-3 w-3 animate-spin"}):o(Fa,{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(Ka,{addonId:c.addonId,maxHeight:"max-h-72"})})]}),trailing:u(Tt,{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(Oe,{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 VB={lan:En,wifi:er,docker:Ko,vpn:Dd,loopback:un,other:un},qB={lan:"LAN",wifi:"Wi-Fi",docker:"Docker",vpn:"VPN",loopback:"Loopback",other:"Other"},UB=["lan","wifi","vpn","docker","other","loopback"];function QB(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 UB.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=VB[f]??un;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:qB[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(ut,{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 cf={"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 GB(){const e=ke(),t=De(),n=jb(void 0,{refetchInterval:3e4}),r=Vb(void 0),s=qb({onSuccess:()=>{e.invalidateQueries({queryKey:[["localNetwork"]]})}}),a=Ub({onSuccess:C=>{p(C.addresses),e.invalidateQueries({queryKey:[["localNetwork"]]})}}),i=Q(()=>n.data?.interfaces??[],[n.data]),l=typeof window<"u"?Number(window.location.port)||(window.location.protocol==="https:"?443:80):4e3,c=typeof window<"u"&&window.location.protocol==="https:"?"https":"http",d=Hb({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 C=[...f].sort(),E=[...g].sort();return C.some((P,I)=>P!==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 C=await t.raceConnectionEndpoints({perCandidateTimeoutMs:1500});console.info("[network-addresses] race result",C)}catch(C){console.warn("[network-addresses] race failed",C)}},k=d.data?.endpoints??[];return u(Xe,{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(Oe,{size:"sm",variant:"secondary",onClick:v,disabled:n.isLoading,children:[o(ht,{className:`h-3 w-3 ${n.isLoading?"animate-spin":""}`}),"Refresh"]}),o(Oe,{size:"sm",variant:"secondary",onClick:N,children:"Probe race"})]})]}),u("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[u(Tt,{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(Oe,{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(R6,{className:"h-3 w-3"}),a.isPending?"Detecting…":"Best match"]}),u(Oe,{size:"sm",variant:"secondary",onClick:w,disabled:f.length===0||s.isPending,children:[o(b0,{className:"h-3 w-3"}),"Clear"]}),b&&o(Oe,{size:"sm",variant:"secondary",onClick:y,disabled:s.isPending,children:"Discard"}),u(Oe,{size:"sm",variant:"primary",onClick:x,disabled:!b||s.isPending,children:[o(x6,{className:"h-3 w-3"}),s.isPending?"Saving…":"Save"]})]})]}),o("div",{className:"p-4",children:o(QB,{mode:"multiple",interfaces:i,value:f,onChange:p,disabled:s.isPending,emptyMessage:n.isLoading?"Loading interfaces…":"No interfaces detected."})})]}),u(Tt,{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(C=>u("li",{className:`flex items-center gap-2 flex-wrap ${C.plausible?"":"opacity-80"}`,children:[o("span",{className:"font-mono text-[10px] w-10 text-foreground-subtle",children:String(C.priority).padStart(4,"0")}),o("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${cf[C.kind]??cf.loopback}`,children:C.kind}),C.interfaceKind!=="lan"&&C.interfaceKind!=="public"&&o("span",{className:"text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-medium uppercase",children:C.interfaceKind}),!C.plausible&&C.interfaceKind!=="loopback"&&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:C.plausibleReason||void 0,children:[o(ut,{className:"h-2.5 w-2.5"}),"Unlikely usable"]}),o("span",{className:`font-mono break-all ${C.plausible?"text-foreground":"text-foreground-subtle"}`,children:C.baseUrl}),u("span",{className:"text-foreground-subtle",children:["— ",C.label]})]},`${C.priority}-${C.baseUrl}`))})})]})]})]})}const KB={mesh:"bg-violet-500/15 text-violet-700 dark:text-violet-300",public:"bg-blue-500/15 text-blue-700 dark:text-blue-300"},WB=5e3,YB=3e4;function iv(){const e=Qb(void 0,{refetchInterval:WB}),t=e.data??[];return o(Ga,{title:"Mesh Networks",subtitle:"Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).",pageIcon:Ko,itemIcon:En,capability:"mesh-network",installButtonLabel:"Add mesh",items:t,isLoading:e.isLoading,emptyTitle:"No mesh-network providers installed",emptyDescription:"Install a mesh addon (e.g. @camstack/addon-tailscale-client) to join this hub into a private VPN mesh.",itemIconColor:n=>n.joined?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle",renderStatusBadges:n=>u(me,{children:[o("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${n.joined?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:n.joined?"Joined":"Not joined"}),n.joined&&u("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle",children:[n.peerCount," peer",n.peerCount===1?"":"s"]})]}),renderActionButtons:n=>o(ZB,{addonId:n.addonId,joined:n.joined}),renderExpandedBody:n=>o(XB,{provider:n})})}function ZB({addonId:e,joined:t}){const n=ke(),[r,s]=_(!1),[a,i]=_(null),[l,c]=_(null),d=De(),f=q(()=>{n.invalidateQueries({queryKey:[["meshOrchestrator"]]})},[n]),p=Kb(),h=Gb({onSuccess:f}),m=Wb({onSuccess:f}),g=q(async()=>{s(!0),i(null);const x={cancelled:!1};c(x);try{const y=await p.mutateAsync({addonId:e});if(x.cancelled)return;y.loginUrl&&window.open(y.loginUrl,"_blank","noopener,noreferrer");const w=Date.now(),v=10*6e4;for(;!x.cancelled&&(await oz(2e3),!x.cancelled);){if((await d.trpcClient.meshOrchestrator.listProviders.query().catch(()=>null))?.find(C=>C.addonId===e)?.joined){f();break}if(Date.now()-w>v){i("Connect timed out — re-open the auth URL and try again.");break}}}catch(y){i(y instanceof Error?y.message:"Connect failed")}finally{s(!1),c(null)}},[e,f,p,d]),b=q(()=>{l&&(l.cancelled=!0),s(!1),c(null)},[l]);return u("div",{className:"flex items-center gap-2",children:[a&&o("span",{className:"text-[10px] text-danger truncate max-w-xs",children:a}),t?u(me,{children:[u(Oe,{size:"sm",variant:"secondary",disabled:h.isPending,onClick:()=>h.mutate({addonId:e}),children:[h.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ld,{className:"h-3 w-3"}),"Disconnect"]}),u(Oe,{size:"sm",variant:"ghost",disabled:m.isPending,onClick:()=>m.mutate({addonId:e}),children:[m.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(wp,{className:"h-3 w-3"}),"Log out"]})]}):r?u(Oe,{size:"sm",variant:"ghost",onClick:b,children:[o(ze,{className:"h-3 w-3 mr-1"})," Cancel"]}):u(me,{children:[u(Oe,{size:"sm",variant:"primary",onClick:()=>void g(),children:[o(OR,{className:"h-3 w-3"}),"Connect"]}),u(Oe,{size:"sm",variant:"ghost",disabled:m.isPending,onClick:()=>m.mutate({addonId:e}),children:[m.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(wp,{className:"h-3 w-3"}),"Log out"]})]})]})}function XB({provider:e}){const[t,n]=_("status"),r=Yb({addonId:e.addonId},{refetchInterval:t==="peers"?YB:!1,enabled:t==="peers"});return u("div",{children:[u("div",{className:"px-4 pt-3 flex items-center gap-1 border-b border-border",children:[o(Zi,{active:t==="status",onClick:()=>n("status"),children:"Status"}),o(Zi,{active:t==="peers",onClick:()=>n("peers"),children:"Peers"}),o(Zi,{active:t==="settings",onClick:()=>n("settings"),children:"Settings"})]}),t==="status"&&o(JB,{provider:e}),t==="peers"&&o(nz,{peers:r.data?.peers??[],loading:r.isLoading}),t==="settings"&&o("div",{className:"p-4",children:o(Ka,{addonId:e.addonId,maxHeight:"max-h-72"})})]})}function Zi({active:e,onClick:t,children:n}){return o("button",{type:"button",onClick:t,className:e?"text-xs font-medium px-3 py-1.5 border-b-2 border-primary text-foreground -mb-px":"text-xs font-medium px-3 py-1.5 border-b-2 border-transparent text-foreground-subtle hover:text-foreground",children:n})}function JB({provider:e}){return u("div",{className:"p-4 space-y-4",children:[e.error&&o("div",{className:"rounded-md border border-danger/40 bg-danger/5 p-3 text-xs text-danger flex items-center gap-2",children:e.error}),o(ez,{provider:e}),e.endpoints.length>0&&u("div",{className:"space-y-1.5",children:[o("div",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Endpoints"}),e.endpoints.map(t=>u("div",{className:"flex items-center gap-2 text-xs flex-wrap",children:[u("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${KB[t.scope]??"bg-foreground-subtle/15 text-foreground-subtle"}`,children:[t.scope==="public"?o(Wt,{className:"inline h-2.5 w-2.5 mr-0.5"}):null,t.label]}),u("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",onClick:n=>n.stopPropagation(),className:"text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1",children:[o($d,{className:"h-3 w-3 shrink-0"}),t.url]})]},t.id))]})]})}function ez({provider:e}){const t=[{label:"Tenant",value:e.tenantName||"—"},{label:"User",value:e.userLogin??"—"},{label:"Control plane",value:e.controlPlaneUrl||"—"},{label:"Mesh IP",value:e.meshIp||"—",mono:!0},{label:"MagicDNS",value:e.magicDnsHostname||"—",mono:!0},{label:"DNS suffix",value:e.magicDnsSuffix||"—",mono:!0},{label:"Peers",value:String(e.peerCount)},{label:"Key expiry",value:e.keyExpiry?tz(e.keyExpiry):"—"}];return o("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5",children:t.map(n=>u("div",{className:"flex items-baseline justify-between gap-3 text-xs",children:[o("span",{className:"text-foreground-subtle shrink-0",children:n.label}),o("span",{className:`text-foreground truncate ${n.mono?"font-mono":""}`,children:n.value})]},n.label))})}function tz(e){const t=e-Date.now();if(t<0)return`Expired ${lv(e)}`;const n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return`in ${n} days`;const r=Math.floor(t/36e5);return r>1?`in ${r}h`:`in ${Math.max(1,Math.floor(t/6e4))} min`}function nz({peers:e,loading:t}){const n=Q(()=>e.map(a=>({...a,_id:a.id})),[e]),r=q(a=>{a&&navigator.clipboard?.writeText(a)},[]),s=Q(()=>[{key:"hostname",header:"Hostname",render:a=>u("div",{className:"flex flex-col",children:[u("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"font-medium text-foreground",children:a.hostname||"(unknown)"}),a.isSelf&&o(ln,{variant:"info",children:"self"}),a.exitNodeOption&&o(ln,{variant:"warning",children:"exit-node"})]}),a.userLogin&&o("div",{className:"text-[10px] text-foreground-subtle truncate",children:a.userLogin})]})},{key:"magicDns",header:"MagicDNS",render:a=>a.magicDns?u("div",{className:"flex items-center gap-1",children:[o("span",{className:"font-mono text-xs truncate",children:a.magicDns}),o("button",{onClick:()=>r(a.magicDns),className:"p-0.5 hover:bg-foreground-subtle/10 rounded","aria-label":"Copy MagicDNS",children:o(Xs,{className:"h-3 w-3 text-foreground-subtle"})})]}):o("span",{className:"text-foreground-subtle",children:"—"})},{key:"addresses",header:"IP",render:a=>{const i=a.addresses[0]??"";return i?u("div",{className:"flex items-center gap-1",children:[o("span",{className:"font-mono text-xs",children:i}),o("button",{onClick:()=>r(i),className:"p-0.5 hover:bg-foreground-subtle/10 rounded","aria-label":"Copy IP",children:o(Xs,{className:"h-3 w-3 text-foreground-subtle"})})]}):o("span",{className:"text-foreground-subtle",children:"—"})}},{key:"connection",header:"Connection",render:a=>u("div",{className:"flex items-center gap-1.5",children:[o(ln,{variant:rz(a.connection),children:a.connection}),a.relay&&o("span",{className:"text-[10px] text-foreground-subtle font-mono",children:a.relay})]})},{key:"routes",header:"Routes",render:a=>a.advertisedRoutes.length>0?o("span",{className:"text-[10px] font-mono text-foreground-subtle truncate",children:a.advertisedRoutes.join(", ")}):o("span",{className:"text-foreground-subtle",children:"—"})},{key:"tx",header:"TX / RX",render:a=>u("span",{className:"text-[10px] text-foreground-subtle font-mono",children:["↑ ",df(a.txBytes)," · ↓ ",df(a.rxBytes)]})},{key:"lastSeen",header:"Last seen",render:a=>o("span",{className:"text-[10px] text-foreground-subtle",children:a.lastSeenMs>0?lv(a.lastSeenMs):"—"})}],[r]);return t&&e.length===0?u("div",{className:"p-4 text-xs text-foreground-subtle",children:[o(Se,{className:"h-3 w-3 animate-spin inline mr-1"})," Loading peers…"]}):e.length===0?o("div",{className:"p-4 text-xs text-foreground-subtle",children:"No peers visible — your tailnet may be empty or the host is not joined."}):o("div",{className:"p-4",children:o(_c,{columns:s,rows:n,rowKey:a=>a._id,minWidthPx:820})})}function rz(e){return e==="direct"?"success":e==="relay"?"warning":"info"}function df(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)}MB`:`${(e/1024/1024/1024).toFixed(2)}GB`}function lv(e){const t=Date.now()-e;return t<6e4?"just now":t<36e5?`${Math.round(t/6e4)}m ago`:t<864e5?`${Math.round(t/36e5)}h ago`:`${Math.round(t/864e5)}d ago`}function oz(e){return new Promise(t=>setTimeout(t,e))}function sz(){return o("div",{className:"flex flex-col p-4",children:o(Bd,{tabs:[{id:"addresses",label:"Network Addresses",icon:un,content:o(GB,{})},{id:"remote-access",label:"Remote Access",icon:Wt,content:o(av,{})},{id:"mesh",label:"Mesh Networks",icon:Ko,content:o(iv,{})},{id:"turn",label:"TURN Servers",icon:En,content:o(HB,{})}]})})}const az=[{kind:"mesh",title:"Mesh networks",subtitle:"Private VPN meshes connecting this hub to your other devices (Tailscale, Headscale, …).",icon:Ko,emptyHint:"Install a mesh-network addon (e.g. @camstack/addon-tailscale-client) to join this hub into a private mesh.",addLabel:"Add mesh"},{kind:"ingress",title:"Public ingress",subtitle:"Public tunnels that expose this hub to the internet (Cloudflare Tunnel, Tailscale Funnel, …).",icon:Wt,emptyHint:"Install a tunnel addon (e.g. @camstack/addon-cloudflare-tunnel) to expose this hub publicly.",addLabel:"Add tunnel"},{kind:"broker",title:"Brokers",subtitle:"Message brokers consumed by exporters and downstream automations (MQTT today, future Kafka, …).",icon:ja,emptyHint:"Install a broker addon (e.g. @camstack/addon-mqtt-broker) to publish device events for downstream automations.",addLabel:"Add broker"},{kind:"email",title:"Email providers",subtitle:"Outbound email relays used for magic-link login, notifications, and alerts (SMTP today, future SendGrid, …).",icon:FR,emptyHint:"Install an email-provider addon (e.g. @camstack/addon-smtp) so the hub can deliver magic-link logins and notifications.",addLabel:"Add email provider"},{kind:"device-export",title:"Device export",subtitle:"Outbound exporters that publish CamStack devices to other ecosystems (HomeAssistant, HomeKit, Alexa, …).",icon:M6,emptyHint:"Install an export addon (e.g. @camstack/addon-export-ha-mqtt) to surface your CamStack devices in HomeAssistant, HomeKit, …",addLabel:"Add export"}];function iz(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e.name;if(typeof t=="string")return t}return null}function lz(e){const t=e,n=t?.manifest;if(!n?.id)return null;const r=[];for(const a of n.capabilities??[]){const i=iz(a);i!==null&&r.push(i)}const s=n.packageDisplayName??n.name??n.id;return{addonId:n.id,displayName:s,packageName:n.packageName??`@camstack/addon-${n.id}`,capNames:r,processState:t?.process?.state??null}}function cz(e,t){const n=new Set(t);return e.filter(r=>r.capNames.some(s=>n.has(s)))}function dz(e){const t=e[0];return t?`/system/addons?capability=${encodeURIComponent(t)}`:null}function uz({kind:e,title:t,subtitle:n,icon:r,installHref:s,addLabel:a}){return u("div",{className:"flex items-center justify-between gap-3",children:[u("div",{className:"flex items-start gap-3 min-w-0",children:[o("div",{className:"h-9 w-9 rounded-lg bg-primary/10 text-primary flex items-center justify-center shrink-0",children:o(r,{className:"h-4 w-4"})}),u("div",{className:"min-w-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:t}),o(mz,{kind:e})]}),o("p",{className:"text-xs text-foreground-subtle mt-0.5",children:n})]})]}),s&&o(Zn,{to:s,className:"shrink-0",children:u(Oe,{size:"sm",variant:"primary",children:[o(ot,{className:"h-3.5 w-3.5 mr-1"}),a]})})]})}function pz(e){return e==="running"?{label:"Running",className:"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300"}:e==="crashed"||e==="failed"?{label:e==="failed"?"Failed":"Crashed",className:"bg-danger/15 text-danger"}:e==="stopped"||e==="disabled"?{label:"Stopped",className:"bg-foreground-subtle/15 text-foreground-subtle"}:{label:e??"Unknown",className:"bg-foreground-subtle/15 text-foreground-subtle"}}function zd({label:e,className:t}){return o("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t}`,children:e})}function fz(){const{data:e,isLoading:t}=Jb(void 0,{refetchInterval:1e4,retry:!1});if(t||!e)return null;const n=TN.safeParse(e);if(!n.success)return null;const r=n.data,s=`${r.brokerCount} broker${r.brokerCount===1?"":"s"}${r.embeddedRunning?" • embedded up":""}`;return o(zd,{label:s,className:"bg-primary/10 text-primary"})}function hz(){const{data:e,isLoading:t}=gb(void 0,{refetchInterval:1e4,retry:!1});if(t||!e)return null;const n=RN.safeParse(e);if(!n.success)return null;const r=n.data,s=r.linkState==="linked"?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":r.linkState==="error"?"bg-danger/15 text-danger":"bg-foreground-subtle/15 text-foreground-subtle",a=`${r.linkState} • ${r.exposedDeviceCount} exposed`;return o(zd,{label:a,className:s})}function mz({kind:e}){return e==="broker"?o(fz,{}):e==="device-export"?o(hz,{}):null}function gz(e,t){const n=t.get(e);return n||`/system/addons?addonId=${encodeURIComponent(e)}`}function bz({rows:e,emptyHint:t,emptyTitle:n,installHref:r,addLabel:s,addonPagePaths:a}){return e.length===0?o(Tt,{children:o(Oc,{title:n,description:t,action:r?o(Zn,{to:r,children:u(Oe,{size:"sm",variant:"primary",children:[o(ot,{className:"h-3.5 w-3.5 mr-1"}),s]})}):void 0})}):o("div",{className:"flex flex-col gap-3",children:e.map(i=>{const l=pz(i.processState);return o(Tt,{children:u("div",{className:"flex items-center gap-4 p-4",children:[o("div",{className:"h-10 w-10 rounded-lg bg-primary/15 text-primary flex items-center justify-center shrink-0",children:o(So,{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:i.displayName}),o(zd,{label:l.label,className:l.className})]}),o("div",{className:"text-xs text-foreground-subtle mt-1 font-mono truncate",children:i.packageName})]}),o(Zn,{to:gz(i.addonId,a),className:"shrink-0",children:o(Oe,{size:"sm",variant:"secondary",children:"Configure"})})]})},i.addonId)})})}function xz(e){const t=new Map;for(const n of e??[])t.has(n.addonId)||t.set(n.addonId,n.page.path);return t}function yz(){const t=(Ho(void 0,{refetchInterval:1e4}).data??[]).map(lz).filter(s=>s!==null),n=Ea(void 0,{refetchInterval:3e4}),r=xz(n.data);return o(Xe,{icon:ko,title:"Integrations",subtitle:"External systems this hub talks to — mesh VPNs, public tunnels, brokers, email, and device exporters. Per-provider settings live on each addon's own page; this page is the directory.",children:o("div",{className:"flex flex-col gap-6",children:az.map(s=>{const a=Object.entries(FN).filter(([,l])=>l===s.kind).map(([l])=>l),i=dz(a);return u("section",{className:"space-y-3",children:[o(uz,{kind:s.kind,title:s.title,subtitle:s.subtitle,icon:s.icon,installHref:i,addLabel:s.addLabel}),s.kind==="mesh"?o(iv,{}):s.kind==="ingress"?o(av,{}):o(bz,{rows:cz(t,a),emptyHint:s.emptyHint,emptyTitle:`No ${s.title.toLowerCase()} installed`,installHref:i,addLabel:s.addLabel,addonPagePaths:r})]},s.kind)})})})}function vz(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 wz({location:e,onEdit:t,onDelete:n,onSetDefault:r}){const s=vz(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(Pi,{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(Pi,{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(Pi,{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&&Ds[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(Ke,{className:"h-3 w-3"})})]})]})}function Nz({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}),Ds[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."})]}),Ds[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(ot,{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:Ds[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(wz,{location:d,onEdit:a,onDelete:i,onSetDefault:l},d.id))})]})}function kz(e){const t=e.trim().toLowerCase();return t.length===0?"":t.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function uf(e,t){const n=kz(t),r=n.length>0?n:"default";return`${e}:${r}`}function cv({initialType:e,onClose:t,onCreated:n}){const r=ke(),s=De().trpcClient,[a,i]=_("picker"),[l,c]=_(e),[d,f]=_(null),[p,h]=_({}),[m,g]=_(""),[b,x]=_(null),[y,w]=_(!1),[v,N]=_(null),[k,C]=_(!1),E=sd(),P=Q(()=>{const D=E.data;return Array.isArray(D)?D.filter(T=>T.supportedLocationTypes.includes(l)):[]},[E.data,l]),I=E.isLoading,z=$a({onSuccess:()=>{r.invalidateQueries({queryKey:[["storage","listLocations"]]}),n()}}),A=Q(()=>b!==null&&b.length>0?b:uf(l,m),[l,m,b]),O=async()=>{if(d){C(!0),N(null);try{const T=await(B=>s.storage.testConfig.query(B))({providerId:d.providerId,config:p});N(T)}catch(D){N({ok:!1,error:D instanceof Error?D.message:String(D)})}finally{C(!1)}}},R=()=>{d&&z.mutate({id:A,type:l,displayName:m.trim(),providerId:d.providerId,config:p,isDefault:y})},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:D=>D.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[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(ze,{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&&P.length===0&&u("div",{className:"rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle",children:['No storage-provider supports type "',l,'". Install a compatible addon (e.g. ',o("code",{className:"font-mono",children:"remote-storage"}),") to enable it."]}),P.map(D=>u("button",{onClick:()=>{f(D),i("config")},className:"flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors",children:[u("div",{className:"flex-1 min-w-0",children:[o("p",{className:"text-xs font-semibold text-foreground",children:D.displayName}),o("p",{className:"text-[10px] text-foreground-subtle font-mono mt-0.5 truncate",children:D.providerId})]}),o(Et,{className:"h-4 w-4 text-foreground-subtle flex-shrink-0"})]},D.providerId))]}),a==="config"&&d&&u("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[o(In,{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:()=>{O()},disabled:k,className:"rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50",children:k?"Testing…":"Test connection"}),o("button",{onClick:()=>i("naming"),className:"rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:"Next"})]})]})]}),a==="naming"&&d&&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:D=>g(D.target.value),placeholder:`${l} on ${d.displayName}`,className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary"})]}),u("div",{className:"space-y-1",children:[u("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:["Id ",o("span",{className:"lowercase tracking-normal text-foreground-subtle",children:"— auto-derived; override if needed"})]}),o("input",{type:"text",value:A,onChange:D=>x(D.target.value),placeholder:uf(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:D=>w(D.target.checked),className:"accent-primary mt-0.5"}),u("div",{className:"space-y-0.5",children:[u("div",{className:"text-xs font-medium text-foreground",children:['Mark as default for type "',l,'"']}),u("div",{className:"text-[10px] text-foreground-subtle",children:["Setting this as default will demote the current default for this type. References like"," ",u("code",{className:"font-mono",children:['"',l,'"']})," resolve to whichever location is the default."]})]})]}),z.isError&&o("div",{className:"rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]",children:z.error instanceof Error?z.error.message:String(z.error)}),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:z.isPending||m.trim().length===0,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[z.isPending?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):null,z.isPending?"Saving…":"Save"]})]})]})]})]})})}function Sz({location:e,onClose:t,onSaved:n}){const r=ke(),s=De().trpcClient,[a,i]=_({...e.config}),[l,c]=_(e.displayName),[d,f]=_(null),[p,h]=_(!1),m=sd(),g=Q(()=>{const w=m.data;return Array.isArray(w)?w.find(N=>N.providerId===e.providerId)??null:null},[m.data,e.providerId]),b=$a({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(ze,{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(In,{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(Se,{className:"h-3.5 w-3.5 animate-spin"}):null,b.isPending?"Saving…":"Save"]})]})]})]})})}const Cz={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"},Mz={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 Ez(){const e=ke(),t=Je(),{data:n,isLoading:r,isError:s}=Yx({}),[a,i]=_(null),[l,c]=_(null),d=Zx({onSuccess:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]})}}),f=$a({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 xu)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(Xe,{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:xu.map(g=>o(Nz,{type:g,displayName:Cz[g],description:Mz[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(cv,{initialType:a,onClose:()=>i(null),onCreated:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]}),i(null)}}),l!==null&&o(Sz,{location:l,onClose:()=>c(null),onSaved:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]}),c(null)}})]})}const Iz=[["backup","listDestinations"]],Az=["backup","listArchives"];function Pz({destinationId:e,restoreSupported:t,onOpenRestoreWizard:n}){const r=ke(),s=Je(),{data:a,isLoading:i,isError:l}=Wc({destinationId:e}),c=a??[],d=cb({onSuccess:()=>{r.invalidateQueries({queryKey:[[...Az]]}),r.invalidateQueries({queryKey:Iz})}}),f=q(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=q(async b=>{h(b.id);try{const x=localStorage.getItem("camstack_admin_token"),y={};x&&(y.Authorization=`Bearer ${x}`);const w=await fetch(_z(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:$z(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(Se,{className:"h-3 w-3 animate-spin"}):o(Mn,{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(yt,{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(Se,{className:"h-3 w-3 animate-spin"}):o(Ke,{className:"h-3 w-3"})})]})})]},b.id))})]})})}function _z(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function $z(e){return new Date(e).toLocaleString(void 0,{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}const dv=[{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 Dz(e){const t=e.trim();for(const n of dv)if(n.cron===t)return n.id;return"custom"}function Lz({value:e,onChange:t,previewCount:n=5,disabled:r=!1}){const s=Dz(e),[a,i]=_(s==="custom");Y(()=>{s!=="custom"&&i(!1)},[s]);const l=Oz(e,250),c=ub({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:[dv.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(Se,{className:"h-3 w-3 animate-spin"}),"Validating…"]}):t===null?null:t.ok?t.nextRuns.length===0?o("div",{className:"rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle",children:"No future runs match this expression."}):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:Rz(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 Rz(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 Oz(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 Bz=[["backup","listDestinations"]];function zz({onCreateAt:e,onOpenRestoreWizard:t}){const{data:n,isLoading:r,isError:s}=Kc(),a=n??[],[i,l]=_(null),c=f=>{l(p=>p===f?null:f)},d=qz();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(Fz,{row:f,isOpen:i===f.id,onToggle:()=>c(f.id),onCreateAt:e,liveLastSuccessAt:p?.at,liveLastSuccessSizeBytes:p?.sizeBytes,...t?{onOpenRestoreWizard:t}:{}},f.id)})})]})})}function Fz({row:e,isOpen:t,onToggle:n,onCreateAt:r,onOpenRestoreWizard:s,liveLastSuccessAt:a,liveLastSuccessSizeBytes:i}){const l=ke(),c=db({onSuccess:()=>{l.invalidateQueries({queryKey:Bz})}}),[d,f]=_(String(e.retentionCount));Y(()=>{f(String(e.retentionCount))},[e.retentionCount]);const[p,h]=_(!1),m=q(x=>{c.mutate({locationId:e.id,enabled:x,retentionCount:e.retentionCount,...e.label!==void 0?{label:e.label}:{},...e.cron!==void 0?{cron:e.cron}:{}})},[c,e.id,e.retentionCount,e.label,e.cron]),g=q(()=>{const x=Number.parseInt(d,10);if(Number.isNaN(x)||x<1){f(String(e.retentionCount));return}x!==e.retentionCount&&c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:x,...e.label!==void 0?{label:e.label}:{},...e.cron!==void 0?{cron:e.cron}:{}})},[c,d,e.id,e.enabled,e.retentionCount,e.label,e.cron]),b=q(x=>{c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:e.retentionCount,...e.label!==void 0?{label:e.label}:{},cron:x},{onSuccess:()=>{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(Nt,{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(jz,{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(Qz,{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(ot,{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(Pz,{destinationId:e.id,restoreSupported:e.restoreSupported,...s?{onOpenRestoreWizard:s}:{}})})}),p&&o(Vz,{destinationName:e.displayName,currentCron:e.cron??"",onSave:b,onClose:()=>h(!1),saving:c.isPending,saveError:c.error instanceof Error?c.error.message:null})]})}function jz({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(RT,{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 ",Hz(t)]})]})}function Hz(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 Vz({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(ze,{className:"h-4 w-4"})})]}),u("div",{className:"p-4",children:[o(Lz,{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 qz(){const{map:e}=Rc(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 Qz({at:e,sizeBytes:t}){const n=Gz(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 Gz(e){const[,t]=_(0);return Y(()=>{const n=setInterval(()=>t(r=>r+1),3e4);return()=>clearInterval(n)},[]),Kz(e)}function Kz(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 Wz=[["backup","list"]];function Yz({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}=Kc(),g=m??[],{data:b,isLoading:x}=Wc({destinationId:l??""},{enabled:!!l}),y=b??[];Y(()=>{if(l!==void 0)return;const z=g.filter(A=>A.restoreSupported);z.length===1&&c(z[0].id)},[l,g]);const{data:w}=ib({destinationId:l??"",backupId:d??""},{enabled:!!l&&!!d}),v=Q(()=>w?.locations??[],[w]);Y(()=>{v.length!==0&&h(z=>z.size===0?new Set(v):z)},[v]);const N=lb({onSuccess:()=>{s.invalidateQueries({queryKey:Wz}),r(),n()}}),k=z=>{h(A=>{const O=new Set(A);return O.has(z)?O.delete(z):O.add(z),O})},C=!!l&&!!d,E=p.size>0,P=C&&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:z=>z.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(ze,{className:"h-4 w-4"})})]}),a===1&&o(Zz,{destinations:g,destinationId:l,onPickDestination:z=>{c(z),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(Jz,{destinationName:g.find(z=>z.id===l)?.displayName??l??"",archive:y.find(z=>z.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(z=>z===3?2:1),className:"inline-flex items-center gap-1 rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:[o(Pd,{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&&!C||a===2&&!E,onClick:()=>i(z=>z===1?2:3),className:"inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:["Next",o(CT,{className:"h-3 w-3"})]}):u("button",{onClick:I,disabled:!P,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[N.isPending?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(yt,{className:"h-3.5 w-3.5"}),"Schedule Restore"]})]})]})]})})}function Zz({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:tF(r)})]},r))})]})]})}function Jz({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(ks,{term:"Destination",value:e}),o(ks,{term:"Archive",value:t?.label??t?.id??"—"}),t&&o(ks,{term:"Created",value:`${new Date(t.createdAt).toLocaleString()} · ${kt(t.sizeBytes)}`}),o(ks,{term:"Locations",value:n.length>0?n.join(", "):"— (full archive)"})]})]})}function ks({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 eF={db:"Database",addons:"Addon configs","addons-data":"Addon data",tls:"TLS certificates",cache:"Cache",data:"Top-level data"};function tF(e){return eF[e]??""}const nF=[["backup","list"]],rF=[["backup","listLocations"]];function oF(){const e=ke(),t=Je(),{data:n}=ab(),r=sb({onSuccess:()=>{e.invalidateQueries({queryKey:nF}),e.invalidateQueries({queryKey:[["backup","listDestinations"]]}),e.invalidateQueries({queryKey:[["backup","listArchives"]]})}}),s=Vg(),[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(Xe,{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(yt,{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(ot,{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(yt,{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(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(yt,{className:"h-3.5 w-3.5"}),"Restart Now"]})]})}),o(zz,{onCreateAt:x=>i(x),onOpenRestoreWizard:x=>c(x)}),a&&o(sF,{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:rF})}})},submitting:r.isPending}),(l||d)&&o(Yz,{...l?{initialDestinationId:l.destinationId,initialArchiveId:l.archiveId}:{},onClose:()=>{c(null),f(!1)},onScheduled:()=>h(!0)}),m&&o(cv,{initialType:"backups",onClose:()=>g(!1),onCreated:()=>{g(!1),e.invalidateQueries({queryKey:[["backup","listDestinations"]]})}})]})}function sF({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(ze,{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(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(n0,{className:"h-3.5 w-3.5"}),s?"Creating…":"Create"]})]})]})})}function aF(){return o("div",{className:"flex flex-col p-4",children:o(Bd,{tabs:[{id:"storage",label:"Storage",icon:Js,content:o(Ez,{})},{id:"backup",label:"Backup",icon:n0,content:o(oF,{})}]})})}function iF(){const{data:e,isLoading:t}=Tn(void 0,{staleTime:3e4}),n=(e??[]).find(s=>s.isHub&&s.isOnline),r=n?.addons.map(s=>s.id)??[];return o(Xe,{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(Gr,{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(Yt,{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 lF(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 cF({nodeId:e,addons:t,isHub:n}){const r=ke(),s=Je(),[a,i]=_(null),[l,c]=_(null),[d,f]=_(!1),[p,h]=_(null),[m,g]=_(0),b=ne(null),x=Aa(),y=ex(),w=sx({nodeId:e}),v=w.data??[],N=new Map(t.map(A=>[A.id,A.capabilities])),k=v.length>0?v.map(A=>({id:A.id,status:A.status,capabilities:N.get(A.id)??[],version:A.version,packageName:A.packageName})):t.map(A=>({id:A.id,status:A.status,capabilities:A.capabilities,version:void 0,packageName:void 0})),C=()=>{r.invalidateQueries({queryKey:[["nodes","topology"]]}),w.refetch()},E=async A=>{i(A);try{await x.mutateAsync({nodeId:e,addonId:A}),C()}catch(O){console.error("Failed to restart addon:",O)}finally{i(null)}},P=async A=>{if(await s({title:"Uninstall addon",message:`Remove "${A}" from ${e}? The addon directory will be deleted on disk.`,confirmLabel:"Uninstall",variant:"danger"})){c(A);try{await y.mutateAsync({nodeId:e,addonId:A}),C()}catch(R){console.error("Failed to uninstall addon:",R)}finally{c(null)}}},z=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 A=>{const O=A.target.files?.[0];if(O){A.target.value="",h(null),f(!0),g(0);try{const R=localStorage.getItem("camstack_admin_token");await lF({file:O,nodeId:e,token:R,onProgress:g}),C()}catch(R){h(R instanceof Error?R.message:String(R))}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(Se,{className:"h-3 w-3 animate-spin"}):o(Ha,{className:"h-3 w-3"}),d?`Uploading… ${m}%`:"Upload addon (.tgz)"]}),d&&o("div",{className:"flex-1 h-1 rounded-full bg-muted overflow-hidden max-w-[140px]",children:o("div",{className:"h-full bg-primary transition-all",style:{width:`${m}%`}})}),p&&o("span",{className:"text-[10px] text-destructive",children:p})]});return k.length===0?u("div",{children:[z,o("div",{className:"py-4 text-xs text-muted-foreground text-center",children:w.isLoading?"Loading addons…":"No addons on this node"})]}):u("div",{children:[z,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:"Version"}),o("th",{className:"py-2 font-medium",children:"Capabilities"}),o("th",{className:"py-2 font-medium",children:"Status"}),o("th",{className:"py-2 font-medium w-16"})]})}),o("tbody",{children:k.map(A=>u("tr",{className:"border-t border-border/50",children:[u("td",{className:"py-2 font-medium",children:[o("div",{children:A.id}),A.packageName&&o("div",{className:"text-[9px] text-muted-foreground",children:A.packageName})]}),o("td",{className:"py-2 text-muted-foreground",children:A.version??"—"}),o("td",{className:"py-2",children:o("div",{className:"flex flex-wrap gap-1",children:A.capabilities.length>0?A.capabilities.map(O=>o("span",{className:"text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400",children:O},O)):o("span",{className:"text-muted-foreground",children:"—"})})}),o("td",{className:"py-2",children:o("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full ${A.status==="running"?"bg-success/10 text-success":A.status==="error"?"bg-destructive/10 text-destructive":"bg-muted text-muted-foreground"}`,children:A.status})}),o("td",{className:"py-2",children:u("div",{className:"flex items-center gap-1 justify-end",children:[o("button",{onClick:()=>E(A.id),disabled:a===A.id||l===A.id,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:`Restart ${A.id}`,children:o(yt,{className:`h-3 w-3 ${a===A.id?"animate-spin":""}`})}),o("button",{onClick:()=>P(A.id),disabled:a===A.id||l===A.id,className:"p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50",title:`Uninstall ${A.id}`,children:l===A.id?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ke,{className:"h-3 w-3"})})]})})]},A.id))})]})]})}function dF(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 uF({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 pF=["trace","debug","info","warn","error"];function fF({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=Aa(),b=tx(),x=ax(),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(C){console.error("Failed to set log level:",C)}};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(Nt,{className:"h-3 w-3 text-muted-foreground shrink-0"}):o(Et,{className:"h-3 w-3 text-muted-foreground shrink-0"}),m?o(un,{className:"h-3.5 w-3.5 text-primary shrink-0"}):o(za,{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(uF,{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:dF(e.uptimeSeconds)}),!m&&u("div",{className:"flex items-center gap-1",onClick:N=>N.stopPropagation(),children:[u(Qm,{children:[o(Gm,{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(Km,{align:"end",className:"min-w-[70px] py-0.5",children:pF.map(N=>o(Wm,{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(yt,{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(rt,{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(ja,{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(yt,{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(Xt,{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(fr,{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 hF({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(fF,{proc:a,nodeId:e,defaultExpanded:i===0,activePanel:n,onTogglePanel:s},a.name))})}function mF(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 gF(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function bF({nodeId:e}){const t=ke(),n=Je(),[r,s]=_("all"),a=zr("metrics.node-processes-snapshot",k=>k.nodeId===e),{data:i}=Zb({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"),C=new Map;for(const E of k)C.has(E.ppid)||C.set(E.ppid,[]),C.get(E.ppid).push(E);return[...C.entries()].filter(([,E])=>E.length>1).map(([E,P])=>({ppid:E,children:P})).sort((E,P)=>P.children.length-E.children.length)},[c]),p=Xb({onSettled:()=>{t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]})}}),h=Q(()=>{const k=new Map;for(const C of c)k.set(C.pid,C.classification);return k},[c]),m=async(k,C)=>{if(k.classification==="root"||k.classification==="system")return;const E=k.classification==="ghost"?"ghost":k.addonId??"process",P=C?"SIGKILL":"SIGTERM";await n({title:`Send ${P}?`,message:`Target pid ${k.pid} (${E}) on node ${e}.`,confirmLabel:`Send ${P}`,variant:"danger"})&&p.mutate({nodeId:e,pid:k.pid,force:C})},g=async(k,C)=>{try{await p.mutateAsync({nodeId:e,pid:k,force:C})}catch{}},b=async k=>{const C=h.get(k.ppid);if(C==="root"||C==="system"){await n({title:"Cannot kill protected ancestor",message:C==="root"?`pid ${k.ppid} is the current node supervisor. Restart the node via the cluster page instead.`:`pid ${k.ppid} is a system ancestor (concurrently / vite / npm wrapper). Killing it would tear down the dev tree.`,confirmLabel:"OK",cancelLabel:"Close",variant:"warning"});return}await n({title:`Kill ghost parent + ${k.children.length} child(ren)?`,message:`SIGKILL parent pid ${k.ppid} and SIGTERM ${k.children.length} ghost child(ren) on node ${e}.`,confirmLabel:"Kill all",variant:"danger"})&&(await Promise.all([g(k.ppid,!0),...k.children.map(P=>g(P.pid,!1))]),t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]}))},x=async()=>{const k=c.filter(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(ht,{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(hs,{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(ut,{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(hs,{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(hs,{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:gF(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:mF(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(Ke,{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(hs,{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 xF({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(Gr,{nodeId:e,addonIds:t,level:"global"})})}function yF({nodeId:e,addons:t}){const n=ke(),{data:r,isLoading:s}=xx({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=yx({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 vF(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 wF(e){const[t,n]=_(!1),[r,s]=_(e.name),a=ke(),i=rx({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(ze,{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:vF(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 NF({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(ft,{className:"h-3 w-3"})," ",e.cpuPercent,"%"]}),u("span",{className:"flex items-center gap-1",children:[o(Td,{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(wF,{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(cF,{nodeId:e.id,addons:e.addons,isHub:e.isHub}),t==="forks"&&o(hF,{nodeId:e.id,processes:r}),t==="processes"&&o(bF,{nodeId:e.id}),t==="settings"&&o(xF,{nodeId:e.id,addonIds:s}),t==="capabilities"&&o(yF,{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 kF({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(NF,{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 SF={value:()=>{}};function Wa(){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 Fs(n)}function Fs(e){this._=e}function CF(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}})}Fs.prototype=Wa.prototype={constructor:Fs,on:function(e,t){var n=this._,r=CF(e+"",n),s,a=-1,i=r.length;if(arguments.length<2){for(;++a<i;)if((s=(e=r[a]).type)&&(s=MF(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]=pf(n[s],e.name,t);else if(t==null)for(s in n)n[s]=pf(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 Fs(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 MF(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function pf(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=SF,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Kl="http://www.w3.org/1999/xhtml";const ff={svg:"http://www.w3.org/2000/svg",xhtml:Kl,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ya(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),ff.hasOwnProperty(t)?{space:ff[t],local:e}:e}function EF(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Kl&&t.documentElement.namespaceURI===Kl?t.createElement(e):t.createElementNS(n,e)}}function IF(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function uv(e){var t=Ya(e);return(t.local?IF:EF)(t)}function AF(){}function Fd(e){return e==null?AF:function(){return this.querySelector(e)}}function PF(e){typeof e!="function"&&(e=Fd(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 mt(r,this._parents)}function _F(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function $F(){return[]}function pv(e){return e==null?$F:function(){return this.querySelectorAll(e)}}function DF(e){return function(){return _F(e.apply(this,arguments))}}function LF(e){typeof e=="function"?e=DF(e):e=pv(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 mt(r,s)}function fv(e){return function(){return this.matches(e)}}function hv(e){return function(t){return t.matches(e)}}var TF=Array.prototype.find;function RF(e){return function(){return TF.call(this.children,e)}}function OF(){return this.firstElementChild}function BF(e){return this.select(e==null?OF:RF(typeof e=="function"?e:hv(e)))}var zF=Array.prototype.filter;function FF(){return Array.from(this.children)}function jF(e){return function(){return zF.call(this.children,e)}}function HF(e){return this.selectAll(e==null?FF:jF(typeof e=="function"?e:hv(e)))}function VF(e){typeof e!="function"&&(e=fv(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 mt(r,this._parents)}function mv(e){return new Array(e.length)}function qF(){return new mt(this._enter||this._groups.map(mv),this._parents)}function aa(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}aa.prototype={constructor:aa,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 UF(e){return function(){return e}}function QF(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 aa(e,a[i]);for(;i<c;++i)(l=t[i])&&(s[i]=l)}function GF(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 aa(e,a[l]);for(l=0;l<f;++l)(c=t[l])&&d.get(h[l])===c&&(s[l]=c)}function KF(e){return e.__data__}function WF(e,t){if(!arguments.length)return Array.from(this,KF);var n=t?GF:QF,r=this._parents,s=this._groups;typeof e!="function"&&(e=UF(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=YF(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 mt(i,r),i._enter=l,i._exit=c,i}function YF(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ZF(){return new mt(this._exit||this._groups.map(mv),this._parents)}function XF(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 JF(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 mt(l,this._parents)}function ej(){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 tj(e){e||(e=nj);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 mt(s,this._parents).order()}function nj(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function rj(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function oj(){return Array.from(this)}function sj(){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 aj(){let e=0;for(const t of this)++e;return e}function ij(){return!this.node()}function lj(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 cj(e){return function(){this.removeAttribute(e)}}function dj(e){return function(){this.removeAttributeNS(e.space,e.local)}}function uj(e,t){return function(){this.setAttribute(e,t)}}function pj(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function fj(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function hj(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 mj(e,t){var n=Ya(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?dj:cj:typeof t=="function"?n.local?hj:fj:n.local?pj:uj)(n,t))}function gv(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function gj(e){return function(){this.style.removeProperty(e)}}function bj(e,t,n){return function(){this.style.setProperty(e,t,n)}}function xj(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function yj(e,t,n){return arguments.length>1?this.each((t==null?gj:typeof t=="function"?xj:bj)(e,t,n??"")):Pr(this.node(),e)}function Pr(e,t){return e.style.getPropertyValue(t)||gv(e).getComputedStyle(e,null).getPropertyValue(t)}function vj(e){return function(){delete this[e]}}function wj(e,t){return function(){this[e]=t}}function Nj(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function kj(e,t){return arguments.length>1?this.each((t==null?vj:typeof t=="function"?Nj:wj)(e,t)):this.node()[e]}function bv(e){return e.trim().split(/^|\s+/)}function jd(e){return e.classList||new xv(e)}function xv(e){this._node=e,this._names=bv(e.getAttribute("class")||"")}xv.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function yv(e,t){for(var n=jd(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function vv(e,t){for(var n=jd(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function Sj(e){return function(){yv(this,e)}}function Cj(e){return function(){vv(this,e)}}function Mj(e,t){return function(){(t.apply(this,arguments)?yv:vv)(this,e)}}function Ej(e,t){var n=bv(e+"");if(arguments.length<2){for(var r=jd(this.node()),s=-1,a=n.length;++s<a;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?Mj:t?Sj:Cj)(n,t))}function Ij(){this.textContent=""}function Aj(e){return function(){this.textContent=e}}function Pj(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function _j(e){return arguments.length?this.each(e==null?Ij:(typeof e=="function"?Pj:Aj)(e)):this.node().textContent}function $j(){this.innerHTML=""}function Dj(e){return function(){this.innerHTML=e}}function Lj(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Tj(e){return arguments.length?this.each(e==null?$j:(typeof e=="function"?Lj:Dj)(e)):this.node().innerHTML}function Rj(){this.nextSibling&&this.parentNode.appendChild(this)}function Oj(){return this.each(Rj)}function Bj(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function zj(){return this.each(Bj)}function Fj(e){var t=typeof e=="function"?e:uv(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function jj(){return null}function Hj(e,t){var n=typeof e=="function"?e:uv(e),r=t==null?jj:typeof t=="function"?t:Fd(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Vj(){var e=this.parentNode;e&&e.removeChild(this)}function qj(){return this.each(Vj)}function Uj(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Qj(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Gj(e){return this.select(e?Qj:Uj)}function Kj(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Wj(e){return function(t){e.call(this,t,this.__data__)}}function Yj(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 Zj(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 Xj(e,t,n){return function(){var r=this.__on,s,a=Wj(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 Jj(e,t,n){var r=Yj(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?Xj:Zj,s=0;s<a;++s)this.each(l(r[s],t,n));return this}function wv(e,t,n){var r=gv(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 eH(e,t){return function(){return wv(this,e,t)}}function tH(e,t){return function(){return wv(this,e,t.apply(this,arguments))}}function nH(e,t){return this.each((typeof t=="function"?tH:eH)(e,t))}function*rH(){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 Nv=[null];function mt(e,t){this._groups=e,this._parents=t}function Zo(){return new mt([[document.documentElement]],Nv)}function oH(){return this}mt.prototype=Zo.prototype={constructor:mt,select:PF,selectAll:LF,selectChild:BF,selectChildren:HF,filter:VF,data:WF,enter:qF,exit:ZF,join:XF,merge:JF,selection:oH,order:ej,sort:tj,call:rj,nodes:oj,node:sj,size:aj,empty:ij,each:lj,attr:mj,style:yj,property:kj,classed:Ej,text:_j,html:Tj,raise:Oj,lower:zj,append:Fj,insert:Hj,remove:qj,clone:Gj,datum:Kj,on:Jj,dispatch:nH,[Symbol.iterator]:rH};function ct(e){return typeof e=="string"?new mt([[document.querySelector(e)]],[document.documentElement]):new mt([[e]],Nv)}function sH(e){let t;for(;t=e.sourceEvent;)e=t;return e}function _t(e,t){if(e=sH(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 aH={passive:!1},Eo={capture:!0,passive:!1};function Xi(e){e.stopImmediatePropagation()}function Sr(e){e.preventDefault(),e.stopImmediatePropagation()}function kv(e){var t=e.document.documentElement,n=ct(e).on("dragstart.drag",Sr,Eo);"onselectstart"in t?n.on("selectstart.drag",Sr,Eo):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Sv(e,t){var n=e.document.documentElement,r=ct(e).on("dragstart.drag",null);t&&(r.on("click.drag",Sr,Eo),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 Ss=e=>()=>e;function Wl(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}})}Wl.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function iH(e){return!e.ctrlKey&&!e.button}function lH(){return this.parentNode}function cH(e,t){return t??{x:e.x,y:e.y}}function dH(){return navigator.maxTouchPoints||"ontouchstart"in this}function Cv(){var e=iH,t=lH,n=cH,r=dH,s={},a=Wa("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,aH).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 C=v(this,t.call(this,N,k),N,k,"mouse");C&&(ct(N.view).on("mousemove.drag",g,Eo).on("mouseup.drag",b,Eo),kv(N.view),Xi(N),d=!1,l=N.clientX,c=N.clientY,C("start",N))}}function g(N){if(Sr(N),!d){var k=N.clientX-l,C=N.clientY-c;d=k*k+C*C>p}s.mouse("drag",N)}function b(N){ct(N.view).on("mousemove.drag mouseup.drag",null),Sv(N.view,d),Sr(N),s.mouse("end",N)}function x(N,k){if(e.call(this,N,k)){var C=N.changedTouches,E=t.call(this,N,k),P=C.length,I,z;for(I=0;I<P;++I)(z=v(this,E,N,k,C[I].identifier,C[I]))&&(Xi(N),z("start",N,C[I]))}}function y(N){var k=N.changedTouches,C=k.length,E,P;for(E=0;E<C;++E)(P=s[k[E].identifier])&&(Sr(N),P("drag",N,k[E]))}function w(N){var k=N.changedTouches,C=k.length,E,P;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),E=0;E<C;++E)(P=s[k[E].identifier])&&(Xi(N),P("end",N,k[E]))}function v(N,k,C,E,P,I){var z=a.copy(),A=_t(I||C,k),O,R,M;if((M=n.call(N,new Wl("beforestart",{sourceEvent:C,target:h,identifier:P,active:i,x:A[0],y:A[1],dx:0,dy:0,dispatch:z}),E))!=null)return O=M.x-A[0]||0,R=M.y-A[1]||0,function D(L,T,B){var F=A,j;switch(L){case"start":s[P]=D,j=i++;break;case"end":delete s[P],--i;case"drag":A=_t(B||T,k),j=i;break}z.call(L,N,new Wl(L,{sourceEvent:T,subject:M,target:h,identifier:P,active:j,x:A[0]+O,y:A[1]+R,dx:A[0]-F[0],dy:A[1]-F[1],dispatch:z}),E)}}return h.filter=function(N){return arguments.length?(e=typeof N=="function"?N:Ss(!!N),h):e},h.container=function(N){return arguments.length?(t=typeof N=="function"?N:Ss(N),h):t},h.subject=function(N){return arguments.length?(n=typeof N=="function"?N:Ss(N),h):n},h.touchable=function(N){return arguments.length?(r=typeof N=="function"?N:Ss(!!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 Hd(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Mv(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Xo(){}var Io=.7,ia=1/Io,Cr="\\s*([+-]?\\d+)\\s*",Ao="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",uH=/^#([0-9a-f]{3,8})$/,pH=new RegExp(`^rgb\\(${Cr},${Cr},${Cr}\\)$`),fH=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),hH=new RegExp(`^rgba\\(${Cr},${Cr},${Cr},${Ao}\\)$`),mH=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${Ao}\\)$`),gH=new RegExp(`^hsl\\(${Ao},${Gt},${Gt}\\)$`),bH=new RegExp(`^hsla\\(${Ao},${Gt},${Gt},${Ao}\\)$`),hf={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};Hd(Xo,nr,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:mf,formatHex:mf,formatHex8:xH,formatHsl:yH,formatRgb:gf,toString:gf});function mf(){return this.rgb().formatHex()}function xH(){return this.rgb().formatHex8()}function yH(){return Ev(this).formatHsl()}function gf(){return this.rgb().formatRgb()}function nr(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=uH.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?bf(t):n===3?new nt(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Cs(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Cs(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=pH.exec(e))?new nt(t[1],t[2],t[3],1):(t=fH.exec(e))?new nt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=hH.exec(e))?Cs(t[1],t[2],t[3],t[4]):(t=mH.exec(e))?Cs(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=gH.exec(e))?vf(t[1],t[2]/100,t[3]/100,1):(t=bH.exec(e))?vf(t[1],t[2]/100,t[3]/100,t[4]):hf.hasOwnProperty(e)?bf(hf[e]):e==="transparent"?new nt(NaN,NaN,NaN,0):null}function bf(e){return new nt(e>>16&255,e>>8&255,e&255,1)}function Cs(e,t,n,r){return r<=0&&(e=t=n=NaN),new nt(e,t,n,r)}function vH(e){return e instanceof Xo||(e=nr(e)),e?(e=e.rgb(),new nt(e.r,e.g,e.b,e.opacity)):new nt}function Yl(e,t,n,r){return arguments.length===1?vH(e):new nt(e,t,n,r??1)}function nt(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Hd(nt,Yl,Mv(Xo,{brighter(e){return e=e==null?ia:Math.pow(ia,e),new nt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Io:Math.pow(Io,e),new nt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new nt(Gn(this.r),Gn(this.g),Gn(this.b),la(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:xf,formatHex:xf,formatHex8:wH,formatRgb:yf,toString:yf}));function xf(){return`#${Vn(this.r)}${Vn(this.g)}${Vn(this.b)}`}function wH(){return`#${Vn(this.r)}${Vn(this.g)}${Vn(this.b)}${Vn((isNaN(this.opacity)?1:this.opacity)*255)}`}function yf(){const e=la(this.opacity);return`${e===1?"rgb(":"rgba("}${Gn(this.r)}, ${Gn(this.g)}, ${Gn(this.b)}${e===1?")":`, ${e})`}`}function la(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Gn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Vn(e){return e=Gn(e),(e<16?"0":"")+e.toString(16)}function vf(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new $t(e,t,n,r)}function Ev(e){if(e instanceof $t)return new $t(e.h,e.s,e.l,e.opacity);if(e instanceof Xo||(e=nr(e)),!e)return new $t;if(e instanceof $t)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 $t(i,l,c,e.opacity)}function NH(e,t,n,r){return arguments.length===1?Ev(e):new $t(e,t,n,r??1)}function $t(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Hd($t,NH,Mv(Xo,{brighter(e){return e=e==null?ia:Math.pow(ia,e),new $t(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Io:Math.pow(Io,e),new $t(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 nt(Ji(e>=240?e-240:e+120,s,r),Ji(e,s,r),Ji(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new $t(wf(this.h),Ms(this.s),Ms(this.l),la(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=la(this.opacity);return`${e===1?"hsl(":"hsla("}${wf(this.h)}, ${Ms(this.s)*100}%, ${Ms(this.l)*100}%${e===1?")":`, ${e})`}`}}));function wf(e){return e=(e||0)%360,e<0?e+360:e}function Ms(e){return Math.max(0,Math.min(1,e||0))}function Ji(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 Vd=e=>()=>e;function kH(e,t){return function(n){return e+n*t}}function SH(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 CH(e){return(e=+e)==1?Iv:function(t,n){return n-t?SH(t,n,e):Vd(isNaN(t)?n:t)}}function Iv(e,t){var n=t-e;return n?kH(e,n):Vd(isNaN(e)?t:e)}const ca=(function e(t){var n=CH(t);function r(s,a){var i=n((s=Yl(s)).r,(a=Yl(a)).r),l=n(s.g,a.g),c=n(s.b,a.b),d=Iv(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 MH(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 EH(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function IH(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]=go(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 AH(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Vt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function PH(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]=go(e[s],t[s]):r[s]=t[s];return function(a){for(s in n)r[s]=n[s](a);return r}}var Zl=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,el=new RegExp(Zl.source,"g");function _H(e){return function(){return e}}function $H(e){return function(t){return e(t)+""}}function Av(e,t){var n=Zl.lastIndex=el.lastIndex=0,r,s,a,i=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Zl.exec(e))&&(s=el.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:Vt(r,s)})),n=el.lastIndex;return n<t.length&&(a=t.slice(n),l[i]?l[i]+=a:l[++i]=a),l.length<2?c[0]?$H(c[0].x):_H(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 go(e,t){var n=typeof t,r;return t==null||n==="boolean"?Vd(t):(n==="number"?Vt:n==="string"?(r=nr(t))?(t=r,ca):Av:t instanceof nr?ca:t instanceof Date?AH:EH(t)?MH:Array.isArray(t)?IH:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?PH:Vt)(e,t)}var Nf=180/Math.PI,Xl={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Pv(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)*Nf,skewX:Math.atan(c)*Nf,scaleX:i,scaleY:l}}var Es;function DH(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Xl:Pv(t.a,t.b,t.c,t.d,t.e,t.f)}function LH(e){return e==null||(Es||(Es=document.createElementNS("http://www.w3.org/2000/svg","g")),Es.setAttribute("transform",e),!(e=Es.transform.baseVal.consolidate()))?Xl:(e=e.matrix,Pv(e.a,e.b,e.c,e.d,e.e,e.f))}function _v(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:Vt(d,p)},{i:b-2,x:Vt(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:Vt(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:Vt(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:Vt(d,p)},{i:b-2,x:Vt(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 TH=_v(DH,"px, ","px)","deg)"),RH=_v(LH,", ",")",")"),OH=1e-12;function kf(e){return((e=Math.exp(e))+1/e)/2}function BH(e){return((e=Math.exp(e))-1/e)/2}function zH(e){return((e=Math.exp(2*e))-1)/(e+1)}const js=(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<OH)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),C=Math.log(Math.sqrt(N*N+1)-N);y=(C-k)/t,x=function(E){var P=E*y,I=kf(k),z=d/(n*w)*(I*zH(t*P+k)-BH(k));return[l+z*m,c+z*g,d*I/kf(t*P+k)]}}return x.duration=y*1e3*t/Math.SQRT2,x}return s.rho=function(a){var i=Math.max(.001,+a),l=i*i,c=l*l;return e(i,l,c)},s})(Math.SQRT2,2,4);var _r=0,so=0,to=0,$v=1e3,da,ao,ua=0,rr=0,Za=0,Po=typeof performance=="object"&&performance.now?performance:Date,Dv=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function qd(){return rr||(Dv(FH),rr=Po.now()+Za)}function FH(){rr=0}function pa(){this._call=this._time=this._next=null}pa.prototype=Lv.prototype={constructor:pa,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?qd():+n)+(t==null?0:+t),!this._next&&ao!==this&&(ao?ao._next=this:da=this,ao=this),this._call=e,this._time=n,Jl()},stop:function(){this._call&&(this._call=null,this._time=1/0,Jl())}};function Lv(e,t,n){var r=new pa;return r.restart(e,t,n),r}function jH(){qd(),++_r;for(var e=da,t;e;)(t=rr-e._time)>=0&&e._call.call(void 0,t),e=e._next;--_r}function Sf(){rr=(ua=Po.now())+Za,_r=so=0;try{jH()}finally{_r=0,VH(),rr=0}}function HH(){var e=Po.now(),t=e-ua;t>$v&&(Za-=t,ua=e)}function VH(){for(var e,t=da,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:da=n);ao=e,Jl(r)}function Jl(e){if(!_r){so&&(so=clearTimeout(so));var t=e-rr;t>24?(e<1/0&&(so=setTimeout(Sf,e-Po.now()-Za)),to&&(to=clearInterval(to))):(to||(ua=Po.now(),to=setInterval(HH,$v)),_r=1,Dv(Sf))}}function Cf(e,t,n){var r=new pa;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var qH=Wa("start","end","cancel","interrupt"),UH=[],Tv=0,Mf=1,ec=2,Hs=3,Ef=4,tc=5,Vs=6;function Xa(e,t,n,r,s,a){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;QH(e,n,{name:t,index:r,group:s,on:qH,tween:UH,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:Tv})}function Ud(e,t){var n=Ft(e,t);if(n.state>Tv)throw new Error("too late; already scheduled");return n}function en(e,t){var n=Ft(e,t);if(n.state>Hs)throw new Error("too late; already running");return n}function Ft(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function QH(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=Lv(a,0,n.time);function a(d){n.state=Mf,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!==Mf)return c();for(f in r)if(m=r[f],m.name===n.name){if(m.state===Hs)return Cf(i);m.state===Ef?(m.state=Vs,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[f]):+f<t&&(m.state=Vs,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[f])}if(Cf(function(){n.state===Hs&&(n.state=Ef,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=ec,n.on.call("start",e,e.__data__,n.index,n.group),n.state===ec){for(n.state=Hs,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=tc,1),p=-1,h=s.length;++p<h;)s[p].call(e,f);n.state===tc&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Vs,n.timer.stop(),delete r[t];for(var d in r)return;delete e.__transition}}function qs(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>ec&&r.state<tc,r.state=Vs,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}a&&delete e.__transition}}function GH(e){return this.each(function(){qs(this,e)})}function KH(e,t){var n,r;return function(){var s=en(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 WH(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var a=en(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 YH(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Ft(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?KH:WH)(n,e,t))}function Qd(e,t,n){var r=e._id;return e.each(function(){var s=en(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Ft(s,r).value[t]}}function Rv(e,t){var n;return(typeof t=="number"?Vt:t instanceof nr?ca:(n=nr(t))?(t=n,ca):Av)(e,t)}function ZH(e){return function(){this.removeAttribute(e)}}function XH(e){return function(){this.removeAttributeNS(e.space,e.local)}}function JH(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 eV(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 tV(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 nV(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 rV(e,t){var n=Ya(e),r=n==="transform"?RH:Rv;return this.attrTween(e,typeof t=="function"?(n.local?nV:tV)(n,r,Qd(this,"attr."+e,t)):t==null?(n.local?XH:ZH)(n):(n.local?eV:JH)(n,r,t))}function oV(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function sV(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function aV(e,t){var n,r;function s(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&sV(e,a)),n}return s._value=t,s}function iV(e,t){var n,r;function s(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&oV(e,a)),n}return s._value=t,s}function lV(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=Ya(e);return this.tween(n,(r.local?aV:iV)(r,t))}function cV(e,t){return function(){Ud(this,e).delay=+t.apply(this,arguments)}}function dV(e,t){return t=+t,function(){Ud(this,e).delay=t}}function uV(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?cV:dV)(t,e)):Ft(this.node(),t).delay}function pV(e,t){return function(){en(this,e).duration=+t.apply(this,arguments)}}function fV(e,t){return t=+t,function(){en(this,e).duration=t}}function hV(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?pV:fV)(t,e)):Ft(this.node(),t).duration}function mV(e,t){if(typeof t!="function")throw new Error;return function(){en(this,e).ease=t}}function gV(e){var t=this._id;return arguments.length?this.each(mV(t,e)):Ft(this.node(),t).ease}function bV(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;en(this,e).ease=n}}function xV(e){if(typeof e!="function")throw new Error;return this.each(bV(this._id,e))}function yV(e){typeof e!="function"&&(e=fv(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 hn(r,this._parents,this._name,this._id)}function vV(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 hn(i,this._parents,this._name,this._id)}function wV(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 NV(e,t,n){var r,s,a=wV(t)?Ud:en;return function(){var i=a(this,e),l=i.on;l!==r&&(s=(r=l).copy()).on(t,n),i.on=s}}function kV(e,t){var n=this._id;return arguments.length<2?Ft(this.node(),n).on.on(e):this.each(NV(n,e,t))}function SV(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function CV(){return this.on("end.remove",SV(this._id))}function MV(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Fd(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,Xa(d[h],t,n,h,d,Ft(f,n)));return new hn(a,this._parents,t,n)}function EV(e){var t=this._name,n=this._id;typeof e!="function"&&(e=pv(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=Ft(f,n),b=0,x=h.length;b<x;++b)(m=h[b])&&Xa(m,t,n,b,h,g);a.push(h),i.push(f)}return new hn(a,i,t,n)}var IV=Zo.prototype.constructor;function AV(){return new IV(this._groups,this._parents)}function PV(e,t){var n,r,s;return function(){var a=Pr(this,e),i=(this.style.removeProperty(e),Pr(this,e));return a===i?null:a===n&&i===r?s:s=t(n=a,r=i)}}function Ov(e){return function(){this.style.removeProperty(e)}}function _V(e,t,n){var r,s=n+"",a;return function(){var i=Pr(this,e);return i===s?null:i===r?a:a=t(r=i,n)}}function $V(e,t,n){var r,s,a;return function(){var i=Pr(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),Pr(this,e))),i===c?null:i===r&&c===s?a:(s=c,a=t(r=i,l))}}function DV(e,t){var n,r,s,a="style."+t,i="end."+a,l;return function(){var c=en(this,e),d=c.on,f=c.value[a]==null?l||(l=Ov(t)):void 0;(d!==n||s!==f)&&(r=(n=d).copy()).on(i,s=f),c.on=r}}function LV(e,t,n){var r=(e+="")=="transform"?TH:Rv;return t==null?this.styleTween(e,PV(e,r)).on("end.style."+e,Ov(e)):typeof t=="function"?this.styleTween(e,$V(e,r,Qd(this,"style."+e,t))).each(DV(this._id,e)):this.styleTween(e,_V(e,r,t),n).on("end.style."+e,null)}function TV(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function RV(e,t,n){var r,s;function a(){var i=t.apply(this,arguments);return i!==s&&(r=(s=i)&&TV(e,i,n)),r}return a._value=t,a}function OV(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,RV(e,t,n??""))}function BV(e){return function(){this.textContent=e}}function zV(e){return function(){var t=e(this);this.textContent=t??""}}function FV(e){return this.tween("text",typeof e=="function"?zV(Qd(this,"text",e)):BV(e==null?"":e+""))}function jV(e){return function(t){this.textContent=e.call(this,t)}}function HV(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&jV(s)),t}return r._value=e,r}function VV(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,HV(e))}function qV(){for(var e=this._name,t=this._id,n=Bv(),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=Ft(c,t);Xa(c,e,n,d,i,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new hn(r,this._parents,e,n)}function UV(){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=en(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 QV=0;function hn(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Bv(){return++QV}var rn=Zo.prototype;hn.prototype={constructor:hn,select:MV,selectAll:EV,selectChild:rn.selectChild,selectChildren:rn.selectChildren,filter:yV,merge:vV,selection:AV,transition:qV,call:rn.call,nodes:rn.nodes,node:rn.node,size:rn.size,empty:rn.empty,each:rn.each,on:kV,attr:rV,attrTween:lV,style:LV,styleTween:OV,text:FV,textTween:VV,remove:CV,tween:YH,delay:uV,duration:hV,ease:gV,easeVarying:xV,end:UV,[Symbol.iterator]:rn[Symbol.iterator]};function GV(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var KV={time:null,delay:0,duration:250,ease:GV};function WV(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 YV(e){var t,n;e instanceof hn?(t=e._id,e=e._name):(t=Bv(),(n=KV).time=qd(),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])&&Xa(c,e,t,d,i,n||WV(c,t));return new hn(r,this._parents,e,t)}Zo.prototype.interrupt=GH;Zo.prototype.transition=YV;const Is=e=>()=>e;function ZV(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 an(e,t,n){this.k=e,this.x=t,this.y=n}an.prototype={constructor:an,scale:function(e){return e===1?this:new an(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new an(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 Ja=new an(1,0,0);zv.prototype=an.prototype;function zv(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ja;return e.__zoom}function tl(e){e.stopImmediatePropagation()}function no(e){e.preventDefault(),e.stopImmediatePropagation()}function XV(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function JV(){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 If(){return this.__zoom||Ja}function eq(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function tq(){return navigator.maxTouchPoints||"ontouchstart"in this}function nq(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 Fv(){var e=XV,t=JV,n=nq,r=eq,s=tq,a=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,c=js,d=Wa("start","zoom","end"),f,p,h,m=500,g=150,b=0,x=10;function y(M){M.property("__zoom",If).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",z).filter(s).on("touchstart.zoom",A).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",R).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(M,D,L,T){var B=M.selection?M.selection():M;B.property("__zoom",If),M!==B?k(M,D,L,T):B.interrupt().each(function(){C(this,arguments).event(T).start().zoom(null,typeof D=="function"?D.apply(this,arguments):D).end()})},y.scaleBy=function(M,D,L,T){y.scaleTo(M,function(){var B=this.__zoom.k,F=typeof D=="function"?D.apply(this,arguments):D;return B*F},L,T)},y.scaleTo=function(M,D,L,T){y.transform(M,function(){var B=t.apply(this,arguments),F=this.__zoom,j=L==null?N(B):typeof L=="function"?L.apply(this,arguments):L,H=F.invert(j),$=typeof D=="function"?D.apply(this,arguments):D;return n(v(w(F,$),j,H),B,i)},L,T)},y.translateBy=function(M,D,L,T){y.transform(M,function(){return n(this.__zoom.translate(typeof D=="function"?D.apply(this,arguments):D,typeof L=="function"?L.apply(this,arguments):L),t.apply(this,arguments),i)},null,T)},y.translateTo=function(M,D,L,T,B){y.transform(M,function(){var F=t.apply(this,arguments),j=this.__zoom,H=T==null?N(F):typeof T=="function"?T.apply(this,arguments):T;return n(Ja.translate(H[0],H[1]).scale(j.k).translate(typeof D=="function"?-D.apply(this,arguments):-D,typeof L=="function"?-L.apply(this,arguments):-L),F,i)},T,B)};function w(M,D){return D=Math.max(a[0],Math.min(a[1],D)),D===M.k?M:new an(D,M.x,M.y)}function v(M,D,L){var T=D[0]-L[0]*M.k,B=D[1]-L[1]*M.k;return T===M.x&&B===M.y?M:new an(M.k,T,B)}function N(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function k(M,D,L,T){M.on("start.zoom",function(){C(this,arguments).event(T).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(T).end()}).tween("zoom",function(){var B=this,F=arguments,j=C(B,F).event(T),H=t.apply(B,F),$=L==null?N(H):typeof L=="function"?L.apply(B,F):L,V=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),G=B.__zoom,Z=typeof D=="function"?D.apply(B,F):D,oe=c(G.invert($).concat(V/G.k),Z.invert($).concat(V/Z.k));return function(te){if(te===1)te=Z;else{var X=oe(te),re=V/X[2];te=new an(re,$[0]-X[0]*re,$[1]-X[1]*re)}j.zoom(null,te)}})}function C(M,D,L){return!L&&M.__zooming||new E(M,D)}function E(M,D){this.that=M,this.args=D,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,D),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,D){return this.mouse&&M!=="mouse"&&(this.mouse[1]=D.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=D.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=D.invert(this.touch1[0])),this.that.__zoom=D,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var D=ct(this.that).datum();d.call(M,this.that,new ZV(M,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:d}),D)}};function P(M,...D){if(!e.apply(this,arguments))return;var L=C(this,D).event(M),T=this.__zoom,B=Math.max(a[0],Math.min(a[1],T.k*Math.pow(2,r.apply(this,arguments)))),F=_t(M);if(L.wheel)(L.mouse[0][0]!==F[0]||L.mouse[0][1]!==F[1])&&(L.mouse[1]=T.invert(L.mouse[0]=F)),clearTimeout(L.wheel);else{if(T.k===B)return;L.mouse=[F,T.invert(F)],qs(this),L.start()}no(M),L.wheel=setTimeout(j,g),L.zoom("mouse",n(v(w(T,B),L.mouse[0],L.mouse[1]),L.extent,i));function j(){L.wheel=null,L.end()}}function I(M,...D){if(h||!e.apply(this,arguments))return;var L=M.currentTarget,T=C(this,D,!0).event(M),B=ct(M.view).on("mousemove.zoom",$,!0).on("mouseup.zoom",V,!0),F=_t(M,L),j=M.clientX,H=M.clientY;kv(M.view),tl(M),T.mouse=[F,this.__zoom.invert(F)],qs(this),T.start();function $(G){if(no(G),!T.moved){var Z=G.clientX-j,oe=G.clientY-H;T.moved=Z*Z+oe*oe>b}T.event(G).zoom("mouse",n(v(T.that.__zoom,T.mouse[0]=_t(G,L),T.mouse[1]),T.extent,i))}function V(G){B.on("mousemove.zoom mouseup.zoom",null),Sv(G.view,T.moved),no(G),T.event(G).end()}}function z(M,...D){if(e.apply(this,arguments)){var L=this.__zoom,T=_t(M.changedTouches?M.changedTouches[0]:M,this),B=L.invert(T),F=L.k*(M.shiftKey?.5:2),j=n(v(w(L,F),T,B),t.apply(this,D),i);no(M),l>0?ct(this).transition().duration(l).call(k,j,T,M):ct(this).call(y.transform,j,T,M)}}function A(M,...D){if(e.apply(this,arguments)){var L=M.touches,T=L.length,B=C(this,D,M.changedTouches.length===T).event(M),F,j,H,$;for(tl(M),j=0;j<T;++j)H=L[j],$=_t(H,this),$=[$,this.__zoom.invert($),H.identifier],B.touch0?!B.touch1&&B.touch0[2]!==$[2]&&(B.touch1=$,B.taps=0):(B.touch0=$,F=!0,B.taps=1+!!f);f&&(f=clearTimeout(f)),F&&(B.taps<2&&(p=$[0],f=setTimeout(function(){f=null},m)),qs(this),B.start())}}function O(M,...D){if(this.__zooming){var L=C(this,D).event(M),T=M.changedTouches,B=T.length,F,j,H,$;for(no(M),F=0;F<B;++F)j=T[F],H=_t(j,this),L.touch0&&L.touch0[2]===j.identifier?L.touch0[0]=H:L.touch1&&L.touch1[2]===j.identifier&&(L.touch1[0]=H);if(j=L.that.__zoom,L.touch1){var V=L.touch0[0],G=L.touch0[1],Z=L.touch1[0],oe=L.touch1[1],te=(te=Z[0]-V[0])*te+(te=Z[1]-V[1])*te,X=(X=oe[0]-G[0])*X+(X=oe[1]-G[1])*X;j=w(j,Math.sqrt(te/X)),H=[(V[0]+Z[0])/2,(V[1]+Z[1])/2],$=[(G[0]+oe[0])/2,(G[1]+oe[1])/2]}else if(L.touch0)H=L.touch0[0],$=L.touch0[1];else return;L.zoom("touch",n(v(j,H,$),L.extent,i))}}function R(M,...D){if(this.__zooming){var L=C(this,D).event(M),T=M.changedTouches,B=T.length,F,j;for(tl(M),h&&clearTimeout(h),h=setTimeout(function(){h=null},m),F=0;F<B;++F)j=T[F],L.touch0&&L.touch0[2]===j.identifier?delete L.touch0:L.touch1&&L.touch1[2]===j.identifier&&delete L.touch1;if(L.touch1&&!L.touch0&&(L.touch0=L.touch1,delete L.touch1),L.touch0)L.touch0[1]=this.__zoom.invert(L.touch0[0]);else if(L.end(),L.taps===2&&(j=_t(j,this),Math.hypot(p[0]-j[0],p[1]-j[1])<x)){var H=ct(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return y.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:Is(+M),y):r},y.filter=function(M){return arguments.length?(e=typeof M=="function"?M:Is(!!M),y):e},y.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:Is(!!M),y):s},y.extent=function(M){return arguments.length?(t=typeof M=="function"?M:Is([[+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 Zt={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."},_o=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],jv=["Enter"," ","Escape"],Hv={"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 Kn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Kn||(Kn={}));var $o;(function(e){e.Partial="partial",e.Full="full"})($o||($o={}));const Vv={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Nn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Nn||(Nn={}));var fa;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(fa||(fa={}));var we;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(we||(we={}));const Af={[we.Left]:we.Right,[we.Right]:we.Left,[we.Top]:we.Bottom,[we.Bottom]:we.Top};function qv(e){return e===null?null:e?"valid":"invalid"}const Uv=e=>"id"in e&&"source"in e&&"target"in e,rq=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Gd=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Jo=(e,t=[0,0])=>{const{width:n,height:r}=bn(e),s=e.origin??t,a=n*s[0],i=r*s[1];return{x:e.position.x-a,y:e.position.y-i}},oq=(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):Gd(s)?s:t.nodeLookup.get(s.id));const l=i?ha(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return ei(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ti(n)},es=(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=ei(n,ha(s)),r=!0)}),r?ti(n):{x:0,y:0,width:0,height:0}},Kd=(e,t,[n,r,s]=[0,0,1],a=!1,i=!1)=>{const l={...ns(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=Do(l,Lr(d)),x=(m??0)*(g??0),y=a&&b>0;(!d.internals.handleBounds||y||b>=x||d.dragging)&&c.push(d)}return c},sq=(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 aq(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 iq({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:a},i){if(e.size===0)return Promise.resolve(!0);const l=aq(e,i),c=es(l),d=Wd(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 Qv({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",Zt.error005());else{const m=l.measured.width,g=l.measured.height;m&&g&&(p=[[c,d],[c+m,d+g]])}else l&&Tr(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=Tr(p)?or(t,p,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&a?.("015",Zt.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 lq({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=sq(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 Dr=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),or=(e={x:0,y:0},t,n)=>({x:Dr(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Dr(e.y,t[0][1],t[1][1]-(n?.height??0))});function Gv(e,t,n){const{width:r,height:s}=bn(n),{x:a,y:i}=n.internals.positionAbsolute;return or(e,[[a,i],[a+r,i+s]],t)}const Pf=(e,t,n)=>e<t?Dr(Math.abs(e-t),1,t)/t:e>n?-Dr(Math.abs(e-n),1,t)/t:0,Kv=(e,t,n=15,r=40)=>{const s=Pf(e.x,r,t.width-r)*n,a=Pf(e.y,r,t.height-r)*n;return[s,a]},ei=(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)}),nc=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),ti=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Lr=(e,t=[0,0])=>{const{x:n,y:r}=Gd(e)?e.internals.positionAbsolute:Jo(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}},ha=(e,t=[0,0])=>{const{x:n,y:r}=Gd(e)?e.internals.positionAbsolute:Jo(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)}},Wv=(e,t)=>ti(ei(nc(e),nc(t))),Do=(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)},_f=e=>Dt(e.width)&&Dt(e.height)&&Dt(e.x)&&Dt(e.y),Dt=e=>!isNaN(e)&&isFinite(e),cq=(e,t)=>{},ts=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),ns=({x:e,y:t},[n,r,s],a=!1,i=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return a?ts(l,i):l},ma=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function gr(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 dq(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=gr(e,n),s=gr(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=gr(e.top??e.y??0,n),s=gr(e.bottom??e.y??0,n),a=gr(e.left??e.x??0,t),i=gr(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 uq(e,t,n,r,s,a){const{x:i,y:l}=ma(e,[t,n,r]),{x:c,y:d}=ma({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 Wd=(e,t,n,r,s,a)=>{const i=dq(a,t,n),l=(t-i.x)/e.width,c=(n-i.y)/e.height,d=Math.min(l,c),f=Dr(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=uq(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}},Lo=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Tr(e){return e!=null&&e!=="parent"}function bn(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Yv(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Zv(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 $f(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function pq(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function fq(e){return{...Hv,...e||{}}}function bo(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:a,y:i}=Lt(e),l=ns({x:a-(s?.left??0),y:i-(s?.top??0)},r),{x:c,y:d}=n?ts(l,t):l;return{xSnapped:c,ySnapped:d,...l}}const Yd=e=>({width:e.offsetWidth,height:e.offsetHeight}),Xv=e=>e?.getRootNode?.()||window?.document,hq=["INPUT","SELECT","TEXTAREA"];function Jv(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:hq.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const e1=e=>"clientX"in e,Lt=(e,t)=>{const n=e1(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)}},Df=(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,...Yd(i)}})};function t1({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:a,targetControlX:i,targetControlY:l}){const c=e*.125+s*.375+i*.375+n*.125,d=t*.125+a*.375+l*.375+r*.125,f=Math.abs(c-e),p=Math.abs(d-t);return[c,d,f,p]}function As(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Lf({pos:e,x1:t,y1:n,x2:r,y2:s,c:a}){switch(e){case we.Left:return[t-As(t-r,a),n];case we.Right:return[t+As(r-t,a),n];case we.Top:return[t,n-As(n-s,a)];case we.Bottom:return[t,n+As(s-n,a)]}}function n1({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:r,targetY:s,targetPosition:a=we.Top,curvature:i=.25}){const[l,c]=Lf({pos:n,x1:e,y1:t,x2:r,y2:s,c:i}),[d,f]=Lf({pos:a,x1:r,y1:s,x2:e,y2:t,c:i}),[p,h,m,g]=t1({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:f});return[`M${e},${t} C${l},${c} ${d},${f} ${r},${s}`,p,h,m,g]}function r1({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 mq({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 gq({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const a=ei(ha(e),ha(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 Do(i,ti(a))>0}const bq=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,xq=(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)),yq=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||bq;let s;return Uv(e)?s={...e}:s={...e,id:r(e)},xq(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function o1({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,a,i,l]=r1({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,a,i,l]}const Tf={[we.Left]:{x:-1,y:0},[we.Right]:{x:1,y:0},[we.Top]:{x:0,y:-1},[we.Bottom]:{x:0,y:1}},vq=({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},Rf=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function wq({source:e,sourcePosition:t=we.Bottom,target:n,targetPosition:r=we.Top,center:s,offset:a,stepPosition:i}){const l=Tf[t],c=Tf[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=vq({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]=r1({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 P=[{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"?P:I:g=h==="x"?I:P}else{const P=[{x:d.x,y:f.y}],I=[{x:f.x,y:d.y}];if(h==="x"?g=l.x===m?I:P:g=l.y===m?P:I,t===r){const M=Math.abs(e[h]-n[h]);if(M<=a){const D=Math.min(a-1,a-M);l[h]===m?y[h]=(d[h]>e[h]?-1:1)*D:w[h]=(f[h]>n[h]?-1:1)*D}}if(t!==r){const M=h==="x"?"y":"x",D=l[h]===c[M],L=d[M]>f[M],T=d[M]<f[M];(l[h]===1&&(!D&&L||D&&T)||l[h]!==1&&(!D&&T||D&&L))&&(g=h==="x"?P:I)}const z={x:d.x+y.x,y:d.y+y.y},A={x:f.x+w.x,y:f.y+w.y},O=Math.max(Math.abs(z.x-g[0].x),Math.abs(A.x-g[0].x)),R=Math.max(Math.abs(z.y-g[0].y),Math.abs(A.y-g[0].y));O>=R?(b=(z.x+A.x)/2,x=g[0].y):(b=g[0].x,x=(z.y+A.y)/2)}const k={x:d.x+y.x,y:d.y+y.y},C={x:f.x+w.x,y:f.y+w.y};return[[e,...k.x!==g[0].x||k.y!==g[0].y?[k]:[],...g,...C.x!==g[g.length-1].x||C.y!==g[g.length-1].y?[C]:[],n],b,x,v,N]}function Nq(e,t,n,r){const s=Math.min(Rf(e,t)/2,Rf(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 rc({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]=wq({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+=Nq(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 Of(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function kq(e){const{sourceNode:t,targetNode:n}=e;if(!Of(t)||!Of(n))return null;const r=t.internals.handleBounds||Bf(t.handles),s=n.internals.handleBounds||Bf(n.handles),a=zf(r?.source??[],e.sourceHandle),i=zf(e.connectionMode===$r.Strict?s?.target??[]:(s?.target??[]).concat(s?.source??[]),e.targetHandle);if(!a||!i)return e.onError?.("008",Zt.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=sr(t,a,l),f=sr(n,i,c);return{sourceX:d.x,sourceY:d.y,targetX:f.x,targetY:f.y,sourcePosition:l,targetPosition:c}}function Bf(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 sr(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??bn(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 zf(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function oc(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function Sq(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=oc(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 s1=1e3,Cq=10,Zd={nodeOrigin:[0,0],nodeExtent:_o,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Mq={...Zd,checkEquality:!0};function Xd(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function Eq(e,t,n){const r=Xd(Zd,n);for(const s of e.values())if(s.parentId)eu(s,e,t,r);else{const a=Jo(s,r.nodeOrigin),i=Tr(s.extent)?s.extent:r.nodeExtent,l=or(a,i,bn(s));s.internals.positionAbsolute=l}}function Iq(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 Jd(e){return e==="manual"}function sc(e,t,n,r={}){const s=Xd(Mq,r),a={i:0},i=new Map(t),l=s?.elevateNodesOnSelect&&!Jd(s.zIndexMode)?s1: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=Jo(f,s.nodeOrigin),m=Tr(f.extent)?f.extent:s.nodeExtent,g=or(h,m,bn(f));p={...s.defaults,...f,measured:{width:f.measured?.width,height:f.measured?.height},internals:{positionAbsolute:g,handleBounds:Iq(f,p),z:a1(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&&eu(p,t,n,r,a),d||=f.selected??!1}return{nodesInitialized:c,hasSelectedNodes:d}}function Aq(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 eu(e,t,n,r,s){const{elevateNodesOnSelect:a,nodeOrigin:i,nodeExtent:l,zIndexMode:c}=Xd(Zd,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}Aq(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*Cq),s&&f.internals.rootParentIndex!==void 0&&(s.i=f.internals.rootParentIndex);const p=a&&!Jd(c)?s1:0,{x:h,y:m,z:g}=Pq(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 a1(e,t,n){const r=Dt(e.zIndex)?e.zIndex:0;return Jd(n)?r:r+(e.selected?t:0)}function Pq(e,t,n,r,s,a){const{x:i,y:l}=t.internals.positionAbsolute,c=bn(e),d=Jo(e,n),f=Tr(e.extent)?or(d,e.extent,c):d;let p=or({x:i+f.x,y:l+f.y},r,c);e.extent==="parent"&&(p=Gv(p,c,t));const h=a1(e,s,a),m=t.internals.z??0;return{x:p.x,y:p.y,z:m>=h?m+1:h}}function tu(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??Lr(l),d=Wv(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=bn(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 _q(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=Yd(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=Tr(g.extent)?g.extent:a;let{positionAbsolute:N}=g.internals;g.parentId&&g.extent==="parent"?N=Gv(N,b,t.get(g.parentId)):v&&(N=or(N,v,b));const k={...g,measured:b,internals:{...g.internals,positionAbsolute:N,handleBounds:{source:Df("source",m.nodeElement,w,p,g.id),target:Df("target",m.nodeElement,w,p,g.id)}}};t.set(g.id,k),g.parentId&&eu(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:Lr(k,s)}))}}if(h.length>0){const m=tu(h,t,n,s);d.push(...m)}return{changes:d,updatedInternals:c}}async function $q({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 Ff(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 i1(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}`;Ff("source",c,f,e,s,i),Ff("target",c,d,e,a,l),t.set(r.id,r)}}function l1(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:l1(n,t):!1}function jf(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 Dq(e,t,n,r){const s=new Map;for(const[a,i]of e)if((i.selected||i.id===r)&&(!i.parentId||!l1(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 nl({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 Lq({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=ts(a,t);return{x:i.x-a.x,y:i.y-a.y}}function Tq({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:C,nodeClickDistance:E=0}){h=ct(N);function P({x:O,y:R}){const{nodeLookup:M,nodeExtent:D,snapGrid:L,snapToGrid:T,nodeOrigin:B,onNodeDrag:F,onSelectionDrag:j,onError:H,updateNodePositions:$}=t();a={x:O,y:R};let V=!1;const G=l.size>1,Z=G&&D?nc(es(l)):null,oe=G&&T?Lq({dragItems:l,snapGrid:L,x:O,y:R}):null;for(const[te,X]of l){if(!M.has(te))continue;let re={x:O-X.distance.x,y:R-X.distance.y};T&&(re=oe?{x:Math.round(re.x+oe.x),y:Math.round(re.y+oe.y)}:ts(re,L));let be=null;if(G&&D&&!X.extent&&Z){const{positionAbsolute:ee}=X.internals,ae=ee.x-Z.x+D[0][0],fe=ee.x+X.measured.width-Z.x2+D[1][0],ge=ee.y-Z.y+D[0][1],U=ee.y+X.measured.height-Z.y2+D[1][1];be=[[ae,ge],[fe,U]]}const{position:J,positionAbsolute:K}=Qv({nodeId:te,nextPosition:re,nodeLookup:M,nodeExtent:be||D,nodeOrigin:B,onError:H});V=V||X.position.x!==J.x||X.position.y!==J.y,X.position=J,X.internals.positionAbsolute=K}if(g=g||V,!!V&&($(l,!0),b&&(r||F||!C&&j))){const[te,X]=nl({nodeId:C,dragItems:l,nodeLookup:M});r?.(b,l,te,X),F?.(b,te,X),C||j?.(b,X)}}async function I(){if(!f)return;const{transform:O,panBy:R,autoPanSpeed:M,autoPanOnNodeDrag:D}=t();if(!D){c=!1,cancelAnimationFrame(i);return}const[L,T]=Kv(d,f,M);(L!==0||T!==0)&&(a.x=(a.x??0)-L/O[2],a.y=(a.y??0)-T/O[2],await R({x:L,y:T})&&P(a)),i=requestAnimationFrame(I)}function z(O){const{nodeLookup:R,multiSelectionActive:M,nodesDraggable:D,transform:L,snapGrid:T,snapToGrid:B,selectNodesOnDrag:F,onNodeDragStart:j,onSelectionDragStart:H,unselectNodesAndEdges:$}=t();p=!0,(!F||!k)&&!M&&C&&(R.get(C)?.selected||$()),k&&F&&C&&e?.(C);const V=bo(O.sourceEvent,{transform:L,snapGrid:T,snapToGrid:B,containerBounds:f});if(a=V,l=Dq(R,D,V,C),l.size>0&&(n||j||!C&&H)){const[G,Z]=nl({nodeId:C,dragItems:l,nodeLookup:R});n?.(O.sourceEvent,l,G,Z),j?.(O.sourceEvent,G,Z),C||H?.(O.sourceEvent,Z)}}const A=Cv().clickDistance(E).on("start",O=>{const{domNode:R,nodeDragThreshold:M,transform:D,snapGrid:L,snapToGrid:T}=t();f=R?.getBoundingClientRect()||null,m=!1,g=!1,b=O.sourceEvent,M===0&&z(O),a=bo(O.sourceEvent,{transform:D,snapGrid:L,snapToGrid:T,containerBounds:f}),d=Lt(O.sourceEvent,f)}).on("drag",O=>{const{autoPanOnNodeDrag:R,transform:M,snapGrid:D,snapToGrid:L,nodeDragThreshold:T,nodeLookup:B}=t(),F=bo(O.sourceEvent,{transform:M,snapGrid:D,snapToGrid:L,containerBounds:f});if(b=O.sourceEvent,(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1||C&&!B.has(C))&&(m=!0),!m){if(!c&&R&&p&&(c=!0,I()),!p){const j=Lt(O.sourceEvent,f),H=j.x-d.x,$=j.y-d.y;Math.sqrt(H*H+$*$)>T&&z(O)}(a.x!==F.xSnapped||a.y!==F.ySnapped)&&l&&p&&(d=Lt(O.sourceEvent,f),P(F))}}).on("end",O=>{if(!(!p||m)&&(c=!1,p=!1,cancelAnimationFrame(i),l.size>0)){const{nodeLookup:R,updateNodePositions:M,onNodeDragStop:D,onSelectionDragStop:L}=t();if(g&&(M(l,!1),g=!1),s||D||!C&&L){const[T,B]=nl({nodeId:C,dragItems:l,nodeLookup:R,dragging:!1});s?.(O.sourceEvent,l,T,B),D?.(O.sourceEvent,T,B),C||L?.(O.sourceEvent,B)}}}).filter(O=>{const R=O.target;return!O.button&&(!w||!jf(R,`.${w}`,N))&&(!v||jf(R,v,N))});h.call(A)}function y(){h?.on(".drag",null)}return{update:x,destroy:y}}function Rq(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())Do(s,Lr(a))>0&&r.push(a);return r}const Oq=250;function Bq(e,t,n,r){let s=[],a=1/0;const i=Rq(e,n,t+Oq);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}=sr(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 c1(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,...sr(i,c,c.position,!0)}:c}function d1(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function zq(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const u1=()=>!0;function Fq(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=u1,onReconnectEnd:w,updateConnection:v,getTransform:N,getFromHandle:k,autoPanSpeed:C,dragThreshold:E=1,handleDomNode:P}){const I=Xv(e.target);let z=0,A;const{x:O,y:R}=Lt(e),M=d1(a,P),D=l?.getBoundingClientRect();let L=!1;if(!D||!M)return;const T=c1(s,M,r,c,t);if(!T)return;let B=Lt(e,D),F=!1,j=null,H=!1,$=null;function V(){if(!f||!D)return;const[J,K]=Kv(B,D,C);h({x:J,y:K}),z=requestAnimationFrame(V)}const G={...T,nodeId:s,type:M,position:T.position},Z=c.get(s);let te={inProgress:!0,isValid:null,from:sr(Z,G,we.Left,!0),fromHandle:G,fromPosition:G.position,fromNode:Z,to:B,toHandle:null,toPosition:Af[G.position],toNode:null,pointer:B};function X(){L=!0,v(te),g?.(e,{nodeId:s,handleId:r,handleType:M})}E===0&&X();function re(J){if(!L){const{x:U,y:ie}=Lt(J),ue=U-O,de=ie-R;if(!(ue*ue+de*de>E*E))return;X()}if(!k()||!G){be(J);return}const K=N();B=Lt(J,D),A=Bq(ns(B,K,!1,[1,1]),n,c,G),F||(V(),F=!0);const ee=p1(J,{handle:A,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:i?"target":"source",isValidConnection:y,doc:I,lib:d,flowId:p,nodeLookup:c});$=ee.handleDomNode,j=ee.connection,H=zq(!!A,ee.isValid);const ae=c.get(s),fe=ae?sr(ae,G,we.Left,!0):te.from,ge={...te,from:fe,isValid:H,to:ee.toHandle&&H?ma({x:ee.toHandle.x,y:ee.toHandle.y},K):B,toHandle:ee.toHandle,toPosition:H&&ee.toHandle?ee.toHandle.position:Af[G.position],toNode:ee.toHandle?c.get(ee.toHandle.nodeId):null,pointer:B};v(ge),te=ge}function be(J){if(!("touches"in J&&J.touches.length>0)){if(L){(A||$)&&j&&H&&b?.(j);const{inProgress:K,...ee}=te,ae={...ee,toPosition:te.toHandle?te.toPosition:null};x?.(J,ae),a&&w?.(J,ae)}m(),cancelAnimationFrame(z),F=!1,H=!1,j=null,$=null,I.removeEventListener("mousemove",re),I.removeEventListener("mouseup",be),I.removeEventListener("touchmove",re),I.removeEventListener("touchend",be)}}I.addEventListener("mousemove",re),I.addEventListener("mouseup",be),I.addEventListener("touchmove",re),I.addEventListener("touchend",be)}function p1(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:a,doc:i,lib:l,flowId:c,isValidConnection:d=u1,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}=Lt(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=d1(void 0,x),v=x.getAttribute("data-nodeid"),N=x.getAttribute("data-handleid"),k=x.classList.contains("connectable"),C=x.classList.contains("connectableend");if(!v||!w)return y;const E={source:p?v:r,sourceHandle:p?N:s,target:p?r:v,targetHandle:p?s:N};y.connection=E;const I=k&&C&&(n===$r.Strict?p&&w==="source"||!p&&w==="target":v!==r||N!==s);y.isValid=I&&d(E),y.toHandle=c1(v,w,N,f,n,!0)}return y}const ac={onPointerDown:Fq,isValid:p1};function jq({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=ct(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&&Lo()?10:1,C=-v.sourceEvent.deltaY*(v.sourceEvent.deltaMode===1?.05:v.sourceEvent.deltaMode?1:.002)*f,E=N[2]*Math.pow(2,C*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],C=[k[0]-b[0],k[1]-b[1]];b=k;const E=r()*Math.max(N[2],Math.log(N[2]))*(m?-1:1),P={x:N[0]-C[0]*E,y:N[1]-C[1]*E},I=[[0,0],[c,d]];t.setViewportConstrained({x:P.x,y:P.y,zoom:N[2]},I,l)},w=Fv().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 ni=e=>({x:e.x,y:e.y,zoom:e.k}),rl=({x:e,y:t,zoom:n})=>Ja.translate(e,t).scale(n),vr=(e,t)=>e.target.closest(`.${t}`),f1=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Hq=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ol=(e,t=0,n=Hq,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},h1=e=>{const t=e.ctrlKey&&Lo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Vq({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:a,zoomOnPinch:i,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:d}){return f=>{if(vr(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=h1(f),w=p*Math.pow(2,y);r.scaleTo(n,w,x,f);return}const h=f.deltaMode===1?20:1;let m=s===Kn.Vertical?0:f.deltaX*h,g=s===Kn.Horizontal?0:f.deltaY*h;!Lo()&&f.shiftKey&&s!==Kn.Vertical&&(m=f.deltaY*h,g=0),r.translateBy(n,-(m/p)*a,-(g/p)*a,{internal:!0});const b=ni(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 qq({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const a=r.type==="wheel",i=!t&&a&&!r.ctrlKey,l=vr(r,e);if(r.ctrlKey&&a&&l&&r.preventDefault(),i||l)return null;r.preventDefault(),n.call(this,r,s)}}function Uq({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;const s=ni(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 Qq({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return a=>{e.usedRightMouseButton=!!(n&&f1(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),s&&!a.sourceEvent?.internal&&s?.(a.sourceEvent,ni(a.transform))}}function Gq({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:a}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&f1(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&a(i.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const l=ni(i.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s?.(i.sourceEvent,l)},n?150:0)}}}function Kq({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"&&(vr(p,`${d}-flow__node`)||vr(p,`${d}-flow__edge`)))return!0;if(!r&&!h&&!s&&!a&&!n||i||f&&!g||vr(p,l)&&g||vr(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 Wq({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=Fv().scaleExtent([t,n]).translateExtent(r),h=ct(e).call(p);w({x:s.x,y:s.y,zoom:Dr(s.zoom,t,n)},[[0,0],[f.width,f.height]],r);const m=h.on("wheel.zoom"),g=h.on("dblclick.zoom");p.wheelDelta(h1);function b(A,O){return h?new Promise(R=>{p?.interpolate(O?.interpolate==="linear"?go:js).transform(ol(h,O?.duration,O?.ease,()=>R(!0)),A)}):Promise.resolve(!1)}function x({noWheelClassName:A,noPanClassName:O,onPaneContextMenu:R,userSelectionActive:M,panOnScroll:D,panOnDrag:L,panOnScrollMode:T,panOnScrollSpeed:B,preventScrolling:F,zoomOnPinch:j,zoomOnScroll:H,zoomOnDoubleClick:$,zoomActivationKeyPressed:V,lib:G,onTransformChange:Z,connectionInProgress:oe,paneClickDistance:te,selectionOnDrag:X}){M&&!d.isZoomingOrPanning&&y();const re=D&&!V&&!M;p.clickDistance(X?1/0:!Dt(te)||te<0?0:te);const be=re?Vq({zoomPanValues:d,noWheelClassName:A,d3Selection:h,d3Zoom:p,panOnScrollMode:T,panOnScrollSpeed:B,zoomOnPinch:j,onPanZoomStart:i,onPanZoom:a,onPanZoomEnd:l}):qq({noWheelClassName:A,preventScrolling:F,d3ZoomHandler:m});if(h.on("wheel.zoom",be,{passive:!1}),!M){const K=Uq({zoomPanValues:d,onDraggingChange:c,onPanZoomStart:i});p.on("start",K);const ee=Qq({zoomPanValues:d,panOnDrag:L,onPaneContextMenu:!!R,onPanZoom:a,onTransformChange:Z});p.on("zoom",ee);const ae=Gq({zoomPanValues:d,panOnDrag:L,panOnScroll:D,onPaneContextMenu:R,onPanZoomEnd:l,onDraggingChange:c});p.on("end",ae)}const J=Kq({zoomActivationKeyPressed:V,panOnDrag:L,zoomOnScroll:H,panOnScroll:D,zoomOnDoubleClick:$,zoomOnPinch:j,userSelectionActive:M,noPanClassName:O,noWheelClassName:A,lib:G,connectionInProgress:oe});p.filter(J),$?h.on("dblclick.zoom",g):h.on("dblclick.zoom",null)}function y(){p.on("zoom",null)}async function w(A,O,R){const M=rl(A),D=p?.constrain()(M,O,R);return D&&await b(D),new Promise(L=>L(D))}async function v(A,O){const R=rl(A);return await b(R,O),new Promise(M=>M(R))}function N(A){if(h){const O=rl(A),R=h.property("__zoom");(R.k!==A.zoom||R.x!==A.x||R.y!==A.y)&&p?.transform(h,O,null,{sync:!0})}}function k(){const A=h?zv(h.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}function C(A,O){return h?new Promise(R=>{p?.interpolate(O?.interpolate==="linear"?go:js).scaleTo(ol(h,O?.duration,O?.ease,()=>R(!0)),A)}):Promise.resolve(!1)}function E(A,O){return h?new Promise(R=>{p?.interpolate(O?.interpolate==="linear"?go:js).scaleBy(ol(h,O?.duration,O?.ease,()=>R(!0)),A)}):Promise.resolve(!1)}function P(A){p?.scaleExtent(A)}function I(A){p?.translateExtent(A)}function z(A){const O=!Dt(A)||A<0?0:A;p?.clickDistance(O)}return{update:x,destroy:y,setViewport:v,setViewportConstrained:w,getViewport:k,scaleTo:C,scaleBy:E,setScaleExtent:P,setTranslateExtent:I,syncViewport:N,setClickDistance:z}}var Rr;(function(e){e.Line="line",e.Handle="handle"})(Rr||(Rr={}));function Yq({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 Hf(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 vn(e,t){return Math.max(0,t-e)}function wn(e,t){return Math.max(0,e-t)}function Ps(e,t,n){return Math.max(0,t-e,e-n)}function Vf(e,t){return e?!t:t}function Zq(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:C,aspectRatio:E}=e;let P=Math.floor(f?m-e.pointerX:0),I=Math.floor(p?g-e.pointerY:0);const z=k+(c?-P:P),A=C+(d?-I:I),O=-a[0]*k,R=-a[1]*C;let M=Ps(z,b,x),D=Ps(A,y,w);if(i){let B=0,F=0;c&&P<0?B=vn(v+P+O,i[0][0]):!c&&P>0&&(B=wn(v+z+O,i[1][0])),d&&I<0?F=vn(N+I+R,i[0][1]):!d&&I>0&&(F=wn(N+A+R,i[1][1])),M=Math.max(M,B),D=Math.max(D,F)}if(l){let B=0,F=0;c&&P>0?B=wn(v+P,l[0][0]):!c&&P<0&&(B=vn(v+z,l[1][0])),d&&I>0?F=wn(N+I,l[0][1]):!d&&I<0&&(F=vn(N+A,l[1][1])),M=Math.max(M,B),D=Math.max(D,F)}if(s){if(f){const B=Ps(z/E,y,w)*E;if(M=Math.max(M,B),i){let F=0;!c&&!d||c&&!d&&h?F=wn(N+R+z/E,i[1][1])*E:F=vn(N+R+(c?P:-P)/E,i[0][1])*E,M=Math.max(M,F)}if(l){let F=0;!c&&!d||c&&!d&&h?F=vn(N+z/E,l[1][1])*E:F=wn(N+(c?P:-P)/E,l[0][1])*E,M=Math.max(M,F)}}if(p){const B=Ps(A*E,b,x)/E;if(D=Math.max(D,B),i){let F=0;!c&&!d||d&&!c&&h?F=wn(v+A*E+O,i[1][0])/E:F=vn(v+(d?I:-I)*E+O,i[0][0])/E,D=Math.max(D,F)}if(l){let F=0;!c&&!d||d&&!c&&h?F=vn(v+A*E,l[1][0])/E:F=wn(v+(d?I:-I)*E,l[0][0])/E,D=Math.max(D,F)}}}I=I+(I<0?D:-D),P=P+(P<0?M:-M),s&&(h?z>A*E?I=(Vf(c,d)?-P:P)/E:P=(Vf(c,d)?-I:I)*E:f?(I=P/E,d=c):(P=I*E,c=d));const L=c?v+P:v,T=d?N+I:N;return{width:k+(c?-P:P),height:C+(d?-I:I),x:a[0]*P*(c?-1:1)+L,y:a[1]*I*(d?-1:1)+T}}const m1={width:0,height:0,x:0,y:0},Xq={...m1,pointerX:0,pointerY:0,aspectRatio:1};function Jq(e){return[[0,0],[e.measured.width,e.measured.height]]}function eU(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 tU({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const a=ct(e);let i={controlDirection:Hf("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={...m1},w={...Xq};i={boundaries:f,resizeDirection:h,keepAspectRatio:p,controlDirection:Hf(d)};let v,N=null,k=[],C,E,P,I=!1;const z=Cv().on("start",A=>{const{nodeLookup:O,transform:R,snapGrid:M,snapToGrid:D,nodeOrigin:L,paneDomNode:T}=n();if(v=O.get(t),!v)return;N=T?.getBoundingClientRect()??null;const{xSnapped:B,ySnapped:F}=bo(A.sourceEvent,{transform:R,snapGrid:M,snapToGrid:D,containerBounds:N});y={width:v.measured.width??0,height:v.measured.height??0,x:v.position.x??0,y:v.position.y??0},w={...y,pointerX:B,pointerY:F,aspectRatio:y.width/y.height},C=void 0,v.parentId&&(v.extent==="parent"||v.expandParent)&&(C=O.get(v.parentId),E=C&&v.extent==="parent"?Jq(C):void 0),k=[],P=void 0;for(const[j,H]of O)if(H.parentId===t&&(k.push({id:j,position:{...H.position},extent:H.extent}),H.extent==="parent"||H.expandParent)){const $=eU(H,v,H.origin??L);P?P=[[Math.min($[0][0],P[0][0]),Math.min($[0][1],P[0][1])],[Math.max($[1][0],P[1][0]),Math.max($[1][1],P[1][1])]]:P=$}m?.(A,{...y})}).on("drag",A=>{const{transform:O,snapGrid:R,snapToGrid:M,nodeOrigin:D}=n(),L=bo(A.sourceEvent,{transform:O,snapGrid:R,snapToGrid:M,containerBounds:N}),T=[];if(!v)return;const{x:B,y:F,width:j,height:H}=y,$={},V=v.origin??D,{width:G,height:Z,x:oe,y:te}=Zq(w,i.controlDirection,L,i.boundaries,i.keepAspectRatio,V,E,P),X=G!==j,re=Z!==H,be=oe!==B&&X,J=te!==F&&re;if(!be&&!J&&!X&&!re)return;if((be||J||V[0]===1||V[1]===1)&&($.x=be?oe:y.x,$.y=J?te:y.y,y.x=$.x,y.y=$.y,k.length>0)){const fe=oe-B,ge=te-F;for(const U of k)U.position={x:U.position.x-fe+V[0]*(G-j),y:U.position.y-ge+V[1]*(Z-H)},T.push(U)}if((X||re)&&($.width=X&&(!i.resizeDirection||i.resizeDirection==="horizontal")?G:y.width,$.height=re&&(!i.resizeDirection||i.resizeDirection==="vertical")?Z:y.height,y.width=$.width,y.height=$.height),C&&v.expandParent){const fe=V[0]*($.width??0);$.x&&$.x<fe&&(y.x=fe,w.x=w.x-($.x-fe));const ge=V[1]*($.height??0);$.y&&$.y<ge&&(y.y=ge,w.y=w.y-($.y-ge))}const K=Yq({width:y.width,prevWidth:j,height:y.height,prevHeight:H,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),ee={...y,direction:K};x?.(A,ee)!==!1&&(I=!0,g?.(A,ee),r($,T))}).on("end",A=>{I&&(b?.(A,{...y}),s?.({...y}),I=!1)});a.call(z)}function c(){a.on(".drag",null)}return{update:l,destroy:c}}var g1={exports:{}},b1={};/**
1120
- * @license React
1121
- * use-sync-external-store-shim/with-selector.production.js
1122
- *
1123
- * Copyright (c) Meta Platforms, Inc. and affiliates.
1124
- *
1125
- * This source code is licensed under the MIT license found in the
1126
- * LICENSE file in the root directory of this source tree.
1127
- */var ri=Hh,nU=T0;function rU(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var oU=typeof Object.is=="function"?Object.is:rU,sU=nU.useSyncExternalStore,aU=ri.useRef,iU=ri.useEffect,lU=ri.useMemo,cU=ri.useDebugValue;b1.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var a=aU(null);if(a.current===null){var i={hasValue:!1,value:null};a.current=i}else i=a.current;a=lU(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,oU(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=sU(e,a[0],a[1]);return iU(function(){i.hasValue=!0,i.value=l},[l]),cU(l),l};g1.exports=b1;var dU=g1.exports;const uU=wN(dU),pU={},qf=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:()=>{(pU?"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},fU=e=>e?qf(e):qf,{useDebugValue:hU}=uc,{useSyncExternalStoreWithSelector:mU}=uU,gU=e=>e;function x1(e,t=gU,n){const r=mU(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return hU(r),r}const Uf=(e,t)=>{const n=fU(e),r=(s,a=t)=>x1(n,s,a);return Object.assign(r,n),r},bU=(e,t)=>e?Uf(e,t):Uf;function je(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 oi=Be(null),xU=oi.Provider,y1=Zt.error001();function $e(e,t){const n=ve(oi);if(n===null)throw new Error(y1);return x1(n,e,t)}function Ve(){const e=ve(oi);if(e===null)throw new Error(y1);return Q(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Qf={display:"none"},yU={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},v1="react-flow__node-desc",w1="react-flow__edge-desc",vU="react-flow__aria-live",wU=e=>e.ariaLiveMessage,NU=e=>e.ariaLabelConfig;function kU({rfId:e}){const t=$e(wU);return o("div",{id:`${vU}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:yU,children:t})}function SU({rfId:e,disableKeyboardA11y:t}){const n=$e(NU);return u(me,{children:[o("div",{id:`${v1}-${e}`,style:Qf,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o("div",{id:`${w1}-${e}`,style:Qf,children:n["edge.a11yDescription.default"]}),!t&&o(kU,{rfId:e})]})}const si=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})});si.displayName="Panel";function CU({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:o(si,{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 MU=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}},_s=e=>e.id;function EU(e,t){return je(e.selectedNodes.map(_s),t.selectedNodes.map(_s))&&je(e.selectedEdges.map(_s),t.selectedEdges.map(_s))}function IU({onSelectionChange:e}){const t=Ve(),{selectedNodes:n,selectedEdges:r}=$e(MU,EU);return Y(()=>{const s={nodes:n,edges:r};e?.(s),t.getState().onSelectionChangeHandlers.forEach(a=>a(s))},[n,r,e]),null}const AU=e=>!!e.onSelectionChangeHandlers;function PU({onSelectionChange:e}){const t=$e(AU);return e||t?o(IU,{onSelectionChange:e}):null}const ic=typeof window<"u"?va:Y,N1=[0,0],_U={x:0,y:0,zoom:1},$U=["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"],Gf=[...$U,"rfId"],DU=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}),Kf={translateExtent:_o,nodeOrigin:N1,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function LU(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:a,setNodeExtent:i,reset:l,setDefaultNodesAndEdges:c}=$e(DU,je),d=Ve();ic(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=Kf,l()}),[]);const f=ne(Kf);return ic(()=>{for(const p of Gf){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:fq(h)}):p==="fitView"?d.setState({fitViewQueued:h}):p==="fitViewOptions"?d.setState({fitViewOptions:h}):d.setState({[p]:h})))}f.current=e},Gf.map(p=>e[p])),null}function Wf(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function TU(e){const[t,n]=_(e==="system"?null:e);return Y(()=>{if(e!=="system"){n(e);return}const r=Wf(),s=()=>n(r?.matches?"dark":"light");return s(),r?.addEventListener("change",s),()=>{r?.removeEventListener("change",s)}},[e]),t!==null?t:Wf()?.matches?"dark":"light"}const Yf=typeof document<"u"?document:null;function To(e=null,t={target:Yf,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("+",`
1128
- `).replace(`
1129
-
1130
- `,`
1131
- +`).split(`
1132
- `)),f=d.reduce((p,h)=>p.concat(...h),[]);return[d,f]}return[[],[]]},[e]);return Y(()=>{const c=t?.target??Yf,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)&&Jv(m))return!1;const b=Xf(m.code,l);if(a.current.add(m[b]),Zf(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=Xf(m.code,l);Zf(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 Zf(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function Xf(e,t){return t.includes(e)?"code":"key"}const RU=()=>{const e=Ve();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=Wd(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 ns(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=ma(t,n);return{x:i.x+s,y:i.y+a}}}),[])};function k1(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)OU(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 OU(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 BU(e,t){return k1(e,t)}function zU(e,t){return k1(e,t)}function Hn(e,t){return{id:e,type:"select",selected:t}}function wr(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(Hn(a.id,i)))}return r}function Jf({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 eh(e){return{id:e.id,type:"remove"}}const th=e=>rq(e),FU=e=>Uv(e);function S1(e){return qe(e)}function nh(e){const[t,n]=_(BigInt(0)),[r]=_(()=>jU(()=>n(s=>s+BigInt(1))));return ic(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function jU(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const C1=Be(null);function HU({children:e}){const t=Ve(),n=q(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=Jf({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=nh(n),s=q(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(Jf({items:m,lookup:h}))},[]),a=nh(s),i=Q(()=>({nodeQueue:r,edgeQueue:a}),[]);return o(C1.Provider,{value:i,children:e})}function VU(){const e=ve(C1);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const qU=e=>!!e.panZoom;function nu(){const e=RU(),t=Ve(),n=VU(),r=$e(qU),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=th(p)?p:h.get(p.id),b=g.parentId?Zv(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 Lr(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&&th(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&&FU(x)?x:{...b,...x}}return b}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>a(p)?.internals.userNode,getInternalNode:a,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(h=>({...h}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:i,setEdges:l,addNodes:p=>{const h=Array.isArray(p)?p:[p];n.nodeQueue.push(m=>[...m,...h])},addEdges:p=>{const h=Array.isArray(p)?p:[p];n.edgeQueue.push(m=>[...m,...h])},toObject:()=>{const{nodes:p=[],edges:h=[],transform:m}=t.getState(),[g,b,x]=m;return{nodes:p.map(y=>({...y})),edges:h.map(y=>({...y})),viewport:{x:g,y:b,zoom:x}}},deleteElements:async({nodes:p=[],edges:h=[]})=>{const{nodes:m,edges:g,onNodesDelete:b,onEdgesDelete:x,triggerNodeChanges:y,triggerEdgeChanges:w,onDelete:v,onBeforeDelete:N}=t.getState(),{nodes:k,edges:C}=await lq({nodesToRemove:p,edgesToRemove:h,nodes:m,edges:g,onBeforeDelete:N}),E=C.length>0,P=k.length>0;if(E){const I=C.map(eh);x?.(C),w(I)}if(P){const I=k.map(eh);b?.(k),y(I)}return(P||E)&&v?.({nodes:k,edges:C}),{deletedNodes:k,deletedEdges:C}},getIntersectingNodes:(p,h=!0,m)=>{const g=_f(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=Lr(x?y:w),N=Do(v,b);return h&&N>0||N>=v.width*v.height||N>=b.width*b.height}):[]},isNodeIntersecting:(p,h,m=!0)=>{const b=_f(p)?p:c(p);if(!b)return!1;const x=Do(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 oq(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??pq();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:h}),n.nodeQueue.push(m=>[...m]),h.promise}}},[]);return Q(()=>({...s,...e,viewportInitialized:r}),[r])}const rh=e=>e.selected,UU=typeof window<"u"?window:void 0;function QU({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Ve(),{deleteElements:r}=nu(),s=To(e,{actInsideInputWithModifier:!1}),a=To(t,{target:UU});Y(()=>{if(s){const{edges:i,nodes:l}=n.getState();r({nodes:l.filter(rh),edges:i.filter(rh)}),n.setState({nodesSelectionActive:!1})}},[s]),Y(()=>{n.setState({multiSelectionActive:a})},[a])}function GU(e){const t=Ve();Y(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const r=Yd(e.current);(r.height===0||r.width===0)&&t.getState().onError?.("004",Zt.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 ai={position:"absolute",width:"100%",height:"100%",top:0,left:0},KU=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function WU({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:a=Kn.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=Ve(),C=ne(null),{userSelectionActive:E,lib:P,connectionInProgress:I}=$e(KU,je),z=To(h),A=ne();GU(C);const O=q(R=>{y?.({x:R[0],y:R[1],zoom:R[2]}),w||k.setState({transform:R})},[y,w]);return Y(()=>{if(C.current){A.current=Wq({domNode:C.current,minZoom:f,maxZoom:p,translateExtent:d,viewport:c,onDraggingChange:L=>k.setState(T=>T.paneDragging===L?T:{paneDragging:L}),onPanZoomStart:(L,T)=>{const{onViewportChangeStart:B,onMoveStart:F}=k.getState();F?.(L,T),B?.(T)},onPanZoom:(L,T)=>{const{onViewportChange:B,onMove:F}=k.getState();F?.(L,T),B?.(T)},onPanZoomEnd:(L,T)=>{const{onViewportChangeEnd:B,onMoveEnd:F}=k.getState();F?.(L,T),B?.(T)}});const{x:R,y:M,zoom:D}=A.current.getViewport();return k.setState({panZoom:A.current,transform:[R,M,D],domNode:C.current.closest(".react-flow")}),()=>{A.current?.destroy()}}},[]),Y(()=>{A.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:a,zoomOnDoubleClick:i,panOnDrag:l,zoomActivationKeyPressed:z,preventScrolling:m,noPanClassName:x,userSelectionActive:E,noWheelClassName:b,lib:P,onTransformChange:O,connectionInProgress:I,selectionOnDrag:N,paneClickDistance:v})},[e,t,n,r,s,a,i,l,z,m,x,E,b,P,O,I,N,v]),o("div",{className:"react-flow__renderer",ref:C,style:ai,children:g})}const YU=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function ZU(){const{userSelectionActive:e,userSelectionRect:t}=$e(YU,je);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 sl=(e,t)=>n=>{n.target===t.current&&e?.(n)},XU=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function JU({isSelecting:e,selectionKeyPressed:t,selectionMode:n=$o.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=Ve(),{userSelectionActive:x,elementsSelectable:y,dragging:w,connectionInProgress:v}=$e(XU,je),N=y&&(e||x),k=ne(null),C=ne(),E=ne(new Set),P=ne(new Set),I=ne(!1),z=B=>{if(I.current||v){I.current=!1;return}c?.(B),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},A=B=>{if(Array.isArray(r)&&r?.includes(2)){B.preventDefault();return}d?.(B)},O=f?B=>f(B):void 0,R=B=>{I.current&&(B.stopPropagation(),I.current=!1)},M=B=>{const{domNode:F}=b.getState();if(C.current=F?.getBoundingClientRect(),!C.current)return;const j=B.target===k.current;if(!j&&!!B.target.closest(".nokey")||!e||!(a&&j||t)||B.button!==0||!B.isPrimary)return;B.target?.setPointerCapture?.(B.pointerId),I.current=!1;const{x:V,y:G}=Lt(B.nativeEvent,C.current);b.setState({userSelectionRect:{width:0,height:0,startX:V,startY:G,x:V,y:G}}),j||(B.stopPropagation(),B.preventDefault())},D=B=>{const{userSelectionRect:F,transform:j,nodeLookup:H,edgeLookup:$,connectionLookup:V,triggerNodeChanges:G,triggerEdgeChanges:Z,defaultEdgeOptions:oe,resetSelectedElements:te}=b.getState();if(!C.current||!F)return;const{x:X,y:re}=Lt(B.nativeEvent,C.current),{startX:be,startY:J}=F;if(!I.current){const ge=t?0:s;if(Math.hypot(X-be,re-J)<=ge)return;te(),i?.(B)}I.current=!0;const K={startX:be,startY:J,x:X<be?X:be,y:re<J?re:J,width:Math.abs(X-be),height:Math.abs(re-J)},ee=E.current,ae=P.current;E.current=new Set(Kd(H,K,j,n===$o.Partial,!0).map(ge=>ge.id)),P.current=new Set;const fe=oe?.selectable??!0;for(const ge of E.current){const U=V.get(ge);if(U)for(const{edgeId:ie}of U.values()){const ue=$.get(ie);ue&&(ue.selectable??fe)&&P.current.add(ie)}}if(!$f(ee,E.current)){const ge=wr(H,E.current,!0);G(ge)}if(!$f(ae,P.current)){const ge=wr($,P.current);Z(ge)}b.setState({userSelectionRect:K,userSelectionActive:!0,nodesSelectionActive:!1})},L=B=>{B.button===0&&(B.target?.releasePointerCapture?.(B.pointerId),!x&&B.target===k.current&&b.getState().userSelectionRect&&z?.(B),b.setState({userSelectionActive:!1,userSelectionRect:null}),I.current&&(l?.(B),b.setState({nodesSelectionActive:E.current.size>0})))},T=r===!0||Array.isArray(r)&&r.includes(0);return u("div",{className:Qe(["react-flow__pane",{draggable:T,dragging:w,selection:e}]),onClick:N?void 0:sl(z,k),onContextMenu:sl(A,k),onWheel:sl(O,k),onPointerEnter:N?void 0:p,onPointerMove:N?D:h,onPointerUp:N?L:void 0,onPointerDownCapture:N?M:void 0,onClickCapture:N?R:void 0,onPointerLeave:m,ref:k,style:ai,children:[g,o(ZU,{})]})}function lc({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",Zt.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&i)&&(a({nodes:[d],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):s([e])}function M1({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:a,nodeClickDistance:i}){const l=Ve(),[c,d]=_(!1),f=ne();return Y(()=>{f.current=Tq({getStoreItems:()=>l.getState(),onNodeMouseDown:p=>{lc({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 eQ=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function E1(){const e=Ve();return q(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:a,nodesDraggable:i,onError:l,updateNodePositions:c,nodeLookup:d,nodeOrigin:f}=e.getState(),p=new Map,h=eQ(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=ts(w,a));const{position:v,positionAbsolute:N}=Qv({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 ru=Be(null),tQ=ru.Provider;ru.Consumer;const I1=()=>ve(ru),nQ=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),rQ=(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 oQ({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=Ve(),y=I1(),{connectOnClick:w,noPanClassName:v,rfId:N}=$e(nQ,je),{connectingFrom:k,connectingTo:C,clickConnecting:E,isPossibleEndHandle:P,connectionInProcess:I,clickConnectionInProcess:z,valid:A}=$e(rQ(y,g,e),je);y||x.getState().onError?.("010",Zt.error010());const O=D=>{const{defaultEdgeOptions:L,onConnect:T,hasDefaultEdges:B}=x.getState(),F={...L,...D};if(B){const{edges:j,setEdges:H}=x.getState();H(yq(F,j))}T?.(F),l?.(F)},R=D=>{if(!y)return;const L=e1(D.nativeEvent);if(s&&(L&&D.button===0||!L)){const T=x.getState();ac.onPointerDown(D.nativeEvent,{handleDomNode:D.currentTarget,autoPanOnConnect:T.autoPanOnConnect,connectionMode:T.connectionMode,connectionRadius:T.connectionRadius,domNode:T.domNode,nodeLookup:T.nodeLookup,lib:T.lib,isTarget:b,handleId:g,nodeId:y,flowId:T.rfId,panBy:T.panBy,cancelConnection:T.cancelConnection,onConnectStart:T.onConnectStart,onConnectEnd:(...B)=>x.getState().onConnectEnd?.(...B),updateConnection:T.updateConnection,onConnect:O,isValidConnection:n||((...B)=>x.getState().isValidConnection?.(...B)??!0),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:T.autoPanSpeed,dragThreshold:T.connectionDragThreshold})}L?f?.(D):p?.(D)},M=D=>{const{onClickConnectStart:L,onClickConnectEnd:T,connectionClickStartHandle:B,connectionMode:F,isValidConnection:j,lib:H,rfId:$,nodeLookup:V,connection:G}=x.getState();if(!y||!B&&!s)return;if(!B){L?.(D.nativeEvent,{nodeId:y,handleId:g,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const Z=Xv(D.target),oe=n||j,{connection:te,isValid:X}=ac.isValid(D.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:F,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:oe,flowId:$,doc:Z,lib:H,nodeLookup:V});X&&te&&O(te);const re=structuredClone(G);delete re.inProgress,re.toPosition=re.toHandle?re.toHandle.position:null,T?.(D,re),x.setState({connectionClickStartHandle:null})};return o("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${N}-${y}-${g}-${e}`,className: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:C,valid:A,connectionindicator:r&&(!I||P)&&(I||z?a:s)}]),onMouseDown:R,onTouchStart:R,onClick:w?M:void 0,ref:m,...h,children:c})}const An=He(S1(oQ));function sQ({data:e,isConnectable:t,sourcePosition:n=we.Bottom}){return u(me,{children:[e?.label,o(An,{type:"source",position:n,isConnectable:t})]})}function aQ({data:e,isConnectable:t,targetPosition:n=we.Top,sourcePosition:r=we.Bottom}){return u(me,{children:[o(An,{type:"target",position:n,isConnectable:t}),e?.label,o(An,{type:"source",position:r,isConnectable:t})]})}function iQ(){return null}function lQ({data:e,isConnectable:t,targetPosition:n=we.Top}){return u(me,{children:[o(An,{type:"target",position:n,isConnectable:t}),e?.label]})}const ga={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},oh={input:sQ,default:aQ,output:lQ,group:iQ};function cQ(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 dQ=e=>{const{width:t,height:n,x:r,y:s}=es(e.nodeLookup,{filter:a=>!!a.selected});return{width:Dt(t)?t:null,height:Dt(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 uQ({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Ve(),{width:s,height:a,transformString:i,userSelectionActive:l}=$e(dQ,je),c=E1(),d=ne(null);Y(()=>{n||d.current?.focus({preventScroll:!0})},[n]);const f=!l&&s!==null&&a!==null;if(M1({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(ga,m.key)&&(m.preventDefault(),c({direction:ga[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 sh=typeof window<"u"?window:void 0,pQ=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function A1({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:C,zoomOnDoubleClick:E,panOnDrag:P,defaultViewport:I,translateExtent:z,minZoom:A,maxZoom:O,preventScrolling:R,onSelectionContextMenu:M,noWheelClassName:D,noPanClassName:L,disableKeyboardA11y:T,onViewportChange:B,isControlledViewport:F}){const{nodesSelectionActive:j,userSelectionActive:H}=$e(pQ,je),$=To(d,{target:sh}),V=To(b,{target:sh}),G=V||P,Z=V||N,oe=f&&G!==!0,te=$||H||oe;return QU({deleteKeyCode:c,multiSelectionKeyCode:g}),o(WU,{onPaneContextMenu:a,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:v,panOnScroll:Z,panOnScrollSpeed:k,panOnScrollMode:C,zoomOnDoubleClick:E,panOnDrag:!$&&G,defaultViewport:I,translateExtent:z,minZoom:A,maxZoom:O,zoomActivationKeyCode:x,preventScrolling:R,noWheelClassName:D,noPanClassName:L,onViewportChange:B,isControlledViewport:F,paneClickDistance:l,selectionOnDrag:oe,children:u(JU,{onSelectionStart:h,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:i,panOnDrag:G,isSelecting:!!te,selectionMode:p,selectionKeyPressed:$,paneClickDistance:l,selectionOnDrag:oe,children:[e,j&&o(uQ,{onSelectionContextMenu:M,noPanClassName:L,disableKeyboardA11y:T})]})})}A1.displayName="FlowRenderer";const fQ=He(A1),hQ=e=>t=>e?Kd(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 mQ(e){return $e(q(hQ(e),[e]),je)}const gQ=e=>e.updateNodeInternals;function bQ(){const e=$e(gQ),[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 xQ({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=Ve(),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 yQ({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}=$e(X=>{const re=X.nodeLookup.get(e),be=X.parentLookup.has(e);return{node:re,internals:re.internals,isParent:be}},je);let C=v.type||"default",E=x?.[C]||oh[C];E===void 0&&(w?.("003",Zt.error003(C)),C="default",E=x?.default||oh.default);const P=!!(v.draggable||l&&typeof v.draggable>"u"),I=!!(v.selectable||c&&typeof v.selectable>"u"),z=!!(v.connectable||d&&typeof v.connectable>"u"),A=!!(v.focusable||f&&typeof v.focusable>"u"),O=Ve(),R=Yv(v),M=xQ({node:v,nodeType:C,hasDimensions:R,resizeObserver:p}),D=M1({nodeRef:M,disabled:v.hidden||!P,noDragClassName:h,handleSelector:v.dragHandle,nodeId:e,isSelectable:I,nodeClickDistance:y}),L=E1();if(v.hidden)return null;const T=bn(v),B=cQ(v),F=I||P||t||n||r||s,j=n?X=>n(X,{...N.userNode}):void 0,H=r?X=>r(X,{...N.userNode}):void 0,$=s?X=>s(X,{...N.userNode}):void 0,V=a?X=>a(X,{...N.userNode}):void 0,G=i?X=>i(X,{...N.userNode}):void 0,Z=X=>{const{selectNodesOnDrag:re,nodeDragThreshold:be}=O.getState();I&&(!re||!P||be>0)&&lc({id:e,store:O,nodeRef:M}),t&&t(X,{...N.userNode})},oe=X=>{if(!(Jv(X.nativeEvent)||g)){if(jv.includes(X.key)&&I){const re=X.key==="Escape";lc({id:e,store:O,unselect:re,nodeRef:M})}else if(P&&v.selected&&Object.prototype.hasOwnProperty.call(ga,X.key)){X.preventDefault();const{ariaLabelConfig:re}=O.getState();O.setState({ariaLiveMessage:re["node.a11yDescription.ariaLiveMessage"]({direction:X.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),L({direction:ga[X.key],factor:X.shiftKey?4:1})}}},te=()=>{if(g||!M.current?.matches(":focus-visible"))return;const{transform:X,width:re,height:be,autoPanOnNodeFocus:J,setCenter:K}=O.getState();if(!J)return;Kd(new Map([[e,v]]),{x:0,y:0,width:re,height:be},X,!0).length>0||K(v.position.x+T.width/2,v.position.y+T.height/2,{zoom:X[2]})};return o("div",{className:Qe(["react-flow__node",`react-flow__node-${C}`,{[m]:P},v.className,{selected:v.selected,selectable:I,parent:k,draggable:P,dragging:D}]),ref:M,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:F?"all":"none",visibility:R?"visible":"hidden",...v.style,...B},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:j,onMouseMove:H,onMouseLeave:$,onContextMenu:V,onClick:Z,onDoubleClick:G,onKeyDown:A?oe:void 0,tabIndex:A?0:void 0,onFocus:A?te:void 0,role:v.ariaRole??(A?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${v1}-${b}`,"aria-label":v.ariaLabel,...v.domAttributes,children:o(tQ,{value:e,children:o(E,{id:e,data:v.data,type:C,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:v.selected??!1,selectable:I,draggable:P,deletable:v.deletable??!0,isConnectable:z,sourcePosition:v.sourcePosition,targetPosition:v.targetPosition,dragging:D,dragHandle:v.dragHandle,zIndex:N.z,parentId:v.parentId,...T})})})}var vQ=He(yQ);const wQ=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function P1(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:a}=$e(wQ,je),i=mQ(e.onlyRenderVisibleElements),l=bQ();return o("div",{className:"react-flow__nodes",style:ai,children:i.map(c=>o(vQ,{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))})}P1.displayName="NodeRenderer";const NQ=He(P1);function kQ(e){return $e(q(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&&gq({sourceNode:a,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),je)}const SQ=({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"})},CQ=({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"})},ah={[fa.Arrow]:SQ,[fa.ArrowClosed]:CQ};function MQ(e){const t=Ve();return Q(()=>Object.prototype.hasOwnProperty.call(ah,e)?ah[e]:(t.getState().onError?.("009",Zt.error009(e)),null),[e])}const EQ=({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=MQ(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},_1=({defaultColor:e,rfId:t})=>{const n=$e(a=>a.edges),r=$e(a=>a.defaultEdgeOptions),s=Q(()=>Sq(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(EQ,{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};_1.displayName="MarkerDefinitions";var IQ=He(_1);function $1({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}$1.displayName="EdgeText";const AQ=He($1);function ii({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&&Dt(t)&&Dt(n)?o(AQ,{x:t,y:n,label:r,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function ih({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 D1({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:r,targetY:s,targetPosition:a=we.Top}){const[i,l]=ih({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,d]=ih({pos:a,x1:r,y1:s,x2:e,y2:t}),[f,p,h,m]=t1({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:i,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${i},${l} ${c},${d} ${r},${s}`,f,p,h,m]}function L1(e){return He(({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]=D1({sourceX:n,sourceY:r,sourcePosition:i,targetX:s,targetY:a,targetPosition:l}),k=e.isInternal?void 0:t;return o(ii,{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 PQ=L1({isInternal:!1}),T1=L1({isInternal:!0});PQ.displayName="SimpleBezierEdge";T1.displayName="SimpleBezierEdgeInternal";function R1(e){return He(({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]=rc({sourceX:n,sourceY:r,sourcePosition:m,targetX:s,targetY:a,targetPosition:g,borderRadius:y?.borderRadius,offset:y?.offset,stepPosition:y?.stepPosition}),C=e.isInternal?void 0:t;return o(ii,{id:C,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 O1=R1({isInternal:!1}),B1=R1({isInternal:!0});O1.displayName="SmoothStepEdge";B1.displayName="SmoothStepEdgeInternal";function z1(e){return He(({id:t,...n})=>{const r=e.isInternal?void 0:t;return o(O1,{...n,id:r,pathOptions:Q(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const _Q=z1({isInternal:!1}),F1=z1({isInternal:!0});_Q.displayName="StepEdge";F1.displayName="StepEdgeInternal";function j1(e){return He(({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]=o1({sourceX:n,sourceY:r,targetX:s,targetY:a}),v=e.isInternal?void 0:t;return o(ii,{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 $Q=j1({isInternal:!1}),H1=j1({isInternal:!0});$Q.displayName="StraightEdge";H1.displayName="StraightEdgeInternal";function V1(e){return He(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:a,sourcePosition:i=we.Bottom,targetPosition:l=we.Top,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:x,pathOptions:y,interactionWidth:w})=>{const[v,N,k]=n1({sourceX:n,sourceY:r,sourcePosition:i,targetX:s,targetY:a,targetPosition:l,curvature:y?.curvature}),C=e.isInternal?void 0:t;return o(ii,{id:C,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 DQ=V1({isInternal:!1}),q1=V1({isInternal:!0});DQ.displayName="BezierEdge";q1.displayName="BezierEdgeInternal";const lh={default:q1,straight:H1,step:F1,smoothstep:B1,simplebezier:T1},ch={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},LQ=(e,t,n)=>n===we.Left?e-t:n===we.Right?e+t:e,TQ=(e,t,n)=>n===we.Top?e-t:n===we.Bottom?e+t:e,dh="react-flow__edgeupdater";function uh({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([dh,`${dh}-${l}`]),cx:LQ(t,r,e),cy:TQ(n,r,e),r,stroke:"transparent",fill:"transparent"})}function RQ({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=Ve(),b=(N,k)=>{if(N.button!==0)return;const{autoPanOnConnect:C,domNode:E,connectionMode:P,connectionRadius:I,lib:z,onConnectStart:A,cancelConnection:O,nodeLookup:R,rfId:M,panBy:D,updateConnection:L}=g.getState(),T=k.type==="target",B=(H,$)=>{h(!1),p?.(H,n,k.type,$)},F=H=>d?.(n,H),j=(H,$)=>{h(!0),f?.(N,n,k.type),A?.(H,$)};ac.onPointerDown(N.nativeEvent,{autoPanOnConnect:C,connectionMode:P,connectionRadius:I,domNode:E,handleId:k.id,nodeId:k.nodeId,nodeLookup:R,isTarget:T,edgeUpdaterType:k.type,lib:z,flowId:M,cancelConnection:O,panBy:D,isValidConnection:(...H)=>g.getState().isValidConnection?.(...H)??!0,onConnect:F,onConnectStart:j,onConnectEnd:(...H)=>g.getState().onConnectEnd?.(...H),onReconnectEnd:B,updateConnection:L,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},x=N=>b(N,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=N=>b(N,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),w=()=>m(!0),v=()=>m(!1);return u(me,{children:[(e===!0||e==="source")&&o(uh,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:x,onMouseEnter:w,onMouseOut:v,type:"source"}),(e===!0||e==="target")&&o(uh,{position:c,centerX:a,centerY:i,radius:t,onMouseDown:y,onMouseEnter:w,onMouseOut:v,type:"target"})]})}function OQ({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=$e(K=>K.edgeLookup.get(e));const N=$e(K=>K.defaultEdgeOptions);v=N?{...N,...v}:v;let k=v.type||"default",C=b?.[k]||lh[k];C===void 0&&(y?.("011",Zt.error011(k)),k="default",C=b?.default||lh.default);const E=!!(v.focusable||t&&typeof v.focusable>"u"),P=typeof p<"u"&&(v.reconnectable||n&&typeof v.reconnectable>"u"),I=!!(v.selectable||r&&typeof v.selectable>"u"),z=ne(null),[A,O]=_(!1),[R,M]=_(!1),D=Ve(),{zIndex:L,sourceX:T,sourceY:B,targetX:F,targetY:j,sourcePosition:H,targetPosition:$}=$e(q(K=>{const ee=K.nodeLookup.get(v.source),ae=K.nodeLookup.get(v.target);if(!ee||!ae)return{zIndex:v.zIndex,...ch};const fe=kq({id:e,sourceNode:ee,targetNode:ae,sourceHandle:v.sourceHandle||null,targetHandle:v.targetHandle||null,connectionMode:K.connectionMode,onError:y});return{zIndex:mq({selected:v.selected,zIndex:v.zIndex,sourceNode:ee,targetNode:ae,elevateOnSelect:K.elevateEdgesOnSelect,zIndexMode:K.zIndexMode}),...fe||ch}},[v.source,v.target,v.sourceHandle,v.targetHandle,v.selected,v.zIndex]),je),V=Q(()=>v.markerStart?`url('#${oc(v.markerStart,g)}')`:void 0,[v.markerStart,g]),G=Q(()=>v.markerEnd?`url('#${oc(v.markerEnd,g)}')`:void 0,[v.markerEnd,g]);if(v.hidden||T===null||B===null||F===null||j===null)return null;const Z=K=>{const{addSelectedEdges:ee,unselectNodesAndEdges:ae,multiSelectionActive:fe}=D.getState();I&&(D.setState({nodesSelectionActive:!1}),v.selected&&fe?(ae({nodes:[],edges:[v]}),z.current?.blur()):ee([e])),s&&s(K,v)},oe=a?K=>{a(K,{...v})}:void 0,te=i?K=>{i(K,{...v})}:void 0,X=l?K=>{l(K,{...v})}:void 0,re=c?K=>{c(K,{...v})}:void 0,be=d?K=>{d(K,{...v})}:void 0,J=K=>{if(!w&&jv.includes(K.key)&&I){const{unselectNodesAndEdges:ee,addSelectedEdges:ae}=D.getState();K.key==="Escape"?(z.current?.blur(),ee({edges:[v]})):ae([e])}};return o("svg",{style:{zIndex:L},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:A,selectable:I}]),onClick:Z,onDoubleClick:oe,onContextMenu:te,onMouseEnter:X,onMouseMove:re,onMouseLeave:be,onKeyDown:E?J: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?`${w1}-${g}`:void 0,ref:z,...v.domAttributes,children:[!R&&o(C,{id:e,source:v.source,target:v.target,type:v.type,selected:v.selected,animated:v.animated,selectable:I,deletable:v.deletable??!0,label:v.label,labelStyle:v.labelStyle,labelShowBg:v.labelShowBg,labelBgStyle:v.labelBgStyle,labelBgPadding:v.labelBgPadding,labelBgBorderRadius:v.labelBgBorderRadius,sourceX:T,sourceY:B,targetX:F,targetY:j,sourcePosition:H,targetPosition:$,data:v.data,style:v.style,sourceHandleId:v.sourceHandle,targetHandleId:v.targetHandle,markerStart:V,markerEnd:G,pathOptions:"pathOptions"in v?v.pathOptions:void 0,interactionWidth:v.interactionWidth}),P&&o(RQ,{edge:v,isReconnectable:P,reconnectRadius:f,onReconnect:p,onReconnectStart:h,onReconnectEnd:m,sourceX:T,sourceY:B,targetX:F,targetY:j,sourcePosition:H,targetPosition:$,setUpdateHover:O,setReconnecting:M})]})})}var BQ=He(OQ);const zQ=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function U1({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}=$e(zQ,je),N=kQ(t);return u("div",{className:"react-flow__edges",children:[o(IQ,{defaultColor:e,rfId:n}),N.map(k=>o(BQ,{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))]})}U1.displayName="EdgeRenderer";const FQ=He(U1),jQ=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function HQ({children:e}){const t=$e(jQ);return o("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function VQ(e){const t=nu(),n=ne(!1);Y(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const qQ=e=>e.panZoom?.syncViewport;function UQ(e){const t=$e(qQ),n=Ve();return Y(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function QQ(e){return e.connection.inProgress?{...e.connection,to:ns(e.connection.to,e.transform)}:{...e.connection}}function GQ(e){return QQ}function KQ(e){const t=GQ();return $e(t,je)}const WQ=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function YQ({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:a,height:i,isValid:l,inProgress:c}=$e(WQ,je);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",qv(l)]),children:o(Q1,{style:t,type:n,CustomComponent:r,isValid:l})})})}const Q1=({style:e,type:t=Nn.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}=KQ();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:qv(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 Nn.Bezier:[g]=n1(b);break;case Nn.SimpleBezier:[g]=D1(b);break;case Nn.Step:[g]=rc({...b,borderRadius:0});break;case Nn.SmoothStep:[g]=rc(b);break;default:[g]=o1(b)}return o("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};Q1.displayName="ConnectionLine";const ZQ={};function ph(e=ZQ){ne(e),Ve(),Y(()=>{},[e])}function XQ(){Ve(),ne(!1),Y(()=>{},[])}function G1({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:C,zoomActivationKeyCode:E,deleteKeyCode:P,onlyRenderVisibleElements:I,elementsSelectable:z,defaultViewport:A,translateExtent:O,minZoom:R,maxZoom:M,preventScrolling:D,defaultMarkerColor:L,zoomOnScroll:T,zoomOnPinch:B,panOnScroll:F,panOnScrollSpeed:j,panOnScrollMode:H,zoomOnDoubleClick:$,panOnDrag:V,onPaneClick:G,onPaneMouseEnter:Z,onPaneMouseMove:oe,onPaneMouseLeave:te,onPaneScroll:X,onPaneContextMenu:re,paneClickDistance:be,nodeClickDistance:J,onEdgeContextMenu:K,onEdgeMouseEnter:ee,onEdgeMouseMove:ae,onEdgeMouseLeave:fe,reconnectRadius:ge,onReconnect:U,onReconnectStart:ie,onReconnectEnd:ue,noDragClassName:de,noWheelClassName:ce,noPanClassName:Ce,disableKeyboardA11y:pe,nodeExtent:_e,rfId:Ae,viewport:We,onViewportChange:st}){return ph(e),ph(t),XQ(),VQ(n),UQ(We),o(fQ,{onPaneClick:G,onPaneMouseEnter:Z,onPaneMouseMove:oe,onPaneMouseLeave:te,onPaneContextMenu:re,onPaneScroll:X,paneClickDistance:be,deleteKeyCode:P,selectionKeyCode:w,selectionOnDrag:v,selectionMode:N,onSelectionStart:h,onSelectionEnd:m,multiSelectionKeyCode:k,panActivationKeyCode:C,zoomActivationKeyCode:E,elementsSelectable:z,zoomOnScroll:T,zoomOnPinch:B,zoomOnDoubleClick:$,panOnScroll:F,panOnScrollSpeed:j,panOnScrollMode:H,panOnDrag:V,defaultViewport:A,translateExtent:O,minZoom:R,maxZoom:M,onSelectionContextMenu:p,preventScrolling:D,noDragClassName:de,noWheelClassName:ce,noPanClassName:Ce,disableKeyboardA11y:pe,onViewportChange:st,isControlledViewport:!!We,children:u(HQ,{children:[o(FQ,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:i,onReconnect:U,onReconnectStart:ie,onReconnectEnd:ue,onlyRenderVisibleElements:I,onEdgeContextMenu:K,onEdgeMouseEnter:ee,onEdgeMouseMove:ae,onEdgeMouseLeave:fe,reconnectRadius:ge,defaultMarkerColor:L,noPanClassName:Ce,disableKeyboardA11y:pe,rfId:Ae}),o(YQ,{style:b,type:g,component:x,containerStyle:y}),o("div",{className:"react-flow__edgelabel-renderer"}),o(NQ,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,nodeClickDistance:J,onlyRenderVisibleElements:I,noPanClassName:Ce,noDragClassName:de,disableKeyboardA11y:pe,nodeExtent:_e,rfId:Ae}),o("div",{className:"react-flow__viewport-portal"})]})})}G1.displayName="GraphView";const JQ=He(G1),fh=({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??_o;i1(b,x,y);const{nodesInitialized:k}=sc(w,m,g,{nodeOrigin:v,nodeExtent:N,zIndexMode:h});let C=[0,0,1];if(i&&s&&a){const E=es(m,{filter:A=>!!((A.width||A.initialWidth)&&(A.height||A.initialHeight))}),{x:P,y:I,zoom:z}=Wd(E,s,a,c,d,l?.padding??.1);C=[P,I,z]}return{rfId:"1",width:s??0,height:a??0,transform:C,nodes:w,nodesInitialized:k,nodeLookup:m,parentLookup:g,edges:y,edgeLookup:x,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:d,translateExtent:_o,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:{...Vv},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:cq,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Hv,zIndexMode:h,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},eG=({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})=>bU((m,g)=>{async function b(){const{nodeLookup:x,panZoom:y,fitViewOptions:w,fitViewResolver:v,width:N,height:k,minZoom:C,maxZoom:E}=g();y&&(await iq({nodes:x,width:N,height:k,panZoom:y,minZoom:C,maxZoom:E},w),v?.resolve(!0),m({fitViewResolver:null}))}return{...fh({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:C,nodesSelectionActive:E}=g(),{nodesInitialized:P,hasSelectedNodes:I}=sc(x,y,w,{nodeOrigin:v,nodeExtent:p,elevateNodesOnSelect:N,checkEquality:!0,zIndexMode:C}),z=E&&I;k&&P?(b(),m({nodes:x,nodesInitialized:P,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:z})):m({nodes:x,nodesInitialized:P,nodesSelectionActive:z})},setEdges:x=>{const{connectionLookup:y,edgeLookup:w}=g();i1(y,w,x),m({edges:x})},setDefaultNodesAndEdges:(x,y)=>{if(x){const{setNodes:w}=g();w(x),m({hasDefaultNodes:!0})}if(y){const{setEdges:w}=g();w(y),m({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:y,nodeLookup:w,parentLookup:v,domNode:N,nodeOrigin:k,nodeExtent:C,debug:E,fitViewQueued:P,zIndexMode:I}=g(),{changes:z,updatedInternals:A}=_q(x,w,v,N,k,C,I);A&&(Eq(w,v,{nodeOrigin:k,nodeExtent:C,zIndexMode:I}),P?(b(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),z?.length>0&&(E&&console.log("React Flow: trigger node changes",z),y?.(z)))},updateNodePositions:(x,y=!1)=>{const w=[];let v=[];const{nodeLookup:N,triggerNodeChanges:k,connection:C,updateConnection:E,onNodesChangeMiddlewareMap:P}=g();for(const[I,z]of x){const A=N.get(I),O=!!(A?.expandParent&&A?.parentId&&z?.position),R={id:I,type:"position",position:O?{x:Math.max(0,z.position.x),y:Math.max(0,z.position.y)}:z.position,dragging:y};if(A&&C.inProgress&&C.fromNode.id===A.id){const M=sr(A,C.fromHandle,we.Left,!0);E({...C,from:M})}O&&A.parentId&&w.push({id:I,parentId:A.parentId,rect:{...z.internals.positionAbsolute,width:z.measured.width??0,height:z.measured.height??0}}),v.push(R)}if(w.length>0){const{parentLookup:I,nodeOrigin:z}=g(),A=tu(w,N,I,z);v.push(...A)}for(const I of P.values())v=I(v);k(v)},triggerNodeChanges:x=>{const{onNodesChange:y,setNodes:w,nodes:v,hasDefaultNodes:N,debug:k}=g();if(x?.length){if(N){const C=BU(x,v);w(C)}k&&console.log("React Flow: trigger node changes",x),y?.(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:y,setEdges:w,edges:v,hasDefaultEdges:N,debug:k}=g();if(x?.length){if(N){const C=zU(x,v);w(C)}k&&console.log("React Flow: trigger edge changes",x),y?.(x)}},addSelectedNodes:x=>{const{multiSelectionActive:y,edgeLookup:w,nodeLookup:v,triggerNodeChanges:N,triggerEdgeChanges:k}=g();if(y){const C=x.map(E=>Hn(E,!0));N(C);return}N(wr(v,new Set([...x]),!0)),k(wr(w))},addSelectedEdges:x=>{const{multiSelectionActive:y,edgeLookup:w,nodeLookup:v,triggerNodeChanges:N,triggerEdgeChanges:k}=g();if(y){const C=x.map(E=>Hn(E,!0));k(C);return}k(wr(w,new Set([...x]))),N(wr(v,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:y}={})=>{const{edges:w,nodes:v,nodeLookup:N,triggerNodeChanges:k,triggerEdgeChanges:C}=g(),E=x||v,P=y||w,I=[];for(const A of E){if(!A.selected)continue;const O=N.get(A.id);O&&(O.selected=!1),I.push(Hn(A.id,!1))}const z=[];for(const A of P)A.selected&&z.push(Hn(A.id,!1));k(I),C(z)},setMinZoom:x=>{const{panZoom:y,maxZoom:w}=g();y?.setScaleExtent([x,w]),m({minZoom:x})},setMaxZoom:x=>{const{panZoom:y,minZoom:w}=g();y?.setScaleExtent([w,x]),m({maxZoom:x})},setTranslateExtent:x=>{g().panZoom?.setTranslateExtent(x),m({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:y,triggerNodeChanges:w,triggerEdgeChanges:v,elementsSelectable:N}=g();if(!N)return;const k=y.reduce((E,P)=>P.selected?[...E,Hn(P.id,!1)]:E,[]),C=x.reduce((E,P)=>P.selected?[...E,Hn(P.id,!1)]:E,[]);w(k),v(C)},setNodeExtent:x=>{const{nodes:y,nodeLookup:w,parentLookup:v,nodeOrigin:N,elevateNodesOnSelect:k,nodeExtent:C,zIndexMode:E}=g();x[0][0]===C[0][0]&&x[0][1]===C[0][1]&&x[1][0]===C[1][0]&&x[1][1]===C[1][1]||(sc(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 $q({delta:x,panZoom:N,transform:y,translateExtent:k,width:w,height:v})},setCenter:async(x,y,w)=>{const{width:v,height:N,maxZoom:k,panZoom:C}=g();if(!C)return Promise.resolve(!1);const E=typeof w?.zoom<"u"?w.zoom:k;return await C.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:{...Vv}})},updateConnection:x=>{m({connection:x})},reset:()=>m({...fh()})}},Object.is);function tG({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]=_(()=>eG({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(xU,{value:g,children:o(HU,{children:m})})}function nG({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(oi)?o(me,{children:e}):o(tG,{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 rG={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function oG({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:C,onNodeDragStart:E,onNodeDrag:P,onNodeDragStop:I,onNodesDelete:z,onEdgesDelete:A,onDelete:O,onSelectionChange:R,onSelectionDragStart:M,onSelectionDrag:D,onSelectionDragStop:L,onSelectionContextMenu:T,onSelectionStart:B,onSelectionEnd:F,onBeforeDelete:j,connectionMode:H,connectionLineType:$=Nn.Bezier,connectionLineStyle:V,connectionLineComponent:G,connectionLineContainerStyle:Z,deleteKeyCode:oe="Backspace",selectionKeyCode:te="Shift",selectionOnDrag:X=!1,selectionMode:re=$o.Full,panActivationKeyCode:be="Space",multiSelectionKeyCode:J=Lo()?"Meta":"Control",zoomActivationKeyCode:K=Lo()?"Meta":"Control",snapToGrid:ee,snapGrid:ae,onlyRenderVisibleElements:fe=!1,selectNodesOnDrag:ge,nodesDraggable:U,autoPanOnNodeFocus:ie,nodesConnectable:ue,nodesFocusable:de,nodeOrigin:ce=N1,edgesFocusable:Ce,edgesReconnectable:pe,elementsSelectable:_e=!0,defaultViewport:Ae=_U,minZoom:We=.5,maxZoom:st=2,translateExtent:mr=_o,preventScrolling:he=!0,nodeExtent:Pe,defaultMarkerColor:Te="#b1b1b7",zoomOnScroll:Re=!0,zoomOnPinch:Rn=!0,panOnScroll:On=!1,panOnScrollSpeed:Wr=.5,panOnScrollMode:Sw=Kn.Free,zoomOnDoubleClick:Cw=!0,panOnDrag:Mw=!0,onPaneClick:Ew,onPaneMouseEnter:Iw,onPaneMouseMove:Aw,onPaneMouseLeave:Pw,onPaneScroll:_w,onPaneContextMenu:$w,paneClickDistance:Dw=1,nodeClickDistance:Lw=0,children:Tw,onReconnect:Rw,onReconnectStart:Ow,onReconnectEnd:Bw,onEdgeContextMenu:zw,onEdgeDoubleClick:Fw,onEdgeMouseEnter:jw,onEdgeMouseMove:Hw,onEdgeMouseLeave:Vw,reconnectRadius:qw=10,onNodesChange:Uw,onEdgesChange:Qw,noDragClassName:Gw="nodrag",noWheelClassName:Kw="nowheel",noPanClassName:cu="nopan",fitView:du,fitViewOptions:uu,connectOnClick:Ww,attributionPosition:Yw,proOptions:Zw,defaultEdgeOptions:Xw,elevateNodesOnSelect:Jw=!0,elevateEdgesOnSelect:eN=!1,disableKeyboardA11y:pu=!1,autoPanOnConnect:tN,autoPanOnNodeDrag:nN,autoPanSpeed:rN,connectionRadius:oN,isValidConnection:sN,onError:aN,style:iN,id:fu,nodeDragThreshold:lN,connectionDragThreshold:cN,viewport:dN,onViewportChange:uN,width:pN,height:fN,colorMode:hN="light",debug:mN,onScroll:hu,ariaLabelConfig:gN,zIndexMode:mu="basic",...bN},xN){const di=fu||"1",yN=TU(hN),vN=q(gu=>{gu.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),hu?.(gu)},[hu]);return o("div",{"data-testid":"rf__wrapper",...bN,onScroll:vN,style:{...iN,...rG},ref:xN,className:Qe(["react-flow",s,yN]),id:fu,role:"application",children:u(nG,{nodes:e,edges:t,width:pN,height:fN,fitView:du,fitViewOptions:uu,minZoom:We,maxZoom:st,nodeOrigin:ce,nodeExtent:Pe,zIndexMode:mu,children:[o(LU,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:g,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:y,nodesDraggable:U,autoPanOnNodeFocus:ie,nodesConnectable:ue,nodesFocusable:de,edgesFocusable:Ce,edgesReconnectable:pe,elementsSelectable:_e,elevateNodesOnSelect:Jw,elevateEdgesOnSelect:eN,minZoom:We,maxZoom:st,nodeExtent:Pe,onNodesChange:Uw,onEdgesChange:Qw,snapToGrid:ee,snapGrid:ae,connectionMode:H,translateExtent:mr,connectOnClick:Ww,defaultEdgeOptions:Xw,fitView:du,fitViewOptions:uu,onNodesDelete:z,onEdgesDelete:A,onDelete:O,onNodeDragStart:E,onNodeDrag:P,onNodeDragStop:I,onSelectionDrag:D,onSelectionDragStart:M,onSelectionDragStop:L,onMove:f,onMoveStart:p,onMoveEnd:h,noPanClassName:cu,nodeOrigin:ce,rfId:di,autoPanOnConnect:tN,autoPanOnNodeDrag:nN,autoPanSpeed:rN,onError:aN,connectionRadius:oN,isValidConnection:sN,selectNodesOnDrag:ge,nodeDragThreshold:lN,connectionDragThreshold:cN,onBeforeDelete:j,debug:mN,ariaLabelConfig:gN,zIndexMode:mu}),o(JQ,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:w,onNodeMouseMove:v,onNodeMouseLeave:N,onNodeContextMenu:k,onNodeDoubleClick:C,nodeTypes:a,edgeTypes:i,connectionLineType:$,connectionLineStyle:V,connectionLineComponent:G,connectionLineContainerStyle:Z,selectionKeyCode:te,selectionOnDrag:X,selectionMode:re,deleteKeyCode:oe,multiSelectionKeyCode:J,panActivationKeyCode:be,zoomActivationKeyCode:K,onlyRenderVisibleElements:fe,defaultViewport:Ae,translateExtent:mr,minZoom:We,maxZoom:st,preventScrolling:he,zoomOnScroll:Re,zoomOnPinch:Rn,zoomOnDoubleClick:Cw,panOnScroll:On,panOnScrollSpeed:Wr,panOnScrollMode:Sw,panOnDrag:Mw,onPaneClick:Ew,onPaneMouseEnter:Iw,onPaneMouseMove:Aw,onPaneMouseLeave:Pw,onPaneScroll:_w,onPaneContextMenu:$w,paneClickDistance:Dw,nodeClickDistance:Lw,onSelectionContextMenu:T,onSelectionStart:B,onSelectionEnd:F,onReconnect:Rw,onReconnectStart:Ow,onReconnectEnd:Bw,onEdgeContextMenu:zw,onEdgeDoubleClick:Fw,onEdgeMouseEnter:jw,onEdgeMouseMove:Hw,onEdgeMouseLeave:Vw,reconnectRadius:qw,defaultMarkerColor:Te,noDragClassName:Gw,noWheelClassName:Kw,noPanClassName:cu,rfId:di,disableKeyboardA11y:pu,nodeExtent:Pe,viewport:dN,onViewportChange:uN}),o(PU,{onSelectionChange:R}),Tw,o(CU,{proOptions:Zw,position:Yw}),o(SU,{rfId:di,disableKeyboardA11y:pu})]})})}var sG=S1(oG);function aG({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 iG({radius:e,className:t}){return o("circle",{cx:e,cy:e,r:e,className:Qe(["react-flow__background-pattern","dots",t])})}var Cn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Cn||(Cn={}));const lG={[Cn.Dots]:1,[Cn.Lines]:1,[Cn.Cross]:6},cG=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function K1({id:e,variant:t=Cn.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}=$e(cG,je),g=r||lG[t],b=t===Cn.Dots,x=t===Cn.Cross,y=Array.isArray(n)?n:[n,n],w=[y[0]*h[2]||1,y[1]*h[2]||1],v=g*h[2],N=Array.isArray(a)?a:[a,a],k=x?[v,v]:w,C=[N[0]*h[2]||1+k[0]/2,N[1]*h[2]||1+k[1]/2],E=`${m}${e||""}`;return u("svg",{className:Qe(["react-flow__background",d]),style:{...c,...ai,"--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(-${C[0]},-${C[1]})`,children:b?o(iG,{radius:v/2,className:f}):o(aG,{dimensions:k,lineWidth:s,variant:t,className:f})}),o("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${E})`})]})}K1.displayName="Background";const dG=He(K1);function uG(){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 pG(){return o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:o("path",{d:"M0 0h32v4.2H0z"})})}function fG(){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 hG(){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 mG(){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 $s({children:e,className:t,...n}){return o("button",{type:"button",className:Qe(["react-flow__controls-button",t]),...n,children:e})}const gG=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function W1({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=Ve(),{isInteractive:b,minZoomReached:x,maxZoomReached:y,ariaLabelConfig:w}=$e(gG,je),{zoomIn:v,zoomOut:N,fitView:k}=nu(),C=()=>{v(),a?.()},E=()=>{N(),i?.()},P=()=>{k(s),l?.()},I=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),c?.(!b)};return u(si,{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($s,{onClick:C,className:"react-flow__controls-zoomin",title:w["controls.zoomIn.ariaLabel"],"aria-label":w["controls.zoomIn.ariaLabel"],disabled:y,children:o(uG,{})}),o($s,{onClick:E,className:"react-flow__controls-zoomout",title:w["controls.zoomOut.ariaLabel"],"aria-label":w["controls.zoomOut.ariaLabel"],disabled:x,children:o(pG,{})})]}),n&&o($s,{className:"react-flow__controls-fitview",onClick:P,title:w["controls.fitView.ariaLabel"],"aria-label":w["controls.fitView.ariaLabel"],children:o(fG,{})}),r&&o($s,{className:"react-flow__controls-interactive",onClick:I,title:w["controls.interactive.ariaLabel"],"aria-label":w["controls.interactive.ariaLabel"],children:b?o(mG,{}):o(hG,{})}),f]})}W1.displayName="Controls";const bG=He(W1);function xG({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 yG=He(xG),vG=e=>e.nodes.map(t=>t.id),al=e=>e instanceof Function?e:()=>e;function wG({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:a=yG,onClick:i}){const l=$e(vG,je),c=al(t),d=al(e),f=al(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return o(me,{children:l.map(h=>o(kG,{id:h,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:a,onClick:i,shapeRendering:p},h))})}function NG({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}=$e(g=>{const b=g.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const x=b.internals.userNode,{x:y,y:w}=b.internals.positionAbsolute,{width:v,height:N}=bn(x);return{node:x,x:y,y:w,width:v,height:N}},je);return!d||d.hidden||!Yv(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 kG=He(NG);var SG=He(wG);const CG=200,MG=150,EG=e=>!e.hidden,IG=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?Wv(es(e.nodeLookup,{filter:EG}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},AG="react-flow__minimap-desc";function Y1({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=Ve(),C=ne(null),{boundingRect:E,viewBB:P,rfId:I,panZoom:z,translateExtent:A,flowWidth:O,flowHeight:R,ariaLabelConfig:M}=$e(IG,je),D=e?.width??CG,L=e?.height??MG,T=E.width/D,B=E.height/L,F=Math.max(T,B),j=F*D,H=F*L,$=N*F,V=E.x-(j-E.width)/2-$,G=E.y-(H-E.height)/2-$,Z=j+$*2,oe=H+$*2,te=`${AG}-${I}`,X=ne(0),re=ne();X.current=F,Y(()=>{if(C.current&&z)return re.current=jq({domNode:C.current,panZoom:z,getTransform:()=>k.getState().transform,getViewScale:()=>X.current}),()=>{re.current?.destroy()}},[z]),Y(()=>{re.current?.update({translateExtent:A,width:O,height:R,inversePan:w,pannable:b,zoomStep:v,zoomable:x})},[b,x,w,v,A,O,R]);const be=m?ee=>{const[ae,fe]=re.current?.pointer(ee)||[0,0];m(ee,{x:ae,y:fe})}:void 0,J=g?q((ee,ae)=>{const fe=k.getState().nodeLookup.get(ae).internals.userNode;g(ee,fe)},[]):void 0,K=y??M["minimap.ariaLabel"];return o(si,{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*F:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof i=="number"?i:void 0},className:Qe(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:u("svg",{width:D,height:L,viewBox:`${V} ${G} ${Z} ${oe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":te,ref:C,onClick:be,children:[K&&o("title",{id:te,children:K}),o(SG,{onClick:J,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:s,nodeStrokeWidth:i,nodeComponent:l}),o("path",{className:"react-flow__minimap-mask",d:`M${V-$},${G-$}h${Z+$*2}v${oe+$*2}h${-Z-$*2}z
1133
- M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Y1.displayName="MiniMap";He(Y1);const PG=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,_G={[Rr.Line]:"right",[Rr.Handle]:"bottom-right"};function $G({nodeId:e,position:t,variant:n=Rr.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=I1(),v=typeof e=="string"?e:w,N=Ve(),k=ne(null),C=n===Rr.Handle,E=$e(q(PG(C&&m),[C,m]),je),P=ne(null),I=t??_G[n];Y(()=>{if(!(!k.current||!v))return P.current||(P.current=tU({domNode:k.current,nodeId:v,getStoreItems:()=>{const{nodeLookup:A,transform:O,snapGrid:R,snapToGrid:M,nodeOrigin:D,domNode:L}=N.getState();return{nodeLookup:A,transform:O,snapGrid:R,snapToGrid:M,nodeOrigin:D,paneDomNode:L}},onChange:(A,O)=>{const{triggerNodeChanges:R,nodeLookup:M,parentLookup:D,nodeOrigin:L}=N.getState(),T=[],B={x:A.x,y:A.y},F=M.get(v);if(F&&F.expandParent&&F.parentId){const j=F.origin??L,H=A.width??F.measured.width??0,$=A.height??F.measured.height??0,V={id:F.id,parentId:F.parentId,rect:{width:H,height:$,...Zv({x:A.x??F.position.x,y:A.y??F.position.y},{width:H,height:$},F.parentId,M,j)}},G=tu([V],M,D,L);T.push(...G),B.x=A.x?Math.max(j[0]*H,A.x):void 0,B.y=A.y?Math.max(j[1]*$,A.y):void 0}if(B.x!==void 0&&B.y!==void 0){const j={id:v,type:"position",position:{...B}};T.push(j)}if(A.width!==void 0&&A.height!==void 0){const H={id:v,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:A.width,height:A.height}};T.push(H)}for(const j of O){const H={...j,type:"position"};T.push(H)}R(T)},onEnd:({width:A,height:O})=>{const R={id:v,type:"dimensions",resizing:!1,dimensions:{width:A,height:O}};N.getState().triggerNodeChanges([R])}})),P.current.update({controlPosition:I,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:f},keepAspectRatio:p,resizeDirection:h,onResizeStart:b,onResize:x,onResizeEnd:y,shouldResize:g}),()=>{P.current?.destroy()}},[I,l,c,d,f,p,b,x,y,g]);const z=I.split("-");return o("div",{className:Qe(["react-flow__resize-control","nodrag",...z,n,r]),ref:k,style:{...s,scale:E,...i&&{[C?"backgroundColor":"borderColor"]:i}},children:a})}He($G);var Z1=Object.defineProperty,DG=(e,t,n)=>t in e?Z1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,LG=(e,t)=>{for(var n in t)Z1(e,n,{get:t[n],enumerable:!0})},TG=(e,t,n)=>DG(e,t+"",n),X1={};LG(X1,{Graph:()=>It,alg:()=>ou,json:()=>ew,version:()=>BG});var RG=Object.defineProperty,J1=(e,t)=>{for(var n in t)RG(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=io(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=OG(this._isDirected,s,a,i);return s=f.v,a=f.w,Object.freeze(f),this._edgeObjs[d]=f,hh(this._preds[a],s),hh(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?il(this._isDirected,e):io(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?il(this._isDirected,e):io(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?il(this._isDirected,e):io(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],mh(this._preds[i],a),mh(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 hh(e,t){e[t]?e[t]++:e[t]=1}function mh(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function io(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 OG(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 il(e,t){return io(e,t.v,t.w,t.name)}var BG="4.0.1",ew={};J1(ew,{read:()=>HG,write:()=>zG});function zG(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:FG(e),edges:jG(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function FG(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 jG(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 HG(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 ou={};J1(ou,{CycleException:()=>xa,bellmanFord:()=>tw,components:()=>UG,dijkstra:()=>ba,dijkstraAll:()=>KG,findCycles:()=>WG,floydWarshall:()=>ZG,isAcyclic:()=>JG,postorder:()=>tK,preorder:()=>nK,prim:()=>rK,shortestPaths:()=>oK,tarjan:()=>rw,topsort:()=>ow});var VG=()=>1;function tw(e,t,n,r){return qG(e,String(t),n||VG,r||function(s){return e.outEdges(s)})}function qG(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 UG(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 nw=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}},QG=()=>1;function ba(e,t,n,r){let s=function(a){return e.outEdges(a)};return GG(e,String(t),n||QG,r||s)}function GG(e,t,n,r){let s={},a=new nw,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 KG(e,t,n){return e.nodes().reduce(function(r,s){return r[s]=ba(e,s,t,n),r},{})}function rw(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 WG(e){return rw(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var YG=()=>1;function ZG(e,t,n){return XG(e,t||YG,n||function(r){return e.outEdges(r)})}function XG(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 xa=class extends Error{constructor(...e){super(...e)}};function ow(e){let t={},n={},r=[];function s(a){if(a in n)throw new xa;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 xa;return r}function JG(e){try{ow(e)}catch(t){if(t instanceof xa)return!1;throw t}return!0}function eK(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=sw(e,l,n==="post",i,a,r,s)}),s}function sw(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=sw(e,l,n,r,s,a,i)}),n&&(i=a(i,t))),i}function aw(e,t,n){return eK(e,t,n,function(r,s){return r.push(s),r},[])}function tK(e,t){return aw(e,t,"post")}function nK(e,t){return aw(e,t,"pre")}function rK(e,t){let n=new It,r={},s=new nw,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 oK(e,t,n,r){return sK(e,t,n,r??(s=>{let a=e.outEdges(s);return a??[]}))}function sK(e,t,n,r){if(n===void 0)return ba(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 tw(e,t,n,r)}return ba(e,t,n,r)}function Kr(e,t,n,r){let s=r;for(;e.hasNode(s);)s=su(r);return n.dummy=t,e.setNode(s,n),s}function aK(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 iw(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 gh(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 rs(e){let t=Ro(cw(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 iK(e){let t=e.nodes().map(r=>{let s=e.node(r).rank;return s===void 0?Number.MAX_VALUE:s}),n=Qt(Math.min,t);e.nodes().forEach(r=>{let s=e.node(r);Object.hasOwn(s,"rank")&&(s.rank-=n)})}function lK(e){let t=e.nodes().map(i=>e.node(i).rank).filter(i=>i!==void 0),n=Qt(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 bh(e,t,n,r){let s={width:0,height:0};return arguments.length>=4&&(s.rank=n,s.order=r),Kr(e,"border",s,t)}function cK(e,t=lw){let n=[];for(let r=0;r<e.length;r+=t){let s=e.slice(r,r+t);n.push(s)}return n}var lw=65535;function Qt(e,t){if(t.length>lw){let n=cK(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function cw(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return Qt(Math.max,t)}function dK(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function dw(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function uw(e,t){return t()}var uK=0;function su(e){let t=++uK;return e+(""+t)}function Ro(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 ya(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function li(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 pK(e,t){return e.reduce((n,r,s)=>(n[r]=t[s],n),{})}var ci="\0",fK="3.0.0",hK=class{constructor(){TG(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return xh(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&xh(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,mK)),n=n._prev;return"["+e.join(", ")+"]"}};function xh(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function mK(e,t){if(e!=="_next"&&e!=="_prev")return t}var gK=hK,bK=()=>1;function xK(e,t){if(e.nodeCount()<=1)return[];let n=vK(e,t||bK);return yK(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function yK(e,t,n){var r;let s=[],a=t[t.length-1],i=t[0],l;for(;e.nodeCount();){for(;l=i.dequeue();)ll(e,t,n,l);for(;l=a.dequeue();)ll(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(ll(e,t,n,l,!0)||[]);break}}}return s}function ll(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,cc(t,n,d)}),(e.outEdges(r.v)||[]).forEach(l=>{let c=e.edge(l),d=l.w,f=e.node(d);f.in-=c,cc(t,n,f)}),e.removeNode(r.v),i}function vK(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=wK(s+r+3).map(()=>new gK),i=r+1;return n.nodes().forEach(l=>{cc(a,i,n.node(l))}),{graph:n,buckets:a,zeroIdx:i}}function cc(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 wK(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function NK(e){(e.graph().acyclicer==="greedy"?xK(e,t(e)):kK(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,su("rev"))});function t(n){return r=>n.edge(r).weight}}function kK(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 SK(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 CK(e){e.graph().dummyChains=[],e.edges().forEach(t=>MK(e,t))}function MK(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=Kr(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 EK(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 au(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=Qt(Math.min,i);return l===Number.POSITIVE_INFINITY&&(l=0),s.rank=l}e.sources().forEach(n)}function Or(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var pw=IK;function IK(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(;AK(t,e)<s&&(a=PK(t,e),!!a);)i=t.hasNode(a.v)?Or(e,a):-Or(e,a),_K(t,e,i);return t}function AK(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)&&!Or(t,a)&&(e.setNode(l,{}),e.setEdge(r,l,{}),n(l))})}return e.nodes().forEach(n),e.nodeCount()}function PK(e,t){return t.edges().reduce((n,r)=>{let s=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(s=Or(t,r)),s<n[0]?[s,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function _K(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:$K,postorder:DK}=ou,LK=hr;hr.initLowLimValues=lu;hr.initCutValues=iu;hr.calcCutValue=fw;hr.leaveEdge=mw;hr.enterEdge=gw;hr.exchangeEdges=bw;function hr(e){e=aK(e),au(e);let t=pw(e);lu(t),iu(t,e);let n,r;for(;n=mw(t);)r=gw(t,e,n),bw(t,e,n,r)}function iu(e,t){let n=DK(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=fw(e,t,n)}function fw(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,OK(e,n,f)){let m=e.edge(n,f).cutvalue;i+=p?-m:m}}}),i}function lu(e,t){arguments.length<2&&(t=e.nodes()[0]),hw(e,{},1,t)}function hw(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=hw(e,t,n,c,r))}),i.low=a,i.lim=n++,s?i.parent=s:delete i.parent,n}function mw(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function gw(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===yh(e,e.node(d.v),l)&&c!==yh(e,e.node(d.w),l)).reduce((d,f)=>Or(t,f)<Or(t,d)?f:d)}function bw(e,t,n,r){let s=n.v,a=n.w;e.removeEdge(s,a),e.setEdge(r.v,r.w,{}),lu(e),iu(e,t),RK(e,t)}function RK(e,t){let n=e.nodes().find(s=>!e.node(s).parent);if(!n)return;let r=$K(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 OK(e,t,n){return e.hasEdge(t,n)}function yh(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var BK=zK;function zK(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":vh(e);break;case"tight-tree":jK(e);break;case"longest-path":FK(e);break;case"none":break;default:vh(e)}}var FK=au;function jK(e){au(e),pw(e)}function vh(e){LK(e)}var HK=VK;function VK(e){let t=UK(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),s=r.edgeObj,a=qK(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 qK(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(ci).forEach(r),t}function QK(e){let t=Kr(e,"root",{},"_root"),n=GK(e),r=Object.values(n),s=Qt(Math.max,r)-1,a=2*s+1;e.graph().nestingRoot=t,e.edges().forEach(l=>e.edge(l).minlen*=a);let i=KK(e)+1;e.children(ci).forEach(l=>xw(e,t,a,i,s,n,l)),e.graph().nodeRankFactor=a}function xw(e,t,n,r,s,a,i){var l;let c=e.children(i);if(!c.length){i!==t&&e.setEdge(t,i,{weight:0,minlen:n});return}let d=bh(e,"_bt"),f=bh(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;xw(e,t,n,r,s,a,h);let g=e.node(h),b=g.borderTop?g.borderTop:h,x=g.borderBottom?g.borderBottom:h,y=g.borderTop?r:2*r,w=b!==x?1:s-((m=a[i])!=null?m:0)+1;e.setEdge(d,b,{weight:y,minlen:w,nestingEdge:!0}),e.setEdge(x,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 GK(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(ci).forEach(r=>n(r,1)),t}function KK(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function WK(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var YK=ZK;function ZK(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)wh(e,"borderLeft","_bl",n,s,a),wh(e,"borderRight","_br",n,s,a)}}e.children(ci).forEach(t)}function wh(e,t,n,r,s,a){let i={width:0,height:0,rank:a,borderType:t},l=s[t][a-1],c=Kr(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")&&yw(e)}function JK(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&eW(e),(n==="lr"||n==="rl")&&(tW(e),yw(e))}function yw(e){e.nodes().forEach(t=>Nh(e.node(t))),e.edges().forEach(t=>Nh(e.edge(t)))}function Nh(e){let t=e.width;e.width=e.height,e.height=t}function eW(e){e.nodes().forEach(t=>cl(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(cl),Object.hasOwn(r,"y")&&cl(r)})}function cl(e){e.y=-e.y}function tW(e){e.nodes().forEach(t=>dl(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(dl),Object.hasOwn(r,"x")&&dl(r)})}function dl(e){let t=e.x;e.x=e.y,e.y=t}function nW(e){let t={},n=e.nodes().filter(l=>!e.children(l).length),r=n.map(l=>e.node(l).rank),s=Qt(Math.max,r),a=Ro(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 rW(e,t){let n=0;for(let r=1;r<t.length;++r)n+=oW(e,t[r-1],t[r]);return n}function oW(e,t,n){let r=pK(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 sW(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 aW(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 iW(r)}function iW(e){let t=[];function n(s){return a=>{a.merged||(a.barycenter===void 0||s.barycenter===void 0||a.barycenter>=s.barycenter)&&lW(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=>ya(s,["vs","i","barycenter","weight"]))}function lW(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 cW(e,t){let n=dK(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(dW(!!t)),c=kh(a,s,c),r.forEach(f=>{c+=f.vs.length,a.push(f.vs),i+=f.barycenter*f.weight,l+=f.weight,c=kh(a,s,c)});let d={vs:a.flat(1)};return l&&(d.barycenter=i/l,d.weight=l),d}function kh(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 dW(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}function vw(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=sW(e,s);d.forEach(h=>{if(e.children(h.v).length){let m=vw(e,h.v,n,r);c[h.v]=m,Object.hasOwn(m,"barycenter")&&pW(h,m)}});let f=aW(d,n);uW(f,c);let p=cW(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 uW(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function pW(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 fW(e,t,n,r){r||(r=e.nodes());let s=hW(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 hW(e){let t;for(;e.hasNode(t=su("_root")););return t}function mW(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 ww(e,t={}){if(typeof t.customOrder=="function"){t.customOrder(e,ww);return}let n=cw(e),r=Sh(e,Ro(1,n+1),"inEdges"),s=Sh(e,Ro(n-1,-1,-1),"outEdges"),a=nW(e);if(Ch(e,a),t.disableOptimalOrderHeuristic)return;let i=Number.POSITIVE_INFINITY,l,c=t.constraints||[];for(let d=0,f=0;f<4;++d,++f){gW(d%2?r:s,d%4>=2,c),a=rs(e);let p=rW(e,a);p<i?(f=0,l=Object.assign({},a),i=p):p===i&&(l=structuredClone(a))}Ch(e,l)}function Sh(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 fW(e,a,n,r.get(a)||[])})}function gW(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=vw(s,a,r,t);i.vs.forEach((l,c)=>s.node(l).order=c),mW(s,r,i.vs)})}function Ch(e,t){Object.values(t).forEach(n=>n.forEach((r,s)=>e.node(r).order=s))}function bW(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=yW(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)&&Nw(n,x,g)})}),l=p+1,i=m)}),a}return t.length&&t.reduce(r),n}function xW(e,t){let n={};function r(a,i,l,c,d){Ro(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)&&Nw(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 yW(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function Nw(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 vW(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 wW(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&&!vW(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 NW(e,t,n,r,s=!1){let a={},i=kW(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 kW(e,t,n,r){let s=new It,a=e.graph(),i=IW(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 SW(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=AW(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 CW(e,t){let n=Object.values(t),r=Qt(Math.min,n),s=Qt(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-Qt(Math.min,d);i!=="l"&&(f=s-Qt(Math.max,d)),f&&(e[l]=li(c,p=>p+f))})})}function MW(e,t=void 0){let n=e.ul;return n?li(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 EW(e){let t=rs(e),n=Object.assign(bW(e,t),xW(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=wW(e,s,n,f=>(i==="u"?e.predecessors(f):e.successors(f))||[]),d=NW(e,s,c.root,c.align,l==="r");l==="r"&&(d=li(d,f=>-f)),r[i+l]=d})});let a=SW(e,r);return CW(r,a),MW(r,e.graph().align)}function IW(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 AW(e,t){return e.node(t).width}function PW(e){e=iw(e),_W(e),Object.entries(EW(e)).forEach(([t,n])=>e.node(t).x=n)}function _W(e){let t=rs(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 $W(e,t={}){let n=t.debugTiming?dw:uw;return n("layout",()=>{let r=n(" buildLayoutGraph",()=>HW(e));return n(" runLayout",()=>DW(r,n,t)),n(" updateInputGraph",()=>LW(e,r)),r})}function DW(e,t,n){t(" makeSpaceForEdgeLabels",()=>VW(e)),t(" removeSelfEdges",()=>XW(e)),t(" acyclic",()=>NK(e)),t(" nestingGraph.run",()=>QK(e)),t(" rank",()=>BK(iw(e))),t(" injectEdgeLabelProxies",()=>qW(e)),t(" removeEmptyRanks",()=>lK(e)),t(" nestingGraph.cleanup",()=>WK(e)),t(" normalizeRanks",()=>iK(e)),t(" assignRankMinMax",()=>UW(e)),t(" removeEdgeLabelProxies",()=>QW(e)),t(" normalize.run",()=>CK(e)),t(" parentDummyChains",()=>HK(e)),t(" addBorderSegments",()=>YK(e)),t(" order",()=>ww(e,n)),t(" insertSelfEdges",()=>JW(e)),t(" adjustCoordinateSystem",()=>XK(e)),t(" position",()=>PW(e)),t(" positionSelfEdges",()=>eY(e)),t(" removeBorderNodes",()=>ZW(e)),t(" normalize.undo",()=>EK(e)),t(" fixupEdgeLabelCoords",()=>WW(e)),t(" undoCoordinateSystem",()=>JK(e)),t(" translateGraph",()=>GW(e)),t(" assignNodeIntersects",()=>KW(e)),t(" reversePoints",()=>YW(e)),t(" acyclic.undo",()=>SK(e))}function LW(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 TW=["nodesep","edgesep","ranksep","marginx","marginy"],RW={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},OW=["acyclicer","ranker","rankdir","align","rankalign"],BW=["width","height","rank"],Mh={width:0,height:0},zW=["minlen","weight","width","height","labeloffset"],FW={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},jW=["labelpos"];function HW(e){let t=new It({multigraph:!0,compound:!0}),n=pl(e.graph());return t.setGraph(Object.assign({},RW,ul(n,TW),ya(n,OW))),e.nodes().forEach(r=>{let s=pl(e.node(r)),a=ul(s,BW);Object.keys(Mh).forEach(l=>{a[l]===void 0&&(a[l]=Mh[l])}),t.setNode(r,a);let i=e.parent(r);i!==void 0&&t.setParent(r,i)}),e.edges().forEach(r=>{let s=pl(e.edge(r));t.setEdge(r,Object.assign({},FW,ul(s,zW),ya(s,jW)))}),t}function VW(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 qW(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};Kr(e,"edge-proxy",s,"_ep")}})}function UW(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 QW(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 GW(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 KW(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(gh(r,a)),n.points.push(gh(s,i))})}function WW(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 YW(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function ZW(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 XW(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 JW(e){rs(e).forEach(t=>{let n=0;t.forEach((r,s)=>{let a=e.node(r);a.order=s+n,(a.selfEdges||[]).forEach(i=>{Kr(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 eY(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 ul(e,t){return li(ya(e,t),Number)}function pl(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}function tY(e){let t=rs(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 nY={graphlib:X1,version:fK,layout:$W,debug:tY,util:{time:dw,notime:uw}},Eh=nY;/*! For license information please see dagre.esm.js.LEGAL.txt */function rY({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=q(E=>{E.stopPropagation(),m?.()},[m]),v=q(E=>{E.stopPropagation(),g?.()},[g]),N=q(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(An,{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(P=>!P.includes(":"));return u("div",{className:"text-[9px] text-muted-foreground mb-1 space-y-0.5",title:[c,...d].filter(Boolean).join(", "),children:[c&&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(ft,{className:"h-2.5 w-2.5"}),f,"%"]}),u("span",{className:"flex items-center gap-0.5",children:[o(Td,{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(Nt,{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(rt,{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(yt,{className:"h-3 w-3"})})]})]}),!n&&o("div",{className:"text-[10px] text-muted-foreground",children:"offline"}),o(An,{type:"source",position:we.Bottom,className:"!bg-border !w-2 !h-2"})]})}const oY=He(rY);function sY(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 aY({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=q(E=>{E.stopPropagation(),d?.()},[d]),N=g?un:za,k=g?"border-primary/50":m?"border-amber-500/50":"border-destructive/50",C=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(An,{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 ${C} shrink-0 mt-0.5`}),o("span",{className:"text-[10px] font-semibold truncate flex-1",children:g?"core":i??t}),o("span",{className:"text-[8px] text-muted-foreground/60 tabular-nums shrink-0",children:r})]}),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(ft,{className:"h-2 w-2"}),s,"%"]}),u("span",{className:"flex items-center gap-0.5",children:[o(Td,{className:"h-2 w-2"}),sY(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(rt,{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(yt,{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(Nt,{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 P=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(rt,{className:"h-2.5 w-2.5"})}),o("button",{onClick:I=>{I.stopPropagation(),h?.(E.addonId,P)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Restart: ${E.addonId}`,children:o(yt,{className:"h-2.5 w-2.5"})})]},E.addonId)})}),o(An,{type:"source",position:we.Bottom,className:`!w-1.5 !h-1.5 ${g?"!bg-primary":"!bg-amber-500"}`})]})}const iY=He(aY),lY={clusterNode:oY,processNode:iY},br={cluster:{width:320,height:170},process:{width:240,height:100},processExpanded:{width:240,height:240}};function cY(e){return typeof e=="object"&&e!==null&&typeof e.x=="number"&&typeof e.y=="number"}function dY(e,t){const n=new Eh.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"?br.cluster:a?br.processExpanded:br.process;n.setNode(s.id,{width:i.width,height:i.height})}for(const s of t)n.setEdge(s.source,s.target);Eh.layout(n);const r=new Map;for(const s of e){const a=n.node(s.id);if(!cY(a))continue;const i=s.type==="processNode"&&!!s.data?.isExpanded,l=s.type==="clusterNode"?br.cluster:i?br.processExpanded:br.process;r.set(s.id,{x:a.x-l.width/2,y:a.y-l.height/2})}return r}function uY({topology:e}){const{resolvedMode:t}=Br(),n=nx(),r=Aa(),[,s]=_(null),[a,i]=_(()=>e.length<=1?new Set(e.map(E=>E.id)):new Set),[l,c]=_(null),[d,f]=_(null),p=q((E,P)=>{f(I=>I?.addonId===E&&I?.agentId===P?null:{addonId:E,agentId:P})},[]),h=q(E=>{f(P=>P?.agentId===E&&!P?.addonId?null:{agentId:E})},[]),m=q(async E=>{try{await n.mutateAsync({nodeId:E})}catch(P){console.error("Failed to restart node:",P)}},[n]),g=q(async(E,P)=>{try{await r.mutateAsync({nodeId:P,addonId:E})}catch(I){console.error("Failed to restart addon:",I)}},[r]),b=q(E=>{i(P=>{const I=new Set(P);return I.has(E)?I.delete(E):I.add(E),I})},[]),x=q(E=>{c(P=>P===E?null:E)},[]),y=q(E=>{s(E)},[]),w=Q(()=>{const E=e.filter(M=>M.isHub),P=e.filter(M=>!M.isHub),I=[],z=[],A=E[0]?.id;function O(M,D){const L=[...D];if(L.length!==0)for(const T of L){const B=`proc:${M}/${T.name}`,F=T.services??[],j=l===B;I.push({id:B,type:"processNode",position:{x:0,y:0},data:{...T,addonId:T.name.includes("(core)")?void 0:F.length>1?T.name:F[0]?.addonId??T.name,parentNodeId:M,services:F,isExpanded:j,onToggleServices:()=>x(B),onShowLogs:p,onRestartAddon:g}}),z.push({id:`edge:${M}-${B}`,source:M,target:B,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)&&O(M.id,M.processes??[]);for(const M of P)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&&M.isOnline&&z.push({id:`${A}-${M.id}`,source:A,target:M.id,animated:!0,style:{stroke:"var(--border)",strokeWidth:1.5}}),a.has(M.id)&&O(M.id,M.processes??[]);const R=dY(I,z);for(const M of I){const D=R.get(M.id);D&&(M.position=D)}return{nodes:I,edges:z}},[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=q(E=>{for(const P of E)P.type==="position"&&P.position&&v.current.set(P.id,P.position)},[]),C=q(()=>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(sG,{nodes:N,edges:w.edges,onNodesChange:k,onPaneClick:C,nodeTypes:lY,nodesConnectable:!1,fitView:!0,fitViewOptions:{padding:.2,maxZoom:1.2},proOptions:{hideAttribution:!0},className:"bg-background",colorMode:t,children:[o(dG,{gap:20,size:1}),o(bG,{showInteractive:!1})]}),d&&o(Py,{addonId:d.addonId,agentId:d.agentId,showScope:!0,onClose:()=>f(null)})]})})}function pY({onlineNodeIds:e}){const t=ke(),n=Je(),{data:r,isLoading:s}=Hr(),a=Ex({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(Tl,{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(Tl,{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(Ke,{className:"h-3 w-3"}),"Remove"]})]},c.nodeId)})})]})}function fY(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 hY(){const{data:e,isLoading:t}=Tn(void 0,{staleTime:1/0}),[n,r]=_(null);return pt("cluster.topology-snapshot",a=>{const i=a.data?.nodes;Array.isArray(i)&&r(i)}),{nodes:Q(()=>n??e??[],[n,e]),isLoading:t&&!n}}function mY(){const[e,t]=_("diagram"),n=fY("(max-width: 767px)"),r=n&&e==="diagram"?"table":e,{nodes:s,isLoading:a}=hY(),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}=Hr(),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",En),p("table","Table",V6),p("offline-agents","Offline agents",Tl,f)]})]}),a?o("div",{className:"flex items-center justify-center flex-1 text-muted-foreground",children:"Loading cluster topology..."}):r==="diagram"?o(uY,{topology:s}):r==="table"?o("div",{className:"flex-1 overflow-auto",children:o(kF,{nodes:s})}):o("div",{className:"flex-1 overflow-auto",children:o(pY,{onlineNodeIds:c})})]})}function on({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 tt({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 gY={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 bY(){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(on,{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(on,{title:"Colors",children:u("div",{className:"flex flex-wrap gap-4",children:[o(tt,{name:"primary",cssVar:"--color-primary"}),o(tt,{name:"background",cssVar:"--color-background"}),o(tt,{name:"surface",cssVar:"--color-surface"}),o(tt,{name:"foreground",cssVar:"--color-foreground"}),o(tt,{name:"success",cssVar:"--color-success"}),o(tt,{name:"warning",cssVar:"--color-warning"}),o(tt,{name:"danger",cssVar:"--color-danger"}),o(tt,{name:"info",cssVar:"--color-info"}),o(tt,{name:"border",cssVar:"--color-border"}),o("div",{className:"w-px"}),o(tt,{name:"frigate",hex:"#3b82f6"}),o(tt,{name:"scrypted",hex:"#a855f7"}),o(tt,{name:"reolink",hex:"#06b6d4"}),o(tt,{name:"ha",hex:"#22d3ee"}),o(tt,{name:"rtsp",hex:"#78716c"})]})}),o(on,{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(on,{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(xY,{})]})}),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(on,{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(Ua,{status:n},n))})]}),u("div",{children:[o("p",{className:"text-xs text-foreground-subtle mb-2",children:"CapabilityBadges"}),o(Va,{capabilities:["streaming","detection","recording","audio"]})]})]})}),o(on,{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(on,{title:"Provider Icons",children:o("div",{className:"flex flex-wrap gap-4",children:["frigate","scrypted","reolink","homeassistant","rtsp","onvif"].map(n=>o(fn,{type:n,size:"lg",showLabel:!0},n))})}),u(on,{title:"Form Builder Demo",children:[o(In,{schema:gY,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(on,{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 xY(){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 Ih={info:{bg:"bg-blue-500/10",border:"border-blue-500/30",icon:Jn},warning:{bg:"bg-orange-500/10",border:"border-orange-500/30",icon:ut},critical:{bg:"bg-red-500/10",border:"border-red-500/30",icon:Xn}};function yY({toast:e,onDismiss:t}){const n=Ih[e.severity]??Ih.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(ze,{className:"h-3.5 w-3.5 text-foreground-subtle"})})]})}function vY(){const[e,t]=_([]),n=q(r=>{t(s=>s.filter(a=>a.id!==r))},[]);return Jx(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(yY,{toast:r,onDismiss:n})},r.id))})}const dc=new Th({defaultOptions:{queries:{staleTime:3e4,retry:!1,refetchOnWindowFocus:!1}}});function wY({field:e,value:t,onChange:n,disabled:r}){return o(aO,{field:e,value:t,onChange:n,disabled:r})}function NY({field:e,value:t,onChange:n,disabled:r}){return o(gO,{field:e,value:t,onChange:n,disabled:r})}const kY={"zone-editor":fT,"live-stats":mT,"pipeline-editor":wY,"model-selector":NY,"live-stream-viewer":xO,"pipeline-stats":yO,"stream-network-stats":vO,"doorbell-recent":NO,"device-info":C0};function SY({children:e}){const{user:t}=Jt(),[n,r]=_(0),s=ne(t?.username??null);Y(()=>{const p=t?.username??null;p!==s.current&&(s.current=p,yr(),r(h=>h+1))},[t]);const a=Q(()=>Bs(),[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=q(()=>{yr(),r(p=>p+1),dc.invalidateQueries()},[]);return lT(f),o(Tc,{system:a,children:o(S.Provider,{client:a.trpcClient,queryClient:dc,children:u(my,{children:[i?e:o(CY,{}),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 CY(){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 MY(){return o(Us,{defaultMode:"dark",children:o(Rh,{client:dc,children:o(zO,{children:o(SY,{children:o(gg,{children:u(Rg,{renderers:kY,children:[o(ZL,{children:u(ML,{children:[o(Le,{path:"/login",element:o(H8,{})}),o(Le,{path:"/change-password",element:o(At,{children:o(q8,{})})}),o(Le,{path:"/showroom",element:o(bY,{})}),u(Le,{element:o(At,{children:o(j8,{})}),children:[o(Le,{index:!0,element:o(xt,{to:"/dashboard",replace:!0})}),o(Le,{path:"/access-denied",element:o(U8,{})}),o(Le,{path:"/dashboard",element:o(n9,{})}),o(Le,{path:"/devices",element:o(r9,{})}),o(Le,{path:"/cameras",element:o(xt,{to:"/devices",replace:!0})}),o(Le,{path:"/integrations",element:o(h9,{})}),o(Le,{path:"/integrations/:integrationId",element:o(b9,{})}),o(Le,{path:"/timeline",element:o(E9,{})}),o(Le,{path:"/pipeline",element:o(l7,{})}),o(Le,{path:"/devices/:deviceId",element:o(iB,{})}),o(Le,{path:"/system/logs",element:o(At,{requireAdmin:!0,children:o(SB,{})})}),o(Le,{path:"/system/addons",element:o(At,{requireAdmin:!0,children:o(xB,{})})}),o(Le,{path:"/system/settings",element:o(At,{requireAdmin:!0,children:o(iF,{})})}),o(Le,{path:"/system/cluster",element:o(At,{requireAdmin:!0,children:o(mY,{})})}),o(Le,{path:"/system/identity",element:o(At,{requireAdmin:!0,children:o(jB,{})})}),o(Le,{path:"/system/my-access",element:o(wB,{})}),o(Le,{path:"/system/network",element:o(At,{requireAdmin:!0,children:o(sz,{})})}),o(Le,{path:"/system/integrations",element:o(At,{requireAdmin:!0,children:o(yz,{})})}),o(Le,{path:"/system/data",element:o(At,{requireAdmin:!0,children:o(aF,{})})}),o(Le,{path:"/system/users",element:o(xt,{to:"/system/identity?tab=users",replace:!0})}),o(Le,{path:"/system/api-keys",element:o(xt,{to:"/system/identity?tab=api-keys",replace:!0})}),o(Le,{path:"/system/authentication",element:o(xt,{to:"/system/identity?tab=authentication",replace:!0})}),o(Le,{path:"/system/remote-access",element:o(xt,{to:"/system/network?tab=remote-access",replace:!0})}),o(Le,{path:"/system/turn",element:o(xt,{to:"/system/network?tab=turn",replace:!0})}),o(Le,{path:"/system/storage",element:o(xt,{to:"/system/data?tab=storage",replace:!0})}),o(Le,{path:"/system/backup",element:o(xt,{to:"/system/data?tab=backup",replace:!0})}),o(Le,{path:"/addon/:pagePath",element:o(At,{requireAdmin:!0,children:o(B8,{})})})]})]})}),o(vY,{})]})})})})})})}const EY={dashboard:"Dashboard",integrations:"Integrations",metrics:"Metrics"},IY={title:"System",addons:"Addons",agents:"Agents",processes:"Processes",logs:"Logs",users:"Users",settings:"Settings",repl:"REPL",models:"Models",integrations:"Integrations"},AY={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"},PY={disconnected:"Server unreachable — reconnecting…",connected:"Connected"},_Y={online:"Online",offline:"Offline",connecting:"Connecting",error:"Error",disabled:"Disabled",enabled:"Enabled",active:"Active",inactive:"Inactive",running:"Running",stopped:"Stopped",pending:"Pending",unknown:"Unknown"},$Y={login:"Login",logout:"Logout",username:"Username",password:"Password",signIn:"Sign In",invalidCredentials:"Invalid username or password"},DY={dark:"Dark",light:"Light",system:"System"},LY={select:"Language",en:"English",it:"Italian"},TY={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"}},RY={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"},OY={nav:EY,system:IY,common:AY,connection:PY,status:_Y,auth:$Y,theme:DY,language:LY,pages:TY,integrations:RY},BY={dashboard:"Dashboard",integrations:"Integrazioni",metrics:"Metriche"},zY={title:"Sistema",addons:"Addon",agents:"Agenti",processes:"Processi",logs:"Log",users:"Utenti",settings:"Impostazioni",repl:"REPL",models:"Modelli",integrations:"Integrazioni"},FY={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"},jY={disconnected:"Server non raggiungibile — riconnessione in corso…",connected:"Connesso"},HY={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"},VY={login:"Accesso",logout:"Esci",username:"Nome utente",password:"Password",signIn:"Accedi",invalidCredentials:"Nome utente o password non validi"},qY={dark:"Scuro",light:"Chiaro",system:"Sistema"},UY={select:"Lingua",en:"Inglese",it:"Italiano"},QY={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"}},GY={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"},KY={nav:BY,system:zY,common:FY,connection:jY,status:HY,auth:VY,theme:qY,language:UY,pages:QY,integrations:GY},kw="camstack_language",WY=localStorage.getItem(kw)??"en";Ze.use(y8).init({resources:{en:{translation:OY},it:{translation:KY}},lng:WY,fallbackLng:"en",interpolation:{escapeValue:!1}});Ze.on("languageChanged",e=>{localStorage.setItem(kw,e)});window.__camstackUiLibrary=CD;window.__camstackSdk=zN;window.__camstackTypes=jN;Dh(document.getElementById("root")).render(o(EN,{children:o(MY,{})}));